Changes

Nəzərə çarpan dəyişiklik yoxdur.
Sətir 1: Sətir 1: −
// Switch language variants of messages (from zh)
+
/**
function wgULS(latn,arab){
+
* Код MediaWiki:Common.js безусловно загружается всем пользователям на всех страницах. Во избежание
        //
+
* отправки лишних запросов по возможности не используйте здесь mw.loader.using с модулями, которые
        az=latn||arab;
+
* не загружаются по умолчанию (см.
        az=az;
+
* [[Обсуждение MediaWiki:Common.js#Список модулей, загружаемых по умолчанию]]). В таком случае
        latn=latn;
+
* лучше создать скрытый гаджет, загружаемый по умолчанию, и добавить ему нужные модули в качестве
        arab=arab;
+
* зависимостей.
        switch(mw.config.get('wgUserLanguage')){
+
*/
                case "az": return ku;
  −
                case "az-arab": return arab;
  −
                case "az-latn": return latn;
  −
                default: return "";
  −
        }
  −
}
     −
/** Skript für Vorlage:Galerie */
+
/**
$(function() {
+
  * Локальная функция загрузки скриптов с поддержкой указания проекта
  if (document.URL.match(/printable/g)) return;
+
  */
   
+
var importScript_ = importScript;
  function toggleImageFunction(group, remindex, shwindex) {
+
importScript = function ( page, proj ) {
    return function() {
+
if ( !proj ) {
      document.getElementById("ImageGroupsGr" + group + "Im" + remindex).style.display = "none";
+
importScript_( page );
      document.getElementById("ImageGroupsGr" + group + "Im" + shwindex).style.display = "block";
+
} else {
      return false;
+
if ( proj.indexOf( '.' ) === -1 ) {
    };
+
proj += '.wikipedia.org';
  }
+
}
+
mw.loader.using( 'mediawiki.util' ).done( function () {
  var divs = document.getElementsByTagName("div");
+
mw.loader.load( '//' + proj + '/w/index.php?title=' + mw.util.wikiUrlencode( page ) +
  var i = 0, j = 0;
+
'&action=raw&ctype=text/javascript' );
  var units, search;
+
} );
  var currentimage;
+
}
  var UnitNode;
+
};
  for (i = 0; i < divs.length; i++) {
  −
    if (divs[i].className !== "ImageGroup") { continue; }
  −
    UnitNode = undefined;
  −
    search = divs[i].getElementsByTagName("div");
  −
    for (j = 0; j < search.length; j++) {
  −
      if (search[j].className !== "ImageGroupUnits") { continue; }
  −
      UnitNode=search[j];
  −
      break;
  −
    }
  −
    if (UnitNode === undefined) { continue; }
  −
    units = [];
  −
    for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
  −
      var temp = UnitNode.childNodes[j];
  −
      if (temp.className === "center") { units.push(temp); }
  −
    }
  −
    var rightlink;
  −
    var commentText;
  −
    for (j = 0; j < units.length; j++) {
  −
      currentimage = units[j];
  −
      currentimage.id = "ImageGroupsGr" + i + "Im" + j;
  −
      var leftlink = document.createElement("a");
  −
      if (commentText !== undefined) {
  −
        leftlink.setAttribute("title", commentText);
  −
      }
  −
      var comment;
  −
      if (typeof(currentimage.getAttribute("title")) !== "string") {
  −
        commentText = (j+1) + "/" + units.length;
  −
        comment = document.createElement("tt").appendChild(document.createTextNode("("+ commentText + ")"));
  −
      }
  −
      else {
  −
        commentText = currentimage.getAttribute("title");
  −
        comment = document.createElement("span").appendChild(document.createTextNode(commentText));
  −
        currentimage.removeAttribute("title");
  −
      }
  −
      if(rightlink !== undefined) {
  −
        rightlink.setAttribute("title", commentText);
  −
      }
  −
      var imghead = document.createElement("div");
  −
      rightlink = document.createElement("a");
  −
      if (j !== 0) {
  −
        leftlink.href = "#";
  −
        leftlink.onclick = toggleImageFunction(i, j, j-1);
  −
        leftlink.appendChild(document.createTextNode("◀"));
  −
      }
  −
      if (j != units.length - 1) {
  −
        rightlink.href = "#";
  −
        rightlink.onclick = toggleImageFunction(i, j, j+1);
  −
        rightlink.appendChild(document.createTextNode("▶"));
  −
      }
  −
      imghead.style.fontSize = "110%";
  −
      imghead.style.fontweight = "bold";
  −
      imghead.appendChild(leftlink);
  −
      imghead.appendChild(document.createTextNode("\xA0"));
  −
      imghead.appendChild(comment);
  −
      imghead.appendChild(document.createTextNode("\xA0"));
  −
      imghead.appendChild(rightlink);
  −
      if (units.length > 1) {
  −
        currentimage.insertBefore(imghead,currentimage.childNodes[0]);
  −
      }
  −
      if (j !== 0) {
  −
        currentimage.style.display = "none";
  −
      }
  −
    }
  −
  }
  −
});
     −
/** Interwiki links to featured articles ***************************************
  −
  *
  −
  *  Description: Highlights interwiki links to featured articles (or
  −
  *              equivalents) by changing the bullet before the interwiki link
  −
  *              into a star.
  −
  *  Maintainers: [[User:R. Koot]]
  −
  */
  −
 
   
/**
 
/**
  * NAVFRAME
+
  * Часто те или иные манипуляции со страницей нужно выполнить как можно раньше, но нет гарантии, что
 +
* к моменту выполнения кода нужный участок DOM готов, а событие полной загрузки страницы происходит
 +
* слишком поздно. В этой функции проверяется наличие элемента $testElement и в случае успеха
 +
* функция-колбэк выполняется, иначе же её выполнение поручается другой функции. Если элемент
 +
* в $testElement имеет содержимое, правильнее указать следующий за ним элемент, чтобы быть
 +
* уверенным, что он загрузился до конца. Имейте в виду, что разные скины часто используют разные
 +
* названия классов и идентификаторов.
 
  */
 
  */
+
function runAsEarlyAsPossible( callback, $testElement, func ) {
//Messages
+
func = func || $;
var listFA = {
+
$testElement = $testElement || $( '#footer' );
fa:'Bu başqa dildəki seçilmiş məqalədir',
  −
fl:'Bu başqa dildəki seçilmiş siyahıdır',
  −
ga:'Bu başqa dildəki yaxşı məqalədir'};
     −
var zeroSectionTip = 'Girişi redaktə et';
+
if ( $testElement.length ) {
 
+
callback();
var NavigationBarHide = '[gizlət]';
+
} else {
var NavigationBarShow = '[göstər]';
+
func( callback );
var NavigationBarShowDefault = 2;
+
}
 
  −
function LinkFA(){
  −
var ll, s;
  −
$('#p-lang li').each( function(i, iw){
  −
  ll = iw.className.replace(/^.*?(interwiki-)/, '$1').replace(/\s.*$/, '') + '-';
  −
  for( var s in listFA )
  −
    if( document.getElementById(ll + s) && !$( iw ).hasClass( 'badge-featuredarticle' ) && !$( iw ).hasClass( 'badge-goodarticle' ) && !$( iw ).hasClass( 'badge-featuredlist' ) )
  −
      $( iw )
  −
        .addClass( s.toUpperCase() )
  −
        .attr( 'title',  listFA[s] + textFA );
  −
});
   
}
 
}
    +
/**
 +
* Настройка обработки «е» и «ё» при сортировке в таблицах
 +
*/
 +
mw.config.set( 'tableSorterCollation', { 'Ё': 'Е', 'ё': 'е' } );
   −
