MediaWiki:Common.js

/* */

/* ######################################################################## */ /* ### JavaScript here is loaded for all users and all skins. ### */ /* ######################################################################## */

/* ######################################################################## */ /* ### SHARED CODE                                                     ### */ /* ### ### */ /* ### Description: Used by multiple modules                            ### */ /* ### Credit:     various                                             ### */ /* ######################################################################## */

/** * Removes lazy loading from all images contained in `lazyIcon`. * * By User:Sakaratte. */ function removeLazyLoad(lazyIcon) { var lazyIconImages = lazyIcon.getElementsByTagName("img"); for (var i = 0; i < lazyIconImages.length; i++) { var iconSrc = lazyIconImages[i].getAttribute("data-src"); if (iconSrc !== null) lazyIconImages[i].setAttribute("src", iconSrc); lazyIconImages[i].className = ""; } }

/* ############################################################################# */ /* ### TICKER                                                               ### */ /* ###  ### */ /* ### Description: Displays a ticker, as in Template:Ticker             ### */ /* ### Credit:     unknown                                                  ### */ /* ###             User:FDekker                                             ### */ /* ############################################################################# */ $(function {   $(".ticker").each(function(_, ticker) { var step = 10; // How many pixels to move text each tick var tickerSpeed = 200; ticker = $(ticker); if (ticker.attr('data-speed') !== undefined) tickerSpeed = parseInt(ticker.attr('data-speed')); if (ticker.attr('data-step') !== undefined) step = parseInt(ticker.attr('data-step')); ticker.css("display", "block");

var wrapper = $(".tickerWrapper", ticker); wrapper.css("left", (step + ticker.width) + "px");

var text = $(".tickerText", ticker); var textWidth = text.outerWidth;

setInterval(function {           var offset =                (wrapper.position.left > -(textWidth + step))                    ? (wrapper.position.left - step) + "px"  // Move left                    : (ticker.width + step) + "px";  // Reset            wrapper.css("left", offset);        }, tickerSpeed); }); });