/
jsgrid.load-indicator.js
executable file
·82 lines (64 loc) · 2.02 KB
/
jsgrid.load-indicator.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
(function(jsGrid, $, undefined) {
function LoadIndicator(config) {
this._init(config);
}
LoadIndicator.prototype = {
container: "body",
message: "Loading...",
shading: true,
zIndex: 1000,
shaderClass: "jsgrid-load-shader",
loadPanelClass: "jsgrid-load-panel",
_init: function(config) {
$.extend(true, this, config);
this._initContainer();
this._initShader();
this._initLoadPanel();
},
_initContainer: function() {
this._container = $(this.container);
},
_initShader: function() {
if(!this.shading)
return;
this._shader = $("<div>").addClass(this.shaderClass)
.hide()
.css({
position: "absolute",
top: 0,
right: 0,
bottom: 0,
left: 0,
zIndex: this.zIndex
})
.appendTo(this._container);
},
_initLoadPanel: function() {
this._loadPanel = $("<div>").addClass(this.loadPanelClass)
.text(this.message)
.hide()
.css({
position: "absolute",
top: "50%",
left: "50%",
zIndex: this.zIndex
})
.appendTo(this._container);
},
show: function() {
var $loadPanel = this._loadPanel.show();
var actualWidth = $loadPanel.outerWidth();
var actualHeight = $loadPanel.outerHeight();
$loadPanel.css({
marginTop: -actualHeight / 2,
marginLeft: -actualWidth / 2
});
this._shader.show();
},
hide: function() {
this._loadPanel.hide();
this._shader.hide();
}
};
jsGrid.LoadIndicator = LoadIndicator;
}(jsGrid, jQuery));