Server IP : 15.235.198.142 / Your IP : 216.73.216.82 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/rhodeworks/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;