$lis
.removeClass( 'selected' )
.each( function () {
- var $li = $(this),
+ var $li = $( this ),
$inputs = $li.find( 'input[type="radio"]' ),
- $oldidRadio = $inputs.filter( '[name="oldid"]' ).eq(0),
- $diffRadio = $inputs.filter( '[name="diff"]' ).eq(0);
+ $oldidRadio = $inputs.filter( '[name="oldid"]' ).eq( 0 ),
+ $diffRadio = $inputs.filter( '[name="diff"]' ).eq( 0 );
if ( !$oldidRadio.length || !$diffRadio.length ) {
return true;
$oldidRadio.css( 'visibility', 'hidden' );
}
}
- });
+ } );
return true;
}
// Ideally we'd use e.target instead of $historySubmitter, but e.target points
// to the form element for submit actions, so.
$historyCompareForm.find( '.historysubmit' ).click( function () {
- $historySubmitter = $(this);
+ $historySubmitter = $( this );
} );
// On submit we clone the form element, remove unneeded fields in the clone
if ( $historySubmitter ) {
$copyForm = $historyCompareForm.clone();
$copyRadios = $copyForm.find( '#pagehistory > li' ).find( 'input[name="diff"], input[name="oldid"]' );
- $copyAction = $copyForm.find( '> [name="action"]');
+ $copyAction = $copyForm.find( '> [name="action"]' );
// Remove action=historysubmit and ids[..]=..
if ( $historySubmitter.hasClass( 'mw-history-compareselectedversions-button' ) ) {
// Also remove potentially conflicting id attributes that we don't need anyway
$copyForm
.css( 'display', 'none' )
- .find('[id]')
- .removeAttr('id')
+ .find( '[id]' )
+ .removeAttr( 'id' )
.end()
.insertAfter( $historyCompareForm )
.submit();
$link = $( '<a>', {
text: showText,
href: '#'
- }).click(function () {
+ } ).click( function () {
if ( $table.hasClass( 'collapsed' ) ) {
$( this ).text( hideText );
} else {
}
$table.toggleClass( 'expanded collapsed' );
return false;
- });
+ } );
$col.append( $link );
$row.append( $col );
} );
}
d.resolve( exists );
- })
+ } )
.fail( d.reject );
return d.promise( { abort: apiPromise.abort } );
apiPromise = this.get( {
list: 'allpages',
apprefix: prefix,
- apnamespace: mw.config.get('wgNamespaceIds').category
+ apnamespace: mw.config.get( 'wgNamespaceIds' ).category
} )
.done( function ( data ) {
var texts = [];
} );
}
d.resolve( texts );
- })
+ } )
.fail( d.reject );
return d.promise( { abort: apiPromise.abort } );
// Now on to justification.
// We may still get ragged edges if someone resizes their window. Could bind to
// that event, otoh do we really want to constantly be resizing galleries?
- $( galleries ).each( function() {
+ $( galleries ).each( function () {
var lastTop,
$img,
imgWidth,
rows = [],
$gallery = $( this );
- $gallery.children( 'li' ).each( function() {
+ $gallery.children( 'li' ).each( function () {
// Math.floor to be paranoid if things are off by 0.00000000001
- var top = Math.floor( $(this ).position().top ),
+ var top = Math.floor( $( this ).position().top ),
$this = $( this );
if ( top !== lastTop ) {
captionWidth: $this.children().children( 'div.gallerytextwrapper' ).width(),
height: imgHeight
};
- });
+ } );
- (function () {
+ ( function () {
var maxWidth,
combinedAspect,
combinedPadding,
$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 ) );
}
hookInfo = {
* without a page reload. Currently, the only image formats that can be multi-page images are
* PDF and DjVu files
*/
-( function (mw, $) {
+( function ( mw, $ ) {
// Initialize ajax request variable
var xhr;
} );
}
- $( document ).ready( function() {
+ $( document ).ready( function () {
// The presence of table.multipageimage signifies that this file is a multi-page image
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 && $( 'table.multipageimage' ).length !== 0 ) {
ajaxifyPageNavigation();
if ( state ) {
loadPage( state.url, true );
}
- });
+ } );
}
}
} );
// Bind onchange event handler and append to form
$html.append(
$( select ).change( function () {
- window.location = QUnit.url( { useskin: $(this).val() } );
+ window.location = QUnit.url( { useskin: $( this ).val() } );
} )
);
};
$( '#prefsubmit' ).attr( 'id', 'prefcontrol' );
- $preftoc = $('<ul id="preftoc"></ul>')
+ $preftoc = $( '<ul id="preftoc"></ul>' )
.attr( 'role', 'tablist' );
$preferences = $( '#preferences' )
.addClass( 'jsprefs' )
$( '<div>' ).addClass( 'mw-navigation-hint' )
.text( mediaWiki.msg( 'prefs-tabs-navigation-hint' ) )
.attr( 'tabIndex', 0 )
- .on( 'focus blur', function( e ) {
+ .on( 'focus blur', function ( e ) {
if ( e.type === 'blur' || e.type === 'focusout' ) {
$( this ).css( 'height', '0' );
} else {
// Populate the prefToc
$legends.each( function ( i, legend ) {
- var $legend = $(legend),
+ var $legend = $( legend ),
ident, $li, $a;
if ( i === 0 ) {
$legend.parent().show();
} );
// Enable keyboard users to use left and right keys to switch tabs
- $preftoc.on( 'keydown', function( event ) {
+ $preftoc.on( 'keydown', function ( event ) {
var keyLeft = 37,
keyRight = 39,
$el;
if ( 'onhashchange' in window &&
( document.documentMode === undefined || document.documentMode >= 8 )
) {
- $(window).on( 'hashchange' , function () {
+ $( window ).on( 'hashchange' , function () {
var hash = window.location.hash;
if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) {
switchPrefTab( hash.replace( '#mw-prefsection-', '' ) );
} else if ( hash === '' ) {
switchPrefTab( 'personal', 'noHash' );
}
- });
+ } );
// In older browsers we'll bind a click handler as fallback.
// We must not have onhashchange *and* the click handlers, other wise
// the click handler calls switchPrefTab() which sets the hash value,
$preftoc.on( 'click', 'li a', function ( e ) {
switchPrefTab( $( this ).attr( 'href' ).replace( '#mw-prefsection-', '' ) );
e.preventDefault();
- });
+ } );
}
/**
}
// Create check all/none button
- $checkboxes = $('#powersearch input[id^=mw-search-ns]');
- $('#mw-search-togglebox').append(
- $('<label>')
- .text(mw.msg('powersearch-togglelabel'))
+ $checkboxes = $( '#powersearch input[id^=mw-search-ns]' );
+ $( '#mw-search-togglebox' ).append(
+ $( '<label>' )
+ .text( mw.msg( 'powersearch-togglelabel' ) )
).append(
- $('<input type="button" />')
+ $( '<input type="button" />' )
.attr( 'id', 'mw-search-toggleall' )
- .prop( 'value', mw.msg('powersearch-toggleall' ) )
+ .prop( 'value', mw.msg( 'powersearch-toggleall' ) )
.click( function () {
- $checkboxes.prop('checked', true);
+ $checkboxes.prop( 'checked', true );
} )
).append(
- $('<input type="button" />')
+ $( '<input type="button" />' )
.attr( 'id', 'mw-search-togglenone' )
- .prop( 'value', mw.msg('powersearch-togglenone' ) )
- .click( function() {
+ .prop( 'value', mw.msg( 'powersearch-togglenone' ) )
+ .click( function () {
$checkboxes.prop( 'checked', false );
} )
);
// Change the header search links to what user entered
$headerLinks = $( '.search-types a' );
$( '#searchText, #powerSearchText' ).change( function () {
- var searchterm = $(this).val();
+ var searchterm = $( this ).val();
$headerLinks.each( function () {
- var parts = $(this).attr('href').split( 'search=' ),
+ var parts = $( this ).attr( 'href' ).split( 'search=' ),
lastpart = '',
prefix = 'search=';
- if ( parts.length > 1 && parts[1].indexOf('&') >= 0 ) {
- lastpart = parts[1].substring( parts[1].indexOf('&') );
+ if ( parts.length > 1 && parts[1].indexOf( '&' ) >= 0 ) {
+ lastpart = parts[1].substring( parts[1].indexOf( '&' ) );
} else {
prefix = '&search=';
}
this.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart;
- });
- }).trigger( 'change' );
+ } );
+ } ).trigger( 'change' );
} );
thumb.find( '.filename' ).text( file.name ).end()
.find( '.fileinfo' ).text( prettySize( file.size ) ).end();
- $canvas = $('<canvas width="' + previewSize + '" height="' + previewSize + '" ></canvas>');
+ $canvas = $( '<canvas width="' + previewSize + '" height="' + previewSize + '" ></canvas>' );
ctx = $canvas[0].getContext( '2d' );
$( '#mw-htmlform-source' ).parent().prepend( thumb );
width = img.width / img.height * previewSize;
}
// Determine the offset required to center the image
- dx = (180 - width) / 2;
- dy = (180 - height) / 2;
+ dx = ( 180 - width ) / 2;
+ dy = ( 180 - height ) / 2;
switch ( rotation ) {
// If a rotation is applied, the direction of the axis
// changes as well. You can derive the values below by
ctx.clearRect( 0, 0, 180, 180 );
ctx.rotate( rotation / 180 * Math.PI );
ctx.drawImage( img, x, y, width, height );
- thumb.find('.mw-small-spinner').replaceWith($canvas);
+ thumb.find( '.mw-small-spinner' ).replaceWith( $canvas );
// Image size
info = mw.msg( 'widthheight', logicalWidth, logicalHeight ) +
if ( callbackBinary && 'readAsBinaryString' in reader ) {
// To fetch JPEG metadata we need a binary string; start there.
// todo:
- reader.onload = function() {
+ reader.onload = function () {
callbackBinary( reader.result );
// Now run back through the regular code path.
// readAsArrayBuffer replaces readAsBinaryString
// However, our JPEG metadata library wants a string.
// So, this is going to be an ugly conversion.
- reader.onload = function() {
+ reader.onload = function () {
var i,
buffer = new Uint8Array( reader.result ),
string = '';
}
for ( i = $rows.length; i; i-- ) {
- $row = $rows.eq(i - 1);
+ $row = $rows.eq( i - 1 );
$row
.find( 'input[name="wpSourceType"]' )
.change( createHandler( $row ) );
/**
* Example to declare existing titles:
- * Title.exist.set(['User:John_Doe', ...]);
+ * Title.exist.set( ['User:John_Doe', ...] );
* Eample to declare titles nonexistent:
- * Title.exist.set(['File:Foo_bar.jpg', ...], false);
+ * Title.exist.set( ['File:Foo_bar.jpg', ...], false );
*
* @static
* @property exist.set
*/
Uri.encode = function ( s ) {
return encodeURIComponent( s )
- .replace( /!/g, '%21').replace( /'/g, '%27').replace( /\(/g, '%28')
- .replace( /\)/g, '%29').replace( /\*/g, '%2A')
+ .replace( /!/g, '%21' ).replace( /'/g, '%27' ).replace( /\(/g, '%28' )
+ .replace( /\)/g, '%29' ).replace( /\*/g, '%2A' )
.replace( /%20/g, '+' );
};
*/
switchPane: function ( e ) {
var currentPaneId = debug.$container.data( 'currentPane' ),
- requestedPaneId = $(this).prop( 'id' ).substr( 9 ),
+ requestedPaneId = $( this ).prop( 'id' ).substr( 9 ),
$currentPane = $( '#mw-debug-pane-' + currentPaneId ),
$requestedPane = $( '#mw-debug-pane-' + requestedPaneId ),
hovDone = false;
// Skip hash fragment handling. Prevents screen from jumping.
e.preventDefault();
- $( this ).addClass( 'current ');
- $( '.mw-debug-panelink' ).not( this ).removeClass( 'current ');
+ $( this ).addClass( 'current ' );
+ $( '.mw-debug-panelink' ).not( this ).removeClass( 'current ' );
// Hide the current pane
if ( requestedPaneId === currentPaneId ) {
* @return {jQuery}
*/
function bitDiv( id ) {
- return $( '<div>' ).prop({
+ return $( '<div>' ).prop( {
id: 'mw-debug-' + id,
className: 'mw-debug-bit'
- })
+ } )
.appendTo( $bits );
}
*/
function paneLabel( id, text ) {
return $( '<a>' )
- .prop({
+ .prop( {
className: 'mw-debug-panelabel',
href: '#mw-debug-pane-' + id
- })
+ } )
.text( text );
}
if ( count ) {
text = text + ' (' + count + ')';
}
- return $( '<div>' ).prop({
+ return $( '<div>' ).prop( {
id: 'mw-debug-' + id,
className: 'mw-debug-bit mw-debug-panelink'
- })
+ } )
.append( paneLabel( id, text ) )
.appendTo( $bits );
}
}
$( '<div>' )
- .prop({
+ .prop( {
className: 'mw-debug-pane',
id: 'mw-debug-pane-' + id
- })
+ } )
.append( panes[id] )
.appendTo( $container );
}
*/
$.fn.goIn = function ( instantToggle ) {
if ( instantToggle === true ) {
- return $(this).show();
+ return $( this ).show();
}
- return $(this).stop( true, true ).fadeIn();
+ return $( this ).stop( true, true ).fadeIn();
};
/**
*/
$.fn.goOut = function ( instantToggle ) {
if ( instantToggle === true ) {
- return $(this).hide();
+ return $( this ).hide();
}
- return $(this).stop( true, true ).fadeOut();
+ return $( this ).stop( true, true ).fadeOut();
};
/**
* @param {Function} callback Takes one parameter, which is {true} when the
* event is called immediately, and {jQuery.Event} when triggered from an event.
*/
- $.fn.liveAndTestAtStart = function ( callback ){
- $(this)
+ $.fn.liveAndTestAtStart = function ( callback ) {
+ $( this )
.live( 'change', callback )
.each( function () {
callback.call( this, true );
// Animate the SelectOrOther fields, to only show the text field when
// 'other' is selected.
$( '.mw-htmlform-select-or-other' ).liveAndTestAtStart( function ( instant ) {
- var $other = $( '#' + $(this).attr( 'id' ) + '-other' );
+ var $other = $( '#' + $( this ).attr( 'id' ) + '-other' );
$other = $other.add( $other.siblings( 'br' ) );
- if ( $(this).val() === 'other' ) {
+ if ( $( this ).val() === 'other' ) {
$other.goIn( instant );
} else {
$other.goOut( instant );
}
- });
+ } );
} );
'class': 'htmlform-chzn-select mw-input ' + oldClass
} );
$oldContainer.find( 'input' ).each( function () {
- var $oldInput = $(this),
+ var $oldInput = $( this ),
checked = $oldInput.prop( 'checked' ),
$option = $( '<option>' );
$option.prop( 'value', $oldInput.prop( 'value' ) );
/**
* N.B. replacements are variadic arguments or an array in second parameter. In other words:
- * somefunction(a, b, c, d)
+ * somefunction( a, b, c, d )
* is equivalent to
- * somefunction(a, [b, c, d])
+ * somefunction( a, [b, c, d] )
*
* @param {string} key Message key.
* @param {Array|mixed} replacements Optional variable replacements (variadically or an array).
var failableParserFn = getFailableParserFn( options );
/**
* N.B. replacements are variadic arguments or an array in second parameter. In other words:
- * somefunction(a, b, c, d)
+ * somefunction( a, b, c, d )
* is equivalent to
- * somefunction(a, [b, c, d])
+ * somefunction( a, [b, c, d] )
*
* We append to 'this', which in a jQuery plugin context will be the selected elements.
* @param {string} key Message key.
// This may be because, to save code, memoization was removed
regularLiteral = makeRegexParser( /^[^{}\[\]$<\\]/ );
- regularLiteralWithoutBar = makeRegexParser(/^[^{}\[\]$\\|]/);
- regularLiteralWithoutSpace = makeRegexParser(/^[^{}\[\]$\s]/);
+ regularLiteralWithoutBar = makeRegexParser( /^[^{}\[\]$\\|]/ );
+ regularLiteralWithoutSpace = makeRegexParser( /^[^{}\[\]$\s]/ );
regularLiteralWithSquareBrackets = makeRegexParser( /^[^{}$\\]/ );
backslash = makeStringParser( '\\' );
// Used to define "literals" without spaces, in space-delimited situations
function literalWithoutSpace() {
var result = nOrMore( 1, escapedOrLiteralWithoutSpace )();
- return result === null ? null : result.join('');
+ return result === null ? null : result.join( '' );
}
// Used to define "literals" within template parameters. The pipe character is the parameter delimeter, so by default
// it is not a literal in the parameter
function literalWithoutBar() {
var result = nOrMore( 1, escapedOrLiteralWithoutBar )();
- return result === null ? null : result.join('');
+ return result === null ? null : result.join( '' );
}
// Used for wikilink page names. Like literalWithoutBar, but
// without allowing escapes.
function unescapedLiteralWithoutBar() {
var result = nOrMore( 1, regularLiteralWithoutBar )();
- return result === null ? null : result.join('');
+ return result === null ? null : result.join( '' );
}
function literal() {
var result = nOrMore( 1, escapedOrRegularLiteral )();
- return result === null ? null : result.join('');
+ return result === null ? null : result.join( '' );
}
function curlyBraceTransformExpressionLiteral() {
var result = nOrMore( 1, regularLiteralWithSquareBrackets )();
- return result === null ? null : result.join('');
+ return result === null ? null : result.join( '' );
}
asciiAlphabetLiteral = makeRegexParser( /[A-Za-z]+/ );
whitespace,
asciiAlphabetLiteral,
htmlAttributeEquals,
- choice( [
+ choice( [
doubleQuotedHtmlAttributeValue,
singleQuotedHtmlAttributeValue
] )
endTagName = parsedCloseTagResult[1];
wrappedAttributes = parsedOpenTagResult[2];
attributes = wrappedAttributes.slice( 1 );
- if ( isAllowedHtml( startTagName, endTagName, attributes) ) {
+ if ( isAllowedHtml( startTagName, endTagName, attributes ) ) {
result = [ 'HTMLELEMENT', startTagName, wrappedAttributes ].concat( parsedHtmlContents );
} else {
// HTML is not allowed, so contents will remain how
] );
return result === null ? null : [ result[0], result[2] ];
}
- colon = makeStringParser(':');
+ colon = makeStringParser( ':' );
templateContents = choice( [
function () {
var res = sequence( [
return [ res[0] ].concat( res[1] );
}
] );
- openTemplate = makeStringParser('{{');
- closeTemplate = makeStringParser('}}');
+ openTemplate = makeStringParser( '{{' );
+ closeTemplate = makeStringParser( '}}' );
nonWhitespaceExpression = choice( [
template,
wikilink,
* Transform parsed structure into external link
* If the href is a jQuery object, treat it as "enclosing" the link text.
* ... function, treat it as the click handler
- * ... string, treat it as a URI
+ * ... string, treat it as a URI
* TODO: throw an error if nodes.length > 2 ?
* @param {Array} of two elements, {jQuery|Function|String} and {String}
* @return {jQuery}
extlinkparam: function ( nodes, replacements ) {
var replacement,
index = parseInt( nodes[0], 10 );
- if ( index < replacements.length) {
+ if ( index < replacements.length ) {
replacement = replacements[index];
} else {
replacement = '$' + ( index + 1 );
plural: function ( nodes ) {
var forms, count;
count = parseFloat( this.language.convertNumber( nodes[0], true ) );
- forms = nodes.slice(1);
+ forms = nodes.slice( 1 );
return forms.length ? this.language.convertPlural( count, forms ) : '';
},
// Caching is somewhat problematic, because we do need different message functions for different maps, so
// we'd have to cache the parser as a member of this.map, which sounds a bit ugly.
// Do not use mw.jqueryMsg unless required
- if ( this.format === 'plain' || !/\{\{|[\[<>]/.test(this.map.get( this.key ) ) ) {
+ if ( this.format === 'plain' || !/\{\{|[\[<>]/.test( this.map.get( this.key ) ) ) {
// Fall back to mw.msg's simple parser
return oldParser.apply( this );
}
.text( mw.msg( 'hidetoc' ) )
.click( function ( e ) {
e.preventDefault();
- util.toggleToc( $(this) );
+ util.toggleToc( $( this ) );
} );
$tocTitle.append(
$tocToggleLink
* This function returns the styleSheet object for convience (due to cross-browsers
* difference as to where it is located).
*
- * var sheet = mw.util.addCSS('.foobar { display: none; }');
- * $(foo).click(function () {
+ * var sheet = mw.util.addCSS( '.foobar { display: none; }' );
+ * $( foo ).click( function () {
* // Toggle the sheet on and off
* sheet.disabled = !sheet.disabled;
- * });
+ * } );
*
* @param {string} text CSS to be appended
* @return {CSSStyleSheet} Use .ownerNode to get to the `<style>` element.
// the ABNF:
// 1 * ( atext / "." ) "@" ldh-str 1*( "." ldh-str )
// With:
- // - atext : defined in RFC 5322 section 3.2.3
+ // - atext : defined in RFC 5322 section 3.2.3
// - ldh-str : defined in RFC 1034 section 3.5
//
// (see STD 68 / RFC 5234 http://tools.ietf.org/html/std68)
// RegExp is case insensitive
'i'
);
- return (null !== mailtxt.match( html5EmailRegexp ) );
+ return ( null !== mailtxt.match( html5EmailRegexp ) );
},
/**