Məzmuna keçin
Şəki Ensiklopediyasına maliyyə dəstəyi göstərmək istəyən hər bir şəxs 4169 7388 5183 5607 (05/26 VISA) Kapital Bank kart hesabımıza istədiyi məbləğdə ianə köçürə bilər.   Daha ətraflı...

MediaWiki:Common.js: Redaktələr arasındakı fərq

4.518 bayt çıxarıldı ,  14 mart 2020
redaktənin izahı yoxdur
(344 dəyişikliyi WikiSysop (Müzakirə) tərəfindən geri alındı.)
Teq: Geri qaytarma
Redaktənin izahı yoxdur
Sətir 1: Sətir 1:
/* Burada istifadəçilərin hamısı üçün bütün səhifələrdə istənilən JavaScript yüklənəcək */
// Switch language variants of messages (from zh)
// Switch language variants of messages (from zh)
function wgULS(latn,arab){
function wgULS(latn,arab){
Sətir 96: Sətir 97:
   }
   }
});
});
/* 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);
    };
})();


  /** Interwiki links to featured articles ***************************************
  /** Interwiki links to featured articles ***************************************
Sətir 104: Sətir 119:
   *  Maintainers: [[User:R. Koot]]
   *  Maintainers: [[User:R. Koot]]
   */
   */
 
/**
* NAVFRAME
*/
   
   
//Messages
//Messages
Sətir 117: Sətir 128:
var zeroSectionTip = 'Girişi redaktə et';
var zeroSectionTip = 'Girişi redaktə et';


var NavigationBarHide = '[gizlət]';
var NavigationBarHide = '[bağla]';
var NavigationBarShow = '[göstər]';
var NavigationBarShow = '[bax]';
var NavigationBarShowDefault = 2;
var NavigationBarShowDefault = 2;


Sətir 152: Sətir 163:




var NavigationBarShowDefault;
/** Collapsible tables *********************************************************
if ( typeof NavigationBarShowDefault === 'undefined' ) {
  *
NavigationBarShowDefault = 1;
  *  Description: Allows tables to be collapsed, showing only the header. See
}
  *              [[Wikipedia:NavFrame]].
  *  Maintainers: [[User:R. Koot]]
  */
