jquery.litelay.js
1.14 KB
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
// LiteLay v0.2 - jQuery content loading overlay plugin
(function ($) {
$.fn.litelay = function (options) {
options = options || {};
this.each(function () {
var
$this = $(this),
data = $this.data('litelay'),
litelay = $('<div/>').addClass('litelay'),
content = $('<div/>').addClass('content').appendTo(litelay);
if (options.off === true && !data) {
return;
}
// Check if litelay has already been initialized on this element. If so, remove it.
if (data) {
$this.find('> .litelay').remove();
$this.removeData('litelay');
return;
}
if (options.message) {
content.append('<div class="message">' + options.message + '<div/>');
}
if (options.spinner) {
content.append('<div class="spinner"><div/>');
}
$this.append(litelay);
$this.data('litelay', {
init: true,
});
});
return this;
};
}(jQuery));