kendo.mobile.loader.js
7.01 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Kendo UI v2016.1.112 (http://www.telerik.com/kendo-ui)
* Copyright 2016 Telerik AD. All rights reserved.
*
* Kendo UI commercial licenses may be obtained at
* http://www.telerik.com/purchase/license-agreement/kendo-ui-complete
* If you do not own a commercial license, this file shall be governed by the trial license terms.
*/
(function (f, define) {
define('kendo.mobile.loader', ['kendo.core'], f);
}(function () {
var __meta__ = {
id: 'mobile.loader',
name: 'Loader',
category: 'mobile',
description: 'Mobile Loader',
depends: ['core'],
hidden: true
};
(function ($, undefined) {
var kendo = window.kendo, ui = kendo.mobile.ui, Widget = ui.Widget, CAPTURE_EVENTS = $.map(kendo.eventMap, function (value) {
return value;
}).join(' ').split(' ');
var Loader = Widget.extend({
init: function (container, options) {
var that = this, element = $('<div class="km-loader"><span class="km-loading km-spin"></span><span class="km-loading-left"></span><span class="km-loading-right"></span></div>');
Widget.fn.init.call(that, element, options);
that.container = container;
that.captureEvents = false;
that._attachCapture();
element.append(that.options.loading).hide().appendTo(container);
},
options: {
name: 'Loader',
loading: '<h1>Loading...</h1>',
timeout: 100
},
show: function () {
var that = this;
clearTimeout(that._loading);
if (that.options.loading === false) {
return;
}
that.captureEvents = true;
that._loading = setTimeout(function () {
that.element.show();
}, that.options.timeout);
},
hide: function () {
this.captureEvents = false;
clearTimeout(this._loading);
this.element.hide();
},
changeMessage: function (message) {
this.options.loading = message;
this.element.find('>h1').html(message);
},
transition: function () {
this.captureEvents = true;
this.container.css('pointer-events', 'none');
},
transitionDone: function () {
this.captureEvents = false;
this.container.css('pointer-events', '');
},
_attachCapture: function () {
var that = this;
that.captureEvents = false;
function capture(e) {
if (that.captureEvents) {
e.preventDefault();
}
}
for (var i = 0; i < CAPTURE_EVENTS.length; i++) {
that.container[0].addEventListener(CAPTURE_EVENTS[i], capture, true);
}
}
});
ui.plugin(Loader);
}(window.kendo.jQuery));
return window.kendo;
}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
(a3 || a2)();
}));