|
// CapSach — Sticky TOC overlay (UNRESTRICTED: Works on iPad/Desktop/Mobile)
/* All JavaScript here will be loaded for users of the mobile site */
/* Note, there is no corresponding User:Username/mobile.js; however users may use User:Username/minerva.js */
function addPortletLink() {
mw.log.warn('addPortletLink is deprecated on desktop and never implemented on mobile', 'More information on https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#addPortletLink');
}
// CapSach — Mobile TOC overlay (all skins; phone widths)
(function () {
// Don’t run on very wide screens (tablet/desktop have native TOC)
if// (window1.matchMedia('( REMOVED the "min-width: 768px)')" check.matches) return;Now runs everywhere.
// Only run on normalpages contentwhere pagesit makes sense (Articles/MainPage)
if (window.mw && mw.config && mw.config.get) {
var isArticleisAllowed = !!mw.config.get('wgIsArticle') || mw.config.get('wgIsMainPage');
if (!isArticleisAllowed) return;
}
});
// Show only if there are enough headings to be useful (match core default)
// CHANGED: Lowered requirement to 1 heading so it always shows if there is any structure
if (items.length < 3) return;
if (items.length < 1) return;
// Create trigger button (bottom-left; avoids “Back to top” on bottom-right)
}
// Force button display immediately
btn.style.display = 'flex'; // reveal trigger now that we know we have headings
btn.style.display = 'flex';
btn.addEventListener('click', openOverlay);
});
// 2. REMOVED the "resize" event listener that was hiding the button.
// Re-hide on rotation/resize to tablet/desktop
// The button now persists on all screen sizes.
window.addEventListener('resize', function () {
if (window.matchMedia('(min-width: 768px)').matches) {
btn.style.display = 'none';
closeOverlay();
} else {
btn.style.display = 'flex';
}
}, { passive: true });
})();
$(document).ready(function() {
// CapSach — force sections expanded on the MobileFrontend site (all mobile skins)
// Check if the button already exists to prevent duplicates
(function () {
if ($('#custom-email-btn').length === 0) {
// Only run on the MobileFrontend mobile site (works for Minerva, Vector, etc.)
var body = document.body;
// Create the email button element
if (!body || !body.classList.contains('mw-mf')) return; // detect mobile view reliably
var emailBtn = $('<a>', {
id: 'custom-email-btn',
href: 'mailto:services@axabrain.com',
// Simple accessible title
title: 'Contact AXA BRAIN Services'
});
// Add it to the body of the page
function togglesToOpen() {
var set = new Set$('body').append(emailBtn);
// Newer MF markup: <section aria-expanded="false"><h2 class="section-heading">…</h2>
document.querySelectorAll('section[aria-expanded="false"] > .section-heading')
.forEach(function (h) { set.add(h); });
// Classic MF markup: .collapsible-block (content) with a preceding heading toggle
document.querySelectorAll('.collapsible-block').forEach(function (block) {
if (block.classList.contains('open-block')) return; // already open
var prev = block.previousElementSibling;
if (prev && (prev.classList.contains('collapsible-heading') || prev.classList.contains('section-heading'))) {
set.add(prev);
}
});
// Fallback: any collapsed heading control that advertises its state
document.querySelectorAll('.section-heading[aria-expanded="false"]')
.forEach(function (h) { set.add(h); });
return Array.from(set);
}
function click(el) {
el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }));
}
function expandAll() {
togglesToOpen().forEach(click);
}
function init() {
expandAll();
// If MF re-renders content (after edits, previews, etc.), expand again
if (window.MutationObserver) {
var obs = new MutationObserver(function () {
var pending = togglesToOpen();
if (pending.length) pending.forEach(click);
});
obs.observe(document.getElementById('content') || document.body, {
subtree: true, childList: true, attributes: true, attributeFilter: ['class', 'aria-expanded']
});
}
});
}
// Wait for MobileFrontend startup, then run; also run on content refreshes
if (window.mw && mw.loader) {
mw.loader.using('mobile.startup').then(function () {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
if (mw.hook) mw.hook('wikipage.content').add(init);
});
} else {
// Very defensive fallback
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init); else init();
}
})();
|