Projekt

Obecné

Profil

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

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

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

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

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

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