MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

/* Extension:Gadgets */ //syntax highlighter mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript'); /* Edittop */ if ($.inArray( mw.config.get('wgAction'), [ 'view', 'purge' ]) !== -1 && mw.config.get( 'wgNamespaceNumber' ) >=0) { $(function edittop_hook {    var localtitles = {      bn: 'সূচনা অনুচ্ছেদ সম্পাদনা করুন',      cs: 'Editovat úvodní sekci',      en: 'Edit lead section',      fa: 'ویرایش بخش آغازین',      fr: 'Modifier le résumé introductif',      id: 'Sunting bagian atas',      it: 'Modifica della sezione iniziale',      ja: '導入部を編集',      min: 'Suntiang bagian ateh',      ko: '도입부를 편집',      pa: 'ਸੋਧ',      pt: 'Editar a seção superior',      'pt-br': 'Editar a seção superior',      sr: 'Уреди уводни део',      vi: 'Sửa phần mở đầu'    };

var our_content = $("#content, #mw_content").first; var span1 = our_content.find("span.mw-editsection:not(.plainlinks)").first; if (!span1.length) { return; }   var span0 = span1.clone;

if ( mw.user.options.get( 'gadget-righteditlinks' ) == 1 ) { var editwidth = span1.outerWidth + (mw.config.get("skin") == "monobook" ? 10 : 0); $("div.topicon, #mw-fr-revisiontag").css("margin-right", editwidth + "px"); }   $("#mw_header h1, #content h1").first.append(span0); span0.find("a").each(function (idx) {     var a = $(this);      a.attr("title", localtitles[mw.config.get( 'wgUserLanguage' )] || localtitles.en);      if (a.attr("href").indexOf("&section=T") == -1) {        a.attr("href", a.attr("href").replace(/&section=\d+/, "&section=0&summary=/*%20top%20*/%20"));      }      else { //transcluded        a.attr("href", mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + "?action=edit&section=0&summary=/*%20top%20*/%20");      }    }); }); }

/* Hot-cat */ mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );

/* ImageMapEdit */ mw.loader.load('//he.wikipedia.org/w/index.php?title=Mediawiki:Gadget-ime.js&action=raw&ctype=text/javascript');

//******************************************************************************** // Start "Articletype positioning" script; by User:Bp - Installed for test by plkrtn 3/2/10 - Testing by Pyramidhead //******************************************************************************** function moveArticletypeDiv { var fooel = document.getElementById('lp-article-type'); if (fooel!=null) { var artel = document.getElementById('article'); var titel = document.getElementById('top'); fooel = fooel.parentNode.removeChild(fooel); if (artel!=null) { artel.parentNode.insertBefore(fooel,artel); } else { //fall back to a position before H1 - useful for monobook skin titel.parentNode.insertBefore(fooel,titel); } } } hookEvent("load", moveArticletypeDiv); // End "Articletype positioning" script /* 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);   }; });

// Scroll to an anchor ID defined in element "data-scroll-to". // Used in conjunction with collapse buttons on long tables/sections. $('[data-scroll-to]').click(function{   var target = $(this).data('scroll-to');  $('html, body').animate({ scrollTop: $(target).offset.top -80 }, 500); });

// Infobox toggle $('+/-').appendTo(     $('.infobox-ep tr.header').filter(function{ return $(this).attr('class').split(" ").length > 1 }).find("th")    );

$(".infobox-ep tr.header").each(function{     var $this = $(this);

if( $this.hasClass("hidden") ){ var firstclass = $this.attr("class").split(" ")[0]; $this.siblings("." + firstclass).addClass("hidden"); }  });

$('a.infoboxtoggle').click (     function (infoboxtoggle)      {        var parent  = $(this).parent ;        var grandparent  = parent.parent ;        var firstclass  = grandparent.attr ('class').split(" ")[0];

infoboxtoggle.preventDefault; grandparent.siblings ('.' + firstclass).has ('td').toggleClass ('hidden'); }   );