MediaWiki:Common.js
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
(function () {
var iconSelector =
'.meter, .parallel, .commentary, .pictures, .outline, .comment, .word';
var panelSelector =
'.metertext, .paralleltext, .commentarytext, ' +
'.picturestext, .outlinetext, .commenttext, .wordtext';
var openIcon = null;
function updateWidth(icon) {
var viewportWidth = document.documentElement.clientWidth;
var availableWidth =
viewportWidth - icon.getBoundingClientRect().left - 16;
icon.style.setProperty(
'--popup-width',
Math.max(0, Math.min(viewportWidth * 0.7, availableWidth)) + 'px'
);
}
document.addEventListener('click', function (event) {
var icon = event.target.closest(iconSelector);
if (!icon) {
return;
}
var panel = icon.querySelector(panelSelector);
if (panel && panel.contains(event.target)) {
return;
}
if (icon === openIcon) {
icon.classList.remove('open');
openIcon = null;
return;
}
if (openIcon) {
openIcon.classList.remove('open');
}
updateWidth(icon);
icon.classList.add('open');
openIcon = icon;
});
window.addEventListener('resize', function () {
if (openIcon) {
updateWidth(openIcon);
}
});
})();