(bug 30499) Create jQuery replacements for injectSpinner and removeSpinner

This commit is contained in:
John Du Hart 2011-08-24 21:08:39 +00:00
parent 0f90a6b10e
commit 3b4e0b46e9
4 changed files with 54 additions and 0 deletions

View file

@ -156,6 +156,10 @@ return array(
'jquery.qunit.completenessTest' => array(
'scripts' => 'resources/jquery/jquery.qunit.completenessTest.js',
),
'jquery.spinner' => array(
'scripts' => 'resources/jquery/jquery.spinner.js',
'styles' => 'resources/jquery/jquery.spinner.css',
),
'jquery.suggestions' => array(
'scripts' => 'resources/jquery/jquery.suggestions.js',
'styles' => 'resources/jquery/jquery.suggestions.css',

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

View file

@ -0,0 +1,8 @@
.loading-spinner {
/* @embed */
background: transparent url('images/spinner.gif');
height: 16px;
width: 16px;
display: inline-block;
vertical-align: middle;
}

View file

@ -0,0 +1,42 @@
/**
* Functions to replace injectSpinner which makes img tags with spinners
*/
( function( $ ) {
$.extend( {
/**
* Creates a spinner element
*
* @param id String id of the spinner
* @return jQuery spinner
*/
createSpinner: function( id ) {
return $( '<div/>' )
.attr({
id: 'mw-spinner-' + id,
class: 'loading-spinner',
title: '...',
alt: '...'
});
},
/**
* Removes a spinner element
*
* @param id
*/
removeSpinner: function( id ) {
$( '#mw-spinner-' + id ).remove();
}
} );
/**
* Injects a spinner after the given objects
*
* @param id String id of the spinner
*/
$.fn.injectSpinner = function( id ) {
return this.after( $.createSpinner( id ) );
};
} )( jQuery );