MediaWiki:Mobile.js: Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1:
// 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');
Line 31:
});
 
// 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;
 
Line 95 ⟶ 96:
}
 
// 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);
 
Line 146 ⟶ 148:
});
 
// 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 });
})();
 
/* ======================================================= */
/* FLOATING TOC: CLICK TITLE TO SCROLL TO TOP */
/* ======================================================= */
$(document).ready(function() {
// Check if the button already exists to prevent duplicates
// Listen for clicks on the TOC title
if ($(document).on('click', '#cpscustom-tocemail-titlebtn',).length function(=== 0) {
// 1. Scroll toCreate the top of theemail pagebutton smoothlyelement
window.scrollTo({var top:emailBtn 0, behavior:= $('smooth<a>', });{
id: 'custom-email-btn',
href: 'mailto:services@axabrain.com',
// 2. OPTIONAL: Uncomment the line below if you also
// want the TOC menu to close// automaticallySimple afteraccessible clicking.title
title: 'Contact AXA BRAIN Services'
// $('#cps-toc-overlay').removeClass('is-open');
});
 
// Add it to the body of the page
$('body').append(emailBtn);
} else {
});