* partly fixes two issues exposed by bug 34280
[mediawiki.git] / resources / jquery / jquery.spinner.js
blob87e453823a58e5241edc87b9aaf924d1da721e58
1 /**
2  * jQuery spinner
3  *
4  * Simple jQuery plugin to create, inject and remove spinners.
5  */
6 ( function( $ ) {
8 $.extend( {
9         /**
10          * Creates a spinner element.
11          *
12          * @param id {String} id of the spinner
13          * @return {jQuery} spinner
14          */
15         createSpinner: function( id ) {
16                 return $( '<div>' ).attr( {
17                         id: 'mw-spinner-' + id,
18                         'class': 'mw-spinner',
19                         title: '...'
20                 } );
21         },
23         /**
24          * Removes a spinner element.
25          *
26          * @param id {String}
27          * @return {jQuery} spinner
28          */
29         removeSpinner: function( id ) {
30                 return $( '#mw-spinner-' + id ).remove();
31         }
32 } );
34 /**
35  * Injects a spinner after the elements in the jQuery collection.
36  *
37  * @param id String id of the spinner
38  * @return {jQuery}
39  */
40 $.fn.injectSpinner = function( id ) {
41         return this.after( $.createSpinner( id ) );
44 } )( jQuery );