function editZeroSection(){
+
/**
  if( !mw.config.get('wgArticleId') ) return;
+
  * Строки. Иноязычный интерфейс предположительно включают весьма редко, поэтому раздувать этот
  mw.util.$content.find('h2')
+
  * список не стоит. При необходимости добавить много сообщений во много языков можно использовать
  .children('.mw-editsection:first')
+
  * механизм системных сообщений (= страниц в пространстве MediaWiki, у которых могут быть суффиксы
  .clone().prependTo('#bodyContent')
+
  * типа /en). См., как их получение реализовано в MediaWiki:Gadget-sidebarRelated.js.
.css('float','right')
+
  */
.find('a')
+
var expandCaption, collapseCaption, zeroSectionTip;
  .each(function(index) {
+
if ( mw.config.get( 'wgUserLanguage' ) === 'en' ) {
$( this ).attr('title', zeroSectionTip);
+
expandCaption = 'show';
if ($( this ).attr('class') === "mw-editsection-visualeditor" ) {  
+
collapseCaption = 'hide';
$( this ).attr('href', mw.config.get('wgScript') + '?title='+mw.util.wikiUrlencode(mw.config.get('wgPageName')) + '&veaction=edit&vesection=0');
+
zeroSectionTip = 'Edit lead section';
} else {  
+
} else {
$( this ).attr('href', mw.config.get('wgScript') + '?title='+mw.util.wikiUrlencode(mw.config.get('wgPageName')) + '&action=edit&section=0');
+
expandCaption = 'показать';
}
+
collapseCaption = 'скрыть';
});
+
zeroSectionTip = 'Править преамбулу';
 
}
 
}
   −
 
+
/**
 +
* [[ВП:Сворачиваемые блоки]]
 +
*/
 +
// Число раскрытых по умолчанию навигационных (и не только) шаблонов, если им задан параметр
 +
// autocollapse. Участники могут переопределять это значение в личных JS.
 
var NavigationBarShowDefault;
 
var NavigationBarShowDefault;
 
if ( typeof NavigationBarShowDefault === 'undefined' ) {
 
if ( typeof NavigationBarShowDefault === 'undefined' ) {
Sətir 158: Sətir 79:     
// table.collapsible
 
// table.collapsible
function makeCollapsibleMwCollapsible( $content ) {
+
function collapsibleTables( $content ) {
var $tables = $content
+
var $btn,
.find( 'table.collapsible:not(.mw-collapsible)' )
+
$a,
.addClass( 'mw-collapsible' );
+
tblIdx = 0,
 +
navboxCount = 0,
 +
notNavboxCount = 0,
 +
colTables = [],
 +
$Tables = $content.find( 'table' );
   −
$.each( $tables, function( index, table ) {
+
$Tables.each( function ( i, table ) {
// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
+
if ( $( table ).hasClass( 'collapsible' ) ) {
if( $( table ).hasClass( 'collapsed') ) {
+
var $table = $( this ),
$( table ).addClass( 'mw-collapsed' );
+
$row = $table.find( 'tr' ).first(),
// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
+
$cell = $row.find( 'th' ).first();
}
+
if ( !$cell.length ) {
} );
+
return;
if( $tables.length > 0 ) {
+
}
mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
+
$table.attr( 'id', 'collapsibleTable' + tblIdx );
$tables.makeCollapsible();
+
$btn = $( '<span>' ).addClass( 'collapseButton' );
} );
+
$a = $( '<a>' )
}
+
.attr( 'id', 'collapseButton' + tblIdx )
}
+
.attr( 'href', 'javascript:collapseTable(' + tblIdx + ');' )
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );
+
// Изменяем цвет ссылки, только если цвет текста в навбоксе нестандартный
 
+
.css( 'color', $cell.css( 'color' ) === $( '.mw-body' ).css( 'color' ) ? 'auto' :
/**
+
$cell.css( 'color' ) )
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
+
.text( collapseCaption );
*
+
$btn
* Maintainers: TheDJ
+
.append( '[' )
*/
+
.append( $a )
function mwCollapsibleSetup( $collapsibleContent ) {
+
.append( ']' );
var $element,
+
if ( $cell.contents().length ) {
$toggle,
+
$btn.insertBefore( $cell.contents().first() );
autoCollapseThreshold = 2;
+
} else {
$.each( $collapsibleContent, function (index, element) {
+
$btn.appendTo( $cell );
$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();
   
}
 
}
}
+
// hasClass( 'navbox' ) — временное решение для навшаблонов, ещё не переведённых
// because of colored backgrounds, style the link in the text color
+
// на {{Навигационная таблица}} (также ниже)
// to ensure accessible contrast
+
if ( $table.hasClass( 'navbox-inner' ) || $table.hasClass( 'navbox' ) ) {
$toggle = $element.find( '.mw-collapsible-toggle' );
+
navboxCount++;
if ( $toggle.length ) {
+
} else {
// Make the toggle inherit text color
+
notNavboxCount++;
if( $toggle.parent()[0].style.color ) {
  −
$toggle.find( 'a' ).css( 'color', 'inherit' );
   
}
 
}
 +
colTables[tblIdx++] = $table;
 
}
 
}
 
} );
 
} );
 +
for ( var i = 0; i < tblIdx; i++ ) {
 +
if ( colTables[i].hasClass( 'collapsed' ) ||
 +
( colTables[i].hasClass( 'autocollapse' ) &&
 +
( ( ( colTables[i].hasClass( 'navbox-inner' ) || colTables[i].hasClass( 'navbox' ) ) &&
 +
navboxCount > NavigationBarShowDefault ) ||
 +
( !( colTables[i].hasClass( 'navbox-inner' ) || colTables[i].hasClass( 'navbox' ) ) &&
 +
notNavboxCount > NavigationBarShowDefault ) ) ) )
 +
{
 +
collapseTable( i );
 +
}
 +
}
 
}
 
}
   −
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
+
mw.hook( 'wikipage.content' ).add( collapsibleTables );
 
  −
/**
  −
* Dynamic Navigation Bars (experimental)
  −
*
  −
* Description: See [[Wikipedia:NavFrame]].
  −
* Maintainers: UNMAINTAINED
  −
*/
  −
  −
var collapseCaption = 'gizlə';
  −
var expandCaption = 'göstər';
  −
 
  −
// Set up the words in your language
  −
var navigationBarHide = '[' + collapseCaption + ']';
  −
var navigationBarShow = '[' + expandCaption + ']';
  −
 
  −
/**
  −
* 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 ) {
+
function collapseTable( idx ) {
 +
var $table = $( '#collapsibleTable' + idx ),
 +
$rows = $table.children().children( 'tr' ),
 +
$btn = $( '#collapseButton' + idx );
 +
if ( !$table.length || !$rows.length || !$btn.length ) {
 
return false;
 
return false;
 
}
 
}
   −
// If shown now
+
var isExpanded = ( $btn.text() === collapseCaption ),
if ( navToggle.firstChild.data === navigationBarHide ) {
+
cssDisplay = isExpanded ? 'none' : $rows.first().css( 'display' );
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();
+
$btn.text( isExpanded ? expandCaption : collapseCaption );
 +
$rows.slice( 1 ).each( function () {
 +
$( this ).css( 'display', cssDisplay );
 +
} );
 
}
 
}
   −
/**
+
// div.NavFrame
* Adds show/hide-button to navigation bars.
+
var navFrameExpandCaption = '[' + expandCaption + ']',
*
+
navFrameCollapseCaption = '[' + collapseCaption + ']';
* @param {jQuery} $content
+
 
*/
+
// Изолируем код из глобальной области видимости
function createNavigationBarToggleButton( $content ) {
+
( function () {
var i, j, navChild, navToggle, navToggleText, isCollapsed,
+
function collapsibleDivs( $content ) {
indexNavigationBar = 0;
+
var navFrameIndex = 0,
// Iterate over all < div >-elements
+
navFrames = [],
var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );
+
i;
$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' );
+
$content.find( 'div' ).each( function () {
/**
+
var $div = $( this );
* Check if any children are already hidden. This loop is here for backwards compatibility:
+
if ( $div.hasClass( 'NavFrame' ) ) {
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
+
var $btn = $( '<a>' )
* to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
+
.addClass( 'NavToggle' )
* the content visible without JavaScript support), the new recommended way is to add the class
+
.attr( 'href', 'javascript:' )
* "collapsed" to the NavFrame itself, just like with collapsible tables.
+
.text( navFrameCollapseCaption )
*/
+
.click( navToggleClickHandler );
for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) {
+
$div.children( '.NavHead' ).append( $btn );
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
+
navFrames[ navFrameIndex++ ] = $div;
if ( navChild.style.display === 'none' ) {
  −
isCollapsed = true;
  −
}
   
}
 
}
}
+
} );
if ( isCollapsed ) {
+
for ( i = 0; i < navFrameIndex; i++ ) {
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
+
if ( navFrames[ i ].hasClass( 'collapsed' ) ||
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
+
( navFrameIndex > NavigationBarShowDefault &&
navChild.style.display = 'none';
+
!navFrames[ i ].hasClass( 'expanded' )
}
+
)
 +
) {
 +
toggleDiv( navFrames[ i ] );
 
}
 
}
 
}
 
}
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 );
+
mw.hook( 'wikipage.content' ).add( collapsibleDivs );
   −
