summaryrefslogtreecommitdiff
path: root/resources/jquery/jquery.spinner.js
blob: 87e453823a58e5241edc87b9aaf924d1da721e58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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 );