"preset": "wikimedia",
"disallowQuotedKeysInObjects": null,
- "requireSpacesInsideArrayBrackets": null,
"requireVarDeclFirst": null,
- "requireSpacesInsideBrackets": null,
"jsDoc": null,
"requireDotNotation": { "allExcept": [ "keywords" ] },
wgScriptPath = process.env.MW_SCRIPT_PATH,
karmaProxy = {};
- karmaProxy[wgScriptPath] = wgServer + wgScriptPath;
+ karmaProxy[ wgScriptPath ] = wgServer + wgScriptPath;
grunt.initConfig( {
jshint: {
return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH );
} );
- grunt.registerTask( 'lint', ['jshint', 'jscs', 'jsonlint', 'banana'] );
+ grunt.registerTask( 'lint', [ 'jshint', 'jscs', 'jsonlint', 'banana' ] );
grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
- grunt.registerTask( 'test', ['lint'] );
+ grunt.registerTask( 'test', [ 'lint' ] );
grunt.registerTask( 'default', 'test' );
};
if ( id ) {
$label = $( 'label[for="' + id + '"]' );
if ( $label.length === 1 ) {
- updateTooltipOnElement( element, $label[0] );
+ updateTooltipOnElement( element, $label[ 0 ] );
}
}
// Search it as parent, because the form control can also be inside the label element itself
$labelParent = $element.parents( 'label' );
if ( $labelParent.length === 1 ) {
- updateTooltipOnElement( element, $labelParent[0] );
+ updateTooltipOnElement( element, $labelParent[ 0 ] );
}
}
}
// Try cache
if ( options.matchText ) {
if ( !( text in matchTextCache ) ) {
- matchTextCache[text] = {};
+ matchTextCache[ text ] = {};
}
- if ( !( options.matchText in matchTextCache[text] ) ) {
- matchTextCache[text][options.matchText] = {};
+ if ( !( options.matchText in matchTextCache[ text ] ) ) {
+ matchTextCache[ text ][ options.matchText ] = {};
}
- if ( !( w in matchTextCache[text][options.matchText] ) ) {
- matchTextCache[text][options.matchText][w] = {};
+ if ( !( w in matchTextCache[ text ][ options.matchText ] ) ) {
+ matchTextCache[ text ][ options.matchText ][ w ] = {};
}
- if ( options.position in matchTextCache[text][options.matchText][w] ) {
- $container.html( matchTextCache[text][options.matchText][w][options.position] );
+ if ( options.position in matchTextCache[ text ][ options.matchText ][ w ] ) {
+ $container.html( matchTextCache[ text ][ options.matchText ][ w ][ options.position ] );
if ( options.tooltip ) {
$container.attr( 'title', text );
}
}
} else {
if ( !( text in cache ) ) {
- cache[text] = {};
+ cache[ text ] = {};
}
- if ( !( w in cache[text] ) ) {
- cache[text][w] = {};
+ if ( !( w in cache[ text ] ) ) {
+ cache[ text ][ w ] = {};
}
- if ( options.position in cache[text][w] ) {
- $container.html( cache[text][w][options.position] );
+ if ( options.position in cache[ text ][ w ] ) {
+ $container.html( cache[ text ][ w ][ options.position ] );
if ( options.tooltip ) {
$container.attr( 'title', text );
}
break;
case 'center':
// TODO: Use binary search like for 'right'
- i = [Math.round( trimmableText.length / 2 ), Math.round( trimmableText.length / 2 )];
+ i = [ Math.round( trimmableText.length / 2 ), Math.round( trimmableText.length / 2 ) ];
// Begin with making the end shorter
side = 1;
- while ( $trimmableText.outerWidth() + pw > w && i[0] > 0 ) {
- $trimmableText.text( trimmableText.slice( 0, i[0] ) + '...' + trimmableText.slice( i[1] ) );
+ while ( $trimmableText.outerWidth() + pw > w && i[ 0 ] > 0 ) {
+ $trimmableText.text( trimmableText.slice( 0, i[ 0 ] ) + '...' + trimmableText.slice( i[ 1 ] ) );
// Alternate between trimming the end and begining
if ( side === 0 ) {
// Make the begining shorter
- i[0]--;
+ i[ 0 ]--;
side = 1;
} else {
// Make the end shorter
- i[1]++;
+ i[ 1 ]++;
side = 0;
}
}
}
if ( options.matchText ) {
$container.highlightText( options.matchText );
- matchTextCache[text][options.matchText][w][options.position] = $container.html();
+ matchTextCache[ text ][ options.matchText ][ w ][ options.position ] = $container.html();
} else {
- cache[text][w][options.position] = $container.html();
+ cache[ text ][ w ][ options.position ] = $container.html();
}
} );
// until the limit is statisfied.
if ( fn ) {
// stop, when there is nothing to slice - bug 41450
- while ( $.byteLength( fn( inpParts.join( '' ) ) ) > byteLimit && inpParts[1].length > 0 ) {
- inpParts[1] = inpParts[1].slice( 0, -1 );
+ while ( $.byteLength( fn( inpParts.join( '' ) ) ) > byteLimit && inpParts[ 1 ].length > 0 ) {
+ inpParts[ 1 ] = inpParts[ 1 ].slice( 0, -1 );
}
} else {
while ( $.byteLength( inpParts.join( '' ) ) > byteLimit ) {
- inpParts[1] = inpParts[1].slice( 0, -1 );
+ inpParts[ 1 ] = inpParts[ 1 ].slice( 0, -1 );
}
}
'color',
'outlineColor'
], function ( i, attr ) {
- $.fx.step[attr] = function ( fx ) {
+ $.fx.step[ attr ] = function ( fx ) {
if ( !fx.colorInit ) {
fx.start = getColor( fx.elem, attr );
fx.end = $.colorUtil.getRGB( fx.end );
fx.colorInit = true;
}
- fx.elem.style[attr] = 'rgb(' + [
- Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[0] - fx.start[0] ) ) + fx.start[0], 10 ), 255 ), 0 ),
- Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[1] - fx.start[1] ) ) + fx.start[1], 10 ), 255 ), 0 ),
- Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[2] - fx.start[2] ) ) + fx.start[2], 10 ), 255 ), 0 )
+ fx.elem.style[ attr ] = 'rgb(' + [
+ Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[ 0 ] - fx.start[ 0 ] ) ) + fx.start[ 0 ], 10 ), 255 ), 0 ),
+ Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[ 1 ] - fx.start[ 1 ] ) ) + fx.start[ 1 ], 10 ), 255 ), 0 ),
+ Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[ 2 ] - fx.start[ 2 ] ) ) + fx.start[ 2 ], 10 ), 255 ), 0 )
].join( ',' ) + ')';
};
} );
// Look for rgb(num,num,num)
if ( result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec( color ) ) {
return [
- parseInt( result[1], 10 ),
- parseInt( result[2], 10 ),
- parseInt( result[3], 10 )
+ parseInt( result[ 1 ], 10 ),
+ parseInt( result[ 2 ], 10 ),
+ parseInt( result[ 3 ], 10 )
];
}
// Look for rgb(num%,num%,num%)
if ( result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec( color ) ) {
return [
- parseFloat( result[1] ) * 2.55,
- parseFloat( result[2] ) * 2.55,
- parseFloat( result[3] ) * 2.55
+ parseFloat( result[ 1 ] ) * 2.55,
+ parseFloat( result[ 2 ] ) * 2.55,
+ parseFloat( result[ 3 ] ) * 2.55
];
}
// Look for #a0b1c2
if ( result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec( color ) ) {
return [
- parseInt( result[1], 16 ),
- parseInt( result[2], 16 ),
- parseInt( result[3], 16 )
+ parseInt( result[ 1 ], 16 ),
+ parseInt( result[ 2 ], 16 ),
+ parseInt( result[ 3 ], 16 )
];
}
// Look for #fff
if ( result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec( color ) ) {
return [
- parseInt( result[1] + result[1], 16 ),
- parseInt( result[2] + result[2], 16 ),
- parseInt( result[3] + result[3], 16 )
+ parseInt( result[ 1 ] + result[ 1 ], 16 ),
+ parseInt( result[ 2 ] + result[ 2 ], 16 ),
+ parseInt( result[ 3 ] + result[ 3 ], 16 )
];
}
}
// Otherwise, we're most likely dealing with a named color
- return $.colorUtil.colors[$.trim( color ).toLowerCase()];
+ return $.colorUtil.colors[ $.trim( color ).toLowerCase() ];
},
/**
* @property {Object}
*/
colors: {
- aqua: [0, 255, 255],
- azure: [240, 255, 255],
- beige: [245, 245, 220],
- black: [0, 0, 0],
- blue: [0, 0, 255],
- brown: [165, 42, 42],
- cyan: [0, 255, 255],
- darkblue: [0, 0, 139],
- darkcyan: [0, 139, 139],
- darkgrey: [169, 169, 169],
- darkgreen: [0, 100, 0],
- darkkhaki: [189, 183, 107],
- darkmagenta: [139, 0, 139],
- darkolivegreen: [85, 107, 47],
- darkorange: [255, 140, 0],
- darkorchid: [153, 50, 204],
- darkred: [139, 0, 0],
- darksalmon: [233, 150, 122],
- darkviolet: [148, 0, 211],
- fuchsia: [255, 0, 255],
- gold: [255, 215, 0],
- green: [0, 128, 0],
- indigo: [75, 0, 130],
- khaki: [240, 230, 140],
- lightblue: [173, 216, 230],
- lightcyan: [224, 255, 255],
- lightgreen: [144, 238, 144],
- lightgrey: [211, 211, 211],
- lightpink: [255, 182, 193],
- lightyellow: [255, 255, 224],
- lime: [0, 255, 0],
- magenta: [255, 0, 255],
- maroon: [128, 0, 0],
- navy: [0, 0, 128],
- olive: [128, 128, 0],
- orange: [255, 165, 0],
- pink: [255, 192, 203],
- purple: [128, 0, 128],
- violet: [128, 0, 128],
- red: [255, 0, 0],
- silver: [192, 192, 192],
- white: [255, 255, 255],
- yellow: [255, 255, 0],
- transparent: [255, 255, 255]
+ aqua: [ 0, 255, 255 ],
+ azure: [ 240, 255, 255 ],
+ beige: [ 245, 245, 220 ],
+ black: [ 0, 0, 0 ],
+ blue: [ 0, 0, 255 ],
+ brown: [ 165, 42, 42 ],
+ cyan: [ 0, 255, 255 ],
+ darkblue: [ 0, 0, 139 ],
+ darkcyan: [ 0, 139, 139 ],
+ darkgrey: [ 169, 169, 169 ],
+ darkgreen: [ 0, 100, 0 ],
+ darkkhaki: [ 189, 183, 107 ],
+ darkmagenta: [ 139, 0, 139 ],
+ darkolivegreen: [ 85, 107, 47 ],
+ darkorange: [ 255, 140, 0 ],
+ darkorchid: [ 153, 50, 204 ],
+ darkred: [ 139, 0, 0 ],
+ darksalmon: [ 233, 150, 122 ],
+ darkviolet: [ 148, 0, 211 ],
+ fuchsia: [ 255, 0, 255 ],
+ gold: [ 255, 215, 0 ],
+ green: [ 0, 128, 0 ],
+ indigo: [ 75, 0, 130 ],
+ khaki: [ 240, 230, 140 ],
+ lightblue: [ 173, 216, 230 ],
+ lightcyan: [ 224, 255, 255 ],
+ lightgreen: [ 144, 238, 144 ],
+ lightgrey: [ 211, 211, 211 ],
+ lightpink: [ 255, 182, 193 ],
+ lightyellow: [ 255, 255, 224 ],
+ lime: [ 0, 255, 0 ],
+ magenta: [ 255, 0, 255 ],
+ maroon: [ 128, 0, 0 ],
+ navy: [ 0, 0, 128 ],
+ olive: [ 128, 128, 0 ],
+ orange: [ 255, 165, 0 ],
+ pink: [ 255, 192, 203 ],
+ purple: [ 128, 0, 128 ],
+ violet: [ 128, 0, 128 ],
+ red: [ 255, 0, 0 ],
+ silver: [ 192, 192, 192 ],
+ white: [ 255, 255, 255 ],
+ yellow: [ 255, 255, 0 ],
+ transparent: [ 255, 255, 255 ]
},
/**
h /= 6;
}
- return [h, s, l];
+ return [ h, s, l ];
},
/**
b = hue2rgb( p, q, h - 1 / 3 );
}
- return [r * 255, g * 255, b * 255];
+ return [ r * 255, g * 255, b * 255 ];
},
/**
*/
getColorBrightness: function ( currentColor, mod ) {
var rgbArr = $.colorUtil.getRGB( currentColor ),
- hslArr = $.colorUtil.rgbToHsl( rgbArr[0], rgbArr[1], rgbArr[2] );
- rgbArr = $.colorUtil.hslToRgb( hslArr[0], hslArr[1], hslArr[2] + mod );
+ hslArr = $.colorUtil.rgbToHsl( rgbArr[ 0 ], rgbArr[ 1 ], rgbArr[ 2 ] );
+ rgbArr = $.colorUtil.hslToRgb( hslArr[ 0 ], hslArr[ 1 ], hslArr[ 2 ] + mod );
return 'rgb(' +
- [parseInt( rgbArr[0], 10 ), parseInt( rgbArr[1], 10 ), parseInt( rgbArr[2], 10 )].join( ',' ) +
+ [ parseInt( rgbArr[ 0 ], 10 ), parseInt( rgbArr[ 1 ], 10 ), parseInt( rgbArr[ 2 ], 10 ) ].join( ',' ) +
')';
}
*/
configure: function ( context, property, value ) {
// TODO: Validate creation using fallback values
- context.config[property] = value;
+ context.config[ property ] = value;
}
};
/* API */
// Handle various calling styles
if ( args.length > 0 ) {
- if ( typeof args[0] === 'object' ) {
+ if ( typeof args[ 0 ] === 'object' ) {
// Apply set of properties
- for ( key in args[0] ) {
- $.expandableField.configure( context, key, args[0][key] );
+ for ( key in args[ 0 ] ) {
+ $.expandableField.configure( context, key, args[ 0 ][ key ] );
}
- } else if ( typeof args[0] === 'string' ) {
+ } else if ( typeof args[ 0 ] === 'string' ) {
if ( args.length > 1 ) {
// Set property values
- $.expandableField.configure( context, args[0], args[1] );
+ $.expandableField.configure( context, args[ 0 ], args[ 1 ] );
// TODO: Do we need to check both null and undefined?
} else if ( returnValue === null || returnValue === undefined ) {
// Get property values, but don't give access to internal data - returns only the first
- returnValue = ( args[0] in context.config ? undefined : context.config[args[0]] );
+ returnValue = ( args[ 0 ] in context.config ? undefined : context.config[ args[ 0 ] ] );
}
}
}
len = controls.length;
for ( i = 0; i < len; i++ ) {
- data[ controls[i].name ] = controls[i].value;
+ data[ controls[ i ].name ] = controls[ i ].value;
}
return data;
* @return {Object}
*/
jQuery.fn.getAttrs = function () {
- return serializeControls( this[0].attributes );
+ return serializeControls( this[ 0 ].attributes );
};
/**
selectedSrc = null;
candidates = srcset.split( / *, */ );
for ( i = 0; i < candidates.length; i++ ) {
- candidate = candidates[i];
+ candidate = candidates[ i ];
bits = candidate.split( / +/ );
- src = bits[0];
- if ( bits.length > 1 && bits[1].charAt( bits[1].length - 1 ) === 'x' ) {
- ratioStr = bits[1].slice( 0, -1 );
+ src = bits[ 0 ];
+ if ( bits.length > 1 && bits[ 1 ].charAt( bits[ 1 ].length - 1 ) === 'x' ) {
+ ratioStr = bits[ 1 ].slice( 0, -1 );
ratio = parseFloat( ratioStr );
if ( ratio <= devicePixelRatio && ratio > selectedRatio ) {
selectedRatio = ratio;
var i,
patArray = pat.split( ' ' );
for ( i = 0; i < patArray.length; i++ ) {
- if ( patArray[i].length === 0 ) {
+ if ( patArray[ i ].length === 0 ) {
continue;
}
- $.highlightText.innerHighlight( node, patArray[i] );
+ $.highlightText.innerHighlight( node, patArray[ i ] );
}
return node;
},
// look for an occurrence of our pattern and store the starting position
match = node.data.match( new RegExp( '(^|\\s)' + mw.RegExp.escape( pat ), 'i' ) );
if ( match ) {
- 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
spannode = document.createElement( 'span' );
spannode.className = 'highlight';
) {
for ( i = 0; i < node.childNodes.length; ++i ) {
// call the highlight function for each child node
- $.highlightText.innerHighlight( node.childNodes[i], pat );
+ $.highlightText.innerHighlight( node.childNodes[ i ], pat );
}
}
}
* @return {string} Localized message
*/
function msg( options, key ) {
- var args = options.params[key] || [];
+ var args = options.params[ key ] || [];
// Format: mw.msg( key [, p1, p2, ...] )
- args.unshift( options.prefix + ( options.keys[key] || key ) );
+ args.unshift( options.prefix + ( options.keys[ key ] || key ) );
return mw.msg.apply( mw, args );
}
*/
$.fn.localize = function ( options ) {
var $target = this,
- attributes = ['title', 'alt', 'placeholder'];
+ attributes = [ 'title', 'alt', 'placeholder' ];
// Extend options
options = $.extend( {
return false;
}
for ( var i = 0; i < arrThis.length; i++ ) {
- if ( $.isArray( arrThis[i] ) ) {
- if ( !$.compareArray( arrThis[i], arrAgainst[i] ) ) {
+ if ( $.isArray( arrThis[ i ] ) ) {
+ if ( !$.compareArray( arrThis[ i ], arrAgainst[ i ] ) ) {
return false;
}
- } else if ( arrThis[i] !== arrAgainst[i] ) {
+ } else if ( arrThis[ i ] !== arrAgainst[ i ] ) {
return false;
}
}
// Check if this property is also present in the other object
if ( prop in objectB ) {
// Compare the types of the properties
- type = typeof objectA[prop];
- if ( type === typeof objectB[prop] ) {
+ type = typeof objectA[ prop ];
+ if ( type === typeof objectB[ prop ] ) {
// Recursively check objects inside this one
switch ( type ) {
case 'object' :
- if ( !$.compareObject( objectA[prop], objectB[prop] ) ) {
+ if ( !$.compareObject( objectA[ prop ], objectB[ prop ] ) ) {
return false;
}
break;
case 'function' :
// Functions need to be strings to compare them properly
- if ( objectA[prop].toString() !== objectB[prop].toString() ) {
+ if ( objectA[ prop ].toString() !== objectB[ prop ].toString() ) {
return false;
}
break;
default:
// Strings, numbers
- if ( objectA[prop] !== objectB[prop] ) {
+ if ( objectA[ prop ] !== objectB[ prop ] ) {
return false;
}
break;
rinlinejQuery = /^jQuery\d+$/;
$.each( elem.attributes, function ( i, attr ) {
if ( attr.specified && !rinlinejQuery.test( attr.name ) ) {
- newAttrs[attr.name] = attr.value;
+ newAttrs[ attr.name ] = attr.value;
}
} );
return newAttrs;
$input = $input.hide().next().show().attr( 'id', $input.removeAttr( 'id' ).data( 'placeholder-id' ) );
// If `clearPlaceholder` was called from `$.valHooks.input.set`
if ( event === true ) {
- $input[0].value = value;
+ $input[ 0 ].value = value;
return value;
}
$input.focus();
// Note: `$input[0] != input` now!
}
$input.addClass( 'placeholder' );
- $input[0].value = $input.attr( 'placeholder' );
+ $input[ 0 ].value = $input.attr( 'placeholder' );
} else {
$input.removeClass( 'placeholder' );
}
if ( $input.attr( 'placeholder' ) !== text ) {
$input.prop( 'placeholder', text );
if ( $input.hasClass( 'placeholder' ) ) {
- $input[0].value = text;
+ $input[ 0 ].value = text;
}
}
}
var $element = $( element ),
$passwordInput = $element.data( 'placeholder-password' );
if ( $passwordInput ) {
- return $passwordInput[0].value;
+ return $passwordInput[ 0 ].value;
}
return $element.data( 'placeholder-enabled' ) && $element.hasClass( 'placeholder' ) ? '' : element.value;
var $element = $( element ),
$passwordInput = $element.data( 'placeholder-password' );
if ( $passwordInput ) {
- $passwordInput[0].value = value;
+ $passwordInput[ 0 ].value = value;
return value;
}
elOutputWrapper.appendChild( elContainer );
util.each( style, function ( key, value ) {
- elOutputWrapper.style[key] = value;
+ elOutputWrapper.style[ key ] = value;
} );
return elOutputWrapper;
}
if ( currName ) {
currPathArray.push( currName );
- currVal = currObj[currName];
+ currVal = currObj[ currName ];
} else {
currName = '(root)';
currVal = currObj;
*/
hasTest: function ( fnName ) {
if ( !( fnName in this.methodCallTracker ) ) {
- this.missingTests[fnName] = true;
+ this.missingTests[ fnName ] = true;
return false;
}
return true;
case 'update':
case '$region':
case 'expandFrom':
- context.config[property] = value;
+ context.config[ property ] = value;
break;
case 'suggestions':
- context.config[property] = value;
+ context.config[ property ] = value;
// Update suggestions
if ( context.data !== undefined ) {
if ( context.data.$textbox.val().length === 0 ) {
expandFrom = 'left';
// Catch invalid values, default to 'auto'
- } else if ( $.inArray( expandFrom, ['left', 'right', 'start', 'end', 'auto'] ) === -1 ) {
+ } else if ( $.inArray( expandFrom, [ 'left', 'right', 'start', 'end', 'auto' ] ) === -1 ) {
expandFrom = 'auto';
}
expWidth = -1;
for ( i = 0; i < context.config.suggestions.length; i++ ) {
/*jshint loopfunc:true */
- text = context.config.suggestions[i];
+ text = context.config.suggestions[ i ];
$result = $( '<div>' )
.addClass( 'suggestions-result' )
.attr( 'rel', i )
- .data( 'text', context.config.suggestions[i] )
+ .data( 'text', context.config.suggestions[ i ] )
.mousemove( function () {
context.data.selectedWithMouse = true;
$.suggestions.highlight(
.appendTo( $results );
// Allow custom rendering
if ( typeof context.config.result.render === 'function' ) {
- context.config.result.render.call( $result, context.config.suggestions[i], context );
+ context.config.result.render.call( $result, context.config.suggestions[ i ], context );
} else {
$result.text( text );
}
}
break;
case 'maxRows':
- context.config[property] = Math.max( 1, Math.min( 100, value ) );
+ context.config[ property ] = Math.max( 1, Math.min( 100, value ) );
break;
case 'delay':
- context.config[property] = Math.max( 0, Math.min( 1200, value ) );
+ context.config[ property ] = Math.max( 0, Math.min( 1200, value ) );
break;
case 'cacheMaxAge':
- context.config[property] = Math.max( 1, value );
+ context.config[ property ] = Math.max( 1, value );
break;
case 'maxExpandFactor':
- context.config[property] = Math.max( 1, value );
+ context.config[ property ] = Math.max( 1, value );
break;
case 'cache':
case 'submitOnClick':
case 'positionFromLeft':
case 'highlightInput':
- context.config[property] = !!value;
+ context.config[ property ] = !!value;
break;
}
},
// Handle various calling styles
if ( args.length > 0 ) {
- if ( typeof args[0] === 'object' ) {
+ if ( typeof args[ 0 ] === 'object' ) {
// Apply set of properties
- for ( key in args[0] ) {
- $.suggestions.configure( context, key, args[0][key] );
+ for ( key in args[ 0 ] ) {
+ $.suggestions.configure( context, key, args[ 0 ][ key ] );
}
- } else if ( typeof args[0] === 'string' ) {
+ } else if ( typeof args[ 0 ] === 'string' ) {
if ( args.length > 1 ) {
// Set property values
- $.suggestions.configure( context, args[0], args[1] );
+ $.suggestions.configure( context, args[ 0 ], args[ 1 ] );
} else if ( returnValue === null || returnValue === undefined ) {
// Get property values, but don't give access to internal data - returns only the first
- returnValue = ( args[0] in context.config ? undefined : context.config[args[0]] );
+ returnValue = ( args[ 0 ] in context.config ? undefined : context.config[ args[ 0 ] ] );
}
}
}
var i,
len = parsers.length;
for ( i = 0; i < len; i++ ) {
- if ( parsers[i].id.toLowerCase() === name.toLowerCase() ) {
- return parsers[i];
+ if ( parsers[ i ].id.toLowerCase() === name.toLowerCase() ) {
+ return parsers[ i ];
}
}
return false;
needed = ( rows.length > 4 ) ? 5 : rows.length;
while ( i < l ) {
- if ( rows[rowIndex] && rows[rowIndex].cells[cellIndex] ) {
- nodeValue = $.trim( getElementSortKey( rows[rowIndex].cells[cellIndex] ) );
+ if ( rows[ rowIndex ] && rows[ rowIndex ].cells[ cellIndex ] ) {
+ nodeValue = $.trim( getElementSortKey( rows[ rowIndex ].cells[ cellIndex ] ) );
} else {
nodeValue = '';
}
if ( nodeValue !== '' ) {
- if ( parsers[i].is( nodeValue, table ) ) {
+ if ( parsers[ i ].is( nodeValue, table ) ) {
concurrent++;
rowIndex++;
if ( concurrent >= needed ) {
// Confirmed the parser for multiple cells, let's return it
- return parsers[i];
+ return parsers[ i ];
}
} else {
// Check next parser, reset rows
}
// 0 is always the generic parser (text)
- return parsers[0];
+ return parsers[ 0 ];
}
function buildParserCache( table, $headers ) {
var sortType, cells, len, i, parser,
- rows = table.tBodies[0].rows,
+ rows = table.tBodies[ 0 ].rows,
parsers = [];
- if ( rows[0] ) {
+ if ( rows[ 0 ] ) {
- cells = rows[0].cells;
+ cells = rows[ 0 ].cells;
len = cells.length;
for ( i = 0; i < len; i++ ) {
function buildCache( table ) {
var i, j, $row, cols,
- totalRows = ( table.tBodies[0] && table.tBodies[0].rows.length ) || 0,
- totalCells = ( table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length ) || 0,
+ totalRows = ( table.tBodies[ 0 ] && table.tBodies[ 0 ].rows.length ) || 0,
+ totalCells = ( table.tBodies[ 0 ].rows[ 0 ] && table.tBodies[ 0 ].rows[ 0 ].cells.length ) || 0,
config = $( table ).data( 'tablesorter' ).config,
parsers = config.parsers,
cache = {
for ( i = 0; i < totalRows; ++i ) {
// Add the table data to main data array
- $row = $( table.tBodies[0].rows[i] );
+ $row = $( table.tBodies[ 0 ].rows[ i ] );
cols = [];
// if this is a child row, add it to the last row's children and
// continue to the next row
if ( $row.hasClass( config.cssChildRow ) ) {
- cache.row[cache.row.length - 1] = cache.row[cache.row.length - 1].add( $row );
+ cache.row[ cache.row.length - 1 ] = cache.row[ cache.row.length - 1 ].add( $row );
// go to the next for loop
continue;
}
cache.row.push( $row );
for ( j = 0; j < totalCells; ++j ) {
- cols.push( parsers[j].format( getElementSortKey( $row[0].cells[j] ), table, $row[0].cells[j] ) );
+ cols.push( parsers[ j ].format( getElementSortKey( $row[ 0 ].cells[ j ] ), table, $row[ 0 ].cells[ j ] ) );
}
cols.push( cache.normalized.length ); // add position for rowCache
row = cache.row,
normalized = cache.normalized,
totalRows = normalized.length,
- checkCell = ( normalized[0].length - 1 ),
+ checkCell = ( normalized[ 0 ].length - 1 ),
fragment = document.createDocumentFragment();
for ( i = 0; i < totalRows; i++ ) {
- pos = normalized[i][checkCell];
+ pos = normalized[ i ][ checkCell ];
- l = row[pos].length;
+ l = row[ pos ].length;
for ( j = 0; j < l; j++ ) {
- fragment.appendChild( row[pos][j] );
+ fragment.appendChild( row[ pos ][ j ] );
}
}
- table.tBodies[0].appendChild( fragment );
+ table.tBodies[ 0 ].appendChild( fragment );
$( table ).trigger( 'sortEnd.tablesorter' );
}
$tfoot = $( '<tfoot>' );
len = $rows.length;
for ( i = len - 1; i >= 0; i-- ) {
- if ( $( $rows[i] ).children( 'td' ).length ) {
+ if ( $( $rows[ i ] ).children( 'td' ).length ) {
break;
}
- $tfoot.prepend( $( $rows[i] ) );
+ $tfoot.prepend( $( $rows[ i ] ) );
}
$table.append( $tfoot );
}
colspan = Number( cell.colSpan );
// Skip the spots in the exploded matrix that are already filled
- while ( exploded[rowIndex] && exploded[rowIndex][columnIndex] !== undefined ) {
+ while ( exploded[ rowIndex ] && exploded[ rowIndex ][ columnIndex ] !== undefined ) {
++columnIndex;
}
// in the exploded matrix rowspan times colspan times, with the proper offsets
for ( matrixColumnIndex = columnIndex; matrixColumnIndex < columnIndex + colspan; ++matrixColumnIndex ) {
for ( matrixRowIndex = rowIndex; matrixRowIndex < rowIndex + rowspan; ++matrixRowIndex ) {
- if ( !exploded[matrixRowIndex] ) {
- exploded[matrixRowIndex] = [];
+ if ( !exploded[ matrixRowIndex ] ) {
+ exploded[ matrixRowIndex ] = [];
}
- exploded[matrixRowIndex][matrixColumnIndex] = cell;
+ exploded[ matrixRowIndex ][ matrixColumnIndex ] = cell;
}
}
} );
}
} );
// We cannot use $.unique() here because it sorts into dom order, which is undesirable
- $tableHeaders = $( uniqueElements( exploded[longestTR] ) ).filter( 'th' );
+ $tableHeaders = $( uniqueElements( exploded[ longestTR ] ) ).filter( 'th' );
}
// as each header can span over multiple columns (using colspan=N),
.prop( 'tabIndex', 0 )
.attr( {
role: 'columnheader button',
- title: msg[1]
+ title: msg[ 1 ]
} );
}
// add cell to headerList
- config.headerList[headerIndex] = this;
+ config.headerList[ headerIndex ] = this;
} );
return $tableHeaders;
var i,
len = a.length;
for ( i = 0; i < len; i++ ) {
- if ( a[i][0] === v ) {
+ if ( a[ i ][ 0 ] === v ) {
return true;
}
}
$.each( headerToColumns, function ( headerIndex, columns ) {
$.each( columns, function ( i, columnIndex ) {
- var header = $headers[headerIndex],
+ var header = $headers[ headerIndex ],
$header = $( header );
if ( !isValueInArray( columnIndex, sortList ) ) {
} else {
// Column shall be sorted: Apply designated count and order.
$.each( sortList, function ( j, sortColumn ) {
- if ( sortColumn[0] === i ) {
+ if ( sortColumn[ 0 ] === i ) {
$header.data( {
- order: sortColumn[1],
- count: sortColumn[1] + 1
+ order: sortColumn[ 1 ],
+ count: sortColumn[ 1 ] + 1
} );
return false;
}
function setHeadersCss( table, $headers, list, css, msg, columnToHeader ) {
// Remove all header information and reset titles to default message
- $headers.removeClass( css[0] ).removeClass( css[1] ).attr( 'title', msg[1] );
+ $headers.removeClass( css[ 0 ] ).removeClass( css[ 1 ] ).attr( 'title', msg[ 1 ] );
for ( var i = 0; i < list.length; i++ ) {
- $headers.eq( columnToHeader[ list[i][0] ] )
- .addClass( css[ list[i][1] ] )
- .attr( 'title', msg[ list[i][1] ] );
+ $headers.eq( columnToHeader[ list[ i ][ 0 ] ] )
+ .addClass( css[ list[ i ][ 1 ] ] )
+ .attr( 'title', msg[ list[ i ][ 1 ] ] );
}
}
sortFn = [],
len = sortList.length;
for ( i = 0; i < len; i++ ) {
- sortFn[i] = ( sortList[i][1] ) ? sortTextDesc : sortText;
+ sortFn[ i ] = ( sortList[ i ][ 1 ] ) ? sortTextDesc : sortText;
}
cache.normalized.sort( function ( array1, array2 ) {
var i, col, ret;
for ( i = 0; i < len; i++ ) {
- col = sortList[i][0];
- ret = sortFn[i].call( this, array1[col], array2[col] );
+ col = sortList[ i ][ 0 ];
+ ret = sortFn[ i ].call( this, array1[ col ], array2[ col ] );
if ( ret !== 0 ) {
return ret;
}
}
// Fall back to index number column to ensure stable sort
- return sortText.call( this, array1[array1.length - 1], array2[array2.length - 1] );
+ return sortText.call( this, array1[ array1.length - 1 ], array2[ array2.length - 1 ] );
} );
return cache;
}
separatorTransformTable = mw.config.get( 'wgSeparatorTransformTable' ),
digitTransformTable = mw.config.get( 'wgDigitTransformTable' );
- if ( separatorTransformTable === null || ( separatorTransformTable[0] === '' && digitTransformTable[2] === '' ) ) {
+ if ( separatorTransformTable === null || ( separatorTransformTable[ 0 ] === '' && digitTransformTable[ 2 ] === '' ) ) {
ts.transformTable = false;
} else {
ts.transformTable = {};
// Unpack the transform table
- ascii = separatorTransformTable[0].split( '\t' ).concat( digitTransformTable[0].split( '\t' ) );
- localised = separatorTransformTable[1].split( '\t' ).concat( digitTransformTable[1].split( '\t' ) );
+ ascii = separatorTransformTable[ 0 ].split( '\t' ).concat( digitTransformTable[ 0 ].split( '\t' ) );
+ localised = separatorTransformTable[ 1 ].split( '\t' ).concat( digitTransformTable[ 1 ].split( '\t' ) );
// Construct regex for number identification
for ( i = 0; i < ascii.length; i++ ) {
- ts.transformTable[localised[i]] = ascii[i];
- digits.push( mw.RegExp.escape( localised[i] ) );
+ ts.transformTable[ localised[ i ] ] = ascii[ i ];
+ digits.push( mw.RegExp.escape( localised[ i ] ) );
}
}
digitClass = '[' + digits.join( '', digits ) + ']';
ts.monthNames = {};
for ( i = 0; i < 12; i++ ) {
- name = mw.language.months.names[i].toLowerCase();
- ts.monthNames[name] = i + 1;
+ name = mw.language.months.names[ i ].toLowerCase();
+ ts.monthNames[ name ] = i + 1;
regex.push( mw.RegExp.escape( name ) );
- name = mw.language.months.genitive[i].toLowerCase();
- ts.monthNames[name] = i + 1;
+ name = mw.language.months.genitive[ i ].toLowerCase();
+ ts.monthNames[ name ] = i + 1;
regex.push( mw.RegExp.escape( name ) );
- name = mw.language.months.abbrev[i].toLowerCase().replace( '.', '' );
- ts.monthNames[name] = i + 1;
+ name = mw.language.months.abbrev[ i ].toLowerCase().replace( '.', '' );
+ ts.monthNames[ name ] = i + 1;
regex.push( mw.RegExp.escape( name ) );
}
// Build RegEx
// Any date formated with . , ' - or /
- ts.dateRegex[0] = new RegExp( /^\s*(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{2,4})\s*?/i );
+ ts.dateRegex[ 0 ] = new RegExp( /^\s*(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{2,4})\s*?/i );
// Written Month name, dmy
- ts.dateRegex[1] = new RegExp( '^\\s*(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' );
+ ts.dateRegex[ 1 ] = new RegExp( '^\\s*(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' );
// Written Month name, mdy
- ts.dateRegex[2] = new RegExp( '^\\s*(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' );
+ ts.dateRegex[ 2 ] = new RegExp( '^\\s*(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' );
}
col = 0,
l = this.cells.length;
for ( i = 0; i < l; i++ ) {
- $( this.cells[i] ).data( 'tablesorter', {
+ $( this.cells[ i ] ).data( 'tablesorter', {
realCellIndex: col,
realRowIndex: this.rowIndex
} );
- col += this.cells[i].colSpan;
+ col += this.cells[ i ].colSpan;
}
} );
}
while ( rowspanCells.length ) {
- if ( $.data( rowspanCells[0], 'tablesorter' ).needResort ) {
+ if ( $.data( rowspanCells[ 0 ], 'tablesorter' ).needResort ) {
resortCells();
}
cell.rowSpan = 1;
$nextRows = $( cell ).parent().nextAll();
for ( i = 0; i < rowSpan - 1; i++ ) {
- $tds = $( $nextRows[i].cells ).filter( filterfunc );
+ $tds = $( $nextRows[ i ].cells ).filter( filterfunc );
$clone = $( cell ).clone();
$clone.data( 'tablesorter', {
realCellIndex: spanningRealCellIndex,
$.each( sortObjects, function ( i, sortObject ) {
$.each( sortObject, function ( columnIndex, order ) {
var orderIndex = ( order === 'desc' ) ? 1 : 0;
- sortList.push( [parseInt( columnIndex, 10 ), orderIndex] );
+ sortList.push( [ parseInt( columnIndex, 10 ), orderIndex ] );
} );
} );
return sortList;
// cells get event .change() and bubbles up to the <table> here
cache = buildCache( table );
- totalRows = ( $table[0].tBodies[0] && $table[0].tBodies[0].rows.length ) || 0;
+ totalRows = ( $table[ 0 ].tBodies[ 0 ] && $table[ 0 ].tBodies[ 0 ].rows.length ) || 0;
if ( !table.sortDisabled && totalRows > 0 ) {
cell = this;
$cell = $( cell );
columns = config.headerToColumns[ $cell.data( 'headerIndex' ) ];
newSortList = $.map( columns, function ( c ) {
// jQuery "helpfully" flattens the arrays...
- return [[c, $cell.data( 'order' )]];
+ return [ [ c, $cell.data( 'order' ) ] ];
} );
// Index of first column belonging to this header
- i = columns[0];
+ i = columns[ 0 ];
- if ( !e[config.sortMultiSortKey] ) {
+ if ( !e[ config.sortMultiSortKey ] ) {
// User only wants to sort on one column set
// Flush the sort list and add new columns
config.sortList = newSortList;
// The user has clicked on an already sorted column.
// Reverse the sorting direction for all tables.
for ( j = 0; j < config.sortList.length; j++ ) {
- s = config.sortList[j];
- o = config.headerList[s[0]];
- if ( isValueInArray( s[0], newSortList ) ) {
- $( o ).data( 'count', s[1] + 1 );
- s[1] = $( o ).data( 'count' ) % 2;
+ s = config.sortList[ j ];
+ o = config.headerList[ s[ 0 ] ];
+ if ( isValueInArray( s[ 0 ], newSortList ) ) {
+ $( o ).data( 'count', s[ 1 ] + 1 );
+ s[ 1 ] = $( o ).data( 'count' ) % 2;
}
}
} else {
setHeadersOrder( $headers, config.sortList, config.headerToColumns );
// Set CSS for headers
- setHeadersCss( $table[0], $headers, config.sortList, sortCSS, sortMsg, config.columnToHeader );
+ setHeadersCss( $table[ 0 ], $headers, config.sortList, sortCSS, sortMsg, config.columnToHeader );
appendToTable(
- $table[0], multisort( $table[0], config.sortList, cache )
+ $table[ 0 ], multisort( $table[ 0 ], config.sortList, cache )
);
// Stop normal event by returning false
len = parsers.length,
a = true;
for ( i = 0; i < len; i++ ) {
- if ( parsers[i].id.toLowerCase() === parser.id.toLowerCase() ) {
+ if ( parsers[ i ].id.toLowerCase() === parser.id.toLowerCase() ) {
a = false;
}
}
for ( p = 0; p < s.length; p++ ) {
c = s.charAt( p );
if ( c in ts.transformTable ) {
- out += ts.transformTable[c];
+ out += ts.transformTable[ c ];
} else {
out += c;
}
},
clearTableBody: function ( table ) {
- $( table.tBodies[0] ).empty();
+ $( table.tBodies[ 0 ] ).empty();
},
getParser: function ( id ) {
if ( ts.collationRegex ) {
var tsc = ts.collationTable;
s = s.replace( ts.collationRegex, function ( match ) {
- var r = tsc[match] ? tsc[match] : tsc[match.toUpperCase()];
+ var r = tsc[ match ] ? tsc[ match ] : tsc[ match.toUpperCase() ];
return r.toLowerCase();
} );
}
ts.addParser( {
id: 'IPAddress',
is: function ( s ) {
- return ts.rgx.IPAddress[0].test( s );
+ return ts.rgx.IPAddress[ 0 ].test( s );
},
format: function ( s ) {
var i, item,
r = '',
len = a.length;
for ( i = 0; i < len; i++ ) {
- item = a[i];
+ item = a[ i ];
if ( item.length === 1 ) {
r += '00' + item;
} else if ( item.length === 2 ) {
ts.addParser( {
id: 'currency',
is: function ( s ) {
- return ts.rgx.currency[0].test( s );
+ return ts.rgx.currency[ 0 ].test( s );
},
format: function ( s ) {
- return $.tablesorter.formatDigit( s.replace( ts.rgx.currency[1], '' ) );
+ return $.tablesorter.formatDigit( s.replace( ts.rgx.currency[ 1 ], '' ) );
},
type: 'numeric'
} );
ts.addParser( {
id: 'url',
is: function ( s ) {
- return ts.rgx.url[0].test( s );
+ return ts.rgx.url[ 0 ].test( s );
},
format: function ( s ) {
- return $.trim( s.replace( ts.rgx.url[1], '' ) );
+ return $.trim( s.replace( ts.rgx.url[ 1 ], '' ) );
},
type: 'text'
} );
ts.addParser( {
id: 'isoDate',
is: function ( s ) {
- return ts.rgx.isoDate[0].test( s );
+ return ts.rgx.isoDate[ 0 ].test( s );
},
format: function ( s ) {
return $.tablesorter.formatFloat( ( s !== '' ) ? new Date( s.replace(
ts.addParser( {
id: 'usLongDate',
is: function ( s ) {
- return ts.rgx.usLongDate[0].test( s );
+ return ts.rgx.usLongDate[ 0 ].test( s );
},
format: function ( s ) {
return $.tablesorter.formatFloat( new Date( s ).getTime() );
ts.addParser( {
id: 'date',
is: function ( s ) {
- return ( ts.dateRegex[0].test( s ) || ts.dateRegex[1].test( s ) || ts.dateRegex[2].test( s ) );
+ return ( ts.dateRegex[ 0 ].test( s ) || ts.dateRegex[ 1 ].test( s ) || ts.dateRegex[ 2 ].test( s ) );
},
format: function ( s ) {
var match, y;
s = $.trim( s.toLowerCase() );
- if ( ( match = s.match( ts.dateRegex[0] ) ) !== null ) {
+ if ( ( match = s.match( ts.dateRegex[ 0 ] ) ) !== null ) {
if ( mw.config.get( 'wgDefaultDateFormat' ) === 'mdy' || mw.config.get( 'wgPageContentLanguage' ) === 'en' ) {
- s = [ match[3], match[1], match[2] ];
+ s = [ match[ 3 ], match[ 1 ], match[ 2 ] ];
} else if ( mw.config.get( 'wgDefaultDateFormat' ) === 'dmy' ) {
- s = [ match[3], match[2], match[1] ];
+ s = [ match[ 3 ], match[ 2 ], match[ 1 ] ];
} else {
// If we get here, we don't know which order the dd-dd-dddd
// date is in. So return something not entirely invalid.
return '99999999';
}
- } else if ( ( match = s.match( ts.dateRegex[1] ) ) !== null ) {
- s = [ match[3], String( ts.monthNames[match[2]] ), match[1] ];
- } else if ( ( match = s.match( ts.dateRegex[2] ) ) !== null ) {
- s = [ match[3], String( ts.monthNames[match[1]] ), match[2] ];
+ } else if ( ( match = s.match( ts.dateRegex[ 1 ] ) ) !== null ) {
+ s = [ match[ 3 ], String( ts.monthNames[ match[ 2 ] ] ), match[ 1 ] ];
+ } else if ( ( match = s.match( ts.dateRegex[ 2 ] ) ) !== null ) {
+ s = [ match[ 3 ], String( ts.monthNames[ match[ 1 ] ] ), match[ 2 ] ];
} else {
// Should never get here
return '99999999';
}
// Pad Month and Day
- if ( s[1].length === 1 ) {
- s[1] = '0' + s[1];
+ if ( s[ 1 ].length === 1 ) {
+ s[ 1 ] = '0' + s[ 1 ];
}
- if ( s[2].length === 1 ) {
- s[2] = '0' + s[2];
+ if ( s[ 2 ].length === 1 ) {
+ s[ 2 ] = '0' + s[ 2 ];
}
- if ( ( y = parseInt( s[0], 10 ) ) < 100 ) {
+ if ( ( y = parseInt( s[ 0 ], 10 ) ) < 100 ) {
// Guestimate years without centuries
if ( y < 30 ) {
- s[0] = 2000 + y;
+ s[ 0 ] = 2000 + y;
} else {
- s[0] = 1900 + y;
+ s[ 0 ] = 1900 + y;
}
}
- while ( s[0].length < 4 ) {
- s[0] = '0' + s[0];
+ while ( s[ 0 ].length < 4 ) {
+ s[ 0 ] = '0' + s[ 0 ];
}
return parseInt( s.join( '' ), 10 );
},
ts.addParser( {
id: 'time',
is: function ( s ) {
- return ts.rgx.time[0].test( s );
+ return ts.rgx.time[ 0 ].test( s );
},
format: function ( s ) {
return $.tablesorter.formatFloat( new Date( '2000/01/01 ' + s ).getTime() );
insertText = '',
selTextArr = selText.split( '\n' );
for ( i = 0; i < selTextArr.length; i++ ) {
- insertText += pre + selTextArr[i] + post;
+ insertText += pre + selTextArr[ i ] + post;
if ( i !== selTextArr.length - 1 ) {
insertText += '\n';
}
context.fn.restoreSelection();
needSave = true;
}
- retval = ( alternateFn && alternateFn[command] || fn[command] ).call( this, options );
+ retval = ( alternateFn && alternateFn[ command ] || fn[ command ] ).call( this, options );
if ( hasWikiEditor && needSave ) {
context.fn.saveSelection();
}
for ( i = 0; i < collapsibleLists.length; i++ ) {
// Pass to a function for iteration-local variables
handleOne(
- $editForm.find( collapsibleLists[i].listSel ),
- $editForm.find( collapsibleLists[i].togglerSel ),
- collapsibleLists[i].cookieName
+ $editForm.find( collapsibleLists[ i ].listSel ),
+ $editForm.find( collapsibleLists[ i ].togglerSel ),
+ collapsibleLists[ i ].cookieName
);
}
} );
$wikiPreview.show();
// Jump to where the preview will appear
- $wikiPreview[0].scrollIntoView();
+ $wikiPreview[ 0 ].scrollIntoView();
copySelectors = [
// Main
indexpageids: '',
prop: 'revisions',
titles: mw.config.get( 'wgPageName' ),
- rvdifftotext: response.parse.text['*'],
+ rvdifftotext: response.parse.text[ '*' ],
rvprop: ''
};
if ( section !== '' ) {
}
return api.post( postData ).done( function ( result2 ) {
try {
- var diffHtml = result2.query.pages[result2.query.pageids[0]]
- .revisions[0].diff['*'];
+ var diffHtml = result2.query.pages[ result2.query.pageids[ 0 ] ]
+ .revisions[ 0 ].diff[ '*' ];
$wikiDiff.find( 'table.diff tbody' ).html( diffHtml );
} catch ( e ) {
// "result.blah is undefined" error, ignore
);
}
if ( response.parse.categorieshtml ) {
- $( '#catlinks' ).replaceWith( response.parse.categorieshtml['*'] );
+ $( '#catlinks' ).replaceWith( response.parse.categorieshtml[ '*' ] );
}
if ( response.parse.templates ) {
newList = [];
li = $( '<li>' )
.append( $( '<a>' )
.attr( {
- 'href': mw.util.getUrl( template['*'] ),
+ 'href': mw.util.getUrl( template[ '*' ] ),
'class': ( template.exists !== undefined ? '' : 'new' )
} )
- .text( template['*'] )
+ .text( template[ '*' ] )
);
newList.push( li );
} );
$editform.find( '.templatesUsed .mw-editfooter-list' ).detach().empty().append( newList ).appendTo( '.templatesUsed' );
}
if ( response.parse.limitreporthtml ) {
- $( '.limitreport' ).html( response.parse.limitreporthtml['*'] );
+ $( '.limitreport' ).html( response.parse.limitreporthtml[ '*' ] );
}
if ( response.parse.langlinks && mw.config.get( 'skin' ) === 'vector' ) {
newList = [];
.append( $( '<a>' )
.attr( {
'href': langlink.url,
- 'title': langlink['*'] + ' - ' + langlink.langname,
+ 'title': langlink[ '*' ] + ' - ' + langlink.langname,
'lang': langlink.lang,
'hreflang': langlink.lang
} )
$list.detach().empty().append( newList ).prependTo( $parent );
}
- if ( response.parse.text['*'] ) {
+ if ( response.parse.text[ '*' ] ) {
$content = $wikiPreview.children( '.mw-content-ltr,.mw-content-rtl' );
$content
.detach()
- .html( response.parse.text['*'] );
+ .html( response.parse.text[ '*' ] );
mw.hook( 'wikipage.content' ).fire( $content );
var isSubject = ( section === 'new' ),
summaryMsg = isSubject ? 'subject-preview' : 'summary-preview',
$summaryPreview = $editform.find( '.mw-summary-preview' ).empty();
- if ( response.parse.parsedsummary && response.parse.parsedsummary['*'] !== '' ) {
+ if ( response.parse.parsedsummary && response.parse.parsedsummary[ '*' ] !== '' ) {
$summaryPreview.append(
mw.message( summaryMsg ).parse(),
' ',
$( '<span>' ).addClass( 'comment' ).html(
// There is no equivalent to rawParams
mw.message( 'parentheses' ).escaped()
- .replace( '$1', response.parse.parsedsummary['*'] )
+ .replace( '$1', response.parse.parsedsummary[ '*' ] )
)
);
}
// Handle common MediaWiki API idioms for passing parameters
for ( key in parameters ) {
// Multiple values are pipe-separated
- if ( $.isArray( parameters[key] ) ) {
- parameters[key] = parameters[key].join( '|' );
+ if ( $.isArray( parameters[ key ] ) ) {
+ parameters[ key ] = parameters[ key ].join( '|' );
}
// Boolean values are only false when not given at all
- if ( parameters[key] === false || parameters[key] === undefined ) {
- delete parameters[key];
+ if ( parameters[ key ] === false || parameters[ key ] === undefined ) {
+ delete parameters[ key ];
}
}
},
formData = new FormData();
for ( key in parameters ) {
- formData.append( key, parameters[key] );
+ formData.append( key, parameters[ key ] );
}
// If we extracted a token parameter, add it back in.
if ( token ) {
d = apiPromise
.then( function ( data ) {
- if ( data.tokens && data.tokens[type + 'token'] ) {
- return data.tokens[type + 'token'];
+ if ( data.tokens && data.tokens[ type + 'token' ] ) {
+ return data.tokens[ type + 'token' ];
}
// If token type is not available for this user,
*/
saveOption: function ( name, value ) {
var param = {};
- param[name] = value;
+ param[ name ] = value;
return this.saveOptions( param );
},
deferreds = [];
for ( name in options ) {
- value = options[name] === null ? null : String( options[name] );
+ value = options[ name ] === null ? null : String( options[ name ] );
// Can we bundle this option, or does it need a separate request?
bundleable =
return apiPromise
.then( function ( data ) {
- return data.parse.text['*'];
+ return data.parse.text[ '*' ];
} )
.promise( { abort: apiPromise.abort } );
}
*/
function processIframeResult( iframe ) {
var json,
- doc = iframe.contentDocument || frames[iframe.id].document;
+ doc = iframe.contentDocument || frames[ iframe.id ].document;
if ( doc.XMLDocument ) {
// The response is a document property in IE
isFileInput = file && file.nodeType === Node.ELEMENT_NODE;
if ( formDataAvailable() && isFileInput && file.files ) {
- file = file.files[0];
+ file = file.files[ 0 ];
}
if ( !file ) {
$iframe = $( iframe );
for ( key in data ) {
- if ( !fieldsAllowed[key] ) {
- delete data[key];
+ if ( !fieldsAllowed[ key ] ) {
+ delete data[ key ];
}
}
deferred = $.Deferred();
for ( key in data ) {
- if ( !fieldsAllowed[key] ) {
- delete data[key];
+ if ( !fieldsAllowed[ key ] ) {
+ delete data[ key ];
}
}
return apiPromise
.then( function ( data ) {
// If a single page was given (not an array) respond with a single item as well.
- return $.isArray( pages ) ? data.watch : data.watch[0];
+ return $.isArray( pages ) ? data.watch : data.watch[ 0 ];
} )
.promise( { abort: apiPromise.abort } );
}
mediaWiki.language.convertGrammar = function ( word, form ) {
var grammarForms = mediaWiki.language.getData( 'bs', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'instrumental': // instrumental
mediaWiki.language.convertGrammar = function ( word, form ) {
var grammarForms = mediaWiki.language.getData( 'dsb', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'instrumental': // instrumental
var grammarForms, aou, origWord;
grammarForms = mediaWiki.language.getData( 'fi', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
// vowel harmony flag
mediaWiki.language.convertGrammar = function ( word, form ) {
/*jshint onecase:true */
var grammarForms = mediaWiki.language.getData( 'ga', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'ainmlae':
mediaWiki.language.convertGrammar = function ( word, form ) {
var grammarForms = mediaWiki.language.getData( 'he', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'prefixed':
mediaWiki.language.convertGrammar = function ( word, form ) {
var grammarForms = mediaWiki.language.getData( 'hsb', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'instrumental': // instrumental
mediaWiki.language.convertGrammar = function ( word, form ) {
var grammarForms = mediaWiki.language.getData( 'hu', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'rol':
mediaWiki.language.convertGrammar = function ( word, form ) {
/*jshint onecase:true */
var grammarForms = mediaWiki.language.getData( 'hy', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
// These rules are not perfect, but they are currently only used for site names so it doesn't
mediaWiki.language.convertGrammar = function ( word, form ) {
var grammarForms = mediaWiki.language.getData( 'la', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'genitive':
// Variable for ending
ending = '';
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
// Checking if the $word is in plural form
if ( word.match( /тæ$/i ) ) {
'use strict';
var grammarForms = mediaWiki.language.getData( 'ru', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'genitive': // родительный падеж
mediaWiki.language.convertGrammar = function ( word, form ) {
var grammarForms = mediaWiki.language.getData( 'sl', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'mestnik': // locative
mediaWiki.language.convertGrammar = function ( word, form ) {
var grammarForms = mediaWiki.language.getData( 'uk', 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word];
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ];
}
switch ( form ) {
case 'genitive': // родовий відмінок
getPluralForm: function ( number, pluralRules ) {
var i;
for ( i = 0; i < pluralRules.length; i++ ) {
- if ( mw.libs.pluralRuleParser( pluralRules[i], number ) ) {
+ if ( mw.libs.pluralRuleParser( pluralRules[ i ], number ) ) {
break;
}
}
getData: function ( langCode, dataKey ) {
var langData = mw.language.data;
langCode = langCode.toLowerCase();
- if ( langData && langData[langCode] instanceof mw.Map ) {
- return langData[langCode].get( dataKey );
+ if ( langData && langData[ langCode ] instanceof mw.Map ) {
+ return langData[ langCode ].get( dataKey );
}
return undefined;
},
setData: function ( langCode, dataKey, value ) {
var langData = mw.language.data;
langCode = langCode.toLowerCase();
- if ( !( langData[langCode] instanceof mw.Map ) ) {
- langData[langCode] = new mw.Map();
+ if ( !( langData[ langCode ] instanceof mw.Map ) ) {
+ langData[ langCode ] = new mw.Map();
}
- langData[langCode].set( dataKey, value );
+ langData[ langCode ].set( dataKey, value );
}
};
return mw.language.convertPlural( parseInt( count, 10 ), template.parameters );
}
// Could not process plural return first form or nothing
- if ( template.parameters[0] ) {
- return template.parameters[0];
+ if ( template.parameters[ 0 ] ) {
+ return template.parameters[ 0 ];
}
return '';
},
var pluralRules,
pluralFormIndex = 0;
- if ( explicitPluralForms && explicitPluralForms[count] ) {
- return explicitPluralForms[count];
+ if ( explicitPluralForms && explicitPluralForms[ count ] ) {
+ return explicitPluralForms[ count ];
}
if ( !forms || forms.length === 0 ) {
pluralRules = mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'pluralRules' );
if ( !pluralRules ) {
// default fallback.
- return ( count === 1 ) ? forms[0] : forms[1];
+ return ( count === 1 ) ? forms[ 0 ] : forms[ 1 ];
}
pluralFormIndex = mw.cldr.getPluralForm( count, pluralRules );
pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 );
- return forms[pluralFormIndex];
+ return forms[ pluralFormIndex ];
},
/**
}
forms = mw.language.preConvertPlural( forms, 2 );
if ( gender === 'male' ) {
- return forms[0];
+ return forms[ 0 ];
}
if ( gender === 'female' ) {
- return forms[1];
+ return forms[ 1 ];
}
- return ( forms.length === 3 ) ? forms[2] : forms[0];
+ return ( forms.length === 3 ) ? forms[ 2 ] : forms[ 0 ];
},
/**
*/
convertGrammar: function ( word, form ) {
var grammarForms = mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'grammarForms' );
- if ( grammarForms && grammarForms[form] ) {
- return grammarForms[form][word] || word;
+ if ( grammarForms && grammarForms[ form ] ) {
+ return grammarForms[ form ][ word ] || word;
}
return word;
},
i = 0;
for ( ; i < list.length; i++ ) {
- text += list[i];
+ text += list[ i ];
if ( list.length - 2 === i ) {
text += mw.msg( 'and' ) + mw.msg( 'word-separator' );
} else if ( list.length - 1 !== i ) {
off,
remainder,
patternParts = pattern.split( '.' ),
- maxPlaces = ( patternParts[1] || [] ).length,
+ maxPlaces = ( patternParts[ 1 ] || [] ).length,
valueParts = String( Math.abs( value ) ).split( '.' ),
- fractional = valueParts[1] || '',
+ fractional = valueParts[ 1 ] || '',
groupSize = 0,
groupSize2 = 0,
pieces = [];
- if ( patternParts[1] ) {
+ if ( patternParts[ 1 ] ) {
// Pad fractional with trailing zeros
- padLength = ( patternParts[1] && patternParts[1].lastIndexOf( '0' ) + 1 );
+ padLength = ( patternParts[ 1 ] && patternParts[ 1 ].lastIndexOf( '0' ) + 1 );
if ( padLength > fractional.length ) {
- valueParts[1] = pad( fractional, padLength, '0', true );
+ valueParts[ 1 ] = pad( fractional, padLength, '0', true );
}
// Truncate fractional
if ( maxPlaces < fractional.length ) {
- valueParts[1] = fractional.slice( 0, maxPlaces );
+ valueParts[ 1 ] = fractional.slice( 0, maxPlaces );
}
} else {
- if ( valueParts[1] ) {
+ if ( valueParts[ 1 ] ) {
valueParts.pop();
}
}
// Pad whole with leading zeros
- patternDigits = patternParts[0].replace( ',', '' );
+ patternDigits = patternParts[ 0 ].replace( ',', '' );
padLength = patternDigits.indexOf( '0' );
if ( padLength !== -1 ) {
padLength = patternDigits.length - padLength;
- if ( padLength > valueParts[0].length ) {
- valueParts[0] = pad( valueParts[0], padLength );
+ if ( padLength > valueParts[ 0 ].length ) {
+ valueParts[ 0 ] = pad( valueParts[ 0 ], padLength );
}
// Truncate whole
if ( patternDigits.indexOf( '#' ) === -1 ) {
- valueParts[0] = valueParts[0].slice( valueParts[0].length - padLength );
+ valueParts[ 0 ] = valueParts[ 0 ].slice( valueParts[ 0 ].length - padLength );
}
}
// Add group separators
- index = patternParts[0].lastIndexOf( ',' );
+ index = patternParts[ 0 ].lastIndexOf( ',' );
if ( index !== -1 ) {
- groupSize = patternParts[0].length - index - 1;
- remainder = patternParts[0].slice( 0, index );
+ groupSize = patternParts[ 0 ].length - index - 1;
+ remainder = patternParts[ 0 ].slice( 0, index );
index = remainder.lastIndexOf( ',' );
if ( index !== -1 ) {
groupSize2 = remainder.length - index - 1;
}
}
- for ( whole = valueParts[0]; whole; ) {
+ for ( whole = valueParts[ 0 ]; whole; ) {
off = groupSize ? whole.length - groupSize : 0;
pieces.push( ( off > 0 ) ? whole.slice( off ) : whole );
whole = ( off > 0 ) ? whole.slice( 0, off ) : '';
groupSize2 = null;
}
}
- valueParts[0] = pieces.reverse().join( options.group );
+ valueParts[ 0 ] = pieces.reverse().join( options.group );
return valueParts.join( options.decimal );
}
convertedNumber = '';
for ( i = 0; i < numberString.length; i++ ) {
- if ( transformTable[ numberString[i] ] ) {
- convertedNumber += transformTable[numberString[i]];
+ if ( transformTable[ numberString[ i ] ] ) {
+ convertedNumber += transformTable[ numberString[ i ] ];
} else {
- convertedNumber += numberString[i];
+ convertedNumber += numberString[ i ];
}
}
return integer ? parseInt( convertedNumber, 10 ) : convertedNumber;
commafy: function ( value, pattern ) {
var numberPattern,
transformTable = mw.language.getSeparatorTransformTable(),
- group = transformTable[','] || ',',
+ group = transformTable[ ',' ] || ',',
numberPatternRE = /[#0,]*[#0](?:\.0*#*)?/, // not precise, but good enough
- decimal = transformTable['.'] || '.',
+ decimal = transformTable[ '.' ] || '.',
patternList = pattern.split( ';' ),
- positivePattern = patternList[0];
+ positivePattern = patternList[ 0 ];
- pattern = patternList[ ( value < 0 ) ? 1 : 0] || ( '-' + positivePattern );
+ pattern = patternList[ ( value < 0 ) ? 1 : 0 ] || ( '-' + positivePattern );
numberPattern = positivePattern.match( numberPatternRE );
if ( !numberPattern ) {
throw new Error( 'unable to find a number expression in pattern: ' + pattern );
}
- return pattern.replace( numberPatternRE, commafyNumber( value, numberPattern[0], {
+ return pattern.replace( numberPatternRE, commafyNumber( value, numberPattern[ 0 ], {
decimal: decimal,
group: group
} ) );
*/
matchAttribute: function ( objects, attrName ) {
return $.map( objects, function ( object ) {
- return object[attrName];
+ return object[ attrName ];
} ).filter( function ( item, index, a ) {
return index === a.indexOf( item );
} ).length === 1;
// Execute the queued functions
for ( i = 0; i < functs.length; i++ ) {
- functs[i]();
+ functs[ i ]();
}
} );
* @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25.
*/
function importScriptURI( url ) {
- if ( loadedScripts[url] ) {
+ if ( loadedScripts[ url ] ) {
return null;
}
- loadedScripts[url] = true;
+ loadedScripts[ url ] = true;
var s = document.createElement( 'script' );
s.setAttribute( 'src', url );
s.setAttribute( 'type', 'text/javascript' );
- document.getElementsByTagName( 'head' )[0].appendChild( s );
+ document.getElementsByTagName( 'head' )[ 0 ].appendChild( s );
return s;
}
if ( media ) {
l.media = media;
}
- document.getElementsByTagName( 'head' )[0].appendChild( l );
+ document.getElementsByTagName( 'head' )[ 0 ].appendChild( l );
return l;
}
* @param {Function} messagePosterConstructor Constructor for MessagePoster
*/
MwMessagePosterFactory.prototype.register = function ( contentModel, messagePosterConstructor ) {
- if ( this.contentModelToClass[contentModel] !== undefined ) {
+ if ( this.contentModelToClass[ contentModel ] !== undefined ) {
throw new Error( 'The content model \'' + contentModel + '\' is already registered.' );
}
- this.contentModelToClass[contentModel] = messagePosterConstructor;
+ this.contentModelToClass[ contentModel ] = messagePosterConstructor;
};
/**
* @param {string} contentModel Content model to unregister
*/
MwMessagePosterFactory.prototype.unregister = function ( contentModel ) {
- delete this.contentModelToClass[contentModel];
+ delete this.contentModelToClass[ contentModel ];
};
/**
titles: title.getPrefixedDb()
} ).then( function ( result ) {
if ( result.query.pageids && result.query.pageids.length > 0 ) {
- pageId = result.query.pageids[0];
- page = result.query.pages[pageId];
+ pageId = result.query.pageids[ 0 ];
+ page = result.query.pages[ pageId ];
contentModel = page.contentmodel;
moduleName = 'mediawiki.messagePoster.' + contentModel;
*
*/
MwMessagePosterFactory.prototype.createForContentModel = function ( contentModel, title ) {
- return new this.contentModelToClass[contentModel]( title );
+ return new this.contentModelToClass[ contentModel ]( title );
};
mw.messagePoster = {
$this = $( this );
if ( top !== lastTop ) {
- rows[rows.length] = [];
+ rows[ rows.length ] = [];
lastTop = top;
}
$img = $this.find( 'div.thumb a.image img' );
- if ( $img.length && $img[0].height ) {
- imgHeight = $img[0].height;
- imgWidth = $img[0].width;
+ if ( $img.length && $img[ 0 ].height ) {
+ imgHeight = $img[ 0 ].height;
+ imgWidth = $img[ 0 ].width;
} else {
// If we don't have a real image, get the containing divs width/height.
// Note that if we do have a real image, using this method will generally
}
captionWidth = $this.children().children( 'div.gallerytextwrapper' ).width();
- rows[rows.length - 1][rows[rows.length - 1].length] = {
+ rows[ rows.length - 1 ][ rows[ rows.length - 1 ].length ] = {
$elm: $this,
width: $this.outerWidth(),
imgWidth: imgWidth,
maxWidth = $gallery.width();
combinedAspect = 0;
combinedPadding = 0;
- curRow = rows[i];
+ curRow = rows[ i ];
curRowHeight = 0;
for ( j = 0; j < curRow.length; j++ ) {
if ( curRowHeight === 0 ) {
- if ( isFinite( curRow[j].height ) ) {
+ if ( isFinite( curRow[ j ].height ) ) {
// Get the height of this row, by taking the first
// non-out of bounds height
- curRowHeight = curRow[j].height;
+ curRowHeight = curRow[ j ].height;
}
}
- if ( curRow[j].aspect === 0 || !isFinite( curRow[j].aspect ) ) {
+ if ( curRow[ j ].aspect === 0 || !isFinite( curRow[ j ].aspect ) ) {
// One of the dimensions are 0. Probably should
// not try to resize.
- combinedPadding += curRow[j].width;
+ combinedPadding += curRow[ j ].width;
} else {
- combinedAspect += curRow[j].aspect;
- combinedPadding += curRow[j].width - curRow[j].imgWidth;
+ combinedAspect += curRow[ j ].aspect;
+ combinedPadding += curRow[ j ].width - curRow[ j ].imgWidth;
}
}
}
for ( j = 0; j < curRow.length; j++ ) {
- newWidth = preferredHeight * curRow[j].aspect;
- padding = curRow[j].width - curRow[j].imgWidth;
- $outerDiv = curRow[j].$elm;
+ newWidth = preferredHeight * curRow[ j ].aspect;
+ padding = curRow[ j ].width - curRow[ j ].imgWidth;
+ $outerDiv = curRow[ j ].$elm;
$innerDiv = $outerDiv.children( 'div' ).first();
$imageDiv = $innerDiv.children( 'div.thumb' );
$imageElm = $imageDiv.find( 'img' ).first();
- imageElm = $imageElm.length ? $imageElm[0] : null;
+ imageElm = $imageElm.length ? $imageElm[ 0 ] : null;
$caption = $outerDiv.find( 'div.gallerytextwrapper' );
// Since we are going to re-adjust the height, the vertical
$outerDiv.width( newWidth + padding );
$innerDiv.width( newWidth + padding );
$imageDiv.width( newWidth );
- $caption.width( curRow[j].captionWidth + ( newWidth - curRow[j].imgWidth ) );
+ $caption.width( curRow[ j ].captionWidth + ( newWidth - curRow[ j ].imgWidth ) );
}
if ( imageElm ) {
$( this ).find( 'div.gallerytextwrapper' ).width( captionWidth );
$imageElm = $( this ).find( 'img' ).first();
- imageElm = $imageElm.length ? $imageElm[0] : null;
+ imageElm = $imageElm.length ? $imageElm[ 0 ] : null;
if ( imageElm ) {
imageElm.width = imgWidth;
imageElm.height = imgHeight;
jqXhr = undefined;
// Try the cache
- if ( cache[url] ) {
+ if ( cache[ url ] ) {
// Update access freshness
cacheOrder.splice( $.inArray( url, cacheOrder ), 1 );
cacheOrder.push( url );
- return $.Deferred().resolve( cache[url] ).promise();
+ return $.Deferred().resolve( cache[ url ] ).promise();
}
// @todo Don't fetch the entire page. Ideally we'd only fetch the content portion or the data
jqXhr = undefined;
// Cache the newly loaded page
- cache[url] = $contents;
+ cache[ url ] = $contents;
cacheOrder.push( url );
// Remove the oldest entry if we're over the limit
if ( cacheOrder.length > 10 ) {
- delete cache[ cacheOrder[0] ];
+ delete cache[ cacheOrder[ 0 ] ];
cacheOrder = cacheOrder.slice( 1 );
}
} );
actionPaths = mw.config.get( 'wgActionPaths' );
for ( key in actionPaths ) {
if ( actionPaths.hasOwnProperty( key ) ) {
- parts = actionPaths[key].split( '$1' );
+ parts = actionPaths[ key ].split( '$1' );
for ( i = 0; i < parts.length; i++ ) {
- parts[i] = mw.RegExp.escape( parts[i] );
+ parts[ i ] = mw.RegExp.escape( parts[ i ] );
}
m = new RegExp( parts.join( '(.+)' ) ).exec( url );
- if ( m && m[1] ) {
+ if ( m && m[ 1 ] ) {
return key;
}
api = new mw.Api();
- api[action]( title )
+ api[ action ]( title )
.done( function ( watchResponse ) {
var otherAction = action === 'watch' ? 'unwatch' : 'watch';
var minutes,
arr = hour.split( ':' );
- arr[0] = parseInt( arr[0], 10 );
+ arr[ 0 ] = parseInt( arr[ 0 ], 10 );
if ( arr.length === 1 ) {
// Specification is of the form [-]XX
- minutes = arr[0] * 60;
+ minutes = arr[ 0 ] * 60;
} else {
// Specification is of the form [-]XX:XX
- minutes = Math.abs( arr[0] ) * 60 + parseInt( arr[1], 10 );
- if ( arr[0] < 0 ) {
+ minutes = Math.abs( arr[ 0 ] ) * 60 + parseInt( arr[ 1 ], 10 );
+ if ( arr[ 0 ] < 0 ) {
minutes *= -1;
}
}
minuteDiff = hoursToMinutes( $tzTextbox.val() );
} else {
// Grab data from the $tzSelect value
- minuteDiff = parseInt( type.split( '|' )[1], 10 ) || 0;
+ minuteDiff = parseInt( type.split( '|' )[ 1 ], 10 ) || 0;
$tzTextbox.val( minutesToHours( minuteDiff ) );
}
var parts = $( this ).attr( 'href' ).split( 'search=' ),
lastpart = '',
prefix = 'search=';
- if ( parts.length > 1 && parts[1].indexOf( '&' ) !== -1 ) {
- lastpart = parts[1].slice( parts[1].indexOf( '&' ) );
+ if ( parts.length > 1 && parts[ 1 ].indexOf( '&' ) !== -1 ) {
+ lastpart = parts[ 1 ].slice( parts[ 1 ].indexOf( '&' ) );
} else {
prefix = '&search=';
}
- this.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart;
+ this.href = parts[ 0 ] + prefix + encodeURIComponent( searchterm ) + lastpart;
} );
} ).trigger( 'change' );
}
// Check response cache
if ( this.responseCache.hasOwnProperty( this.nameToCheck ) ) {
- this.setWarning( this.responseCache[this.nameToCheck] );
+ this.setWarning( this.responseCache[ this.nameToCheck ] );
return;
}
} ).done( function ( result ) {
var resultOut = '';
if ( result.query ) {
- resultOut = result.query.pages[result.query.pageids[0]].imageinfo[0];
+ resultOut = result.query.pages[ result.query.pageids[ 0 ] ].imageinfo[ 0 ];
}
$spinnerDestCheck.remove();
uploadWarning.processResult( resultOut, uploadWarning.nameToCheck );
processResult: function ( result, fileName ) {
this.setWarning( result.html );
- this.responseCache[fileName] = result.html;
+ this.responseCache[ fileName ] = result.html;
},
setWarning: function ( warning ) {
return;
}
if ( this.responseCache.hasOwnProperty( license ) ) {
- this.showPreview( this.responseCache[license] );
+ this.showPreview( this.responseCache[ license ] );
return;
}
},
processResult: function ( result, license ) {
- this.responseCache[license] = result.parse.text['*'];
- this.showPreview( this.responseCache[license] );
+ this.responseCache[ license ] = result.parse.text[ '*' ];
+ this.showPreview( this.responseCache[ license ] );
},
showPreview: function ( preview ) {
fname = fname.replace( / /g, '_' );
// Capitalise first letter if needed
if ( mw.config.get( 'wgCapitalizeUploads' ) ) {
- fname = fname[0].toUpperCase() + fname.slice( 1 );
+ fname = fname[ 0 ].toUpperCase() + fname.slice( 1 );
}
// Output result
* @return boolean
*/
function fileIsPreviewable( file ) {
- var known = ['image/png', 'image/gif', 'image/jpeg', 'image/svg+xml'],
+ var known = [ 'image/png', 'image/gif', 'image/jpeg', 'image/svg+xml' ],
tooHuge = 10 * 1024 * 1024;
return ( $.inArray( file.type, known ) !== -1 ) && file.size > 0 && file.size < tooHuge;
}
* @return {string}
*/
function prettySize( s ) {
- var sizeMsgs = ['size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes'];
+ var sizeMsgs = [ 'size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes' ];
while ( s >= 1024 && sizeMsgs.length > 1 ) {
s /= 1024;
sizeMsgs = sizeMsgs.slice( 1 );
}
- return mw.msg( sizeMsgs[0], Math.round( s ) );
+ return mw.msg( sizeMsgs[ 0 ], Math.round( s ) );
}
/**
.find( '.thumbinner' ).prepend( $spinner ).end();
$canvas = $( '<canvas>' ).attr( { width: previewSize, height: previewSize } );
- ctx = $canvas[0].getContext( '2d' );
+ ctx = $canvas[ 0 ].getContext( '2d' );
$( '#mw-htmlform-source' ).parent().prepend( thumb );
fetchPreview( file, function ( dataURL ) {
buffer = new Uint8Array( reader.result ),
string = '';
for ( i = 0; i < buffer.byteLength; i++ ) {
- string += String.fromCharCode( buffer[i] );
+ string += String.fromCharCode( buffer[ i ] );
}
callbackBinary( string );
function getMaxUploadSize( type ) {
var sizes = mw.config.get( 'wgMaxUploadSize' );
- if ( sizes[type] !== undefined ) {
- return sizes[type];
+ if ( sizes[ type ] !== undefined ) {
+ return sizes[ type ];
}
- return sizes['*'];
+ return sizes[ '*' ];
}
$( '.mw-upload-source-error' ).remove();
clearPreview();
if ( this.files && this.files.length ) {
// Note: would need to be updated to handle multiple files.
- var file = this.files[0];
+ var file = this.files[ 0 ];
if ( !checkMaxUploadSize( file ) ) {
return;
ususers: username // '|' in usernames is handled below
} )
.done( function ( resp ) {
- var userinfo = resp.query.users[0];
+ var userinfo = resp.query.users[ 0 ];
if ( resp.query.users.length !== 1 ) {
// Happens if the user types '|' into the field
$toolbar = $( '#toolbar' );
for ( i = 0; i < queue.length; i++ ) {
- button = queue[i];
+ button = queue[ i ];
if ( $.isArray( button ) ) {
// Forwarded arguments array from mw.toolbar.addButton
insertButton.apply( toolbar, button );
}
this.$oldBody = this.$body.addClass( 'mw-widget-calendarWidget-old-body' );
// Clone without children
- this.$body = $( this.$body[0].cloneNode( false ) )
+ this.$body = $( this.$body[ 0 ].cloneNode( false ) )
.removeClass( 'mw-widget-calendarWidget-old-body' )
.toggleClass( 'mw-widget-calendarWidget-body-month', this.displayLayer === 'month' )
.toggleClass( 'mw-widget-calendarWidget-body-year', this.displayLayer === 'year' )
setTimeout( function () {
var $focussed = $( ':focus' );
// Deactivate unless the focus moved to something else inside this widget
- if ( !OO.ui.contains( widget.$element[ 0 ], $focussed[0], true ) ) {
+ if ( !OO.ui.contains( widget.$element[ 0 ], $focussed[ 0 ], true ) ) {
widget.deactivate();
}
}, 0 );
widget.interwikiPrefixes.indexOf( interwiki ) !== -1
) {
return $.Deferred().resolve( { query: {
- pages: [{
+ pages: [ {
title: widget.value
- }]
+ } ]
} } ).promise( promiseAbortObject );
} else {
params = {
if ( data.redirects ) {
for ( i = 0, len = data.redirects.length; i < len; i++ ) {
- redirect = data.redirects[i];
- redirectsTo[redirect.to] = redirectsTo[redirect.to] || [];
- redirectsTo[redirect.to].push( redirect.from );
+ redirect = data.redirects[ i ];
+ redirectsTo[ redirect.to ] = redirectsTo[ redirect.to ] || [];
+ redirectsTo[ redirect.to ].push( redirect.from );
}
}
for ( index in data.pages ) {
- suggestionPage = data.pages[index];
- pageData[suggestionPage.title] = {
+ suggestionPage = data.pages[ index ];
+ pageData[ suggestionPage.title ] = {
missing: suggestionPage.missing !== undefined,
redirect: suggestionPage.redirect !== undefined,
disambiguation: OO.getProp( suggestionPage, 'pageprops', 'disambiguation' ) !== undefined,
titles.push( suggestionPage.title );
}
- redirects = redirectsTo[suggestionPage.title] || [];
+ redirects = redirectsTo[ suggestionPage.title ] || [];
for ( i = 0, len = redirects.length; i < len; i++ ) {
- pageData[redirects[i]] = {
+ pageData[ redirects[ i ] ] = {
missing: false,
redirect: true,
disambiguation: false,
description: mw.msg( 'mw-widgets-titleinput-description-redirect', suggestionPage.title )
};
- titles.push( redirects[i] );
+ titles.push( redirects[ i ] );
}
}
);
if ( !pageExists ) {
- pageData[this.value] = {
+ pageData[ this.value ] = {
missing: true, redirect: false, disambiguation: false,
description: mw.msg( 'mw-widgets-titleinput-description-new-page' )
};
titles.push( this.value );
}
for ( i = 0, len = titles.length; i < len; i++ ) {
- page = pageData[titles[i]] || {};
- items.push( new mw.widgets.TitleOptionWidget( this.getOptionWidgetData( titles[i], page ) ) );
+ page = pageData[ titles[ i ] ] || {};
+ items.push( new mw.widgets.TitleOptionWidget( this.getOptionWidgetData( titles[ i ], page ) ) );
}
return items;
list: 'allusers',
// Prefix of list=allusers is case sensitive. Normalise first
// character to uppercase so that "fo" may yield "Foo".
- auprefix: inputValue[0].toUpperCase() + inputValue.slice( 1 ),
+ auprefix: inputValue[ 0 ].toUpperCase() + inputValue.slice( 1 ),
aulimit: this.limit
} );
};
items = [];
for ( i = 0, len = data.length; i < len; i++ ) {
- user = data[i] || {};
+ user = data[ i ] || {};
items.push( new OO.ui.MenuOptionWidget( {
label: user.name,
data: user.name
var i, category;
for ( i = 0; i < categories.length; i++ ) {
- category = categories[i];
+ category = categories[ i ];
this.categories.push( category );
}
};
var i, desc, templateCalls = [];
for ( i = 0; i < this.descriptions.length; i++ ) {
- desc = this.descriptions[i];
+ desc = this.descriptions[ i ];
templateCalls.push( '{{' + desc.language + '|' + desc.text + '}}' );
}
var i, cat, categoryLinks = [];
for ( i = 0; i < this.categories.length; i++ ) {
- cat = this.categories[i];
+ cat = this.categories[ i ];
categoryLinks.push( '[[Category:' + cat + ']]' );
}
return false;
}
ns = ns.toLowerCase();
- id = mw.config.get( 'wgNamespaceIds' )[ns];
+ id = mw.config.get( 'wgNamespaceIds' )[ ns ];
if ( id === undefined ) {
return false;
}
.replace( rUnderscoreTrim, '' );
// Process initial colon
- if ( title !== '' && title[0] === ':' ) {
+ if ( title !== '' && title[ 0 ] === ':' ) {
// Initial colon means main namespace instead of specified default
namespace = NS_MAIN;
title = title
// Process namespace prefix (if any)
m = title.match( rSplit );
if ( m ) {
- id = getNsIdByName( m[1] );
+ id = getNsIdByName( m[ 1 ] );
if ( id !== false ) {
// Ordinary namespace
namespace = id;
- title = m[2];
+ title = m[ 2 ];
// For Talk:X pages, make sure X has no "namespace" prefix
if ( namespace === NS_TALK && ( m = title.match( rSplit ) ) ) {
// Disallow titles like Talk:File:x (subject should roundtrip: talk:file:x -> file:x -> file_talk:x)
- if ( getNsIdByName( m[1] ) !== false ) {
+ if ( getNsIdByName( m[ 1 ] ) !== false ) {
return false;
}
}
}
// Any remaining initial :s are illegal.
- if ( title[0] === ':' ) {
+ if ( title[ 0 ] === ':' ) {
return false;
}
rules = sanitationRules;
for ( i = 0, ruleLength = rules.length; i < ruleLength; ++i ) {
- rule = rules[i];
+ rule = rules[ i ];
for ( m = 0, filterLength = filter.length; m < filterLength; ++m ) {
- if ( rule[filter[m]] ) {
+ if ( rule[ filter[ m ] ] ) {
s = s.replace( rule.pattern, rule.replace );
}
}
title = $.trim( title.replace( rWhitespace, ' ' ) );
// Process initial colon
- if ( title !== '' && title[0] === ':' ) {
+ if ( title !== '' && title[ 0 ] === ':' ) {
// Initial colon means main namespace instead of specified default
namespace = NS_MAIN;
title = title
// Process namespace prefix (if any)
m = title.match( rSplit );
if ( m ) {
- id = getNsIdByName( m[1] );
+ id = getNsIdByName( m[ 1 ] );
if ( id !== false ) {
// Ordinary namespace
namespace = id;
- title = m[2];
+ title = m[ 2 ];
}
}
recount = regexes.length;
- src = img.jquery ? img[0].src : img.src;
+ src = img.jquery ? img[ 0 ].src : img.src;
matches = src.match( thumbPhpRegex );
decodedSrc = decodeURIComponent( src );
for ( i = 0; i < recount; i++ ) {
- regex = regexes[i];
+ regex = regexes[ i ];
matches = decodedSrc.match( regex );
- if ( matches && matches[1] ) {
- return mw.Title.newFromText( 'File:' + matches[1] );
+ if ( matches && matches[ 1 ] ) {
+ return mw.Title.newFromText( 'File:' + matches[ 1 ] );
}
}
obj = Title.exist.pages;
if ( type === 'string' ) {
- match = obj[title];
+ match = obj[ title ];
} else if ( type === 'object' && title instanceof Title ) {
- match = obj[title.toString()];
+ match = obj[ title.toString() ];
} else {
throw new Error( 'mw.Title.exists: title must be a string or an instance of Title' );
}
pages: {},
set: function ( titles, state ) {
- titles = $.isArray( titles ) ? titles : [titles];
+ titles = $.isArray( titles ) ? titles : [ titles ];
state = state === undefined ? true : !!state;
var i,
pages = this.pages,
len = titles.length;
for ( i = 0; i < len; i++ ) {
- pages[ titles[i] ] = state;
+ pages[ titles[ i ] ] = state;
}
return true;
}
) {
return this.title;
}
- return this.title[0].toUpperCase() + this.title.slice( 1 );
+ return this.title[ 0 ].toUpperCase() + this.title.slice( 1 );
},
/**
// Only copy direct properties, not inherited ones
if ( uri.hasOwnProperty( prop ) ) {
// Deep copy object properties
- if ( $.isArray( uri[prop] ) || $.isPlainObject( uri[prop] ) ) {
- this[prop] = $.extend( true, {}, uri[prop] );
+ if ( $.isArray( uri[ prop ] ) || $.isPlainObject( uri[ prop ] ) ) {
+ this[ prop ] = $.extend( true, {}, uri[ prop ] );
} else {
- this[prop] = uri[prop];
+ this[ prop ] = uri[ prop ];
}
}
}
this.port = defaultUri.port;
}
}
- if ( this.path && this.path[0] !== '/' ) {
+ if ( this.path && this.path[ 0 ] !== '/' ) {
// A real relative URL, relative to defaultUri.path. We can't really handle that since we cannot
// figure out whether the last path component of defaultUri.path is a directory or a file.
throw new Error( 'Bad constructor arguments' );
className: 'mw-debug-pane',
id: 'mw-debug-pane-' + id
} )
- .append( panes[id] )
+ .append( panes[ id ] )
.appendTo( $container );
}
};
for ( i = 0, length = this.data.log.length; i < length; i += 1 ) {
- entry = this.data.log[i];
+ entry = this.data.log[ i ];
entry.typeText = entryTypeText( entry.type );
$( '<tr>' )
.appendTo( $table );
for ( i = 0, length = this.data.queries.length; i < length; i += 1 ) {
- query = this.data.queries[i];
+ query = this.data.queries[ i ];
$( '<tr>' )
.append( $( '<td>' ).text( i + 1 ) )
.append( $( '<td>' ).text( query.sql ) )
.append( $( '<td class="stats">' ).text( ( query.time * 1000 ).toFixed( 4 ) + 'ms' ) )
- .append( $( '<td>' ).text( query['function'] ) )
+ .append( $( '<td>' ).text( query[ 'function' ] ) )
.appendTo( $table );
}
$list = $( '<ul>' );
for ( i = 0, length = this.data.debugLog.length; i < length; i += 1 ) {
- line = this.data.debugLog[i];
+ line = this.data.debugLog[ i ];
$( '<li>' )
.html( mw.html.escape( line ).replace( /\n/g, '<br />\n' ) )
.appendTo( $list );
$( '<tr>' )
.append( $( '<th>' ).text( key ) )
- .append( $( '<td>' ).text( data[key] ) )
+ .append( $( '<td>' ).text( data[ key ] ) )
.appendTo( $table );
}
$table = $( '<table>' );
for ( i = 0, length = this.data.includes.length; i < length; i += 1 ) {
- file = this.data.includes[i];
+ file = this.data.includes[ i ];
$( '<tr>' )
.append( $( '<td>' ).text( file.name ) )
.append( $( '<td class="nr">' ).text( file.size ) )
}
for ( key in buckets ) {
- range += buckets[key];
+ range += buckets[ key ];
}
hash = hashString( experiment.name + ':' + token );
max = ( hash / MAX_INT32_UNSIGNED ) * range;
for ( key in buckets ) {
- acc += buckets[key];
+ acc += buckets[ key ];
if ( max <= acc ) {
return key;
function hideIfParse( $el, spec ) {
var op, i, l, v, $field, $fields, fields, func, funcs, getVal;
- op = spec[0];
+ op = spec[ 0 ];
l = spec.length;
switch ( op ) {
case 'AND':
funcs = [];
fields = [];
for ( i = 1; i < l; i++ ) {
- if ( !$.isArray( spec[i] ) ) {
+ if ( !$.isArray( spec[ i ] ) ) {
throw new Error( op + ' parameters must be arrays' );
}
- v = hideIfParse( $el, spec[i] );
- fields = fields.concat( v[0].toArray() );
- funcs.push( v[1] );
+ v = hideIfParse( $el, spec[ i ] );
+ fields = fields.concat( v[ 0 ].toArray() );
+ funcs.push( v[ 1 ] );
}
$fields = $( fields );
func = function () {
var i;
for ( i = 0; i < l; i++ ) {
- if ( !funcs[i]() ) {
+ if ( !funcs[ i ]() ) {
return false;
}
}
func = function () {
var i;
for ( i = 0; i < l; i++ ) {
- if ( funcs[i]() ) {
+ if ( funcs[ i ]() ) {
return true;
}
}
func = function () {
var i;
for ( i = 0; i < l; i++ ) {
- if ( !funcs[i]() ) {
+ if ( !funcs[ i ]() ) {
return true;
}
}
func = function () {
var i;
for ( i = 0; i < l; i++ ) {
- if ( funcs[i]() ) {
+ if ( funcs[ i ]() ) {
return false;
}
}
if ( l !== 2 ) {
throw new Error( 'NOT takes exactly one parameter' );
}
- if ( !$.isArray( spec[1] ) ) {
+ if ( !$.isArray( spec[ 1 ] ) ) {
throw new Error( 'NOT parameters must be arrays' );
}
- v = hideIfParse( $el, spec[1] );
- $fields = v[0];
- func = v[1];
+ v = hideIfParse( $el, spec[ 1 ] );
+ $fields = v[ 0 ];
+ func = v[ 1 ];
return [ $fields, function () {
return !func();
} ];
if ( l !== 3 ) {
throw new Error( op + ' takes exactly two parameters' );
}
- $field = hideIfGetField( $el, spec[1] );
+ $field = hideIfGetField( $el, spec[ 1 ] );
if ( !$field ) {
return [ $(), function () {
return false;
} ];
}
- v = spec[2];
+ v = spec[ 2 ];
if ( $field.first().prop( 'type' ) === 'radio' ||
$field.first().prop( 'type' ) === 'checkbox'
}
v = hideIfParse( $el, spec );
- $fields = v[0];
- test = v[1];
+ $fields = v[ 0 ];
+ test = v[ 1 ];
func = function () {
if ( test() ) {
$el.hide();
function sortByProperty( array, prop, descending ) {
var order = descending ? -1 : 1;
return array.sort( function ( a, b ) {
- return a[prop] > b[prop] ? order : a[prop] < b[prop] ? -order : 0;
+ return a[ prop ] > b[ prop ] ? order : a[ prop ] < b[ prop ] ? -order : 0;
} );
}
for ( ; bytes >= 1024; bytes /= 1024 ) { i++; }
// Maintain one decimal for kB and above, but don't
// add ".0" for bytes.
- return bytes.toFixed( i > 0 ? 1 : 0 ) + units[i];
+ return bytes.toFixed( i > 0 ? 1 : 0 ) + units[ i ];
}
/**
graph = {};
$.each( modules, function ( moduleIndex, moduleName ) {
- var dependencies = mw.loader.moduleRegistry[moduleName].dependencies || [];
+ var dependencies = mw.loader.moduleRegistry[ moduleName ].dependencies || [];
if ( !hasOwn.call( graph, moduleName ) ) {
- graph[moduleName] = { requiredBy: [] };
+ graph[ moduleName ] = { requiredBy: [] };
}
- graph[moduleName].requires = dependencies;
+ graph[ moduleName ].requires = dependencies;
$.each( dependencies, function ( depIndex, depName ) {
if ( !hasOwn.call( graph, depName ) ) {
- graph[depName] = { requiredBy: [] };
+ graph[ depName ] = { requiredBy: [] };
}
- graph[depName].requiredBy.push( moduleName );
+ graph[ depName ].requiredBy.push( moduleName );
} );
} );
return graph;
$.map( inspect.reports, function ( v, k ) { return k; } );
$.each( reports, function ( index, name ) {
- inspect.dumpTable( inspect.reports[name]() );
+ inspect.dumpTable( inspect.reports[ name ]() );
} );
},
var modules = [];
$.each( inspect.getLoadedModules(), function ( index, name ) {
- var css, stats, module = mw.loader.moduleRegistry[name];
+ var css, stats, module = mw.loader.moduleRegistry[ name ];
try {
css = module.style.css.join();
stats.totalSize = humanSize( $.byteLength( raw ) );
} catch ( e ) {}
}
- return [stats];
+ return [ stats ];
}
},
}
return $.grep( inspect.getLoadedModules(), function ( moduleName ) {
- var module = mw.loader.moduleRegistry[moduleName];
+ var module = mw.loader.moduleRegistry[ moduleName ];
// Grep module's JavaScript
if ( $.isFunction( module.script ) && pattern.test( module.script.toString() ) ) {
var i, len;
if ( !$.isArray( children ) ) {
- children = [children];
+ children = [ children ];
}
for ( i = 0, len = children.length; i < len; i++ ) {
- if ( typeof children[i] !== 'object' ) {
- children[i] = document.createTextNode( children[i] );
+ if ( typeof children[ i ] !== 'object' ) {
+ children[ i ] = document.createTextNode( children[ i ] );
}
}
return function ( args ) {
var fallback,
- key = args[0],
- argsArray = $.isArray( args[1] ) ? args[1] : slice.call( args, 1 );
+ key = args[ 0 ],
+ argsArray = $.isArray( args[ 1 ] ) ? args[ 1 ] : slice.call( args, 1 );
try {
return parser.parse( key, argsArray );
} catch ( e ) {
*/
getAst: function ( key ) {
var wikiText,
- cacheKey = [key, this.settings.onlyCurlyBraceTransform].join( ':' );
+ cacheKey = [ key, this.settings.onlyCurlyBraceTransform ].join( ':' );
if ( this.astCache[ cacheKey ] === undefined ) {
wikiText = this.settings.messages.get( key );
return function () {
var i, result;
for ( i = 0; i < ps.length; i++ ) {
- result = ps[i]();
+ result = ps[ i ]();
if ( result !== null ) {
return result;
}
originalPos = pos,
result = [];
for ( i = 0; i < ps.length; i++ ) {
- res = ps[i]();
+ res = ps[ i ]();
if ( res === null ) {
pos = originalPos;
return null;
if ( matches === null ) {
return null;
}
- pos += matches[0].length;
- return matches[0];
+ pos += matches[ 0 ].length;
+ return matches[ 0 ];
};
}
backslash,
anyCharacter
] );
- return result === null ? null : result[1];
+ return result === null ? null : result[ 1 ];
}
escapedOrLiteralWithoutSpace = choice( [
escapedLiteral,
if ( result === null ) {
return null;
}
- return [ 'REPLACE', parseInt( result[1], 10 ) - 1 ];
+ return [ 'REPLACE', parseInt( result[ 1 ], 10 ) - 1 ];
}
openExtlink = makeStringParser( '[' );
closeExtlink = makeStringParser( ']' );
closeExtlink
] );
if ( parsedResult !== null ) {
- result = [ 'EXTLINK', parsedResult[1] ];
+ result = [ 'EXTLINK', parsedResult[ 1 ] ];
// TODO (mattflaschen, 2013-03-22): Clean this up if possible.
// It's avoiding CONCAT for single nodes, so they at least doesn't get the htmlEmitter span.
- if ( parsedResult[3].length === 1 ) {
- result.push( parsedResult[3][0] );
+ if ( parsedResult[ 3 ].length === 1 ) {
+ result.push( parsedResult[ 3 ][ 0 ] );
} else {
- result.push( ['CONCAT'].concat( parsedResult[3] ) );
+ result.push( [ 'CONCAT' ].concat( parsedResult[ 3 ] ) );
}
}
return result;
if ( result === null ) {
return null;
}
- return [ 'EXTLINKPARAM', parseInt( result[2], 10 ) - 1, result[4] ];
+ return [ 'EXTLINKPARAM', parseInt( result[ 2 ], 10 ) - 1, result[ 4 ] ];
}
openWikilink = makeStringParser( '[[' );
closeWikilink = makeStringParser( ']]' );
templateContents,
closeTemplate
] );
- return result === null ? null : result[1];
+ return result === null ? null : result[ 1 ];
}
wikilinkPage = choice( [
pipe,
expression
] );
- return result === null ? null : [ result[0], result[2] ];
+ return result === null ? null : [ result[ 0 ], result[ 2 ] ];
}
wikilinkContents = choice( [
closeWikilink
] );
if ( parsedResult !== null ) {
- parsedLinkContents = parsedResult[1];
+ parsedLinkContents = parsedResult[ 1 ];
result = [ 'WIKILINK' ].concat( parsedLinkContents );
}
return result;
htmlDoubleQuoteAttributeValue,
doubleQuote
] );
- return parsedResult === null ? null : parsedResult[1];
+ return parsedResult === null ? null : parsedResult[ 1 ];
}
function singleQuotedHtmlAttributeValue() {
htmlSingleQuoteAttributeValue,
singleQuote
] );
- return parsedResult === null ? null : parsedResult[1];
+ return parsedResult === null ? null : parsedResult[ 1 ];
}
function htmlAttribute() {
singleQuotedHtmlAttributeValue
] )
] );
- return parsedResult === null ? null : [parsedResult[1], parsedResult[3]];
+ return parsedResult === null ? null : [ parsedResult[ 1 ], parsedResult[ 3 ] ];
}
/**
}
for ( i = 0, len = attributes.length; i < len; i += 2 ) {
- attributeName = attributes[i];
+ attributeName = attributes[ i ];
if ( $.inArray( attributeName, settings.allowedHtmlCommonAttributes ) === -1 &&
- $.inArray( attributeName, settings.allowedHtmlAttributesByElement[startTagName] || [] ) === -1 ) {
+ $.inArray( attributeName, settings.allowedHtmlAttributesByElement[ startTagName ] || [] ) === -1 ) {
return false;
}
}
function htmlAttributes() {
var parsedResult = nOrMore( 0, htmlAttribute )();
// Un-nest attributes array due to structure of jQueryMsg operations (see emit).
- return concat.apply( ['HTMLATTRIBUTES'], parsedResult );
+ return concat.apply( [ 'HTMLATTRIBUTES' ], parsedResult );
}
// Subset of allowed HTML markup.
}
endOpenTagPos = pos;
- startTagName = parsedOpenTagResult[1];
+ startTagName = parsedOpenTagResult[ 1 ];
parsedHtmlContents = nOrMore( 0, expression )();
}
endCloseTagPos = pos;
- endTagName = parsedCloseTagResult[1];
- wrappedAttributes = parsedOpenTagResult[2];
+ endTagName = parsedCloseTagResult[ 1 ];
+ wrappedAttributes = parsedOpenTagResult[ 2 ];
attributes = wrappedAttributes.slice( 1 );
if ( isAllowedHtml( startTagName, endTagName, attributes ) ) {
result = [ 'HTMLELEMENT', startTagName, wrappedAttributes ]
if ( result === null ) {
return null;
}
- expr = result[1];
+ expr = result[ 1 ];
// use a CONCAT operator if there are multiple nodes, otherwise return the first node, raw.
- return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[0];
+ return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[ 0 ];
}
function templateWithReplacement() {
colon,
replacement
] );
- return result === null ? null : [ result[0], result[2] ];
+ return result === null ? null : [ result[ 0 ], result[ 2 ] ];
}
function templateWithOutReplacement() {
var result = sequence( [
colon,
paramExpression
] );
- return result === null ? null : [ result[0], result[2] ];
+ return result === null ? null : [ result[ 0 ], result[ 2 ] ];
}
function templateWithOutFirstParameter() {
var result = sequence( [
templateName,
colon
] );
- return result === null ? null : [ result[0], '' ];
+ return result === null ? null : [ result[ 0 ], '' ];
}
colon = makeStringParser( ':' );
templateContents = choice( [
choice( [ templateWithReplacement, templateWithOutReplacement, templateWithOutFirstParameter ] ),
nOrMore( 0, templateParam )
] );
- return res === null ? null : res[0].concat( res[1] );
+ return res === null ? null : res[ 0 ].concat( res[ 1 ] );
},
function () {
var res = sequence( [
if ( res === null ) {
return null;
}
- return [ res[0] ].concat( res[1] );
+ return [ res[ 0 ] ].concat( res[ 1 ] );
}
] );
openTemplate = makeStringParser( '{{' );
subnodes = $.map( node.slice( 1 ), function ( n ) {
return jmsg.emit( n, replacements );
} );
- operation = node[0].toLowerCase();
- if ( typeof jmsg[operation] === 'function' ) {
+ operation = node[ 0 ].toLowerCase();
+ if ( typeof jmsg[ operation ] === 'function' ) {
ret = jmsg[ operation ]( subnodes, replacements );
} else {
throw new Error( 'Unknown operation "' + operation + '"' );
* @return {String} replacement
*/
replace: function ( nodes, replacements ) {
- var index = parseInt( nodes[0], 10 );
+ var index = parseInt( nodes[ 0 ], 10 );
if ( index < replacements.length ) {
- return replacements[index];
+ return replacements[ index ];
} else {
// index not found, fallback to displaying variable
return '$' + ( index + 1 );
wikilink: function ( nodes ) {
var page, anchor, url;
- page = nodes[0];
+ page = nodes[ 0 ];
url = mw.util.getUrl( page );
if ( nodes.length === 1 ) {
anchor = page;
} else {
// [[Some Page|anchor text]] or [[Namespace:Some Page|anchor]]
- anchor = nodes[1];
+ anchor = nodes[ 1 ];
}
return $( '<a>' ).attr( {
htmlattributes: function ( nodes ) {
var i, len, mapping = {};
for ( i = 0, len = nodes.length; i < len; i += 2 ) {
- mapping[nodes[i]] = decodePrimaryHtmlEntities( nodes[i + 1] );
+ mapping[ nodes[ i ] ] = decodePrimaryHtmlEntities( nodes[ i + 1 ] );
}
return mapping;
},
*/
extlink: function ( nodes ) {
var $el,
- arg = nodes[0],
- contents = nodes[1];
+ arg = nodes[ 0 ],
+ contents = nodes[ 1 ];
if ( arg instanceof jQuery ) {
$el = arg;
} else {
*/
extlinkparam: function ( nodes, replacements ) {
var replacement,
- index = parseInt( nodes[0], 10 );
+ index = parseInt( nodes[ 0 ], 10 );
if ( index < replacements.length ) {
- replacement = replacements[index];
+ replacement = replacements[ index ];
} else {
replacement = '$' + ( index + 1 );
}
- return this.extlink( [ replacement, nodes[1] ] );
+ return this.extlink( [ replacement, nodes[ 1 ] ] );
},
/**
var forms, firstChild, firstChildText, explicitPluralFormNumber, formIndex, form, count,
explicitPluralForms = {};
- count = parseFloat( this.language.convertNumber( nodes[0], true ) );
+ count = parseFloat( this.language.convertNumber( nodes[ 0 ], true ) );
forms = nodes.slice( 1 );
for ( formIndex = 0; formIndex < forms.length; formIndex++ ) {
- form = forms[formIndex];
+ form = forms[ formIndex ];
if ( form.jquery && form.hasClass( 'mediaWiki_htmlEmitter' ) ) {
// This is a nested node, may be an explicit plural form like 5=[$2 linktext]
if ( firstChild && firstChild.nodeType === Node.TEXT_NODE ) {
firstChildText = firstChild.textContent;
if ( /^\d+=/.test( firstChildText ) ) {
- explicitPluralFormNumber = parseInt( firstChildText.split( /=/ )[0], 10 );
+ explicitPluralFormNumber = parseInt( firstChildText.split( /=/ )[ 0 ], 10 );
// Use the digit part as key and rest of first text node and
// rest of child nodes as value.
firstChild.textContent = firstChildText.slice( firstChildText.indexOf( '=' ) + 1 );
- explicitPluralForms[explicitPluralFormNumber] = form;
- forms[formIndex] = undefined;
+ explicitPluralForms[ explicitPluralFormNumber ] = form;
+ forms[ formIndex ] = undefined;
}
}
} else if ( /^\d+=/.test( form ) ) {
// Simple explicit plural forms like 12=a dozen
- explicitPluralFormNumber = parseInt( form.split( /=/ )[0], 10 );
- explicitPluralForms[explicitPluralFormNumber] = form.slice( form.indexOf( '=' ) + 1 );
- forms[formIndex] = undefined;
+ explicitPluralFormNumber = parseInt( form.split( /=/ )[ 0 ], 10 );
+ explicitPluralForms[ explicitPluralFormNumber ] = form.slice( form.indexOf( '=' ) + 1 );
+ forms[ formIndex ] = undefined;
}
}
*/
gender: function ( nodes ) {
var gender,
- maybeUser = nodes[0],
+ maybeUser = nodes[ 0 ],
forms = nodes.slice( 1 );
if ( maybeUser === '' ) {
* @return {string} selected grammatical form according to current language
*/
grammar: function ( nodes ) {
- var form = nodes[0],
- word = nodes[1];
+ var form = nodes[ 0 ],
+ word = nodes[ 1 ];
return word && form && this.language.convertGrammar( word, form );
},
* @return {string} Other message
*/
'int': function ( nodes ) {
- var msg = nodes[0];
+ var msg = nodes[ 0 ];
return mw.jqueryMsg.getMessageFunction()( msg.charAt( 0 ).toLowerCase() + msg.slice( 1 ) );
},
* @return {number|string} Formatted number
*/
formatnum: function ( nodes ) {
- var isInteger = ( nodes[1] && nodes[1] === 'R' ) ? true : false,
- number = nodes[0];
+ var isInteger = ( nodes[ 1 ] && nodes[ 1 ] === 'R' ) ? true : false,
+ number = nodes[ 0 ];
return this.language.convertNumber( number, isInteger );
}
if ( $.isPlainObject( selection ) ) {
for ( s in selection ) {
- setGlobalMapValue( this, s, selection[s] );
+ setGlobalMapValue( this, s, selection[ s ] );
}
return true;
}
* @param {Mixed} value
*/
function setGlobalMapValue( map, key, value ) {
- map.values[key] = value;
+ map.values[ key ] = value;
mw.log.deprecate(
window,
key,
selection = slice.call( selection );
results = {};
for ( i = 0; i < selection.length; i++ ) {
- results[selection[i]] = this.get( selection[i], fallback );
+ results[ selection[ i ] ] = this.get( selection[ i ], fallback );
}
return results;
}
if ( !hasOwn.call( this.values, selection ) ) {
return fallback;
}
- return this.values[selection];
+ return this.values[ selection ];
}
if ( selection === undefined ) {
if ( $.isPlainObject( selection ) ) {
for ( s in selection ) {
- this.values[s] = selection[s];
+ this.values[ s ] = selection[ s ];
}
return true;
}
if ( typeof selection === 'string' && arguments.length > 1 ) {
- this.values[selection] = value;
+ this.values[ selection ] = value;
return true;
}
return false;
if ( $.isArray( selection ) ) {
for ( s = 0; s < selection.length; s++ ) {
- if ( typeof selection[s] !== 'string' || !hasOwn.call( this.values, selection[s] ) ) {
+ if ( typeof selection[ s ] !== 'string' || !hasOwn.call( this.values, selection[ s ] ) ) {
return false;
}
}
params: function ( parameters ) {
var i;
for ( i = 0; i < parameters.length; i += 1 ) {
- this.parameters.push( parameters[i] );
+ this.parameters.push( parameters[ i ] );
}
return this;
},
var parameters = slice.call( arguments, 1 );
return formatString.replace( /\$(\d+)/g, function ( str, match ) {
var index = parseInt( match, 10 ) - 1;
- return parameters[index] !== undefined ? parameters[index] : '$' + match;
+ return parameters[ index ] !== undefined ? parameters[ index ] : '$' + match;
} );
},
*/
trackUnsubscribe: function ( callback ) {
trackHandlers = $.grep( trackHandlers, function ( fns ) {
- if ( fns[1] === callback ) {
- trackCallbacks.remove( fns[0] );
+ if ( fns[ 1 ] === callback ) {
+ trackCallbacks.remove( fns[ 0 ] );
// Ensure the tuple is removed to avoid holding on to closures
return false;
}
* @param {string} [msg] Optional text to include in the deprecation message
*/
log.deprecate = !Object.defineProperty ? function ( obj, key, val ) {
- obj[key] = val;
+ obj[ key ] = val;
} : function ( obj, key, val, msg ) {
msg = 'Use of "' + key + '" is deprecated.' + ( msg ? ( ' ' + msg ) : '' );
// Support: IE8
} );
} catch ( err ) {
// Fallback to creating a copy of the value to the object.
- obj[key] = val;
+ obj[ key ] = val;
}
};
if ( nextnode ) {
$( nextnode ).before( s );
} else {
- document.getElementsByTagName( 'head' )[0].appendChild( s );
+ document.getElementsByTagName( 'head' )[ 0 ].appendChild( s );
}
if ( s.styleSheet ) {
// Support: IE6-10
*/
function getCombinedVersion( modules ) {
var hashes = $.map( modules, function ( module ) {
- return registry[module].version;
+ return registry[ module ].version;
} );
// Trim for consistency with server-side ResourceLoader::makeHash. It also helps
// save precious space in the limited query string. Otherwise modules are more
function allReady( modules ) {
var i;
for ( i = 0; i < modules.length; i++ ) {
- if ( mw.loader.getState( modules[i] ) !== 'ready' ) {
+ if ( mw.loader.getState( modules[ i ] ) !== 'ready' ) {
return false;
}
}
function anyFailed( modules ) {
var i, state;
for ( i = 0; i < modules.length; i++ ) {
- state = mw.loader.getState( modules[i] );
+ state = mw.loader.getState( modules[ i ] );
if ( state === 'error' || state === 'missing' ) {
return true;
}
function handlePending( module ) {
var j, job, hasErrors, m, stateChange;
- if ( registry[module].state === 'error' || registry[module].state === 'missing' ) {
+ if ( registry[ module ].state === 'error' || registry[ module ].state === 'missing' ) {
// If the current module failed, mark all dependent modules also as failed.
// Iterate until steady-state to propagate the error state upwards in the
// dependency tree.
do {
stateChange = false;
for ( m in registry ) {
- if ( registry[m].state !== 'error' && registry[m].state !== 'missing' ) {
- if ( anyFailed( registry[m].dependencies ) ) {
- registry[m].state = 'error';
+ if ( registry[ m ].state !== 'error' && registry[ m ].state !== 'missing' ) {
+ if ( anyFailed( registry[ m ].dependencies ) ) {
+ registry[ m ].state = 'error';
stateChange = true;
}
}
// Execute all jobs whose dependencies are either all satisfied or contain at least one failed module.
for ( j = 0; j < jobs.length; j += 1 ) {
- hasErrors = anyFailed( jobs[j].dependencies );
- if ( hasErrors || allReady( jobs[j].dependencies ) ) {
+ hasErrors = anyFailed( jobs[ j ].dependencies );
+ if ( hasErrors || allReady( jobs[ j ].dependencies ) ) {
// All dependencies satisfied, or some have errors
- job = jobs[j];
+ job = jobs[ j ];
jobs.splice( j, 1 );
j -= 1;
try {
if ( hasErrors ) {
if ( $.isFunction( job.error ) ) {
- job.error( new Error( 'Module ' + module + ' has failed dependencies' ), [module] );
+ job.error( new Error( 'Module ' + module + ' has failed dependencies' ), [ module ] );
}
} else {
if ( $.isFunction( job.ready ) ) {
}
}
- if ( registry[module].state === 'ready' ) {
+ if ( registry[ module ].state === 'ready' ) {
// The current module became 'ready'. Set it in the module store, and recursively execute all
// dependent modules that are loaded and now have all dependencies satisfied.
- mw.loader.store.set( module, registry[module] );
+ mw.loader.store.set( module, registry[ module ] );
for ( m in registry ) {
- if ( registry[m].state === 'loaded' && allReady( registry[m].dependencies ) ) {
+ if ( registry[ m ].state === 'loaded' && allReady( registry[ m ].dependencies ) ) {
execute( m );
}
}
throw new Error( 'Unknown dependency: ' + module );
}
- if ( registry[module].skip !== null ) {
+ if ( registry[ module ].skip !== null ) {
/*jshint evil:true */
- skip = new Function( registry[module].skip );
- registry[module].skip = null;
+ skip = new Function( registry[ module ].skip );
+ registry[ module ].skip = null;
if ( skip() ) {
- registry[module].skipped = true;
- registry[module].dependencies = [];
- registry[module].state = 'ready';
+ registry[ module ].skipped = true;
+ registry[ module ].dependencies = [];
+ registry[ module ].state = 'ready';
handlePending( module );
return;
}
}
// Resolves dynamic loader function and replaces it with its own results
- if ( $.isFunction( registry[module].dependencies ) ) {
- registry[module].dependencies = registry[module].dependencies();
+ if ( $.isFunction( registry[ module ].dependencies ) ) {
+ registry[ module ].dependencies = registry[ module ].dependencies();
// Ensures the module's dependencies are always in an array
- if ( typeof registry[module].dependencies !== 'object' ) {
- registry[module].dependencies = [registry[module].dependencies];
+ if ( typeof registry[ module ].dependencies !== 'object' ) {
+ registry[ module ].dependencies = [ registry[ module ].dependencies ];
}
}
if ( $.inArray( module, resolved ) !== -1 ) {
unresolved = {};
}
// Tracks down dependencies
- deps = registry[module].dependencies;
+ deps = registry[ module ].dependencies;
len = deps.length;
for ( n = 0; n < len; n += 1 ) {
- if ( $.inArray( deps[n], resolved ) === -1 ) {
- if ( unresolved[deps[n]] ) {
+ if ( $.inArray( deps[ n ], resolved ) === -1 ) {
+ if ( unresolved[ deps[ n ] ] ) {
throw new Error(
'Circular reference detected: ' + module +
- ' -> ' + deps[n]
+ ' -> ' + deps[ n ]
);
}
// Add to unresolved
- unresolved[module] = true;
- sortDependencies( deps[n], resolved, unresolved );
- delete unresolved[module];
+ unresolved[ module ] = true;
+ sortDependencies( deps[ n ], resolved, unresolved );
+ delete unresolved[ module ];
}
}
- resolved[resolved.length] = module;
+ resolved[ resolved.length ] = module;
}
/**
if ( !hasOwn.call( registry, module ) ) {
throw new Error( 'Module has not been registered yet: ' + module );
}
- if ( registry[module].state === 'registered' ) {
+ if ( registry[ module ].state === 'registered' ) {
throw new Error( 'Module has not been requested from the server yet: ' + module );
}
- if ( registry[module].state === 'loading' ) {
+ if ( registry[ module ].state === 'loading' ) {
throw new Error( 'Module has not completed loading yet: ' + module );
}
- if ( registry[module].state === 'ready' ) {
+ if ( registry[ module ].state === 'ready' ) {
throw new Error( 'Module has already been executed: ' + module );
}
// and their dependencies from the legacyWait (to prevent a circular dependency).
legacyModules = resolve( mw.config.get( 'wgResourceLoaderLegacyModules', [] ) );
try {
- script = registry[module].script;
+ script = registry[ module ].script;
markModuleReady = function () {
- registry[module].state = 'ready';
+ registry[ module ].state = 'ready';
handlePending( module );
};
nestedAddScript = function ( arr, callback, i ) {
return;
}
- addScript( arr[i], function () {
+ addScript( arr[ i ], function () {
nestedAddScript( arr, callback, i + 1 );
} );
};
} catch ( e ) {
// This needs to NOT use mw.log because these errors are common in production mode
// and not in debug mode, such as when a symbol that should be global isn't exported
- registry[module].state = 'error';
+ registry[ module ].state = 'error';
mw.track( 'resourceloader.exception', { exception: e, module: module, source: 'module-execute' } );
handlePending( module );
}
// (after CSS is loaded) we need to set it here right away. It is crucial that
// when execute() is called this is set synchronously, otherwise modules will get
// executed multiple times as the registry will state that it isn't loading yet.
- registry[module].state = 'loading';
+ registry[ module ].state = 'loading';
// Add localizations to message system
- if ( registry[module].messages ) {
- mw.messages.set( registry[module].messages );
+ if ( registry[ module ].messages ) {
+ mw.messages.set( registry[ module ].messages );
}
// Initialise templates
- if ( registry[module].templates ) {
- mw.templates.set( module, registry[module].templates );
+ if ( registry[ module ].templates ) {
+ mw.templates.set( module, registry[ module ].templates );
}
// Make sure we don't run the scripts until all stylesheet insertions have completed.
// * back-compat: { <media>: [url, ..] }
// * { "css": [css, ..] }
// * { "url": { <media>: [url, ..] } }
- if ( registry[module].style ) {
- for ( key in registry[module].style ) {
- value = registry[module].style[key];
+ if ( registry[ module ].style ) {
+ for ( key in registry[ module ].style ) {
+ value = registry[ module ].style[ key ];
media = undefined;
if ( key !== 'url' && key !== 'css' ) {
for ( i = 0; i < value.length; i += 1 ) {
if ( key === 'bc-url' ) {
// back-compat: { <media>: [url, ..] }
- addLink( media, value[i] );
+ addLink( media, value[ i ] );
} else if ( key === 'css' ) {
// { "css": [css, ..] }
- addEmbeddedCSS( value[i], cssHandle() );
+ addEmbeddedCSS( value[ i ], cssHandle() );
}
}
// Not an array, but a regular object
} else if ( typeof value === 'object' ) {
// { "url": { <media>: [url, ..] } }
for ( media in value ) {
- urls = value[media];
+ urls = value[ media ];
for ( i = 0; i < urls.length; i += 1 ) {
- addLink( media, urls[i] );
+ addLink( media, urls[ i ] );
}
}
}
function request( dependencies, ready, error ) {
// Allow calling by single module name
if ( typeof dependencies === 'string' ) {
- dependencies = [dependencies];
+ dependencies = [ dependencies ];
}
// Add ready and error callbacks if they were given
if ( ready !== undefined || error !== undefined ) {
- jobs[jobs.length] = {
+ jobs[ jobs.length ] = {
dependencies: $.grep( dependencies, function ( module ) {
var state = mw.loader.getState( module );
return state === 'registered' || state === 'loaded' || state === 'loading';
if ( state === 'registered' && $.inArray( module, queue ) === -1 ) {
// Private modules must be embedded in the page. Don't bother queuing
// these as the server will deny them anyway (T101806).
- if ( registry[module].group === 'private' ) {
- registry[module].state = 'error';
+ if ( registry[ module ].group === 'private' ) {
+ registry[ module ].state = 'error';
handlePending( module );
return;
}
}
a.sort();
for ( key = 0; key < a.length; key += 1 ) {
- sorted[a[key]] = o[a[key]];
+ sorted[ a[ key ] ] = o[ a[ key ] ];
}
return sorted;
}
for ( prefix in moduleMap ) {
p = prefix === '' ? '' : prefix + '.';
- arr.push( p + moduleMap[prefix].join( ',' ) );
+ arr.push( p + moduleMap[ prefix ].join( ',' ) );
}
return arr.join( '|' );
}
*/
function resolveIndexedDependencies( modules ) {
$.each( modules, function ( idx, module ) {
- if ( module[2] ) {
- module[2] = $.map( module[2], function ( dep ) {
- return typeof dep === 'number' ? modules[dep][0] : dep;
+ if ( module[ 2 ] ) {
+ module[ 2 ] = $.map( module[ 2 ], function ( dep ) {
+ return typeof dep === 'number' ? modules[ dep ][ 0 ] : dep;
} );
}
} );
// Appends a list of modules from the queue to the batch
for ( q = 0; q < queue.length; q += 1 ) {
// Only request modules which are registered
- if ( hasOwn.call( registry, queue[q] ) && registry[queue[q]].state === 'registered' ) {
+ if ( hasOwn.call( registry, queue[ q ] ) && registry[ queue[ q ] ].state === 'registered' ) {
// Prevent duplicate entries
- if ( $.inArray( queue[q], batch ) === -1 ) {
- batch[batch.length] = queue[q];
+ if ( $.inArray( queue[ q ], batch ) === -1 ) {
+ batch[ batch.length ] = queue[ q ];
// Mark registered modules as loading
- registry[queue[q]].state = 'loading';
+ registry[ queue[ q ] ].state = 'loading';
}
}
}
// the error) instead of all of them.
mw.track( 'resourceloader.exception', { exception: err, source: 'store-eval' } );
origBatch = $.grep( origBatch, function ( module ) {
- return registry[module].state === 'loading';
+ return registry[ module ].state === 'loading';
} );
batch = batch.concat( origBatch );
}
// Split batch by source and by group.
for ( b = 0; b < batch.length; b += 1 ) {
- bSource = registry[batch[b]].source;
- bGroup = registry[batch[b]].group;
+ bSource = registry[ batch[ b ] ].source;
+ bGroup = registry[ batch[ b ] ].group;
if ( !hasOwn.call( splits, bSource ) ) {
- splits[bSource] = {};
+ splits[ bSource ] = {};
}
- if ( !hasOwn.call( splits[bSource], bGroup ) ) {
- splits[bSource][bGroup] = [];
+ if ( !hasOwn.call( splits[ bSource ], bGroup ) ) {
+ splits[ bSource ][ bGroup ] = [];
}
- bSourceGroup = splits[bSource][bGroup];
- bSourceGroup[bSourceGroup.length] = batch[b];
+ bSourceGroup = splits[ bSource ][ bGroup ];
+ bSourceGroup[ bSourceGroup.length ] = batch[ b ];
}
// Clear the batch - this MUST happen before we append any
for ( source in splits ) {
- sourceLoadScript = sources[source];
+ sourceLoadScript = sources[ source ];
- for ( group in splits[source] ) {
+ for ( group in splits[ source ] ) {
// Cache access to currently selected list of
// modules for this group from this source.
- modules = splits[source][group];
+ modules = splits[ source ][ group ];
currReqBase = $.extend( {
version: getCombinedVersion( modules )
for ( i = 0; i < modules.length; i += 1 ) {
// Determine how many bytes this module would add to the query string
- lastDotIndex = modules[i].lastIndexOf( '.' );
+ lastDotIndex = modules[ i ].lastIndexOf( '.' );
// If lastDotIndex is -1, substr() returns an empty string
- prefix = modules[i].substr( 0, lastDotIndex );
- suffix = modules[i].slice( lastDotIndex + 1 );
+ prefix = modules[ i ].substr( 0, lastDotIndex );
+ suffix = modules[ i ].slice( lastDotIndex + 1 );
bytesAdded = hasOwn.call( moduleMap, prefix )
? suffix.length + 3 // '%2C'.length == 3
- : modules[i].length + 3; // '%7C'.length == 3
+ : modules[ i ].length + 3; // '%7C'.length == 3
// If the request would become too long, create a new one,
// but don't create empty requests
mw.track( 'resourceloader.splitRequest', { maxQueryLength: maxQueryLength } );
}
if ( !hasOwn.call( moduleMap, prefix ) ) {
- moduleMap[prefix] = [];
+ moduleMap[ prefix ] = [];
}
- moduleMap[prefix].push( suffix );
+ moduleMap[ prefix ].push( suffix );
l += bytesAdded;
}
// If there's anything left in moduleMap, request that too
// Allow multiple additions
if ( typeof id === 'object' ) {
for ( source in id ) {
- mw.loader.addSource( source, id[source] );
+ mw.loader.addSource( source, id[ source ] );
}
return true;
}
loadUrl = loadUrl.loadScript;
}
- sources[id] = loadUrl;
+ sources[ id ] = loadUrl;
return true;
},
resolveIndexedDependencies( module );
for ( i = 0, len = module.length; i < len; i++ ) {
// module is an array of module names
- if ( typeof module[i] === 'string' ) {
- mw.loader.register( module[i] );
+ if ( typeof module[ i ] === 'string' ) {
+ mw.loader.register( module[ i ] );
// module is an array of arrays
- } else if ( typeof module[i] === 'object' ) {
- mw.loader.register.apply( mw.loader, module[i] );
+ } else if ( typeof module[ i ] === 'object' ) {
+ mw.loader.register.apply( mw.loader, module[ i ] );
}
}
return;
throw new Error( 'module already registered: ' + module );
}
// List the module as registered
- registry[module] = {
+ registry[ module ] = {
version: version !== undefined ? String( version ) : '',
dependencies: [],
group: typeof group === 'string' ? group : null,
};
if ( typeof dependencies === 'string' ) {
// Allow dependencies to be given as a single module name
- registry[module].dependencies = [ dependencies ];
+ registry[ module ].dependencies = [ dependencies ];
} else if ( typeof dependencies === 'object' || $.isFunction( dependencies ) ) {
// Allow dependencies to be given as an array of module names
// or a function which returns an array
- registry[module].dependencies = dependencies;
+ registry[ module ].dependencies = dependencies;
}
},
mw.loader.register( module );
}
// Check for duplicate implementation
- if ( hasOwn.call( registry, module ) && registry[module].script !== undefined ) {
+ if ( hasOwn.call( registry, module ) && registry[ module ].script !== undefined ) {
throw new Error( 'module already implemented: ' + module );
}
// Attach components
- registry[module].script = script || [];
- registry[module].style = style || {};
- registry[module].messages = messages || {};
- registry[module].templates = templates || {};
+ registry[ module ].script = script || [];
+ registry[ module ].style = style || {};
+ registry[ module ].messages = messages || {};
+ registry[ module ].templates = templates || {};
// The module may already have been marked as erroneous
- if ( $.inArray( registry[module].state, ['error', 'missing'] ) === -1 ) {
- registry[module].state = 'loaded';
- if ( allReady( registry[module].dependencies ) ) {
+ if ( $.inArray( registry[ module ].state, [ 'error', 'missing' ] ) === -1 ) {
+ registry[ module ].state = 'loaded';
+ if ( allReady( registry[ module ].dependencies ) ) {
execute( module );
}
}
if ( typeof module === 'object' ) {
for ( m in module ) {
- mw.loader.state( m, module[m] );
+ mw.loader.state( m, module[ m ] );
}
return;
}
if ( !hasOwn.call( registry, module ) ) {
mw.loader.register( module );
}
- if ( $.inArray( state, ['ready', 'error', 'missing'] ) !== -1
- && registry[module].state !== state ) {
+ if ( $.inArray( state, [ 'ready', 'error', 'missing' ] ) !== -1
+ && registry[ module ].state !== state ) {
// Make sure pending modules depending on this one get executed if their
// dependencies are now fulfilled!
- registry[module].state = state;
+ registry[ module ].state = state;
handlePending( module );
} else {
- registry[module].state = state;
+ registry[ module ].state = state;
}
},
* in the registry.
*/
getVersion: function ( module ) {
- if ( !hasOwn.call( registry, module ) || registry[module].version === undefined ) {
+ if ( !hasOwn.call( registry, module ) || registry[ module ].version === undefined ) {
return null;
}
- return registry[module].version;
+ return registry[ module ].version;
},
/**
* in the registry.
*/
getState: function ( module ) {
- if ( !hasOwn.call( registry, module ) || registry[module].state === undefined ) {
+ if ( !hasOwn.call( registry, module ) || registry[ module ].state === undefined ) {
return null;
}
- return registry[module].state;
+ return registry[ module ].state;
},
/**
*/
getModuleKey: function ( module ) {
return hasOwn.call( registry, module ) ?
- ( module + '@' + registry[module].version ) : null;
+ ( module + '@' + registry[ module ].version ) : null;
},
/**
key = mw.loader.store.getModuleKey( module );
if ( key in mw.loader.store.items ) {
mw.loader.store.stats.hits++;
- return mw.loader.store.items[key];
+ return mw.loader.store.items[ key ];
}
mw.loader.store.stats.misses++;
return false;
];
// Attempted workaround for a possible Opera bug (bug T59567).
// This regex should never match under sane conditions.
- if ( /^\s*\(/.test( args[1] ) ) {
- args[1] = 'function' + args[1];
+ if ( /^\s*\(/.test( args[ 1 ] ) ) {
+ args[ 1 ] = 'function' + args[ 1 ];
mw.track( 'resourceloader.assert', { source: 'bug-T59567' } );
}
} catch ( e ) {
if ( src.length > mw.loader.store.MODULE_SIZE_MAX ) {
return false;
}
- mw.loader.store.items[key] = src;
+ mw.loader.store.items[ key ] = src;
mw.loader.store.update();
},
module = key.slice( 0, key.indexOf( '@' ) );
if ( mw.loader.store.getModuleKey( module ) !== key ) {
mw.loader.store.stats.expired++;
- delete mw.loader.store.items[key];
- } else if ( mw.loader.store.items[key].length > mw.loader.store.MODULE_SIZE_MAX ) {
+ delete mw.loader.store.items[ key ];
+ } else if ( mw.loader.store.items[ key ].length > mw.loader.store.MODULE_SIZE_MAX ) {
// This value predates the enforcement of a size limit on cached modules.
- delete mw.loader.store.items[key];
+ delete mw.loader.store.items[ key ];
}
}
},
var v, attrName, s = '<' + name;
for ( attrName in attrs ) {
- v = attrs[attrName];
+ v = attrs[ attrName ];
// Convert name=true, to name=name
if ( v === true ) {
v = attrName;
*/
return function ( name ) {
var list = hasOwn.call( lists, name ) ?
- lists[name] :
- lists[name] = $.Callbacks( 'memory' );
+ lists[ name ] :
+ lists[ name ] = $.Callbacks( 'memory' );
return {
/**
$notifications.each( function () {
var notif = $( this ).data( 'mw.notification' );
if ( notif ) {
- notif[fn]();
+ notif[ fn ]();
}
} );
}
// Compatibility map
map = {
// SimpleSearch is broken in Opera < 9.6
- opera: [['>=', 9.6]],
+ opera: [ [ '>=', 9.6 ] ],
// Older Konquerors are unable to position the suggestions correctly (bug 50805)
- konqueror: [['>=', '4.11']],
+ konqueror: [ [ '>=', '4.11' ] ],
docomo: false,
blackberry: false,
// Support for iOS 6 or higher. It has not been tested on iOS 5 or lower
- ipod: [['>=', 6]],
- iphone: [['>=', 6]]
+ ipod: [ [ '>=', 6 ] ],
+ iphone: [ [ '>=', 6 ] ]
};
if ( !$.client.test( map ) ) {
$( searchboxesSelectors.join( ', ' ) )
.suggestions( {
fetch: function ( query, response, maxRows ) {
- var node = this[0];
+ var node = this[ 0 ];
api = api || new mw.Api();
$.data( node, 'request', mw.searchSuggest.request( api, query, response, maxRows ) );
},
cancel: function () {
- var node = this[0],
+ var node = this[ 0 ],
request = $.data( node, 'request' );
if ( request ) {
if ( !compiler.compile ) {
throw new Error( 'Compiler must implement compile method.' );
}
- compilers[name] = compiler;
+ compilers[ name ] = compiler;
},
/**
var compiledTemplate,
compilerName = this.getCompilerName( templateName );
- if ( !compiledTemplates[moduleName] ) {
- compiledTemplates[moduleName] = {};
+ if ( !compiledTemplates[ moduleName ] ) {
+ compiledTemplates[ moduleName ] = {};
}
compiledTemplate = this.compile( templateBody, compilerName );
- compiledTemplates[moduleName][ templateName ] = compiledTemplate;
+ compiledTemplates[ moduleName ][ templateName ] = compiledTemplate;
return compiledTemplate;
},
*/
function getUserInfo( info ) {
var api;
- if ( !deferreds[info] ) {
+ if ( !deferreds[ info ] ) {
deferreds.rights = $.Deferred();
deferreds.groups = $.Deferred();
}
- return deferreds[info].promise();
+ return deferreds[ info ].promise();
}
// Map from numbers 0-255 to a hex string (with padding)
for ( i = 0; i < 256; i++ ) {
// Padding: Add a full byte (0x100, 256) and strip the extra character
- byteToHex[i] = ( i + 256 ).toString( 16 ).slice( 1 );
+ byteToHex[ i ] = ( i + 256 ).toString( 16 ).slice( 1 );
}
// mw.user with the properties options and tokens gets defined in mediawiki.js.
if ( ( i & 3 ) === 0 ) {
r = Math.random() * 0x100000000;
}
- rnds[i] = r >>> ( ( i & 3 ) << 3 ) & 255;
+ rnds[ i ] = r >>> ( ( i & 3 ) << 3 ) & 255;
}
}
// Convert from number to hex
for ( i = 0; i < 8; i++ ) {
- hexRnds[i] = byteToHex[rnds[i]];
+ hexRnds[ i ] = byteToHex[ rnds[ i ] ];
}
// Concatenation of two random integers with entrophy n and m
// Bucket information is stored as 2 integers, together as version:bucket like: "1:2"
if ( typeof cookie === 'string' && cookie.length > 2 && cookie.indexOf( ':' ) !== -1 ) {
parts = cookie.split( ':' );
- if ( parts.length > 1 && Number( parts[0] ) === options.version ) {
- version = Number( parts[0] );
- bucket = String( parts[1] );
+ if ( parts.length > 1 && Number( parts[ 0 ] ) === options.version ) {
+ version = Number( parts[ 0 ] );
+ bucket = String( parts[ 1 ] );
}
}
// Find range
range = 0;
for ( k in options.buckets ) {
- range += options.buckets[k];
+ range += options.buckets[ k ];
}
// Select random value within range
total = 0;
for ( k in options.buckets ) {
bucket = k;
- total += options.buckets[k];
+ total += options.buckets[ k ];
if ( total >= rand ) {
break;
}
config = {
fetch: function ( userInput, response, maxRows ) {
- var node = this[0];
+ var node = this[ 0 ];
api = api || new mw.Api();
list: 'allusers',
// Prefix of list=allusers is case sensitive. Normalise first
// character to uppercase so that "fo" may yield "Foo".
- auprefix: userInput[0].toUpperCase() + userInput.slice( 1 ),
+ auprefix: userInput[ 0 ].toUpperCase() + userInput.slice( 1 ),
aulimit: maxRows
} ).done( function ( data ) {
var users = $.map( data.query.allusers, function ( userObj ) {
} ) );
},
cancel: function () {
- var node = this[0],
+ var node = this[ 0 ],
request = $.data( node, 'request' );
if ( request ) {
];
for ( i = 0, l = selectors.length; i < l; i++ ) {
- $node = $( selectors[i] );
+ $node = $( selectors[ i ] );
if ( $node.length ) {
return $node.first();
}
if ( m ) {
// Beware that decodeURIComponent is not required to understand '+'
// by spec, as encodeURIComponent does not produce it.
- return decodeURIComponent( m[1].replace( /\+/g, '%20' ) );
+ return decodeURIComponent( m[ 1 ].replace( /\+/g, '%20' ) );
}
return null;
},
// Error: Invalid nextnode
nextnode = undefined;
}
- if ( nextnode && ( nextnode.length !== 1 || nextnode[0].parentNode !== $ul[0] ) ) {
+ if ( nextnode && ( nextnode.length !== 1 || nextnode[ 0 ].parentNode !== $ul[ 0 ] ) ) {
// Error: nextnode must resolve to a single node
// Error: nextnode must have the associated <ul> as its parent
nextnode = undefined;
// to get a localized access key label (bug 67946).
$link.updateTooltipAccessKeys();
- return $item[0];
+ return $item[ 0 ];
},
/**
// Browsers with outdated or limited JavaScript engines get the no-JS experience
return !(
// Internet Explorer < 8
- ( ua.indexOf( 'MSIE' ) !== -1 && parseFloat( ua.split( 'MSIE' )[1] ) < 8 ) ||
+ ( ua.indexOf( 'MSIE' ) !== -1 && parseFloat( ua.split( 'MSIE' )[ 1 ] ) < 8 ) ||
// Firefox < 3
- ( ua.indexOf( 'Firefox/' ) !== -1 && parseFloat( ua.split( 'Firefox/' )[1] ) < 3 ) ||
+ ( ua.indexOf( 'Firefox/' ) !== -1 && parseFloat( ua.split( 'Firefox/' )[ 1 ] ) < 3 ) ||
// Opera < 12
( ua.indexOf( 'Opera/' ) !== -1 && ( ua.indexOf( 'Version/' ) === -1 ?
// "Opera/x.y"
- parseFloat( ua.split( 'Opera/' )[1] ) < 10 :
+ parseFloat( ua.split( 'Opera/' )[ 1 ] ) < 10 :
// "Opera/9.80 ... Version/x.y"
- parseFloat( ua.split( 'Version/' )[1] ) < 12
+ parseFloat( ua.split( 'Version/' )[ 1 ] ) < 12
) ) ||
// "Mozilla/0.0 ... Opera x.y"
- ( ua.indexOf( 'Opera ' ) !== -1 && parseFloat( ua.split( ' Opera ' )[1] ) < 10 ) ||
+ ( ua.indexOf( 'Opera ' ) !== -1 && parseFloat( ua.split( ' Opera ' )[ 1 ] ) < 10 ) ||
// BlackBerry < 6
ua.match( /BlackBerry[^\/]*\/[1-5]\./ ) ||
// Open WebOS < 1.5
startUp();
}
};
- document.getElementsByTagName( 'head' )[0].appendChild( script );
+ document.getElementsByTagName( 'head' )[ 0 ].appendChild( script );
}() );
sinon.config = {
injectIntoThis: true,
injectInto: null,
- properties: ['spy', 'stub', 'mock', 'sandbox'],
+ properties: [ 'spy', 'stub', 'mock', 'sandbox' ],
// Don't fake timers by default
useFakeTimers: false,
useFakeServer: false
children = $node.contents();
processedChildren = [];
for ( i = 0, len = children.length; i < len; i++ ) {
- el = children[i];
+ el = children[ i ];
if ( el.nodeType === Node.ELEMENT_NODE || el.nodeType === Node.TEXT_NODE ) {
processedChildren.push( getDomStructure( el ) );
}
* @param {string} html HTML markup for one or more nodes.
*/
function getHtmlStructure( html ) {
- var el = $( '<div>' ).append( html )[0];
+ var el = $( '<div>' ).append( html )[ 0 ];
return getDomStructure( el );
}
missing = [];
for ( i = 0, len = modules.length; i < len; i++ ) {
- state = mw.loader.getState( modules[i] );
+ state = mw.loader.getState( modules[ i ] );
if ( state === 'error' ) {
- error.push( modules[i] );
+ error.push( modules[ i ] );
} else if ( state === 'missing' ) {
- missing.push( modules[i] );
+ missing.push( modules[ i ] );
}
}
var getAccessKeyPrefixTestData = [
// ua string, platform string, expected prefix
// Internet Explorer
- ['Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', 'Win32', 'alt-'],
- ['Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)', 'Win32', 'alt-'],
- ['Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; rv:11.0) like Gecko', 'Win64', 'alt-'],
+ [ 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', 'Win32', 'alt-' ],
+ [ 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)', 'Win32', 'alt-' ],
+ [ 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; rv:11.0) like Gecko', 'Win64', 'alt-' ],
// Firefox
- ['Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19', 'MacIntel', 'ctrl-'],
- ['Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/10.10 (maverick) Firefox/3.6.17', 'Linux i686', 'alt-shift-'],
- ['Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1', 'Win32', 'alt-shift-'],
+ [ 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19', 'MacIntel', 'ctrl-' ],
+ [ 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/10.10 (maverick) Firefox/3.6.17', 'Linux i686', 'alt-shift-' ],
+ [ 'Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1', 'Win32', 'alt-shift-' ],
// Safari / Konqueror
- ['Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; nl-nl) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7', 'MacIntel', 'ctrl-alt-'],
- ['Mozilla/5.0 (Windows; U; Windows NT 6.0; cs-CZ) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7', 'Win32', 'alt-'],
- ['Mozilla/5.0 (X11; Linux i686) KHTML/4.9.1 (like Gecko) Konqueror/4.9', 'Linux i686', 'ctrl-'],
+ [ 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; nl-nl) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7', 'MacIntel', 'ctrl-alt-' ],
+ [ 'Mozilla/5.0 (Windows; U; Windows NT 6.0; cs-CZ) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7', 'Win32', 'alt-' ],
+ [ 'Mozilla/5.0 (X11; Linux i686) KHTML/4.9.1 (like Gecko) Konqueror/4.9', 'Linux i686', 'ctrl-' ],
// Opera
- ['Opera/9.80 (Windows NT 5.1)', 'Win32', 'shift-esc-'],
- ['Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.130', 'Win32', 'shift-esc-'],
+ [ 'Opera/9.80 (Windows NT 5.1)', 'Win32', 'shift-esc-' ],
+ [ 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.130', 'Win32', 'shift-esc-' ],
// Chrome
- ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30', 'MacIntel', 'ctrl-option-'],
- ['Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.68 Safari/534.30', 'Linux i686', 'alt-shift-']
+ [ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30', 'MacIntel', 'ctrl-option-' ],
+ [ 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.68 Safari/534.30', 'Linux i686', 'alt-shift-' ]
],
// strings appended to title to make sure updateTooltipAccessKeys handles them correctly
updateTooltipAccessKeysTestData = [ '', ' [a]', ' [test-a]', ' [alt-b]' ];
var i;
for ( i = 0; i < getAccessKeyPrefixTestData.length; i++ ) {
assert.equal( $.fn.updateTooltipAccessKeys.getAccessKeyPrefix( {
- userAgent: getAccessKeyPrefixTestData[i][0],
- platform: getAccessKeyPrefixTestData[i][1]
- } ), getAccessKeyPrefixTestData[i][2], 'Correct prefix for ' + getAccessKeyPrefixTestData[i][0] );
+ userAgent: getAccessKeyPrefixTestData[ i ][ 0 ],
+ platform: getAccessKeyPrefixTestData[ i ][ 1 ]
+ } ), getAccessKeyPrefixTestData[ i ][ 2 ], 'Correct prefix for ' + getAccessKeyPrefixTestData[ i ][ 0 ] );
}
} );
// (no browser is known using such a short prefix, though) or "Alt+Umschalt+" in German Firefox.
result = /^Title \[(.+)[aA]\]$/.exec( title );
assert.ok( result, 'title should match expected structure.' );
- assert.notEqual( result[1], 'test-', 'Prefix used for testing shouldn\'t be used in production.' );
+ assert.notEqual( result[ 1 ], 'test-', 'Prefix used for testing shouldn\'t be used in production.' );
} );
QUnit.test( 'updateTooltipAccessKeys - no access key', updateTooltipAccessKeysTestData.length, function ( assert ) {
var i, oldTitle, $input, newTitle;
for ( i = 0; i < updateTooltipAccessKeysTestData.length; i++ ) {
- oldTitle = 'Title' + updateTooltipAccessKeysTestData[i];
+ oldTitle = 'Title' + updateTooltipAccessKeysTestData[ i ];
$input = $( makeInput( oldTitle ) );
$( '#qunit-fixture' ).append( $input );
newTitle = $input.updateTooltipAccessKeys().prop( 'title' );
$.fn.updateTooltipAccessKeys.setTestMode( true );
var i, oldTitle, $input, newTitle;
for ( i = 0; i < updateTooltipAccessKeysTestData.length; i++ ) {
- oldTitle = 'Title' + updateTooltipAccessKeysTestData[i];
+ oldTitle = 'Title' + updateTooltipAccessKeysTestData[ i ];
$input = $( makeInput( oldTitle, 'a' ) );
$( '#qunit-fixture' ).append( $input );
newTitle = $input.updateTooltipAccessKeys().prop( 'title' );
function findDivergenceIndex( a, b ) {
var i = 0;
- while ( i < a.length && i < b.length && a[i] === b[i] ) {
+ while ( i < a.length && i < b.length && a[ i ] === b[ i ] ) {
i++;
}
return i;
// Add two characters using scary black magic
spanText = $span.text();
d = findDivergenceIndex( origText, spanText );
- spanTextNew = spanText.slice( 0, d ) + origText[d] + origText[d] + '...';
+ spanTextNew = spanText.slice( 0, d ) + origText[ d ] + origText[ d ] + '...';
assert.gt( spanTextNew.length, spanText.length, 'Verify that the new span-length is indeed greater' );
$canvas.animate( { backgroundColor: '#000' }, 10 ).promise().then( function () {
var endColors = $.colorUtil.getRGB( $canvas.css( 'background-color' ) );
- assert.deepEqual( endColors, [0, 0, 0], 'end state' );
+ assert.deepEqual( endColors, [ 0, 0, 0 ], 'end state' );
} );
this.clock.tick( 20 );
QUnit.test( 'getRGB', 18, function ( assert ) {
assert.strictEqual( $.colorUtil.getRGB(), undefined, 'No arguments' );
assert.strictEqual( $.colorUtil.getRGB( '' ), undefined, 'Empty string' );
- assert.deepEqual( $.colorUtil.getRGB( [0, 100, 255] ), [0, 100, 255], 'Parse array of rgb values' );
- assert.deepEqual( $.colorUtil.getRGB( 'rgb(0,100,255)' ), [0, 100, 255], 'Parse simple rgb string' );
- assert.deepEqual( $.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [0, 100, 255], 'Parse simple rgb string with spaces' );
- assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [0, 51, 102], 'Parse rgb string with percentages' );
- assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [0, 51, 102], 'Parse rgb string with percentages and spaces' );
- assert.deepEqual( $.colorUtil.getRGB( '#f2ddee' ), [242, 221, 238], 'Hex string: 6 char lowercase' );
- assert.deepEqual( $.colorUtil.getRGB( '#f2DDEE' ), [242, 221, 238], 'Hex string: 6 char uppercase' );
- assert.deepEqual( $.colorUtil.getRGB( '#f2DdEe' ), [242, 221, 238], 'Hex string: 6 char mixed' );
- assert.deepEqual( $.colorUtil.getRGB( '#eee' ), [238, 238, 238], 'Hex string: 3 char lowercase' );
- assert.deepEqual( $.colorUtil.getRGB( '#EEE' ), [238, 238, 238], 'Hex string: 3 char uppercase' );
- assert.deepEqual( $.colorUtil.getRGB( '#eEe' ), [238, 238, 238], 'Hex string: 3 char mixed' );
- assert.deepEqual( $.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [255, 255, 255], 'Zero rgba for Safari 3; Transparent (whitespace)' );
+ assert.deepEqual( $.colorUtil.getRGB( [ 0, 100, 255 ] ), [ 0, 100, 255 ], 'Parse array of rgb values' );
+ assert.deepEqual( $.colorUtil.getRGB( 'rgb(0,100,255)' ), [ 0, 100, 255 ], 'Parse simple rgb string' );
+ assert.deepEqual( $.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [ 0, 100, 255 ], 'Parse simple rgb string with spaces' );
+ assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [ 0, 51, 102 ], 'Parse rgb string with percentages' );
+ assert.deepEqual( $.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [ 0, 51, 102 ], 'Parse rgb string with percentages and spaces' );
+ assert.deepEqual( $.colorUtil.getRGB( '#f2ddee' ), [ 242, 221, 238 ], 'Hex string: 6 char lowercase' );
+ assert.deepEqual( $.colorUtil.getRGB( '#f2DDEE' ), [ 242, 221, 238 ], 'Hex string: 6 char uppercase' );
+ assert.deepEqual( $.colorUtil.getRGB( '#f2DdEe' ), [ 242, 221, 238 ], 'Hex string: 6 char mixed' );
+ assert.deepEqual( $.colorUtil.getRGB( '#eee' ), [ 238, 238, 238 ], 'Hex string: 3 char lowercase' );
+ assert.deepEqual( $.colorUtil.getRGB( '#EEE' ), [ 238, 238, 238 ], 'Hex string: 3 char uppercase' );
+ assert.deepEqual( $.colorUtil.getRGB( '#eEe' ), [ 238, 238, 238 ], 'Hex string: 3 char mixed' );
+ assert.deepEqual( $.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [ 255, 255, 255 ], 'Zero rgba for Safari 3; Transparent (whitespace)' );
// Perhaps this is a bug in colorUtil, but it is the current behavior so, let's keep
// track of it, so we will know in case it would ever change.
assert.strictEqual( $.colorUtil.getRGB( 'rgba(0,0,0,0)' ), undefined, 'Zero rgba without whitespace' );
- assert.deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' );
- assert.deepEqual( $.colorUtil.getRGB( 'transparent' ), [255, 255, 255], 'Color names (transparent)' );
+ assert.deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [ 144, 238, 144 ], 'Color names (lightGreen)' );
+ assert.deepEqual( $.colorUtil.getRGB( 'transparent' ), [ 255, 255, 255 ], 'Color names (transparent)' );
assert.strictEqual( $.colorUtil.getRGB( 'mediaWiki' ), undefined, 'Inexisting color name' );
} );
// Re-create the rgbToHsl return array items, limited to two decimals.
hsl = $.colorUtil.rgbToHsl( 144, 238, 144 );
- ret = [ dualDecimals( hsl[0] ), dualDecimals( hsl[1] ), dualDecimals( hsl[2] ) ];
+ ret = [ dualDecimals( hsl[ 0 ] ), dualDecimals( hsl[ 1 ] ), dualDecimals( hsl[ 2 ] ) ];
- assert.deepEqual( ret, [0.33, 0.73, 0.75], 'rgb(144, 238, 144): hsl(0.33, 0.73, 0.75)' );
+ assert.deepEqual( ret, [ 0.33, 0.73, 0.75 ], 'rgb(144, 238, 144): hsl(0.33, 0.73, 0.75)' );
} );
QUnit.test( 'hslToRgb', 1, function ( assert ) {
rgb = $.colorUtil.hslToRgb( 0.3, 0.7, 0.8 );
// Re-create the hslToRgb return array items, rounded to whole numbers.
- ret = [ Math.round( rgb[0] ), Math.round( rgb[1] ), Math.round( rgb[2] ) ];
+ ret = [ Math.round( rgb[ 0 ] ), Math.round( rgb[ 1 ] ), Math.round( rgb[ 2 ] ) ];
- assert.deepEqual( ret, [183, 240, 168], 'hsl(0.3, 0.7, 0.8): rgb(183, 240, 168)' );
+ assert.deepEqual( ret, [ 183, 240, 168 ], 'hsl(0.3, 0.7, 0.8): rgb(183, 240, 168)' );
} );
QUnit.test( 'getColorBrightness', 2, function ( assert ) {
html = '<div><span><html:msg key="foo-welcome" /></span></div>';
$lc = $( html ).localize( {
params: {
- 'foo-welcome': [sitename, 'yesterday']
+ 'foo-welcome': [ sitename, 'yesterday' ]
}
} ).find( 'span' );
'label': x + '-label'
},
params: {
- 'title': [sitename, '3 minutes ago'],
- 'label': [sitename, '3 minutes ago']
+ 'title': [ sitename, '3 minutes ago' ],
+ 'label': [ sitename, '3 minutes ago' ]
}
} ).find( 'span' );
} );
QUnit.test( 'Comparison functions', 5, function ( assert ) {
- assert.ok( $.compareArray( [0, 'a', [], [2, 'b'] ], [0, 'a', [], [2, 'b'] ] ),
+ assert.ok( $.compareArray( [ 0, 'a', [], [ 2, 'b' ] ], [ 0, 'a', [], [ 2, 'b' ] ] ),
'compareArray: Two deep arrays that are excactly the same' );
- assert.ok( !$.compareArray( [1], [2] ), 'compareArray: Two different arrays (false)' );
+ assert.ok( !$.compareArray( [ 1 ], [ 2 ] ), 'compareArray: Two different arrays (false)' );
assert.ok( $.compareObject( {}, {} ), 'compareObject: Two empty objects' );
assert.ok( $.compareObject( { foo: 1 }, { foo: 1 } ), 'compareObject: Two the same objects' );
'</form>',
testElement = function ( $el, assert ) {
- var el = $el[0],
+ var el = $el[ 0 ],
placeholder = el.getAttribute( 'placeholder' );
assert.strictEqual( $el.placeholder(), $el, 'should be chainable' );
var selector = '#input-type-password',
$el = $( selector ),
- el = $el[0],
+ el = $el[ 0 ],
placeholder = el.getAttribute( 'placeholder' );
assert.strictEqual( $el.placeholder(), $el, 'should be chainable' );
// Re-select the element, as it gets replaced by another one in some browsers
$el = $( selector );
- el = $el[0];
+ el = $el[ 0 ];
assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' );
assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' );
// Re-select the element, as it gets replaced by another one in some browsers
$el = $( selector );
- el = $el[0];
+ el = $el[ 0 ];
assert.strictEqual( el.value, '', '`value` should be the empty string on focus' );
assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' );
// Re-select the element, as it gets replaced by another one in some browsers
$el = $( selector );
- el = $el[0];
+ el = $el[ 0 ];
assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' );
assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' );
this.liveMonths = mw.language.months;
mw.language.months = {
'keys': {
- 'names': ['january', 'february', 'march', 'april', 'may_long', 'june',
- 'july', 'august', 'september', 'october', 'november', 'december'],
- 'genitive': ['january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen',
- 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen'],
- 'abbrev': ['jan', 'feb', 'mar', 'apr', 'may', 'jun',
- 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
+ 'names': [ 'january', 'february', 'march', 'april', 'may_long', 'june',
+ 'july', 'august', 'september', 'october', 'november', 'december' ],
+ 'genitive': [ 'january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen',
+ 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen' ],
+ 'abbrev': [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun',
+ 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ]
},
- 'names': ['January', 'February', 'March', 'April', 'May', 'June',
- 'July', 'August', 'September', 'October', 'November', 'December'],
- 'genitive': ['January', 'February', 'March', 'April', 'May', 'June',
- 'July', 'August', 'September', 'October', 'November', 'December'],
- 'abbrev': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+ 'names': [ 'January', 'February', 'March', 'April', 'May', 'June',
+ 'July', 'August', 'September', 'October', 'November', 'December' ],
+ 'genitive': [ 'January', 'February', 'March', 'April', 'May', 'June',
+ 'July', 'August', 'September', 'October', 'November', 'December' ],
+ 'abbrev': [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]
};
},
teardown: function () {
/* default date format of the content language */
wgDefaultDateFormat: 'dmy',
/* These two are important for numeric interpretations */
- wgSeparatorTransformTable: ['', ''],
- wgDigitTransformTable: ['', '']
+ wgSeparatorTransformTable: [ '', '' ],
+ wgDigitTransformTable: [ '', '' ]
}
} ) );
parser = $.tablesorter.getParser( parserId );
$.each( data, function ( index, testcase ) {
- extractedR = parser.is( testcase[0] );
- extractedF = parser.format( testcase[0] );
+ extractedR = parser.is( testcase[ 0 ] );
+ extractedF = parser.format( testcase[ 0 ] );
- assert.strictEqual( extractedR, testcase[1], 'Detect: ' + testcase[3] );
- assert.strictEqual( extractedF, testcase[2], 'Sortkey: ' + testcase[3] );
+ assert.strictEqual( extractedR, testcase[ 1 ], 'Detect: ' + testcase[ 3 ] );
+ assert.strictEqual( extractedF, testcase[ 2 ], 'Sortkey: ' + testcase[ 3 ] );
} );
} );
ipv4 = [
// Some randomly generated fake IPs
- ['0.0.0.0', true, 0, 'An IP address' ],
- ['255.255.255.255', true, 255255255255, 'An IP address' ],
- ['45.238.27.109', true, 45238027109, 'An IP address' ],
- ['1.238.27.1', true, 1238027001, 'An IP address with small numbers' ],
- ['238.27.1', false, 238027001, 'A malformed IP Address' ],
- ['1', false, 1, 'A super malformed IP Address' ],
- ['Just text', false, 0, 'A line with just text' ],
- ['45.238.27.109Postfix', false, 45238027109, 'An IP address with a connected postfix' ],
- ['45.238.27.109 postfix', false, 45238027109, 'An IP address with a seperated postfix' ]
+ [ '0.0.0.0', true, 0, 'An IP address' ],
+ [ '255.255.255.255', true, 255255255255, 'An IP address' ],
+ [ '45.238.27.109', true, 45238027109, 'An IP address' ],
+ [ '1.238.27.1', true, 1238027001, 'An IP address with small numbers' ],
+ [ '238.27.1', false, 238027001, 'A malformed IP Address' ],
+ [ '1', false, 1, 'A super malformed IP Address' ],
+ [ 'Just text', false, 0, 'A line with just text' ],
+ [ '45.238.27.109Postfix', false, 45238027109, 'An IP address with a connected postfix' ],
+ [ '45.238.27.109 postfix', false, 45238027109, 'An IP address with a seperated postfix' ]
];
parserTest( 'IPv4', 'IPAddress', ipv4 );
simpleMDYDatesInMDY = [
- ['January 17, 2010', true, 20100117, 'Long middle endian date'],
- ['Jan 17, 2010', true, 20100117, 'Short middle endian date'],
- ['1/17/2010', true, 20100117, 'Numeric middle endian date'],
- ['01/17/2010', true, 20100117, 'Numeric middle endian date with padding on month'],
- ['01/07/2010', true, 20100107, 'Numeric middle endian date with padding on day'],
- ['01/07/0010', true, 20100107, 'Numeric middle endian date with padding on year'],
- ['5.12.1990', true, 19900512, 'Numeric middle endian date with . separator']
+ [ 'January 17, 2010', true, 20100117, 'Long middle endian date' ],
+ [ 'Jan 17, 2010', true, 20100117, 'Short middle endian date' ],
+ [ '1/17/2010', true, 20100117, 'Numeric middle endian date' ],
+ [ '01/17/2010', true, 20100117, 'Numeric middle endian date with padding on month' ],
+ [ '01/07/2010', true, 20100107, 'Numeric middle endian date with padding on day' ],
+ [ '01/07/0010', true, 20100107, 'Numeric middle endian date with padding on year' ],
+ [ '5.12.1990', true, 19900512, 'Numeric middle endian date with . separator' ]
];
parserTest( 'MDY Dates using mdy content language', 'date', simpleMDYDatesInMDY );
simpleMDYDatesInDMY = [
- ['January 17, 2010', true, 20100117, 'Long middle endian date'],
- ['Jan 17, 2010', true, 20100117, 'Short middle endian date'],
- ['1/17/2010', true, 20101701, 'Numeric middle endian date'],
- ['01/17/2010', true, 20101701, 'Numeric middle endian date with padding on month'],
- ['01/07/2010', true, 20100701, 'Numeric middle endian date with padding on day'],
- ['01/07/0010', true, 20100701, 'Numeric middle endian date with padding on year'],
- ['5.12.1990', true, 19901205, 'Numeric middle endian date with . separator']
+ [ 'January 17, 2010', true, 20100117, 'Long middle endian date' ],
+ [ 'Jan 17, 2010', true, 20100117, 'Short middle endian date' ],
+ [ '1/17/2010', true, 20101701, 'Numeric middle endian date' ],
+ [ '01/17/2010', true, 20101701, 'Numeric middle endian date with padding on month' ],
+ [ '01/07/2010', true, 20100701, 'Numeric middle endian date with padding on day' ],
+ [ '01/07/0010', true, 20100701, 'Numeric middle endian date with padding on year' ],
+ [ '5.12.1990', true, 19901205, 'Numeric middle endian date with . separator' ]
];
parserTest( 'MDY Dates using dmy content language', 'date', simpleMDYDatesInDMY, function () {
mw.config.set( {
} );
oldMDYDates = [
- ['January 19, 1400 BC', false, '99999999', 'BC'],
- ['January 19, 1400BC', false, '99999999', 'Connected BC'],
- ['January, 19 1400 B.C.', false, '99999999', 'B.C.'],
- ['January 19, 1400 AD', false, '99999999', 'AD'],
- ['January, 19 10', true, 20100119, 'AD'],
- ['January, 19 1', false, '99999999', 'AD']
+ [ 'January 19, 1400 BC', false, '99999999', 'BC' ],
+ [ 'January 19, 1400BC', false, '99999999', 'Connected BC' ],
+ [ 'January, 19 1400 B.C.', false, '99999999', 'B.C.' ],
+ [ 'January 19, 1400 AD', false, '99999999', 'AD' ],
+ [ 'January, 19 10', true, 20100119, 'AD' ],
+ [ 'January, 19 1', false, '99999999', 'AD' ]
];
parserTest( 'Very old MDY dates', 'date', oldMDYDates );
complexMDYDates = [
- ['January, 19 2010', true, 20100119, 'Comma after month'],
- ['January 19, 2010', true, 20100119, 'Comma after day'],
- ['January/19/2010', true, 20100119, 'Forward slash separator'],
- ['04 22 1991', true, 19910422, 'Month with 0 padding'],
- ['April 21 1991', true, 19910421, 'Space separation'],
- ['04 22 1991', true, 19910422, 'Month with 0 padding'],
- ['December 12 \'10', true, 20101212, ''],
- ['Dec 12 \'10', true, 20101212, ''],
- ['Dec. 12 \'10', true, 20101212, '']
+ [ 'January, 19 2010', true, 20100119, 'Comma after month' ],
+ [ 'January 19, 2010', true, 20100119, 'Comma after day' ],
+ [ 'January/19/2010', true, 20100119, 'Forward slash separator' ],
+ [ '04 22 1991', true, 19910422, 'Month with 0 padding' ],
+ [ 'April 21 1991', true, 19910421, 'Space separation' ],
+ [ '04 22 1991', true, 19910422, 'Month with 0 padding' ],
+ [ 'December 12 \'10', true, 20101212, '' ],
+ [ 'Dec 12 \'10', true, 20101212, '' ],
+ [ 'Dec. 12 \'10', true, 20101212, '' ]
];
parserTest( 'MDY Dates', 'date', complexMDYDates );
clobberedDates = [
- ['January, 19 2010 - January, 20 2010', false, '99999999', 'Date range with hyphen'],
- ['January, 19 2010 — January, 20 2010', false, '99999999', 'Date range with mdash'],
- ['prefixJanuary, 19 2010', false, '99999999', 'Connected prefix'],
- ['prefix January, 19 2010', false, '99999999', 'Prefix'],
- ['December 12 2010postfix', false, '99999999', 'ConnectedPostfix'],
- ['December 12 2010 postfix', false, '99999999', 'Postfix'],
- ['A simple text', false, '99999999', 'Plain text in date sort'],
- ['04l22l1991', false, '99999999', 'l char as separator'],
- ['January\\19\\2010', false, '99999999', 'backslash as date separator']
+ [ 'January, 19 2010 - January, 20 2010', false, '99999999', 'Date range with hyphen' ],
+ [ 'January, 19 2010 — January, 20 2010', false, '99999999', 'Date range with mdash' ],
+ [ 'prefixJanuary, 19 2010', false, '99999999', 'Connected prefix' ],
+ [ 'prefix January, 19 2010', false, '99999999', 'Prefix' ],
+ [ 'December 12 2010postfix', false, '99999999', 'ConnectedPostfix' ],
+ [ 'December 12 2010 postfix', false, '99999999', 'Postfix' ],
+ [ 'A simple text', false, '99999999', 'Plain text in date sort' ],
+ [ '04l22l1991', false, '99999999', 'l char as separator' ],
+ [ 'January\\19\\2010', false, '99999999', 'backslash as date separator' ]
];
parserTest( 'Clobbered Dates', 'date', clobberedDates );
MYDates = [
- ['December 2010', false, '99999999', 'Plain month year'],
- ['Dec 2010', false, '99999999', 'Abreviated month year'],
- ['12 2010', false, '99999999', 'Numeric month year']
+ [ 'December 2010', false, '99999999', 'Plain month year' ],
+ [ 'Dec 2010', false, '99999999', 'Abreviated month year' ],
+ [ '12 2010', false, '99999999', 'Numeric month year' ]
];
parserTest( 'MY Dates', 'date', MYDates );
YDates = [
- ['2010', false, '99999999', 'Plain 4-digit year'],
- ['876', false, '99999999', '3-digit year'],
- ['76', false, '99999999', '2-digit year'],
- ['\'76', false, '99999999', '2-digit millenium bug year'],
- ['2010 BC', false, '99999999', '4-digit year BC']
+ [ '2010', false, '99999999', 'Plain 4-digit year' ],
+ [ '876', false, '99999999', '3-digit year' ],
+ [ '76', false, '99999999', '2-digit year' ],
+ [ '\'76', false, '99999999', '2-digit millenium bug year' ],
+ [ '2010 BC', false, '99999999', '4-digit year BC' ]
];
parserTest( 'Y Dates', 'date', YDates );
currencyData = [
- ['1.02 $', true, 1.02, ''],
- ['$ 3.00', true, 3, ''],
- ['€ 2,99', true, 299, ''],
- ['$ 1.00', true, 1, ''],
- ['$3.50', true, 3.50, ''],
- ['$ 1.50', true, 1.50, ''],
- ['€ 0.99', true, 0.99, ''],
- ['$ 299.99', true, 299.99, ''],
- ['$ 2,299.99', true, 2299.99, ''],
- ['$ 2,989', true, 2989, ''],
- ['$ 2 299.99', true, 2299.99, ''],
- ['$ 2 989', true, 2989, ''],
- ['$ 2.989', true, 2.989, '']
+ [ '1.02 $', true, 1.02, '' ],
+ [ '$ 3.00', true, 3, '' ],
+ [ '€ 2,99', true, 299, '' ],
+ [ '$ 1.00', true, 1, '' ],
+ [ '$3.50', true, 3.50, '' ],
+ [ '$ 1.50', true, 1.50, '' ],
+ [ '€ 0.99', true, 0.99, '' ],
+ [ '$ 299.99', true, 299.99, '' ],
+ [ '$ 2,299.99', true, 2299.99, '' ],
+ [ '$ 2,989', true, 2989, '' ],
+ [ '$ 2 299.99', true, 2299.99, '' ],
+ [ '$ 2 989', true, 2989, '' ],
+ [ '$ 2.989', true, 2.989, '' ]
];
parserTest( 'Currency', 'currency', currencyData );
transformedCurrencyData = [
- ['1.02 $', true, 102, ''],
- ['$ 3.00', true, 300, ''],
- ['€ 2,99', true, 2.99, ''],
- ['$ 1.00', true, 100, ''],
- ['$3.50', true, 350, ''],
- ['$ 1.50', true, 150, ''],
- ['€ 0.99', true, 99, ''],
- ['$ 299.99', true, 29999, ''],
- ['$ 2\'299,99', true, 2299.99, ''],
- ['$ 2,989', true, 2.989, ''],
- ['$ 2 299.99', true, 229999, ''],
- ['2 989 $', true, 2989, ''],
- ['299.99 $', true, 29999, ''],
- ['2\'299,99 $', true, 2299.99, ''],
- ['2,989 $', true, 2.989, ''],
- ['2 299.99 $', true, 229999, ''],
- ['2 989 $', true, 2989, '']
+ [ '1.02 $', true, 102, '' ],
+ [ '$ 3.00', true, 300, '' ],
+ [ '€ 2,99', true, 2.99, '' ],
+ [ '$ 1.00', true, 100, '' ],
+ [ '$3.50', true, 350, '' ],
+ [ '$ 1.50', true, 150, '' ],
+ [ '€ 0.99', true, 99, '' ],
+ [ '$ 299.99', true, 29999, '' ],
+ [ '$ 2\'299,99', true, 2299.99, '' ],
+ [ '$ 2,989', true, 2.989, '' ],
+ [ '$ 2 299.99', true, 229999, '' ],
+ [ '2 989 $', true, 2989, '' ],
+ [ '299.99 $', true, 29999, '' ],
+ [ '2\'299,99 $', true, 2299.99, '' ],
+ [ '2,989 $', true, 2.989, '' ],
+ [ '2 299.99 $', true, 229999, '' ],
+ [ '2 989 $', true, 2989, '' ]
];
parserTest( 'Currency with european separators', 'currency', transformedCurrencyData, function () {
mw.config.set( {
// We expect 22'234.444,22
// Map from ascii separators => localized separators
- wgSeparatorTransformTable: [', . ,', '\' , .'],
- wgDigitTransformTable: ['', '']
+ wgSeparatorTransformTable: [ ', . ,', '\' , .' ],
+ wgDigitTransformTable: [ '', '' ]
} );
} );
b1 = [ 'B', '1' ],
b2 = [ 'B', '2' ],
b3 = [ 'B', '3' ],
- simple = [a2, b3, a1, a3, b2, b1],
- simpleAsc = [a1, a2, a3, b1, b2, b3],
- simpleDescasc = [b1, b2, b3, a1, a2, a3],
+ simple = [ a2, b3, a1, a3, b2, b1 ],
+ simpleAsc = [ a1, a2, a3, b1, b2, b3 ],
+ simpleDescasc = [ b1, b2, b3, a1, a2, a3 ],
// Data set "colspan"
aaa1 = [ 'A', 'A', 'A', '1' ],
mars = [ 'Mars', '3390.0' ],
jupiter = [ 'Jupiter', '69911' ],
saturn = [ 'Saturn', '58232' ],
- planets = [mercury, venus, earth, mars, jupiter, saturn],
- planetsAscName = [earth, jupiter, mars, mercury, saturn, venus],
- planetsAscRadius = [mercury, mars, venus, earth, saturn, jupiter],
+ planets = [ mercury, venus, earth, mars, jupiter, saturn ],
+ planetsAscName = [ earth, jupiter, mars, mercury, saturn, venus ],
+ planetsAscRadius = [ mercury, mars, venus, earth, saturn, jupiter ],
planetsRowspan,
planetsRowspanII,
planetsAscNameLegacy,
// Data set "ipv4"
ipv4 = [
// Some randomly generated fake IPs
- ['45.238.27.109'],
- ['44.172.9.22'],
- ['247.240.82.209'],
- ['204.204.132.158'],
- ['170.38.91.162'],
- ['197.219.164.9'],
- ['45.68.154.72'],
- ['182.195.149.80']
+ [ '45.238.27.109' ],
+ [ '44.172.9.22' ],
+ [ '247.240.82.209' ],
+ [ '204.204.132.158' ],
+ [ '170.38.91.162' ],
+ [ '197.219.164.9' ],
+ [ '45.68.154.72' ],
+ [ '182.195.149.80' ]
],
ipv4Sorted = [
// Sort order should go octet by octet
- ['44.172.9.22'],
- ['45.68.154.72'],
- ['45.238.27.109'],
- ['170.38.91.162'],
- ['182.195.149.80'],
- ['197.219.164.9'],
- ['204.204.132.158'],
- ['247.240.82.209']
+ [ '44.172.9.22' ],
+ [ '45.68.154.72' ],
+ [ '45.238.27.109' ],
+ [ '170.38.91.162' ],
+ [ '182.195.149.80' ],
+ [ '197.219.164.9' ],
+ [ '204.204.132.158' ],
+ [ '247.240.82.209' ]
],
// Data set "umlaut"
umlautWords = [
- ['Günther'],
- ['Peter'],
- ['Björn'],
- ['Bjorn'],
- ['Apfel'],
- ['Äpfel'],
- ['Strasse'],
- ['Sträßschen']
+ [ 'Günther' ],
+ [ 'Peter' ],
+ [ 'Björn' ],
+ [ 'Bjorn' ],
+ [ 'Apfel' ],
+ [ 'Äpfel' ],
+ [ 'Strasse' ],
+ [ 'Sträßschen' ]
],
umlautWordsSorted = [
- ['Äpfel'],
- ['Apfel'],
- ['Björn'],
- ['Bjorn'],
- ['Günther'],
- ['Peter'],
- ['Sträßschen'],
- ['Strasse']
+ [ 'Äpfel' ],
+ [ 'Apfel' ],
+ [ 'Björn' ],
+ [ 'Bjorn' ],
+ [ 'Günther' ],
+ [ 'Peter' ],
+ [ 'Sträßschen' ],
+ [ 'Strasse' ]
],
complexMDYDates = [
- ['January, 19 2010'],
- ['April 21 1991'],
- ['04 22 1991'],
- ['5.12.1990'],
- ['December 12 \'10']
+ [ 'January, 19 2010' ],
+ [ 'April 21 1991' ],
+ [ '04 22 1991' ],
+ [ '5.12.1990' ],
+ [ 'December 12 \'10' ]
],
complexMDYSorted = [
- ['5.12.1990'],
- ['April 21 1991'],
- ['04 22 1991'],
- ['January, 19 2010'],
- ['December 12 \'10']
+ [ '5.12.1990' ],
+ [ 'April 21 1991' ],
+ [ '04 22 1991' ],
+ [ 'January, 19 2010' ],
+ [ 'December 12 \'10' ]
],
currencyUnsorted = [
- ['1.02 $'],
- ['$ 3.00'],
- ['€ 2,99'],
- ['$ 1.00'],
- ['$3.50'],
- ['$ 1.50'],
- ['€ 0.99']
+ [ '1.02 $' ],
+ [ '$ 3.00' ],
+ [ '€ 2,99' ],
+ [ '$ 1.00' ],
+ [ '$3.50' ],
+ [ '$ 1.50' ],
+ [ '€ 0.99' ]
],
currencySorted = [
- ['€ 0.99'],
- ['$ 1.00'],
- ['1.02 $'],
- ['$ 1.50'],
- ['$ 3.00'],
- ['$3.50'],
+ [ '€ 0.99' ],
+ [ '$ 1.00' ],
+ [ '1.02 $' ],
+ [ '$ 1.50' ],
+ [ '$ 3.00' ],
+ [ '$3.50' ],
// Comma's sort after dots
// Not intentional but test to detect changes
- ['€ 2,99']
+ [ '€ 2,99' ]
],
numbers = [
- [ '12' ],
- [ '7' ],
- [ '13,000'],
- [ '9' ],
- [ '14' ],
- [ '8.0' ]
+ [ '12' ],
+ [ '7' ],
+ [ '13,000' ],
+ [ '9' ],
+ [ '14' ],
+ [ '8.0' ]
],
numbersAsc = [
- [ '7' ],
- [ '8.0' ],
- [ '9' ],
- [ '12' ],
- [ '14' ],
- [ '13,000']
+ [ '7' ],
+ [ '8.0' ],
+ [ '9' ],
+ [ '12' ],
+ [ '14' ],
+ [ '13,000' ]
],
correctDateSorting1 = [
- ['01 January 2010'],
- ['05 February 2010'],
- ['16 January 2010']
+ [ '01 January 2010' ],
+ [ '05 February 2010' ],
+ [ '16 January 2010' ]
],
correctDateSortingSorted1 = [
- ['01 January 2010'],
- ['16 January 2010'],
- ['05 February 2010']
+ [ '01 January 2010' ],
+ [ '16 January 2010' ],
+ [ '05 February 2010' ]
],
correctDateSorting2 = [
- ['January 01 2010'],
- ['February 05 2010'],
- ['January 16 2010']
+ [ 'January 01 2010' ],
+ [ 'February 05 2010' ],
+ [ 'January 16 2010' ]
],
correctDateSortingSorted2 = [
- ['January 01 2010'],
- ['January 16 2010'],
- ['February 05 2010']
+ [ 'January 01 2010' ],
+ [ 'January 16 2010' ],
+ [ 'February 05 2010' ]
];
QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment( {
this.liveMonths = mw.language.months;
mw.language.months = {
'keys': {
- 'names': ['january', 'february', 'march', 'april', 'may_long', 'june',
- 'july', 'august', 'september', 'october', 'november', 'december'],
- 'genitive': ['january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen',
- 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen'],
- 'abbrev': ['jan', 'feb', 'mar', 'apr', 'may', 'jun',
- 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
+ 'names': [ 'january', 'february', 'march', 'april', 'may_long', 'june',
+ 'july', 'august', 'september', 'october', 'november', 'december' ],
+ 'genitive': [ 'january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen',
+ 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen' ],
+ 'abbrev': [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun',
+ 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ]
},
- 'names': ['January', 'February', 'March', 'April', 'May', 'June',
- 'July', 'August', 'September', 'October', 'November', 'December'],
- 'genitive': ['January', 'February', 'March', 'April', 'May', 'June',
- 'July', 'August', 'September', 'October', 'November', 'December'],
- 'abbrev': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+ 'names': [ 'January', 'February', 'March', 'April', 'May', 'June',
+ 'July', 'August', 'September', 'October', 'November', 'December' ],
+ 'genitive': [ 'January', 'February', 'March', 'April', 'May', 'June',
+ 'July', 'August', 'September', 'October', 'November', 'December' ],
+ 'abbrev': [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]
};
},
teardown: function () {
},
config: {
wgDefaultDateFormat: 'dmy',
- wgSeparatorTransformTable: ['', ''],
- wgDigitTransformTable: ['', ''],
+ wgSeparatorTransformTable: [ '', '' ],
+ wgDigitTransformTable: [ '', '' ],
wgPageContentLanguage: 'en'
}
} ) );
for ( i = 0; i < data.length; i++ ) {
/*jshint loopfunc: true */
$tr = $( '<tr>' );
- $.each( data[i], function ( j, str ) {
+ $.each( data[ i ], function ( j, str ) {
var $td = $( '<td>' );
$td.text( str ).appendTo( $tr );
} );
}
// Sample data set using planets named and their radius
- header = [ 'Planet', 'Radius (km)'];
+ header = [ 'Planet', 'Radius (km)' ];
tableTest(
'Basic planet table: sorting initially - ascending by name',
// Pretend to click while pressing the multi-sort key
var event = $.Event( 'click' );
- event[$table.data( 'tablesorter' ).config.sortMultiSortKey] = true;
+ event[ $table.data( 'tablesorter' ).config.sortMultiSortKey ] = true;
$table.find( '.headerSort:eq(1)' ).trigger( event );
}
);
// Regression tests!
tableTest(
'Bug 28775: German-style (dmy) short numeric dates',
- ['Date'],
+ [ 'Date' ],
[
// German-style dates are day-month-year
- ['11.11.2011'],
- ['01.11.2011'],
- ['02.10.2011'],
- ['03.08.2011'],
- ['09.11.2011']
+ [ '11.11.2011' ],
+ [ '01.11.2011' ],
+ [ '02.10.2011' ],
+ [ '03.08.2011' ],
+ [ '09.11.2011' ]
],
[
// Sorted by ascending date
- ['03.08.2011'],
- ['02.10.2011'],
- ['01.11.2011'],
- ['09.11.2011'],
- ['11.11.2011']
+ [ '03.08.2011' ],
+ [ '02.10.2011' ],
+ [ '01.11.2011' ],
+ [ '09.11.2011' ],
+ [ '11.11.2011' ]
],
function ( $table ) {
mw.config.set( 'wgDefaultDateFormat', 'dmy' );
tableTest(
'Bug 28775: American-style (mdy) short numeric dates',
- ['Date'],
+ [ 'Date' ],
[
// American-style dates are month-day-year
- ['11.11.2011'],
- ['01.11.2011'],
- ['02.10.2011'],
- ['03.08.2011'],
- ['09.11.2011']
+ [ '11.11.2011' ],
+ [ '01.11.2011' ],
+ [ '02.10.2011' ],
+ [ '03.08.2011' ],
+ [ '09.11.2011' ]
],
[
// Sorted by ascending date
- ['01.11.2011'],
- ['02.10.2011'],
- ['03.08.2011'],
- ['09.11.2011'],
- ['11.11.2011']
+ [ '01.11.2011' ],
+ [ '02.10.2011' ],
+ [ '03.08.2011' ],
+ [ '09.11.2011' ],
+ [ '11.11.2011' ]
],
function ( $table ) {
mw.config.set( 'wgDefaultDateFormat', 'mdy' );
tableTest(
'Bug 17141: IPv4 address sorting',
- ['IP'],
+ [ 'IP' ],
ipv4,
ipv4Sorted,
function ( $table ) {
);
tableTest(
'Bug 17141: IPv4 address sorting (reverse)',
- ['IP'],
+ [ 'IP' ],
ipv4,
reversed( ipv4Sorted ),
function ( $table ) {
tableTest(
'Accented Characters with custom collation',
- ['Name'],
+ [ 'Name' ],
umlautWords,
umlautWordsSorted,
function ( $table ) {
tableTest(
'Complex date parsing I',
- ['date'],
+ [ 'date' ],
complexMDYDates,
complexMDYSorted,
function ( $table ) {
tableTest(
'Currency parsing I',
- ['currency'],
+ [ 'currency' ],
currencyUnsorted,
currencySorted,
function ( $table ) {
);
planetsAscNameLegacy = planetsAscName.slice( 0 );
- planetsAscNameLegacy[4] = planetsAscNameLegacy[5];
+ planetsAscNameLegacy[ 4 ] = planetsAscNameLegacy[ 5 ];
planetsAscNameLegacy.pop();
tableTest(
$table.find( '.headerSort:eq(0)' ).click();
assert.equal(
- $table.data( 'tablesorter' ).config.parsers[0].id,
+ $table.data( 'tablesorter' ).config.parsers[ 0 ].id,
'number',
'Correctly detected column content skipping sortbottom'
);
} );
tableTest( 'bug 8115: sort numbers with commas (ascending)',
- ['Numbers'], numbers, numbersAsc,
+ [ 'Numbers' ], numbers, numbersAsc,
function ( $table ) {
$table.tablesorter();
$table.find( '.headerSort:eq(0)' ).click();
);
tableTest( 'bug 8115: sort numbers with commas (descending)',
- ['Numbers'], numbers, reversed( numbersAsc ),
+ [ 'Numbers' ], numbers, reversed( numbersAsc ),
function ( $table ) {
$table.tablesorter();
$table.find( '.headerSort:eq(0)' ).click().click();
tableTest(
'Correct date sorting I',
- ['date'],
+ [ 'date' ],
correctDateSorting1,
correctDateSortingSorted1,
function ( $table ) {
tableTest(
'Correct date sorting II',
- ['date'],
+ [ 'date' ],
correctDateSorting2,
correctDateSortingSorted2,
function ( $table ) {
}
pos = $textarea.textSelection( 'getCaretPosition', { startAndEnd: true } );
- among( pos[0], options.start, 'Caret start should be where we set it.' );
- among( pos[1], options.end, 'Caret end should be where we set it.' );
+ among( pos[ 0 ], options.start, 'Caret start should be where we set it.' );
+ among( pos[ 1 ], options.end, 'Caret end should be where we set it.' );
} );
}
function sequence( responses ) {
var i = 0;
return function ( request ) {
- var response = responses[i];
+ var response = responses[ i ];
if ( response ) {
i++;
request.respond.apply( request, response );
function sequenceBodies( status, headers, bodies ) {
jQuery.each( bodies, function ( i, body ) {
- bodies[i] = [ status, headers, body ];
+ bodies[ i ] = [ status, headers, body ];
} );
return sequence( bodies );
}
} );
assert.equal( this.server.requests.length, 2, 'Request made' );
- assert.equal( this.server.requests[0].requestHeaders['X-Foo'], 'Bar', 'Header sent' );
+ assert.equal( this.server.requests[ 0 ].requestHeaders[ 'X-Foo' ], 'Bar', 'Header sent' );
} );
QUnit.test( 'postWithToken() - badtoken', function ( assert ) {
return $.Deferred().promise();
} );
- api.uploadWithIframe( $( '<input>' )[0], { filename: 'Testing API upload.jpg' } );
+ api.uploadWithIframe( $( '<input>' )[ 0 ], { filename: 'Testing API upload.jpg' } );
$iframe = $( 'iframe' );
$form = $( 'form.mw-api-upload-form' );
} );
api.watch( [ 'Foo' ] ).done( function ( items ) {
- assert.equal( items[0].title, 'Foo' );
+ assert.equal( items[ 0 ].title, 'Foo' );
} );
api.watch( [ 'Foo', 'Bar' ] ).done( function ( items ) {
- assert.equal( items[0].title, 'Foo' );
- assert.equal( items[1].title, 'Bar' );
+ assert.equal( items[ 0 ].title, 'Foo' );
+ assert.equal( items[ 1 ].title, 'Bar' );
} );
// Requests are POST, match requestBody instead of url
QUnit.test( 'constructor', cases.invalid.length, function ( assert ) {
var i, title;
for ( i = 0; i < cases.valid.length; i++ ) {
- title = new mw.Title( cases.valid[i] );
+ title = new mw.Title( cases.valid[ i ] );
}
for ( i = 0; i < cases.invalid.length; i++ ) {
/*jshint loopfunc:true */
- title = cases.invalid[i];
+ title = cases.invalid[ i ];
assert.throws( function () {
return new mw.Title( title );
- }, cases.invalid[i] );
+ }, cases.invalid[ i ] );
}
} );
var i;
for ( i = 0; i < cases.valid.length; i++ ) {
assert.equal(
- $.type( mw.Title.newFromText( cases.valid[i] ) ),
+ $.type( mw.Title.newFromText( cases.valid[ i ] ) ),
'object',
- cases.valid[i]
+ cases.valid[ i ]
);
}
for ( i = 0; i < cases.invalid.length; i++ ) {
assert.equal(
- $.type( mw.Title.newFromText( cases.invalid[i] ) ),
+ $.type( mw.Title.newFromText( cases.invalid[ i ] ) ),
'null',
- cases.invalid[i]
+ cases.invalid[ i ]
);
}
} );
assert.equal( title.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' );
// $wgCapitalLinks = false;
- mw.config.set( 'wgCaseSensitiveNamespaces', [0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15] );
+ mw.config.set( 'wgCaseSensitiveNamespaces', [ 0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15 ] );
title = new mw.Title( 'article' );
assert.equal( title.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' );
assert.strictEqual( title.exists(), null, 'Return null with empty existance registry' );
// Basic registry, checks default to boolean
- mw.Title.exist.set( ['Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules'], true );
- mw.Title.exist.set( ['Does_not_exist', 'User:John', 'Foobar'], false );
+ mw.Title.exist.set( [ 'Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules' ], true );
+ mw.Title.exist.set( [ 'Does_not_exist', 'User:John', 'Foobar' ], false );
title = new mw.Title( 'Project:Sandbox rules' );
assert.assertTrue( title.exists(), 'Return true for page titles marked as existing' );
];
for ( i = 0; i < cases.length; i++ ) {
- thisCase = cases[i];
+ thisCase = cases[ i ];
title = mw.Title.newFromImg( { src: thisCase.url } );
if ( thisCase.nameText !== undefined ) {
];
for ( i = 0; i < cases.length; i++ ) {
- thisCase = cases[i];
+ thisCase = cases[ i ];
title = mw.Title.newFromText( thisCase.text );
assert.equal( title.getRelativeText( thisCase.relativeTo ), thisCase.expectedResult );
];
for ( i = 0; i < cases.length; i++ ) {
- thisCase = cases[i];
+ thisCase = cases[ i ];
title = mw.Title.newFromUserInput( thisCase.title, thisCase.defaultNamespace, thisCase.options );
if ( thisCase.expected !== undefined ) {
];
for ( i = 0; i < cases.length; i++ ) {
- thisCase = cases[i];
+ thisCase = cases[ i ];
title = mw.Title.newFromFileName( thisCase.fileName, thisCase.extensionDesired );
if ( thisCase.nameText !== undefined ) {
}
} ) );
- $.each( [true, false], function ( i, strictMode ) {
+ $.each( [ true, false ], function ( i, strictMode ) {
QUnit.test( 'Basic construction and properties (' + ( strictMode ? '' : 'non-' ) + 'strict mode)', 2, function ( assert ) {
var uriString, uri;
uriString = 'http://www.ietf.org/rfc/rfc2396.txt';
} );
assert.strictEqual( uri.query.n, '1', 'Simple parameter with overrideKeys:false' );
- assert.strictEqual( uri.query.m[0], 'foo', 'Order of multi-value parameters with overrideKeys:true' );
- assert.strictEqual( uri.query.m[1], 'bar', 'Order of multi-value parameters with overrideKeys:true' );
+ assert.strictEqual( uri.query.m[ 0 ], 'foo', 'Order of multi-value parameters with overrideKeys:true' );
+ assert.strictEqual( uri.query.m[ 1 ], 'bar', 'Order of multi-value parameters with overrideKeys:true' );
assert.strictEqual( uri.query.m.length, 2, 'Number of mult-value field is correct' );
uri = new mw.Uri( 'ftp://usr:pwd@192.0.2.16/' );
QUnit.test( 'Plural Test for ' + langCode, tests.length, function ( assert ) {
for ( var i = 0; i < tests.length; i++ ) {
assert.equal(
- mw.language.convertPlural( tests[i][0], tests[i][1] ),
- tests[i][2],
- tests[i][3]
+ mw.language.convertPlural( tests[ i ][ 0 ], tests[ i ][ 1 ] ),
+ tests[ i ][ 2 ],
+ tests[ i ][ 3 ]
);
}
} );
} );
call = $.cookie.lastCall.args;
- assert.strictEqual( call[0], 'myPrefixfoo' );
+ assert.strictEqual( call[ 0 ], 'myPrefixfoo' );
assert.deepEqual( call[ 2 ], {
expires: expiryDate,
domain: 'myDomain',
} );
call = $.cookie.lastCall.args;
- assert.strictEqual( call[0], 'myPrefixfoo' );
+ assert.strictEqual( call[ 0 ], 'myPrefixfoo' );
assert.deepEqual( call[ 2 ], {
expires: date,
domain: 'myDomain',
*/
function getMwLanguage( langCode ) {
if ( !hasOwn.call( mwLanguageCache, langCode ) ) {
- mwLanguageCache[langCode] = $.ajax( {
+ mwLanguageCache[ langCode ] = $.ajax( {
url: mw.util.wikiScript( 'load' ),
data: {
skin: mw.config.get( 'skin' ),
return mw.language;
} );
}
- return mwLanguageCache[langCode];
+ return mwLanguageCache[ langCode ];
}
/**
QUnit.test( 'Curly brace transformation', 16, function ( assert ) {
var oldUserLang = mw.config.get( 'wgUserLanguage' );
- assertBothModes( assert, ['gender-msg', 'Bob', 'male'], 'Bob: blue', 'gender is resolved' );
+ assertBothModes( assert, [ 'gender-msg', 'Bob', 'male' ], 'Bob: blue', 'gender is resolved' );
- assertBothModes( assert, ['plural-msg', 5], 'Found 5 items', 'plural is resolved' );
+ assertBothModes( assert, [ 'plural-msg', 5 ], 'Found 5 items', 'plural is resolved' );
- assertBothModes( assert, ['grammar-msg'], 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'grammar is resolved' );
+ assertBothModes( assert, [ 'grammar-msg' ], 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'grammar is resolved' );
mw.config.set( 'wgUserLanguage', 'en' );
- assertBothModes( assert, ['formatnum-msg', '987654321.654321'], '987,654,321.654', 'formatnum is resolved' );
+ assertBothModes( assert, [ 'formatnum-msg', '987654321.654321' ], '987,654,321.654', 'formatnum is resolved' );
// Test non-{{ wikitext, where behavior differs
outerCalled = false;
innerCalled = false;
message = mw.message( key );
- message[format]();
+ message[ format ]();
assert.strictEqual( outerCalled, shouldCall, 'Outer function called for ' + key );
assert.strictEqual( innerCalled, shouldCall, 'Inner function called for ' + key );
}
QUnit.test( 'HTML', 26, function ( assert ) {
mw.messages.set( 'jquerymsg-italics-msg', '<i>Very</i> important' );
- assertBothModes( assert, ['jquerymsg-italics-msg'], mw.messages.get( 'jquerymsg-italics-msg' ), 'Simple italics unchanged' );
+ assertBothModes( assert, [ 'jquerymsg-italics-msg' ], mw.messages.get( 'jquerymsg-italics-msg' ), 'Simple italics unchanged' );
mw.messages.set( 'jquerymsg-bold-msg', '<b>Strong</b> speaker' );
- assertBothModes( assert, ['jquerymsg-bold-msg'], mw.messages.get( 'jquerymsg-bold-msg' ), 'Simple bold unchanged' );
+ assertBothModes( assert, [ 'jquerymsg-bold-msg' ], mw.messages.get( 'jquerymsg-bold-msg' ), 'Simple bold unchanged' );
mw.messages.set( 'jquerymsg-bold-italics-msg', 'It is <b><i>key</i></b>' );
- assertBothModes( assert, ['jquerymsg-bold-italics-msg'], mw.messages.get( 'jquerymsg-bold-italics-msg' ), 'Bold and italics nesting order preserved' );
+ assertBothModes( assert, [ 'jquerymsg-bold-italics-msg' ], mw.messages.get( 'jquerymsg-bold-italics-msg' ), 'Bold and italics nesting order preserved' );
mw.messages.set( 'jquerymsg-italics-bold-msg', 'It is <i><b>vital</b></i>' );
- assertBothModes( assert, ['jquerymsg-italics-bold-msg'], mw.messages.get( 'jquerymsg-italics-bold-msg' ), 'Italics and bold nesting order preserved' );
+ assertBothModes( assert, [ 'jquerymsg-italics-bold-msg' ], mw.messages.get( 'jquerymsg-italics-bold-msg' ), 'Italics and bold nesting order preserved' );
mw.messages.set( 'jquerymsg-italics-with-link', 'An <i>italicized [[link|wiki-link]]</i>' );
for ( var i = 0; i < test.length; i++ ) {
assert.equal(
- mw.language.convertGrammar( test[i].word, test[i].grammarForm ),
- test[i].expected,
- test[i].description
+ mw.language.convertGrammar( test[ i ].word, test[ i ].grammarForm ),
+ test[ i ].expected,
+ test[ i ].description
);
}
} );
QUnit.test( 'List to text test', 4, function ( assert ) {
assert.equal( mw.language.listToText( [] ), '', 'Blank list' );
- assert.equal( mw.language.listToText( ['a'] ), 'a', 'Single item' );
- assert.equal( mw.language.listToText( ['a', 'b'] ), 'a and b', 'Two items' );
- assert.equal( mw.language.listToText( ['a', 'b', 'c'] ), 'a, b and c', 'More than two items' );
+ assert.equal( mw.language.listToText( [ 'a' ] ), 'a', 'Single item' );
+ assert.equal( mw.language.listToText( [ 'a', 'b' ] ), 'a and b', 'Two items' );
+ assert.equal( mw.language.listToText( [ 'a', 'b', 'c' ] ), 'a, b and c', 'More than two items' );
} );
}( mediaWiki, jQuery ) );
mw.messagePoster.factory.register( TEST_MODEL, testMessagePosterConstructor );
assert.strictEqual(
- mw.messagePoster.factory.contentModelToClass[TEST_MODEL],
+ mw.messagePoster.factory.contentModelToClass[ TEST_MODEL ],
testMessagePosterConstructor,
'Constructor is registered'
);
'MediaWiki': true
};
assert.strictEqual( conf.set( someValues ), true, 'Map.set returns boolean true if multiple values were set by passing an object' );
- assert.deepEqual( conf.get( ['foo', 'lorem'] ), {
+ assert.deepEqual( conf.get( [ 'foo', 'lorem' ] ), {
'foo': 'bar',
'lorem': 'ipsum'
}, 'Map.get returns multiple values correctly as an object' );
assert.deepEqual( conf, new mw.Map( conf.values ), 'new mw.Map maps over existing values-bearing object' );
- assert.deepEqual( conf.get( ['foo', 'notExist'] ), {
+ assert.deepEqual( conf.get( [ 'foo', 'notExist' ] ), {
'foo': 'bar',
'notExist': null
}, 'Map.get return includes keys that were not found as null values' );
len = formats.length;
for ( i = 0; i < len; i++ ) {
- format = formats[i];
- assert.equal( mw.message.apply( null, messageArguments )[format](), expectedResult, assertMessage + ' when format is ' + format );
+ format = formats[ i ];
+ assert.equal( mw.message.apply( null, messageArguments )[ format ](), expectedResult, assertMessage + ' when format is ' + format );
}
}
assert.equal( hello.format, 'escaped', 'Message.escaped correctly updated the "format" property' );
assert.ok( mw.messages.set( 'multiple-curly-brace', '"{{SITENAME}}" is the home of {{int:other-message}}' ), 'mw.messages.set: Register' );
- assertMultipleFormats( ['multiple-curly-brace'], ['text', 'parse'], '"' + siteName + '" is the home of Other Message', 'Curly brace format works correctly' );
+ assertMultipleFormats( [ 'multiple-curly-brace' ], [ 'text', 'parse' ], '"' + siteName + '" is the home of Other Message', 'Curly brace format works correctly' );
assert.equal( mw.message( 'multiple-curly-brace' ).plain(), mw.messages.get( 'multiple-curly-brace' ), 'Plain format works correctly for curly brace message' );
assert.equal( mw.message( 'multiple-curly-brace' ).escaped(), mw.html.escape( '"' + siteName + '" is the home of Other Message' ), 'Escaped format works correctly for curly brace message' );
assert.ok( mw.messages.set( 'multiple-square-brackets-and-ampersand', 'Visit the [[Project:Community portal|community portal]] & [[Project:Help desk|help desk]]' ), 'mw.messages.set: Register' );
- assertMultipleFormats( ['multiple-square-brackets-and-ampersand'], ['plain', 'text'], mw.messages.get( 'multiple-square-brackets-and-ampersand' ), 'Square bracket message is not processed' );
+ assertMultipleFormats( [ 'multiple-square-brackets-and-ampersand' ], [ 'plain', 'text' ], mw.messages.get( 'multiple-square-brackets-and-ampersand' ), 'Square bracket message is not processed' );
assert.equal( mw.message( 'multiple-square-brackets-and-ampersand' ).escaped(), 'Visit the [[Project:Community portal|community portal]] & [[Project:Help desk|help desk]]', 'Escaped format works correctly for square bracket message' );
assert.htmlEqual( mw.message( 'multiple-square-brackets-and-ampersand' ).parse(), 'Visit the ' +
'<a title="Project:Community portal" href="/wiki/Project:Community_portal">community portal</a>' +
' & <a title="Project:Help desk" href="/wiki/Project:Help_desk">help desk</a>', 'Internal links work with parse' );
- assertMultipleFormats( ['mediawiki-test-version-entrypoints-index-php'], ['plain', 'text', 'escaped'], mw.messages.get( 'mediawiki-test-version-entrypoints-index-php' ), 'External link markup is unprocessed' );
+ assertMultipleFormats( [ 'mediawiki-test-version-entrypoints-index-php' ], [ 'plain', 'text', 'escaped' ], mw.messages.get( 'mediawiki-test-version-entrypoints-index-php' ), 'External link markup is unprocessed' );
assert.htmlEqual( mw.message( 'mediawiki-test-version-entrypoints-index-php' ).parse(), '<a href="https://www.mediawiki.org/wiki/Manual:index.php">index.php</a>', 'External link works correctly in parse mode' );
- assertMultipleFormats( ['external-link-replace', 'http://example.org/?x=y&z'], ['plain', 'text'], 'Foo [http://example.org/?x=y&z bar]', 'Parameters are substituted but external link is not processed' );
+ assertMultipleFormats( [ 'external-link-replace', 'http://example.org/?x=y&z' ], [ 'plain', 'text' ], 'Foo [http://example.org/?x=y&z bar]', 'Parameters are substituted but external link is not processed' );
assert.equal( mw.message( 'external-link-replace', 'http://example.org/?x=y&z' ).escaped(), 'Foo [http://example.org/?x=y&z bar]', 'In escaped mode, parameters are substituted and ampersand is escaped, but external link is not processed' );
assert.htmlEqual( mw.message( 'external-link-replace', 'http://example.org/?x=y&z' ).parse(), 'Foo <a href="http://example.org/?x=y&z">bar</a>', 'External link with replacement works in parse mode without double-escaping' );
goodbye = mw.message( 'goodbye' );
assert.strictEqual( goodbye.exists(), false, 'Message.exists returns false for nonexistent messages' );
- assertMultipleFormats( ['goodbye'], ['plain', 'text'], '<goodbye>', 'Message.toString returns <key> if key does not exist' );
+ assertMultipleFormats( [ 'goodbye' ], [ 'plain', 'text' ], '<goodbye>', 'Message.toString returns <key> if key does not exist' );
// bug 30684
- assertMultipleFormats( ['goodbye'], ['parse', 'escaped'], '<goodbye>', 'Message.toString returns properly escaped <key> if key does not exist' );
+ assertMultipleFormats( [ 'goodbye' ], [ 'parse', 'escaped' ], '<goodbye>', 'Message.toString returns properly escaped <key> if key does not exist' );
assert.ok( mw.messages.set( 'plural-test-msg', 'There {{PLURAL:$1|is|are}} $1 {{PLURAL:$1|result|results}}' ), 'mw.messages.set: Register' );
- assertMultipleFormats( ['plural-test-msg', 6], ['text', 'parse', 'escaped'], 'There are 6 results', 'plural get resolved' );
+ assertMultipleFormats( [ 'plural-test-msg', 6 ], [ 'text', 'parse', 'escaped' ], 'There are 6 results', 'plural get resolved' );
assert.equal( mw.message( 'plural-test-msg', 6 ).plain(), 'There {{PLURAL:6|is|are}} 6 {{PLURAL:6|result|results}}', 'Parameter is substituted but plural is not resolved in plain' );
assert.ok( mw.messages.set( 'plural-test-msg-explicit', 'There {{plural:$1|is one car|are $1 cars|0=are no cars|12=are a dozen cars}}' ), 'mw.messages.set: Register message with explicit plural forms' );
- assertMultipleFormats( ['plural-test-msg-explicit', 12], ['text', 'parse', 'escaped'], 'There are a dozen cars', 'explicit plural get resolved' );
+ assertMultipleFormats( [ 'plural-test-msg-explicit', 12 ], [ 'text', 'parse', 'escaped' ], 'There are a dozen cars', 'explicit plural get resolved' );
assert.ok( mw.messages.set( 'plural-test-msg-explicit-beginning', 'Basket has {{plural:$1|0=no eggs|12=a dozen eggs|6=half a dozen eggs|one egg|$1 eggs}}' ), 'mw.messages.set: Register message with explicit plural forms' );
- assertMultipleFormats( ['plural-test-msg-explicit-beginning', 1], ['text', 'parse', 'escaped'], 'Basket has one egg', 'explicit plural given at beginning get resolved for singular' );
- assertMultipleFormats( ['plural-test-msg-explicit-beginning', 4], ['text', 'parse', 'escaped'], 'Basket has 4 eggs', 'explicit plural given at beginning get resolved for plural' );
- assertMultipleFormats( ['plural-test-msg-explicit-beginning', 6], ['text', 'parse', 'escaped'], 'Basket has half a dozen eggs', 'explicit plural given at beginning get resolved for 6' );
- assertMultipleFormats( ['plural-test-msg-explicit-beginning', 0], ['text', 'parse', 'escaped'], 'Basket has no eggs', 'explicit plural given at beginning get resolved for 0' );
+ assertMultipleFormats( [ 'plural-test-msg-explicit-beginning', 1 ], [ 'text', 'parse', 'escaped' ], 'Basket has one egg', 'explicit plural given at beginning get resolved for singular' );
+ assertMultipleFormats( [ 'plural-test-msg-explicit-beginning', 4 ], [ 'text', 'parse', 'escaped' ], 'Basket has 4 eggs', 'explicit plural given at beginning get resolved for plural' );
+ assertMultipleFormats( [ 'plural-test-msg-explicit-beginning', 6 ], [ 'text', 'parse', 'escaped' ], 'Basket has half a dozen eggs', 'explicit plural given at beginning get resolved for 6' );
+ assertMultipleFormats( [ 'plural-test-msg-explicit-beginning', 0 ], [ 'text', 'parse', 'escaped' ], 'Basket has no eggs', 'explicit plural given at beginning get resolved for 0' );
- assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary'], ['plain', 'text'], mw.messages.get( 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ), 'Double square brackets with no parameters unchanged' );
+ assertMultipleFormats( [ 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ], [ 'plain', 'text' ], mw.messages.get( 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ), 'Double square brackets with no parameters unchanged' );
- assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName], ['plain', 'text'], 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets with one parameter' );
+ assertMultipleFormats( [ 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ], [ 'plain', 'text' ], 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets with one parameter' );
assert.equal( mw.message( 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ).escaped(), 'Notifying author of deletion nomination for [[' + mw.html.escape( specialCharactersPageName ) + ']]', 'Double square brackets with one parameter, when escaped' );
assert.ok( mw.messages.set( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result', '<a href=\'#\' title=\'{{#special:mypage}}\'>Username</a> (<a href=\'#\' title=\'{{#special:mytalk}}\'>talk</a>)' ), 'mw.messages.set: Register' );
assert.equal( mw.message( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result' ).plain(), mw.messages.get( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result' ), 'HTML message with curly braces is not changed in plain mode' );
- assertMultipleFormats( ['gender-plural-msg', 'male', 1], ['text', 'parse', 'escaped'], 'he is awesome', 'Gender and plural are resolved' );
+ assertMultipleFormats( [ 'gender-plural-msg', 'male', 1 ], [ 'text', 'parse', 'escaped' ], 'he is awesome', 'Gender and plural are resolved' );
assert.equal( mw.message( 'gender-plural-msg', 'male', 1 ).plain(), '{{GENDER:male|he|she|they}} {{PLURAL:1|is|are}} awesome', 'Parameters are substituted, but gender and plural are not resolved in plain mode' );
assert.equal( mw.message( 'grammar-msg' ).plain(), mw.messages.get( 'grammar-msg' ), 'Grammar is not resolved in plain mode' );
- assertMultipleFormats( ['grammar-msg'], ['text', 'parse'], 'Przeszukaj ' + siteName, 'Grammar is resolved' );
+ assertMultipleFormats( [ 'grammar-msg' ], [ 'text', 'parse' ], 'Przeszukaj ' + siteName, 'Grammar is resolved' );
assert.equal( mw.message( 'grammar-msg' ).escaped(), 'Przeszukaj ' + siteName, 'Grammar is resolved in escaped mode' );
- assertMultipleFormats( ['formatnum-msg', '987654321.654321'], ['text', 'parse', 'escaped'], '987,654,321.654', 'formatnum is resolved' );
+ assertMultipleFormats( [ 'formatnum-msg', '987654321.654321' ], [ 'text', 'parse', 'escaped' ], '987,654,321.654', 'formatnum is resolved' );
assert.equal( mw.message( 'formatnum-msg' ).plain(), mw.messages.get( 'formatnum-msg' ), 'formatnum is not resolved in plain mode' );
- assertMultipleFormats( ['int-msg'], ['text', 'parse', 'escaped'], 'Some Other Message', 'int is resolved' );
+ assertMultipleFormats( [ 'int-msg' ], [ 'text', 'parse', 'escaped' ], 'Some Other Message', 'int is resolved' );
assert.equal( mw.message( 'int-msg' ).plain(), mw.messages.get( 'int-msg' ), 'int is not resolved in plain mode' );
assert.ok( mw.messages.set( 'mediawiki-italics-msg', '<i>Very</i> important' ), 'mw.messages.set: Register' );
- assertMultipleFormats( ['mediawiki-italics-msg'], ['plain', 'text', 'parse'], mw.messages.get( 'mediawiki-italics-msg' ), 'Simple italics unchanged' );
+ assertMultipleFormats( [ 'mediawiki-italics-msg' ], [ 'plain', 'text', 'parse' ], mw.messages.get( 'mediawiki-italics-msg' ), 'Simple italics unchanged' );
assert.htmlEqual(
mw.message( 'mediawiki-italics-msg' ).escaped(),
'<i>Very</i> important',
);
assert.ok( mw.messages.set( 'mediawiki-italics-with-link', 'An <i>italicized [[link|wiki-link]]</i>' ), 'mw.messages.set: Register' );
- assertMultipleFormats( ['mediawiki-italics-with-link'], ['plain', 'text'], mw.messages.get( 'mediawiki-italics-with-link' ), 'Italics with link unchanged' );
+ assertMultipleFormats( [ 'mediawiki-italics-with-link' ], [ 'plain', 'text' ], mw.messages.get( 'mediawiki-italics-with-link' ), 'Italics with link unchanged' );
assert.htmlEqual(
mw.message( 'mediawiki-italics-with-link' ).escaped(),
'An <i>italicized [[link|wiki-link]]</i>',
);
assert.ok( mw.messages.set( 'mediawiki-script-msg', '<script >alert( "Who put this script here?" );</script>' ), 'mw.messages.set: Register' );
- assertMultipleFormats( ['mediawiki-script-msg'], ['plain', 'text'], mw.messages.get( 'mediawiki-script-msg' ), 'Script unchanged' );
+ assertMultipleFormats( [ 'mediawiki-script-msg' ], [ 'plain', 'text' ], mw.messages.get( 'mediawiki-script-msg' ), 'Script unchanged' );
assert.htmlEqual(
mw.message( 'mediawiki-script-msg' ).escaped(),
'<script >alert( "Who put this script here?" );</script>',
isAwesomeDone = true;
};
- mw.loader.implement( 'test.callback', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )] );
+ mw.loader.implement( 'test.callback', [ QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' ) ] );
mw.loader.using( 'test.callback', function () {
isAwesomeDone = true;
};
- mw.loader.implement( 'hasOwnProperty', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )], {}, {} );
+ mw.loader.implement( 'hasOwnProperty', [ QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' ) ], {}, {} );
mw.loader.using( 'hasOwnProperty', function () {
isAwesomeDone = true;
};
- mw.loader.implement( 'test.promise', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )] );
+ mw.loader.implement( 'test.promise', [ QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' ) ] );
mw.loader.using( 'test.promise' )
.done( function () {
},
{
'url': {
- 'print': [urlStyleTest( '.mw-test-implement-b1', 'text-align', 'center' )],
+ 'print': [ urlStyleTest( '.mw-test-implement-b1', 'text-align', 'center' ) ],
'screen': [
// bug 40834: Make sure it actually works with more than 1 stylesheet reference
urlStyleTest( '.mw-test-implement-b2', 'float', 'left' ),
} );
},
{
- 'all': [urlStyleTest( '.mw-test-implement-d', 'float', 'right' )],
- 'print': [urlStyleTest( '.mw-test-implement-d2', 'text-align', 'center' )]
+ 'all': [ urlStyleTest( '.mw-test-implement-d', 'float', 'right' ) ],
+ 'print': [ urlStyleTest( '.mw-test-implement-d2', 'text-align', 'center' ) ]
}
);
);
mw.loader.register( [
- [ 'test.implement.e', '0', ['test.implement.e2']],
+ [ 'test.implement.e', '0', [ 'test.implement.e2' ] ],
[ 'test.implement.e2', '0' ]
] );
this.sandbox.stub( mw, 'track' );
mw.loader.register( [
- ['test.module1', '0'],
- ['test.module2', '0', ['test.module1']],
- ['test.module3', '0', ['test.module2']]
+ [ 'test.module1', '0' ],
+ [ 'test.module2', '0', [ 'test.module1' ] ],
+ [ 'test.module3', '0', [ 'test.module2' ] ]
] );
mw.loader.implement( 'test.module1', function () {
throw new Error( 'expected' );
QUnit.test( 'mw.loader out-of-order implementation', 9, function ( assert ) {
mw.loader.register( [
- ['test.module4', '0'],
- ['test.module5', '0', ['test.module4']],
- ['test.module6', '0', ['test.module5']]
+ [ 'test.module4', '0' ],
+ [ 'test.module5', '0', [ 'test.module4' ] ],
+ [ 'test.module6', '0', [ 'test.module5' ] ]
] );
mw.loader.implement( 'test.module4', function () {} );
assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
QUnit.test( 'mw.loader missing dependency', 13, function ( assert ) {
mw.loader.register( [
- ['test.module7', '0'],
- ['test.module8', '0', ['test.module7']],
- ['test.module9', '0', ['test.module8']]
+ [ 'test.module7', '0' ],
+ [ 'test.module8', '0', [ 'test.module7' ] ],
+ [ 'test.module9', '0', [ 'test.module8' ] ]
] );
mw.loader.implement( 'test.module8', function () {} );
assert.strictEqual( mw.loader.getState( 'test.module7' ), 'registered', 'Expected "registered" state for test.module7' );
assert.strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
assert.strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
mw.loader.using(
- ['test.module7'],
+ [ 'test.module7' ],
function () {
assert.ok( false, 'Success fired despite missing dependency' );
assert.ok( true, 'QUnit expected() count dummy' );
},
function ( e, dependencies ) {
assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' );
- assert.deepEqual( dependencies, ['test.module7'], 'Error callback called with module test.module7' );
+ assert.deepEqual( dependencies, [ 'test.module7' ], 'Error callback called with module test.module7' );
}
);
mw.loader.using(
- ['test.module9'],
+ [ 'test.module9' ],
function () {
assert.ok( false, 'Success fired despite missing dependency' );
assert.ok( true, 'QUnit expected() count dummy' );
dependencies.sort();
assert.deepEqual(
dependencies,
- ['test.module7', 'test.module8', 'test.module9'],
+ [ 'test.module7', 'test.module8', 'test.module9' ],
'Error callback called with all three modules as dependencies'
);
}
QUnit.asyncTest( 'mw.loader dependency handling', 5, function ( assert ) {
mw.loader.register( [
// [module, version, dependencies, group, source]
- ['testMissing', '1', [], null, 'testloader'],
- ['testUsesMissing', '1', ['testMissing'], null, 'testloader'],
- ['testUsesNestedMissing', '1', ['testUsesMissing'], null, 'testloader']
+ [ 'testMissing', '1', [], null, 'testloader' ],
+ [ 'testUsesMissing', '1', [ 'testMissing' ], null, 'testloader' ],
+ [ 'testUsesNestedMissing', '1', [ 'testUsesMissing' ], null, 'testloader' ]
] );
function verifyModuleStates() {
assert.equal( mw.loader.getState( 'testUsesNestedMissing' ), 'error', 'Module with indirect missing dependency must have state "error"' );
}
- mw.loader.using( ['testUsesNestedMissing'],
+ mw.loader.using( [ 'testUsesNestedMissing' ],
function () {
assert.ok( false, 'Error handler should be invoked.' );
assert.ok( true ); // Dummy to reach QUnit expect()
// As soon as server spits out state('testMissing', 'missing');
// it will bubble up and trigger the error callback.
// Therefor the badmodules array is not testUsesMissing or testUsesNestedMissing.
- assert.deepEqual( badmodules, ['testMissing'], 'Bad modules as expected.' );
+ assert.deepEqual( badmodules, [ 'testMissing' ], 'Bad modules as expected.' );
verifyModuleStates();
QUnit.asyncTest( 'mw.loader skin-function handling', 5, function ( assert ) {
mw.loader.register( [
// [module, version, dependencies, group, source, skip]
- ['testSkipped', '1', [], null, 'testloader', 'return true;'],
- ['testNotSkipped', '1', [], null, 'testloader', 'return false;'],
- ['testUsesSkippable', '1', ['testSkipped', 'testNotSkipped'], null, 'testloader']
+ [ 'testSkipped', '1', [], null, 'testloader', 'return true;' ],
+ [ 'testNotSkipped', '1', [], null, 'testloader', 'return false;' ],
+ [ 'testUsesSkippable', '1', [ 'testSkipped', 'testNotSkipped' ], null, 'testloader' ]
] );
function verifyModuleStates() {
assert.equal( mw.loader.getState( 'testUsesSkippable' ), 'ready', 'Module is ready when skippable dependencies are ready' );
}
- mw.loader.using( ['testUsesSkippable'],
+ mw.loader.using( [ 'testUsesSkippable' ],
function () {
assert.ok( true, 'Success handler should be invoked.' );
assert.ok( true ); // Dummy to match error handler and reach QUnit expect()
mw.hook( 'test.hook.data' ).add( function ( data1, data2 ) {
assert.equal( data1, 'example', 'Fire with data (string param)' );
- assert.deepEqual( data2, ['two'], 'Fire with data (array param)' );
+ assert.deepEqual( data2, [ 'two' ], 'Fire with data (array param)' );
} );
- mw.hook( 'test.hook.data' ).fire( 'example', ['two'] );
+ mw.hook( 'test.hook.data' ).fire( 'example', [ 'two' ] );
hook = mw.hook( 'test.hook.chainable' );
assert.strictEqual( hook.add(), hook, 'hook.add is chainable' );
add = hook.add;
fire = hook.fire;
add( function ( x, y ) {
- assert.deepEqual( [x, y], ['x', 'y'], 'Detached (contextless) with data' );
+ assert.deepEqual( [ x, y ], [ 'x', 'y' ], 'Detached (contextless) with data' );
} );
fire( 'x', 'y' );
assert.equal( chr, 'z', 'Adding callback later invokes right away with last data' );
} );
- assert.deepEqual( chars, ['x', 'y', 'z'], 'Multiple callbacks with multiple fires' );
+ assert.deepEqual( chars, [ 'x', 'y', 'z' ], 'Multiple callbacks with multiple fires' );
chars = [];
callback = function ( chr ) {
assert.deepEqual(
chars,
- ['x', 'x', 'x', 'x', 'y', 'z'],
+ [ 'x', 'x', 'x', 'x', 'y', 'z' ],
'"add" and "remove" support variadic arguments. ' +
'"add" does not filter unique. ' +
'"remove" removes all equal by reference. ' +
var
// Based on IPTest.php > testisIPv4
IPV4_CASES = [
- [false, false, 'Boolean false is not an IP'],
- [false, true, 'Boolean true is not an IP'],
- [false, '', 'Empty string is not an IP'],
- [false, 'abc', '"abc" is not an IP'],
- [false, ':', 'Colon is not an IP'],
- [false, '124.24.52', 'IPv4 not enough quads'],
- [false, '24.324.52.13', 'IPv4 out of range'],
- [false, '.24.52.13', 'IPv4 starts with period'],
-
- [true, '124.24.52.13', '124.24.52.134 is a valid IP'],
- [true, '1.24.52.13', '1.24.52.13 is a valid IP'],
- [false, '74.24.52.13/20', 'IPv4 ranges are not recognized as valid IPs']
+ [ false, false, 'Boolean false is not an IP' ],
+ [ false, true, 'Boolean true is not an IP' ],
+ [ false, '', 'Empty string is not an IP' ],
+ [ false, 'abc', '"abc" is not an IP' ],
+ [ false, ':', 'Colon is not an IP' ],
+ [ false, '124.24.52', 'IPv4 not enough quads' ],
+ [ false, '24.324.52.13', 'IPv4 out of range' ],
+ [ false, '.24.52.13', 'IPv4 starts with period' ],
+
+ [ true, '124.24.52.13', '124.24.52.134 is a valid IP' ],
+ [ true, '1.24.52.13', '1.24.52.13 is a valid IP' ],
+ [ false, '74.24.52.13/20', 'IPv4 ranges are not recognized as valid IPs' ]
],
// Based on IPTest.php > testisIPv6
IPV6_CASES = [
- [false, ':fc:100::', 'IPv6 starting with lone ":"'],
- [false, 'fc:100:::', 'IPv6 ending with a ":::"'],
- [false, 'fc:300', 'IPv6 with only 2 words'],
- [false, 'fc:100:300', 'IPv6 with only 3 words'],
-
- [false, 'fc:100:a:d:1:e:ac:0::', 'IPv6 with 8 words ending with "::"'],
- [false, 'fc:100:a:d:1:e:ac:0:1::', 'IPv6 with 9 words ending with "::"'],
-
- [false, ':::'],
- [false, '::0:', 'IPv6 ending in a lone ":"'],
-
- [true, '::', 'IPv6 zero address'],
-
- [false, '::fc:100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words'],
- [false, '::fc:100:a:d:1:e:ac:0:1', 'IPv6 with 9 words'],
-
- [false, ':fc::100', 'IPv6 starting with lone ":"'],
- [false, 'fc::100:', 'IPv6 ending with lone ":"'],
- [false, 'fc:::100', 'IPv6 with ":::" in the middle'],
-
- [true, 'fc::100', 'IPv6 with "::" and 2 words'],
- [true, 'fc::100:a', 'IPv6 with "::" and 3 words'],
- [true, 'fc::100:a:d', 'IPv6 with "::" and 4 words'],
- [true, 'fc::100:a:d:1', 'IPv6 with "::" and 5 words'],
- [true, 'fc::100:a:d:1:e', 'IPv6 with "::" and 6 words'],
- [true, 'fc::100:a:d:1:e:ac', 'IPv6 with "::" and 7 words'],
- [true, '2001::df', 'IPv6 with "::" and 2 words'],
- [true, '2001:5c0:1400:a::df', 'IPv6 with "::" and 5 words'],
- [true, '2001:5c0:1400:a::df:2', 'IPv6 with "::" and 6 words'],
-
- [false, 'fc::100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words'],
- [false, 'fc::100:a:d:1:e:ac:0:1', 'IPv6 with 9 words']
+ [ false, ':fc:100::', 'IPv6 starting with lone ":"' ],
+ [ false, 'fc:100:::', 'IPv6 ending with a ":::"' ],
+ [ false, 'fc:300', 'IPv6 with only 2 words' ],
+ [ false, 'fc:100:300', 'IPv6 with only 3 words' ],
+
+ [ false, 'fc:100:a:d:1:e:ac:0::', 'IPv6 with 8 words ending with "::"' ],
+ [ false, 'fc:100:a:d:1:e:ac:0:1::', 'IPv6 with 9 words ending with "::"' ],
+
+ [ false, ':::' ],
+ [ false, '::0:', 'IPv6 ending in a lone ":"' ],
+
+ [ true, '::', 'IPv6 zero address' ],
+
+ [ false, '::fc:100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words' ],
+ [ false, '::fc:100:a:d:1:e:ac:0:1', 'IPv6 with 9 words' ],
+
+ [ false, ':fc::100', 'IPv6 starting with lone ":"' ],
+ [ false, 'fc::100:', 'IPv6 ending with lone ":"' ],
+ [ false, 'fc:::100', 'IPv6 with ":::" in the middle' ],
+
+ [ true, 'fc::100', 'IPv6 with "::" and 2 words' ],
+ [ true, 'fc::100:a', 'IPv6 with "::" and 3 words' ],
+ [ true, 'fc::100:a:d', 'IPv6 with "::" and 4 words' ],
+ [ true, 'fc::100:a:d:1', 'IPv6 with "::" and 5 words' ],
+ [ true, 'fc::100:a:d:1:e', 'IPv6 with "::" and 6 words' ],
+ [ true, 'fc::100:a:d:1:e:ac', 'IPv6 with "::" and 7 words' ],
+ [ true, '2001::df', 'IPv6 with "::" and 2 words' ],
+ [ true, '2001:5c0:1400:a::df', 'IPv6 with "::" and 5 words' ],
+ [ true, '2001:5c0:1400:a::df:2', 'IPv6 with "::" and 6 words' ],
+
+ [ false, 'fc::100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words' ],
+ [ false, 'fc::100:a:d:1:e:ac:0:1', 'IPv6 with 9 words' ]
];
Array.prototype.push.apply( IPV6_CASES,
'::fc:100:a:d:1:e:ac',
'fc:100:a:d:1:e:ac:0'
], function ( el ) {
- return [[ true, el, el + ' is a valid IP' ]];
+ return [ [ true, el, el + ' is a valid IP' ] ];
} )
);
);
assert.equal( $tbMW.closest( '.portlet' ).attr( 'id' ), 'p-test-tb', 'Link was inserted within correct portlet' );
- assert.strictEqual( $tbMW.next()[0], tbRL, 'Link is in the correct position (nextnode as Node object)' );
+ assert.strictEqual( $tbMW.next()[ 0 ], tbRL, 'Link is in the correct position (nextnode as Node object)' );
cuQuux = mw.util.addPortletLink( 'p-test-custom', '#', 'Quux', null, 'Example [shift-x]', 'q' );
$cuQuux = $( cuQuux );
tbRLDM = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/RL/DM',
'Default modules', 't-rldm', 'List of all default modules ', 'd', '#t-rl' );
- assert.strictEqual( $( tbRLDM ).next()[0], tbRL, 'Link is in the correct position (CSS selector as nextnode)' );
+ assert.strictEqual( $( tbRLDM ).next()[ 0 ], tbRL, 'Link is in the correct position (CSS selector as nextnode)' );
caFoo = mw.util.addPortletLink( 'p-test-views', '#', 'Foo' );
assert.strictEqual( $( caFoo ).find( 'span' ).length, 1, 'A <span> element should be added for porlets with vectorTabs class.' );
addedAfter = mw.util.addPortletLink( 'p-test-tb', '#', 'After foo', 'post-foo', 'After foo', null, $( tbRL ) );
- assert.strictEqual( $( addedAfter ).next()[0], tbRL, 'Link is in the correct position (jQuery object as nextnode)' );
+ assert.strictEqual( $( addedAfter ).next()[ 0 ], tbRL, 'Link is in the correct position (jQuery object as nextnode)' );
// test case - nonexistent id as next node
tbRLDMnonexistentid = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/RL/DM',
'Default modules', 't-rldm-nonexistent', 'List of all default modules ', 'd', '#t-rl-nonexistent' );
- assert.equal( tbRLDMnonexistentid, $( '#p-test-tb li:last' )[0], 'Fallback to adding at the end (nextnode non-matching CSS selector)' );
+ assert.equal( tbRLDMnonexistentid, $( '#p-test-tb li:last' )[ 0 ], 'Fallback to adding at the end (nextnode non-matching CSS selector)' );
// test case - empty jquery object as next node
tbRLDMemptyjquery = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/RL/DM',
'Default modules', 't-rldm-empty-jquery', 'List of all default modules ', 'd', $( '#t-rl-nonexistent' ) );
- assert.equal( tbRLDMemptyjquery, $( '#p-test-tb li:last' )[0], 'Fallback to adding at the end (nextnode as empty jQuery object)' );
+ assert.equal( tbRLDMemptyjquery, $( '#p-test-tb li:last' )[ 0 ], 'Fallback to adding at the end (nextnode as empty jQuery object)' );
} );
QUnit.test( 'validateEmail', 6, function ( assert ) {
QUnit.test( 'isIPv6Address', 40, function ( assert ) {
$.each( IPV6_CASES, function ( i, ipCase ) {
- assert.strictEqual( mw.util.isIPv6Address( ipCase[1] ), ipCase[0], ipCase[2] );
+ assert.strictEqual( mw.util.isIPv6Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] );
} );
} );
QUnit.test( 'isIPv4Address', 11, function ( assert ) {
$.each( IPV4_CASES, function ( i, ipCase ) {
- assert.strictEqual( mw.util.isIPv4Address( ipCase[1] ), ipCase[0], ipCase[2] );
+ assert.strictEqual( mw.util.isIPv4Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] );
} );
} );
QUnit.test( 'isIPAddress', 51, function ( assert ) {
$.each( IPV4_CASES, function ( i, ipCase ) {
- assert.strictEqual( mw.util.isIPv4Address( ipCase[1] ), ipCase[0], ipCase[2] );
+ assert.strictEqual( mw.util.isIPv4Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] );
} );
$.each( IPV6_CASES, function ( i, ipCase ) {
- assert.strictEqual( mw.util.isIPv6Address( ipCase[1] ), ipCase[0], ipCase[2] );
+ assert.strictEqual( mw.util.isIPv6Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] );
} );
} );
}( mediaWiki, jQuery ) );