/** "Technical restrictions" title fix *****************************************
+
function navToggleClickHandler() {
*
+
var $btn = $( this );
* Description:
+
toggleDiv( $btn.closest( '.NavFrame' ), $btn );
* Maintainers: User:Interiot, User:Mets501, User:Freakofnurture
  −
*/
  −
//
  −
// For pages that have something like Template:Lowercase, replace the title, but only if it is cut-and-pasteable as a valid wikilink.
  −
// (for instance iPod's title is updated. But [[C#]] is not an equivalent
  −
// wikilink, so [[C Sharp]] doesn't have its main title changed)
  −
// Likewise for users who have selected the U.K. date format ("1 March") the 
  −
// titles of day-of-the-year articles will appear in that style. Users with any
  −
// other date setting are not affected.
  −
//
  −
// The function looks for a banner like this:
  −
// &lt;div id="RealTitleBanner"&gt;  ... &lt;span id="RealTitle"&gt;title&lt;/span&gt; ... &lt;/div&gt;
  −
// An element with id=DisableRealTitle disables the function.
  −
//
  −
var disableRealTitle = 0; // users can set disableRealTitle = 1 locally to disable.
  −
if (mw.config.get('wgIsArticle')) { // don't display the RealTitle when editing, since it is apparently inconsistent (doesn't show when editing sections, doesn't show when not previewing)
  −
  $(function() {
  −
    try {
  −
        var realTitleBanner = document.getElementById("RealTitleBanner");
  −
        if (realTitleBanner && !document.getElementById("DisableRealTitle") && !disableRealTitle ) {
  −
            var realTitle = document.getElementById("RealTitle");
  −
            if (realTitle) {
  −
                var realTitleHTML = realTitle.innerHTML;
  −
                realTitleText = pickUpText(realTitle);
  −
 
  −
                var isPasteable = 0;
  −
                //var containsHTML = /</.test(realTitleHTML);    // contains ANY HTML
  −
                var containsTooMuchHTML = /</.test( realTitleHTML.replace(/<\/?(sub|sup|small|big)>/gi, "") ); // contains HTML that will be ignored when cut-n-pasted as a wikilink
  −
                // calculate whether the title is pasteable
  −
                var verifyTitle = realTitleText.replace(/^ +/, "");      // trim left spaces
  −
                verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length);    // uppercase first character
  −
 
  −
                // if the namespace prefix is there, remove it on our verification copy. If it isn't there, add it to the original realValue copy.
  −
                if (mw.config.get('wgNamespaceNumber') != 0) {
  −
                    if (mw.config.get('wgCanonicalNamespace') == verifyTitle.substr(0, mw.config.get('wgCanonicalNamespace').length).replace(/ /g, "_") && verifyTitle.charAt(mw.config.get('wgCanonicalNamespace').length) == ":") {
  −
                        verifyTitle = verifyTitle.substr(mw.config.get('wgCanonicalNamespace').length + 1);
  −
                    } else {
  −
                        realTitleText = mw.config.get('wgCanonicalNamespace').replace(/_/g, " ") + ":" + realTitleText;
  −
                        realTitleHTML = mw.config.get('wgCanonicalNamespace').replace(/_/g, " ") + ":" + realTitleHTML;
  −
                    }
  −
                }
  −
 
  −
                // verify whether wgTitle matches
  −
                verifyTitle = verifyTitle.replace(/[\s_]+/g, " ");      // underscores and multiple spaces to single spaces
  −
                verifyTitle = verifyTitle.replace(/^\s+/, "").replace(/\s+$/, "");        // trim left and right spaces
  −
                verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length);    // uppercase first character
  −
                if ( (verifyTitle == mw.config.get('wgTitle')) || (verifyTitle == mw.config.get('wgTitle').replace(/^(.+)?(January|February|March|April|May|June|July|August|September|October|November|December)\s+([12]?[0-9]|3[0123])([^\d].*)?$/g, "$1$3 $2$4") )) isPasteable = 1;
  −
                var h1 = document.getElementsByTagName("h1")[0];
  −
                if (h1 && isPasteable) {
  −
                    h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML;
  −
                    if (!containsTooMuchHTML)
  −
                        realTitleBanner.style.display = "none";
  −
                }
  −
                document.title = realTitleText + " - Şəki Ensiklopediyası";
  −
            }
  −
        }
  −
    } catch (e) {
  −
        /* Something went wrong. */
  −
    }
  −
  });
  −
}
  −
 
  −
// similar to innerHTML, but only returns the text portions of the insides, excludes HTML
  −
function pickUpText(aParentElement) {
  −
var str = "";
  −
 
  −
function pickUpTextInternal(aElement) {
  −
  var child = aElement.firstChild;
  −
  while (child) {
  −
  if (child.nodeType == 1)    // ELEMENT_NODE
  −
    pickUpTextInternal(child);
  −
  else if (child.nodeType == 3)  // TEXT_NODE
  −
    str += child.nodeValue;
  −
 
  −
  child = child.nextSibling;
  −
  }
  −
}
  −
 
  −
  pickUpTextInternal(aParentElement);
  −
  return str;
  −
}
  −
 
  −
//fix edit summary prompt for undo
  −
//this code fixes the fact that the undo function combined with the "no edit summary prompter" causes problems if leaving the
  −
//edit summary unchanged
  −
//this was added by [[User:Deskana]], code by [[User:Tra]]
  −
$(function () {
  −
  if (document.location.search.indexOf("undo=") != -1
  −
  && document.getElementsByName('wpAutoSummary')[0]) {
  −
    document.getElementsByName('wpAutoSummary')[0].value='';
  −
  }
  −
})
  −
 
  −
/**
  −
* Qeydiyyatdan keçmiş istifadəçilər üçün gizli kateqoriyaların göstərilməsi üçün (+) düyməsini əlavə edən funksiya
  −
*/
  −
function hiddencat( $ ) {
  −
if (mw.util.getParamValue('printable') === 'yes') {
  −
return;
  −
}
  −
var cl = document.getElementById('catlinks');
  −
if (!cl) {
  −
return;
  −
}
  −
var $hc = $('#mw-hidden-catlinks');
  −
if ( !$hc.length ) {
  −
return;
  −
}
  −
if ( $hc.hasClass('mw-hidden-cats-user-shown') ) {
  −
return;
  −
}
  −
if ( $hc.hasClass('mw-hidden-cats-ns-shown') ) {
  −
$hc.addClass('mw-hidden-cats-hidden');
  −
}
  −
var nc = document.getElementById('mw-normal-catlinks');
  −
if ( !nc ) {
  −
var catline = document.createElement('div');
  −
catline.id = 'mw-normal-catlinks';
  −
var a = document.createElement('a');
  −
a.href = '';
  −
a.title = '';
  −
a.appendChild(document.createTextNode('Kateqoriyalar'));
  −
catline.appendChild(a);
  −
catline.appendChild(document.createTextNode(' : '));
  −
nc = cl.insertBefore(catline, cl.firstChild);
   
}
 
}
var lnk = document.createElement('a');
  −
lnk.id = 'mw-hidden-cats-link';
  −
lnk.title = 'Bu məqalədə gizli kateqoriyalar var';
  −
lnk.style.cursor = 'pointer';
  −
lnk.style.color = 'black';
  −
