littlelink-extended/js/sensitive-content.js
Seth Cottle c99d8fd702 Updates
Adds Babylist as a new brand, fixes SimpleX Chat Alt, and adds a new sensitive content warning module (new HTML, new CSS file, new JS folder and file, new icon).
2025-03-16 20:59:47 -04:00

47 lines
No EOL
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

document.addEventListener('DOMContentLoaded', function () {
// 1) Check for slide-container
const containers = document.querySelectorAll('.slide-container');
containers.forEach((container) => {
// 2) Find the key elements inside this container
const trigger = container.querySelector('.sensitive-trigger');
const panel = container.querySelector('.sensitive-panel');
const continueBtn = container.querySelector('.sensitive-continue');
// 3) Read the URL from data-continue-url
const externalUrl = container.dataset.continueUrl;
// Safety checks: if we dont have a trigger or panel, skip
if (!trigger || !panel) return;
// 4) Toggle panel on trigger click
trigger.addEventListener('click', function (evt) {
evt.preventDefault();
panel.classList.toggle('open'); // open if closed, close if open
});
// 5) Close panel if user clicks outside
document.addEventListener('click', function (evt) {
if (
panel.classList.contains('open') &&
!panel.contains(evt.target) &&
evt.target !== trigger
) {
panel.classList.remove('open');
}
});
// 6) “Continue” button
if (continueBtn) {
continueBtn.addEventListener('click', function () {
// Close the panel
panel.classList.remove('open');
// If there's a data-continue-url, open it in a new tab
if (externalUrl) {
window.open(externalUrl, '_blank');
}
});
}
});
});