Skip to content

Instantly share code, notes, and snippets.

@hkitago
Created November 11, 2024 01:28
Show Gist options
  • Save hkitago/b7551b8d79f3506c478141b5f7b0c2a1 to your computer and use it in GitHub Desktop.
Save hkitago/b7551b8d79f3506c478141b5f7b0c2a1 to your computer and use it in GitHub Desktop.
Popover for the browser extension with auto-close func
/*
import { labelStrings, getCurrentLangCode } from './localization.js';
const langCode = getCurrentLangCode();
*/
/* Global variables */
const closeWindowTime = 1500;
let closeTimeout;
/* Rendering */
document.addEventListener('DOMContentLoaded', async () => {
if (navigator.userAgent.indexOf('iPhone') > -1) {
document.body.style.width = 'initial';
}
/*
if (langCode.substring(0, 2) === 'ar' || langCode.substring(0, 2) === 'he') {
document.body.classList.add('rtl');
document.documentElement.setAttribute('lang', langCode.substring(0, 2));
document.documentElement.setAttribute('dir', 'rtl');
}
*/
document.body.addEventListener('mouseleave', () => {
closeTimeout = setTimeout(() => {
closeWindow();
}, closeWindowTime);
});
document.body.addEventListener('mouseenter', () => {
if (closeTimeout) {
clearTimeout(closeTimeout);
closeTimeout = null;
}
});
const header = document.querySelector('header');
const main = document.querySelector('main');
const footer = document.querySelector('footer');
const initializePopupPage = () => {};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment