Projekt

Obecné

Profil

Stáhnout (1.33 KB) Statistiky
| Větev: | Tag: | Revize:
1
/**
2
 * Loader animation displayed when running some expensive operation.
3
 * 
4
 * @param {*object} options 
5
 */
6
function Loader(options) {
7
	var defaultOptions = {
8
		lines: 17, // The number of lines to draw
9
		length: 21, // The length of each line
10
		width: 8, // The line thickness
11
		radius: 40, // The radius of the inner circle
12
		rotate: 0, // The rotation offset
13
		color: '#000', // #rgb or #rrggbb
14
		speed: 1.2, // Rounds per second
15
		trail: 58, // Afterglow percentage
16
		shadow: true, // Whether to render a shadow
17
		hwaccel: true, // Whether to use hardware acceleration
18
		className: 'spinner', // The CSS class to assign to the spinner
19
		zIndex: 2e9 // The z-index (defaults to 2000000000)
20
	};
21

    
22
	var opts = $.extend(defaultOptions, options);
23

    
24
	/**
25
	 * Spin jQuery plugin.
26
	 */
27
	$.fn.spin = function(opts) {
28
		this.each(function() {
29
			var $this = $(this),
30
			data = $this.data();
31
			
32
			if (data.spinner) {
33
				data.spinner.stop();
34
				delete data.spinner;
35
			}
36

    
37
			if (opts !== false) {
38
				data.spinner = new Spinner($.extend({
39
					color: $this.css('color')
40
				}, opts)).spin(this);
41
			}
42
		});
43
		return this;
44
	};
45

    
46
	/**
47
	* Enables loader.
48
	*/
49
	this.enable = function() {
50
		$('#loader').show();
51
		$('#spinLoader').spin(opts);
52
	};
53

    
54
	/**
55
	* Disables loader.
56
	*/
57
	this.disable = function() {
58
		$('#loader').hide();
59
		$('#spinLoader').spin(false);
60
	};
61
}
(10-10/19)