MediaWiki:Common.js: Redaktələr arasındakı fərq
Шариф Ахмет (müzakirə) tərəfindən edilmiş 62379 nömrəli redaktə geri qaytarıldı
Teq: Geri qaytarma |
(Шариф Ахмет (müzakirə) tərəfindən edilmiş 62379 nömrəli redaktə geri qaytarıldı) Teq: Geri qaytarma |
||
(4 redaktor tərəfindən edilmiş 32 dəyişiklik göstərilmir) | |||
Sətir 1: | Sətir 1: | ||
/* | /** | ||
* Skriptləri yükləmək üçün lokal skript | |||
*/ | |||
var importScript_ = importScript; | |||
importScript = function ( page, proj ) { | |||
if ( !proj ) { | |||
importScript_( page ); | |||
} else { | |||
if ( proj.indexOf( '.' ) === -1 ) { | |||
proj += '.sheki.org'; | |||
} | |||
mw.loader.using( 'mediawiki.util' ).done( function () { | |||
mw.loader.load( '//' + proj + '/w/index.php?title=' + mw.util.wikiUrlencode( page ) + | |||
'&action=raw&ctype=text/javascript' ); | |||
} ); | |||
} | |||
}; | |||
//runAsEarlyAsPossible from ruwiki | |||
function runAsEarlyAsPossible( callback, $testElement, func ) { | |||
func = func || $; | |||
$testElement = $testElement || $( '#footer' ); | |||
if ( $testElement.length ) { | |||
callback(); | |||
} else { | |||
func( callback ); | |||
} | |||
} | |||
// Switch language variants of messages (from zh) | // Switch language variants of messages (from zh) | ||
function wgULS(latn,arab){ | function wgULS(latn,arab){ | ||
Sətir 45: | Sətir 74: | ||
for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) { | for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) { | ||
var temp = UnitNode.childNodes[j]; | var temp = UnitNode.childNodes[j]; | ||
if (temp.className | if (['center', 'mw-halign-center'].some(function(className) { return temp.classList.contains(className); })) { units.push(temp); } | ||
} | } | ||
var rightlink; | var rightlink; | ||
var commentText; | var commentText; | ||
var wrap; | |||
for (j = 0; j < units.length; j++) { | for (j = 0; j < units.length; j++) { | ||
currentimage = units[j]; | currentimage = units[j]; | ||
wrap = document.createElement('div'); | |||
wrap.id = "ImageGroupsGr" + i + "Im" + j; | |||
currentimage.parentNode.insertBefore(wrap, currentimage); | |||
wrap.appendChild(currentimage); | |||
var leftlink = document.createElement("a"); | var leftlink = document.createElement("a"); | ||
if (commentText !== undefined) { | if (commentText !== undefined) { | ||
Sətir 89: | Sətir 122: | ||
imghead.appendChild(rightlink); | imghead.appendChild(rightlink); | ||
if (units.length > 1) { | if (units.length > 1) { | ||
wrap.insertBefore(imghead,wrap.childNodes[0]); | |||
} | } | ||
if (j !== 0) { | if (j !== 0) { | ||
wrap.style.display = "none"; | |||
} | } | ||
} | } | ||
} | } | ||
}); | }); | ||
/** Interwiki links to featured articles *************************************** | /** Interwiki links to featured articles *************************************** | ||
Sətir 119: | Sətir 138: | ||
* Maintainers: [[User:R. Koot]] | * Maintainers: [[User:R. Koot]] | ||
*/ | */ | ||
/** | |||
* NAVFRAME | |||
*/ | |||
//Messages | //Messages | ||
Sətir 128: | Sətir 151: | ||
var zeroSectionTip = 'Girişi redaktə et'; | var zeroSectionTip = 'Girişi redaktə et'; | ||
var NavigationBarHide = '[ | var NavigationBarHide = '[gizlət]'; | ||
var NavigationBarShow = '[ | var NavigationBarShow = '[göstər]'; | ||
var NavigationBarShowDefault = 2; | var NavigationBarShowDefault = 2; | ||
Sətir 163: | Sətir 186: | ||
var NavigationBarShowDefault; | |||
if ( typeof NavigationBarShowDefault === 'undefined' ) { | |||
NavigationBarShowDefault = 1; | |||
} | |||
// table.collapsible | |||
function makeCollapsibleMwCollapsible( $content ) { | |||
var $tables = $content | |||
.find( 'table.collapsible:not(.mw-collapsible)' ) | |||
.addClass( 'mw-collapsible' ); | |||
$.each( $tables, function( index, table ) { | |||
// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.'); | |||
if( $( table ).hasClass( 'collapsed') ) { | |||
$( table ).addClass( 'mw-collapsed' ); | |||
// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.'); | |||
} | |||
} ); | |||
if( $tables.length > 0 ) { | |||
mw.loader.using( 'jquery.makeCollapsible' ).then( function() { | |||
$tables.makeCollapsible(); | |||
} ); | |||
} | |||
} | |||
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible ); | |||
/** | |||
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse | |||
* | |||
* Maintainers: TheDJ | |||
*/ | |||
function mwCollapsibleSetup( $collapsibleContent ) { | |||
var $element, | |||
$toggle, | |||
autoCollapseThreshold = 2; | |||
$.each( $collapsibleContent, function (index, element) { | |||
$element = $( element ); | |||
if ( $element.hasClass( 'collapsible' ) ) { | |||
$element.find('tr:first > th:first').prepend( $element.find('tr:first > * > .mw-collapsible-toggle')); | |||
} | |||
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) { | |||
$element.data( 'mw-collapsible' ).collapse(); | |||
} else if ( $element.hasClass( 'innercollapse' ) ) { | |||
if ( $element.parents( '.outercollapse' ).length > 0 ) { | |||
$element.data( 'mw-collapsible' ).collapse(); | |||
} | |||
} | |||
// because of colored backgrounds, style the link in the text color | |||
// to ensure accessible contrast | |||
$toggle = $element.find( '.mw-collapsible-toggle' ); | |||
if ( $toggle.length ) { | |||
// Make the toggle inherit text color | |||
if( $toggle.parent()[0].style.color ) { | |||
$toggle.find( 'a' ).css( 'color', 'inherit' ); | |||
} | |||
} | |||
} ); | |||
} | |||
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup ); | |||
/** | |||
* Dynamic Navigation Bars (experimental) | |||
* | |||
* Description: See [[Şəki Ensiklopediyası:NavFrame]]. | |||
* Maintainers: UNMAINTAINED | |||
*/ | |||
var collapseCaption = 'gizlə'; | |||
var expandCaption = 'göstər'; | |||
// Set up the words in your language | |||
function | var navigationBarHide = '[' + collapseCaption.toLowerCase() + ']'; | ||
var navigationBarShow = '[' + expandCaption.toLowerCase() + ']'; | |||
/** | |||
* Shows and hides content and picture (if available) of navigation bars. | |||
* | |||
* @param {number} indexNavigationBar The index of navigation bar to be toggled | |||
* @param {jQuery.Event} event Event object | |||
*/ | |||
function toggleNavigationBar( indexNavigationBar, event ) { | |||
var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar ); | |||
var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar ); | |||
var navChild; | |||
if ( !navFrame || !navToggle ) { | |||
return false; | |||
} | |||
// If shown now | |||
if ( navToggle.firstChild.data === navigationBarHide ) { | |||
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) { | |||
if ( $( navChild ).hasClass( 'NavContent' ) ) { | |||
navChild.style.display = 'none'; | |||
} | |||
} | |||
navToggle.firstChild.data = navigationBarShow; | |||
// If hidden now | |||
} else if ( navToggle.firstChild.data === navigationBarShow ) { | |||
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) { | |||
if ( $( navChild ).hasClass( 'NavContent' ) ) { | |||
navChild.style.display = 'block'; | |||
} | |||
} | |||
navToggle.firstChild.data = navigationBarHide; | |||
} | |||
event.preventDefault(); | |||
} | |||
/* [[Şablon:Yarımbaşlıq]] üçün */ | |||
function sousTitreH1( $content ) { | |||
$( '#firstHeading > #second_header_h1' ).remove(); | |||
var $span = $content.find( '#second_header_h1' ); | |||
if ( $span.length ) { | |||
$span.prepend( ' ' ); | |||
$( '#firstHeading' ).append( $span ); | |||
} | |||
} | |||
mw.hook( 'wikipage.content' ).add( sousTitreH1 ); | |||
/** | |||
* Adds show/hide-button to navigation bars. | |||
* | |||
* @param {jQuery} $content | |||
*/ | |||
function createNavigationBarToggleButton( $content ) { | |||
var i, j, navChild, navToggle, navToggleText, isCollapsed, | |||
indexNavigationBar = 0; | |||
// Iterate over all < div >-elements | |||
var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' ); | |||
$divs.each( function ( i, navFrame ) { | |||
indexNavigationBar++; | |||
navToggle = document.createElement( 'a' ); | |||
navToggle.className = 'NavToggle'; | |||
navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar ); | |||
navToggle.setAttribute( 'href', '#' ); | |||
$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) ); | |||
isCollapsed = $( navFrame ).hasClass( '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" | |||
* to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make | |||
* the content visible without JavaScript support), the new recommended way is to add the class | |||
* "collapsed" to the NavFrame itself, just like with collapsible tables. | |||
*/ | |||
for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) { | |||
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) { | |||
if ( navChild.style.display === 'none' ) { | |||
isCollapsed = true; | |||
} | |||
} | |||
} | |||
if ( isCollapsed ) { | |||
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) { | |||
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) { | |||
navChild.style.display = 'none'; | |||
} | |||
} | |||
} | |||
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) | |||
for ( j = 0; j < navFrame.childNodes.length; j++ ) { | |||
if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) { | |||
navToggle.style.color = navFrame.childNodes[j].style.color; | |||
navFrame.childNodes[j].appendChild( navToggle ); | |||
} | |||
} | |||
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar ); | |||
} ); | |||
} | |||
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton ); | |||
/** "Technical restrictions" title fix ***************************************** | /** "Technical restrictions" title fix ***************************************** | ||
Sətir 414: | Sətir 422: | ||
realTitleBanner.style.display = "none"; | realTitleBanner.style.display = "none"; | ||
} | } | ||
document.title = realTitleText + " - | document.title = realTitleText + " - Şəki Ensiklopediyası"; | ||
} | } | ||
} | } | ||
Sətir 571: | Sətir 579: | ||
var searchEngines = { | var searchEngines = { | ||
mediawiki: { | mediawiki: { | ||
ShortName: " | ShortName: "Şəki Ensiklopediyası", | ||
Template: "/ | Template: "/wiki/index.php?search={searchTerms}" | ||
}, | }, | ||
globalwpsearch: { | globalwpsearch: { | ||
ShortName: " | ShortName: "Vikipediya", | ||
Template: " | Template: "https://vs.aka-online.de/cgi-bin/globalwpsearch.pl?timeout=120&search={searchTerms}" | ||
}, | }, | ||
google: { | google: { | ||
ShortName: "Google", | ShortName: "Google", | ||
Template: " | Template: "https://www.google.cat/search?as_sitesearch=az.wikipedia.org&hl={language}&q={searchTerms}" | ||
}, | }, | ||
wikiwix: { | wikiwix: { | ||
ShortName: "Wikiwix", | ShortName: "Wikiwix", | ||
Template: " | Template: "https://www.wikiwix.com/index.php?action={searchTerms}&lang=az" | ||
}, | }, | ||
yahoo: { | yahoo: { | ||
ShortName: "Yahoo!", | ShortName: "Yahoo!", | ||
Template: " | Template: "https://search.yahoo.com/search?p={searchTerms}&vs=sheki.org" | ||
}, | }, | ||
wlive: { | wlive: { | ||
ShortName: "Windows Live", | ShortName: "Windows Live", | ||
Template: " | Template: "https://search.live.com/results.aspx?q={searchTerms}&q1=site:https://sheki.org" | ||
} | } | ||
}; | }; | ||
Sətir 706: | Sətir 714: | ||
} | } | ||
} | } | ||
if (mw.config.get('wgCanonicalSpecialPageName') == "Search") { | if (mw.config.get('wgCanonicalSpecialPageName') == "Search") { | ||
Sətir 713: | Sətir 720: | ||
if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit") { | if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit") { | ||
importScript('MediaWiki:Editpage.js'); | importScript('MediaWiki:Editpage.js'); | ||
mw.loader.load('ext.gadget.wikificator'); | |||
} | } | ||
Sətir 769: | Sətir 777: | ||
} | } | ||
} | } | ||
//</source> | //</source> | ||
// Results from Wikidata | // Results from Wikidata | ||
Sətir 776: | Sətir 785: | ||
} | } | ||
/** | /** | ||
* | * Imagemap Highlight | ||
* | */ | ||
* | if ( $( '.imageMapHighlighter' ).length && $( '<canvas>' )[ 0 ].getContext ) { | ||
* | importScript( 'MediaWiki:Imagemap-Highlight.js' ); | ||
} | |||
/** | |||
* imgToggle | |||
*/ | |||
if ( $( 'div.img_toggle' ).length ) { | |||
mw.loader.load( 'ext.gadget.imgToggle' ); | |||
} | |||
/** | |||
* withJS | |||
* İzah: URL keçidləri ilə MediaViki skriptlərinin işə salınması | |||
* @mənbə: www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL | |||
*/ | |||
(function() { | |||
var extraJS = mw.util.getParamValue('withJS'); | |||
if (extraJS) { | |||
if (extraJS.match(/^Media[VW]iki:[^&<>=%#]*\.js$/)) { | |||
importScript(extraJS); | |||
} else { | |||
mw.notify( 'Yalnız MediaViki ad fəzasındakı səhifələrə icazə verilir.', { title: 'Yanlış "withJS" dəyəri' } ); | |||
} | |||
} | |||
}()); | |||
/** | |||
* Magic editintros | |||
* İzah: Yaşayan insanların məqalələrini redaktə edərkən göstərilən xəbərdarlıq qutusu | |||
* Müəllif: [[User:RockMFR]] | |||
*/ | */ | ||
function addEditIntro( name ) { | function addEditIntro( name ) { | ||
$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) { | $( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) { | ||
el.href = $( this ).attr( 'href' ) + '&editintro=' + name; | el.href = $( this ).attr( 'href' ) + '&editintro=' + name; | ||
} ); | |||
} | |||
if ( mw.config.get( 'wgNamespaceNumber' ) === 2 || mw.config.get( 'wgNamespaceNumber' ) === 3) { | |||
$( function () { | |||
if ( document.getElementById( 'userpageedn' ) ) { | |||
addEditIntro( 'Şablon:Editnotice_userpage' ); | |||
} | |||
} ); | } ); | ||
} | } | ||
Sətir 807: | Sətir 846: | ||
return; | return; | ||
} | } | ||
if ( $.inArray( 'Yaşayan insanlar', cats ) !== -1 || $.inArray( 'Yaşayan | if ( $.inArray( 'Yaşayan insanlar', cats ) !== -1 || $.inArray( 'Yaşayan uzunömürlülər', cats ) !== -1 ) { | ||
addEditIntro( 'Template:BLP_editintro' ); | addEditIntro( 'Template:BLP_editintro' ); | ||
} | } | ||
Sətir 813: | Sətir 852: | ||
} | } | ||
// Web2Cit | |||
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Diegodlh/Web2Cit/script.js&action=raw&ctype=text/javascript' ); // Backlink: [[:en:User:Diegodlh/Web2Cit/script.js]] | |||
// Naviqasiya panelində "İnzibatçıların iş bölgüsü" başlığının yerləşdirilməsi | |||
importScript("MediaWiki:SysopDuties.js"); | |||