User:Codc/common.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
mw.loader.load( 'ext.gadget.VisualFileChange' );

//mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Wiegels/slideshow.js&action=raw&ctype=text/javascript', 'text/javascript'); // [[c:User:Wiegels/slideshow.js]]

/*
 * slideshow.js
 * extension of gallery slideshow gadget on Commons for German WLE/WLM jurors
 *
 * https://commons.wikimedia.org/wiki/MediaWiki:Gadget-GallerySlideshow.js
 * https://commons.wikimedia.org/wiki/MediaWiki:GallerySlideshow.js
 */
if ($('.gallery[title="Jury"]').length>0) { // 2020-09-30
    $(document).on('slideshow', function(event, command, object) {
        /// console.debug(command);
        if (command=='codeLoaded') {
            object.findImageSize = function(height, width) {
                object.actualMaxSize = {w: 1550, h: 766}; // for resolution 1600 * 900
            };
        }
        else if (command=='shown') {
            object.maxImageHeight = $(window).height() - object.$thumbsUl.height() - object.$controlsContainer.height();
            object.maxImageWidth = $(window).width() - 50;
            $('#controls').prepend('<div id="jw-index" style="color:#666; float:left; font-size:3em; margin-top:8px;"></div>');
            $('#caption').hide().css('min-width', '0').css('width', '0').find('.image-caption').css('padding', '0').css('width', '0');
        }
        if (command=='shown' || command=='afterQuery') {
            $('#com-gs-thumbs img').each(function(index, element) {
                $(this).attr('title', ('000'+(index+1)).substr(-3));
            });
        }
        else if (command=='newSlide') {
            $('#jw-index').text(('000'+(object.preloadStartIndex+1)).substr(-3));
        }
    });
}