|
|
(26 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| (function() { | | mw.hook('ext.popups').add(function() { |
| function cleanSlideshowStyles(slideshowContainer) { | | $('.mwe-popups-extract .portable-infobox').each(function() { |
| const slideshow = slideshowContainer.querySelector('.slideshow'); | | var $infobox = $(this); |
| if (slideshow) { | | var $firstParagraph = $('.mwe-popups-extract p:first'); |
| // Remove inline styles on the main slideshow container
| |
| slideshow.style.width = '';
| |
| slideshow.style.height = '';
| |
|
| |
|
| // Remove inline styles on each slide div
| | // If there is a paragraph, move the infobox after it |
| slideshow.querySelectorAll('div').forEach(slide => {
| | if ($firstParagraph.length) { |
| slide.style.width = '';
| | $infobox.insertAfter($firstParagraph); |
| slide.style.height = '';
| | } else { |
| }); | | // If there's no paragraph, just hide the infobox |
| | $infobox.hide(); |
| } | | } |
| } | | }); |
| | | }); |
| function initSlideshowFix() {
| |
| // Locate all mw-jsslideshow instances
| |
| document.querySelectorAll('.mw-jsslideshow').forEach(mwSlideshow => {
| |
| // Clean styles on page load
| |
| cleanSlideshowStyles(mwSlideshow);
| |
| | |
| // Optional: Re-clean styles on window resize
| |
| window.addEventListener('resize', () => {
| |
| cleanSlideshowStyles(mwSlideshow);
| |
| });
| |
| | |
| // Hook into slide transitions if needed (depends on the specific JS driving the slideshow)
| |
| const slideshow = mwSlideshow.querySelector('.slideshow');
| |
| if (slideshow) {
| |
| const observer = new MutationObserver(() => {
| |
| cleanSlideshowStyles(mwSlideshow);
| |
| });
| |
| | |
| observer.observe(slideshow, {
| |
| attributes: true,
| |
| attributeFilter: ['style'],
| |
| childList: false,
| |
| subtree: false
| |
| });
| |
| }
| |
| });
| |
| }
| |
| | |
| // Run once DOM is ready (in case the slideshows are injected late)
| |
| if (document.readyState === 'complete' || document.readyState === 'interactive') {
| |
| initSlideshowFix();
| |
| } else {
| |
| document.addEventListener('DOMContentLoaded', initSlideshowFix);
| |
| }
| |
| })();
| |
| /* Any JavaScript here will be loaded for all users on every page load. */
| |
| (function() {
| |
| function cleanSlideshowStyles(slideshowContainer) {
| |
| const slideshow = slideshowContainer.querySelector('.slideshow');
| |
| if (slideshow) {
| |
| // Remove inline styles on the main slideshow container
| |
| slideshow.style.width = '';
| |
| slideshow.style.height = '';
| |
| | |
| // Remove inline styles on each slide div
| |
| slideshow.querySelectorAll('div').forEach(slide => {
| |
| slide.style.width = '';
| |
| slide.style.height = '';
| |
| });
| |
| }
| |
| }
| |
| | |
| function initSlideshowFix() {
| |
| // Locate all mw-jsslideshow instances
| |
| document.querySelectorAll('.mw-jsslideshow').forEach(mwSlideshow => {
| |
| // Clean styles on page load
| |
| cleanSlideshowStyles(mwSlideshow);
| |
| | |
| // Optional: Re-clean styles on window resize
| |
| window.addEventListener('resize', () => {
| |
| cleanSlideshowStyles(mwSlideshow);
| |
| });
| |
| | |
| // Hook into slide transitions if needed (depends on the specific JS driving the slideshow)
| |
| const slideshow = mwSlideshow.querySelector('.slideshow');
| |
| if (slideshow) {
| |
| const observer = new MutationObserver(() => {
| |
| cleanSlideshowStyles(mwSlideshow);
| |
| });
| |
| | |
| observer.observe(slideshow, {
| |
| attributes: true,
| |
| attributeFilter: ['style'],
| |
| childList: false,
| |
| subtree: false
| |
| });
| |
| }
| |
| });
| |
| }
| |
| | |
| // Run once DOM is ready (in case the slideshows are injected late)
| |
| if (document.readyState === 'complete' || document.readyState === 'interactive') {
| |
| initSlideshowFix();
| |
| } else {
| |
| document.addEventListener('DOMContentLoaded', initSlideshowFix);
| |
| }
| |
| })();
| |
mw.hook('ext.popups').add(function() {
$('.mwe-popups-extract .portable-infobox').each(function() {
var $infobox = $(this);
var $firstParagraph = $('.mwe-popups-extract p:first');
// If there is a paragraph, move the infobox after it
if ($firstParagraph.length) {
$infobox.insertAfter($firstParagraph);
} else {
// If there's no paragraph, just hide the infobox
$infobox.hide();
}
});
});