MediaWiki:Mobile.js: Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
 
(7 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:
}
 
// the linkForce isbutton re-addeddisplay 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 });
})();
 
$(document).ready(function () {
/* ======================================================= */
// Check if the button already exists to prevent duplicates
/* ADD 'BIZ BOOKS' TO MOBILE SIDEBAR (PERSISTENT METHOD) */
if ($menu.find('#custom-email-btn' + linkId).length === 0) {
/* ======================================================= */
} else {
// Create the itememail button element
var $newLinkemailBtn = $('<a>'), {
id: 'custom-email-btn',
href: 'mailto:services@axabrain.com',
// CreateSimple theaccessible linktitle
title: 'Contact AXA BRAIN Services'
});
 
// Add it to the body of the page
$(function () {
$newItem('body').append($newLinkemailBtn);
// Configuration
var linkId = 'mobile-nav-biz-books';
var linkHref = '/wiki/Biz/Books'; // Change if your URL structure is different
var linkText = 'Biz Books';
 
// The function that enforces the link's existence
function enforceBizBooksLink() {
// 1. Target the sidebar container (confirmed by your CSS to be #mw-mf-page-left)
var $sidebar = $('#mw-mf-page-left');
 
// 2. Only proceed if the sidebar is actually in the DOM (rendered)
if ($sidebar.length === 0) return;
 
// 3. Find the menu list (first UL inside the sidebar)
var $menu = $sidebar.find('ul').first();
if ($menu.length === 0) return;
 
// 4. Check if our link is missing
if ($menu.find('#' + linkId).length === 0) {
console.log('BizSlash: Sidebar detected, injecting Biz Books link...');
 
// Create the item
var $newItem = $('<li>')
.addClass('mw-ui-icon-extra')
.attr('id', linkId);
 
// Create the link
// Using 'mw-ui-icon-minerva-book' (Standard) or fallback to 'mw-ui-icon-minerva-list'
var $newLink = $('<a>')
.attr('href', linkHref)
.addClass('mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-book')
.text(linkText);
 
$newItem.append($newLink);
 
// 5. Append to the menu
$menu.append($newItem);
}
}
 
// Run immediately on load
enforceBizBooksLink();
 
// Run every 500ms forever.
// This ensures that if the user closes and re-opens the menu (which wipes the DOM),
// the link is re-added immediately.
setInterval(enforceBizBooksLink, 500);
});