Война в Украине

Все мы знаем, какой пиздец сейчас происходит с Украиной и одной известной вам страной-победительницей-фашизма. Если вы хотите почитать об этом, помочь актуализировать информацию или высказать свое мнение — можете сделать это в статье Война в Украине и в обсуждении.

MediaWiki:Common.js — различия между версиями

Материал из Urbanculture
Перейти к: навигация, поиск
 
(не показано 58 промежуточных версий 2 участников)
Строка 1: Строка 1:
/** Misc common defines ****/  
+
/** Misc common defines ****/
  
  
Строка 6: Строка 6:
 
/*** _is_editable - у меня есть права на правку текущей страницы? */
 
/*** _is_editable - у меня есть права на правку текущей страницы? */
 
/*** _is_autoconfirmed  */
 
/*** _is_autoconfirmed  */
var _is_editpage = mw.config.get( 'wgAction' ) == 'edit' || mw.config.get( 'wgAction' ) == 'submit';
+
var _is_editpage = mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit';
 
var _is_editable = (function isEditable() {
 
var _is_editable = (function isEditable() {
     var restrict = mw.config.get( 'wgRestrictionEdit' ) || [], g;
+
     var restrict = mw.config.get('wgRestrictionEdit') || [], g;
     if (restrict.length < 1) {return true;}
+
     if (restrict.length < 1) { return true; }
     if (!mw.config.get( 'wgUserGroups' )) {return false;}
+
     if (!mw.config.get('wgUserGroups')) { return false; }
     for( g=0; g<mw.config.get( 'wgUserGroups' ).length; g++) {if ($.inArray(mw.config.get( 'wgUserGroups' )[g], restrict)!=-1) {return true;}}
+
     for (g = 0; g < mw.config.get('wgUserGroups').length; g++) { if ($.inArray(mw.config.get('wgUserGroups')[g], restrict) != -1) { return true; } }
 
     return false;
 
     return false;
 
}());
 
}());
var _is_autoconfirmed = mw.config.get( 'wgUserGroups' ) && ($.inArray('autoconfirmed', mw.config.get( 'wgUserGroups' )) != -1),
+
var _is_autoconfirmed = mw.config.get('wgUserGroups') && ($.inArray('autoconfirmed', mw.config.get('wgUserGroups')) != -1),
     f5s=('localStorage' in window) && window.localStorage!==null ? window.localStorage : false,
+
     f5s = ('localStorage' in window) && window.localStorage !== null ? window.localStorage : false,
 
     Queue
 
     Queue
 
     ;
 
     ;
 
/** /Misc common defines ****/
 
/** /Misc common defines ****/
 
 
  
 
/** Processing queue ****/
 
/** Processing queue ****/
Строка 33: Строка 31:
 
/**** Queue.runEachFragment(scope) - scope can be an html element or array of elements */
 
/**** Queue.runEachFragment(scope) - scope can be an html element or array of elements */
  
