"मीडियाविकि:Common.js": अवतरणों में अंतर
भारत डिस्कवरी प्रस्तुति
आदित्य चौधरी (वार्ता | योगदान) No edit summary |
व्यवस्थापन (वार्ता | योगदान) No edit summary |
||
| पंक्ति 207: | पंक्ति 207: | ||
addOnloadHook( createNavigationBarToggleButton ); | addOnloadHook( createNavigationBarToggleButton ); | ||
== Menük és tabsetek inicializálása == | |||
*/ | |||
function generateMenuLayout(desti, level) { | |||
if (level > 2) return 0; // max. 2 szint | |||
var curr = $("<ul></ul>"); | |||
$("div", desti).each(function() { | |||
var cdiv = $(this); | |||
if (cdiv.hasClass("menuItem")) { | |||
$("<li>").html(cdiv.html()).appendTo(curr); | |||
} else { | |||
var ret = generateMenuLayout($("#wikiMenu-" + cdiv.attr("title")), level+1); | |||
if (ret != 0) { | |||
$("<li>").html(cdiv.html()).append(ret).appendTo(curr); | |||
} | |||
} | |||
}); | |||
if (level == 0) { | |||
desti.after(curr); | |||
var destid = "menu-" + desti.attr("id").substring(10); | |||
curr.attr("id", destid) | |||
.addClass("sf-menu"); | |||
desti.remove(); | |||
if (mw.config.get('wikimenu.useCustomMenu', false) == true | |||
&& wgUserName != null && curr.parents("#header-menu").length > 0) | |||
{ | |||
$.wiki.getPageRaw({ | |||
pageName: "User:" + wgUserName + "/Saját menü", | |||
async: false, | |||
success: function(data) { | |||
var items = data.split("\n"); | |||
if (items.length == 0 || items.length == 1 && items[0] == "") return; | |||
var cmenu = $('<ul></ul>'); | |||
var ccount = 0; | |||
for (var zs = 0; zs < items.length; zs++) { | |||
if (items[zs] == "" || items[zs].substring(0,1) != '#') continue; | |||
var foo = items[zs].substring(1); | |||
if (foo.indexOf("|") > -1) { | |||
var splitem = foo.split("|"); | |||
$('<li><a href="' + $.wiki.wikiLink(splitem[0], false) + '">' + splitem[1] + '</a></li>').appendTo(cmenu); | |||
} else { | |||
$('<li><a href="' + $.wiki.wikiLink(foo, false) + '">' + foo + '</a></li>').appendTo(cmenu); | |||
} | |||
ccount++; | |||
} | |||
if (ccount > 0) { | |||
$('<li><a href="#">Saját</a></li>').append(cmenu).appendTo(curr); | |||
} | |||
} | |||
}); | |||
} | |||
return destid; | |||
} else { | |||
return curr; | |||
} | |||
} | |||
$(function() { | |||
if (wgNamespaceNumber != 0) { | |||
/* Sima cím eltüntetése, ha a menü alatt van helyettesítő */ | |||
if (wgAction != "edit" && wgAction != "submit" && $("#header-title").length > 0) { | |||
if (skin != "modern") { | |||
$("#firstHeading").css("display", "none"); | |||
$("#siteSub").css("display", "none"); | |||
} | |||
if ($("#contentSub").length > 0 && $("#mw-revision-info").length == 0) | |||
$("#contentSub").css("display", "none"); | |||
} | |||
/* Gombok */ | |||
var bigButtons = $(".bigButton", $($.wiki.contentSelector)); | |||
if (bigButtons.length > 0) { | |||
bigButtons.each(function() { | |||
var link = $("a:first", $(this)); | |||
if (link.length > 0) { | |||
var curLink = link.attr("href"); | |||
link.parent().html(link.html()); | |||
$(this).css("cursor", "pointer") | |||
.wrap('<a class="buttonWrapperAnchor" href="' + curLink + '"></a>'); | |||
} | |||
}); | |||
} | |||
/* Eligazítólapok */ | |||
var eliItems = $(".eligazitoLap > .eligazitoElem", $($.wiki.contentSelector)); | |||
if (eliItems.length > 0) { | |||
/* IE6 miaza:hover??-bugfix */ | |||
if ($.browser.msie && $.browser.version == 6) { | |||
eliItems.hover( | |||
function() { | |||
$(this).addClass("eeHover"); | |||
}, | |||
function() { | |||
$(this).removeClass("eeHover"); | |||
} | |||
); | |||
} | |||
eliItems.each(function() { | |||
var link = $(".eligazitoTovabb > a", $(this)); | |||
if (link.length > 0) { | |||
var curLink = link.attr("href"); | |||
link.parent().html(link.html()); | |||
$(this).css("cursor", "pointer") | |||
.wrap('<a href="' + curLink + '" class="eligazitoWrapLink"></a>'); | |||
} | |||
}); | |||
} | |||
/* Tabok felépítése */ | |||
$(".tabset-tabs", $($.wiki.contentSelector)).each(function() { | |||
var tabul = $("<ul></ul>"); | |||
var curid = $(this).attr("id").substring(10); | |||
var tabCount = 0; | |||
$("#" + curid + "-content > div").each(function() { | |||
var cdiv = $(this); | |||
if (cdiv.hasClass("tab-nojs")) cdiv.removeClass("tab-nojs"); | |||
if (cdiv.attr("title") != "") { | |||
$("<li></li>").html("<a>" + cdiv.attr("title") + "</a>").appendTo(tabul); | |||
tabCount++; | |||
} else { | |||
cdiv.remove(); | |||
} | |||
}); | |||
if (tabCount > 0) { | |||
$(this).after(tabul); | |||
tabul.attr("id", curid); | |||
tabul.addClass("tabset-tabs"); | |||
tabul.tabs("#" + curid + "-content > div"); | |||
tabul.trigger('tabsetReady'); | |||
} else { | |||
$("#" + curid + "-content").remove(); | |||
} | |||
$(this).remove(); | |||
}); | |||
/* Menük felépítése */ | |||
if (mw.config.get('wikimenu.disabled', false) == false) { | |||
var menuRoots = $(".wikiMenu-rootContainer", $($.wiki.contentSelector)); | |||
if (menuRoots.length > 0) { | |||
menuRoots.each(function() { | |||
var destid = generateMenuLayout($(this), 0); | |||
if (jQuery.browser.msie && jQuery.browser.version == 6) { | |||
$("#" + destid).superfish(); | |||
} else { | |||
$("#" + destid).supersubs({ | |||
minWidth: 12, // minimum width of sub-menus in em units | |||
maxWidth: 27, // maximum width of sub-menus in em units | |||
extraWidth: 2 // extra width can ensure lines don't sometimes turn over | |||
// due to slight rounding differences and font-family | |||
}).superfish(); | |||
} | |||
}); | |||
} | |||
$(".wikiMenu-container", $($.wiki.contentSelector)).remove(); | |||
} | |||
} | |||
}); | |||
/* Kapcsolódó lapok */ | |||
$j(function() { | |||
$j('.buborekGomb').each(function() { | |||
if (wgNamespaceNumber===0) return; | |||
var $this = $j(this); | |||
var contentDivSelector = '#' + $this.attr('id').replace(/^button-/, '') + '-content'; | |||
var contentDiv = $j(contentDivSelector); | |||
var bodySelector = 'body'; | |||
if (skin==='monobook') bodySelector = '#globalWrapper'; | |||
$j(contentDivSelector).appendTo(bodySelector); | |||
var contentDivWidth = 0; | |||
$j.swap(contentDiv.get(0), {display: 'block'}, function() { | |||
contentDivWidth = $j(this).outerWidth(); | |||
}); | |||
function reposBuborek() { | |||
var contentDivLeft = $this.offset().left + contentDivWidth > $j(window).width() | |||
? $this.offset().left + $this.outerWidth() - contentDivWidth | |||
: $this.offset().left; | |||
$j(contentDivSelector).css({ | |||
position: 'absolute', | |||
top: $this.offset().top + $this.outerHeight(), | |||
left: contentDivLeft | |||
}); | |||
} | |||
reposBuborek(); | |||
$j(contentDivSelector).find('.buborekTitlebar').prepend( | |||
$j('<div>').addClass('buborekCloseButton') | |||
.html('x') | |||
.click(function() { | |||
$this.removeClass('button-active'); | |||
contentDiv.stop().fadeTo(200, 0).removeClass('buborekVisible').hide(); | |||
}) | |||
); | |||
$this.click(function() { | |||
if(contentDiv.hasClass('buborekVisible')) { | |||
$this.removeClass('button-active'); | |||
contentDiv.stop().fadeTo(200, 0).removeClass('buborekVisible').hide(); | |||
} else { | |||
reposBuborek(); | |||
$this.addClass('button-active'); | |||
contentDiv.stop().show().fadeTo(200, 1).addClass('buborekVisible'); | |||
} | |||
}); | |||
}); | |||
}); | |||
/* | |||
06:37, 23 जून 2011 का अवतरण
/* यहां लिखी गई जावास्क्रीप्ट सभी सदस्योंके लिये इस्तेमाल में लाई जायेगी। */
function includePage( name )
{
document.write('<script type="text/javascript" src="' + wgScript + '?title='
+ name
+ '&action=raw&ctype=text/javascript"><\/script>'
);
}
/* End of includePage */
/* Including extra .js pages */
// switches for scripts
// var load_extratabs = true;
var load_edittools = true;
// extra drop down menu on editing for adding special characters
includePage( 'MediaWiki:Edittools.js' );
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* http://www.mediawiki.org/wiki/Manual:Collapsible_tables.
* Maintainers: [[**MAINTAINERS**]]
*/
var autoCollapse = 2;
var collapseCaption = 'छिपाएँ';
var expandCaption = 'दिखाएँ';
function collapseTable( tableIndex ) {
var Button = document.getElementById( 'collapseButton' + tableIndex );
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.rows;
if ( Button.firstChild.data == collapseCaption ) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = 'none';
}
Button.firstChild.data = expandCaption;
} else {
for ( var 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 = new Object();
var Tables = document.getElementsByTagName( 'table' );
for ( var i = 0; i < Tables.length; i++ ) {
if ( hasClass( Tables[i], 'collapsible' ) ) {
/* only add button and increment count if there is a header row to work with */
var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
if( !HeaderRow ) continue;
var Header = HeaderRow.getElementsByTagName( 'th' )[0];
if( !Header ) continue;
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.className = 'collapseButton'; // Styles are declared in MediaWiki:Common.css
ButtonLink.style.color = Header.style.color;
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( ']' ) );
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
for ( var i = 0; i < tableIndex; i++ ) {
if ( hasClass( NavigationBoxes[i], 'collapsed' ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], 'autocollapse' ) ) ) {
collapseTable( i );
}
}
}
addOnloadHook( createCollapseButtons );
/** 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);
};
})();
/** Dynamic Navigation Bars (experimental) *************************************
*
* Description: See [[Wikipedia:NavFrame]].
* Maintainers: UNMAINTAINED
*/
// set up the words in your language
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar)
{
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {
return false;
}
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
NavChild.style.display = 'none';
}
}
NavToggle.firstChild.data = NavigationBarShow;
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
NavChild.style.display = 'block';
}
}
NavToggle.firstChild.data = NavigationBarHide;
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
var indexNavigationBar = 0;
// iterate over all < div >-elements
var divs = document.getElementsByTagName("div");
for (var i = 0; NavFrame = divs[i]; i++) {
// if found a navigation bar
if (hasClass(NavFrame, "NavFrame")) {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var isCollapsed = hasClass( NavFrame, "collapsed" );
/*
* Check if any children are already hidden. This loop is here for backwards compatibility:
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
* 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 (var NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
if ( NavChild.style.display == 'none' ) {
isCollapsed = true;
}
}
}
if (isCollapsed) {
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
NavChild.style.display = 'none';
}
}
}
var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
for(var j=0; j < NavFrame.childNodes.length; j++) {
if (hasClass(NavFrame.childNodes[j], "NavHead")) {
NavFrame.childNodes[j].appendChild(NavToggle);
}
}
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
}
addOnloadHook( createNavigationBarToggleButton );
== Menük és tabsetek inicializálása ==
*/
function generateMenuLayout(desti, level) {
if (level > 2) return 0; // max. 2 szint
var curr = $("<ul></ul>");
$("div", desti).each(function() {
var cdiv = $(this);
if (cdiv.hasClass("menuItem")) {
$("<li>").html(cdiv.html()).appendTo(curr);
} else {
var ret = generateMenuLayout($("#wikiMenu-" + cdiv.attr("title")), level+1);
if (ret != 0) {
$("<li>").html(cdiv.html()).append(ret).appendTo(curr);
}
}
});
if (level == 0) {
desti.after(curr);
var destid = "menu-" + desti.attr("id").substring(10);
curr.attr("id", destid)
.addClass("sf-menu");
desti.remove();
if (mw.config.get('wikimenu.useCustomMenu', false) == true
&& wgUserName != null && curr.parents("#header-menu").length > 0)
{
$.wiki.getPageRaw({
pageName: "User:" + wgUserName + "/Saját menü",
async: false,
success: function(data) {
var items = data.split("\n");
if (items.length == 0 || items.length == 1 && items[0] == "") return;
var cmenu = $('<ul></ul>');
var ccount = 0;
for (var zs = 0; zs < items.length; zs++) {
if (items[zs] == "" || items[zs].substring(0,1) != '#') continue;
var foo = items[zs].substring(1);
if (foo.indexOf("|") > -1) {
var splitem = foo.split("|");
$('<li><a href="' + $.wiki.wikiLink(splitem[0], false) + '">' + splitem[1] + '</a></li>').appendTo(cmenu);
} else {
$('<li><a href="' + $.wiki.wikiLink(foo, false) + '">' + foo + '</a></li>').appendTo(cmenu);
}
ccount++;
}
if (ccount > 0) {
$('<li><a href="#">Saját</a></li>').append(cmenu).appendTo(curr);
}
}
});
}
return destid;
} else {
return curr;
}
}
$(function() {
if (wgNamespaceNumber != 0) {
/* Sima cím eltüntetése, ha a menü alatt van helyettesítő */
if (wgAction != "edit" && wgAction != "submit" && $("#header-title").length > 0) {
if (skin != "modern") {
$("#firstHeading").css("display", "none");
$("#siteSub").css("display", "none");
}
if ($("#contentSub").length > 0 && $("#mw-revision-info").length == 0)
$("#contentSub").css("display", "none");
}
/* Gombok */
var bigButtons = $(".bigButton", $($.wiki.contentSelector));
if (bigButtons.length > 0) {
bigButtons.each(function() {
var link = $("a:first", $(this));
if (link.length > 0) {
var curLink = link.attr("href");
link.parent().html(link.html());
$(this).css("cursor", "pointer")
.wrap('<a class="buttonWrapperAnchor" href="' + curLink + '"></a>');
}
});
}
/* Eligazítólapok */
var eliItems = $(".eligazitoLap > .eligazitoElem", $($.wiki.contentSelector));
if (eliItems.length > 0) {
/* IE6 miaza:hover??-bugfix */
if ($.browser.msie && $.browser.version == 6) {
eliItems.hover(
function() {
$(this).addClass("eeHover");
},
function() {
$(this).removeClass("eeHover");
}
);
}
eliItems.each(function() {
var link = $(".eligazitoTovabb > a", $(this));
if (link.length > 0) {
var curLink = link.attr("href");
link.parent().html(link.html());
$(this).css("cursor", "pointer")
.wrap('<a href="' + curLink + '" class="eligazitoWrapLink"></a>');
}
});
}
/* Tabok felépítése */
$(".tabset-tabs", $($.wiki.contentSelector)).each(function() {
var tabul = $("<ul></ul>");
var curid = $(this).attr("id").substring(10);
var tabCount = 0;
$("#" + curid + "-content > div").each(function() {
var cdiv = $(this);
if (cdiv.hasClass("tab-nojs")) cdiv.removeClass("tab-nojs");
if (cdiv.attr("title") != "") {
$("<li></li>").html("<a>" + cdiv.attr("title") + "</a>").appendTo(tabul);
tabCount++;
} else {
cdiv.remove();
}
});
if (tabCount > 0) {
$(this).after(tabul);
tabul.attr("id", curid);
tabul.addClass("tabset-tabs");
tabul.tabs("#" + curid + "-content > div");
tabul.trigger('tabsetReady');
} else {
$("#" + curid + "-content").remove();
}
$(this).remove();
});
/* Menük felépítése */
if (mw.config.get('wikimenu.disabled', false) == false) {
var menuRoots = $(".wikiMenu-rootContainer", $($.wiki.contentSelector));
if (menuRoots.length > 0) {
menuRoots.each(function() {
var destid = generateMenuLayout($(this), 0);
if (jQuery.browser.msie && jQuery.browser.version == 6) {
$("#" + destid).superfish();
} else {
$("#" + destid).supersubs({
minWidth: 12, // minimum width of sub-menus in em units
maxWidth: 27, // maximum width of sub-menus in em units
extraWidth: 2 // extra width can ensure lines don't sometimes turn over
// due to slight rounding differences and font-family
}).superfish();
}
});
}
$(".wikiMenu-container", $($.wiki.contentSelector)).remove();
}
}
});
/* Kapcsolódó lapok */
$j(function() {
$j('.buborekGomb').each(function() {
if (wgNamespaceNumber===0) return;
var $this = $j(this);
var contentDivSelector = '#' + $this.attr('id').replace(/^button-/, '') + '-content';
var contentDiv = $j(contentDivSelector);
var bodySelector = 'body';
if (skin==='monobook') bodySelector = '#globalWrapper';
$j(contentDivSelector).appendTo(bodySelector);
var contentDivWidth = 0;
$j.swap(contentDiv.get(0), {display: 'block'}, function() {
contentDivWidth = $j(this).outerWidth();
});
function reposBuborek() {
var contentDivLeft = $this.offset().left + contentDivWidth > $j(window).width()
? $this.offset().left + $this.outerWidth() - contentDivWidth
: $this.offset().left;
$j(contentDivSelector).css({
position: 'absolute',
top: $this.offset().top + $this.outerHeight(),
left: contentDivLeft
});
}
reposBuborek();
$j(contentDivSelector).find('.buborekTitlebar').prepend(
$j('<div>').addClass('buborekCloseButton')
.html('x')
.click(function() {
$this.removeClass('button-active');
contentDiv.stop().fadeTo(200, 0).removeClass('buborekVisible').hide();
})
);
$this.click(function() {
if(contentDiv.hasClass('buborekVisible')) {
$this.removeClass('button-active');
contentDiv.stop().fadeTo(200, 0).removeClass('buborekVisible').hide();
} else {
reposBuborek();
$this.addClass('button-active');
contentDiv.stop().show().fadeTo(200, 1).addClass('buborekVisible');
}
});
});
});
/*