MediaWiki:Common.js

From Mor Afgin Website
Revision as of 14:46, 28 October 2024 by Mor Afgin (talk | contribs)

Note: After publishing, 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: Press Ctrl-F5.
// Initialize PhotoSwipe
mw.loader.using(['ext.photoswipe'], function() {
    if (typeof PhotoSwipe !== 'undefined') {
        // Initialize PhotoSwipe for elements with photoswipe class
        var elements = document.getElementsByClassName('photoswipe');
        if (elements.length > 0) {
            new PhotoSwipe(elements);
        }
    }
});

mw.loader.using(['ext.photoSwipe'], function() {
    // Initialize PhotoSwipe
    const galleries = document.querySelectorAll('.photoswipe-gallery');
    if (galleries.length > 0) {
        galleries.forEach(gallery => {
            const lightbox = new PhotoSwipeLightbox({
                gallery: gallery,
                children: 'a',
                pswpModule: PhotoSwipe
            });
            lightbox.init();
        });
    }
});