-window.changeText = function( el, newText ) {
- // Safari work around
- if ( el.innerText ) {
- el.innerText = newText;
- } else if ( el.firstChild && el.firstChild.nodeValue ) {
- el.firstChild.nodeValue = newText;
- }
-};
-
-window.killEvt = function( evt ) {
- evt = evt || window.event || window.Event; // W3C, IE, Netscape
- if ( typeof evt.preventDefault !== 'undefined' ) {
- evt.preventDefault(); // Don't follow the link
- evt.stopPropagation();
- } else {
- evt.cancelBubble = true; // IE
- }
- return false; // Don't follow the link (IE)
-};
-
-window.mwEditButtons = [];
-window.mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js
-
-window.escapeQuotes = function( text ) {
- var re = new RegExp( "'", "g" );
- text = text.replace( re, "\\'" );
- re = new RegExp( "\\n", "g" );
- text = text.replace( re, "\\n" );
- return window.escapeQuotesHTML( text );
-};
-
-window.escapeQuotesHTML = function( text ) {
- var re = new RegExp( '&', "g" );
- text = text.replace( re, "&" );
- re = new RegExp( '"', "g" );
- text = text.replace( re, """ );
- re = new RegExp( '<', "g" );
- text = text.replace( re, "<" );
- re = new RegExp( '>', "g" );
- text = text.replace( re, ">" );
- return text;
-};
-
-/**
- * Accesskey prefix utilities.
- * To be removed in MediaWiki 1.23.
- *
- * @deprecated since 1.17 Use mediawiki.util instead.
- */
-mw.log.deprecate( window, 'tooltipAccessKeyPrefix', 'alt-', 'Use mediawiki.util instead.' );
-mw.log.deprecate( window, 'tooltipAccessKeyRegexp', /\[(alt-)?(.)\]$/, 'Use mediawiki.util instead.' );
-mw.log.deprecate( window, 'updateTooltipAccessKeys', mw.util.updateTooltipAccessKeys, 'Use mediawiki.util instead.' );
-
-/**
- * Add a link to one of the portlet menus on the page, including:
- *
- * p-cactions: Content actions (shown as tabs above the main content in Monobook)
- * p-personal: Personal tools (shown at the top right of the page in Monobook)
- * p-navigation: Navigation
- * p-tb: Toolbox
- *
- * This function exists for the convenience of custom JS authors. All
- * but the first three parameters are optional, though providing at
- * least an id and a tooltip is recommended.
- *
- * By default the new link will be added to the end of the list. To
- * add the link before a given existing item, pass the DOM node of
- * that item (easily obtained with document.getElementById()) as the
- * nextnode parameter; to add the link _after_ an existing item, pass
- * the node's nextSibling instead.
- *
- * @param portlet String id of the target portlet ("p-cactions", "p-personal", "p-navigation" or "p-tb")
- * @param href String link URL
- * @param text String link text (will be automatically lowercased by CSS for p-cactions in Monobook)
- * @param id String id of the new item, should be unique and preferably have the appropriate prefix ("ca-", "pt-", "n-" or "t-")
- * @param tooltip String text to show when hovering over the link, without accesskey suffix
- * @param accesskey String accesskey to activate this link (one character, try to avoid conflicts)
- * @param nextnode Node the DOM node before which the new item should be added, should be another item in the same list
- *
- * @return Node -- the DOM node of the new item (an LI element) or null
- */
-window.addPortletLink = function( portlet, href, text, id, tooltip, accesskey, nextnode ) {
- var root = document.getElementById( portlet );
- if ( !root ) {
- return null;
- }
- var uls = root.getElementsByTagName( 'ul' );
- var node;
- if ( uls.length > 0 ) {
- node = uls[0];
- } else {
- node = document.createElement( 'ul' );
- var lastElementChild = null;
- for ( var i = 0; i < root.childNodes.length; ++i ) { /* get root.lastElementChild */
- if ( root.childNodes[i].nodeType === 1 ) {
- lastElementChild = root.childNodes[i];
- }
- }
- if ( lastElementChild && lastElementChild.nodeName.match( /div/i ) ) {
- /* Insert into the menu divs */
- lastElementChild.appendChild( node );
- } else {
- root.appendChild( node );
- }
- }
- if ( !node ) {
- return null;
- }
-
- // unhide portlet if it was hidden before
- root.className = root.className.replace( /(^| )emptyPortlet( |$)/, "$2" );
-
- var link = document.createElement( 'a' );
- link.appendChild( document.createTextNode( text ) );
- link.href = href;
-
- // Wrap in a span - make it work with vector tabs and has no effect on any other portlets
- var span = document.createElement( 'span' );
- span.appendChild( link );
-
- var item = document.createElement( 'li' );
- item.appendChild( span );
- if ( id ) {
- item.id = id;
- }
-
- if ( accesskey ) {
- link.setAttribute( 'accesskey', accesskey );
- tooltip += ' [' + accesskey + ']';
- }
- if ( tooltip ) {
- link.setAttribute( 'title', tooltip );
- }
- if ( accesskey && tooltip ) {
- mw.util.updateTooltipAccessKeys( [link] );
- }
-
- if ( nextnode && nextnode.parentNode === node ) {
- node.insertBefore( item, nextnode );
- } else {
- node.appendChild( item ); // IE compatibility (?)
- }
-
- return item;
-};
-
-window.getInnerText = function( el ) {
- if ( typeof el === 'string' ) {
- return el;
- }
- if ( typeof el === 'undefined' ) {
- return el;
- }
- // Custom sort value through 'data-sort-value' attribute
- // (no need to prepend hidden text to change sort value)
- if ( el.nodeType && el.getAttribute( 'data-sort-value' ) !== null ) {
- // Make sure it's a valid DOM element (.nodeType) and that the attribute is set (!null)
- return el.getAttribute( 'data-sort-value' );
- }
- if ( el.textContent ) {
- return el.textContent; // not needed but it is faster
- }
- if ( el.innerText ) {
- return el.innerText; // IE doesn't have textContent
- }
- var str = '';
-
- var cs = el.childNodes;
- var l = cs.length;
- for ( var i = 0; i < l; i++ ) {
- switch ( cs[i].nodeType ) {
- case 1: // ELEMENT_NODE
- str += window.getInnerText( cs[i] );
- break;
- case 3: // TEXT_NODE
- str += cs[i].nodeValue;
- break;
- }
- }
- return str;
-};
-
-/**
- * Toggle checkboxes with shift selection.
- * To be removed in MediaWiki 1.23.
- *
- * @deprecated since 1.17 Use jquery.checkboxShiftClick instead.
- */
-$.each({
- checkboxes: [],
- lastCheckbox: null,
- setupCheckboxShiftClick: $.noop,
- addCheckboxClickHandlers: $.noop,
- checkboxClickHandler: $.noop
-}, function ( key, val ) {
- mw.log.deprecate( window, key, val, 'Use jquery.checkboxShiftClick instead.' );
-} );
-
-/*
- Written by Jonathan Snook, http://www.snook.ca/jonathan
- Add-ons by Robert Nyman, http://www.robertnyman.com
- Author says "The credit comment is all it takes, no license. Go crazy with it!:-)"
- From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
-*/
-window.getElementsByClassName = function( oElm, strTagName, oClassNames ) {
- var arrReturnElements = [];
- if ( typeof oElm.getElementsByClassName === 'function' ) {
- /* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */
- var arrNativeReturn = oElm.getElementsByClassName( oClassNames );
- if ( strTagName === '*' ) {
- return arrNativeReturn;
- }
- for ( var h = 0; h < arrNativeReturn.length; h++ ) {
- if( arrNativeReturn[h].tagName.toLowerCase() === strTagName.toLowerCase() ) {
- arrReturnElements[arrReturnElements.length] = arrNativeReturn[h];
- }
- }
- return arrReturnElements;
- }
- var arrElements = ( strTagName === '*' && oElm.all ) ? oElm.all : oElm.getElementsByTagName( strTagName );
- var arrRegExpClassNames = [];
- if( typeof oClassNames === 'object' ) {
- for( var i = 0; i < oClassNames.length; i++ ) {
- arrRegExpClassNames[arrRegExpClassNames.length] =
- new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)");
- }
- } else {
- arrRegExpClassNames[arrRegExpClassNames.length] =
- new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)");
- }
- var oElement;
- var bMatchesAll;
- for( var j = 0; j < arrElements.length; j++ ) {
- oElement = arrElements[j];
- bMatchesAll = true;
- for( var k = 0; k < arrRegExpClassNames.length; k++ ) {
- if( !arrRegExpClassNames[k].test( oElement.className ) ) {
- bMatchesAll = false;
- break;
- }
- }
- if( bMatchesAll ) {
- arrReturnElements[arrReturnElements.length] = oElement;
- }
- }
- return ( arrReturnElements );
-};
-
-window.redirectToFragment = function( fragment ) {