Follows-up
fcf4934a52.
protect:
* Use jQuery instead.
* Removing now-obsolete dependency.
* Make cell.appendChild more obvious and potentialy faster
by grouping the dom actions in 1 sequence.
config:
* Removing obsolete dependency.
upload:
* Use jquery.spinner instead.
* Removing now-obsolete dependency.
jquery.spinner:
* While at it, updated documentation to be included in our
jsduck index, similar to jquery.localize.
jsduck/external.js:
* Added @static to jQuery.ajax which was missing, it showed up
between instance methods like jQuery#injectSpinner.
The only module left using mediawiki.legacy.wikibits is
mediawiki.legacy.ajax which remains in tact for now.
Bug: 56726
Change-Id: I712112626a99dc2d0090f554c56052770cd0ae88
"../../resources/mediawiki.action/mediawiki.action.view.postEdit.js",
"../../resources/mediawiki.page/mediawiki.page.startup.js",
"../../resources/mediawiki.api",
- "../../resources/jquery/jquery.localize.js"
+ "../../resources/jquery/jquery.localize.js",
+ "../../resources/jquery/jquery.spinner.js"
]
}
/**
* @method ajax
+ * @static
* @source <http://api.jquery.com/jQuery.ajax/>
* @return {jqXHR}
*/
'size-gigabytes',
'largefileserver',
),
- 'dependencies' => array( 'mediawiki.libs.jpegmeta', 'mediawiki.util' ),
+ 'dependencies' => array(
+ 'mediawiki.libs.jpegmeta',
+ 'mediawiki.util',
+ ),
),
'mediawiki.special.userlogin' => array(
'styles' => array(
'remoteBasePath' => $GLOBALS['wgStylePath'],
'localBasePath' => $GLOBALS['wgStyleDirectory'],
'dependencies' => array(
- 'mediawiki.legacy.wikibits',
'jquery.byteLimit',
),
'position' => 'top',
'remoteBasePath' => $GLOBALS['wgStylePath'],
'localBasePath' => $GLOBALS['wgStyleDirectory'],
'dependencies' => array(
+ 'jquery.spinner',
'mediawiki.api',
'mediawiki.Title',
- 'mediawiki.legacy.wikibits',
'mediawiki.util',
),
),
/**
- * jQuery spinner
+ * jQuery Spinner
*
* Simple jQuery plugin to create, inject and remove spinners.
+ *
+ * @class jQuery.plugin.spinner
*/
( function ( $ ) {
$.extend({
/**
- * Creates a spinner element.
+ * Create a spinner element
*
* The argument is an object with options used to construct the spinner. These can be:
*
* It is a good practice to keep a reference to the created spinner to be able to remove it later.
- * Alternatively one can use the id option and removeSpinner() (but make sure to choose an id
+ * Alternatively one can use the id option and #removeSpinner (but make sure to choose an id
* that's unlikely to cause conflicts, e.g. with extensions, gadgets or user scripts).
*
* CSS classes used:
- * .mw-spinner for every spinner
- * .mw-spinner-small / .mw-spinner-large for size
- * .mw-spinner-block / .mw-spinner-inline for display types
+ * - .mw-spinner for every spinner
+ * - .mw-spinner-small / .mw-spinner-large for size
+ * - .mw-spinner-block / .mw-spinner-inline for display types
*
- * @example
* // Create a large spinner reserving all available horizontal space.
* var $spinner = $.createSpinner({ size: 'large', type: 'block' });
* // Insert above page content.
* $( '#mw-content-text' ).prepend( $spinner );
- * @example
+ *
* // Place a small inline spinner next to the "Save" button
* var $spinner = $.createSpinner({ size: 'small', type: 'inline' });
* // Alternatively, just `$.createSpinner();` as these are the default options.
* $( '#wpSave' ).after( $spinner );
- * @example
+ *
* // The following two are equivalent:
* $.createSpinner( 'magic' );
* $.createSpinner({ id: 'magic' });
*
- * @param {Object|String} opts [optional] ID string or options:
- * - id: If given, spinner will be given an id of "mw-spinner-<id>"
+ * @static
+ * @inheritable
+ * @param {Object|string} [opts] ID string or options:
+ * - id: If given, spinner will be given an id of "mw-spinner-{id}"
* - size: 'small' (default) or 'large' for a 20-pixel or 32-pixel spinner
* - type: 'inline' (default) or 'block'. Inline creates an inline-block with width and
* height equal to spinner size. Block is a block-level element with width 100%, height
},
/**
- * Removes a spinner element.
+ * Remove a spinner element
*
- * @param {String} id [optional] Id of the spinner, as passed to createSpinner.
- * @return {jQuery} The (now detached) spinner.
+ * @static
+ * @inheritable
+ * @param {string} id Id of the spinner, as passed to #createSpinner
+ * @return {jQuery} The (now detached) spinner element
*/
removeSpinner: function ( id ) {
return $( '#mw-spinner-' + id ).remove();
});
/**
- * Injects a spinner after the elements in the jQuery collection
- * (as siblings, not children). Collection contents remain unchanged.
+ * Inject a spinner after each element in the collection
+ *
+ * Inserts spinner as siblings, not children, of the target elements.
+ * Collection contents remain unchanged.
*
- * @param {Object|String} opts See createSpinner() for description.
+ * @param {Object|string} [opts] See #createSpinner
* @return {jQuery}
*/
$.fn.injectSpinner = function ( opts ) {
return this.after( $.createSpinner( opts ) );
};
+
+ /**
+ * @class jQuery
+ * @mixins jQuery.plugin.spinner
+ */
+
}( jQuery ) );
check = document.createElement( 'input' );
check.id = 'mwProtectUnchained';
check.type = 'checkbox';
- cell.appendChild( check );
- window.addClickHandler( check, function () {
+ $( check ).click( function () {
ProtectionForm.onChainClick();
} );
- cell.appendChild( document.createTextNode( ' ' ) );
label = document.createElement( 'label' );
label.htmlFor = 'mwProtectUnchained';
label.appendChild( document.createTextNode( opts.labelText ) );
+
+ cell.appendChild( check );
+ cell.appendChild( document.createTextNode( ' ' ) );
cell.appendChild( label );
check.checked = !this.areAllTypesMatching();
( function ( mw, $ ) {
var licenseSelectorCheck, wgUploadWarningObj, wgUploadLicenseObj, fillDestFilename,
ajaxUploadDestCheck = mw.config.get( 'wgAjaxUploadDestCheck' ),
- fileExtensions = mw.config.get( 'wgFileExtensions' );
+ fileExtensions = mw.config.get( 'wgFileExtensions' ),
+ $spinnerDestCheck, $spinnerLicense;
licenseSelectorCheck = window.licenseSelectorCheck = function () {
var selector = document.getElementById( 'wpLicense' ),
if ( !ajaxUploadDestCheck || this.nameToCheck === '' ) {
return;
}
- window.injectSpinner( document.getElementById( 'wpDestFile' ), 'destcheck' );
+ $spinnerDestCheck = $.createSpinner().insertAfter( '#wpDestFile' );
var uploadWarningObj = this;
( new mw.Api() ).get( {
},
processResult: function ( result, fileName ) {
- window.removeSpinner( 'destcheck' );
+ $spinnerDestCheck.remove();
+ $spinnerDestCheck = undefined;
this.setWarning( result.html );
this.responseCache[fileName] = result.html;
},
var warningElt = document.getElementById( 'wpDestFile-warning' ),
ackElt = document.getElementsByName( 'wpDestFileWarningAck' );
- this.setInnerHTML(warningElt, warning);
+ this.setInnerHTML( warningElt, warning );
// Set a value in the form indicating that the warning is acknowledged and
// doesn't need to be redisplayed post-upload
return;
}
}
- window.injectSpinner( document.getElementById( 'wpLicense' ), 'license' );
+
+ $spinnerLicense = $.createSpinner().insertAfter( '#wpLicense' );
title = document.getElementById( 'wpDestFile' ).value;
if ( !title ) {
},
processResult: function ( result, license ) {
- window.removeSpinner( 'license' );
+ $spinnerLicense.remove();
+ $spinnerLicense = undefined;
this.responseCache[license] = result.parse.text['*'];
this.showPreview( this.responseCache[license] );
},