Все мы знаем, какой пиздец сейчас происходит с Украиной и одной известной вам страной-победительницей-фашизма. Если вы хотите почитать об этом, помочь актуализировать информацию или высказать свое мнение — можете сделать это в статье Война в Украине и в обсуждении.
MediaWiki:Common.js — различия между версиями
Материал из Urbanculture
Строка 1: | Строка 1: | ||
− | /** Misc common defines *** | + | /** Misc common defines ****/ |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | */ | + | |
/* Неоднократно нужные проверки: */ | /* Неоднократно нужные проверки: */ | ||
Строка 14: | Строка 7: | ||
var _is_editpage = wgAction == 'edit' || wgAction == 'submit'; | var _is_editpage = wgAction == 'edit' || wgAction == 'submit'; | ||
var _is_editable = (function isEditable() { | var _is_editable = (function isEditable() { | ||
− | var restrict = (typeof wgRestrictionEdit !== 'undefined'?wgRestrictionEdit: | + | var restrict = (typeof wgRestrictionEdit !== 'undefined'?wgRestrictionEdit:[]); |
if (restrict.length < 1) return true; | if (restrict.length < 1) return true; | ||
if (!wgUserGroups) return false; | if (!wgUserGroups) return false; | ||
Строка 23: | Строка 16: | ||
var f5s=('localStorage' in window) && window['localStorage']!==null ? window['localStorage'] : false; | var f5s=('localStorage' in window) && window['localStorage']!==null ? window['localStorage'] : false; | ||
/** /Misc common defines ****/ | /** /Misc common defines ****/ | ||
+ | |||
/** Processing queue ****/ | /** Processing queue ****/ | ||
− | /**** Queue.addOnce(function(){}, condition = true) - adds function to run once on page load */ | + | /**** 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(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 */ | /**** 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 */ | /**** Both functions take optional second parameter - if false, function won't be run on current page */ | ||
Строка 34: | Строка 30: | ||
/**** 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() { | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | /** Edittools ****/ | |
− | + | /* Authors: [[User:Anotubus]], [[User:Obvious]] */ | |
− | + | Queue.addOnce('UC.edittools', 'tabbedEditTools', ( | |
− | + | !wgCanonicalSpecialPageName && | |
− | + | ( | |
− | + | location.href.match(/&action=(?:edit|submit)/) !== null || | |
+ | wgAction == 'edit' || | ||
+ | wgAction == 'submit' | ||
+ | ) || | ||
+ | wgPageName.match(/mediawiki:(?:edittools|topedittools)/i) !== null || | ||
+ | wgCanonicalNamespace.match(/talk$/i) !== null | ||
+ | ) ); | ||
+ | Queue.addOnce('UC.edittools', 'fileInsert', ( | ||
+ | !wgCanonicalSpecialPageName && | ||
+ | ( | ||
+ | location.href.match(/&action=(?:edit|submit)/) !== null || | ||
+ | wgAction == 'edit' || | ||
+ | wgAction == 'submit' | ||
+ | ) || | ||
+ | wgPageName.match(/mediawiki:(?:edittools|topedittools)/i) !== null || | ||
+ | wgCanonicalNamespace.match(/talk$/i) !== null | ||
+ | ) ); | ||
− | + | /** Collapsible tables ****/ | |
− | + | // Используется в коллапсерах | |
− | + | Queue.addEachFragment( 'UC.tablecollapsers','createTableCollapsers', !wgCanonicalSpecialPageName ); | |
− | + | ||
− | |||
− | |||
− | /** | + | /** NSFW Gallery Items ****/ |
− | /* | + | /* Description: Hides images with |NSFW in description from galleries */ |
− | /* Authors: | + | /* Authors: [[User:Anotubus]], [[User:Obvious]] */ |
+ | Queue.addEachFragment('UC.gallerymodify','processNSFWGalleryItems', !wgCanonicalSpecialPageName); | ||
− | // | + | /** Dynamic gallery ****/ |
− | + | Queue.addEachFragment('UC.gallerymodify','dynamicGallery', !wgCanonicalSpecialPageName); | |
− | + | ||
− | + | ||
− | + | /** Ajaxed *****/ | |
+ | Queue.addEachFragment('UC.ajaxed', 'ajaxed', !wgCanonicalSpecialPageName); | ||
− | |||
− | |||
− | |||
− | + | /** Morph LM Edition **************************************/ | |
− | + | Queue.addEachFragment('UC.morphobjects','createMorphObjects', !wgCanonicalSpecialPageName); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | /** 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') | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | Queue. | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | + | }) | |
− | + | }, !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) | |
− | + | $('.curreference').removeClass('curreference'); | |
− | var | + | if (iscurrent) return; |
− | + | ||
− | + | ||
− | $( | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | var par = x.parent(), o = par.offset(), l = o.left, t = o.top+13 | |
+ | var b = $('body'), mh = b.height(), mw = b.width() | ||
+ | var c=$(x.attr('href'), refs).clone().find('a:first').remove().end().html() | ||
− | / | + | 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) | ||
+ | }) | ||
+ | }, !wgCanonicalSpecialPageName) | ||
− | /** | + | /** Linkchecker ***/ |
+ | function linkchecker(scope) { | ||
+ | $('.linkchecker', scope).each(function(i, e) { | ||
+ | var lc_if = $(".linkcheckerif a", this) | ||
+ | var lc_then = $(".linkcheckerthen", this) | ||
+ | var 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, !wgCanonicalSpecialPageName); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | Queue. | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | /** | + | /** ShortDiffURL ****/ |
− | + | function shortdiffurl() { | |
− | function | + | if ($("#ca-history").size() > 0 ){ |
− | + | $("#ca-history").after('<li><a href="'+location.href.replace(/^(.+\?).*&?(diff=(?:\d+|prev|next|curr)).*?(&oldid=\d+)?.*$/,"$1$2$3")+'" title="Короткая ссылка на дифф">url</a></li>'); | |
− | + | ||
− | if ( | + | |
− | + | ||
− | + | ||
} | } | ||
− | + | }; | |
− | } | + | Queue.addOnce(shortdiffurl, !wgCanonicalSpecialPageName && location.href.indexOf("diff=") != -1) |
− | + | ||
− | + | ||
− | + | ||
− | |||
− | |||
− | |||
− | + | /** Needed page **/ | |
+ | Queue.addOnce(function() { | ||
+ | $('.mw-redirect').addClass('neededpagerdrcts'); | ||
+ | $('ul').addClass('neededpagelist'); | ||
+ | }, !wgCanonicalSpecialPageName && wgPageName == 'Urbanculture:R') | ||
− | + | /** Wikificator ************************************* */ | |
− | function | + | function wikification() { |
− | + | $('<button id="Wikifybutton" onclick="Wikify();" type="button">Викифицировать</button>').insertBefore($('#wpSave')); | |
− | + | if(wgNamespaceNumber==-1 || wgNamespaceNumber==108) {$('#Wikifybutton').attr('disabled','disabled');} | |
− | + | $('#editpage-copywarn').insertAfter('.editOptions'); | |
− | + | ||
} | } | ||
− | + | Queue.addOnce( 'UC.wikificator', wikification, !wgCanonicalSpecialPageName && wgAction == "edit" || wgAction == "submit" || wgPageName == "Special:Upload"); | |
− | + | ||
− | + | ||
− | |||
− | |||
− | |||
− | + | /** Image Categorizer ************************************* */ | |
− | + | /** Author: Anotubus */ | |
− | + | /* if ( (wgCanonicalNamespace == 'File' || wgNamespaceNumber == 6) && _is_autoconfirmed && _is_editable ) importScriptURI("/skins/common/imgcat.js");*/ | |
− | + | ||
− | + | ||
− | |||
− | |||
− | |||
− | + | /** Section menus ****************************************** */ | |
− | + | /* Authors: [[User:Tachikoma]], [[User:T_kns]], [[User:Мопец Ципельман]] */ | |
− | + | Queue.addOnce('UC.sectionmenus','addSectionMenus', !wgCanonicalSpecialPageName && skin=='impetus'); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | /** collapsibledivs *****/ | |
− | + | Queue.addOnce('UC.collapsiblesidebar','collapsibleSideBar', f5s && skin=='impetus'); | |
− | |||
− | |||
− | |||
+ | /* empty pagename ****/ | ||
Queue.addOnce(function() { | 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) { | |
− | if( | + | wrap.append($('<p class="pagenameneeded">Введите имя статьи</p>').delay(1500).fadeOut('slow',function() {$(this).remove();})); |
+ | } | ||
+ | return false; | ||
} | } | ||
}); | }); | ||
− | }, | + | }, !wgCanonicalSpecialPageName && 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 && wgCanonicalSpecialPageName == 'Preferences' ); | ||
+ | Queue.addEachFragment( 'UC.prettyphotify', 'prettyPhotify', f5s && localStorage.getItem('gallery_slideshow') != 'false' ); | ||
− | /* | + | /* By ****/ |
− | Queue. | + | Queue.addOnce(function() { |
− | + | $('body').addClass('ns-talk'); | |
+ | }, !wgCanonicalSpecialPageName && wgPageName == "Urbanculture:Вниманию_участников"); | ||
− | + | /* Spoilers ****/ | |
− | /** | + | Queue.addEachFragment(function(scope) { |
− | + | $('.spoiler',scope).click(function() { | |
− | + | $(this).toggleClass('spoilered'); | |
− | + | ||
− | + | ||
− | Queue.addEachFragment(function(scope | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}); | }); | ||
− | }, | + | }, !wgCanonicalSpecialPageName ); |
− | + | /* new gallerytemplate ****/ | |
− | + | //Queue.addEachFragment('UC.newgallerytemplate', 'newGalleryTemplate', !wgCanonicalSpecialPageName); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | /*** Resize textarea ***/ | |
− | + | Queue.addOnce('UC.autosizetextarea','autoSizeTextArea') | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
}); | }); | ||
− | |||
− | / | + | /** /Processing queue ****/ |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | |||
/*** Scroll menu ***/ | /*** Scroll menu ***/ | ||
Строка 915: | Строка 215: | ||
var windowWidth = $(window).width(); | var windowWidth = $(window).width(); | ||
$(document).scroll(function () { | $(document).scroll(function () { | ||
− | if ((scrollmenu == false) && ($(window).scrollTop() > 112) && ($(window).height() > 700) && ($('#content').outerHeight() > 750)) { | + | if ((scrollmenu == false) && ($(window).scrollTop() > 112) && ($(window).height() > 700) && ($('#content').outerHeight() > 750) && (skin=='impetus')) { |
$(".editbox").css('position', 'fixed'); | $(".editbox").css('position', 'fixed'); | ||
$(".editbox").css('top', '0'); | $(".editbox").css('top', '0'); | ||
Строка 928: | Строка 228: | ||
/*** /Scroll menu ***/ | /*** /Scroll menu ***/ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
/*** Title page ***/ | /*** Title page ***/ | ||
$('#write-article a').click(function () { | $('#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; | ||
}); | }); | ||
Строка 1028: | Строка 247: | ||
$('div.news.old').appendTo($('#oldnews')); | $('div.news.old').appendTo($('#oldnews')); | ||
$('#oldnews').after("<div id='showarchive'><a id='show-link' href='#' class='showarchive'><span>Показать архив</span></a></div>"); | $('#oldnews').after("<div id='showarchive'><a id='show-link' href='#' class='showarchive'><span>Показать архив</span></a></div>"); | ||
− | $('#show-link').toggle( function() { | + | $('#show-link').toggle(function () { |
− | + | $('#oldnews').fadeIn(); | |
− | + | $(this).html('<span>Скрыть архив</span>') | |
− | + | .stop(); | |
− | + | }, function () { | |
− | + | $('#oldnews').hide(); | |
− | + | $(this).html('<span>Показать архив</span>') | |
− | + | .stop(); | |
}); | }); | ||
+ | |||
+ | |||
+ | /*** Mobile menu ***/ | ||
+ | if (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') | ||
+ | }); | ||
+ | } |
Версия 20:36, 21 октября 2012
/** Misc common defines ****/ /* Неоднократно нужные проверки: */ /*** _is_editpage - я на странице редактирования? */ /*** _is_editable - у меня есть права на правку текущей страницы? */ /*** _is_autoconfirmed */ var _is_editpage = wgAction == 'edit' || wgAction == 'submit'; var _is_editable = (function isEditable() { var restrict = (typeof wgRestrictionEdit !== 'undefined'?wgRestrictionEdit:[]); if (restrict.length < 1) return true; if (!wgUserGroups) return false; for(var g=0; g<wgUserGroups.length; g++) if ($.inArray(wgUserGroups[g], restrict)!=-1) return true; return false; })(); var _is_autoconfirmed = wgUserGroups && ($.inArray('autoconfirmed', wgUserGroups) != -1); var f5s=('localStorage' in window) && window['localStorage']!==null ? window['localStorage'] : false; /** /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() { /** Edittools ****/ /* Authors: [[User:Anotubus]], [[User:Obvious]] */ Queue.addOnce('UC.edittools', 'tabbedEditTools', ( !wgCanonicalSpecialPageName && ( location.href.match(/&action=(?:edit|submit)/) !== null || wgAction == 'edit' || wgAction == 'submit' ) || wgPageName.match(/mediawiki:(?:edittools|topedittools)/i) !== null || wgCanonicalNamespace.match(/talk$/i) !== null ) ); Queue.addOnce('UC.edittools', 'fileInsert', ( !wgCanonicalSpecialPageName && ( location.href.match(/&action=(?:edit|submit)/) !== null || wgAction == 'edit' || wgAction == 'submit' ) || wgPageName.match(/mediawiki:(?:edittools|topedittools)/i) !== null || wgCanonicalNamespace.match(/talk$/i) !== null ) ); /** Collapsible tables ****/ // Используется в коллапсерах Queue.addEachFragment( 'UC.tablecollapsers','createTableCollapsers', !wgCanonicalSpecialPageName ); /** NSFW Gallery Items ****/ /* Description: Hides images with |NSFW in description from galleries */ /* Authors: [[User:Anotubus]], [[User:Obvious]] */ Queue.addEachFragment('UC.gallerymodify','processNSFWGalleryItems', !wgCanonicalSpecialPageName); /** Dynamic gallery ****/ Queue.addEachFragment('UC.gallerymodify','dynamicGallery', !wgCanonicalSpecialPageName); /** Ajaxed *****/ Queue.addEachFragment('UC.ajaxed', 'ajaxed', !wgCanonicalSpecialPageName); /** Morph LM Edition **************************************/ Queue.addEachFragment('UC.morphobjects','createMorphObjects', !wgCanonicalSpecialPageName); /** 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') } }) }, !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) $('.curreference').removeClass('curreference'); if (iscurrent) return; var par = x.parent(), o = par.offset(), l = o.left, t = o.top+13 var b = $('body'), mh = b.height(), mw = b.width() var c=$(x.attr('href'), refs).clone().find('a:first').remove().end().html() 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) }) }, !wgCanonicalSpecialPageName) /** Linkchecker ***/ function linkchecker(scope) { $('.linkchecker', scope).each(function(i, e) { var lc_if = $(".linkcheckerif a", this) var lc_then = $(".linkcheckerthen", this) var 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, !wgCanonicalSpecialPageName); /** ShortDiffURL ****/ function shortdiffurl() { if ($("#ca-history").size() > 0 ){ $("#ca-history").after('<li><a href="'+location.href.replace(/^(.+\?).*&?(diff=(?:\d+|prev|next|curr)).*?(&oldid=\d+)?.*$/,"$1$2$3")+'" title="Короткая ссылка на дифф">url</a></li>'); } }; Queue.addOnce(shortdiffurl, !wgCanonicalSpecialPageName && location.href.indexOf("diff=") != -1) /** Needed page **/ Queue.addOnce(function() { $('.mw-redirect').addClass('neededpagerdrcts'); $('ul').addClass('neededpagelist'); }, !wgCanonicalSpecialPageName && wgPageName == 'Urbanculture:R') /** Wikificator ************************************* */ function wikification() { $('<button id="Wikifybutton" onclick="Wikify();" type="button">Викифицировать</button>').insertBefore($('#wpSave')); if(wgNamespaceNumber==-1 || wgNamespaceNumber==108) {$('#Wikifybutton').attr('disabled','disabled');} $('#editpage-copywarn').insertAfter('.editOptions'); } Queue.addOnce( 'UC.wikificator', wikification, !wgCanonicalSpecialPageName && wgAction == "edit" || wgAction == "submit" || wgPageName == "Special:Upload"); /** Image Categorizer ************************************* */ /** Author: Anotubus */ /* if ( (wgCanonicalNamespace == 'File' || wgNamespaceNumber == 6) && _is_autoconfirmed && _is_editable ) importScriptURI("/skins/common/imgcat.js");*/ /** Section menus ****************************************** */ /* Authors: [[User:Tachikoma]], [[User:T_kns]], [[User:Мопец Ципельман]] */ Queue.addOnce('UC.sectionmenus','addSectionMenus', !wgCanonicalSpecialPageName && skin=='impetus'); /** collapsibledivs *****/ Queue.addOnce('UC.collapsiblesidebar','collapsibleSideBar', f5s && skin=='impetus'); /* 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; } }); }, !wgCanonicalSpecialPageName && 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 && wgCanonicalSpecialPageName == 'Preferences' ); Queue.addEachFragment( 'UC.prettyphotify', 'prettyPhotify', f5s && localStorage.getItem('gallery_slideshow') != 'false' ); /* By ****/ Queue.addOnce(function() { $('body').addClass('ns-talk'); }, !wgCanonicalSpecialPageName && wgPageName == "Urbanculture:Вниманию_участников"); /* Spoilers ****/ Queue.addEachFragment(function(scope) { $('.spoiler',scope).click(function() { $(this).toggleClass('spoilered'); }); }, !wgCanonicalSpecialPageName ); /* new gallerytemplate ****/ //Queue.addEachFragment('UC.newgallerytemplate', 'newGalleryTemplate', !wgCanonicalSpecialPageName); /*** Resize textarea ***/ Queue.addOnce('UC.autosizetextarea','autoSizeTextArea') }); /** /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() > 700) && ($('#content').outerHeight() > 750) && (skin=='impetus')) { $(".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 ***/ $('div.news.old').first().before("<div id='oldnews'></div>"); $('div.news.old').appendTo($('#oldnews')); $('#oldnews').after("<div id='showarchive'><a id='show-link' href='#' class='showarchive'><span>Показать архив</span></a></div>"); $('#show-link').toggle(function () { $('#oldnews').fadeIn(); $(this).html('<span>Скрыть архив</span>') .stop(); }, function () { $('#oldnews').hide(); $(this).html('<span>Показать архив</span>') .stop(); }); /*** Mobile menu ***/ if (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') }); }