|
|
Строка 1: |
Строка 1: |
− | /** Misc common defines ****/ | + | importScript_ = importScript |
| + | importScript = function (page, proj){ |
| + | if (!proj) importScript_(page) |
| + | else { |
| + | if (proj.indexOf('.')==-1) proj += '.wikipedia.org' |
| + | importScriptURI('http://'+proj+'/w/index.php?action=raw&ctype=text/javascript&title='+encodeURIComponent(page.replace(/ /g,'_'))) |
| + | } |
| + | } |
| | | |
− | var _is_editpage = wgAction == 'edit' || wgAction == 'submit'; | + | function newSectionLink(){ |
| + | var plus = document.getElementById('ca-addsection') |
| + | if (!plus) return |
| + | var custom = document.getElementById('add-custom-section') |
| + | if (!custom) return |
| + | plus.firstChild.setAttribute('href', custom.getElementsByTagName('a')[0].href) |
| + | } |
| | | |
| + | function editZeroSection(){ |
| + | var body = document.getElementById('bodyContent') |
| + | if (!body) return |
| + | var h2s = body.getElementsByTagName('H2') |
| + | var h2 = h2s[0] |
| + | if (!h2) return |
| + | if (h2.parentNode.id == 'toctitle') h2 = h2s[1] |
| + | if (!h2) return |
| + | var span = h2.firstChild |
| + | if (!span || span.className != 'editsection') return |
| + | var zero = span.cloneNode(true) |
| + | body.insertBefore(zero, body.firstChild) |
| + | var a = zero.getElementsByTagName('a')[0] |
| + | if (a.href.indexOf('§ion=T') == -1 ) a.title = a.title.replace(/:.*$/,': 0') |
| + | else a.title = 'Править секцию: 0' |
| + | a.setAttribute('href', wgScript + '?title='+encodeURIComponent(wgPageName) + '&action=edit§ion=0') |
| + | } |
| | | |
− | /**** Queue.addOnce(function(){}, condition = true) - adds function to run once on page load */ | + | //Execution |
− | /**** Queue.addEachFragment(function(scope){}, condtion = true) - 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 */
| + | |
| | | |
− | var Queue = {
| + | if (wgAction=='edit' || wgAction=='submit') importScript_('MediaWiki:Editpage.js') |
− | _once: [],
| + | |
− | _each: [],
| + | |
− | addOnce: function(f, pre) { if (pre !== false) this._once.push(f); return this; },
| + | |
− | addEachFragment: function(f, pre) { if (pre !== false) this._each.push(f); return this; },
| + | |
| | | |
− | runOnce: function() {
| + | /** Collapsible tables ********************************************************* |
− | $.each(this._once, function(i, f) { f() })
| + | * |
− | return this;
| + | * Description: Allows tables to be collapsed, showing only the header. See |
− | },
| + | * [[Wikipedia:NavFrame]]. |
− | runEachFragment: function(sc) {
| + | * Maintainers: [[User:R. Koot]] |
− | var que = this._each, sc = sc || document;
| + | */ |
− |
| + | |
− | $(sc).each(function(x, e) { $.each(que, function(i, f) { f(e) }) });
| + | |
− | return this;
| + | |
− | }
| + | |
− | };
| + | |
− | | + | |
− | addOnloadHook(function() { Queue.runOnce().runEachFragment(document); })
| + | |
− | /** /Processing queue ****/ | + | |
− | | + | |
− | | + | |
− | /** Miscellanea ****/
| + | |
− | | + | |
− | // Paranoia
| + | |
− | | + | |
− | if (wgPageName == "Паранойя" && wgIsArticle == true && navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(){}); }
| + | |
− | | + | |
− | // jew-jitsu by enhydra
| + | |
− | Queue.addOnce(function(){ if (document.getElementById("logo-jews")) document.body.className += " body-jews" });
| + | |
− | | + | |
− | /** /Miscellanea ****/
| + | |
− | | + | |
− | | + | |
− | /** Collapsible tables ****/
| + | |
− | /* Description: Allows tables to be collapsed, showing only the header. */
| + | |
− | /* Authors: rewrite by [[User:Tachikoma]] based on [[Wikipedia:NavFrame]] */
| + | |
− | | + | |
− | // Используется в коллапсерах
| + | |
| var autoCollapse = 2; | | var autoCollapse = 2; |
− | var collapseCaption = "скрыть"; | + | var collapseCaption = "[спрятать]"; |
− | var expandCaption = "показать"; | + | var expandCaption = "[показать]"; |
− | | + | |
− | function createTableCollapsers(scope) { | + | function collapseTable( tableIndex ) |
− | | + | { |
− | function collapseTable(tbl) { | + | var Button = document.getElementById( "collapseButton" + tableIndex ); |
− | var rows = $('tr', tbl).not('tr:first')
| + | var Table = document.getElementById( "collapsibleTable" + tableIndex ); |
− | var btn = $('a.collapselink', tbl)
| + | |
− |
| + | if ( !Table || !Button ) { |
− | if (btn.text() == collapseCaption) {
| + | return false; |
− | rows.hide(); btn.text(expandCaption)
| + | |
− | } else { | + | |
− | rows.show(); btn.text(collapseCaption)
| + | |
− | }
| + | |
| } | | } |
− |
| |
− | var autocollapse_count = 0;
| |
− | $('table.collapsible', scope).each(function(i, e) {
| |
− | var header = $('tr th:first', e)
| |
− | if (!header.size()) return;
| |
− |
| |
− | autocollapse_count++;
| |
− |
| |
− | var collapselink = $('<a href="#" class="collapselink"/>').text(collapseCaption)
| |
− | collapselink.click(function(ev) { ev.preventDefault(); collapseTable(e) })
| |
− |
| |
− | var collapsebutton = $('<span style="float:right; text-align:right; width:6em; font-weight:normal">[<a></a>]</span>')
| |
− | $('a', collapsebutton).replaceWith(collapselink)
| |
− |
| |
− | header.prepend(collapsebutton)
| |
− |
| |
− | if ($(e).hasClass('collapsed') || ( autocollapse_count >= autoCollapse && $(e).hasClass('autocollapsible'))) collapseTable(e)
| |
− | });
| |
− | };
| |
− |
| |
− | Queue.addEachFragment( createTableCollapsers );
| |
− |
| |
− | /** /Collapsible tables ****/
| |
− |
| |
− |
| |
− | /** Dynamic Navigation Bars (experimental) *************************************
| |
− | *
| |
− | * Description: See [[Wikipedia:NavFrame]].
| |
− | * Authors: rewrite by [[User:Tachikoma]] based on [[Wikipedia:NavFrame]]
| |
− | */
| |
| | | |
− | function createHiderButtons(scope) {
| + | var Rows = Table.rows; |
− | // set up the words in your language
| + | |
− | var NavigationBarHide = '[' + collapseCaption + ']';
| + | if ( Button.firstChild.data == collapseCaption ) { |
− | var NavigationBarShow = '[' + expandCaption + ']';
| + | for ( var i = 1; i < Rows.length; i++ ) { |
− | | + | Rows[i].style.display = "none"; |
− | $('div.NavFrame', scope).each(function(i, e) { | + | |
− | var _ = $(this), head = _.children('.NavHead')
| + | |
− | | + | |
− | if(!head.size()) return;
| + | |
− |
| + | |
− | var shown = true;
| + | |
− | var NavToggle = $('<a href="#"></a>').text(NavigationBarHide)
| + | |
− |
| + | |
− | function toggle() {
| + | |
− | shown = !shown;
| + | |
− | if(shown) {
| + | |
− | _.children('.NavContent').show(); _.children('.NavPic').show(); NavToggle.text(NavigationBarHide)
| + | |
− | } else { | + | |
− | _.children('.NavContent').hide(); _.children('.NavPic').hide(); NavToggle.text(NavigationBarShow)
| + | |
− | };
| + | |
| } | | } |
− | | + | Button.firstChild.data = expandCaption; |
− | NavToggle.click(function(ev) { ev.preventDefault(); toggle(); }) | + | } else { |
− | head.append(NavToggle);
| + | for ( var i = 1; i < Rows.length; i++ ) { |
− | | + | Rows[i].style.display = Rows[0].style.display; |
− | if($(this).hasClass('NavHideByDefault')) toggle();
| + | |
− | }) | + | |
− | }
| + | |
− | | + | |
− | Queue.addEachFragment( createHiderButtons );
| + | |
− | | + | |
− | /** /Dynamic Navigation Bars ****/
| + | |
− | | + | |
− | | + | |
− | /** NSFW Gallery Items ****/
| + | |
− | /* Description: Hides images with |NSFW in description from galleries */
| + | |
− | /* Authors: [[User:Anotubus]], [[User:Obvious]] */
| + | |
− | | + | |
− | function processNSFWGalleryItems(scope) {
| + | |
− | $('div.gallerytext', scope).each(function(i, el) {
| + | |
− | var descP = $('p:first', el)
| + | |
− | if (!descP.size()) return;
| + | |
− |
| + | |
− | var desc = descP.html()
| + | |
− | if (desc.match(/(?:\|NSFW|NSFW\||^NSFW\s$)/i)) {
| + | |
− | descP.html(desc.replace(/(.*)(?:\|NSFW|NSFW\||^NSFW\s$)(.*)/i,'$1$2')); | + | |
− | var NSFWFrame = $(el).parent().find('div:first')
| + | |
− | NSFWFrame.children().css('visibility', 'hidden')
| + | |
− | NSFWFrame.css({'background':'url(/skins/common/images/nsfw.png) no-repeat center center', 'cursor':'pointer'})
| + | |
− | NSFWFrame.click(function(e) {
| + | |
− | NSFWFrame.css({'background':'none', 'cursor':'default'})
| + | |
− | NSFWFrame.children().css('visibility', 'visible')
| + | |
− | })
| + | |
| } | | } |
− | })
| + | Button.firstChild.data = collapseCaption; |
− | };
| + | |
− | | + | |
− | Queue.addEachFragment(processNSFWGalleryItems);
| + | |
− | | + | |
− | /** /NSFW Gallery Items ****/
| + | |
− | | + | |
− | | + | |
− | /** 0sectionedit ****/
| + | |
− | function Sect0Edit(){
| + | |
− | var editlink = $("#ca-edit a")
| + | |
− | if (!editlink.size()) return;
| + | |
− | var spansect0span = $('<span class="editsection">[<a>править</a>]</span>')
| + | |
− | $('a', spansect0span).attr('href', editlink.attr('href')+"§ion=0")
| + | |
− | $(".firstHeading").append(spansect0span)
| + | |
− | };
| + | |
− | | + | |
− | Queue.addOnce(Sect0Edit, wgIsArticle == true && skin!='vector')
| + | |
− | /** /0sectionedit ****/
| + | |
− | | + | |
− | | + | |
− | /** X-Roller *************************************
| + | |
− | *
| + | |
− | * Description: works only on the page with a id="xroller" element on it
| + | |
− | */
| + | |
− | | + | |
− | function crc32(str){function Utf8Encode(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if (c<128){utftext+=String.fromCharCode(c);}
| + | |
− | else if ((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
| + | |
− | else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
| + | |
− | return utftext;};str=Utf8Encode(str);var table="00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";var crc=0;if (typeof(crc)=="undefined"){crc=0;}
| + | |
− | var x=0;var y=0;crc=crc^(-1);for(var i=0,iTop=str.length;i<iTop;i++){y=(crc^str.charCodeAt(i))&0xFF;x="0x"+table.substr(y*9,8);crc=(crc>>>8)^x;}
| + | |
− | return crc^(-1);};
| + | |
− | | + | |
− | function XRoller() {
| + | |
− | if ( document.getElementById('xroller') != null
| + | |
− | && wgIsArticle == true
| + | |
− | && (skin == "monobook" || skin == "modern" || skin == "vector")
| + | |
− | && location.href.match(/(diff=)/) == null/*
| + | |
− | Здесь, особо хитрожопым кодерастам стоит взять на заметку:
| + | |
− | Только потому, что ты разгадал секрет — еще не значит, что ты можешь невозбранно лепить XRoller© всюду, где захочешь.
| + | |
− | Несанкционированное использование карается баном. Тебя предупредили. */
| + | |
− | && document.getElementById('xroller').getAttribute('title').replace(/^.*@code=([^@]*)@.*$/, '$1') == crc32('ololorolled'+wgPageName)
| + | |
− | && document.getElementById('xroller').getAttribute('class').match(/^(video|image|audio|screamer)$/)
| + | |
− | ) { | + | |
− | var xroller = document.getElementById('xroller');
| + | |
− | var xrollerClass = xroller.getAttribute('class');
| + | |
− | var xrollerPrefs = xroller.getAttribute('title');
| + | |
− | var blend;
| + | |
− | var blendElements;
| + | |
− | var globalWrapper=document.getElementsByTagName('body')[0];
| + | |
− | // id's of HUD-elements of the skins to hide&restore
| + | |
− | var monobookElements = [ 'column-content', 'column-one' ];
| + | |
− | var vectorElements = [ 'column-content', 'column-one' ];
| + | |
− | var modernElements = [ 'mw_header', 'mw_main', 'p-personal', 'footer' ];
| + | |
− | function massSetAttributes(obj, data) { for (i in data) { obj.setAttribute(data[i][0], data[i][1]) } };
| + | |
− | function HideElements(elementsToHide) { for (i in elementsToHide) { document.getElementById(elementsToHide[i]).setAttribute('style','display:none') } };
| + | |
− | function blendClick(elementsToRestore) {
| + | |
− | for (i in elementsToRestore) { document.getElementById(elementsToRestore[i]).removeAttribute('style') };
| + | |
− | for (i in blendElements) { blendElements[i].parentNode.removeChild(blendElements[i]) };
| + | |
− | globalWrapper.removeChild(blend);
| + | |
− | };
| + | |
− | function getXRPref(prefname) { return xrollerPrefs.replace( (new RegExp('^.*@'+prefname+'=([^@]*)@.*$', 'g')), '$1' ) };
| + | |
− |
| + | |
− | blend=document.createElement('div');
| + | |
− | massSetAttributes(blend, [ ['style','cursor: pointer; display:block; height:100%; position:fixed; right:0; top:0; width:100%; z-index:5; background-color:white; opacity:1;'], ['title','Убрать'], ['align','center'] ]);
| + | |
− | addClickHandler(blend, function () { blendClick( eval(skin+'Elements') )} );
| + | |
− | // IN ANOTHER UNIVERSE: TODO: добавить object для ослоёбов
| + | |
− | // RE: Ослоёбы сосут ослячие хуйцы
| + | |
− | var innerRollerWrapper=document.createElement('div');
| + | |
− | switch ( xrollerClass ) {
| + | |
− | case 'video' : {
| + | |
− | massSetAttributes(innerRollerWrapper, [ ['style', 'vertical-align: middle; padding-top: 50px;'] ]);
| + | |
− | var rollerMedia=document.createElement('video');
| + | |
− | massSetAttributes(rollerMedia, [ ['controls', ''], ['autoplay', ''], ['width', getXRPref('width')?getXRPref('width'):'280'], ['height', getXRPref('height')?getXRPref('height'):'210'], ['src', getXRPref('video')?getXRPref('video'):''], ['tabindex', '0'], ['style', 'background-image: url("'+(getXRPref('gif')?getXRPref('gif'):'')+'"); background-repeat: no-repeat; background-position: center bottom'] ]);
| + | |
− | var rollerEmbed=document.createElement('embed');
| + | |
− | massSetAttributes(rollerEmbed, [ ['type', 'application/x-shockwave-flash'], ['src', getXRPref('embed')?getXRPref('embed'):''], ['width', getXRPref('width')?getXRPref('width'):'280'], ['height', getXRPref('height')?getXRPref('height'):'210'], ['allowfullscreen', 'true'], ['allowscriptaccess', 'always'], ['style', 'background-image: url("'+(getXRPref('gif')?getXRPref('gif'):'')+'"); background-repeat: no-repeat; background-position: center bottom'] ]);
| + | |
− | innerRollerWrapper.appendChild(rollerMedia);
| + | |
− | rollerMedia.appendChild(rollerEmbed);
| + | |
− | blendElements = [ rollerEmbed, rollerMedia, innerRollerWrapper ];
| + | |
− | } break;
| + | |
− | case 'image' : {
| + | |
− |
| + | |
− | } break;
| + | |
− | case 'audio' : {
| + | |
− |
| + | |
− | } break;
| + | |
− | case 'screamer' : {
| + | |
− |
| + | |
− | } break;
| + | |
− | default: ;
| + | |
− | };
| + | |
− | xroller.parentNode.removeChild(xroller);
| + | |
− | eval('HideElements('+skin+'Elements)');
| + | |
− | blend.appendChild(innerRollerWrapper);
| + | |
− | globalWrapper.appendChild(blend);
| + | |
− | };
| + | |
− | };
| + | |
− | | + | |
− | Queue.addOnce(XRoller);
| + | |
− | /** /X-Roller ****/
| + | |
− | | + | |
− | | + | |
− | /** Morph LM Edition *************************************
| + | |
− | *
| + | |
− | * Description: слайдер скрытого контента
| + | |
− | * Stolen^W Made by: hikki-zadrot, Tachikoma, Anotubus
| + | |
− | */
| + | |
− | | + | |
− | function createMorphObjects(scope) {
| + | |
− | $('.morphcontainer', scope).each(function() {
| + | |
− | var _this = this, all = $('*', this)
| + | |
− | | + | |
− | var containers = $('* .morphcontainer', this);
| + | |
− | containers.each(function() { all = all.not($('*', this)) })
| + | |
− | | + | |
− | var morphlinks = all.filter('.morphlink')
| + | |
− | var morphcontents = all.filter('.morphcontent')
| + | |
− | var morphlink_hilight = $(_this).children('.morphlink_hilight').size()? $(_this).children('.morphlink_hilight').eq(0).attr('style'):'color:blue; text-decoration:underline; cursor: pointer;',
| + | |
− | morphlink_default = $(_this).children('.morphlink_default').size()? $(_this).children('.morphlink_default').eq(0).attr('style'):'color:blue; cursor: pointer;',
| + | |
− | selmethod = $(_this).hasClass('hover') ? 'mouseover' : 'click',
| + | |
− | currentsel = 0;
| + | |
− | $(morphcontents).hide();
| + | |
− | $(_this).children('.morphlink_hilight, .morphlink_default').remove();
| + | |
− | $(morphlinks).attr('style', morphlink_default).each(function(i, e) {
| + | |
− | var assocmorphcontents = $('');
| + | |
− | if ($(_this).hasClass('manualsort')) {
| + | |
− | var morphlinkers = $(e).attr('class').replace(/(.*)morphlink(.*)/, '$1$2').match(/morph\S+/g);
| + | |
− | for (x in morphlinkers)
| + | |
− | assocmorphcontents = $(assocmorphcontents).add($(morphcontents).filter('.' + morphlinkers[x]));
| + | |
− | } else {
| + | |
− | assocmorphcontents = $(assocmorphcontents).add($(morphcontents).eq(i));
| + | |
− | }
| + | |
− | $(e).bind(selmethod, function() {
| + | |
− | $(morphlinks).attr('style', morphlink_default);
| + | |
− | $(e).attr('style', morphlink_hilight);
| + | |
− | $(morphcontents).hide();
| + | |
− | $(assocmorphcontents).show();
| + | |
− | currentsel = i;
| + | |
− | });
| + | |
− | });
| + | |
− | all.filter('.morphprev, .morphnext').click(function() {
| + | |
− | var totrigger = $(this).hasClass('morphprev') ? (currentsel - 1) : ((currentsel + 1));
| + | |
− | if (totrigger < 0) totrigger = morphlinks.size() - 1;
| + | |
− | if (totrigger > morphlinks.size() - 1) totrigger = 0;
| + | |
− | $(morphlinks).eq(totrigger).triggerHandler(selmethod);
| + | |
− | });
| + | |
− | $(morphlinks).eq(currentsel).triggerHandler(selmethod);
| + | |
− | });
| + | |
− | }
| + | |
− | | + | |
− | Queue.addEachFragment(createMorphObjects);
| + | |
− | | + | |
− | /** /Morph LM Edition ****/
| + | |
− | | + | |
− | | + | |
− | /** Tabbed Edittools *************************************
| + | |
− | *
| + | |
− | * Description: Делает из таблицы edittools страницы с табами.
| + | |
− | * Made by: Tachikoma, Anotubus
| + | |
− | */
| + | |
− | | + | |
− | (function(){
| + | |
− | var TabSwitchTimer = null
| + | |
− | var TabSwitchGlobState = 0
| + | |
− | var MyEditTools = {
| + | |
− |
| + | |
− | updateFirstVisible: function() {
| + | |
− | $('.first').removeClass('first'); $("#editpage-specialchars table tr:visible").eq(0).addClass('first')
| + | |
− | },
| + | |
− |
| + | |
− | setAll: function(t) {
| + | |
− | var rows = $('#editpage-specialchars table tr'), sw = $("#switcher div")
| + | |
− | if (t) {
| + | |
− | var cl = t>0?"visible":"hidden"; rows.each(function(i) { if (!TabSwitchGlobState) $(this).data('prevstate', this.className); this.className = cl })
| + | |
− | var cl = t>0?"fixed":""; sw.each(function(i) { if (!TabSwitchGlobState) $(this).data('prevstate', this.className); this.className = cl })
| + | |
− | } else {
| + | |
− | rows.each(function(i) { this.className = $(this).data('prevstate') || '' })
| + | |
− | sw.each(function(i) { this.className = $(this).data('prevstate') || '' })
| + | |
− | }
| + | |
− | TabSwitchGlobState = t
| + | |
− | $('#pageShowAll').attr('class', t > 0 ? 'swon' : 'swoff'); $('#pageHideAll').attr('class', t < 0 ? 'swon' : 'swoff')
| + | |
− | MyEditTools.updateFirstVisible()
| + | |
− | },
| + | |
− |
| + | |
− | clearTimer: function() {
| + | |
− | if (TabSwitchTimer) { window.clearTimeout(TabSwitchTimer); TabSwitchTimer = null }
| + | |
− | },
| + | |
− |
| + | |
− | clearSelected: function() {
| + | |
− | $('#switcher div.selected').removeClass('selected')
| + | |
− | $('#editpage-specialchars table tr.selected').removeClass('visible').addClass('hidden').removeClass('selected')
| + | |
− | },
| + | |
− |
| + | |
− | init: function() {
| + | |
− | if (!$('#editpage-specialchars').size()) return
| + | |
− | | + | |
− | $('#editpage-specialchars').css('border', "none")
| + | |
− |
| + | |
− | //var switcher = $('<div id="switcher"/>').insertBefore($("#editpage-specialchars table"))
| + | |
− | var switcher = $('<caption style="text-align:left" id="switcher"/>').prependTo($("#editpage-specialchars table"));
| + | |
− | var rows = $("#editpage-specialchars table tr")
| + | |
− | rows.each(function(i) {
| + | |
− | var id = "page"+i,td = $('td:first', this)
| + | |
− | var row = $(this).attr('id', 'r'+id).addClass(i == 0 ? "visible" : "hidden").toggleClass("first", !i).toggleClass("selected",!i)
| + | |
− | var sw = $('<div/>')
| + | |
− | .attr("id", "sw"+id).html((td.html() || '').replace(/:/, ''))
| + | |
− | .hover(function(e) {
| + | |
− | MyEditTools.clearTimer()
| + | |
− | if (sw.hasClass("fixed")) return
| + | |
− | TabSwitchTimer = window.setTimeout(function() {
| + | |
− | MyEditTools.clearSelected()
| + | |
− | sw.addClass('selected'); row.addClass('selected').removeClass('hidden').addClass('visible')
| + | |
− | MyEditTools.updateFirstVisible()
| + | |
− | }, 50)
| + | |
− | }, MyEditTools.clearTimer)
| + | |
− | .click(function(e){
| + | |
− | MyEditTools.clearTimer()
| + | |
− | if (!sw.hasClass('fixed')) {
| + | |
− | sw.removeClass("selected").addClass("fixed")
| + | |
− | row.removeClass("selected").removeClass("hidden").addClass("visible")
| + | |
− | } else {
| + | |
− | MyEditTools.clearSelected()
| + | |
− | sw.removeClass("fixed").addClass("selected")
| + | |
− | }
| + | |
− | MyEditTools.updateFirstVisible()
| + | |
− | })
| + | |
− | .appendTo(switcher)
| + | |
− | .toggleClass("selected", !i)
| + | |
− | })
| + | |
− |
| + | |
− | with(switcher){
| + | |
− | append($('<div id="pageHideAll" class="swoff">Hide All</div>').click(function() {
| + | |
− | MyEditTools.clearTimer(); MyEditTools.setAll(TabSwitchGlobState<0?0:-1)
| + | |
− | }))
| + | |
− | append($('<div id="pageShowAll" class="swoff">Show All</div>').click(function() {
| + | |
− | MyEditTools.clearTimer(); MyEditTools.setAll(TabSwitchGlobState>0?0:1)
| + | |
− | }))
| + | |
− | }
| + | |
− | | + | |
− | $('#toolbar').before($('.mw-editTools'))
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | Queue.addOnce(MyEditTools.init, _is_editpage);
| + | |
− | })();
| + | |
− | | + | |
− | /** /Tabbed Edittools ****/
| + | |
− | | + | |
− | | + | |
− | /** 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')
| + | |
− | }
| + | |
− | })
| + | |
− | }).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)
| + | |
− | })
| + | |
− | })
| + | |
− | /** /Ref tooltips****************************************/
| + | |
− | | + | |
− | | + | |
− | /** 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);
| + | |
− | /** /Linkchecker ****/
| + | |
− | | + | |
− | | + | |
− | /** 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, location.href.indexOf("diff=") != -1)
| + | |
− | /** /ShortDiffURL ****/
| + | |
− | | + | |
− | | + | |
− | /** Needed page **/
| + | |
− | Queue.addOnce(function() {
| + | |
− | $('.mw-redirect').addClass('neededpagerdrcts');
| + | |
− | $('ul').addClass('neededpagelist');
| + | |
− | }, wgPageName == 'Lurkmore:Нужные_статьи')
| + | |
− | /** /Needed page **/
| + | |
− | | + | |
− | | + | |
− | /** Gay-roller **/
| + | |
− | Queue.addOnce(function() {
| + | |
− | if (Math.random() > 0.5) {
| + | |
− | $("img[src='/images/6/68/S%D0%BEtilas_test.jpg']").attr('src', '/images/5/51/Sotilas_test.jpg')
| + | |
− | } else {
| + | |
− | $("img[src='/images/5/51/Sotilas_test.jpg']").attr('src', '/images/6/68/S%D0%BEtilas_test.jpg')
| + | |
| } | | } |
− | }, wgPageName == 'Финский_армейский_тест')
| |
− | /** /Gay-roller **/
| |
− |
| |
− |
| |
− | /** Summary buttons ************************************* */
| |
− | function insertSummary(text) {
| |
− | var sum = document.getElementById('wpSummary')
| |
− | if (sum.value.indexOf(text) != -1) return
| |
− | if (sum.value.match(/[^,; \/]$/)) sum.value += ','
| |
− | if (sum.value.match(/[^ ]$/)) sum.value += ' '
| |
− | sum.value += text
| |
| } | | } |
− | function addSumButton(name, text, title) {
| + | |
− | var btn = document.createElement('a')
| + | function createCollapseButtons() |
− | btn.appendChild(document.createTextNode(name))
| + | |
− | btn.title = title || text
| + | |
− | btn.onclick = function(){insertSummary(text)}
| + | |
− | document.getElementById('userSummaryButtonsA').appendChild(btn)
| + | |
− | }
| + | |
− | function SummaryButtons(){
| + | |
− | var sum = document.getElementById('wpSummary')
| + | |
− | if (!sum || (sum.form.wpSection && sum.form.wpSection.value == 'new')) return
| + | |
− | | + | |
− | var sp = document.createElement('span'); sp.id = 'userSummaryButtonsA'
| + | |
− | sum.parentNode.insertBefore(sp, sum.nextSibling)
| + | |
− | sum.parentNode.insertBefore(document.createElement('br'), sum.nextSibling)
| + | |
− | addSumButton('викиф.','викификация','Тыц на кнопочку')
| + | |
− | addSumButton('оформл.','оформление','Оформление отремонтировано')
| + | |
− | addSumButton('стиль','стиль','Поправлен стиль статей, текстов и постов')
| + | |
− | addSumButton('орфогр.','орфография','Поправлена орфографика и пунктуация')
| + | |
− | addSumButton('пруфлинк','пруфлинк','Добавлены пруфлинки')
| + | |
− | addSumButton('кат.','категория','Исправлена категория')
| + | |
− | addSumButton('шаб.','шаблон','Гы! Шаблончег!')
| + | |
− | addSumButton('доп.','дополнение','Добавлены новые свѣденiя')
| + | |
− | addSumButton('картинка','картинка','Пруфпик, десу')
| + | |
− | addSumButton('обнов.','упдейт','Обновлены устаревшие данные')
| + | |
− | addSumButton('shitty','+{{говно}}','Ваша статья говно! Я гарантирую это!')
| + | |
− | addSumButton('moar','+{{moar}}','Требуются пруфлинки, пруфпики и косплееры-лесбиянки')
| + | |
− | }
| + | |
− | | + | |
− | Queue.addOnce(SummaryButtons, _is_editpage);
| + | |
− | /** /Summary buttons ****/
| + | |
− | | + | |
− | | + | |
− | /** Wikificator ************************************* */
| + | |
− | if (wgAction == "edit" || wgAction == "submit" || wgPageName == "Special:Upload") //scripts specific to editing pages
| + | |
| { | | { |
− | importScriptURI("/skins/common/wikificator.js"); | + | var tableIndex = 0; |
− | }
| + | var NavigationBoxes = new Object(); |
− | | + | var Tables = document.getElementsByTagName( "table" ); |
− | function wikification() {
| + | |
− | $('<button id="Wikifybutton" onclick="Wikify();" type="button">Викифицировать</button>').insertBefore($('#wpSave')); | + | for ( var i = 0; i < Tables.length; i++ ) { |
− | if(wgNamespaceNumber==-1 || wgNamespaceNumber==102) {$('#Wikifybutton').attr('disabled','disabled');} | + | if ( hasClass( Tables[i], "collapsible" ) ) { |
− | $('#editpage-copywarn').insertAfter('.editOptions');
| + | |
− | }
| + | /* only add button and increment count if there is a header row to work with */ |
− | Queue.addOnce(wikification);
| + | var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; |
− | /** /Wikificator ************************************* */
| + | if (!HeaderRow) continue; |
− | | + | var Header = HeaderRow.getElementsByTagName( "th" )[0]; |
− | /** Section menus ****************************************** */ | + | if (!Header) continue; |
− | /* Authors: [[User:Tachikoma]], [[User:T_kns]], [[User:Мопец Ципельман]] */
| + | |
− | | + | NavigationBoxes[ tableIndex ] = Tables[i]; |
− | // SectionToolbar.addButton(function(elt, out) { var button = $(elt).find('something'); $(out).doAnythingWith(button); })
| + | Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex ); |
− | // SectionToolbar.appendButton(function(elt) { var button = $(elt).find('something'); return button; }
| + | |
− | var SectionToolbar = {
| + | var Button = document.createElement( "span" ); |
− | _buttons: [],
| + | var ButtonLink = document.createElement( "a" ); |
− | addButton: function(fn) { this._buttons.push(fn); return this },
| + | var ButtonText = document.createTextNode( collapseCaption ); |
− | appendButton: function(fn) { this._buttons.push(function(elt, out) { $(out).append(fn(elt)) }); return this },
| + | |
− | _run: function(elt, out) { var btn = this._buttons; for(var i in btn) btn[i](elt, out) }
| + | Button.className = "collapseButton"; //Styles are declared in Common.css |
− | }
| + | |
− | | + | ButtonLink.style.color = Header.style.color; |
− | function addSectionMenus() {
| + | ButtonLink.setAttribute( "id", "collapseButton" + tableIndex ); |
− | if (!wgIsArticle) return;
| + | ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" ); |
− | | + | ButtonLink.appendChild( ButtonText ); |
− | var editimg = '<img src="/skins/vector/pencil.png" width="16" height="16" alt="Править" title="Править"/>'
| + | |
− | var viewimg = '<img src="/skins/vector/magnifier.png" width="16" height="16" alt="Просмотр" title="Просмотр"/>'
| + | Button.appendChild( document.createTextNode( "" ) ); |
− | | + | Button.appendChild( ButtonLink ); |
− | var new_header = $('<h1 class="firstHeading" id="firstHeading"></h1>')
| + | Button.appendChild( document.createTextNode( "" ) ); |
− | var headline = $('<span></span>').text($('#firstHeading').text()).appendTo(new_header) | + | |
− | var toolbar = $('<div class="showmenu"/>').appendTo(new_header).hide()
| + | Header.insertBefore( Button, Header.childNodes[0] ); |
− | var toolsline = $('<div class="toolsline"/>')
| + | tableIndex++; |
− | var headtext = $('<span class="headtext"/>').html(headline.html())
| + | |
− | var
| + | |
− | div = $('<div class="redact"/>'),
| + | |
− | link = $('<a/>').attr('href', wgScript+'?'+$.param({ title: wgPageName, action: 'edit', section: 0 }))
| + | |
− |
| + | |
− | $('.firstHeading').replaceWith(new_header);
| + | |
− | toolbar.append(toolsline.append(headtext).append(div.append(link.append(_editimg))))
| + | |
− | $(toolbar).css({'position': 'fixed', 'left':0, 'top':0})
| + | |
− | $(new_header).hover(
| + | |
− | function() {
| + | |
− | var pos = headline.offset();
| + | |
− | toolbar.show().offset({left:pos.left-6, top:pos.top-6})
| + | |
− | }, function() { toolbar.hide() })
| + | |
− |
| + | |
− | $(':header:has(.mw-headline)').each(function(i, e) {
| + | |
− | var new_header = $(e).clone(true);
| + | |
− | new_header.children().remove(':not(.mw-headline)')
| + | |
− | | + | |
− | var headline = $('.mw-headline', new_header)
| + | |
− | var toolbar = $('<div class="showmenu"/>').appendTo(new_header).hide()
| + | |
− | var toolsline = $('<div class="toolsline"/>')
| + | |
− | var headtext = $('<span class="headtext"/>').html(headline.html())
| + | |
− | | + | |
− | toolsline.append(headtext)
| + | |
− | | + | |
− | var original_link = $('.editsection a',e)
| + | |
− | if (original_link.size()) {
| + | |
− | var | + | |
− | div = $('<div class="redact"/>'),
| + | |
− | link = $('<a/>').attr('href', $('.editsection a',e).attr('href'))
| + | |
− | toolsline.append(div.append(link.append(original_link.hasClass('viewlink')? viewimg : editimg))) | + | |
| } | | } |
− | toolbar.append(toolsline)
| |
− |
| |
− | var buttons = $('<div class="buttons-line"/>').appendTo(toolsline)
| |
− | SectionToolbar._run(e, toolsline);
| |
− |
| |
− | $(e).replaceWith(new_header);
| |
− |
| |
− | $(toolbar).css({'position': 'fixed', 'left':0, 'top':0})
| |
− |
| |
− | var timer;
| |
− | $(new_header).hover(
| |
− | function() { timer = setTimeout(function(){ var pos = headline.offset(); toolbar.show().offset({left:pos.left-6, top:pos.top-6}) }, 300) },
| |
− | function() { clearTimeout(timer); toolbar.hide() }
| |
− | )
| |
− | })
| |
− | $(window).scroll(function(){$('.showmenu').hide()})
| |
− | }
| |
− |
| |
− | SectionToolbar.addButton(function(elt, out) {
| |
− | var
| |
− | div = $('<div class="shorturl" />'),
| |
− | input = $('<input class="shortlink" type="text" value="http://tinyurl.com/..." readonly="readonly" />').css('color', '#bbb').hide(),
| |
− | url_out = $('<a href="#"><img src="/skins/vector/url_out.png" width="16" height="16" alt="TinyURL" title="TinyURL"></a>'),
| |
− | url_in = $('<a href="#"><img src="/skins/vector/url_in.png" width="16" height="16" alt="Внутренняя ссылка" title="Внутренняя ссылка"></a>')
| |
− |
| |
− |
| |
− | function gentlyEncode(string) {
| |
− | return ( encodeURIComponent
| |
− | ? encodeURIComponent(string).replace(/%20(\D)?/g, "+$1").replace(/'/g, escape("'"))
| |
− | : escape(string).replace(/\+/g, "%2B").replace(/%20/g, "+") );
| |
| } | | } |
− | var href = /^([^#]+)#?.*$/.exec(location.href)[1]+'#'+$('.mw-headline',elt).attr('id') | + | |
− | | + | for ( var i = 0; i < tableIndex; i++ ) { |
− | function getTinyLink(evt) {
| + | if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) { |
− | evt.preventDefault()
| + | collapseTable( i ); |
− | | + | } |
− | $.ajax({ | + | else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) { |
− | url:"http://json-tinyurl.appspot.com/?callback=?&url=" + gentlyEncode(href),
| + | var element = NavigationBoxes[i]; |
− | dataType: 'json',
| + | while (element = element.parentNode) { |
− | success: function(data) {
| + | if ( hasClass( element, "outercollapse" ) ) { |
− | var tinyurl = data.tinyurl;
| + | collapseTable ( i ); |
− | input.val(tinyurl).css('color', 'black').show().select()
| + | break; |
− | url_out.click(function(e) { e.preventDefault(); input.val(tinyurl).show().select() }) | + | } |
− | url_out.attr('href', tinyurl) | + | |
− | },
| + | |
− | error: function() {
| + | |
− | url_out.one('click', getTinyLink); input.val("http://tinyurl.com/... :(((").show()
| + | |
| } | | } |
− | }) | + | } |
| } | | } |
− |
| |
− | url_out.one('click', getTinyLink)
| |
− |
| |
− | var Url={decode:function(string){return this._utf8_decode(unescape(string));},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}return string;}}
| |
− | url_in.click(function(e) {
| |
− | e.preventDefault()
| |
− | input.val('[['+wgPageName.replace(/_/g, ' ')+'#'+Url.decode( $('.mw-headline',elt).attr('id').replace(/\.([0-9A-F]{2})/g, '%$1').replace(/_/g, ' ') )+']]').css('color', 'black').show().select()
| |
− | })
| |
− | url_in.attr('href', href)
| |
− |
| |
− | input.select().focus(function(e){ this.select() })
| |
− | $('.buttons-line', out).append(url_out).append(url_in)
| |
− | $(out).append(div.append(input))
| |
− | })
| |
− |
| |
− | Queue.addOnce(addSectionMenus, skin=='vector');
| |
− | /** /Section menus ***************************************** */
| |
− |
| |
− |
| |
− | /** Autochange skin ***************************************** */
| |
− | function addcurskintolinks() {
| |
− | $('a:not([href*="useskin"])').each(function(i){
| |
− | var hd = /^([^\#]*)(\#?.*)$/.exec($(this).attr('href'));
| |
− | var h = hd[1];
| |
− | if (/^(?:\/|http:\/\/wiki\.redthreaddesign\.ru)/.test(h)) {
| |
− | h += (h.indexOf("?") == -1)?'?':'&';
| |
− | h += 'useskin=' + skin.toLowerCase();
| |
− | $(this).attr('href',h+hd[2]);
| |
− | }
| |
− | });
| |
| } | | } |
− |
| |
− | Queue.addOnce(addcurskintolinks, location.href.indexOf("useskin=") > 0)
| |
− | /** /Autochange skin ***************************************** */
| |
− |
| |
− |
| |
− | /** collapsibledivs *****/
| |
− | ;(function(){
| |
− | var f5s=('localStorage' in window) && window['localStorage']!==null ? window['localStorage'] : false;
| |
− | function fromStorage() {
| |
− | var items = {};
| |
− | var saved = f5s && typeof localStorage.clpsd !== 'undefined' && localStorage.clpsd != null && localStorage.clpsd;
| |
− | if (saved) {
| |
− | if (saved.indexOf(':')!=-1) { saved = saved.replace(/(.+?):\d+/g, '$1'); localStorage.clpsd = saved; }
| |
− | $.each(saved.split('|'), function(i, e) { items[e] = true })
| |
− | }
| |
− | return items;
| |
− | }
| |
− | function toStorage(items) {
| |
− | var t = [];
| |
− | $.each(items, function(i, e) { if (e) t.push(i); })
| |
| | | |
− | t = t.join('|').replace(/(?:^[\s\|]*|\|{2,}|[\s\|]*$)/g,'')
| + | addOnloadHook( createCollapseButtons ); |
− | if (t!='') localStorage.clpsd = t; else delete localStorage.clpsd;
| + | |
− | }
| + | |
| | | |
− | var saved = fromStorage();
| |
| | | |
| + | /** Dynamic Navigation Bars (experimental) ************************************* |
| + | * |
| + | * Description: See [[Wikipedia:NavFrame]]. |
| + | * Maintainers: UNMAINTAINED |
| + | */ |
| | | |
− | function togglest(th) {
| + | // set up the words in your language |
− | saved[th.attr('id')] = !(saved[th.attr('id')] === true);
| + | var NavigationBarHide = '' + collapseCaption + ''; |
− | th.children('.pBody').slideToggle();
| + | var NavigationBarShow = '' + expandCaption + ''; |
− | th.children('h5').attr('class',(saved[th.attr('id')]===true)?'portlet-title-minimized':'portlet-title-maximized');
| + | |
− | toStorage(saved);
| + | |
− | }
| + | |
| | | |
− | function maxiorminiicon(cur) {
| + | // shows and hides content and picture (if available) of navigation bars |
− | return (cur)?'/skins/common/images/Maximize.png':'/skins/common/images/Minimize.png';
| + | // Parameters: |
− | } | + | // indexNavigationBar: the index of navigation bar to be toggled |
| + | function toggleNavigationBar(indexNavigationBar) |
| + | { |
| + | var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); |
| + | var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); |
| | | |
− | function maxiorminiclass(cur) { | + | if (!NavFrame || !NavToggle) { |
− | return (cur)?'maximinibutton maximinibutton-minimized':'maximinibutton maximinibutton-maximized'; | + | return false; |
| } | | } |
| | | |
− | function minimizediv(o, tdv, save) { | + | // if shown now |
− | tdv.slideToggle('fast'); | + | if (NavToggle.firstChild.data == NavigationBarHide) { |
− | var itval = o.attr('src').indexOf('Maximize')==-1;
| + | for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) { |
− | o.attr('src',maxiorminiicon(itval));
| + | if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) { |
− | o.attr('class',maxiorminiclass(itval)); | + | NavChild.style.display = 'none'; |
| + | } |
| + | } |
| + | NavToggle.firstChild.data = NavigationBarShow; |
| | | |
− | if (save && f5s) {
| + | // if hidden now |
− | var id1 = tdv.attr('id').replace(/\:/g,' ');
| + | } else if (NavToggle.firstChild.data == NavigationBarShow) { |
− | saved[id1] = itval;
| + | for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) { |
− |
| + | if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) { |
− | toStorage(saved) | + | NavChild.style.display = 'block'; |
| + | } |
| } | | } |
| + | NavToggle.firstChild.data = NavigationBarHide; |
| } | | } |
| + | } |
| | | |
− | Queue.addOnce(function() {
| + | // adds show/hide-button to navigation bars |
− | $('div.collapsiblediv').each(function(i) {
| + | function createNavigationBarToggleButton() |
− | var _this = $(this), id = _this.attr('id').replace(/\:/g,' ')
| + | { |
− | var save = !(id === undefined || id.length == 0)
| + | var indexNavigationBar = 0; |
− | var itval = save && saved && saved[id] === true;
| + | // iterate over all < div >-elements |
| + | var divs = document.getElementsByTagName("div"); |
| + | for (var i = 0; NavFrame = divs[i]; i++) { |
| + | // if found a navigation bar |
| + | if (hasClass(NavFrame, "NavFrame")) { |
| | | |
− | var img = $('<img alt="_"></img>').attr('src', maxiorminiicon(itval)).attr('class',maxiorminiclass(itval)).click(function(){minimizediv(img, _this, save); return false;}) | + | indexNavigationBar++; |
− | $(this).before($('<div class="maximinipanel"></div>').append(img)); | + | var NavToggle = document.createElement("a"); |
| + | NavToggle.className = 'NavToggle'; |
| + | NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); |
| + | NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); |
| | | |
− | if (itval) $(this).hide(); | + | var isCollapsed = hasClass( NavFrame, "collapsed" ); |
− | });
| + | /* |
− | })
| + | * Check if any children are already hidden. This loop is here for backwards compatibility: |
− | | + | * the old way of making NavFrames start out collapsed was to manually add style="display:none" |
− | Queue.addOnce(function() {
| + | * to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make |
− | $('div.portlet').each(function() {
| + | * the content visible without JavaScript support), the new recommended way is to add the class |
− | if($.inArray($(this).attr('id'),['p-categories','p-navigation','p-tb','p-lang']) != -1) { | + | * "collapsed" to the NavFrame itself, just like with collapsible tables. |
− | var _this = $(this); | + | */ |
− | $('h5',this).css('cursor','pointer').click(function(){togglest(_this);return false;});
| + | for (var NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) { |
− | if(saved[$(this).attr('id')] === true) {$('.pBody',this).hide();$('h5',this).attr('class','portlet-title-minimized');} else {$('h5',this).attr('class','portlet-title-maximized');}
| + | if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) { |
| + | if ( NavChild.style.display == 'none' ) { |
| + | isCollapsed = true; |
| + | } |
| + | } |
| } | | } |
− | });
| + | if (isCollapsed) { |
− | },skin != 'vectormobile');
| + | for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) { |
| + | if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) { |
| + | NavChild.style.display = 'none'; |
| + | } |
| + | } |
| + | } |
| + | var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide); |
| + | NavToggle.appendChild(NavToggleText); |
| | | |
− | })()
| + | // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) |
− | /** /collapsibledivs ****/ | + | for(var j=0; j < NavFrame.childNodes.length; j++) { |
− | | + | if (hasClass(NavFrame.childNodes[j], "NavHead")) { |
− | /* empty pagename ****/
| + | NavFrame.childNodes[j].appendChild(NavToggle); |
− | 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; | + | NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); |
| } | | } |
− | }); | + | } |
− | }, wgPageName == "Lurkmore:Написать"); | + | } |
| + | |
| + | addOnloadHook( createNavigationBarToggleButton ); |
| | | |
− | /* /empty pagename ****/ | + | /* Test if an element has a certain class ************************************** |
| + | * |
| + | * Description: Uses regular expressions and caching for better performance. |
| + | * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]] |
| + | */ |
| + | |
| + | var hasClass = (function () { |
| + | var reCache = {}; |
| + | return function (element, className) { |
| + | return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); |
| + | }; |
| + | })(); |
| | | |
− | /* b-yauser ****/
| + | var withJS = document.URL.match(/[&?]withjs=((mediawiki:)?([^&#]+))/i) |
− | Queue.addEachFragment(function(sc) { $('.b-yauser a', sc).each(function(i) { $(this).html($(this).html().replace(/^([^<])/,'<b>$1</b>')); }); });
| + | if (withJS) importScript_('MediaWiki:'+withJS[3]) |
− | /* /b-yauser ****/
| + | |
− | | + | |
− | | + | |
− | /** Ajaxed ****
| + | |
− | *
| + | |
− | * Description: динамическая подгрузка произвольных страниц
| + | |
− | * Authors: [[User:Tachikoma]], [[User:T_kns]]
| + | |
− | */
| + | |
− | Queue.addEachFragment(function(scope) {
| + | |
− | var placeholder = $('<div style="text-align:center;"><img src="/skins/common/images/ajax-loader.gif" alt="l" /></div>')
| + | |
− |
| + | |
− | $(".ajaxed", scope).each(function(i, links){
| + | |
− | var contcl = /\bajaxtarget(\S+?)(?:\s|$)/.exec(this.className)
| + | |
− | if(!contcl) return;
| + | |
− | | + | |
− | var lastshown, add_hider = false;
| + | |
− | if($(this).hasClass('ajax_addhider')) { add_hider = $(".ajax_addhider.ajaxhide"+contcl[1], scope).eq(0); if(!add_hider.length) add_hider = false; }
| + | |
− | var target = $(".ajaxcont"+contcl[1], scope).eq(0)
| + | |
− | | + | |
− | function show(cont, tgt) {
| + | |
− | if(lastshown == cont[0]) { if(!tgt.is(':visible')) tgt.show(); return };
| + | |
− |
| + | |
− | lastshown = cont[0]
| + | |
− | | + | |
− | var d = cont.data('remote');
| + | |
− | if(!d) return;
| + | |
− | | + | |
− | tgt.empty().append( d.clone() )
| + | |
− | if(add_hider)
| + | |
− | tgt.append( $('<div style="clear:both;"/>').append( add_hider.clone().click(function(e) { e.preventDefault(); target.toggle(); if ( window.pageYOffset > ($(links).offset().top+$(links).height())) $('html,body').animate({scrollTop:$(links).offset().top}, 350); })) );
| + | |
− | Queue.runEachFragment(tgt);
| + | |
− | tgt.show()
| + | |
− | }
| + | |
− |
| + | |
− | $("a:not(.external)", this).addClass('ajaxlink').one('click', function(e) {
| + | |
− | e.preventDefault()
| + | |
− | | + | |
− | var $this = $(this)
| + | |
− | | + | |
− | $this.data('remote', placeholder.clone())
| + | |
− | target.empty().append(placeholder.clone());
| + | |
− | | + | |
− | $.ajax({
| + | |
− | url:wgServer+wgScriptPath+'/api.php'+'?action=parse&format=json&redirects&prop=text&page='+encodeURIComponent($(this).attr('title')),
| + | |
− | dataType: 'json',
| + | |
− | success: function(data) {
| + | |
− | var d = $(data.parse.text["*"]).wrap('<p/>'), inc;
| + | |
− | inc = $('.ajaxinclude'+contcl[1], d); inc = inc.length ? inc : $('.ajaxinclude', d)
| + | |
− | if(inc.length) d = inc;
| + | |
− | $this.data('remote', d)
| + | |
− | show($this, target)
| + | |
− | }
| + | |
− | })
| + | |
− | $this.click(function(e){ e.preventDefault(); show($this, target); })
| + | |
− | })
| + | |
− | $(".ajaxhide"+contcl[1], scope).click(function(e) { e.preventDefault(); target.toggle(); })
| + | |
− | })
| + | |
− | });
| + | |
− | /** /Ajaxed ****/
| + | |