mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-08-23 14:46:59 +00:00
Build and push containers / metadata (push) Has been cancelled
Build and push containers / build-push-containers (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Has been cancelled
ChangeDetection.io App Test / lint-code (push) Has been cancelled
ChangeDetection.io App Test / lint-translations (push) Has been cancelled
ChangeDetection.io App Test / lint-template-i18n (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Test the built package works basically. (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-10 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-11 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-12 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-13 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-14 (push) Has been cancelled
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
// "More" overflow menu (the kebab button in the top menu). Toggles its sibling
|
|
// .menu-pop open/closed; closes on click-outside, Escape, or selecting an item.
|
|
(function () {
|
|
'use strict';
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const toggles = Array.prototype.slice.call(document.querySelectorAll('.js-menu-more-toggle'));
|
|
if (!toggles.length) return;
|
|
|
|
function closeAll() {
|
|
document.querySelectorAll('.menu-pop.open').forEach(function (pop) {
|
|
pop.classList.remove('open');
|
|
});
|
|
toggles.forEach(function (t) { t.setAttribute('aria-expanded', 'false'); });
|
|
}
|
|
|
|
toggles.forEach(function (toggle) {
|
|
const pop = toggle.parentElement.querySelector('.menu-pop');
|
|
if (!pop) return;
|
|
|
|
toggle.addEventListener('click', function (e) {
|
|
e.stopPropagation();
|
|
const willOpen = !pop.classList.contains('open');
|
|
closeAll();
|
|
if (willOpen) {
|
|
pop.classList.add('open');
|
|
toggle.setAttribute('aria-expanded', 'true');
|
|
}
|
|
});
|
|
|
|
// Selecting an item dismisses the menu (the item's own action still runs).
|
|
pop.querySelectorAll('.mi').forEach(function (item) {
|
|
item.addEventListener('click', closeAll);
|
|
});
|
|
});
|
|
|
|
// Click outside / Escape closes any open popup.
|
|
document.addEventListener('click', function (e) {
|
|
if (!e.target.closest('.menu-pop-wrap')) closeAll();
|
|
});
|
|
document.addEventListener('keydown', function (e) {
|
|
if (e.key === 'Escape') closeAll();
|
|
});
|
|
});
|
|
})();
|