lnk.style.marginLeft = '0.3em';
  −
$(lnk).click(toggleHiddenCats);
  −
lnk.appendChild(document.createTextNode('[+]'));
  −
nc.appendChild(lnk);
  −
}
     −
function toggleHiddenCats(e) {
+
function toggleDiv( $div, $btn ) {
var $hc = $('#mw-hidden-catlinks');
+
$btn = $btn || $div.find( '.NavToggle' ).first();
if ( $hc.hasClass('mw-hidden-cats-hidden') ) {
+
if ( !$div.length || !$btn.length ) return false;
$hc.removeClass('mw-hidden-cats-hidden');
+
var isExpanded = ( $btn.text() === navFrameCollapseCaption );
$hc.addClass('mw-hidden-cat-user-shown');
+
$btn.text( isExpanded ? navFrameExpandCaption : navFrameCollapseCaption );
$(e.target).text('[–]');
+
$div.children( '.NavContent, .NavPic' ).each( function () {
} else {
+
$( this ).css( 'display', isExpanded ? 'none' : 'block' );
$hc.removeClass('mw-hidden-cat-user-shown');
+
} );
$hc.addClass('mw-hidden-cats-hidden');
  −
$(e.target).text('[+]');
   
}
 
}
}
  −
  −
mw.loader.using('mediawiki.util', function () {
  −
$( hiddencat );
  −
});
  −
  −
/** Add dismiss button to watchlist-message *************************************
  −
  *
  −
  *  Description: Hide the watchlist message for one week.
  −
  *  Maintainers: [[User:Ruud Koot|Ruud Koot]]
  −
  */
  −
  −
function addDismissButton() {
  −
    var watchlistMessage = document.getElementById("watchlist-message");
  −
    if ( watchlistMessage == null ) return;
  −
  −
    if ( document.cookie.indexOf( "hidewatchlistmessage=yes" ) != -1 ) {
  −
        watchlistMessage.style.display = "none";
  −
    }
  −
  −
    var Button    = document.createElement( "span" );
  −
    var ButtonLink = document.createElement( "a" );
  −
    var ButtonText = document.createTextNode( "dismiss" );
  −
  −
    ButtonLink.setAttribute( "id", "dismissButton" );
  −
    ButtonLink.setAttribute( "href", "javascript:dismissWatchlistMessage();" );
  −
    ButtonLink.setAttribute( "title", "Hide this message for one week" );
  −
    ButtonLink.appendChild( ButtonText );
  −
  −
    Button.appendChild( document.createTextNode( "[" ) );
  −
    Button.appendChild( ButtonLink );
  −
    Button.appendChild( document.createTextNode( "]" ) );
  −
  −
    watchlistMessage.appendChild( Button );
  −
}
  −
  −
function dismissWatchlistMessage() {
  −
    var e = new Date();
  −
    e.setTime( e.getTime() + (7*24*60*60*1000) );
  −
    document.cookie = "hidewatchlistmessage=yes; expires=" + e.toGMTString() + "; path=/";
  −
    var watchlistMessage = document.getElementById("watchlist-message");
  −
    watchlistMessage.style.display = "none";
  −
}
  −
  −
$( addDismissButton );
  −
  −
/** MediaWiki media player *******************************************************
  −
  *
  −
  *  Description: A Java player for in-browser playback of media files.
  −
  *  Created by: [[User:Gmaxwell]]
  −
  */
  −
  −
mw.loader.load('//en.wikipedia.org/w/index.php?title=Mediawiki:Wikimediaplayer.js&action=raw&ctype=text/javascript');
  −
  −
// Choice of multiple search engines
  −
// Autor: Jakob Voss, Guillaume (tret de de:MediaWiki:SpezialSuche.js)
  −
// Version: 0.3.8
  −
// Published as Public Domain
  −
  −
// Map of search engines and some OpenSearch-based fields
  −
var searchEngines = {
  −
  mediawiki: {
  −
    ShortName: "MediaWiki axtarışı",
  −
    Template: "/w/index.php?search={searchTerms}"
  −
  },
  −
  google: {
  −
    ShortName: "Google",
  −
    Template: "http://www.google.cat/search?as_sitesearch=wiki.sheki.site&hl={language}&q={searchTerms}"
  −
  },
  −
  yahoo: {
  −
    ShortName: "Yahoo!",
  −
    Template: "http://search.yahoo.com/search?p={searchTerms}&vs=wiki.sheki.site"
  −
  },
  −
  wlive: {
  −
    ShortName: "Windows Live",
  −
    Template: "http://search.live.com/results.aspx?q={searchTerms}&q1=site:http://wiki.sheki.site"
  −
  }
  −
};
  −
  −
  −
function externalSearchEngines() {
  −
  if (typeof SpecialSearchEnhanced2Disabled != 'undefined') return;
  −
  −
  −
  var mainNode = document.getElementById("powersearch");
  −
  if (!mainNode) mainNode = document.getElementById("search");
  −
  if (!mainNode) return;
  −
  −
  var beforeNode = document.getElementById("mw-search-top-table");
  −
  if (!beforeNode) return;
  −
  beforeNode = beforeNode.nextSibling;
  −
  if (!beforeNode) return;
  −
  −
  var firstEngine = "mediawiki";
  −
  −
  var choices = document.createElement("div");
  −
  choices.setAttribute("id","searchengineChoices");
  −
  choices.style.textAlign = "center";
  −
  −
  var lsearchbox = document.getElementById("searchText");
  −
  var initValue = lsearchbox.value;
  −
  −
  var space = "";
  −
  −
  for (var id in searchEngines) {
  −
    var engine = searchEngines[id];
  −
if(engine.ShortName)
  −
  {
  −
    if (space) choices.appendChild(space);
  −
    space = document.createTextNode(" ");
  −
  −
    var attr = {
  −
      type: "radio",
  −
      name: "searchengineselect",
  −
      value: id,
  −
      onFocus: "changeSearchEngine(this.value)",
  −
      id: "searchengineRadio-"+id
  −
    };
  −
  −
    var html = "<input";
  −
    for (var a in attr) html += " " + a + "='" + attr[a] + "'";
  −
    html += " />";
  −
    var span = document.createElement("span");
  −
    span.innerHTML = html;
  −
  −
    choices.appendChild( span );
  −
    var label
  −
    if (engine.Template.indexOf('http') == 0) {
  −
      label = document.createElement("a");
  −
      label.href = engine.Template.replace("{searchTerms}", initValue).replace("{language}", "fr");
  −
    } else {
  −
      label = document.createElement("label");
  −
    }
  −
 
  −
    label.appendChild( document.createTextNode( engine.ShortName ) );
  −
    choices.appendChild( label );
  −
  }
  −
}
  −
  mainNode.insertBefore(choices, beforeNode);
  −
  −
  var input = document.createElement("input");
  −
  input.id = "searchengineextraparam";
  −
  input.type = "hidden";
  −
  −
  mainNode.insertBefore(input, beforeNode);
  −
  −
  changeSearchEngine(firstEngine, initValue);
  −
}
  −
  −
function changeSearchEngine(selectedId, searchTerms) {
  −
  −
  var currentId = document.getElementById("searchengineChoices").currentChoice;
  −
  if (selectedId == currentId) return;
  −
  −
  document.getElementById("searchengineChoices").currentChoice = selectedId;
  −
  var radio = document.getElementById('searchengineRadio-'  + selectedId);
  −
  radio.checked = "checked";
  −
  −
  var engine = searchEngines[selectedId];
  −
  var p = engine.Template.indexOf('?');
  −
  var params = engine.Template.substr(p+1);
  −
  −
  var form;
  −
  if (document.forms["search"]) {
  −
    form = document.forms["search"];
  −
  } else {
  −
    form = document.getElementById("powersearch");
  −
  }
  −
  form.setAttribute("action", engine.Template.substr(0,p));
  −
  −
  var l = ("" + params).split("&");
  −
  for (var idx = 0;idx < l.length;idx++) {
  −
    var p = l[idx].split("=");
  −
    var pValue = p[1];
  −
  −
    if (pValue == "{language}") {
  −
    } else if (pValue == "{searchTerms}") {
  −
      var input;
  −
      input = document.getElementById("searchText");
  −
  −
      input.name = p[0];
  −
    } else {
  −
      var input = document.getElementById("searchengineextraparam");
  −
  −
      input.name = p[0];
  −
      input.value = pValue;
  −
    }
  −
  }
  −
}
  −
  −
  −
