From: John Du Hart Date: Wed, 24 Aug 2011 21:08:39 +0000 (+0000) Subject: (bug 30499) Create jQuery replacements for injectSpinner and removeSpinner X-Git-Tag: 1.31.0-rc.0~28088 X-Git-Url: http://git.cyclocoop.org/data/modifier.php?a=commitdiff_plain;h=3b4e0b46e954f9490f571359ec35565a6f4ff0b9;p=lhc%2Fweb%2Fwiklou.git (bug 30499) Create jQuery replacements for injectSpinner and removeSpinner --- diff --git a/resources/Resources.php b/resources/Resources.php index 898d241fd4..4d4b8f51ed 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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', diff --git a/resources/jquery/images/spinner.gif b/resources/jquery/images/spinner.gif new file mode 100644 index 0000000000..d0bce15423 Binary files /dev/null and b/resources/jquery/images/spinner.gif differ diff --git a/resources/jquery/jquery.spinner.css b/resources/jquery/jquery.spinner.css new file mode 100644 index 0000000000..d3dd093d7a --- /dev/null +++ b/resources/jquery/jquery.spinner.css @@ -0,0 +1,8 @@ +.loading-spinner { + /* @embed */ + background: transparent url('images/spinner.gif'); + height: 16px; + width: 16px; + display: inline-block; + vertical-align: middle; +} \ No newline at end of file diff --git a/resources/jquery/jquery.spinner.js b/resources/jquery/jquery.spinner.js new file mode 100644 index 0000000000..5536ecc877 --- /dev/null +++ b/resources/jquery/jquery.spinner.js @@ -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 $( '
' ) + .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 ); \ No newline at end of file