(bug 30499) Create jQuery replacements for injectSpinner and removeSpinner
This commit is contained in:
parent
0f90a6b10e
commit
3b4e0b46e9
4 changed files with 54 additions and 0 deletions
|
|
@ -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',
|
||||
|
|
|
|||
BIN
resources/jquery/images/spinner.gif
Normal file
BIN
resources/jquery/images/spinner.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 673 B |
8
resources/jquery/jquery.spinner.css
Normal file
8
resources/jquery/jquery.spinner.css
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
.loading-spinner {
|
||||
/* @embed */
|
||||
background: transparent url('images/spinner.gif');
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
42
resources/jquery/jquery.spinner.js
Normal file
42
resources/jquery/jquery.spinner.js
Normal 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 );
|
||||
Loading…
Reference in a new issue