if (mw.config.get('wgCanonicalSpecialPageName') == "Search") {
  −
  $(externalSearchEngines);
  −
}
  −
if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit") {
  −
  importScript('MediaWiki:Editpage.js');
  −
}
  −
  −
// Sidebar Dəyişiklikləri
  −
function ModifySidebar(action, section, name, link) {
  −
    try {
  −
        switch (section) {
  −
          case "Başqa dillərdə":
  −
            var target = "p-lang";
  −
            break;
  −
          case "Alətlər sandığı":
  −
            var target = "p-tb";
  −
            break;
  −
          case "rəhbər":
  −
            var target = "p-navigation";
  −
            break;
  −
          default:
  −
            var target = "p-" + section;
  −
            break;
  −
        }
  −
  −
        if (action == "add") {
  −
            var node = document.getElementById(target)
  −
                              .getElementsByTagName('div')[0]
  −
                              .getElementsByTagName('ul')[0];
  −
  −
            var aNode = document.createElement('a');
  −
            var liNode = document.createElement('li');
  −
  −
            aNode.appendChild(document.createTextNode(name));
  −
            aNode.setAttribute('href', link);
  −
            liNode.appendChild(aNode);
  −
            liNode.className='plainlinks';
  −
            node.appendChild(liNode);
  −
        }
  −
  −
        if (action == "remove") {
  −
            var list = document.getElementById(target)
  −
                              .getElementsByTagName('div')[0]
  −
                              .getElementsByTagName('ul')[0];
  −
  −
            var listelements = list.getElementsByTagName('li');
  −
  −
            for (var i = 0; i < listelements.length; i++) {
  −
                if (listelements[i].getElementsByTagName('a')[0].innerHTML == name ||
  −
                    listelements[i].getElementsByTagName('a')[0].href == link) {
  −
  −
                    list.removeChild(listelements[i]);
  −
                }
  −
            }
  −
        }
  −
  −
    } catch(e) {
  −
      // lets just ignore what's happened
  −
      return;
  −
    }
  −
}
  −
//</source>
  −
// Results from Wikidata
  −
// [[File:Wdsearch_script_screenshot.png]]
  −
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||  ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
  −
        mw.loader.load("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
  −
}
  −
      
/**
 
/**
* Imagemap Highlight
+
* Загрузка скриптов через систему подгаджетов
$(document).ready(function() {
+
*/
 +
var namespaceNumber = mw.config.get( 'wgNamespaceNumber' );
   −
    var
+
// Скрипты для служебных страниц
//add this class to all elements created by the script. the reason is that we call the script again on
+
if ( namespaceNumber === -1 ) {
//window resize, and use the class to remove all the "artefacts" we created in the previous run.
+
var specialGadgets = [
myClassName = 'imageMapHighlighterArtefacts'
+
'Abusefilter',
, liHighlightClass = 'liHighlighting'
+
'Block',
, specialAreaMark = 'area_mark'
+
'Log',
, specialLiClassesMark = 'list_classes'
+
'Movepage',
// "2d context" attributes used for highlighting.
+
'Newpages',
, areaHighLighting = {fillStyle: 'rgba(0,0,0,0.35)', strokeStyle: 'yellow', lineJoin: 'round', lineWidth: 2}
+
'Search',
//every imagemap that wants highlighting, should reside in a div of this 'class':
+
'Upload'
, hilightDivMarker = '.imageMapHighlighter'
+
];
// specifically for wikis - redlinks tooltip adds this message
+
var canonicalSpecialPageName = mw.config.get( 'wgCanonicalSpecialPageName' );
, az = mw && mw.config && mw.config.get('wgUserLanguage') == 'az'
+
if ( specialGadgets.indexOf( canonicalSpecialPageName ) > -1 ) {
, expandLegend = az ? 'Adları göstər' : 'ּShow Legend'
+
mw.loader.load( 'ext.gadget.common-special-' + canonicalSpecialPageName.toLowerCase() );
, collapseLegend = az ? 'Adları gizlət' : 'Hide Legend'
+
}
;
+
} else {
 +
// Скрипты для действий
 +
var action = mw.config.get( 'wgAction' );
 +
var actionGadgets = {
 +
'edit': [ 'ext.gadget.common-action-edit', 'ext.gadget.wikificator', 'ext.gadget.summaryButtons' ]
 +
};
 +
actionGadgets[ 'submit' ] = actionGadgets[ 'edit' ];
    +
if ( actionGadgets[ action ] ) {
 +
mw.loader.load( actionGadgets[ action ] );
 +
}
   −
function drawMarker(context, areas) { // this is where the magic is done.
+
// Скрипты для пространств
 
+
var namespaceGadgets = {
function drawPoly(coords) {
+
6: [ 'ext.gadget.common-namespace-file' ]
context.moveTo(coords.shift(), coords.shift());
+
};
while (coords.length)
  −
context.lineTo(coords.shift(), coords.shift());
  −
}
     −
for (var i in areas) {
+
if ( namespaceGadgets[ namespaceNumber ] ) {
var coords = areas[i].coords.split(',');
+
mw.loader.load( namespaceGadgets[ namespaceNumber ] );
context.beginPath();
  −
switch (areas[i].shape) {
  −
case 'rect': drawPoly([coords[0], coords[1], coords[0], coords[3], coords[2], coords[3], coords[2], coords[1]]); break;
  −
case 'circle': context.arc(coords[0],coords[1],coords[2],0,Math.PI*2);  break;//x,y,r,startAngle,endAngle
  −
case 'poly': drawPoly(coords); break;
  −
}
  −
context.closePath();
  −
context.stroke();
  −
context.fill();
   
}
 
}
 
}
 
}
 +
}() );
   −
function mouseAction(e) {
+
/**
var $this = $(this),
+
* Старые коды
activate = e.type == 'mouseover',
+
*/
caption = $this.text(),
+
if ( navigator.platform.indexOf( 'Win' ) !== -1 ) {
ol = $this.parent(),
+
mw.loader.using( 'mediawiki.util' ).done( function () {
context = ol.data('context'),
+
mw.util.addCSS( '.IPA, .Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; }' );
special = ol.data(specialAreaMark);
+
} );
+
}
$this.toggleClass(liHighlightClass, activate); // mark/unmark the list item.  
  −
  −
context.clearRect(0, 0, context.canvas.width, context.canvas.height); // prepare for a new day.
  −
  −
ol.find('li').each(function() {
  −
var $li = $(this);
  −
var licap = $li.text();
  −
var param;
  −
if (activate && licap === caption) { // highlight!!!
  −
param = special && special.hover  || areaHighLighting;
  −
} else {
  −
param = special && special.nover && (special.nover[licap] || special.nover.default);
  −
}
  −
if (param) {
  −
$.extend(context, param);
  −
drawMarker(context, $li.data('areas'));
  −
}
  −
});
  −
}
     −
