* JavaScript for Special:Block
*/
( function ( mw, $ ) {
- $( function ( $ ) {
-
+ $( document ).ready( function () {
var $blockTarget = $( '#mw-bi-target' ),
$anonOnlyRow = $( '#mw-input-wpHardBlock' ).closest( 'tr' ),
$enableAutoblockRow = $( '#mw-input-wpAutoBlock' ).closest( 'tr' ),
$watchUser = $( '#mw-input-wpWatch' ).closest( 'tr' );
function updateBlockOptions( instant ) {
- if ( !$blockTarget.length ) {
- return;
- }
-
var blocktarget = $.trim( $blockTarget.val() ),
isEmpty = blocktarget === '',
isIp = mw.util.isIPv4Address( blocktarget, true ) || mw.util.isIPv6Address( blocktarget, true ),
}
}
- // Bind functions so they're checked whenever stuff changes
- $blockTarget.keyup( updateBlockOptions );
+ if ( $blockTarget.length ) {
+ // Bind functions so they're checked whenever stuff changes
+ $blockTarget.keyup( updateBlockOptions );
- // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
- updateBlockOptions( /* instant= */ true );
+ // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
+ updateBlockOptions( /* instant= */ true );
+ }
} );
}( mediaWiki, jQuery ) );
-/*
+/**
* JavaScript for Special:ChangeEmail
*/
( function ( mw, $ ) {
+ /**
+ * Given an email validity status (true, false, null) update the label CSS class
+ */
+ function updateMailValidityLabel( mail ) {
+ var isValid = mw.util.validateEmail( mail ),
+ $label = $( '#mw-emailaddress-validity' );
-/**
- * Given an email validity status (true, false, null) update the label CSS class
- */
-function updateMailValidityLabel( mail ) {
- var isValid = mw.util.validateEmail( mail ),
- $label = $( '#mw-emailaddress-validity' );
-
- // We allow empty address
- if( isValid === null ) {
- $label.text( '' ).removeClass( 'valid invalid' );
+ // We allow empty address
+ if ( isValid === null ) {
+ $label.text( '' ).removeClass( 'valid invalid' );
- // Valid
- } else if ( isValid ) {
- $label.text( mw.msg( 'email-address-validity-valid' ) ).addClass( 'valid' ).removeClass( 'invalid' );
+ // Valid
+ } else if ( isValid ) {
+ $label.text( mw.msg( 'email-address-validity-valid' ) ).addClass( 'valid' ).removeClass( 'invalid' );
- // Not valid
- } else {
- $label.text( mw.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' );
+ // Not valid
+ } else {
+ $label.text( mw.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' );
+ }
}
-}
-$( document ).ready( function () {
- // Lame tip to let user know if its email is valid. See bug 22449
- // Only bind once for 'blur' so that the user can fill it in without errors
- // After that look at every keypress for direct feedback if it was invalid onblur
- $( '#wpNewEmail' ).one( 'blur', function () {
- if ( $( '#mw-emailaddress-validity' ).length === 0 ) {
- $(this).after( '<label for="wpNewEmail" id="mw-emailaddress-validity"></label>' );
- }
- updateMailValidityLabel( $(this).val() );
- $(this).keyup( function () {
- updateMailValidityLabel( $(this).val() );
+ $( document ).ready( function () {
+ // Lame tip to let user know if its email is valid. See bug 22449.
+ // Only bind once for 'blur' so that the user can fill it in without errors;
+ // after that, look at every keypress for immediate feedback.
+ $( '#wpNewEmail' ).one( 'blur', function () {
+ var $this = $( this );
+ if ( $( '#mw-emailaddress-validity' ).length === 0 ) {
+ $this.after( '<label for="wpNewEmail" id="mw-emailaddress-validity"></label>' );
+ }
+
+ updateMailValidityLabel( $this.val() );
+ $this.keyup( function () {
+ updateMailValidityLabel( $this.val() );
+ } );
} );
} );
-} );
-
}( mediaWiki, jQuery ) );
/**
* JavaScript for Special:MovePage
*/
-
-jQuery( function( $ ) {
+jQuery( document ).ready( function ( $ ) {
$( '#wpReason, #wpNewTitleMain' ).byteLimit();
} );
-/*
+/**
* JavaScript for Special:Preferences
*/
jQuery( document ).ready( function ( $ ) {
$( '#prefsubmit' ).attr( 'id', 'prefcontrol' );
- $preftoc = $('<ul id="preftoc"></ul>'),
- $preferences = $( '#preferences' )
- .addClass( 'jsprefs' )
- .before( $preftoc ),
- $fieldsets = $preferences.children( 'fieldset' )
- .hide()
- .addClass( 'prefsection' ),
- $legends = $fieldsets
- .children( 'legend' )
- .addClass( 'mainLegend' );
+ $preftoc = $('<ul id="preftoc"></ul>');
+ $preferences = $( '#preferences' )
+ .addClass( 'jsprefs' )
+ .before( $preftoc );
+ $fieldsets = $preferences.children( 'fieldset' )
+ .hide()
+ .addClass( 'prefsection' );
+ $legends = $fieldsets
+ .children( 'legend' )
+ .addClass( 'mainLegend' );
/**
- * It uses document.getElementById for security reasons (html injections in
- * jQuery()).
+ * It uses document.getElementById for security reasons (HTML injections in $()).
*
* @param String name: the name of a tab without the prefix ("mw-prefsection-")
* @param String mode: [optional] A hash will be set according to the current
* JavaScript for Special:RecentChanges
*/
( function ( mw, $ ) {
- var rc,
- $checkboxes,
- $select;
+ var rc, $checkboxes, $select;
rc = {
-
/**
* Handler to disable/enable the namespace selector checkboxes when the
* special 'all' namespace is selected/unselected respectively.
*/
updateCheckboxes: function () {
// The option element for the 'all' namespace has an empty value
- var isAllNS = $select.find( 'option:selected' ).val() === '';
+ var isAllNS = $select.val() === '';
// Iterates over checkboxes and propagate the selected option
$checkboxes.prop( 'disabled', isAllNS );
}
};
- $( rc.init );
+ $( document ).ready( rc.init );
mw.special.recentchanges = rc;
-/*
+/**
* JavaScript for Special:Search
*/
-( function ( $, mw ) {
- $( function () {
+( function ( mw, $ ) {
+ $( document ).ready( function () {
var $checkboxes, $headerLinks;
// Emulate HTML5 autofocus behavior in non HTML5 compliant browsers
} );
-}( jQuery, mediaWiki ) );
+}( mediaWiki, jQuery ) );
-/*
- * JavaScript for Specical:Undelete
+/**
+ * JavaScript for Special:Undelete
*/
jQuery( document ).ready( function ( $ ) {
$( '#mw-undelete-invert' ).click( function ( e ) {
- e.preventDefault();
$( '#undelete input[type="checkbox"]' ).prop( 'checked', function ( i, val ) {
return !val;
} );
+ e.preventDefault();
} );
} );
/**
* Add a preview to the upload form
*/
- $( function ( $ ) {
+ $( document ).ready( function () {
/**
* Is the FileAPI available with sufficient functionality?
*/
* @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;
}
$( '#mw-htmlform-source' ).parent().prepend( thumb );
fetchPreview( file, function ( dataURL ) {
- var img = new Image(),
+ var img = new Image(),
rotation = 0;
if ( meta && meta.tiff && meta.tiff.Orientation ) {
/**
* Disable all upload source fields except the selected one
*/
- $( function ( $ ) {
+ $( document ).ready( function () {
var i, $row,
$rows = $( '.mw-htmlform-field-UploadSourceField' );