|
|
Строка 1: |
Строка 1: |
− | /* 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);
| |
− | };
| |
− | })();
| |
− |
| |
− | mw.hook( 'wikipage.content' ).add( function() {
| |
− | $( '.thumbinner' ).each( function() {
| |
− | $( this ).css( 'width', ( parseInt( $( this ).css( 'width' ) ) - 2 ) + 'px' );
| |
− | } );
| |
− | } );
| |
− |
| |
− | // ************************************************************************************************
| |
− | // Admin tool displayer
| |
− | // If an object has class="adminTools" and style="display:none;",
| |
− | // it will be displayed for sysops
| |
− | if(window.wgUserGroups)
| |
− | {
| |
− | function addMainPageTools() {
| |
− | var at = getElementsByClassName(document.getElementById('bodyContent'),'*','adminTools');
| |
− | if(at.length==0) return
| |
− | for(var i=0;i<at.length;i++) {
| |
− | at[i].style.display = 'block';
| |
− | at[i].className += ' plainlinks';
| |
− | }
| |
− | }
| |
− | if(wgUserGroups.join(' ').indexOf('staff') + wgUserGroups.join(' ').indexOf('sysop') > -2){ addOnloadHook(addMainPageTools);
| |
− | }
| |
− | }
| |
− | // ************************************************************************************************
| |
− | // Edit page tool selector
| |
− | // -> modified from http://commons.wikimedia.org/wiki/MediaWiki:Edittools.js
| |
− |
| |
− | if(queryString('action')=='edit'||queryString('action')=='submit') addOnloadHook(customCharInsert)
| |
− | function customCharInsert() {
| |
− | if(!window.wgCustomCharInsert||!wgUserName) return;
| |
− | var spec = document.getElementById('specialchars');
| |
− | var userp = document.createElement('p');
| |
− | userp.className = 'specialbasic';
| |
− | userp.id = 'Custom_Edittools'
| |
− | userp.style.display='none';
| |
− |
| |
− | for (var i=0;i<wgCustomCharInsert.length;i++) {
| |
− | var a = document.createElement('a');
| |
− | a.href='#';
| |
− | a.setAttribute('onclick', 'insertTags("' + wgCustomCharInsert[i].tagOpen + '","' + wgCustomCharInsert[i].tagClose + '","' + wgCustomCharInsert[i].sampleText + '"); return false;');
| |
− | a.appendChild(document.createTextNode(wgCustomCharInsert[i].tagOpen + wgCustomCharInsert[i].tagClose));
| |
− | userp.appendChild(a);
| |
− | if(i!=wgCustomCharInsert.length-1) userp.appendChild(document.createTextNode(' · '));
| |
− | }
| |
− | spec.appendChild(userp);
| |
− | }
| |
− |
| |
− | if(queryString('action')=='edit'||queryString('action')=='submit') addOnloadHook(edittoolsTabs)
| |
− | function edittoolsTabs() {
| |
− | var spec = document.getElementById('specialchars');
| |
− | if(!spec) return;
| |
− | var sb = getElementsByClassName(spec,'p','specialbasic');
| |
− | if(sb.length<=1) return;
| |
− |
| |
− | var sel = document.createElement('select');
| |
− | sel.style.display = 'inline';
| |
− | sel.setAttribute('onchange','chooseCharSubset(selectedIndex)');
| |
− |
| |
− | for(var i=0;i<sb.length;i++) {
| |
− | var o = document.createElement('option');
| |
− | o.appendChild(document.createTextNode(sb[i].id.replace(/_/g,' ')));
| |
− | sel.appendChild(o);
| |
− | }
| |
− | spec.insertBefore(sel,spec.firstChild.nextSibling);
| |
− | }
| |
− |
| |
− | function chooseCharSubset(seld) {
| |
− | var spec = document.getElementById('specialchars');
| |
− | var sb = getElementsByClassName(spec,'p','specialbasic');
| |
− | for (var i = 0; i < sb.length ; i++) {
| |
− | sb[i].style.display = i == seld ? 'inline' : 'none';
| |
− | }
| |
− | }
| |
− |
| |
− | function queryString(p) {
| |
− | var re = RegExp('[&?]' + p + '=([^&]*)');
| |
− | var matches;
| |
− | if (matches = re.exec(document.location)) {
| |
− | try {
| |
− | return decodeURI(matches[1]);
| |
− | } catch (e) {
| |
− | }
| |
− | }
| |
− | return null;
| |
− | }
| |
− |
| |
− | /* </pre> */
| |
− |
| |
− | /*<pre>*/
| |
− |
| |
| /** | | /** |
| * Easy Copy Input | | * Easy Copy Input |
Строка 127: |
Строка 24: |
| function cpInputOnBlur() { | | function cpInputOnBlur() { |
| this.style.backgroundColor = '#FFFFFF'; | | this.style.backgroundColor = '#FFFFFF'; |
− | }
| |
− |
| |
− |
| |
− | if (mwCustomEditButtons) {
| |
− |
| |
− | mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
− | "imageFile": "http://images1.wikia.nocookie.net/central/images/7/70/Button_disambig.png",
| |
− | "speedTip": "пометить как страницу разрешения противоречий",
| |
− | "tagOpen": "\{\{disambig\}\}",
| |
− | "tagClose": "",
| |
− | "sampleText": ""};
| |
− |
| |
− | mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
− | "imageFile": "http://images.wikia.com/central/images/8/8c/Button_RedX.png",
| |
− | "speedTip": "пометить на удаление",
| |
− | "tagOpen": "\{\{delete|",
| |
− | "tagClose": "\}\}",
| |
− | "sampleText": "причина удаления"};
| |
− |
| |
− | mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
− | "imageFile": "http://norrath.ru/w/images/c/c9/Button_strike.png",
| |
− | "speedTip": "применить стиль 'зачеркнуто'",
| |
− | "tagOpen": "<s>",
| |
− | "tagClose": "<\/s>",
| |
− | "sampleText": ""};
| |
− |
| |
− | mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
− | "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/bb/Wiki-button-italic-be.png",
| |
− | "speedTip": "жирный курсив",
| |
− | "tagOpen": "<b><i>",
| |
− | "tagClose": "<\/i><\/b>",
| |
− | "sampleText": ""};
| |
− |
| |
− | mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
− | "imageFile": "http://norrath.ru/w/images/3/38/Button_wikify.png",
| |
− | "speedTip": "вставить шаблон WikiFy",
| |
− | "tagOpen": "\{\{wikify\}\}",
| |
− | "tagClose": "",
| |
− | "sampleText": ""};
| |
− |
| |
| } | | } |