function handleOneMap() {
+
/**
var img = $(this),
+
* Дополнительный функционал для заглавной страницы
w = img.width(),
+
*/
h = img.height(),
+
if ( mw.config.get( 'wgIsMainPage' ) && mw.config.get( 'wgAction' ) === 'view' ) {
map = img.siblings('map:first'),
+
mw.hook( 'wikipage.content' ).add( function () {
dims = {position: 'absolute', width: w + 'px', height: h + 'px', border: 0, top:0, left:0},
+
mw.loader.using( 'mediawiki.util' ).done( function () {
specialHighlight = img.closest(hilightDivMarker).data(specialAreaMark),
+
var el = mw.util.addPortletLink(
specialLiClasses = img.closest(hilightDivMarker).data(specialLiClassesMark);
+
'p-lang',
+
mw.config.get( 'wgArticlePath' ).replace( /\$1/, 'Википедия:Список_Википедий' ),
+
'Полный список',
if (!('area', map).length)
+
'interwiki-completelist'
return; //not an imagemap. inside "each" anonymous function, 'return' means "continue".
+
);
 
+
if ( el ) {
var jcanvas = $('<canvas>', {'class': myClassName})
+
el.style.fontWeight = 'bold';
.css(dims)
  −
.attr({width: w, height: h});
  −
var bgimg = $('<img>', {'class': myClassName, src: img.attr('src')})
  −
.css(dims);//completely inert image. this is what we see.
  −
var context = $.extend(jcanvas[0].getContext("2d"), areaHighLighting);
  −
  −
// this is where the magic is done: prepare a sandwich of the inert bgimg at the bottom,
  −
// the canvas above it, and the original image on top,
  −
// so canvas won't steal the mouse events.
  −
// pack them all TIGHTLY in a newly minted "relative" div, so when page chnage
  −
// (other scripts adding elements, window resize etc.), canvas and imagese remain aligned.
  −
var div = $('<div>').css({position: 'relative', width: w + 'px', height: h + 'px'});
  −
img.before(div); // put the div just above the image, and ...
  −
div.append(bgimg) // place the background image in the div
  −
.append(jcanvas)// and the canvas. both are "absolute", so they don't occupy space in the div
  −
.append(img); // now yank the original image from the window and place it on the div.
  −
img.fadeTo(1, 0); // make the image transparent - we see canvas and bgimg through it.
  −
// the original, now transparent image is creating our mouse events
  −
  −
var ol = $('<ol>', {'class': myClassName})
  −
.css({clear: 'both', margin: 0, listStyle: 'none', maxWidth: w + 'px', float: 'left', position: 'relative'})
  −
.attr({'data-expandtext' : expandLegend, 'data-collapsetext': collapseLegend})
  −
.data(specialAreaMark, specialHighlight)
  −
.data('context', context);
  −
 
  −
// ol below image, hr below ol. original caption pushed below hr.
  −
div.after($('<hr>', {'class': myClassName}).css('clear', 'both'))
  −
.after(ol);
  −
var lis = {}; //collapse areas with same caption to one list item
  −
var someli; // select arbitrary one
  −
$('area', map).each(function() {
  −
var text = this.title;
  −
var li = lis[text]; // title already met? use the same li
  −
if (!li) { //no? create a new one.
  −
var href = this.href;
  −
lis[text] = li = $('<li>', {'class': myClassName})
  −
.append($('<a>', {href: href, text: text}))
  −
.on('mouseover mouseout', mouseAction)
  −
.data('areas', [])
  −
.addClass(specialLiClasses && (specialLiClasses[text] || specialLiClasses['default']))
  −
.appendTo(ol);
   
}
 
}
li.data('areas').push(this); //add the area to the li
  −
someli = li; // whichever - we just want one...
  −
$(this).on('mouseover mouseout', function(e) {li.trigger(e);});
  −
});
  −
if (someli) someli.trigger('mouseout');
  −
ol.addClass('mw-collapsed')
  −
.makeCollapsible();
  −
}
     −
function init() {
+
$( '#p-wikibase-otherprojects li.wb-otherproject-link a' ).each( function () {
mw.util.addCSS('li.' + myClassName + '{white-space:nowrap;border:solid 1px transparent;border-radius:6px;}\n' + //css for li element
+
var $link = $( this ),
'li.' + myClassName + '.' + liHighlightClass + '{background-color:yellow;border-color:green;}\n' + //css for highlighted li element.
+
url = $link.attr( 'href' ).replace( '/Main_Page', mw.util.wikiUrlencode( '/Заглавная_страница' ) );
'.rtl li.' + myClassName + '{float: right; margin-left: 3em;}\n' +
+
if ( $link.parent().hasClass( 'wb-otherproject-mediawiki' ) ) {
'.ltr li.' + myClassName + '{float: left; margin-right: 3em;}');
+
url = $link.attr( 'href' ) + '/ru';
$(hilightDivMarker+ ' img').each(handleOneMap);
+
}
}
+
$link.attr( 'href', url );
 +
} );
 +
} );
 +
} );
 +
 +
// Закрываем меню при клике за его пределами
 +
mw.hook( 'wikipage.content' ).add( function () {
 +
var $items =  $( '.main-footer-menuToggle' ),
 +
$target;
 +
 +
document.body.addEventListener( 'click', function ( event ) {
 +
    $target = $( event.target ).parents( '.main-footer-menuToggle' )[0];
 +
    $items.each( function () {
 +
        if( this !== $target && !$( this ).hasClass( 'mw-collapsible-toggle-collapsed' ) ) {
 +
            $( this ).click();
 +
        }
 +
    } );
 +
}, true );
 +
} );
 +
}
   −
//has at least one "imagehighlight" div, and canvas-capable browser:
  −
if ( $(hilightDivMarker).length && $('<canvas>')[0].getContext )
  −
mw.loader.using( ['jquery.makeCollapsible', 'mediawiki.util'] ).done( init );
  −
});
  −
  −
    /**
  −
* imgToggle
  −
*/
  −
// На странице есть как минимум один элемент div.img_toggle
  −
if ( $( 'div.img_toggle' ).length ) {
  −
mw.loader.load( 'ext.gadget.imgToggle' );
  −
}
   
/**
 
/**
  * Magic editintros ****************************************************
+
  * Выполнение скриптов из пространства MediaWiki, указанных в URL
  *
+
  * См. также https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
* Description: Adds editintros on disambiguation pages and BLP pages.
  −
* Maintainers: [[User:RockMFR]]
   
  */
 
  */
function addEditIntro( name ) {
+
var withJS = location.href.match( /[&?]withjs=((mediawiki:)?([^&#]+))/i );
$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) {
+
if ( withJS ) {
el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
+
importScript_( 'MediaWiki:' + withJS[3] );
} );
   
}
 
}
   −
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
+
/**
$( function () {
+
* Код, который нужно выполнить как можно раньше. Он выполняется, если загружен подвал страницы,
if ( document.getElementById( 'disambigbox' ) ) {
+
* иначе же ждёт наступления события wikipage.content (см. выше определение runAsEarlyAsPossible
addEditIntro( 'Template:Disambig_editintro' );
+
* и ниже про wikipage.content).
 +
*/
 +
runAsEarlyAsPossible( function () {
 +
/**
 +
* {{выполнить скрипт}}
 +
*/
 +
$( '.executeJS' ).each( function () {
 +
var names = $( this ).data( 'scriptnames' );
 +
if (names) {
 +
names.split( ' ' ).forEach( function ( name ) {
 +
name = name.replace( /[^\w_-]/g, '' );
 +
if ( name ) {
 +
importScript( 'MediaWiki:Script/' + name + '.js' );
 +
}
 +
} );
 
}
 
}
 
} );
 
} );
   −
$( function () {
+
/**
var cats = mw.config.get('wgCategories');
+
* Чтобы ссылки на очистку кэша не требовали подтверждения (они должны быть помещены в тег с классом
if ( !cats ) {
+
* purgelink и именем страницы в атрибуте data-pagename, например как в шаблоне {{очистить кэш}})
return;
+
*/
}
+
$( '.purgelink a' ).click( function ( e ) {
if ( $.inArray( 'Yaşayan insanlar', cats ) !== -1 || $.inArray( 'Yaşayan insanlar', cats ) !== -1 ) {
+
mw.loader.using( [ 'mediawiki.api', 'mediawiki.util', 'mediawiki.notify' ] ).done( function () {
addEditIntro( 'Template:BLP_editintro' );
+
var pageName = $( this ).parent( '.purgelink' ).data( 'pagename' ) || mw.config.get( 'wgPageName' );
}
+
new mw.Api().post( {
 +
action: 'purge',
 +
titles: pageName
 +
} ).then( function () {
 +
var url = mw.util.getUrl( pageName );
 +
if ( e.ctrlKey ) {
 +
if ( !window.open( url ) ) {
 +
location.assign( url );
 +
}
 +
} else {
 +
location.assign( url );
 +
}
 +
}, function () {
 +
mw.notify( 'Не удалось очистить кэш.', { type: 'error' } );
 +
} );
 +
e.preventDefault();
 +
} );
 
} );
 
} );
}
+
}, $( '#footer' ), mw.hook( 'wikipage.content' ).add );
   −
