-// MediaWiki JavaScript support functions
+/**
+ * MediaWiki legacy wikibits
+ */
+( function ( mw ) {
window.clientPC = navigator.userAgent.toLowerCase(); // Get client info
window.is_gecko = /gecko/.test( clientPC ) &&
ie6_bugs = true;
}
-// Global external objects used by this script.
-/*extern ta, stylepath, skin */
-
// add any onload functions in this hook (please don't hard-code any events in the xhtml source)
window.doneOnloadHook = undefined;
};
window.importScript = function( page ) {
- // TODO: might want to introduce a utility function to match wfUrlencode() in PHP
- var uri = wgScript + '?title=' +
- encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') +
+ var uri = mw.config.get( 'wgScript' ) + '?title=' +
+ mw.util.wikiUrlencode( page ) +
'&action=raw&ctype=text/javascript';
return importScriptURI( uri );
};
};
window.importStylesheet = function( page ) {
- return importStylesheetURI( wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent( page.replace(/ /g,'_') ) );
+ return importStylesheetURI( mw.config.get( 'wgScript' ) + '?action=raw&ctype=text/css&title=' + mw.util.wikiUrlencode( page ) );
};
window.importStylesheetURI = function( url, media ) {
};
// Special stylesheet links for Monobook only (see bug 14717)
-if ( typeof stylepath != 'undefined' && skin == 'monobook' ) {
+var skinpath = mw.config.get( 'stylepath' ) + '/' + mw.config.get( 'skin' );
+if ( mw.config.get( 'skin' ) === 'monobook' ) {
if ( opera6_bugs ) {
- importStylesheetURI( stylepath + '/' + skin + '/Opera6Fixes.css' );
+ importStylesheetURI( skinpath + '/Opera6Fixes.css' );
} else if ( opera7_bugs ) {
- importStylesheetURI( stylepath + '/' + skin + '/Opera7Fixes.css' );
+ importStylesheetURI( skinpath + '/Opera7Fixes.css' );
} else if ( opera95_bugs ) {
- importStylesheetURI( stylepath + '/' + skin + '/Opera9Fixes.css' );
+ importStylesheetURI( skinpath + '/Opera9Fixes.css' );
} else if ( ff2_bugs ) {
- importStylesheetURI( stylepath + '/' + skin + '/FF2Fixes.css' );
+ importStylesheetURI( skinpath + '/FF2Fixes.css' );
}
}
-
-if ( 'wgBreakFrames' in window && window.wgBreakFrames ) {
+if ( mw.config.get( 'wgBreakFrames' ) ) {
// Un-trap us from framesets
if ( window.top != window ) {
window.top.location = window.location;
link.setAttribute( 'title', tooltip );
}
if ( accesskey && tooltip ) {
- updateTooltipAccessKeys( new Array( link ) );
+ updateTooltipAccessKeys( [link] );
}
if ( nextnode && nextnode.parentNode == node ) {
return str;
};
-/* Dummy for deprecated function */
-window.ta = [];
-window.akeytt = function( doId ) {
-};
-
window.checkboxes = undefined;
window.lastCheckbox = undefined;
From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
*/
window.getElementsByClassName = function( oElm, strTagName, oClassNames ) {
- var arrReturnElements = new Array();
+ var arrReturnElements = [];
if ( typeof( oElm.getElementsByClassName ) == 'function' ) {
/* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */
var arrNativeReturn = oElm.getElementsByClassName( oClassNames );
return arrReturnElements;
}
var arrElements = ( strTagName == '*' && oElm.all ) ? oElm.all : oElm.getElementsByTagName( strTagName );
- var arrRegExpClassNames = new Array();
+ var arrRegExpClassNames = [];
if( typeof oClassNames == 'object' ) {
for( var i = 0; i < oClassNames.length; i++ ) {
arrRegExpClassNames[arrRegExpClassNames.length] =
* Add a cute little box at the top of the screen to inform the user of
* something, replacing any preexisting message.
*
- * @param message String -or- Dom Object HTML to be put inside the right div
- * @param className String Used in adding a class; should be different for each
- * call to allow CSS/JS to hide different boxes. null = no class used.
- * @return Boolean True on success, false on failure
+ * @deprecated since 1.17 Use mw.util.jsMessage instead.
+ * @param {String|HTMLElement} message To be put inside the message box.
+ * @param {String} className Used in adding a class; Can be used to selectively
+ * apply CSS to a certain category of messages. null = no class used.
+ * @return {Boolean} True on success, false on failure
*/
-window.jsMsg = function( message, className ) {
- if ( !document.getElementById ) {
- return false;
- }
- // We special-case skin structures provided by the software. Skins that
- // choose to abandon or significantly modify our formatting can just define
- // an mw-js-message div to start with.
- var messageDiv = document.getElementById( 'mw-js-message' );
- if ( !messageDiv ) {
- messageDiv = document.createElement( 'div' );
- if ( document.getElementById( 'column-content' )
- && document.getElementById( 'content' ) ) {
- // MonoBook, presumably
- document.getElementById( 'content' ).insertBefore(
- messageDiv,
- document.getElementById( 'content' ).firstChild
- );
- } else if ( document.getElementById( 'content' )
- && document.getElementById( 'article' ) ) {
- // Non-Monobook but still recognizable (old-style)
- document.getElementById( 'article').insertBefore(
- messageDiv,
- document.getElementById( 'article' ).firstChild
- );
- } else {
- return false;
- }
- }
-
- messageDiv.setAttribute( 'id', 'mw-js-message' );
- messageDiv.style.display = 'block';
- if( className ) {
- messageDiv.setAttribute( 'class', 'mw-js-message-' + className );
- }
-
- if ( typeof message === 'object' ) {
- while ( messageDiv.hasChildNodes() ) { // Remove old content
- messageDiv.removeChild( messageDiv.firstChild );
- }
- messageDiv.appendChild( message ); // Append new content
- } else {
- messageDiv.innerHTML = message;
- }
- return true;
+window.jsMsg = function () {
+ return mw.util.jsMessage.apply( mw.util, arguments );
};
/**
window.injectSpinner = function( element, id ) {
var spinner = document.createElement( 'img' );
spinner.id = 'mw-spinner-' + id;
- spinner.src = stylepath + '/common/images/spinner.gif';
+ spinner.src = mw.config.get( 'stylepath' ) + '/common/images/spinner.gif';
spinner.alt = spinner.title = '...';
if( element.nextSibling ) {
element.parentNode.insertBefore( spinner, element.nextSibling );
// might cause the function to terminate prematurely
doneOnloadHook = true;
- updateTooltipAccessKeys( null );
- setupCheckboxShiftClick();
-
// Run any added-on functions
for ( var i = 0; i < onloadFuncts.length; i++ ) {
onloadFuncts[i]();
hookEvent( 'load', runOnloadHook );
if ( ie6_bugs ) {
- importScriptURI( stylepath + '/common/IEFixes.js' );
-}
\ No newline at end of file
+ importScriptURI( mw.config.get( 'stylepath' ) + '/common/IEFixes.js' );
+}
+
+}( mediaWiki ) );