Server IP : 85.214.239.14 / Your IP : 216.73.216.179 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/wordpress/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;