$(function() {
+
// По какой-то причине фикс для FlaggedRevs работает только при использовании then(), но не done().
 
+
mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init' ).then( function () {
var
+
/**
//add this class to all elements created by the script. the reason is that we call the script again on
+
* Исправление поведения FlaggedRevs в сочетании с визуальным редактором, чтобы
//window resize, and use the class to remove all the "artefacts" we created in the previous run.
+
* в стабилизированных статьях на правку в визреде открывалась последняя версия, что
myClassName = 'imageMapHighlighterArtefacts',
+
* соответствует поведению обычного редактора. См. [[phab:T165283]],
liHighlightClass = 'liHighlighting',
+
* [[Википедия:Форум/Архив/Общий/2017/12#Серьёзная проблема с анонимными правками в стабилизированных статьях]].
specialAreaMark = 'area_mark',
+
*/
specialLiClassesMark = 'list_classes',
+
runAsEarlyAsPossible( function () {
specialAreaMarkFile = 'area_mark_file',
+
function fixEditLinksForStableRevs( removeClickHandlers ) {
// "2d context" attributes used for highlighting.
+
if ( $( '#ca-view.selected' ).length ) {
areaHighLighting = {
+
// При выходе из визреда (сохранении или переключении) ссылки работают правильно
fillStyle: 'rgba(0,0,0,0.35)',
+
// и убирать обработчики событий нет нужды — только исправить URL’ы на случай
strokeStyle: 'yellow',
+
// открытия правки в новой вкладке.
lineJoin: 'round',
+
if ( removeClickHandlers ) {
lineWidth: 2
+
$( '#ca-ve-edit, .mw-editsection-visualeditor' ).off( 'click' );
},
+
}
//every imagemap that wants highlighting, should reside in a div of this 'class':
+
$( '#ca-ve-edit a, .mw-editsection-visualeditor' ).each( function () {
hilightDivMarker = '.imageMapHighlighter',
+
var href = $( this ).attr( 'href' );
// specifically for wikis - redlinks tooltip adds this message
+
if ( !/[?&]stable=0/.test( href ) ) {
ru = mw && mw.config && mw.config.get('wgUserLanguage') == 'ru',
+
$( this ).attr( 'href',
expandLegend = ru ? 'показать ссылки текстом' : 'sıyahını aç',
+
href
collapseLegend = ru ? 'скрыть ссылки текстом' : 'siyahını bağla',
+
.replace( /&veaction=edit/, '&stable=0&veaction=edit' )
files = [];
+
.replace( /&oldid=\d+/,  '' )
 
+
);
 
+
}
function drawMarker(context, areas) { // this is where the magic is done.
+
} );
 
+
}
function drawPoly(coords) {
  −
context.moveTo(coords.shift(), coords.shift());
  −
while (coords.length)
  −
context.lineTo(coords.shift(), coords.shift());
   
}
 
}
   −
for (var i in areas) {
+
// Не включаем сюда проверку на наличие #ca-view.selected, чтобы не вычёркивать случай,
var coords = areas[i].coords.split(',');
+
// когда визред открыт без Ajax и по выходу из него нужно заменить URL’ы в ссылках.
context.beginPath();
+
if ( $( '#ca-current' ).length && !/[?&](oldid|diff)=\d+/.test( location.search ) ) {
switch (areas[i].shape) {
+
fixEditLinksForStableRevs( true );
case 'rect':
+
drawPoly([coords[0], coords[1], coords[0], coords[3], coords[2], coords[
+
mw.hook( 've.deactivationComplete' ).add( function () {
3], coords[2], coords[1]]);
+
fixEditLinksForStableRevs( false );
break;
+
} );
case 'circle':
  −
context.arc(coords[0], coords[1], coords[2], 0, Math.PI * 2);
  −
break; //x,y,r,startAngle,endAngle
  −
case 'poly':
  −
drawPoly(coords);
  −
break;
  −
}
  −
context.closePath();
  −
context.stroke();
  −
context.fill();
   
}
 
}
}
+
} );
 +
 +
/**
 +
* Поддержка Викификатора в новом режиме вики-текста aka 2017 wikitext editor
 +
*/
 +
mw.libs.ve.addPlugin( function () {
 +
return mw.loader.using( 'ext.gadget.wikificator' );
 +
} );
 +
} );
   −
function mouseAction(e) {
+
/**
var $this = $(this),
+
* {{TOC hidden}}
activate = e.type == 'mouseover',
+
*/
caption = $this.text(),
+
function TOChidden() {
ol = $this.parent(),
+
$( '.tochidden-wrapper > #toc > #toctogglecheckbox' ).prop('checked', true );
context = ol.data('context'),
+
$( '.tochidden-wrapper' ).attr( "class", "toc-wrapper" );
special = ol.data(specialAreaMark),
+
}
specialFile = ol.data(specialAreaMarkFile); //read JSON file addition
     −
if (specialFile) {
+
runAsEarlyAsPossible( function () {
if (files[specialFile]) {
+
if ( $( '.tochidden-wrapper' ).length ) {
$.extend(special, files[specialFile]);
+
mw.loader.using( [ 'mediawiki.cookie' ] ).done( function () {
always(activate, caption, context, ol, special, $this);
+
if ( mw.cookie.get( 'hidetoc' ) === null ) {
} else {
+
$.when( mw.loader.using( [ 'mediawiki.toc' ] ), $.ready ).then( TOChidden );
$.get(mw.util.wikiScript(), {
  −
title: specialFile,
  −
action: 'raw'
  −
})
  −
.done(function(data) {
  −
files[specialFile] = JSON.parse(data);
  −
$.extend(special, files[specialFile]);
  −
})
  −
.always(function() {
  −
always(activate, caption, context, ol, special, $this);
  −
});
   
}
 
}
} else
+
} );
always(activate, caption, context, ol, special, $this);
   
}
 
}
 +
}, $( '#toc' ), mw.hook( 'wikipage.content' ).add );
   −
