|
// 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() {
/* ======================================================= */
// 3. Check if linkthe button already exists to prevent duplicates▼
/* ADD 'BIZ BOOKS' TO MOBILE SIDEBAR (BRUTE FORCE METHOD) */
if ($('#custom-email-btn').length === 0) {
/* ======================================================= */
mw.loader.using( 'mobile.startup', function () {
$( function () {
// DefineCreate the functionemail thatbutton inserts the linkelement
functionvar insertCustomLinkemailBtn = $()'<a>', {
//id: 1. Find the sidebar drawer'custom-email-btn',
var $drawer = $(href: '#mw-mf-page-leftmailto:services@axabrain.com' );,
if// (Simple $drawer.lengthaccessible === 0 ) return false;title
title: 'Contact AXA BRAIN Services'
// 2.Add Findit to the navigation list (First ULbody insideof the drawer)page
var $menu = $drawer.find( 'ulbody' ).firstappend(emailBtn);
if ( $menu.length === 0 ) return false;
▲ // 3. Check if link already exists
if ( $menu.find( '#mobile-nav-biz-books' ).length > 0 ) return true;
console.log( 'BizSlash Debug: Menu found. Inserting link...' );
// 4. Create the List Item
var $newItem = $( '<li>' )
.addClass( 'mw-ui-icon-extra' )
.attr( 'id', 'mobile-nav-biz-books' );
// 5. Create the Link
// We use 'mw-ui-icon-minerva-home' first because we KNOW it exists.
// We also add a temporary red border to ensure you can see it.
var $newLink = $( '<a>' )
.attr( 'href', '/wiki/Biz/Books' )
.addClass( 'mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-home' )
.text( 'Biz Books' )
.css( 'border', '1px solid red' ); // DEBUG STYLE: Remove this line later
$newItem.append( $newLink );
// 6. Prepend to put it at the TOP, Append for BOTTOM
$menu.append( $newItem );
return true;
}
// Run once on load (for some skins that preload the menu)
insertCustomLink();
// LISTEN FOR CLICK on the Hamburger Button
$( 'body' ).on( 'click', '.mw-ui-icon-minerva-mainmenu', function() {
console.log( 'BizSlash Debug: Hamburger clicked. Starting search...' );
// Retry every 50ms for 2 seconds (handles lazy loading)
var attempts = 0;
var poller = setInterval( function() {
var success = insertCustomLink();
attempts++;
// Stop if successful or after 40 attempts (2 seconds)
if ( success || attempts > 40 ) {
clearInterval( poller );
}
}, 50 );
});
});
|