resources/jquery.effects
resources/jquery.tipsy
resources/jquery.ui
-resources/mediawiki.libs/mediawiki.libs.jpegmeta.js
+resources/mediawiki.libs
tests/jasmine/lib/jasmine-1.0.1/jasmine-html.js
tests/jasmine/lib/jasmine-1.0.1/jasmine.js
"jquery": true,
"nomen": true,
- "onevar": false
+ "onevar": true
}
),
'jquery.highlightText' => array(
'scripts' => 'resources/jquery/jquery.highlightText.js',
+ 'dependencies' => 'jquery.mwExtension',
),
'jquery.hoverIntent' => array(
'scripts' => 'resources/jquery/jquery.hoverIntent.js',
'scripts' => 'resources/jquery/jquery.tablesorter.js',
'styles' => 'resources/jquery/jquery.tablesorter.css',
'messages' => array( 'sort-descending', 'sort-ascending' ),
+ 'dependencies' => 'jquery.mwExtension',
),
'jquery.textSelection' => array(
'scripts' => 'resources/jquery/jquery.textSelection.js',
'mediawiki.api.watch',
'mediawiki.util',
'mediawiki.notify',
+ 'jquery.mwExtension',
),
'messages' => array(
'watch',
* </script>
*
*/
-
( function ( $ ) {
$.fn.arrowSteps = function () {
+ var $steps, width, arrowWidth;
this.addClass( 'arrowSteps' );
- var $steps = this.find( 'li' );
+ $steps = this.find( 'li' );
- var width = parseInt( 100 / $steps.length, 10 );
+ width = parseInt( 100 / $steps.length, 10 );
$steps.css( 'width', width + '%' );
// every step except the last one has an arrow at the right hand side. Also add in the padding
// for the calculated arrow width.
- var arrowWidth = parseInt( this.outerHeight(), 10 );
+ arrowWidth = parseInt( this.outerHeight(), 10 );
$steps.filter( ':not(:last-child)' ).addClass( 'arrow' )
.find( 'div' ).css( 'padding-right', arrowWidth.toString() + 'px' );
};
$.fn.arrowStepsHighlight = function ( selector ) {
- var $steps = this.data( 'arrowSteps' );
- var $previous;
+ var $previous,
+ $steps = this.data( 'arrowSteps' );
$.each( $steps, function ( i, step ) {
var $step = $( step );
if ( $step.is( selector ) ) {
*/
( function ( $ ) {
-// Cache ellipsed substrings for every string-width-position combination
-var cache = { };
-// Use a separate cache when match highlighting is enabled
-var matchTextCache = { };
+var
+ // Cache ellipsed substrings for every string-width-position combination
+ cache = { },
+
+ // Use a separate cache when match highlighting is enabled
+ matchTextCache = { };
$.fn.autoEllipsis = function ( options ) {
options = $.extend( {
$(this).each( function () {
var $container, $trimmableText,
text, trimmableText, w, pw,
- l, r, i, side,
+ l, r, i, side, m,
$el = $(this);
if ( options.restoreText ) {
if ( !$el.data( 'autoEllipsis.originalText' ) ) {
l = 0;
r = trimmableText.length;
do {
- var m = Math.ceil( ( l + r ) / 2 );
+ m = Math.ceil( ( l + r ) / 2 );
$trimmableText.text( trimmableText.substr( 0, m ) + '...' );
if ( $trimmableText.width() + pw > w ) {
// Text is too long
* @author Krinkle <krinklemail@gmail.com>
* @license GPL v2
*/
-( function( $ ) {
+( function ( $ ) {
$.fn.checkboxShiftClick = function ( text ) {
- var prevCheckbox = null;
- var $box = this;
+ var prevCheckbox = null, $box = this;
// When our boxes are clicked..
$box.click( function ( e ) {
// And one has been clicked before...
$box.slice(
Math.min( $box.index( prevCheckbox ), $box.index( e.target ) ),
Math.max( $box.index( prevCheckbox ), $box.index( e.target ) ) + 1
- ).prop( 'checked', e.target.checked ? true : false );
+ ).prop( 'checked', !!e.target.checked );
}
// Either way, update the prevCheckbox variable to the one clicked now
prevCheckbox = e.target;
* }
*/
profile: function ( nav ) {
- /*jshint boss:true */
+ /*jshint boss: true */
if ( nav === undefined ) {
nav = window.navigator;
$.fn.expandableField = function () {
// Multi-context fields
- var returnValue;
- var args = arguments;
+ var returnValue,
+ args = arguments;
$( this ).each( function () {
- var key;
+ var key, context;
/* Construction / Loading */
- var context = $( this ).data( 'expandableField-context' );
+ context = $( this ).data( 'expandableField-context' );
// TODO: Do we need to check both null and undefined?
if ( context === undefined || context === null ) {
// Split our pattern string at spaces and run our highlight function on the results
splitAndHighlight: function ( node, pat ) {
- var patArray = pat.split( ' ' );
- for ( var i = 0; i < patArray.length; i++ ) {
+ var i,
+ patArray = pat.split( ' ' );
+ for ( i = 0; i < patArray.length; i++ ) {
if ( patArray[i].length === 0 ) {
continue;
}
// scans a node looking for the pattern and wraps a span around each match
innerHighlight: function ( node, pat ) {
+ var i, match, pos, spannode, middlebit, middleclone;
// if this is a text node
if ( node.nodeType === 3 ) {
// TODO - need to be smarter about the character matching here.
// non latin characters can make regex think a new word has begun: do not use \b
// http://stackoverflow.com/questions/3787072/regex-wordwrap-with-utf8-characters-in-js
// look for an occurrence of our pattern and store the starting position
- var match = node.data.match( new RegExp( "(^|\\s)" + $.escapeRE( pat ), "i" ) );
+ match = node.data.match( new RegExp( "(^|\\s)" + $.escapeRE( pat ), "i" ) );
if ( match ) {
- var pos = match.index + match[1].length; // include length of any matched spaces
+ pos = match.index + match[1].length; // include length of any matched spaces
// create the span wrapper for the matched text
- var spannode = document.createElement( 'span' );
+ spannode = document.createElement( 'span' );
spannode.className = 'highlight';
// shave off the characters preceding the matched text
- var middlebit = node.splitText( pos );
+ middlebit = node.splitText( pos );
// shave off any unmatched text off the end
middlebit.splitText( pat.length );
// clone for appending to our span
- var middleclone = middlebit.cloneNode( true );
+ middleclone = middlebit.cloneNode( true );
// append the matched text node to the span
spannode.appendChild( middleclone );
// replace the matched node, with our span-wrapped clone of the matched node
// if this is an element with childnodes, and not a script, style or an element we created
} else if ( node.nodeType === 1 && node.childNodes && !/(script|style)/i.test( node.tagName )
&& !( node.tagName.toLowerCase() === 'span' && node.className.match( /\bhighlight/ ) ) ) {
- for ( var i = 0; i < node.childNodes.length; ++i ) {
+ for ( i = 0; i < node.childNodes.length; ++i ) {
// call the highlight function for each child node
$.highlightText.innerHighlight( node.childNodes[i], pat );
}
return true;
},
compareObject: function ( objectA, objectB ) {
+ var prop, type;
// Do a simple check if the types match
if ( typeof objectA === typeof objectB ) {
if ( objectA === objectB ) {
return true;
} else {
- var prop;
// Iterate over each property
for ( prop in objectA ) {
// Check if this property is also present in the other object
if ( prop in objectB ) {
// Compare the types of the properties
- var type = typeof objectA[prop];
+ type = typeof objectA[prop];
if ( type === typeof objectB[prop] ) {
// Recursively check objects inside this one
switch ( type ) {
$.fn.placeholder = function () {
return this.each( function () {
+ var placeholder, $input;
// If the HTML5 placeholder attribute is supported, use it
if ( this.placeholder && 'placeholder' in document.createElement( this.tagName ) ) {
return;
}
- var placeholder = this.getAttribute( 'placeholder' );
- var $input = $(this);
+ placeholder = this.getAttribute( 'placeholder' );
+ $input = $(this);
// Show initially, if empty
if ( this.value === '' || this.value === placeholder ) {
* other constructor. Otherwise "missingTests" will include all methods that
* were not called from that instance.
*/
- var CompletenessTest = function ( masterVariable, ignoreFn ) {
+ function CompletenessTest( masterVariable, ignoreFn ) {
// Keep track in these objects. Keyed by strings with the
// method names (ie. 'my.foo', 'my.bar', etc.) values are boolean true.
});
return this;
- };
+ }
/* Static members */
CompletenessTest.ACTION_INJECT = 500;
$.fn.extend({
focus: ( function ( jqFocus ) {
return function () {
+ var $w, state, result;
if ( arguments.length === 0 ) {
- var $w = $( window );
- var state = {top: $w.scrollTop(), left: $w.scrollLeft()};
- var result = jqFocus.apply( this, arguments );
+ $w = $( window );
+ state = {top: $w.scrollTop(), left: $w.scrollLeft()};
+ result = jqFocus.apply( this, arguments );
window.scrollTo( state.top, state.left );
return result;
}
* in some browsers (IE/Opera)
*/
getSelection: function () {
- var e = this.get( 0 );
- var retval = '';
- if ( $(e).is( ':hidden' ) ) {
+ var retval, range,
+ el = this.get( 0 );
+
+ if ( $(el).is( ':hidden' ) ) {
// Do nothing
+ retval = '';
} else if ( document.selection && document.selection.createRange ) {
- activateElementOnIE( e );
- var range = document.selection.createRange();
+ activateElementOnIE( el );
+ range = document.selection.createRange();
retval = range.text;
- } else if ( e.selectionStart || e.selectionStart === 0 ) {
- retval = e.value.substring( e.selectionStart, e.selectionEnd );
+ } else if ( el.selectionStart || el.selectionStart === 0 ) {
+ retval = el.value.substring( el.selectionStart, el.selectionEnd );
}
+
return retval;
},
/**
encapsulateSelection: function ( options ) {
return this.each( function () {
var selText, scrollTop, insertText,
+ isSample, range, range2, range3, startPos, endPos,
pre = options.pre,
post = options.post;
* Wrap each line of the selected text with pre and post
*/
function doSplitLines( selText, pre, post ) {
- var insertText = '';
- var selTextArr = selText.split( '\n' );
- for ( var i = 0; i < selTextArr.length; i++ ) {
+ var i,
+ insertText = '',
+ selTextArr = selText.split( '\n' );
+ for ( i = 0; i < selTextArr.length; i++ ) {
insertText += pre + selTextArr[i] + post;
if ( i !== selTextArr.length - 1 ) {
insertText += '\n';
return insertText;
}
- var isSample = false;
+ isSample = false;
if ( this.style.display === 'none' ) {
// Do nothing
} else if ( document.selection && document.selection.createRange ) {
selText = $(this).textSelection( 'getSelection' );
scrollTop = this.scrollTop;
- var range = document.selection.createRange();
+ range = document.selection.createRange();
checkSelectedText();
insertText = pre + selText + post;
insertText = doSplitLines( selText, pre, post );
}
if ( options.ownline && range.moveStart ) {
- var range2 = document.selection.createRange();
+ range2 = document.selection.createRange();
range2.collapse();
range2.moveStart( 'character', -1 );
// FIXME: Which check is correct?
insertText = "\n" + insertText;
pre += "\n";
}
- var range3 = document.selection.createRange();
+ range3 = document.selection.createRange();
range3.collapse( false );
range3.moveEnd( 'character', 1 );
if ( range3.text !== "\r" && range3.text !== "\n" && range3.text !== "" ) {
}
selText = $(this).textSelection( 'getSelection' );
- var startPos = this.selectionStart;
- var endPos = this.selectionEnd;
+ startPos = this.selectionStart;
+ endPos = this.selectionEnd;
scrollTop = this.scrollTop;
checkSelectedText();
if ( options.selectionStart !== undefined
// whatever we do later (bug 31847).
activateElementOnIE( e );
- // IE Support
- var preFinished = false;
- var periFinished = false;
- var postFinished = false;
- var preText, rawPreText, periText;
- var rawPeriText, postText, rawPostText;
- // Create range containing text in the selection
- var periRange = document.selection.createRange().duplicate();
- // Create range containing text before the selection
- var preRange = rangeForElementIE( e );
+ var
+ preText, rawPreText, periText,
+ rawPeriText, postText, rawPostText,
+
+ // IE Support
+ preFinished = false,
+ periFinished = false,
+ postFinished = false,
+ // Range containing text in the selection
+ periRange = document.selection.createRange().duplicate(),
+ // Range containing text before the selection
+ preRange,
+ // Range containing text after the selection
+ postRange;
+
+ preRange = rangeForElementIE( e ),
// Move the end where we need it
preRange.setEndPoint( 'EndToStart', periRange );
- // Create range containing text after the selection
- var postRange = rangeForElementIE( e );
+
+ postRange = rangeForElementIE( e );
// Move the start where we need it
postRange.setEndPoint( 'StartToEnd', periRange );
+
// Load the text values we need to compare
preText = rawPreText = preRange.text;
periText = rawPeriText = periRange.text;
postText = rawPostText = postRange.text;
+
/*
* Check each range for trimmed newlines by shrinking the range by 1
* character and seeing if the text property has changed. If it has
*/
setSelection: function ( options ) {
return this.each( function () {
+ var selection, length, newLines;
if ( $(this).is( ':hidden' ) ) {
// Do nothing
} else if ( this.selectionStart || this.selectionStart === 0 ) {
this.selectionEnd = options.end;
}
} else if ( document.body.createTextRange ) {
- var selection = rangeForElementIE( this );
- var length = this.value.length;
+ selection = rangeForElementIE( this );
+ length = this.value.length;
// IE doesn't count \n when computing the offset, so we won't either
- var newLines = this.value.match( /\n/g );
+ newLines = this.value.match( /\n/g );
if ( newLines ) {
length = length - newLines.length;
}
// Silence that error
try {
selection.select();
- } catch( e ) { }
+ } catch ( e ) { }
}
});
},
return ( $.client.profile().platform === 'mac' ? 13 : ( $.client.profile().platform === 'linux' ? 15 : 16 ) ) * row;
}
return this.each(function () {
+ var scroll, range, savedRange, pos, oldScrollTop;
if ( $(this).is( ':hidden' ) ) {
// Do nothing
} else if ( this.selectionStart || this.selectionStart === 0 ) {
// Mozilla
- var scroll = getCaretScrollPosition( this );
+ scroll = getCaretScrollPosition( this );
if ( options.force || scroll < $(this).scrollTop() ||
scroll > $(this).scrollTop() + $(this).height() ) {
$(this).scrollTop( scroll );
* cover that case, we'll force it to act by moving one
* character back and forth.
*/
- var range = document.body.createTextRange();
- var savedRange = document.selection.createRange();
- var pos = $(this).textSelection( 'getCaretPosition' );
- var oldScrollTop = this.scrollTop;
+ range = document.body.createTextRange();
+ savedRange = document.selection.createRange();
+ pos = $(this).textSelection( 'getCaretPosition' );
+ oldScrollTop = this.scrollTop;
range.moveToElementText( this );
range.collapse();
range.move( 'character', pos + 1);
/**
* Additional mw.Api methods to assist with API calls related to categories.
*/
-
-( function( $, mw, undefined ) {
+( function ( mw, $ ) {
$.extend( mw.Api.prototype, {
/**
* @param err {Function} optional callback to run if api error
* @return ajax call object
*/
- isCategory: function( title, success, err ) {
- var params = {
- prop: 'categoryinfo',
- titles: title.toString()
- },
- ok = function( data ) {
- var exists = false;
- if ( data.query && data.query.pages ) {
- $.each( data.query.pages, function( id, page ) {
- if ( page.categoryinfo ) {
- exists = true;
- }
- } );
- }
- success( exists );
- };
+ isCategory: function ( title, success, err ) {
+ var params, ok;
+ params = {
+ prop: 'categoryinfo',
+ titles: title.toString()
+ };
+ ok = function ( data ) {
+ var exists = false;
+ if ( data.query && data.query.pages ) {
+ $.each( data.query.pages, function ( id, page ) {
+ if ( page.categoryinfo ) {
+ exists = true;
+ }
+ } );
+ }
+ success( exists );
+ };
return this.get( params, { ok: ok, err: err } );
},
* @param err {Function} optional callback to run if api error
* @return {jqXHR}
*/
- getCategoriesByPrefix: function( prefix, success, err ) {
-
- // fetch with allpages to only get categories that have a corresponding description page.
- var params = {
+ getCategoriesByPrefix: function ( prefix, success, err ) {
+ // Fetch with allpages to only get categories that have a corresponding description page.
+ var params, ok;
+ params = {
'list': 'allpages',
'apprefix': prefix,
'apnamespace': mw.config.get('wgNamespaceIds').category
};
-
- var ok = function( data ) {
+ ok = function ( data ) {
var texts = [];
if ( data.query && data.query.allpages ) {
- $.each( data.query.allpages, function( i, category ) {
+ $.each( data.query.allpages, function ( i, category ) {
texts.push( new mw.Title( category.title ).getNameText() );
} );
}
* @param async {Boolean} optional asynchronousness (default = true = async)
* @return {jqXHR}
*/
- getCategories: function( title, success, err, async ) {
+ getCategories: function ( title, success, err, async ) {
var params, ok;
params = {
prop: 'categories',
if ( async === undefined ) {
async = true;
}
- ok = function( data ) {
+ ok = function ( data ) {
var ret = false;
if ( data.query && data.query.pages ) {
- $.each( data.query.pages, function( id, page ) {
+ $.each( data.query.pages, function ( id, page ) {
if ( page.categories ) {
if ( typeof ret !== 'object' ) {
ret = [];
}
- $.each( page.categories, function( i, cat ) {
+ $.each( page.categories, function ( i, cat ) {
ret.push( new mw.Title( cat.title ) );
} );
}
} );
-} )( jQuery, mediaWiki );
+}( mediaWiki, jQuery ) );
/**
* Additional mw.Api methods to assist with API calls related to editing wiki pages.
*/
-
-( function( $, mw, undefined ) {
+( function ( mw, $ ) {
// Cache token so we don't have to keep fetching new ones for every single request.
var cachedToken = null;
* @param err {Function} [optional] error callback
* @return {jqXHR}
*/
- postWithEditToken: function( params, ok, err ) {
- var api = this, useTokenToPost, getTokenIfBad;
+ postWithEditToken: function ( params, ok, err ) {
+ var useTokenToPost, getTokenIfBad,
+ api = this;
if ( cachedToken === null ) {
// We don't have a valid cached token, so get a fresh one and try posting.
// We do not trap any 'badtoken' or 'notoken' errors, because we don't want
// an infinite loop. If this fresh token is bad, something else is very wrong.
- useTokenToPost = function( token ) {
+ useTokenToPost = function ( token ) {
params.token = token;
api.post( params, ok, err );
};
// We do have a token, but it might be expired. So if it is 'bad' then
// start over with a new token.
params.token = cachedToken;
- getTokenIfBad = function( code, result ) {
+ getTokenIfBad = function ( code, result ) {
if ( code === 'badtoken' ) {
- cachedToken = null; // force a new token
+ // force a new token, clear any old one
+ cachedToken = null;
api.postWithEditToken( params, ok, err );
} else {
err( code, result );
* @param err {Function} error callback
* @return {jqXHR}
*/
- getEditToken: function( tokenCallback, err ) {
+ getEditToken: function ( tokenCallback, err ) {
var parameters = {
action: 'tokens',
type: 'edit'
},
- ok = function( data ) {
+ ok = function ( data ) {
var token;
// If token type is not available for this user,
// key 'edittoken' is missing or can contain Boolean false
* @param err {Function} error handler
* @return {jqXHR}
*/
- newSection: function( title, header, message, ok, err ) {
+ newSection: function ( title, header, message, ok, err ) {
var params = {
action: 'edit',
section: 'new',
} );
-} )( jQuery, mediaWiki );
+}( mediaWiki, jQuery ) );
/**
* mw.Api objects represent the API of a particular MediaWiki server.
*/
-( function( $, mw, undefined ) {
+( function ( mw, $ ) {
/**
* @var defaultOptions {Object}
* @param options {Object} See defaultOptions documentation above. Ajax options can also be
* overridden for each individual request to jQuery.ajax() later on.
*/
- mw.Api = function( options ) {
+ mw.Api = function ( options ) {
if ( options === undefined ) {
options = {};
* @param {Object|Function} [optional] ajax options
* @return {jQuery.Promise}
*/
- get: function( parameters, ajaxOptions ) {
+ get: function ( parameters, ajaxOptions ) {
ajaxOptions = this.normalizeAjaxOptions( ajaxOptions );
ajaxOptions.type = 'GET';
return this.ajax( parameters, ajaxOptions );
* @param {Object|Function} [optional] ajax options
* @return {jQuery.Promise}
*/
- post: function( parameters, ajaxOptions ) {
+ post: function ( parameters, ajaxOptions ) {
ajaxOptions = this.normalizeAjaxOptions( ajaxOptions );
ajaxOptions.type = 'POST';
return this.ajax( parameters, ajaxOptions );
* - done: API response data as first argument
* - fail: errorcode as first arg, details (string or object) as second arg.
*/
- ajax: function( parameters, ajaxOptions ) {
+ ajax: function ( parameters, ajaxOptions ) {
var token,
apiDeferred = $.Deferred();
'exists'
];
-})( jQuery, mediaWiki );
+}( mediaWiki, jQuery ) );
* @param err {Function} [optional] deprecated (error callback)
* @return {jQuery.Promise}
*/
- parse: function( wikiText, ok, err ) {
+ parse: function ( wikiText, ok, err ) {
var apiDeferred = $.Deferred();
// Backwards compatibility (< MW 1.20)
}
} );
-} )( mediaWiki, jQuery );
+}( mediaWiki, jQuery ) );
* Additional mw.Api methods to assist with API calls to the API module of the TitleBlacklist extension.
*/
-( function( $, mw, undefined ) {
+( function ( mw, $ ) {
$.extend( mw.Api.prototype, {
/**
* @param err {Function} optional callback to run if api error
* @return {jqXHR}
*/
- isBlacklisted: function( title, success, err ) {
+ isBlacklisted: function ( title, success, err ) {
var params = {
action: 'titleblacklist',
tbaction: 'create',
tbtitle: title.toString()
},
- ok = function( data ) {
+ ok = function ( data ) {
var result;
// this fails open (if nothing valid is returned by the api, allows the title)
}
} );
-} )( jQuery, mediaWiki );
+
+}( mediaWiki, jQuery ) );
* Additional mw.Api methods to assist with (un)watching wiki pages.
* @since 1.19
*/
-( function( $, mw ) {
+( function ( mw, $ ) {
/**
* @context {mw.Api}
} );
-} )( jQuery, mediaWiki );
+}( mediaWiki, jQuery ) );
}
var
+ /**
+ * Public methods (defined later)
+ */
+ fn,
+
/**
* Strip some illegal chars: control chars, colon, less than, greater than,
* brackets, braces, pipe, whitespace and normal spaces. This still leaves some insanity
/* Public methods */
- var fn = {
+ fn = {
constructor: Title,
/**
* Constructs the HTML for the debugging toolbar
*/
buildHtml: function () {
- var $container, $bits, panes, id;
+ var $container, $bits, panes, id, gitInfo;
$container = $( '<div id="mw-debug-toolbar" class="mw-debug"></div>' );
* @return {jQuery}
*/
function bitDiv( id ) {
- return $( '<div>' ).attr({
+ return $( '<div>' ).prop({
id: 'mw-debug-' + id,
- 'class': 'mw-debug-bit'
+ className: 'mw-debug-bit'
})
.appendTo( $bits );
}
*/
function paneLabel( id, text ) {
return $( '<a>' )
- .attr({
- 'class': 'mw-debug-panelabel',
+ .prop({
+ className: 'mw-debug-panelabel',
href: '#mw-debug-pane-' + id
})
.text( text );
* @return {jQuery}
*/
function paneTriggerBitDiv( id, text, count ) {
- if( count ) {
+ if ( count ) {
text = text + ' (' + count + ')';
}
- return $( '<div>' ).attr({
+ return $( '<div>' ).prop({
id: 'mw-debug-' + id,
- 'class': 'mw-debug-bit mw-debug-panelink'
+ className: 'mw-debug-bit mw-debug-panelink'
})
.append( paneLabel( id, text ) )
.appendTo( $bits );
paneTriggerBitDiv( 'includes', 'PHP includes', this.data.includes.length );
- var gitInfo = '';
+ gitInfo = '';
if ( this.data.gitRevision !== false ) {
gitInfo = '(' + this.data.gitRevision.substring( 0, 7 ) + ')';
if ( this.data.gitViewUrl !== false ) {
- gitInfo = $( '<a>' ).attr( 'href', this.data.gitViewUrl ).text( gitInfo );
+ gitInfo = $( '<a>' )
+ .attr( 'href', this.data.gitViewUrl )
+ .text( gitInfo );
}
}
bitDiv( 'mwversion' )
- .append( $( '<a href="//www.mediawiki.org/"></a>' ).text( 'MediaWiki' ) )
- .append( ': ' + this.data.mwVersion + ' ' )
+ .append( $( '<a href="//www.mediawiki.org/">MediaWiki</a>' ) )
+ .append( document.createTextNode( ': ' + this.data.mwVersion + ' ' ) )
.append( gitInfo );
if ( this.data.gitBranch !== false ) {
}
$( '<div>' )
- .attr({
- 'class': 'mw-debug-pane',
+ .prop({
+ className: 'mw-debug-pane',
id: 'mw-debug-pane-' + id
})
.append( panes[id] )
$table = $( '<table id="mw-debug-console">' );
- $('<colgroup>').css( 'width', /*padding=*/20 + ( 10 * /*fontSize*/11 ) ).appendTo( $table );
- $('<colgroup>').appendTo( $table );
- $('<colgroup>').css( 'width', 350 ).appendTo( $table );
+ $( '<colgroup>' ).css( 'width', /* padding = */ 20 + ( 10 * /* fontSize = */ 11 ) ).appendTo( $table );
+ $( '<colgroup>' ).appendTo( $table );
+ $( '<colgroup>' ).css( 'width', 350 ).appendTo( $table );
entryTypeText = function( entryType ) {
$( '<tr>' )
.append( $( '<td>' )
.text( entry.typeText )
- .attr( 'class', 'mw-debug-console-' + entry.type )
+ .addClass( 'mw-debug-console-' + entry.type )
)
.append( $( '<td>' ).html( entry.msg ) )
.append( $( '<td>' ).text( entry.caller ) )
$table = $( '<table id="mw-debug-querylist"></table>' );
$( '<tr>' )
- .append( $('<th>#</th>').css( 'width', '4em' ) )
- .append( $('<th>SQL</th>') )
- .append( $('<th>Time</th>').css( 'width', '8em' ) )
- .append( $('<th>Call</th>').css( 'width', '18em' ) )
+ .append( $( '<th>#</th>' ).css( 'width', '4em' ) )
+ .append( $( '<th>SQL</th>' ) )
+ .append( $( '<th>Time</th>' ).css( 'width', '8em' ) )
+ .append( $( '<th>Call</th>' ).css( 'width', '18em' ) )
.appendTo( $table );
for ( i = 0, length = this.data.queries.length; i < length; i += 1 ) {
for ( i = 0, length = this.data.debugLog.length; i < length; i += 1 ) {
line = this.data.debugLog[i];
$( '<li>' )
- .html( mw.html.escape( line ).replace( /\n/g, "<br />\n" ) )
+ .html( mw.html.escape( line ).replace( /\n/g, '<br />\n' ) )
.appendTo( $list );
}
// If there is no console, use our own log box
mw.loader.using( 'jquery.footHovzer', function () {
- var d = new Date(),
+ var hovzer,
+ d = new Date(),
// Create HH:MM:SS.MIL timestamp
time = ( d.getHours() < 10 ? '0' + d.getHours() : d.getHours() ) +
':' + ( d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes() ) +
backgroundColor: 'white',
borderTop: 'solid 2px #ADADAD'
} );
- var hovzer = $.getFootHovzer();
+ hovzer = $.getFootHovzer();
hovzer.$.append( $log );
hovzer.update();
}
* User object
*/
function User( options, tokens ) {
+ var user, callbacks;
/* Private Members */
- var that = this;
- var callbacks = {};
+ user = this;
+ callbacks = {};
/**
* Gets the current user's groups or rights.
* @return String: Random set of 32 alpha-numeric characters
*/
function generateId() {
- var id = '';
- var seed = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
- for ( var i = 0, r; i < 32; i++ ) {
+ var i, r,
+ id = '',
+ seed = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
+ for ( i = 0; i < 32; i++ ) {
r = Math.floor( Math.random() * seed.length );
id += seed.substring( r, r + 1 );
}
* @return Boolean
*/
this.isAnon = function () {
- return that.getName() === null;
+ return user.getName() === null;
};
/**
* @deprecated since 1.20 use mw.user.isAnon() instead
*/
this.anonymous = function () {
- return that.isAnon();
+ return user.isAnon();
};
/**
* @return String: User name or random session ID
*/
this.id = function() {
- var name = that.getName();
+ var id,
+ name = user.getName();
if ( name ) {
return name;
}
- var id = $.cookie( 'mediaWiki.user.id' );
+ id = $.cookie( 'mediaWiki.user.id' );
if ( typeof id === 'undefined' || id === null ) {
id = generateId();
}
* } );
*/
this.bucket = function ( key, options ) {
+ var cookie, parts, version, bucket,
+ range, k, rand, total;
+
options = $.extend( {
- 'buckets': {},
- 'version': 0,
- 'tracked': false,
- 'expires': 30
+ buckets: {},
+ version: 0,
+ tracked: false,
+ expires: 30
}, options || {} );
- var cookie = $.cookie( 'mediaWiki.user.bucket:' + key );
- var bucket = null;
- var version = 0;
+
+ cookie = $.cookie( 'mediaWiki.user.bucket:' + key );
+
// Bucket information is stored as 2 integers, together as version:bucket like: "1:2"
if ( typeof cookie === 'string' && cookie.length > 2 && cookie.indexOf( ':' ) > 0 ) {
- var parts = cookie.split( ':' );
+ parts = cookie.split( ':' );
if ( parts.length > 1 && Number( parts[0] ) === options.version ) {
version = Number( parts[0] );
bucket = String( parts[1] );
}
}
- if ( bucket === null ) {
+ if ( bucket === undefined ) {
if ( !$.isPlainObject( options.buckets ) ) {
throw 'Invalid buckets error. Object expected for options.buckets.';
}
version = Number( options.version );
// Find range
- var range = 0, k;
+ range = 0;
for ( k in options.buckets ) {
range += options.buckets[k];
}
// Select random value within range
- var rand = Math.random() * range;
+ rand = Math.random() * range;
// Determine which bucket the value landed in
- var total = 0;
+ total = 0;
for ( k in options.buckets ) {
bucket = k;
total += options.buckets[k];