MediaWiki:Common.js: Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
 
(28 intermediate revisions by the same user not shown)
Line 121:
/* End of mw.loader.using callback */
} );
 
// CapSach — Mobile TOC overlay (all skins; phone widths)
// CapSach — Sticky TOC overlay (UNRESTRICTED: Works on iPad/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 153 ⟶ 154:
});
 
// 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 < 3) return;
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'; // reveal trigger now that we know we have headings
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.
// 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 });
})();
 
/* Script for Inline Expandable Template */
/* 1. Reset the wrapper to be a simple container */
$(function() {
.quiet-btn-wrapper {
$('.inline-expand-trigger').on('click', function() {
display: inline-block;
// 1. Toggle the content visibility
/* No padding here, we want the link inside to handle the size */
$(this).next('.inline-expand-content').toggle();
}
 
/* 2. Style the actual link inside to look// like2. Toggle the Buttonarrow */icon
const currentText = $(this).text();
.quiet-btn-wrapper a {
/* Layout & Box Model */$(this).text(
currentText.includes('▸') ? currentText.replace('▸', '◂') : currentText.replace('◂', '▸')
display: inline-flex; /* Ensures vertical centering */
align-items: center );
});
box-sizing: border-box;
});
min-height: 32px; /* Exact Codex button height */
padding: 0 12px; /* Standard horizontal padding */
border-radius: 2px; /* The distinct 'square-ish' rounded corners */
border: 1px solid transparent; /* Keeps sizing consistent with bordered buttons */
 
$(document).ready(function() {
/* Typography */
// Check if the button already exists to prevent duplicates
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Lato, Helvetica, Arial, sans-serif;
if ($('#custom-email-btn').length === 0) {
font-size: 0.875rem; /* 14px - Exact interface size */
font-weight: 700; /* Bold text */
// Create the email button element
line-height: 1.6; /* Standard line-height */
var emailBtn = $('<a>', {
text-decoration: none; /* No underline */
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
/* Default Colors (Codex Neutral Quiet) */
$('body').append(emailBtn);
background-color: #f8f9fa; /* Light gray background */
}
color: #202122 !important; /* Dark gray/black text (forced) */
});
 
/* Open AXA BRAIN AI Assistant when clicking the logo */
/* Smooth Transition Effect */
$(document).ready(function() {
transition: background-color 100ms ease, color 100ms ease, border-color 100ms ease, box-shadow 100ms ease;
$('.fullscreen-logo').css('cursor:', 'pointer;').click(function(e) {
e.preventDefault();
}
 
// Method 1: Click the AI Assistant floating icon
/* 3. Hover State (Mouse over) */
var $aiButton = $('img[src*="ai-icon.png"]').closest('div, button, a');
.quiet-btn-wrapper a:hover {
if ($aiButton.length > 0) {
background-color: #eaecf0; /* Slightly darker gray */
$aiButton.trigger('click');
color: #202122 !important;
return;
text-decoration: none;
}
}
 
// Method 2: Try the extension's trigger class
/* 4. Active State (Clicking down) */
var $trigger = $('.ext-aiassistant-trigger, .ext-aiassistant');
.quiet-btn-wrapper a:active {
if ($trigger.length > 0) {
background-color: #c8ccd1; /* Even darker gray for click feedback */
$trigger.first().trigger('click');
box-shadow: none;
return;
}
}
 
/* 5. Focus State (Accessibility/Keyboard navigation) */
.quiet-btn-wrapper a:focus {
outline: 2px solid #36c; /* Standard Wiki focus blue */
outline-offset: 2px;
}
 
console.log("AXA BRAIN Assistant button not found on this page.");
/* DO NOT ADD CODE BELOW THIS LINE */
});
});