|
// 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();
▲ btn.style.display = 'flex';
}
}, { passive: true });
})();
$(document).ready(function() {
/* ======================================================= */
// Check if the button already exists to prevent duplicates
/* ADD 'BIZ BOOKS' TO MOBILE SIDEBAR (UNIVERSAL METHOD) */
if ($('#custom-email-btn').length === 0) {
/* ======================================================= */
mw.loader.using( ['mediawiki.util', 'jquery'], function () {
$( function () {
var// linkIdCreate the email =button 'mobile-nav-biz-books';element
var linkHrefemailBtn = $('/wiki/Biz/Books<a>';, {
var linkText = 'Biz Booksid: 'custom-email-btn';,
href: 'mailto:services@axabrain.com',
// Helper function to find the// correctSimple menuaccessible listtitle
title: 'Contact AXA BRAIN Services'
function findTargetMenu() {
// 1. Look for the standard Minerva menu class
var $lists = $( '.menu ul, .navigation-drawer ul' );
// 2. Filter to find the list that actually contains the "Home" or "Random" links
// This prevents us from injecting into the wrong list (like the user settings)
var $target = $lists.filter(function() {
// Look for links to Main_Page or Random inside this UL
return $(this).find('a[href*="Main_Page"], a[href*="Random"]').length > 0;
});
// If found, return the first match. If not, fallback to the first UL in the drawer.
return $target.length ? $target.first() : $lists.first();
}
function injectLink() {
var $menu = findTargetMenu();
// If no menu is found, or if our link already exists, stop.
if ( $menu.length === 0 || $menu.find( '#' + linkId ).length > 0 ) return;
console.log( 'BizSlash: Valid menu found. Injecting...' );
var $newItem = $( '<li>' )
.addClass( 'mw-ui-icon-extra' )
.attr( 'id', linkId );
var $newLink = $( '<a>' )
.attr( 'href', linkHref )
// We use 'mw-ui-icon-minerva-list' as a fallback icon because it exists in all versions
.addClass( 'mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-list' )
.text( linkText )
// Force visibility in case classes fail
.css({
'display': 'block',
'font-weight': 'bold'
});
$newItem.append( $newLink ); ▼
// PREPEND puts it at the TOP of the menu so you can't miss it
$menu.prepend( $newItem );
}
// 1. Run on load
injectLink();
// 2. Run whenever the drawer is opened (Click listener)
// We listen on the document body for clicks on the hamburger icon
$( 'body' ).on( 'click', '.mw-ui-icon-minerva-mainmenu, #mw-mf-main-menu-button', function() {
// Retry multiple times as the menu slides in
var count = 0;
var interval = setInterval(function() {
injectLink();
count++;
if (count > 20) clearInterval(interval); // Stop after 2 seconds
}, 100);
});
// 3.Add MutationObserverit (Theto Backup)the body of the page
▲ $ newItem('body').append( $newLink emailBtn);
// Watch for the drawer appearing in the DOM
var observer = new MutationObserver(function(mutations) {
injectLink();
});
// Start observing the body for added nodes
observer.observe(document.body, { childList: true, subtree: true });
} );
|