MediaWiki:Mobile.js: Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
 
(27 intermediate revisions by the same user not shown)
Line 1:
// CapSach — MobileSticky TOC overlay (allUNRESTRICTED: skins;Works phoneon widthsiPad/Desktop/Mobile)
/* All JavaScript here will be loaded for users of the mobile site */
/* Note, there is no corresponding User:Username/mobile.js; however users may use User:Username/minerva.js */
function addPortletLink() {
mw.log.warn('addPortletLink is deprecated on desktop and never implemented on mobile', 'More information on https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#addPortletLink');
}
// CapSach — Mobile TOC overlay (all skins; phone widths)
(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 36 ⟶ 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 100 ⟶ 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 151 ⟶ 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 });
})();
 
$(document).ready(function () {
// CapSach — expand all collapsed sections on the mobile site
// Check if the button already exists to prevent duplicates
(function () {
if ($('#custom-email-btn').length === 0) {
// Only run on the mobile site (Minerva/MobileFrontend)
} else {
if (document.body && !document.body.classList.contains('skin-minerva')) return;
// Create the email button element
var emailBtn = $('<a>', {
id: 'custom-email-btn',
href: 'mailto:services@axabrain.com',
// Simple accessible title
title: 'Contact AXA BRAIN Services'
});
 
// Add it to the body of the page
function expandAll() {
$('body').append(emailBtn);
// Heuristics that work across MF releases; safe to no-op if nothing matches
}
var headings = document.querySelectorAll(
})();
'.collapsible-block:not(.open-block) .section-heading,' +
'section[aria-expanded="false"] > .section-heading'
);
headings.forEach(function (h) { h.click(); });
}
 
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', expandAll);
} else {
expandAll();
}
})();