MediaWiki:Common.js: Difference between revisions

From Mor Afgin Website
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: // Load Fancybox from CDN mw.loader.using(['jquery', 'mediawiki.util'], function () { $.getScript('https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', function () { // Initialize Fancybox on all images with class 'fancybox' $('a.image').attr('data-fancybox', 'gallery').fancybox({ buttons: [ 'zoom', 's...")
 
No edit summary
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
// Initialize PhotoSwipe
 
mw.loader.using(['ext.photoSwipe'], function() {
// Load Fancybox from CDN
     var config = mw.config.get('wgPhotoSwipeConfig');
mw.loader.using(['jquery', 'mediawiki.util'], function () {
    if (!config) {
     $.getScript('https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', function () {
         // Default configuration if none exists
         // Initialize Fancybox on all images with class 'fancybox'
         config = {
         $('a.image').attr('data-fancybox', 'gallery').fancybox({
             mode: 'recommended',
             buttons: [
            options: {
                'zoom',
                 gallery: 'table.gallery',
                 'slideShow',
                 children: 'a.img',
                 'fullScreen',
                 thumbSelector: 'a.img',
                 'thumbs',
                 allowPanToNext: false,
                 'close'
                wheelToZoom: true
            ],
             }
            protect: true, // Prevents image download by right-click
         };
            loop: true,    // Allows cycling through images
        mw.config.set('wgPhotoSwipeConfig', config);
             background: 'rgba(255, 255, 255, 0.9)' // White background
     }
         });
     });
});
});

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);
    }
});