MediaWiki:Common.js/slider.js

// Slider // Autor: Pecoes & Vuh // Modyfikacje: Nanaki // Licencja: CC-BY-NC-SA //          http://creativecommons.org/licenses/by-nc-sa/3.0/deed.pl

// Oryginał: http://pl.elderscrolls.wikia.com/wiki/MediaWiki:Slider.js // Lekko zmodyfikowana wersja skryptu pozwalająca działać z galerią if (mediaWiki.config.get('wgAction') === 'view') (function  {    'use strict';    function createSlider  {        /*jshint validthis:true*/        var scrollPane = $(this),            scrollPaneWidth = scrollPane.width,            scrollContent = scrollPane.find('.scroll-content'),            scrollContentWidth = 0;        var elems = scrollContent.find('.wikia-gallery-item')        if (!elems.length) elems = scrollContent.find('img');

elems.each(function {            var $this = $(this),                width = $this.outerWidth;            if (width) {                scrollContentWidth += width;            } else {                $this.on('load', function  { scrollContentWidth += $this.outerWidth; });           }        });        var scrollbar = scrollPane.find('.scroll-bar').slider({            slide: function(event, ui) {                if (scrollContentWidth > scrollPaneWidth) {                    scrollContent.css('margin-left', Math.round(                        ui.value / 100 * (scrollPaneWidth - scrollContentWidth)                    ) + 'px');                } else {                    scrollContent.css('margin-left', 0);                }            }        }); scrollPane.css( "overflow", "hidden" ); scrollbar.find('.ui-slider-handle').css({           width: '60px',            marginLeft: '-30px'        }); }   $(function  {        var imgSlider = $('.img-slider');        if (!imgSlider.length) return;        $('head')        .append(' .ui-widget-header { background: transparent; border: none; } .scroll-bar-wrap{ width: 500px; margin: 0 auto; padding: 4px; background: transparent; border: none; } .ui-slider { border: 1px solid #000; box-shadow: 0 0 4px #000; background: transparent; } .scroll-bar-wrap .ui-slider-handle {background: #143746; border: 1px black; } .scroll-bar-wrap .ui-slider-handle:hover { background: none repeat scroll 0 0 #143746; border: 1px black; } .img-slider { overflow: hidden; white-space: nowrap; width: auto; } .img-slider * { margin: 0; padding: 0; } .img-slider figure { display: inline-block; } ');        imgSlider        .wrap(' ')        .addClass('scroll-content') .after('  '); mediaWiki.loader.using('jquery.ui.slider', function {            $('.scroll-pane').each(createSlider);        }); }); });