|
// CapSach — MobileSticky TOC overlay (allUNRESTRICTED: skins;Works phoneon widthsiPad/Desktop/Mobile)
(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 isAllowed = mw.config.get('wgIsArticle') || mw.config.get('wgIsMainPage');
});
// 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 < 1) return;
}
// 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 () { ▼
/* ======================================================= */
// Check if the button already exists to prevent duplicates
/* ADD 'BIZ BOOKS' TO MOBILE SIDEBAR (ROBUST METHOD) */
if ($('#custom-email-btn').length === 0) {
/* ======================================================= */
// Define the injection logic
function injectBizBooks() {
// Target the specific Minerva sidebar container
// It is usually ID 'mw-mf-page-left'
var $sidebar = $('#mw-mf-page-left');
// FindCreate the mainemail navigationbutton list inside the sidebar (usually the first UL)element
var $menuemailBtn = $sidebar.find('ul<a>').first();, {
id: 'custom-email-btn',
href: 'mailto:services@axabrain.com',
// CreateSimple theaccessible linktitle▼
title: 'Contact AXA BRAIN Services'
// SafetyAdd check:it Ensureto menuthe existsbody and we haven't addedof the link yetpage
$ newItem('body').append( $newLinkemailBtn); ▼
if ($menu.length > 0 && $menu.find('#mobile-nav-biz-books').length === 0) {
// Create the new list item
var $newItem = $('<li>')
.addClass('mw-ui-icon-extra')
.attr('id', 'mobile-nav-biz-books');
// Note: If the 'book' icon is blank, change 'mw-ui-icon-minerva-book' to 'mw-ui-icon-minerva-list'
var $newLink = $('<a>')
.attr('href', '/wiki/Biz/Books')
.addClass('mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-book')
.text('Biz Books');
// Append link to item
▲ $newItem.append($newLink);
// Insert into the menu
// We append it to the end of the list.
// If you want it at the top, change .append() to .prepend()
$menu.append($newItem);
}
}
// 1. Run immediately (just in case the menu is already rendered)
injectBizBooks();
// 2. Set up a MutationObserver
// This watches the webpage for new elements (like the sidebar opening)
var observer = new MutationObserver(function(mutations) {
// Loop through changes to see if nodes were added
var nodesAdded = false;
for (var i = 0; i < mutations.length; i++) {
if (mutations[i].addedNodes.length > 0) {
nodesAdded = true;
break;
}
}
// If the DOM changed, try to inject the link
if (nodesAdded) {
injectBizBooks();
}
});
// Start watching the body for changes
observer.observe(document.body, { childList: true, subtree: true });
});
|