var autoCollapse = 2;
var collapseCaption = "bağla";
var expandCaption = "bax";
function collapseTable( tableIndex )
{
    var Button = document.getElementById( "collapseButton" + tableIndex );
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
    var i;
    if ( !Table || !Button ) {
        return false;
    }
    var Rows = Table.getElementsByTagName( "tr" );
    if ( Button.firstChild.data == collapseCaption ) {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = "none";
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
}
function createCollapseButtons()
{
    var tableIndex = 0;
    var NavigationBoxes = {};
    var Tables = document.getElementsByTagName( "table" );
    var i;
    for ( i = 0; i < Tables.length; i++ ) {
        if ( hasClass( Tables[i], "collapsible" ) ) {
            NavigationBoxes[ tableIndex ] = Tables[i];
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
            var Button    = document.createElement( "span" );
            var ButtonLink = document.createElement( "a" );
            var ButtonText = document.createTextNode( collapseCaption );
            Button.style.styleFloat = "right";
            Button.style.cssFloat = "right";
            Button.style.fontWeight = "normal";
            Button.style.textAlign = "right";
            Button.style.width = "6em";
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
            ButtonLink.appendChild( ButtonText );
            Button.appendChild( document.createTextNode( "[" ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( "]" ) );
            var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
            /* only add button and increment count if there is a header row to work with */
            if (Header) {
                Header.insertBefore( Button, Header.childNodes[0] );
                tableIndex++;
            }
        }
    }
    for ( i = 0;  i < tableIndex; i++ ) {
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
            collapseTable( i );
        }
    }
}
$( createCollapseButtons );


// table.collapsible
/** Dynamic Navigation Bars (experimental) *************************************
function makeCollapsibleMwCollapsible( $content ) {
  *
var $tables = $content
  *  Description: See [[Wikipedia:NavFrame]].
.find( 'table.collapsible:not(.mw-collapsible)' )
  * Maintainers: UNMAINTAINED
.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 [[Wikipedia:NavFrame]].
  * Maintainers: UNMAINTAINED
*/
   
   
var collapseCaption = 'gizlə';
  // set up the words in your language
var expandCaption = 'göstər';
  var NavigationBarHide = '[' + collapseCaption + ']';
 
  var NavigationBarShow = '[' + expandCaption + ']';
// Set up the words in your language
 
var navigationBarHide = '[' + collapseCaption + ']';
  // set up max count of Navigation Bars on page,
var navigationBarShow = '[' + expandCaption + ']';
  // if there are more, all will be hidden
 
  // NavigationBarShowDefault = 0; // all bars will be hidden
/**
  // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
* Shows and hides content and picture (if available) of navigation bars.
  var NavigationBarShowDefault = autoCollapse;
*
 
* @param {number} indexNavigationBar The index of navigation bar to be toggled
 
* @param {jQuery.Event} event Event object
  // shows and hides content and picture (if available) of navigation bars
*/
  // Parameters:
function toggleNavigationBar( indexNavigationBar, event ) {
  //    indexNavigationBar: the index of navigation bar to be toggled
var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
  function toggleNavigationBar(indexNavigationBar)
var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
  {
var navChild;
    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
 
    var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if ( !navFrame || !navToggle ) {
 
return false;
    if (!NavFrame || !NavToggle) {
}
        return false;
 
    }
// If shown now
 
if ( navToggle.firstChild.data === navigationBarHide ) {
    // if shown now
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
    if (NavToggle.firstChild.data == NavigationBarHide) {
if ( $( navChild ).hasClass( 'NavContent' ) ) {
        for (
navChild.style.display = 'none';
                var NavChild = NavFrame.firstChild;
}
                NavChild != null;
}
                NavChild = NavChild.nextSibling
navToggle.firstChild.data = navigationBarShow;
            ) {
            if ( hasClass( NavChild, 'NavPic' ) ) {
// If hidden now
                NavChild.style.display = 'none';
} else if ( navToggle.firstChild.data === navigationBarShow ) {
            }
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
            if ( hasClass( NavChild, 'NavContent') ) {
if ( $( navChild ).hasClass( 'NavContent' ) ) {
                NavChild.style.display = 'none';
navChild.style.display = 'block';
            }
}
        }
}
    NavToggle.firstChild.data = NavigationBarShow;
navToggle.firstChild.data = navigationBarHide;
 
}
    // if hidden now
 
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
event.preventDefault();
        for (
}
                var NavChild = NavFrame.firstChild;
 
                NavChild != null;
/**
                NavChild = NavChild.nextSibling
* Adds show/hide-button to navigation bars.
            ) {
*
            if (hasClass(NavChild, 'NavPic')) {
* @param {jQuery} $content
                NavChild.style.display = 'block';
*/
            }
function createNavigationBarToggleButton( $content ) {
            if (hasClass(NavChild, 'NavContent')) {
var i, j, navChild, navToggle, navToggleText, isCollapsed,
                NavChild.style.display = 'block';
indexNavigationBar = 0;
            }
// Iterate over all < div >-elements
        }
var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );
    NavToggle.firstChild.data = NavigationBarHide;
$divs.each( function ( i, navFrame ) {
    }
indexNavigationBar++;
  }
navToggle = document.createElement( 'a' );
 
navToggle.className = 'NavToggle';
  // adds show/hide-button to navigation bars
navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
  function createNavigationBarToggleButton()
navToggle.setAttribute( 'href', '#' );
  {
$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );
    var indexNavigationBar = 0;
 
    // iterate over all < div >-elements  
isCollapsed = $( navFrame ).hasClass( 'collapsed' );
    var divs = document.getElementsByTagName("div");
/**
    for(
* Check if any children are already hidden.  This loop is here for backwards compatibility:
            var i=0;  
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
            NavFrame = divs[i];
* to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
            i++
* 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.
        // if found a navigation bar
*/
        if (hasClass(NavFrame, "NavFrame")) {
for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) {
 
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
            indexNavigationBar++;
if ( navChild.style.display === 'none' ) {
            var NavToggle = document.createElement("a");
isCollapsed = true;
            NavToggle.className = 'NavToggle';
}
            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
}
            NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
}
           
if ( isCollapsed ) {
            var NavToggleText = document.createTextNode(NavigationBarHide);
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
            NavToggle.appendChild(NavToggleText);
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
            // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
navChild.style.display = 'none';
            for(
}
              var j=0;  
}
              j < NavFrame.childNodes.length;  
}
              j++
