MediaWiki:Mobile.js: Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
 
(16 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 isArticleisAllowed = !!mw.config.get('wgIsArticle') || mw.config.get('wgIsMainPage');
if (!isArticleisAllowed) return;
}
 
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 < 31) return;
 
// Create trigger button (bottom-left; avoids “Back to top” on bottom-right)
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 });
})();
 
setTimeout$(document).ready(function () {
// === Auto-expand all H2 sections on mobile ===
// Check if the button already exists to prevent duplicates
mw.loader.using('mediawiki.util', function () {
if ($('#custom-email-btn').length === 0) {
// Run only on mobile skins
} else {
var skin = mw.config.get('skin');
// Create the email button element
if (skin === 'minerva' || (skin === 'vector-2022' && window.innerWidth < 720)) {
var $headingemailBtn = $(this);'<a>', {
id: 'custom-email-btn',
// Delay to ensure DOM ready
href: 'mailto:services@axabrain.com',
mw.hook('wikipage.content').add(function ($content) {
// Simple accessible title
// Expand all section headers that are collapsed
title: 'Contact AXA BRAIN Services'
setTimeout(function () {
// Target collapsible H2s in mobile
$content.find('.section-heading, .mf-section-heading, .vector-section-heading').each(function () {
var $heading = $(this);
// Simulate click if section collapsed
if ($heading.hasClass('collapsible-heading') || $heading.hasClass('collapsible-heading-collapsed')) {
$heading.trigger('click');
}
});
 
}, 500);
// Add it to the body of the page
});
$('body').append(emailBtn);
}
}
});