MediaWiki:Common--new.js
Замечание. Возможно, после сохранения вам придётся очистить кэш своего браузера, чтобы увидеть изменения.
/* https://ru.warface.com/wiki/index.php/MediaWiki:Common--new.js */ /*--[dom]--*/ var $html = $( 'html' ); var $head = $( 'head' ); var $body = $( 'body' ); var $globalWrapper = $( '#globalWrapper' ); var $bodyContent = $( '#bodyContent' ); /*--[/dom]--*/ /*--[design]--*/ var device; var design = { constructor: function() { var breakpoint = { width: { game: 0, desktop: 0, tablet: 0, mobile: 0 }, height: { game: 0 } }; $( window ).resize( function() { device = { width: $( window ).width(), height: $( window ).height(), type: undefined }; if ( device.width == breakpoint.width.game && device.height <= breakpoint.height.game ) { device.type = 'game'; } else if ( device.width < breakpoint.width.tablet ) { device.type = 'mobile'; } else if ( device.width < breakpoint.width.desktop ) { device.type = 'tablet'; } else { device.type = 'desktop'; }; } ); $( window ).resize(); } }; $( design.constructor ); /*--[/design]--*/ /*--[include]--*/ var include = { constructor: function() { $( '.include--html' ).each( function() { $( this ) .after( $( this ).text() ) .remove(); } ); $( '.include--js[data-title]' ).each( function() { $.getScript( '/wiki/index.php?title=' + $( this ).attr( 'data-title' ) + '&ctype=text%2Fjavascript&action=raw' ); $( this ).remove(); } ); $( '.include--css' ).each( function() { $( this ) .after( '<style>' + $( this ).text() + '</style>' ) .remove(); } ); } }; $( include.constructor ); /*--[/include]--*/ /*--[legacy]--*/ var legacy = { constructor: function() { $( 'link[rel="shortcut icon"]', $head ).remove(); $( 'meta[name="generator"]', $head ).remove(); $( 'link[rel="copyright"]', $head ).remove(); $( 'link[rel="alternate"][type="application/atom+xml"]', $head ).remove(); $( 'link[title="Creative Commons"][type="application/rdf+xml"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="/wiki/skins/common/shared.css"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="/wiki/skins/common/commonPrint.css"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="MediaWiki:Common.css"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="MediaWiki:Print.css"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="/wiki/skins/monobook/main.css"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="/wiki/skins/monobook/IE50Fixes.css"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="/wiki/skins/monobook/IE55Fixes.css"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="/wiki/skins/monobook/IE60Fixes.css"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="/wiki/skins/monobook/IE70Fixes.css"]', $head ).remove(); $( 'link[rel="stylesheet"][href*="/static/wf.mail.ru/css/wiki/main.css"]', $head ).remove(); $( 'script[src*="/wiki/skins/common/monobook/wf_gallery.js"]', $head ).remove(); $( '#toc, .toc', $body ).remove(); } }; $( legacy.constructor ); /*--[/legacy]--*/ /*--[head]--*/ var head = { constructor: function() { var html = '<meta http-equiv="X-UA-Compatible" content="IE=edge">' + '<meta name="viewport" content="width=device-width, initial-scale=1.0">' + '<meta name="HandheldFriendly" content="true">' + '<meta name="MobileOptimized" content="width">' + '<meta name="apple-mobile-web-app-capable" content="yes">' // + '<link rel="apple-touch-icon" sizes="57x57" href="/Apple-touch-icon-57x57.png">' // + '<link rel="apple-touch-icon" sizes="60x60" href="/Apple-touch-icon-60x60.png">' // + '<link rel="apple-touch-icon" sizes="72x72" href="/Apple-touch-icon-72x72.png">' // + '<link rel="apple-touch-icon" sizes="76x76" href="/Apple-touch-icon-76x76.png">' // + '<link rel="apple-touch-icon" sizes="114x114" href="/Apple-touch-icon-114x114.png">' // + '<link rel="apple-touch-icon" sizes="120x120" href="/Apple-touch-icon-120x120.png">' // + '<link rel="apple-touch-icon" sizes="144x144" href="/Apple-touch-icon-144x144.png">' // + '<link rel="apple-touch-icon" sizes="152x152" href="/Apple-touch-icon-152x152.png">' // + '<link rel="apple-touch-icon" sizes="180x180" href="/Apple-touch-icon-180x180.png">' // + '<link rel="icon" type="image/png" sizes="16x16" href="/Favicon-16x16.png">' // + '<link rel="icon" type="image/png" sizes="32x32" href="/Favicon-32x32.png">' // + '<link rel="icon" type="image/png" sizes="96x96" href="/Favicon-96x96.png">' + '<link rel="shortcut icon" href="/static/wf.mail.ru/img/main/favicon.ico" type="image/x-icon">' + '<link rel="icon" href="/static/wf.mail.ru/img/main/favicon.ico" type="image/x-icon">'; $head.append( html ); } }; $( head.constructor ); /*--[/head]--*/ /*--[platforms]--*/ var platforms = { constructor: function() { var $platforms = $( '.platforms' ); $globalWrapper.append( $platforms ); } }; $( platforms.constructor ); /*--[/platforms]--*/ /*--[footer]--*/ var footer = { constructor: function() { var $footer = $( '.footer' ); $globalWrapper.append( $footer ); $( '.footer__copyright-date' ).text( new Date().getFullYear() ); } }; $( footer.constructor ); /*--[/footer]--*/ /*--[heading]--*/ var heading = { constructor: function() { var $heading = $( '.heading' ); if( $heading.length ) { $( '#firstHeading, .firstHeading' ).remove(); document.title = $heading.text() + ' — Warface Wiki'; }; } }; $( heading.constructor ); /*--[/heading]--*/ /*--[video]--*/ var video = { constructor: function() { $( '.video-include' ).each( function() { $( this ) .after( '<div class="video">' + '<div class="video__inner">' + '<iframe src="' + $( this ).text() + '" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture;" frameborder="0" allowfullscreen></iframe>' + '</div>' + '</div>' ) .remove(); } ); } }; $( video.constructor ); /*--[/video]--*/ /*--[spoiler]--*/ var spoiler = { constructor: function() { $( '.spoiler__title' ).append( '<div class="spoiler__marker"><div class="spoiler__marker-symbol"></div></div>' ); $bodyContent.on( 'click', '.spoiler__title', function() { $( this ) .parent() .toggleClass( 'is-open' ); } ); } }; $( spoiler.constructor ); /*--[/spoiler]--*/ /*--[slider]--*/ var slider = { constructor: function() { var $slider = $( '.slider' ); function slickSlider__load_style( name ) { $head.append( '<link rel="stylesheet" href="/wiki/index.php?title=Mediawiki:Libs/slick-slider/' + name + '.css&ctype=text%2Fcss&action=raw">' ); }; function slickSlider__load_script( name ) { $.ajax( { async: false, url: '/wiki/index.php?title=MediaWiki:Libs/slick-slider/' + name + '.js&ctype=text%2Fjavascript&action=raw', dataType: 'script' } ); }; if ( $slider.length ) { slickSlider__load_style( 'slick-slider' ); slickSlider__load_script( 'slick-slider' ); var slider__counter = 0; $slider.each( function() { slider__counter++; $( this ).attr( 'data-slider', slider__counter ) var slider__imgs = []; $( this ) .find( 'img' ) .each( function() { slider__imgs.push( $( this ).attr( 'src' ) ); } ); if ( $( this ).hasClass( 'slider--double' ) ) { var sliderDoubleFor__items = ''; $.each( slider__imgs, function( index, value ) { sliderDoubleFor__items += '<div class="slider__item"><img class="slider__img" data-lazy="' + value + '"></div>'; } ); var sliderDoubleNav__items = ''; $.each( slider__imgs, function( index, value ) { sliderDoubleNav__items += '<div class="slider__item"><img class="slider__img" src="' + value + '"></div>'; } ); $( this ).html( '<div class="slider-for">' + sliderDoubleFor__items + '</div>' + '<div class="slider-nav">' + sliderDoubleNav__items + '</div>' ); $( this ) .children( '.slider-for' ) .slick( { asNavFor: '.slider[data-slider="' + slider__counter + '"] > .slider-nav', draggable: false, fade: true, nextArrow: '<button class="slick-next" type="button"></button>', prevArrow: '<button class="slick-prev" type="button"></button>', slidesToScroll: 1, slidesToShow: 1, speed: 500, swipe: false } ); $( this ) .children( '.slider-nav' ) .slick( { arrows: false, asNavFor: '.slider[data-slider="' + slider__counter + '"] > .slider-for', focusOnSelect: true, slidesToScroll: 1, slidesToShow: 6, speed: 500, variableWidth: true } ); }; if ( $( this ).hasClass( 'slider--gallery' ) ) { var sliderGallery__items = ''; $.each( slider__imgs, function( index, value ) { sliderGallery__items += '<div class="slider__item"><a href="' + value + '"><div class="slider__img-wrap"><img class="slider__img" src="' + value + '"></div></a></div>'; } ); $( this ).html( sliderGallery__items ); var sliderGallery__settings = { rows: 1, slidesPerRow: 3, slidesToShow: 3 }; if ( slider__imgs.length == 1 ) { $( this ).addClass( 'slider--gallery_col-1' ); sliderGallery__settings.slidesPerRow = 1; sliderGallery__settings.slidesToShow = 1; } else if ( slider__imgs.length == 2 ) { $( this ).addClass( 'slider--gallery_col-2' ); sliderGallery__settings.slidesPerRow = 2; sliderGallery__settings.slidesToShow = 2; } else { $( this ).addClass( 'slider--gallery_col-3' ); sliderGallery__settings.rows = Math.ceil( slider__imgs.length / 3 ); }; $( this ) .slick( { arrows: false, draggable: false, fade: true, rows: sliderGallery__settings.rows, slidesPerRow: sliderGallery__settings.slidesPerRow, slidesToScroll: 1, slidesToShow: sliderGallery__settings.slidesToShow, swipe: false, variableWidth: true } ); }; } ); }; } }; $( slider.constructor ); /*--[/slider]--*/