MediaWiki:Common.js: Difference between revisions

From Mor Afgin Website
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
// Initialize PhotoSwipe
// Initialize PhotoSwipe
mw.loader.using(['ext.photoswipe'], function() {
mw.loader.using(['ext.photoSwipe'], function() {
     if (typeof PhotoSwipe !== 'undefined') {
    var config = mw.config.get('wgPhotoSwipeConfig');
         // Initialize PhotoSwipe for elements with photoswipe class
     if (!config) {
         var elements = document.getElementsByClassName('photoswipe');
         // Default configuration if none exists
         if (elements.length > 0) {
         config = {
            new PhotoSwipe(elements);
            mode: 'recommended',
        }
            options: {
                gallery: 'table.gallery',
                children: 'a.img',
                thumbSelector: 'a.img',
                allowPanToNext: false,
                wheelToZoom: true
            }
        };
         mw.config.set('wgPhotoSwipeConfig', config);
     }
     }
});
});

Latest revision as of 19:05, 28 October 2024

// Initialize PhotoSwipe
mw.loader.using(['ext.photoSwipe'], function() {
    var config = mw.config.get('wgPhotoSwipeConfig');
    if (!config) {
        // Default configuration if none exists
        config = {
            mode: 'recommended',
            options: {
                gallery: 'table.gallery',
                children: 'a.img',
                thumbSelector: 'a.img',
                allowPanToNext: false,
                wheelToZoom: true
            }
        };
        mw.config.set('wgPhotoSwipeConfig', config);
    }
});