diff options
Diffstat (limited to 'resources/jquery/jquery.spinner.js')
-rw-r--r-- | resources/jquery/jquery.spinner.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/resources/jquery/jquery.spinner.js b/resources/jquery/jquery.spinner.js new file mode 100644 index 00000000..87e45382 --- /dev/null +++ b/resources/jquery/jquery.spinner.js @@ -0,0 +1,44 @@ +/** + * jQuery spinner + * + * Simple jQuery plugin to create, inject and remove 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': 'mw-spinner', + title: '...' + } ); + }, + + /** + * Removes a spinner element. + * + * @param id {String} + * @return {jQuery} spinner + */ + removeSpinner: function( id ) { + return $( '#mw-spinner-' + id ).remove(); + } +} ); + +/** + * Injects a spinner after the elements in the jQuery collection. + * + * @param id String id of the spinner + * @return {jQuery} + */ +$.fn.injectSpinner = function( id ) { + return this.after( $.createSpinner( id ) ); +}; + +} )( jQuery ); |