MediaWiki:Common.js/sliderVuh.js

// Nowy slider by Vuh

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 = 670;        scrollContent.find('img').each(function  { var $this = $(this), width = $this.width; if (width) { scrollContentWidth += width; } else { $this.on('load', function {                    scrollContentWidth += $this.width;                }); }       });        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: 500; margin: 0 auto; padding: 4px; background: transparent; border: none; } .ui-slider { border: 1px solid #333; box-shadow: 0 0 4px #333; background: transparent; } .scroll-bar-wrap .ui-slider-handle {background: black; border: none; } .scroll-bar-wrap .ui-slider-handle:hover { background: none repeat scroll 0 0 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);        }); }); });