| Server IP : 62.60.133.156 / Your IP : 216.73.217.51 Web Server : LiteSpeed System : Linux linux24.centraldnserver.com 4.18.0-553.141.2.lve.el8.x86_64 #1 SMP Wed Jul 8 16:10:02 UTC 2026 x86_64 User : mimradmin ( 1166) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, exec, popen, proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/cwd/wp-content/plugins/really-simple-ssl/settings/src/utils/ |
Upload File : |
// 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;