function always(activate, caption, context, ol, special, $this) {
+
/**
$this.toggleClass(liHighlightClass, activate); // mark/unmark the list item.
+
* Код, выполняемый по событию wikipage.content (его обработчики выполняются раньше колбэков для $,
 +
* хотя в глубине это одно и то же событие, просто колбэк, инициирующий wikipage.content, становится
 +
* в очередь раньше). Так как wikipage.content инициируется после обновления страницы в результате
 +
* Ajax-запросов (например, гаджетом быстрого предпросмотра), не добавляйте сюда коды, которые
 +
* должны гарантированно выполниться не более одного раза на странице.
 +
*/
 +
mw.hook( 'wikipage.content' ).add( function () {
 +
/**
 +
* Отключение обтекания раздела примечаний, если в нём есть колонки.
 +
* Короткие (до 16 ссылок) списки примечаний обтекаются только справа.
 +
*/
 +
$( '.reflist.columns' ).each( function () {
 +
var clear = 'both';
 +
if ( $( this ).find( 'ol.references > li' ).length < 16 ) {
 +
clear = 'left';
 +
}
 +
$( this )
 +
.prevUntil( 'h1, h2, h3, h4, h5, h6' )
 +
.addBack()
 +
.first()
 +
.prev()
 +
.css( 'clear', clear );
 +
} );
   −
context.clearRect(0, 0, context.canvas.width, context.canvas.height); // prepare for a new day.
+
/**
 
+
* Imagemap Highlight
ol.find('li')
+
*/
.each(function() {
+
// На странице есть как минимум один элемент .imageMapHighlighter, а браузер поддерживает <canvas>
var $li = $(this);
+
if ( $( '.imageMapHighlighter' ).length && $( '<canvas>' )[ 0 ].getContext ) {
var licap = $li.text();
+
importScript( 'MediaWiki:Imagemap-Highlight.js' );
var param;
  −
if (activate && licap === caption) { // highlight!!!
  −
param = special && (special.hover && special.hover[licap]
  −
|| getblocks(special, licap)) || areaHighLighting;
  −
} else {
  −
param = special && special.nover && (special.nover[licap] || special.nover
  −
.default);
  −
}
  −
if (param) {
  −
$.extend(context, param);
  −
drawMarker(context, $li.data('areas'));
  −
}
  −
});
   
}
 
}
   −
function getblocks(special, licap) {
+
/**
if (special.hoverblocks) {
+
* imgToggle
if (special.hoverblocks[licap])
+
*/
return special.hoverblocks[licap].value;
+
// На странице есть как минимум один элемент div.img_toggle
for (var key in special.hoverblocks)
+
if ( $( 'div.img_toggle' ).length ) {
if (special.hoverblocks[key] && special.hoverblocks[key].list.indexOf(licap) >=0 )
+
mw.loader.load( 'ext.gadget.imgToggle' );
return special.hoverblocks[key].value;
  −
}
  −
if (special.hover)
  −
return special.hover.default;
   
}
 
}
  −
function handleOneMap() {
  −
var img = $(this),
  −
w = img.width(),
  −
h = img.height(),
  −
infoIcon = img.next(),
  −
parent = img.parent(),
  −
map = img.siblings('map:first'),
  −
dims = {
  −
position: 'absolute',
  −
width: w + 'px',
  −
height: h + 'px',
  −
border: 0,
  −
top: 0,
  −
left: 0
  −
},
  −
specialHighlight = img.closest(hilightDivMarker)
  −
.data(specialAreaMark),
  −
specialLiClasses = img.closest(hilightDivMarker)
  −
.data(specialLiClassesMark),
  −
specialHover = img.closest(hilightDivMarker)
  −
.data(specialAreaMarkFile);
     −
if (!('area', map)
+
/**
.length)
+
* Авторазбиение списков на колонки. Будет работать только для однострочных списков. 35em
return; //not an imagemap. inside "each" anonymous function, 'return' means "continue".
+
* (из Mediawiki:Common.css) является предварительным числом, а фактическое будет посчитано исходя
 +
* из ширины элементов. Должно использоваться только для UL внутри DIV. Пример использования —
 +
* шаблон {{Wikidata/SisterCities}}.
 +
*/
 +
$("div.autocolumns").each(function(d, div) {
 +
var parentWidth = $(div).parent()[0].offsetWidth;
 +
if (!parentWidth) return;
   −
var jcanvas = $('<canvas>', {
+
var maxWidth = 0;
'class': myClassName
+
var elements = 0;
})
+
$(div).find("ul>li").each(function(l, li) {
.css(dims)
+
elements++;
.attr({
+
var jLi = $(li);
width: w,
+
if (jLi.children().length != jLi.contents().length)
height: h
+
jLi.wrapInner(document.createElement("span"));
});
  −
var bgimg = $('<img>', {
  −
'class': myClassName,
  −
src: img.attr('src')
  −
})
  −
.css(dims); //completely inert image. this is what we see.
  −
var context = $.extend(jcanvas[0].getContext("2d"), areaHighLighting);
     −
// this is where the magic is done: prepare a sandwich of the inert bgimg at the bottom,
+
var liWidth = 0;
// the canvas above it, and the original image on top,
+
jLi.children().each(function(c, child) {
// so canvas won't steal the mouse events.
+
liWidth += child.offsetWidth;
// pack them all TIGHTLY in a newly minted "relative" div, so when page chnage
  −
// (other scripts adding elements, window resize etc.), canvas and imagese remain aligned.
  −
var div = $('<div>')
  −
.css({
  −
position: 'relative',
  −
width: w + 'px',
  −
height: h + 'px'
   
});
 
});
img.before(div); // put the div just above the image, and ...
+
if (liWidth > maxWidth)
div.append(bgimg) // place the background image in the div
+
maxWidth = liWidth;
.append(jcanvas) // and the canvas. both are "absolute", so they don't occupy space in the div
+
});
.append(img); // now yank the original image from the window and place it on the div.
+
if ( maxWidth === 0 ) return;
img.fadeTo(1, 0); // make the image transparent - we see canvas and bgimg through it.
+
// UL/LI bullet width + padding
// the original, now transparent image is creating our mouse events
+
maxWidth += 22.5 * 2;
   −
infoIcon.css({
+
var maxColumns = "" + Math.ceil( elements / 5 );
position: 'relative'
+
$(div).css({"-moz-columns": maxWidth + "px " + maxColumns, "columns" : maxWidth + "px " + maxColumns});
}); // set position to info icon
+
});
var ol = $('<ol>', {
+
});
'class': myClassName
  −
})
  −
.css({
  −
clear: 'both',
  −
margin: 0,
  −
listStyle: 'none',
  −
maxWidth: w + 'px',
  −
position: 'relative'
  −
})
  −
.data(specialAreaMark, specialHighlight)
  −
.data(specialAreaMarkFile, specialHover)
  −
.data('context', context);
  −
var oldiv = $('<div>')
  −
.html(ol)
  −
.css({
  −
clear: 'both',
  −
margin: 0,
  −
listStyle: 'none',
  −
maxWidth: w + 'px',
  −
position: 'relative'
  −
})
  −
.attr({
  −
'data-expandtext': expandLegend,
  −
'data-collapsetext': collapseLegend
  −
});
     −
// ol below image parent, hr below ol. original caption pushed below hr.
+
/**
parent.after($('<hr>', {
+
* Кнопки описания правок для визуального редактора
'class': myClassName
+
*/
})
+
mw.hook( 've.activationComplete' ).add( function () {
.css('clear', 'both'))
+
mw.loader.load( 'ext.gadget.summaryButtons' );
.after(oldiv);
+
} );
$('<hr>', {
  −
'class': myClassName
  −
})
  −
.css('clear', 'both')
  −
.insertBefore($(oldiv));
  −
  −
var lis = {}; //collapse areas with same caption to one list item
  −
var someli; // select arbitrary one
  −
$('area', map)
  −
.each(function() {
  −
var text = this.title;
  −
var li = lis[text]; // title already met? use the same li
  −
if (!li) { //no? create a new one.
  −
var href = this.href;
  −
lis[text] = li = $('<li>', {
  −
'class': myClassName
  −
})
  −
.append($('<a>', {
  −
href: href,
  −
text: text
  −
}))
  −
.on('mouseover mouseout', mouseAction)
  −
.data('areas', [])
  −
.addClass(specialLiClasses && (specialLiClasses[text] ||
  −
specialLiClasses['default']))
  −
.appendTo(ol);
  −
if (specialLiClasses && specialLiClasses[text + ' super'])
  −
li.find('a')
  −
.addClass(specialLiClasses[text + ' super']);
  −
}
  −
li.data('areas')
  −
.push(this); //add the area to the li
  −
someli = li; // whichever - we just want one...
  −
$(this)
  −
.on('mouseover mouseout', function(e) {
  −
li.trigger(e);
  −
});
  −
});
  −
if (someli) someli.trigger('mouseout');
  −
oldiv.addClass('mw-collapsed')
  −
.makeCollapsible();
  −
ol.attr('style', ol.attr('style')
  −
.replace('none', 'disc'));
  −
}
  −
 
  −
function init() {
  −
mw.util.addCSS('li.' + myClassName +
  −
'{white-space:nowrap; font-size:88.36%;}\n' + //css for li element
  −
'li.' + liHighlightClass + '{background-color:yellow;}\n' + //css for highlighted li element.
  −
'.rtl li.' + myClassName + '{float: right; margin-left: 1.5em;}\n' +
  −
'.ltr li.' + myClassName + '{float: left; margin-right: 1.5em;}\n' +
  −
hilightDivMarker + ' .mw-collapsible-toggle {float: none}');
  −
$(hilightDivMarker + ' img')
  −
.each(handleOneMap);
  −
}
  −
 
  −
//has at least one "imagehighlight" div, and canvas-capable browser:
  −
if ($(hilightDivMarker)
  −
.length && $('<canvas>')[0].getContext)
  −
mw.loader.using(['jquery.makeCollapsible', 'mediawiki.util'])
  −
.done(init);
  −
});