mw.loader.using('UC.queue', function() {
+
mw.loader.using('UC.queue', function () {
  
    /**  Edittools ****/
+
     Queue.addOnce(function () {
    /* Authors: [[User:Anotubus]], [[User:Obvious]] */
+
         $('.boxes a').each(function () {
    Queue.addOnce('UC.edittools', 'tabbedEditTools', (
+
        (!mw.config.get( 'wgCanonicalSpecialPageName' ) &&
+
        (
+
            location.href.match(/&action=(?:edit|submit)/) !== null ||
+
            mw.config.get( 'wgAction' ) == 'edit' ||
+
            mw.config.get( 'wgAction' ) == 'submit'
+
        )) ||
+
        mw.config.get( 'wgPageName' ).match(/mediawiki:(?:edittools|topedittools)/i) !== null ||
+
        mw.config.get( 'wgCanonicalNamespace' ).match(/talk$/i) !== null ||
+
        mw.config.get( 'wgPageName' ) == "Special:Upload" ||
+
        mw.config.get( 'wgPageName' ) == "Служебная:Загрузка"
+
    ) );
+
    Queue.addOnce('UC.edittools', 'fileInsert', (
+
        (!mw.config.get( 'wgCanonicalSpecialPageName' ) &&
+
        (
+
            location.href.match(/&action=(?:edit|submit)/) !== null ||
+
            mw.config.get( 'wgAction' ) == 'edit' ||
+
            mw.config.get( 'wgAction' ) == 'submit'
+
        )) ||
+
        mw.config.get( 'wgPageName' ).match(/mediawiki:(?:edittools|topedittools)/i) !== null ||
+
        mw.config.get( 'wgCanonicalNamespace' ).match(/talk$/i) !== null
+
    ) );
+
     Queue.addOnce(function(){
+
         $('.boxes a').each(function() {
+
 
             var parentalt = $(this).parent().attr('title');
 
             var parentalt = $(this).parent().attr('title');
 
             $(this).attr('alt', parentalt);
 
             $(this).attr('alt', parentalt);
             if($(this).parent().hasClass('menuicon')) {
+
             if ($(this).parent().hasClass('menuicon')) {
 
                 $(this).html('<span class="glyphicon"></span>')
 
                 $(this).html('<span class="glyphicon"></span>')
 
             };
 
             };
Строка 69: Строка 43:
 
     });
 
     });
  
     //Fixed edittools on big pages
+
     /** Drafts save ****/
     Queue.addOnce('jquery.visible', function(){
+
     Queue.addOnce('UC.draftarticle', 'draftArticle', (
        $(document).on("scroll", function() {
+
         (!mw.config.get('wgCanonicalSpecialPageName') &&
            var visible = $('.mw-editTools').visible(),
+
            (
                scrollTop    = $(window).scrollTop(),
+
                location.href.match(/&action=(?:edit|submit)/) !== null ||
                elementOffset = $('.editOptions').offset().top,
+
                mw.config.get('wgAction') == 'edit' ||
                distance      = (elementOffset - scrollTop),
+
                mw.config.get('wgAction') == 'submit'
                topPosition = $(window).scrollTop() - 80;
+
            ))
            if (visible || distance < 180) {
+
     ));
                $(this).find('#editpage-specialchars-new').removeClass('fixed')
+
                    .css('top', '0');
+
            } else {
+
                $(this).find('#editpage-specialchars-new').addClass('fixed')
+
                    .css('top', topPosition);
+
            }
+
         });
+
    }, (!mw.config.get( 'wgCanonicalSpecialPageName' ) &&
+
        (  
+
            location.href.match(/&action=(?:edit|submit)/) !== null ||
+
            mw.config.get( 'wgAction' ) == 'edit' ||
+
            mw.config.get( 'wgAction' ) == 'submit'
+
        ))
+
     );
+
  
 
     /** Collapsible tables ****/
 
     /** Collapsible tables ****/
 
     // Используется в коллапсерах
 
     // Используется в коллапсерах
     Queue.addEachFragment( 'UC.tablecollapsers','createTableCollapsers', !mw.config.get( 'wgCanonicalSpecialPageName' ) );
+
     Queue.addEachFragment('UC.tablecollapsers', 'createTableCollapsers', !mw.config.get('wgCanonicalSpecialPageName'));
     Queue.addEachFragment( 'UC.tablecollapsers','createHiderButtons', !mw.config.get( 'wgCanonicalSpecialPageName' ) );
+
     Queue.addEachFragment('UC.tablecollapsers', 'createHiderButtons', !mw.config.get('wgCanonicalSpecialPageName'));
 
+
  
 
     /** NSFW Gallery Items ****/
 
     /** NSFW Gallery Items ****/
 
     /* Description: Hides images with |NSFW in description from galleries */
 
     /* Description: Hides images with |NSFW in description from galleries */
 
     /* Authors: [[User:Anotubus]], [[User:Obvious]] */
 
     /* Authors: [[User:Anotubus]], [[User:Obvious]] */
     Queue.addEachFragment('UC.gallerymodify','processNSFWGalleryItems', !mw.config.get( 'wgCanonicalSpecialPageName' ));
+
     Queue.addEachFragment('UC.gallerymodify', 'processNSFWGalleryItems', !mw.config.get('wgCanonicalSpecialPageName'));
  
 
     /** Dynamic gallery ****/
 
     /** Dynamic gallery ****/
     Queue.addEachFragment('UC.gallerymodify','dynamicGallery', !mw.config.get( 'wgCanonicalSpecialPageName' ));
+
     Queue.addEachFragment('UC.gallerymodify', 'dynamicGallery', !mw.config.get('wgCanonicalSpecialPageName'));
  
 
     /** Ajaxed *****/
 
     /** Ajaxed *****/
     Queue.addEachFragment('UC.ajaxed', 'ajaxed', !mw.config.get( 'wgCanonicalSpecialPageName' ));
+
     Queue.addEachFragment('UC.ajaxed', 'ajaxed', !mw.config.get('wgCanonicalSpecialPageName'));
  
 
     /** Sidebar scroll *****/
 
     /** Sidebar scroll *****/
     Queue.addOnce('jquery.slimscroll', function(){
+
     Queue.addOnce('jquery.slimscroll', function () {
         if($(window).width() > '980') {
+
         if ($(window).width() > '980') {
 
             $('#mw-panel').slimScroll({
 
             $('#mw-panel').slimScroll({
 
                 color: '#ffffff',
 
                 color: '#ffffff',
                 distance: '3px',
+
                 distance: '3px'
 
             });
 
             });
 
         };
 
         };
 +
 +
        $('#toc > ul').slimScroll({
 +
            color: '#333333',
 +
            distance: '3px',
 +
            allowPageScroll: false
 +
        });
 
     });
 
     });
  
    /** Morph LM Edition **************************************/
 
    Queue.addEachFragment('UC.morphobjects','createMorphObjects', !mw.config.get( 'wgCanonicalSpecialPageName' ));
 
  
 
     /** Ref tooltips******************************************
 
     /** Ref tooltips******************************************
Строка 129: Строка 92:
 
       */
 
       */
  
     Queue.addOnce(function() {
+
     Queue.addOnce(function () {
         $(window).click(function(e) {
+
         $(window).click(function (e) {
 
             if (!($(e.target).hasClass('areference') || $(e.target).parents().andSelf().hasClass('tooltip'))) {
 
             if (!($(e.target).hasClass('areference') || $(e.target).parents().andSelf().hasClass('tooltip'))) {
 
                 $('.tooltip').hide(250); $('.curreference').removeClass('curreference');
 
                 $('.tooltip').hide(250); $('.curreference').removeClass('curreference');
 
             }
 
             }
 
         });
 
         });
     }, !mw.config.get( 'wgCanonicalSpecialPageName' )).addEachFragment(function(scope) {
+
     }, !mw.config.get('wgCanonicalSpecialPageName')).addEachFragment(function (scope) {
 
         var refs = $('ol.references', scope);
 
         var refs = $('ol.references', scope);
 
         if (!refs.size()) { return; }
 
         if (!refs.size()) { return; }
         refs.before($('<a href="#">[показать примечания]</a>').click(function(e) { e.preventDefault(); refs.toggle(); } )).hide();
+
         refs.before($('<a href="#">[показать примечания]</a>').click(function (e) { e.preventDefault(); refs.toggle(); })).hide();
         $('.reference a', scope).click(function(e) {
+
         $('.reference a', scope).click(function (e) {
 
             e.preventDefault();
 
             e.preventDefault();
 
             var x = $(this), iscurrent = x.hasClass('curreference'), i = $('.tooltip').hide(250),
 
             var x = $(this), iscurrent = x.hasClass('curreference'), i = $('.tooltip').hide(250),
                 par = x.parent(), o = par.offset(), l = o.left, t = o.top+13,
+
                 par = x.parent(), o = par.offset(), l = o.left, t = o.top + 13,
 
                 b = $('body'), mh = b.height(), mw = b.width(),
 
                 b = $('body'), mh = b.height(), mw = b.width(),
                 c=$(x.attr('href'), refs).clone().find('a:first').remove().end().html();
+
                 c = $(x.attr('href'), refs).clone().find('a:first').remove().end().html();
 
             $('.curreference').removeClass('curreference');
 
             $('.curreference').removeClass('curreference');
 
             if (iscurrent) { return; }
 
             if (iscurrent) { return; }
  
 
             x.addClass('areference').addClass('curreference');
 
             x.addClass('areference').addClass('curreference');
             if (!i.size()) { i = $('<div/>').addClass('tooltip');}
+
             if (!i.size()) { i = $('<div/>').addClass('tooltip'); }
             i.appendTo(b).queue(function() {
+
             i.appendTo(b).queue(function () {
                 i.empty().append(c).css({ 'left': l-((l+i.width() >= mw) && i.width()), 'top': t-((t+i.height() >= mh) && (i.height()+26)) }).dequeue();
+
                 i.empty().append(c).css({ 'left': l - ((l + i.width() >= mw) && i.width()), 'top': t - ((t + i.height() >= mh) && (i.height() + 26)) }).dequeue();
 
             }).show(250);
 
             }).show(250);
 
         });
 
         });
     }, !mw.config.get( 'wgCanonicalSpecialPageName' ));
+
     }, !mw.config.get('wgCanonicalSpecialPageName'));
  
 
     /** Morph LM Edition **************************************/
 
     /** Morph LM Edition **************************************/
     Queue.addEachFragment('UC.morphobjects','createMorphObjects', !mw.config.get( 'wgCanonicalSpecialPageName' ));
+
     Queue.addEachFragment('UC.morphobjects', 'createMorphObjects', !mw.config.get('wgCanonicalSpecialPageName'));
  
 
     /** Pre lines******************************************
 
     /** Pre lines******************************************
Строка 165: Строка 128:
 
       */
 
       */
  
     Queue.addOnce(function() {
+
     Queue.addOnce(function () {
         $('pre').each(function() {
+
         $('pre').each(function () {
             var rows_count = Math.round($(this).height()/parseInt($(this).css('line-height')));
+
             var rows_count = Math.round($(this).height() / parseInt($(this).css('line-height')));
 
             var $pre = $(this);
 
             var $pre = $(this);
 
             var html = $pre.html();
 
             var html = $pre.html();
 
             var nl = /\n|\r|\r\n/g;
 
             var nl = /\n|\r|\r\n/g;
             $pre.html(('\n'+html).replace(nl, '</div><div class="row">'));
+
             $pre.html(('\n' + html).replace(nl, '</div><div class="row">'));
 
         });
 
         });
 
     });
 
     });
Строка 177: Строка 140:
 
     /** Linkchecker ***/
 
     /** Linkchecker ***/
 
     function linkchecker(scope) {
 
     function linkchecker(scope) {
         $('.linkchecker', scope).each(function(i, e) {
+
         $('.linkchecker', scope).each(function (i, e) {
 
             var lc_if = $(".linkcheckerif a", this),
 
             var lc_if = $(".linkcheckerif a", this),
 
                 lc_then = $(".linkcheckerthen", this),
 
                 lc_then = $(".linkcheckerthen", this),
 
                 lc_else = $(".linkcheckerelse", this)
 
                 lc_else = $(".linkcheckerelse", this)
            ;
+
                ;
  
 
             if (lc_if.size() && lc_then.size()) {
 
             if (lc_if.size() && lc_then.size()) {
Строка 189: Строка 152:
 
         });
 
         });
 
     }
 
     }
     Queue.addEachFragment(linkchecker, !mw.config.get( 'wgCanonicalSpecialPageName' ));
+
     Queue.addEachFragment(linkchecker, !mw.config.get('wgCanonicalSpecialPageName'));
  
 
     /** ShortDiffURL ****/
 
     /** ShortDiffURL ****/
 
     Queue.addOnce(function shortdiffurl() {
 
     Queue.addOnce(function shortdiffurl() {
         if (!mw.config.get( 'wgCanonicalSpecialPageName' ) && window.location.href.indexOf("diff=") != '-1' && $("#ca-history").size() > 0 ){
+
         if (!mw.config.get('wgCanonicalSpecialPageName') && window.location.href.indexOf("diff=") != '-1' && $("#ca-history").size() > 0) {
             $("#ca-history").after('<li id="ca-diff" class="collapsible"><span><a href="'+location.href.replace(/^(.+\?).*&?(diff=(?:\d+|prev|next|curr)).*?(&oldid=\d+)?.*$/,"$1$2$3")+'" title="Короткая ссылка на дифф">Дифф</a></span></li>');
+
             $("#ca-history").after('<li id="ca-diff" class="collapsible"><span><a href="' + location.href.replace(/^(.+\?).*&?(diff=(?:\d+|prev|next|curr)).*?(&oldid=\d+)?.*$/, "$1$2$3") + '" title="Короткая ссылка на дифф">Дифф</a></span></li>');
 
         };
 
         };
 
     });
 
     });
 
  
 
     /** Needed page **/
 
     /** Needed page **/
     Queue.addOnce(function() {
+
     Queue.addOnce(function () {
          $('.mw-redirect').addClass('neededpagerdrcts');
+
        $('.mw-redirect').addClass('neededpagerdrcts');
          $('ul').addClass('neededpagelist');
+
        $('ul').addClass('neededpagelist');
     }, !mw.config.get( 'wgCanonicalSpecialPageName' ) && mw.config.get( 'wgPageName' ) == 'Urbanculture:R');
+
     }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == 'Urbanculture:R');
 
+
    /** Wikificator  ************************************* */
+
    function wikification() {
+
        $('<button id="Wikifybutton" onclick="Wikify();" type="button">Викифицировать</button>').insertBefore($('#wpSave'));
+
        if(mw.config.get( 'wgNamespaceNumber' )==-1 || mw.config.get( 'wgNamespaceNumber' )==108) {$('#Wikifybutton').attr('disabled','disabled');}
+
        $('#editpage-copywarn').insertAfter('.editOptions');
+
    }
+
 
+
    Queue.addOnce( 'UC.wikificator', wikification, (!mw.config.get( 'wgCanonicalSpecialPageName' ) && mw.config.get( 'wgAction' ) == "edit") || mw.config.get( 'wgAction' ) == "submit" || mw.config.get( 'wgPageName' ) == "Special:Upload");
+
 
+
  
 
     /** Image Categorizer  ************************************* */
 
     /** Image Categorizer  ************************************* */
Строка 223: Строка 175:
 
     /* Authors: [[User:Tachikoma]], [[User:T_kns]], [[User:Мопец Ципельман]] */
 
     /* Authors: [[User:Tachikoma]], [[User:T_kns]], [[User:Мопец Ципельман]] */
 
     window.excludedSectionHeaders = $('.c-comment :header');
 
     window.excludedSectionHeaders = $('.c-comment :header');
     Queue.addOnce('UC.sectionmenus','addSectionMenus', !mw.config.get( 'wgCanonicalSpecialPageName' ) && mw.config.get( 'skin' )=='vector');
+
     Queue.addOnce('UC.sectionmenus', 'addSectionMenus', !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('skin') == 'vector');
  
  
 
     /** collapsibledivs *****/
 
     /** collapsibledivs *****/
    Queue.addOnce('UC.collapsiblesidebar','collapsibleSideBar', f5s && mw.config.get( 'skin' )=='vector');
+
    Queue.addOnce('UC.collapsiblesidebar', 'collapsibleSideBar', f5s && mw.config.get('skin') == 'vector');
 
+
  
 
     /* empty pagename ****/
 
     /* empty pagename ****/
     Queue.addOnce(function() {
+
     Queue.addOnce(function () {
         $('#bodySearch').submit(function(e) {
+
         $('#bodySearch').submit(function (e) {
 
             var wrap = $(this).children(".bodySearchWrap");
 
             var wrap = $(this).children(".bodySearchWrap");
             if(/^\s*$/.test(wrap.children('#bodySearchInput').val())) {
+
             if (/^\s*$/.test(wrap.children('#bodySearchInput').val())) {
                 if(wrap.children('.pagenameneeded').size() === 0) {
+
                 if (wrap.children('.pagenameneeded').size() === 0) {
                     wrap.append($('<p class="pagenameneeded">Введите имя статьи</p>').delay(1500).fadeOut('slow',function() {$(this).remove();}));
+
                     wrap.append($('<p class="pagenameneeded">Введите имя статьи</p>').delay(1500).fadeOut('slow', function () { $(this).remove(); }));
 
                 }
 
                 }
 
                 return false;
 
                 return false;
 
             }
 
             }
 
         });
 
         });
     }, !mw.config.get( 'wgCanonicalSpecialPageName' ) && mw.config.get( 'wgPageName' ) == "Urbanculture:Новая_статья");
+
     }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == "Urbanculture:Новая_статья");
  
 
     /* b-yauser ****/
 
     /* b-yauser ****/
     Queue.addEachFragment(function(sc) { $('.b-yauser a', sc).each(function(i) { $(this).html($(this).html().replace(/^([^<])/,'<b>$1</b>')); }); });
+
     Queue.addEachFragment(function (sc) { $('.b-yauser a', sc).each(function (i) { $(this).html($(this).html().replace(/^([^<])/, '<b>$1</b>')); }); });
  
  
 
     /* prettyPhoto ****/
 
     /* prettyPhoto ****/
     Queue.addOnce( 'UC.prettyphotify', 'prettyPhotifyOptions', f5s && mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Preferences' );
+
     Queue.addOnce('UC.prettyphotify', 'prettyPhotifyOptions', f5s && mw.config.get('wgCanonicalSpecialPageName') == 'Preferences');
     Queue.addEachFragment( 'UC.prettyphotify', 'prettyPhotify', f5s && localStorage.getItem('gallery_slideshow') != 'false' );
+
     Queue.addEachFragment('UC.prettyphotify', 'prettyPhotify', f5s && localStorage.getItem('gallery_slideshow') != 'false');
  
 
     /* By ****/
 
     /* By ****/
     Queue.addOnce(function() {
+
     Queue.addOnce(function () {
 
         $('body').addClass('ns-talk');
 
         $('body').addClass('ns-talk');
     }, !mw.config.get( 'wgCanonicalSpecialPageName' ) && mw.config.get( 'wgPageName' ) == "Urbanculture:Вниманию_участников");
+
     }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == "Urbanculture:Вниманию_участников");
  
 
     /* Spoilers ****/
 
     /* Spoilers ****/
     Queue.addEachFragment(function(scope) {
+
     Queue.addEachFragment(function (scope) {
         $('.spoiler',scope).click(function() {
+
         $('.spoiler', scope).click(function () {
 
             $(this).toggleClass('spoilered');
 
             $(this).toggleClass('spoilered');
 
         });
 
         });
     }, !mw.config.get( 'wgCanonicalSpecialPageName' ) );
+
     }, !mw.config.get('wgCanonicalSpecialPageName'));
  
 
     /* new gallerytemplate ****/
 
     /* new gallerytemplate ****/
Строка 268: Строка 219:
  
 
     /*** Resize textarea ***/
 
     /*** Resize textarea ***/
     Queue.addOnce('jquery.autoSizeTextArea', function () {
+
     //Queue.addOnce('jquery.autoSizeTextArea', function () {
        $('#wpTextbox1').autoSizeTextArea();
+
    //    $('#wpTextbox1').autoSizeTextArea();
        $(document).ready(function () {
+
    //    $(document).ready(function () {
            $('#wpTextbox1').autoSizeTextArea('update')
+
    //        $('#wpTextbox1').autoSizeTextArea('update')
 +
    //    });
 +
    //});
 +
 
 +
    /* LazyLoad EmbedVideo****/
 +
    Queue.addEachFragment(['ext.embedVideo', 'ext.embedVideo-lazy', 'ext.embedVideo-playpause'], 'embedVideoLazyLoad', !mw.config.get('wgCanonicalSpecialPageName'));
 +
 
 +
 
 +
    /***********    Modern gallery Toggler    ***********/
 +
    Queue.addEachFragment(function (sc) {
 +
        const gallery = $('.combinedgallery, .videogallery', sc)
 +
            ;
 +
        gallery.each(function () {
 +
            var t = $(this),
 +
                tElLength = t.data('line-elems'),
 +
                tElems = t.find('.gallery_content_block').length
 +
                ;//console.log(t)
 +
            if (tElems > tElLength) t.addClass('__hide_content');
 
         });
 
         });
     });
+
     }, !mw.config.get('wgCanonicalSpecialPageName'));
 +
 
 +
    Queue.addOnce(function () {//console.log('Modern gallery Toggler addOnce', $(document))
 +
        $('body').on('click', '.gallery_toggle', function () {
 +
            var t = $(this),
 +
                tGall = t.closest('.combinedgallery, .videogallery')
 +
                ;//console.log(t)
 +
            tGall.toggleClass('__hide_content __show_content')
 +
        });
 +
    }, !mw.config.get('wgCanonicalSpecialPageName'))
 +
 
 +
 
 +
    /***********    /Modern gallery Toggler    ***********/
 +
 
 +
    /***********    Scale    ***********/
 +
    Queue.addOnce('UC.scalemap', 'scaleMap', f5s && mw.config.get('skin') == 'vector');
 +
    /***********    /Scale    ***********/
  
 
     /*** define the functions, that will be ran on each Comments display refresh ***/
 
     /*** define the functions, that will be ran on each Comments display refresh ***/
     window.commentJSrunMultiHooks = function (scope) {};
+
     window.commentJSrunMultiHooks = function (scope) { };
  
 
});
 
});
Строка 288: Строка 272:
 
$(document).ready(function () {
 
$(document).ready(function () {
 
     var windowWidth = $(window).width();
 
     var windowWidth = $(window).width();
        $(document).scroll(function () {
+
    $(document).scroll(function () {
            if ((scrollmenu == false) && ($(window).scrollTop() > 112) && ($(window).height() > 900) && ($('#content').outerHeight() > 950) && (mw.config.get( 'skin' )=='vector')) {
+
        if ((scrollmenu == false) && ($(window).scrollTop() > 112) && ($(window).height() > 900) && ($('#content').outerHeight() > 950) && (mw.config.get('skin') == 'vector')) {
                $(".editbox").css('position', 'fixed');
+
            $(".editbox").css('position', 'fixed');
                $(".editbox").css('top', '0');
+
            $(".editbox").css('top', '0');
                scrollmenu = true;
+
            scrollmenu = true;
            } else if ((scrollmenu === true) && ($(window).scrollTop() < 113)) {
+
        } else if ((scrollmenu === true) && ($(window).scrollTop() < 113)) {
                $(".editbox").css('position', 'absolute');
+
            $(".editbox").css('position', 'absolute');
                $(".editbox").css('top', '');
+
            $(".editbox").css('top', '');
                scrollmenu = false;
+
            scrollmenu = false;
            }
+
        }
        });
+
    });
 
});
 
});
  
Строка 323: Строка 307:
 
     $('#oldnews').after("<div id='showarchive'><a class='show-link' href='#' class='showarchive'><span>Показать архив</span></a><a class='hide-link' href='#' class='showarchive' style='display:none'><span>Скрыть архив</span></a></div>");
 
     $('#oldnews').after("<div id='showarchive'><a class='show-link' href='#' class='showarchive'><span>Показать архив</span></a><a class='hide-link' href='#' class='showarchive' style='display:none'><span>Скрыть архив</span></a></div>");
 
     $('#showarchive a').click(function () {
 
     $('#showarchive a').click(function () {
         if($(this).hasClass('show-link')) {
+
         if ($(this).hasClass('show-link')) {
 
             $('#oldnews').fadeIn();
 
             $('#oldnews').fadeIn();
 
             $(this).hide().siblings().show()
 
             $(this).hide().siblings().show()
Строка 337: Строка 321:
  
 
/*** Mobile menu ***/
 
/*** Mobile menu ***/
if (mw.config.get( 'skin' )=='mobile') {
+
if (mw.config.get('skin') == 'mobile') {
     $('.portlet h5').click(function() {
+
     $('.portlet h5').click(function () {
 
         var portlet = $(this);
 
         var portlet = $(this);
 
         $('#portlet-bg').fadeIn('slow');
 
         $('#portlet-bg').fadeIn('slow');
 
         portlet.parent().addClass('visible');
 
         portlet.parent().addClass('visible');
 
     });
 
     });
     $('#close-portlet').click(function() {
+
     $('#close-portlet').click(function () {
 
         $(this).parent().fadeOut('slow');
 
         $(this).parent().fadeOut('slow');
 
         $('.portlet').removeClass('visible');
 
         $('.portlet').removeClass('visible');
Строка 349: Строка 333:
 
}
 
}
  
 +
/***********    NSFW    ***********/
 +
$(document).on('click', '.NSFW', function (e) {
 +
    e.preventDefault();
  
/* Saladificator */
+
    $(this).removeClass('NSFW');
 +
});
 +
/***********    /NSFW    ***********/
  
var now     = new Date('2015-12-30T00:00:00+05:30'),
+
/* Saladificator */
 +
var now = new Date(),
 
     now_month = now.getMonth() + 1,
 
     now_month = now.getMonth() + 1,
     now_day = now.getDate();  
+
     now_day = now.getDate(),
 +
    hash = window.location.hash.substr(1);
  
console.log(now_month + '' + now_day)
 
 
$(document).ready(function () {
 
$(document).ready(function () {
     if( (now_month + '' + now_day) > 1230 || (now_month + '' + now_day) < 0101) {
+
     if ((now_month + '' + now_day) > 1228 || (now_month + '' + now_day) < 13) {
         $('#mw-panel').addClass('saladificator')
+
         //$('#mw-panel').addClass('saladificator')
 
     }
 
     }
 +
 +
    if (!hash.includes("WG7Pg4o"))
 +
        $('#mw-panel').addClass('ukraine');
 +
    else
 +
        $('#siteNotice').hide();
 +
 +
 +
    /* TOC sticky */
 +
    const toc = document.getElementById('toc');
 +
 +
    if (toc) {
 +
        const directParent = toc.parentElement.classList.contains('tocright');
 +
 +
        var goToTopButton = document.createElement('div');
 +
 +
        goToTopButton.addEventListener('click', function (e) {
 +
            window.scrollTo({ top: 0, behavior: 'auto' });
 +
        });
 +
 +
        goToTopButton.setAttribute("id", "go_to_top");
 +
        goToTopButton.innerHTML = '<span class="icon"></span>';
 +
 +
        toc.appendChild(goToTopButton);
 +
 +
        toc.querySelectorAll(':scope a').forEach(function (anchor) {
 +
            anchor.addEventListener('click', function (e) {
 +
                e.preventDefault();
 +
 +
                var anchorText = this.getAttribute('href'),
 +
                    anchorId = anchorText.substring(1, anchorText.length);
 +
 +
                document.getElementById(anchorId).scrollIntoView({
 +
                    behavior: 'smooth'
 +
                });
 +
 +
                toc.classList.add('__hidden');
 +
 +
                // Update the URL without reloading the page
 +
                var url = window.location.href.split('#')[0] + anchorText;
 +
                history.pushState(null, null, url);
 +
            });
 +
        });
 +
 +
        if (!directParent) {
 +
 +
            var tocHeight = -toc.offsetHeight,
 +
                topPos = toc.getBoundingClientRect().top - tocHeight,
 +
                tocToggler = document.getElementById('toctitle');
 +
 +
            if (topPos <= tocHeight) {
 +
                toc.classList.add('__sticky', '__ontop', '__hidden');
 +
            }
 +
 +
            tocToggler.addEventListener("click", function () {
 +
                toc.classList.toggle("__hidden");
 +
            });
 +
 +
            document.addEventListener('scroll', function (e) {
 +
                topPos = toc.getBoundingClientRect().top;
 +
                setTimeout(function () {
 +
                    if (topPos <= tocHeight) {
 +
                        toc.classList.add('__sticky', '__ontop', '__hidden');
 +
                    } else if (topPos && topPos >= 1) {
 +
                        toc.classList.remove('__sticky', '__ontop');
 +
                    }
 +
                }, 50);
 +
            });
 +
        }
 +
    }
 +
 
});
 
});

Текущая версия на 22:20, 27 января 2024

/** Misc common defines ****/
 
 
/* Неоднократно нужные проверки: */
/*** _is_editpage - я на странице редактирования? */
/*** _is_editable - у меня есть права на правку текущей страницы? */
/*** _is_autoconfirmed  */
var _is_editpage = mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit';
var _is_editable = (function isEditable() {
    var restrict = mw.config.get('wgRestrictionEdit') || [], g;
    if (restrict.length < 1) { return true; }
    if (!mw.config.get('wgUserGroups')) { return false; }
    for (g = 0; g < mw.config.get('wgUserGroups').length; g++) { if ($.inArray(mw.config.get('wgUserGroups')[g], restrict) != -1) { return true; } }
    return false;
}());
var _is_autoconfirmed = mw.config.get('wgUserGroups') && ($.inArray('autoconfirmed', mw.config.get('wgUserGroups')) != -1),
    f5s = ('localStorage' in window) && window.localStorage !== null ? window.localStorage : false,
    Queue
    ;
/** /Misc common defines ****/
 
/** Processing queue ****/
 
/**** Queue.addOnce(function(){}, condition = true) - adds a function to run once on page load */
/**** Queue.addOnce('module.name', [function(){} | function name string string], condition = true) - loads a module and adds a function to run once on page load */
/**** Queue.addEachFragment(function(scope){}, condtion = true) - adds function to run on page load AND on each AJAX loaded fragment */
/**** Queue.addEachFragment('module.name', [function(scope){} | function name string string], condtion = true) - loads a module and adds function to run on page load AND on each AJAX loaded fragment */
/****     Function must take a single parameter - currently processed fragment */
/**** Both functions take optional second parameter - if false, function won't be run on current page */
/**** Queue.runOnce - self-descriptive, shouldn't be run directly */
/**** Queue.runEachFragment(scope) - scope can be an html element or array of elements */
 
mw.loader.using('UC.queue', function () {
 
    Queue.addOnce(function () {
        $('.boxes a').each(function () {
            var parentalt = $(this).parent().attr('title');
            $(this).attr('alt', parentalt);
            if ($(this).parent().hasClass('menuicon')) {
                $(this).html('<span class="glyphicon"></span>')
            };
        });
    });
 
    /** Drafts save ****/
    Queue.addOnce('UC.draftarticle', 'draftArticle', (
        (!mw.config.get('wgCanonicalSpecialPageName') &&
            (
                location.href.match(/&action=(?:edit|submit)/) !== null ||
                mw.config.get('wgAction') == 'edit' ||
                mw.config.get('wgAction') == 'submit'
            ))
    ));
 
    /** Collapsible tables ****/
    // Используется в коллапсерах
    Queue.addEachFragment('UC.tablecollapsers', 'createTableCollapsers', !mw.config.get('wgCanonicalSpecialPageName'));
    Queue.addEachFragment('UC.tablecollapsers', 'createHiderButtons', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** NSFW Gallery Items ****/
    /* Description: Hides images with |NSFW in description from galleries */
    /* Authors: [[User:Anotubus]], [[User:Obvious]] */
    Queue.addEachFragment('UC.gallerymodify', 'processNSFWGalleryItems', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Dynamic gallery ****/
    Queue.addEachFragment('UC.gallerymodify', 'dynamicGallery', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Ajaxed *****/
    Queue.addEachFragment('UC.ajaxed', 'ajaxed', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Sidebar scroll *****/
    Queue.addOnce('jquery.slimscroll', function () {
        if ($(window).width() > '980') {
            $('#mw-panel').slimScroll({
                color: '#ffffff',
                distance: '3px'
            });
        };
 
        $('#toc > ul').slimScroll({
            color: '#333333',
            distance: '3px',
            allowPageScroll: false
        });
    });
 
 
    /** Ref tooltips******************************************
      *
      *  Description: Replace references with JQuery-based tooltips
      *  Made by:  Tachikoma
      */
 
    Queue.addOnce(function () {
        $(window).click(function (e) {
            if (!($(e.target).hasClass('areference') || $(e.target).parents().andSelf().hasClass('tooltip'))) {
                $('.tooltip').hide(250); $('.curreference').removeClass('curreference');
            }
        });
    }, !mw.config.get('wgCanonicalSpecialPageName')).addEachFragment(function (scope) {
        var refs = $('ol.references', scope);
        if (!refs.size()) { return; }
        refs.before($('<a href="#">[показать примечания]</a>').click(function (e) { e.preventDefault(); refs.toggle(); })).hide();
        $('.reference a', scope).click(function (e) {
            e.preventDefault();
            var x = $(this), iscurrent = x.hasClass('curreference'), i = $('.tooltip').hide(250),
                par = x.parent(), o = par.offset(), l = o.left, t = o.top + 13,
                b = $('body'), mh = b.height(), mw = b.width(),
                c = $(x.attr('href'), refs).clone().find('a:first').remove().end().html();
            $('.curreference').removeClass('curreference');
            if (iscurrent) { return; }
 
            x.addClass('areference').addClass('curreference');
            if (!i.size()) { i = $('<div/>').addClass('tooltip'); }
            i.appendTo(b).queue(function () {
                i.empty().append(c).css({ 'left': l - ((l + i.width() >= mw) && i.width()), 'top': t - ((t + i.height() >= mh) && (i.height() + 26)) }).dequeue();
            }).show(250);
        });
    }, !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Morph LM Edition **************************************/
    Queue.addEachFragment('UC.morphobjects', 'createMorphObjects', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Pre lines******************************************
      *
      *  Description: add lines to <pre> tags
      *  Made by: Munhgauzen
      */
 
    Queue.addOnce(function () {
        $('pre').each(function () {
            var rows_count = Math.round($(this).height() / parseInt($(this).css('line-height')));
            var $pre = $(this);
            var html = $pre.html();
            var nl = /\n|\r|\r\n/g;
            $pre.html(('\n' + html).replace(nl, '</div><div class="row">'));
        });
    });
 
    /** Linkchecker ***/
    function linkchecker(scope) {
        $('.linkchecker', scope).each(function (i, e) {
            var lc_if = $(".linkcheckerif a", this),
                lc_then = $(".linkcheckerthen", this),
                lc_else = $(".linkcheckerelse", this)
                ;
 
            if (lc_if.size() && lc_then.size()) {
                if (lc_if.hasClass('new')) { lc_then.hide(); } else { lc_else.hide(); }
                lc_if.parent().hide();
            } else { $(this).hide(); }
        });
    }
    Queue.addEachFragment(linkchecker, !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** ShortDiffURL ****/
    Queue.addOnce(function shortdiffurl() {
        if (!mw.config.get('wgCanonicalSpecialPageName') && window.location.href.indexOf("diff=") != '-1' && $("#ca-history").size() > 0) {
            $("#ca-history").after('<li id="ca-diff" class="collapsible"><span><a href="' + location.href.replace(/^(.+\?).*&?(diff=(?:\d+|prev|next|curr)).*?(&oldid=\d+)?.*$/, "$1$2$3") + '" title="Короткая ссылка на дифф">Дифф</a></span></li>');
        };
    });
 
    /** Needed page **/
    Queue.addOnce(function () {
        $('.mw-redirect').addClass('neededpagerdrcts');
        $('ul').addClass('neededpagelist');
    }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == 'Urbanculture:R');
 
    /** Image Categorizer  ************************************* */
    /** Author: Anotubus   */
    /* if ( (mw.config.get( 'wgCanonicalNamespace' ) == 'File' || mw.config.get( 'wgNamespaceNumber' ) == 6) && _is_autoconfirmed && _is_editable ) importScriptURI("/skins/common/imgcat.js");*/
 
 
    /** Section menus ****************************************** */
    /* Authors: [[User:Tachikoma]], [[User:T_kns]], [[User:Мопец Ципельман]] */
    window.excludedSectionHeaders = $('.c-comment :header');
    Queue.addOnce('UC.sectionmenus', 'addSectionMenus', !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('skin') == 'vector');
 
 
    /** collapsibledivs *****/
    Queue.addOnce('UC.collapsiblesidebar', 'collapsibleSideBar', f5s && mw.config.get('skin') == 'vector');
 
    /* empty pagename ****/
    Queue.addOnce(function () {
        $('#bodySearch').submit(function (e) {
            var wrap = $(this).children(".bodySearchWrap");
            if (/^\s*$/.test(wrap.children('#bodySearchInput').val())) {
                if (wrap.children('.pagenameneeded').size() === 0) {
                    wrap.append($('<p class="pagenameneeded">Введите имя статьи</p>').delay(1500).fadeOut('slow', function () { $(this).remove(); }));
                }
                return false;
            }
        });
    }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == "Urbanculture:Новая_статья");
 
    /* b-yauser ****/
    Queue.addEachFragment(function (sc) { $('.b-yauser a', sc).each(function (i) { $(this).html($(this).html().replace(/^([^<])/, '<b>$1</b>')); }); });
 
 
    /* prettyPhoto ****/
    Queue.addOnce('UC.prettyphotify', 'prettyPhotifyOptions', f5s && mw.config.get('wgCanonicalSpecialPageName') == 'Preferences');
    Queue.addEachFragment('UC.prettyphotify', 'prettyPhotify', f5s && localStorage.getItem('gallery_slideshow') != 'false');
 
    /* By ****/
    Queue.addOnce(function () {
        $('body').addClass('ns-talk');
    }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == "Urbanculture:Вниманию_участников");
 
    /* Spoilers ****/
    Queue.addEachFragment(function (scope) {
        $('.spoiler', scope).click(function () {
            $(this).toggleClass('spoilered');
        });
    }, !mw.config.get('wgCanonicalSpecialPageName'));
 
    /* new gallerytemplate ****/
    //Queue.addEachFragment('UC.newgallerytemplate', 'newGalleryTemplate', !mw.config.get( 'wgCanonicalSpecialPageName' ));
 
 
    /*** Resize textarea ***/
    //Queue.addOnce('jquery.autoSizeTextArea', function () {
    //    $('#wpTextbox1').autoSizeTextArea();
    //    $(document).ready(function () {
    //        $('#wpTextbox1').autoSizeTextArea('update')
    //    });
    //});
 
    /* LazyLoad EmbedVideo****/
    Queue.addEachFragment(['ext.embedVideo', 'ext.embedVideo-lazy', 'ext.embedVideo-playpause'], 'embedVideoLazyLoad', !mw.config.get('wgCanonicalSpecialPageName'));
 
 
    /***********     Modern gallery Toggler    ***********/
    Queue.addEachFragment(function (sc) {
        const gallery = $('.combinedgallery, .videogallery', sc)
            ;
        gallery.each(function () {
            var t = $(this),
                tElLength = t.data('line-elems'),
                tElems = t.find('.gallery_content_block').length
                ;//console.log(t)
            if (tElems > tElLength) t.addClass('__hide_content');
        });
    }, !mw.config.get('wgCanonicalSpecialPageName'));
 
    Queue.addOnce(function () {//console.log('Modern gallery Toggler addOnce', $(document))
        $('body').on('click', '.gallery_toggle', function () {
            var t = $(this),
                tGall = t.closest('.combinedgallery, .videogallery')
                ;//console.log(t)
            tGall.toggleClass('__hide_content __show_content')
        });
    }, !mw.config.get('wgCanonicalSpecialPageName'))
 
 
    /***********    /Modern gallery Toggler    ***********/
 
    /***********     Scale    ***********/
    Queue.addOnce('UC.scalemap', 'scaleMap', f5s && mw.config.get('skin') == 'vector');
    /***********    /Scale    ***********/
 
    /*** define the functions, that will be ran on each Comments display refresh ***/
    window.commentJSrunMultiHooks = function (scope) { };
 
});
 
/** /Processing queue ****/
 
 
/*** Scroll menu ***/
 
var scrollmenu = false;
$(document).ready(function () {
    var windowWidth = $(window).width();
    $(document).scroll(function () {
        if ((scrollmenu == false) && ($(window).scrollTop() > 112) && ($(window).height() > 900) && ($('#content').outerHeight() > 950) && (mw.config.get('skin') == 'vector')) {
            $(".editbox").css('position', 'fixed');
            $(".editbox").css('top', '0');
            scrollmenu = true;
        } else if ((scrollmenu === true) && ($(window).scrollTop() < 113)) {
            $(".editbox").css('position', 'absolute');
            $(".editbox").css('top', '');
            scrollmenu = false;
        }
    });
});
 
/*** /Scroll menu ***/
 
/*** Title page ***/
$('#write-article a').click(function () {
    $(this).hide();
    $('#create-page-lay').fadeIn();
    $('#create-page-lay .createboxInput').focus();
    $("#create-page-lay .createboxInput").focusout(function () {
        if ($(this).val() === "") {
            $('#create-page-lay').hide();
            $('#write-article a').fadeIn();
        }
    });
    return false;
});
 
/*** Blog page ***/
$(document).ready(function () {
    $('div.news.old').first().before("<div id='oldnews'></div>");
    $('div.news.old').appendTo($('#oldnews'));
    $('#oldnews').after("<div id='showarchive'><a class='show-link' href='#' class='showarchive'><span>Показать архив</span></a><a class='hide-link' href='#' class='showarchive' style='display:none'><span>Скрыть архив</span></a></div>");
    $('#showarchive a').click(function () {
        if ($(this).hasClass('show-link')) {
            $('#oldnews').fadeIn();
            $(this).hide().siblings().show()
                .stop();
        } else {
            $('#oldnews').hide();
            $(this).hide().siblings().show()
                .stop();
        }
    });
});
 
 
/*** Mobile menu ***/
if (mw.config.get('skin') == 'mobile') {
    $('.portlet h5').click(function () {
        var portlet = $(this);
        $('#portlet-bg').fadeIn('slow');
        portlet.parent().addClass('visible');
    });
    $('#close-portlet').click(function () {
        $(this).parent().fadeOut('slow');
        $('.portlet').removeClass('visible');
    });
}
 
/***********     NSFW     ***********/
$(document).on('click', '.NSFW', function (e) {
    e.preventDefault();
 
    $(this).removeClass('NSFW');
});
/***********    /NSFW     ***********/
 
/* Saladificator */
var now = new Date(),
    now_month = now.getMonth() + 1,
    now_day = now.getDate(),
    hash = window.location.hash.substr(1);
 
$(document).ready(function () {
    if ((now_month + '' + now_day) > 1228 || (now_month + '' + now_day) < 13) {
        //$('#mw-panel').addClass('saladificator')
    }
 
    if (!hash.includes("WG7Pg4o"))
        $('#mw-panel').addClass('ukraine');
    else
        $('#siteNotice').hide();
 
 
    /* TOC sticky */
    const toc = document.getElementById('toc');
 
    if (toc) {
        const directParent = toc.parentElement.classList.contains('tocright');
 
        var goToTopButton = document.createElement('div');
 
        goToTopButton.addEventListener('click', function (e) {
            window.scrollTo({ top: 0, behavior: 'auto' });
        });
 
        goToTopButton.setAttribute("id", "go_to_top");
        goToTopButton.innerHTML = '<span class="icon"></span>';
 
        toc.appendChild(goToTopButton);
 
        toc.querySelectorAll(':scope a').forEach(function (anchor) {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
 
                var anchorText = this.getAttribute('href'),
                    anchorId = anchorText.substring(1, anchorText.length);
 
                document.getElementById(anchorId).scrollIntoView({
                    behavior: 'smooth'
                });
 
                toc.classList.add('__hidden');
 
                // Update the URL without reloading the page
                var url = window.location.href.split('#')[0] + anchorText;
                history.pushState(null, null, url);
            });
        });
 
        if (!directParent) {
 
            var tocHeight = -toc.offsetHeight,
                topPos = toc.getBoundingClientRect().top - tocHeight,
                tocToggler = document.getElementById('toctitle');
 
            if (topPos <= tocHeight) {
                toc.classList.add('__sticky', '__ontop', '__hidden');
            }
 
            tocToggler.addEventListener("click", function () {
                toc.classList.toggle("__hidden");
            });
 
            document.addEventListener('scroll', function (e) {
                topPos = toc.getBoundingClientRect().top;
                setTimeout(function () {
                    if (topPos <= tocHeight) {
                        toc.classList.add('__sticky', '__ontop', '__hidden');
                    } else if (topPos && topPos >= 1) {
                        toc.classList.remove('__sticky', '__ontop');
                    }
                }, 50);
            });
        }
    }
 
});