(Follows-up r95445)
* Using the same spinner as before, preserving svn history (20px vs. 16px)
* Adding a line-break at the end of file and changing indentation per our conventions
* Adjusting doc to reflect the plugin itself instead of what it replaces.
* Using shorthand utility in jQuery (no / and using the attr-object as second argument)
* Adding @return comment to $.fn.injectSpinner
* Adding return statement to $.removerSpinner (returning a jQuery object of the element). Could be useful, but better than not having a return value at all.
JSHint:
* Adding parentheses around the class object property, otherwise it may be interpreted as a class operator which breaks the object.
- background: transparent url('images/spinner.gif');
- height: 16px;
- width: 16px;
+ background: transparent url(images/spinner.gif);
+ height: 20px;
+ width: 20px;
display: inline-block;
vertical-align: middle;
}
\ No newline at end of file
display: inline-block;
vertical-align: middle;
}
\ No newline at end of file
- * Functions to replace injectSpinner which makes img tags with spinners
+ * jQuery spinner
+ *
+ * Simple jQuery plugin to create, inject and remove spinners.
*/
( function( $ ) {
$.extend( {
/**
*/
( function( $ ) {
$.extend( {
/**
- * Creates a spinner element
+ * Creates a spinner element.
- * @param id String id of the spinner
- * @return jQuery spinner
+ * @param id {String} id of the spinner
+ * @return {jQuery} spinner
*/
createSpinner: function( id ) {
*/
createSpinner: function( id ) {
- return $( '<div/>' )
- .attr({
- id: 'mw-spinner-' + id,
- class: 'loading-spinner',
- title: '...',
- alt: '...'
- });
+ return $( '<div>' ).attr( {
+ id: 'mw-spinner-' + id,
+ 'class': 'mw-spinner',
+ title: '...',
+ alt: '...'
+ } );
- * Removes a spinner element
+ * Removes a spinner element.
+ * @param id {String}
+ * @return {jQuery} spinner
*/
removeSpinner: function( id ) {
*/
removeSpinner: function( id ) {
- $( '#mw-spinner-' + id ).remove();
+ return $( '#mw-spinner-' + id ).remove();
- * Injects a spinner after the given objects
+ * Injects a spinner after the elements in the jQuery collection.
*
* @param id String id of the spinner
*
* @param id String id of the spinner
*/
$.fn.injectSpinner = function( id ) {
return this.after( $.createSpinner( id ) );
};
*/
$.fn.injectSpinner = function( id ) {
return this.after( $.createSpinner( id ) );
};
-} )( jQuery );
\ No newline at end of file