kendo.mobile.shim.js
7.87 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* 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.shim', ['kendo.popup'], f);
}(function () {
var __meta__ = {
id: 'mobile.shim',
name: 'Shim',
category: 'mobile',
description: 'Mobile Shim',
depends: ['popup'],
hidden: true
};
(function ($, undefined) {
var kendo = window.kendo, ui = kendo.mobile.ui, Popup = kendo.ui.Popup, SHIM = '<div class="km-shim"/>', HIDE = 'hide', Widget = ui.Widget;
var Shim = Widget.extend({
init: function (element, options) {
var that = this, app = kendo.mobile.application, os = kendo.support.mobileOS, osname = app ? app.os.name : os ? os.name : 'ios', ioswp = osname === 'ios' || osname === 'wp' || (app ? app.os.skin : false), bb = osname === 'blackberry', align = options.align || (ioswp ? 'bottom center' : bb ? 'center right' : 'center center'), position = options.position || (ioswp ? 'bottom center' : bb ? 'center right' : 'center center'), effect = options.effect || (ioswp ? 'slideIn:up' : bb ? 'slideIn:left' : 'fade:in'), shim = $(SHIM).handler(that).hide();
Widget.fn.init.call(that, element, options);
that.shim = shim;
element = that.element;
options = that.options;
if (options.className) {
that.shim.addClass(options.className);
}
if (!options.modal) {
that.shim.on('down', '_hide');
}
(app ? app.element : $(document.body)).append(shim);
that.popup = new Popup(that.element, {
anchor: shim,
modal: true,
appendTo: shim,
origin: align,
position: position,
animation: {
open: {
effects: effect,
duration: options.duration
},
close: { duration: options.duration }
},
close: function (e) {
var prevented = false;
if (!that._apiCall) {
prevented = that.trigger(HIDE);
}
if (prevented) {
e.preventDefault();
}
that._apiCall = false;
},
deactivate: function () {
shim.hide();
},
open: function () {
shim.show();
}
});
kendo.notify(that);
},
events: [HIDE],
options: {
name: 'Shim',
modal: false,
align: undefined,
position: undefined,
effect: undefined,
duration: 200
},
show: function () {
this.popup.open();
},
hide: function () {
this._apiCall = true;
this.popup.close();
},
destroy: function () {
Widget.fn.destroy.call(this);
this.shim.kendoDestroy();
this.popup.destroy();
this.shim.remove();
},
_hide: function (e) {
if (!e || !$.contains(this.shim.children().children('.k-popup')[0], e.target)) {
this.popup.close();
}
}
});
ui.plugin(Shim);
}(window.kendo.jQuery));
return window.kendo;
}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
(a3 || a2)();
}));