MediaWiki:Common.js: Difference between revisions
Content deleted Content added
No edit summary Tag: Manual revert |
No edit summary |
||
| (21 intermediate revisions by the same user not shown) | |||
Line 121:
/* End of mw.loader.using callback */
} );
// CapSach — Sticky TOC overlay (UNRESTRICTED: Works on iPad/Desktop/Mobile)
(function () {
// Only run on
if (window.mw && mw.config && mw.config.get) {
var
if (!
}
Line 153 ⟶ 154:
});
// Show only if there are enough headings to be useful
// CHANGED: Lowered requirement to 1 heading so it always shows if there is any structure
if (items.length < 1) return;
// Create trigger button (bottom-left; avoids “Back to top” on bottom-right)
Line 217 ⟶ 219:
}
// Force button display immediately
btn.style.display = 'flex';
btn.addEventListener('click', openOverlay);
Line 231 ⟶ 234:
// Navigate and try to ensure mobile-collapsed sections are visible
// Navigate and try to ensure mobile-collapsed sections are visible
list.addEventListener('click', function (e) {
var a = e.target.closest('a');
Line 237 ⟶ 241:
var targetId = a.getAttribute('href').slice(1);
// === NEW LOGIC START: Scroll to Top for "Contents" ===
// If the user clicks the "Contents" header (id="mw-toc-heading"), scroll to top (0,0)
// === FIXED CODE ===
if (targetId === 'mw-toc-heading') {
closeOverlay();
// Delay scroll to let iOS Safari process the overflow change
setTimeout(function() {
try {
window.scrollTo({ top: 0, behavior: 'smooth' });
} catch (e) {
window.scrollTo(0, 0);
}
// Fallback for older iOS Safari
document.documentElement.scrollTop = 0;
document.body.scrollTop = 0;
}, 100);
if (history.replaceState) {
history.replaceState(null, '', window.location.pathname + window.location.search);
}
return;
}
// === NEW LOGIC END ===
var target = document.getElementById(targetId);
closeOverlay();
Line 268 ⟶ 296:
});
// 2. REMOVED the "resize" event listener that was hiding the button.
// The button now persists on all screen sizes.
})();
/* Script for Inline Expandable Template */
$(function() {
$('.inline-expand-trigger').on('click', function() {
// 1. Toggle the content visibility
$(this).next('.inline-expand-content').toggle();
// 2. Toggle the arrow icon
const currentText = $(this).text();
$(this).text(
currentText.includes('▸') ? currentText.replace('▸', '◂') : currentText.replace('◂', '▸')
);
});
});
$(document).ready(function() {
// Check if the button already exists to prevent duplicates
if ($('#custom-email-btn').length === 0) {
// 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
$('body').append(emailBtn);
}
});
/* Open AXA BRAIN AI Assistant when clicking the logo */
$(document).ready(function() {
$('.fullscreen-logo').css('cursor', 'pointer').click(function(e) {
e.preventDefault();
// Method 1: Click the AI Assistant floating icon
var $aiButton = $('img[src*="ai-icon.png"]').closest('div, button, a');
if ($aiButton.length > 0) {
$aiButton.trigger('click');
return;
}
// Method 2: Try the extension's trigger class
var $trigger = $('.ext-aiassistant-trigger, .ext-aiassistant');
if ($trigger.length > 0) {
$trigger.first().trigger('click');
return;
}
console.log("AXA BRAIN Assistant button not found on this page.");
});
});
| |||