navToggleText = document.createTextNode( isCollapsed ? navigationBarShow : navigationBarHide );
            ) {
navToggle.appendChild( navToggleText );
              if (hasClass(NavFrame.childNodes[j], "NavHead")) {
 
                NavFrame.childNodes[j].appendChild(NavToggle);
// 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' ) ) {
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
navToggle.style.color = navFrame.childNodes[j].style.color;
        }
navFrame.childNodes[j].appendChild( navToggle );
    }
}
    // if more Navigation Bars found than Default: hide all
}
    if (NavigationBarShowDefault < indexNavigationBar) {
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
        for(
} );
                var i=1;
}
                i<=indexNavigationBar;  
 
                i++
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
        ) {
            toggleNavigationBar(i);
        }
    }
 
  }
 
  $( createNavigationBarToggleButton );


  /** "Technical restrictions" title fix *****************************************
  /** "Technical restrictions" title fix *****************************************
Sətir 376: Sətir 414:
                         realTitleBanner.style.display = "none";
                         realTitleBanner.style.display = "none";
                 }
                 }
                 document.title = realTitleText + " - Şəki Ensiklopediyası";
                 document.title = realTitleText + " - Wikipedia, the free encyclopedia";
             }
             }
         }
         }
Sətir 535: Sətir 573:
     ShortName: "MediaWiki axtarışı",
     ShortName: "MediaWiki axtarışı",
     Template: "/w/index.php?search={searchTerms}"
     Template: "/w/index.php?search={searchTerms}"
  },
  globalwpsearch: {
    ShortName: "Qlobal vikipediyalar",
    Template: "http://vs.aka-online.de/cgi-bin/globalwpsearch.pl?timeout=120&search={searchTerms}"
   },
   },
   google: {
   google: {
     ShortName: "Google",
     ShortName: "Google",
     Template: "http://www.google.cat/search?as_sitesearch=wiki.sheki.site&hl={language}&q={searchTerms}"
     Template: "http://www.google.cat/search?as_sitesearch=az.wikipedia.org&hl={language}&q={searchTerms}"
  },
  wikiwix: {
    ShortName: "Wikiwix",
    Template: "http://www.wikiwix.com/index.php?action={searchTerms}&lang=az"
   },
   },
   yahoo: {
   yahoo: {
     ShortName: "Yahoo!",
     ShortName: "Yahoo!",
     Template: "http://search.yahoo.com/search?p={searchTerms}&vs=wiki.sheki.site"
     Template: "http://search.yahoo.com/search?p={searchTerms}&vs=az.wikipedia.org"
   },
   },
   wlive: {
   wlive: {
     ShortName: "Windows Live",
     ShortName: "Windows Live",
     Template: "http://search.live.com/results.aspx?q={searchTerms}&q1=site:http://wiki.sheki.site"
     Template: "http://search.live.com/results.aspx?q={searchTerms}&q1=site:http://az.wikipedia.org"
   }
   }
};
};
Sətir 729: Sətir 775:
         mw.loader.load("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
         mw.loader.load("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
}
}
/**
* Imagemap Highlight
$(document).ready(function() {
    var
//add this class to all elements created by the script. the reason is that we call the script again on
//window resize, and use the class to remove all the "artefacts" we created in the previous run.
myClassName = 'imageMapHighlighterArtefacts'
, liHighlightClass = 'liHighlighting'
, specialAreaMark = 'area_mark'
, specialLiClassesMark = 'list_classes'
// "2d context" attributes used for highlighting.
, areaHighLighting = {fillStyle: 'rgba(0,0,0,0.35)', strokeStyle: 'yellow', lineJoin: 'round', lineWidth: 2}
//every imagemap that wants highlighting, should reside in a div of this 'class':
, hilightDivMarker = '.imageMapHighlighter'
// specifically for wikis - redlinks tooltip adds this message
, az = mw && mw.config && mw.config.get('wgUserLanguage') == 'az'
, expandLegend = az ? 'Adları göstər' : 'ּShow Legend'
, collapseLegend = az ? 'Adları gizlət' : 'Hide Legend'
;
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) {
var coords = areas[i].coords.split(',');
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(),
ol = $this.parent(),
context = ol.data('context'),
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(),
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);
if (!('area', map).length)
return; //not an imagemap. inside "each" anonymous function, 'return' means "continue".
var jcanvas = $('<canvas>', {'class': myClassName})
.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() {
mw.util.addCSS('li.' + myClassName + '{white-space:nowrap;border:solid 1px transparent;border-radius:6px;}\n' + //css for li element
'li.' +  myClassName + '.' + liHighlightClass + '{background-color:yellow;border-color:green;}\n' + //css for highlighted li element.
'.rtl li.' + myClassName + '{float: right; margin-left: 3em;}\n' +
'.ltr li.' + myClassName + '{float: left; margin-right: 3em;}');
$(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 );
});


     /**
     /**