@finqu/cool 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/build/.eslintrc.json +10 -0
- package/build/banner.js +14 -0
- package/build/build-plugins.js +92 -0
- package/build/rollup.config.js +78 -0
- package/dist/css/cool-grid.css +3672 -0
- package/dist/css/cool-grid.css.map +30 -0
- package/dist/css/cool-grid.min.css +7 -0
- package/dist/css/cool-grid.min.css.map +1 -0
- package/dist/css/cool-reboot.css +281 -0
- package/dist/css/cool-reboot.css.map +58 -0
- package/dist/css/cool-reboot.min.css +7 -0
- package/dist/css/cool-reboot.min.css.map +1 -0
- package/dist/css/cool.css +14841 -0
- package/dist/css/cool.css.map +144 -0
- package/dist/css/cool.min.css +7 -0
- package/dist/css/cool.min.css.map +1 -0
- package/dist/js/cool.bundle.js +15304 -0
- package/dist/js/cool.bundle.js.map +1 -0
- package/dist/js/cool.bundle.min.js +45 -0
- package/dist/js/cool.bundle.min.js.map +1 -0
- package/dist/js/cool.esm.js +4766 -0
- package/dist/js/cool.esm.js.map +1 -0
- package/dist/js/cool.esm.min.js +7 -0
- package/dist/js/cool.esm.min.js.map +1 -0
- package/dist/js/cool.js +4948 -0
- package/dist/js/cool.js.map +1 -0
- package/dist/js/cool.min.js +7 -0
- package/dist/js/cool.min.js.map +1 -0
- package/html/index.html +892 -0
- package/js/dist/collapse.js +321 -0
- package/js/dist/collapse.js.map +1 -0
- package/js/dist/common.js +1474 -0
- package/js/dist/common.js.map +1 -0
- package/js/dist/cooldropdown.js +467 -0
- package/js/dist/cooldropdown.js.map +1 -0
- package/js/dist/coolpopover.js +391 -0
- package/js/dist/coolpopover.js.map +1 -0
- package/js/dist/coolsectiontabs.js +256 -0
- package/js/dist/coolsectiontabs.js.map +1 -0
- package/js/dist/coolselect.js +796 -0
- package/js/dist/coolselect.js.map +1 -0
- package/js/dist/cooltooltip.js +360 -0
- package/js/dist/cooltooltip.js.map +1 -0
- package/js/dist/coolui.js +73 -0
- package/js/dist/coolui.js.map +1 -0
- package/js/dist/dropdown.js +1716 -0
- package/js/dist/dropdown.js.map +1 -0
- package/js/dist/popover.js +587 -0
- package/js/dist/popover.js.map +1 -0
- package/js/dist/sectiontabs.js +263 -0
- package/js/dist/sectiontabs.js.map +1 -0
- package/js/dist/select.js +2029 -0
- package/js/dist/select.js.map +1 -0
- package/js/dist/tooltip.js +555 -0
- package/js/dist/tooltip.js.map +1 -0
- package/js/index.esm.js +21 -0
- package/js/index.umd.js +21 -0
- package/js/src/abstract-ui-component.js +70 -0
- package/js/src/collapse.js +258 -0
- package/js/src/common.js +280 -0
- package/js/src/dialog.js +570 -0
- package/js/src/dropdown.js +443 -0
- package/js/src/popover.js +615 -0
- package/js/src/section-tabs.js +204 -0
- package/js/src/select.js +832 -0
- package/js/src/toast.js +581 -0
- package/js/src/tooltip.js +575 -0
- package/js/src/util/animate-css.js +22 -0
- package/js/src/util/index.js +112 -0
- package/js/src/util/perfect-scrollbar.js +1316 -0
- package/less/alert.less +345 -0
- package/less/badge.less +38 -0
- package/less/bootstrap-noconflict.less +23 -0
- package/less/bootstrap.less +23 -0
- package/less/button-group.less +153 -0
- package/less/buttons.less +287 -0
- package/less/dialog-noconflict.less +174 -0
- package/less/dialog.less +203 -0
- package/less/dropdown.less +209 -0
- package/less/forms.less +770 -0
- package/less/images.less +242 -0
- package/less/input-group.less +163 -0
- package/less/list-group.less +73 -0
- package/less/mixins/aspect-ratio.less +23 -0
- package/less/mixins/border-radius.less +24 -0
- package/less/mixins/box-shadow.less +4 -0
- package/less/mixins/buttons.less +17 -0
- package/less/mixins/caret.less +51 -0
- package/less/mixins/clearfix.less +10 -0
- package/less/mixins/gradients.less +34 -0
- package/less/mixins/nav-divider.less +7 -0
- package/less/mixins/object-fit.less +13 -0
- package/less/mixins/reset-text.less +16 -0
- package/less/mixins.less +11 -0
- package/less/package.json +11 -0
- package/less/pagination.less +69 -0
- package/less/popover.less +143 -0
- package/less/project.sublime-workspace +774 -0
- package/less/reboot.less +235 -0
- package/less/section.less +793 -0
- package/less/select.less +150 -0
- package/less/tables.less +737 -0
- package/less/tabs.less +162 -0
- package/less/tooltip.less +87 -0
- package/less/type.less +71 -0
- package/less/utilities/align.less +27 -0
- package/less/utilities/animate.less +3512 -0
- package/less/utilities/background.less +70 -0
- package/less/utilities/borders.less +16 -0
- package/less/utilities/color.less +70 -0
- package/less/utilities/cursor.less +8 -0
- package/less/utilities/display.less +38 -0
- package/less/utilities/embed.less +61 -0
- package/less/utilities/flex.less +76 -0
- package/less/utilities/jquery-ui.less +116 -0
- package/less/utilities/lazyload.less +29 -0
- package/less/utilities/overflow.less +11 -0
- package/less/utilities/pace.less +25 -0
- package/less/utilities/placeholder.less +60 -0
- package/less/utilities/position.less +42 -0
- package/less/utilities/scrollbar.less +152 -0
- package/less/utilities/spacing.less +197 -0
- package/less/utilities/text.less +68 -0
- package/less/utilities/transform.less +7 -0
- package/less/utilities.less +21 -0
- package/less/variables.less +343 -0
- package/package.json +71 -0
- package/scss/LISENCE +15 -0
- package/scss/_alert.scss +125 -0
- package/scss/_badge.scss +58 -0
- package/scss/_button-group.scss +124 -0
- package/scss/_buttons.scss +206 -0
- package/scss/_custom-forms.scss +423 -0
- package/scss/_dialog.scss +149 -0
- package/scss/_dropdown.scss +234 -0
- package/scss/_forms.scss +257 -0
- package/scss/_frame.scss +523 -0
- package/scss/_functions.scss +114 -0
- package/scss/_grid.scss +35 -0
- package/scss/_images.scss +312 -0
- package/scss/_input-group.scss +245 -0
- package/scss/_list-group.scss +82 -0
- package/scss/_mixins.scss +32 -0
- package/scss/_navbar.scss +214 -0
- package/scss/_pagination.scss +79 -0
- package/scss/_popover.scss +165 -0
- package/scss/_reboot.scss +279 -0
- package/scss/_root.scss +15 -0
- package/scss/_section.scss +851 -0
- package/scss/_select.scss +166 -0
- package/scss/_tables.scss +707 -0
- package/scss/_tabs.scss +175 -0
- package/scss/_toast.scss +182 -0
- package/scss/_tooltip.scss +101 -0
- package/scss/_type.scss +90 -0
- package/scss/_utilities.scss +21 -0
- package/scss/_variables.scss +697 -0
- package/scss/cool-grid.scss +29 -0
- package/scss/cool-reboot.scss +11 -0
- package/scss/cool.scss +36 -0
- package/scss/mixins/_alert-variant.scss +40 -0
- package/scss/mixins/_aspect-ratio.scss +29 -0
- package/scss/mixins/_background-variant.scss +25 -0
- package/scss/mixins/_badge-variant.scss +13 -0
- package/scss/mixins/_breakpoints.scss +102 -0
- package/scss/mixins/_buttons.scss +104 -0
- package/scss/mixins/_caret.scss +80 -0
- package/scss/mixins/_clearfix.scss +10 -0
- package/scss/mixins/_float.scss +14 -0
- package/scss/mixins/_forms.scss +51 -0
- package/scss/mixins/_gradients.scss +40 -0
- package/scss/mixins/_grid-framework.scss +72 -0
- package/scss/mixins/_grid.scss +60 -0
- package/scss/mixins/_nav-divider.scss +9 -0
- package/scss/mixins/_object-fit.scss +16 -0
- package/scss/mixins/_reset-text.scss +19 -0
- package/scss/mixins/_text-emphasis.scss +21 -0
- package/scss/mixins/_text-hide.scss +10 -0
- package/scss/mixins/_text-truncate.scss +8 -0
- package/scss/project.sublime-workspace +491 -0
- package/scss/utilities/_align.scss +41 -0
- package/scss/utilities/_animate.scss +3512 -0
- package/scss/utilities/_background.scss +14 -0
- package/scss/utilities/_borders.scss +146 -0
- package/scss/utilities/_clearfix.scss +6 -0
- package/scss/utilities/_collapse.scss +33 -0
- package/scss/utilities/_cursor.scss +10 -0
- package/scss/utilities/_display.scss +16 -0
- package/scss/utilities/_embed.scss +78 -0
- package/scss/utilities/_flex.scss +50 -0
- package/scss/utilities/_lazyload.scss +31 -0
- package/scss/utilities/_overflow.scss +6 -0
- package/scss/utilities/_perfect-scrollbar.scss +154 -0
- package/scss/utilities/_placeholder.scss +76 -0
- package/scss/utilities/_position.scss +30 -0
- package/scss/utilities/_sizing.scss +32 -0
- package/scss/utilities/_spacing.scss +92 -0
- package/scss/utilities/_text.scss +97 -0
|
@@ -0,0 +1,1716 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Cool UI dropdown.js v1.0.0 (https://finqu.fi)
|
|
3
|
+
* Copyright 2011-2019 Finqu Oy
|
|
4
|
+
* Licensed under the ISC license - (http://opensource.org/licenses/ISC)
|
|
5
|
+
*/
|
|
6
|
+
(function (global, factory) {
|
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
|
|
8
|
+
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
|
|
9
|
+
(global = global || self, global.Dropdown = factory());
|
|
10
|
+
}(this, function () { 'use strict';
|
|
11
|
+
|
|
12
|
+
/*!
|
|
13
|
+
* perfect-scrollbar v1.4.0
|
|
14
|
+
* (c) 2018 Hyunje Jun
|
|
15
|
+
* @license MIT
|
|
16
|
+
*/
|
|
17
|
+
function get(element) {
|
|
18
|
+
return getComputedStyle(element);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function set(element, obj) {
|
|
22
|
+
for (var key in obj) {
|
|
23
|
+
var val = obj[key];
|
|
24
|
+
|
|
25
|
+
if (typeof val === 'number') {
|
|
26
|
+
val = val + "px";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
element.style[key] = val;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return element;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function div(className) {
|
|
36
|
+
var div = document.createElement('div');
|
|
37
|
+
div.className = className;
|
|
38
|
+
return div;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var elMatches = typeof Element !== 'undefined' && (Element.prototype.matches || Element.prototype.webkitMatchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector);
|
|
42
|
+
|
|
43
|
+
function matches(element, query) {
|
|
44
|
+
if (!elMatches) {
|
|
45
|
+
throw new Error('No element matching method supported');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return elMatches.call(element, query);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function remove(element) {
|
|
52
|
+
if (element.remove) {
|
|
53
|
+
element.remove();
|
|
54
|
+
} else {
|
|
55
|
+
if (element.parentNode) {
|
|
56
|
+
element.parentNode.removeChild(element);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function queryChildren(element, selector) {
|
|
62
|
+
return Array.prototype.filter.call(element.children, function (child) {
|
|
63
|
+
return matches(child, selector);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var cls = {
|
|
68
|
+
main: 'ps',
|
|
69
|
+
element: {
|
|
70
|
+
thumb: function (x) {
|
|
71
|
+
return "ps__thumb-" + x;
|
|
72
|
+
},
|
|
73
|
+
rail: function (x) {
|
|
74
|
+
return "ps__rail-" + x;
|
|
75
|
+
},
|
|
76
|
+
consuming: 'ps__child--consume'
|
|
77
|
+
},
|
|
78
|
+
state: {
|
|
79
|
+
focus: 'ps--focus',
|
|
80
|
+
clicking: 'ps--clicking',
|
|
81
|
+
active: function (x) {
|
|
82
|
+
return "ps--active-" + x;
|
|
83
|
+
},
|
|
84
|
+
scrolling: function (x) {
|
|
85
|
+
return "ps--scrolling-" + x;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/*
|
|
90
|
+
* Helper methods
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
var scrollingClassTimeout = {
|
|
94
|
+
x: null,
|
|
95
|
+
y: null
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
function addScrollingClass(i, x) {
|
|
99
|
+
var classList = i.element.classList;
|
|
100
|
+
var className = cls.state.scrolling(x);
|
|
101
|
+
|
|
102
|
+
if (classList.contains(className)) {
|
|
103
|
+
clearTimeout(scrollingClassTimeout[x]);
|
|
104
|
+
} else {
|
|
105
|
+
classList.add(className);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function removeScrollingClass(i, x) {
|
|
110
|
+
scrollingClassTimeout[x] = setTimeout(function () {
|
|
111
|
+
return i.isAlive && i.element.classList.remove(cls.state.scrolling(x));
|
|
112
|
+
}, i.settings.scrollingThreshold);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function setScrollingClassInstantly(i, x) {
|
|
116
|
+
addScrollingClass(i, x);
|
|
117
|
+
removeScrollingClass(i, x);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var EventElement = function EventElement(element) {
|
|
121
|
+
this.element = element;
|
|
122
|
+
this.handlers = {};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var prototypeAccessors = {
|
|
126
|
+
isEmpty: {
|
|
127
|
+
configurable: true
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
EventElement.prototype.bind = function bind(eventName, handler) {
|
|
132
|
+
if (typeof this.handlers[eventName] === 'undefined') {
|
|
133
|
+
this.handlers[eventName] = [];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.handlers[eventName].push(handler);
|
|
137
|
+
this.element.addEventListener(eventName, handler, false);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
EventElement.prototype.unbind = function unbind(eventName, target) {
|
|
141
|
+
var this$1 = this;
|
|
142
|
+
this.handlers[eventName] = this.handlers[eventName].filter(function (handler) {
|
|
143
|
+
if (target && handler !== target) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this$1.element.removeEventListener(eventName, handler, false);
|
|
148
|
+
return false;
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
EventElement.prototype.unbindAll = function unbindAll() {
|
|
153
|
+
var this$1 = this;
|
|
154
|
+
|
|
155
|
+
for (var name in this$1.handlers) {
|
|
156
|
+
this$1.unbind(name);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
prototypeAccessors.isEmpty.get = function () {
|
|
161
|
+
var this$1 = this;
|
|
162
|
+
return Object.keys(this.handlers).every(function (key) {
|
|
163
|
+
return this$1.handlers[key].length === 0;
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
Object.defineProperties(EventElement.prototype, prototypeAccessors);
|
|
168
|
+
|
|
169
|
+
var EventManager = function EventManager() {
|
|
170
|
+
this.eventElements = [];
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
EventManager.prototype.eventElement = function eventElement(element) {
|
|
174
|
+
var ee = this.eventElements.filter(function (ee) {
|
|
175
|
+
return ee.element === element;
|
|
176
|
+
})[0];
|
|
177
|
+
|
|
178
|
+
if (!ee) {
|
|
179
|
+
ee = new EventElement(element);
|
|
180
|
+
this.eventElements.push(ee);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return ee;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
EventManager.prototype.bind = function bind(element, eventName, handler) {
|
|
187
|
+
this.eventElement(element).bind(eventName, handler);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
EventManager.prototype.unbind = function unbind(element, eventName, handler) {
|
|
191
|
+
var ee = this.eventElement(element);
|
|
192
|
+
ee.unbind(eventName, handler);
|
|
193
|
+
|
|
194
|
+
if (ee.isEmpty) {
|
|
195
|
+
// remove
|
|
196
|
+
this.eventElements.splice(this.eventElements.indexOf(ee), 1);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
EventManager.prototype.unbindAll = function unbindAll() {
|
|
201
|
+
this.eventElements.forEach(function (e) {
|
|
202
|
+
return e.unbindAll();
|
|
203
|
+
});
|
|
204
|
+
this.eventElements = [];
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
EventManager.prototype.once = function once(element, eventName, handler) {
|
|
208
|
+
var ee = this.eventElement(element);
|
|
209
|
+
|
|
210
|
+
var onceHandler = function (evt) {
|
|
211
|
+
ee.unbind(eventName, onceHandler);
|
|
212
|
+
handler(evt);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
ee.bind(eventName, onceHandler);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
function createEvent(name) {
|
|
219
|
+
if (typeof window.CustomEvent === 'function') {
|
|
220
|
+
return new CustomEvent(name);
|
|
221
|
+
} else {
|
|
222
|
+
var evt = document.createEvent('CustomEvent');
|
|
223
|
+
evt.initCustomEvent(name, false, false, undefined);
|
|
224
|
+
return evt;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var processScrollDiff = function (i, axis, diff, useScrollingClass, forceFireReachEvent) {
|
|
229
|
+
if (useScrollingClass === void 0) useScrollingClass = true;
|
|
230
|
+
if (forceFireReachEvent === void 0) forceFireReachEvent = false;
|
|
231
|
+
var fields;
|
|
232
|
+
|
|
233
|
+
if (axis === 'top') {
|
|
234
|
+
fields = ['contentHeight', 'containerHeight', 'scrollTop', 'y', 'up', 'down'];
|
|
235
|
+
} else if (axis === 'left') {
|
|
236
|
+
fields = ['contentWidth', 'containerWidth', 'scrollLeft', 'x', 'left', 'right'];
|
|
237
|
+
} else {
|
|
238
|
+
throw new Error('A proper axis should be provided');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
processScrollDiff$1(i, diff, fields, useScrollingClass, forceFireReachEvent);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
function processScrollDiff$1(i, diff, ref, useScrollingClass, forceFireReachEvent) {
|
|
245
|
+
var contentHeight = ref[0];
|
|
246
|
+
var containerHeight = ref[1];
|
|
247
|
+
var scrollTop = ref[2];
|
|
248
|
+
var y = ref[3];
|
|
249
|
+
var up = ref[4];
|
|
250
|
+
var down = ref[5];
|
|
251
|
+
if (useScrollingClass === void 0) useScrollingClass = true;
|
|
252
|
+
if (forceFireReachEvent === void 0) forceFireReachEvent = false;
|
|
253
|
+
var element = i.element; // reset reach
|
|
254
|
+
|
|
255
|
+
i.reach[y] = null; // 1 for subpixel rounding
|
|
256
|
+
|
|
257
|
+
if (element[scrollTop] < 1) {
|
|
258
|
+
i.reach[y] = 'start';
|
|
259
|
+
} // 1 for subpixel rounding
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
if (element[scrollTop] > i[contentHeight] - i[containerHeight] - 1) {
|
|
263
|
+
i.reach[y] = 'end';
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (diff) {
|
|
267
|
+
element.dispatchEvent(createEvent("ps-scroll-" + y));
|
|
268
|
+
|
|
269
|
+
if (diff < 0) {
|
|
270
|
+
element.dispatchEvent(createEvent("ps-scroll-" + up));
|
|
271
|
+
} else if (diff > 0) {
|
|
272
|
+
element.dispatchEvent(createEvent("ps-scroll-" + down));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (useScrollingClass) {
|
|
276
|
+
setScrollingClassInstantly(i, y);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (i.reach[y] && (diff || forceFireReachEvent)) {
|
|
281
|
+
element.dispatchEvent(createEvent("ps-" + y + "-reach-" + i.reach[y]));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function toInt(x) {
|
|
286
|
+
return parseInt(x, 10) || 0;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function isEditable(el) {
|
|
290
|
+
return matches(el, 'input,[contenteditable]') || matches(el, 'select,[contenteditable]') || matches(el, 'textarea,[contenteditable]') || matches(el, 'button,[contenteditable]');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function outerWidth(element) {
|
|
294
|
+
var styles = get(element);
|
|
295
|
+
return toInt(styles.width) + toInt(styles.paddingLeft) + toInt(styles.paddingRight) + toInt(styles.borderLeftWidth) + toInt(styles.borderRightWidth);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
var env = {
|
|
299
|
+
isWebKit: typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style,
|
|
300
|
+
supportsTouch: typeof window !== 'undefined' && ('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
|
|
301
|
+
supportsIePointer: typeof navigator !== 'undefined' && navigator.msMaxTouchPoints,
|
|
302
|
+
isChrome: typeof navigator !== 'undefined' && /Chrome/i.test(navigator && navigator.userAgent)
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
var updateGeometry = function (i) {
|
|
306
|
+
var element = i.element;
|
|
307
|
+
var roundedScrollTop = Math.floor(element.scrollTop);
|
|
308
|
+
i.containerWidth = element.clientWidth;
|
|
309
|
+
i.containerHeight = element.clientHeight;
|
|
310
|
+
i.contentWidth = element.scrollWidth;
|
|
311
|
+
i.contentHeight = element.scrollHeight;
|
|
312
|
+
|
|
313
|
+
if (!element.contains(i.scrollbarXRail)) {
|
|
314
|
+
// clean up and append
|
|
315
|
+
queryChildren(element, cls.element.rail('x')).forEach(function (el) {
|
|
316
|
+
return remove(el);
|
|
317
|
+
});
|
|
318
|
+
element.appendChild(i.scrollbarXRail);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (!element.contains(i.scrollbarYRail)) {
|
|
322
|
+
// clean up and append
|
|
323
|
+
queryChildren(element, cls.element.rail('y')).forEach(function (el) {
|
|
324
|
+
return remove(el);
|
|
325
|
+
});
|
|
326
|
+
element.appendChild(i.scrollbarYRail);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) {
|
|
330
|
+
i.scrollbarXActive = true;
|
|
331
|
+
i.railXWidth = i.containerWidth - i.railXMarginWidth;
|
|
332
|
+
i.railXRatio = i.containerWidth / i.railXWidth;
|
|
333
|
+
i.scrollbarXWidth = getThumbSize(i, toInt(i.railXWidth * i.containerWidth / i.contentWidth));
|
|
334
|
+
i.scrollbarXLeft = toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth));
|
|
335
|
+
} else {
|
|
336
|
+
i.scrollbarXActive = false;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (!i.settings.suppressScrollY && i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight) {
|
|
340
|
+
i.scrollbarYActive = true;
|
|
341
|
+
i.railYHeight = i.containerHeight - i.railYMarginHeight;
|
|
342
|
+
i.railYRatio = i.containerHeight / i.railYHeight;
|
|
343
|
+
i.scrollbarYHeight = getThumbSize(i, toInt(i.railYHeight * i.containerHeight / i.contentHeight));
|
|
344
|
+
i.scrollbarYTop = toInt(roundedScrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight));
|
|
345
|
+
} else {
|
|
346
|
+
i.scrollbarYActive = false;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) {
|
|
350
|
+
i.scrollbarXLeft = i.railXWidth - i.scrollbarXWidth;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (i.scrollbarYTop >= i.railYHeight - i.scrollbarYHeight) {
|
|
354
|
+
i.scrollbarYTop = i.railYHeight - i.scrollbarYHeight;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
updateCss(element, i);
|
|
358
|
+
|
|
359
|
+
if (i.scrollbarXActive) {
|
|
360
|
+
element.classList.add(cls.state.active('x'));
|
|
361
|
+
} else {
|
|
362
|
+
element.classList.remove(cls.state.active('x'));
|
|
363
|
+
i.scrollbarXWidth = 0;
|
|
364
|
+
i.scrollbarXLeft = 0;
|
|
365
|
+
element.scrollLeft = 0;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (i.scrollbarYActive) {
|
|
369
|
+
element.classList.add(cls.state.active('y'));
|
|
370
|
+
} else {
|
|
371
|
+
element.classList.remove(cls.state.active('y'));
|
|
372
|
+
i.scrollbarYHeight = 0;
|
|
373
|
+
i.scrollbarYTop = 0;
|
|
374
|
+
element.scrollTop = 0;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
function getThumbSize(i, thumbSize) {
|
|
379
|
+
if (i.settings.minScrollbarLength) {
|
|
380
|
+
thumbSize = Math.max(thumbSize, i.settings.minScrollbarLength);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (i.settings.maxScrollbarLength) {
|
|
384
|
+
thumbSize = Math.min(thumbSize, i.settings.maxScrollbarLength);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return thumbSize;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function updateCss(element, i) {
|
|
391
|
+
var xRailOffset = {
|
|
392
|
+
width: i.railXWidth
|
|
393
|
+
};
|
|
394
|
+
var roundedScrollTop = Math.floor(element.scrollTop);
|
|
395
|
+
|
|
396
|
+
if (i.isRtl) {
|
|
397
|
+
xRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth - i.contentWidth;
|
|
398
|
+
} else {
|
|
399
|
+
xRailOffset.left = element.scrollLeft;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (i.isScrollbarXUsingBottom) {
|
|
403
|
+
xRailOffset.bottom = i.scrollbarXBottom - roundedScrollTop;
|
|
404
|
+
} else {
|
|
405
|
+
xRailOffset.top = i.scrollbarXTop + roundedScrollTop;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
set(i.scrollbarXRail, xRailOffset);
|
|
409
|
+
var yRailOffset = {
|
|
410
|
+
top: roundedScrollTop,
|
|
411
|
+
height: i.railYHeight
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
if (i.isScrollbarYUsingRight) {
|
|
415
|
+
if (i.isRtl) {
|
|
416
|
+
yRailOffset.right = i.contentWidth - (i.negativeScrollAdjustment + element.scrollLeft) - i.scrollbarYRight - i.scrollbarYOuterWidth;
|
|
417
|
+
} else {
|
|
418
|
+
yRailOffset.right = i.scrollbarYRight - element.scrollLeft;
|
|
419
|
+
}
|
|
420
|
+
} else {
|
|
421
|
+
if (i.isRtl) {
|
|
422
|
+
yRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth * 2 - i.contentWidth - i.scrollbarYLeft - i.scrollbarYOuterWidth;
|
|
423
|
+
} else {
|
|
424
|
+
yRailOffset.left = i.scrollbarYLeft + element.scrollLeft;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
set(i.scrollbarYRail, yRailOffset);
|
|
429
|
+
set(i.scrollbarX, {
|
|
430
|
+
left: i.scrollbarXLeft,
|
|
431
|
+
width: i.scrollbarXWidth - i.railBorderXWidth
|
|
432
|
+
});
|
|
433
|
+
set(i.scrollbarY, {
|
|
434
|
+
top: i.scrollbarYTop,
|
|
435
|
+
height: i.scrollbarYHeight - i.railBorderYWidth
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
var clickRail = function (i) {
|
|
440
|
+
i.event.bind(i.scrollbarY, 'mousedown', function (e) {
|
|
441
|
+
return e.stopPropagation();
|
|
442
|
+
});
|
|
443
|
+
i.event.bind(i.scrollbarYRail, 'mousedown', function (e) {
|
|
444
|
+
var positionTop = e.pageY - window.pageYOffset - i.scrollbarYRail.getBoundingClientRect().top;
|
|
445
|
+
var direction = positionTop > i.scrollbarYTop ? 1 : -1;
|
|
446
|
+
i.element.scrollTop += direction * i.containerHeight;
|
|
447
|
+
updateGeometry(i);
|
|
448
|
+
e.stopPropagation();
|
|
449
|
+
});
|
|
450
|
+
i.event.bind(i.scrollbarX, 'mousedown', function (e) {
|
|
451
|
+
return e.stopPropagation();
|
|
452
|
+
});
|
|
453
|
+
i.event.bind(i.scrollbarXRail, 'mousedown', function (e) {
|
|
454
|
+
var positionLeft = e.pageX - window.pageXOffset - i.scrollbarXRail.getBoundingClientRect().left;
|
|
455
|
+
var direction = positionLeft > i.scrollbarXLeft ? 1 : -1;
|
|
456
|
+
i.element.scrollLeft += direction * i.containerWidth;
|
|
457
|
+
updateGeometry(i);
|
|
458
|
+
e.stopPropagation();
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
var dragThumb = function (i) {
|
|
463
|
+
bindMouseScrollHandler(i, ['containerWidth', 'contentWidth', 'pageX', 'railXWidth', 'scrollbarX', 'scrollbarXWidth', 'scrollLeft', 'x', 'scrollbarXRail']);
|
|
464
|
+
bindMouseScrollHandler(i, ['containerHeight', 'contentHeight', 'pageY', 'railYHeight', 'scrollbarY', 'scrollbarYHeight', 'scrollTop', 'y', 'scrollbarYRail']);
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
function bindMouseScrollHandler(i, ref) {
|
|
468
|
+
var containerHeight = ref[0];
|
|
469
|
+
var contentHeight = ref[1];
|
|
470
|
+
var pageY = ref[2];
|
|
471
|
+
var railYHeight = ref[3];
|
|
472
|
+
var scrollbarY = ref[4];
|
|
473
|
+
var scrollbarYHeight = ref[5];
|
|
474
|
+
var scrollTop = ref[6];
|
|
475
|
+
var y = ref[7];
|
|
476
|
+
var scrollbarYRail = ref[8];
|
|
477
|
+
var element = i.element;
|
|
478
|
+
var startingScrollTop = null;
|
|
479
|
+
var startingMousePageY = null;
|
|
480
|
+
var scrollBy = null;
|
|
481
|
+
|
|
482
|
+
function mouseMoveHandler(e) {
|
|
483
|
+
element[scrollTop] = startingScrollTop + scrollBy * (e[pageY] - startingMousePageY);
|
|
484
|
+
addScrollingClass(i, y);
|
|
485
|
+
updateGeometry(i);
|
|
486
|
+
e.stopPropagation();
|
|
487
|
+
e.preventDefault();
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function mouseUpHandler() {
|
|
491
|
+
removeScrollingClass(i, y);
|
|
492
|
+
i[scrollbarYRail].classList.remove(cls.state.clicking);
|
|
493
|
+
i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
i.event.bind(i[scrollbarY], 'mousedown', function (e) {
|
|
497
|
+
startingScrollTop = element[scrollTop];
|
|
498
|
+
startingMousePageY = e[pageY];
|
|
499
|
+
scrollBy = (i[contentHeight] - i[containerHeight]) / (i[railYHeight] - i[scrollbarYHeight]);
|
|
500
|
+
i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
|
|
501
|
+
i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
|
|
502
|
+
i[scrollbarYRail].classList.add(cls.state.clicking);
|
|
503
|
+
e.stopPropagation();
|
|
504
|
+
e.preventDefault();
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
var keyboard = function (i) {
|
|
509
|
+
var element = i.element;
|
|
510
|
+
|
|
511
|
+
var elementHovered = function () {
|
|
512
|
+
return matches(element, ':hover');
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
var scrollbarFocused = function () {
|
|
516
|
+
return matches(i.scrollbarX, ':focus') || matches(i.scrollbarY, ':focus');
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
function shouldPreventDefault(deltaX, deltaY) {
|
|
520
|
+
var scrollTop = Math.floor(element.scrollTop);
|
|
521
|
+
|
|
522
|
+
if (deltaX === 0) {
|
|
523
|
+
if (!i.scrollbarYActive) {
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (scrollTop === 0 && deltaY > 0 || scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0) {
|
|
528
|
+
return !i.settings.wheelPropagation;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
var scrollLeft = element.scrollLeft;
|
|
533
|
+
|
|
534
|
+
if (deltaY === 0) {
|
|
535
|
+
if (!i.scrollbarXActive) {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
if (scrollLeft === 0 && deltaX < 0 || scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0) {
|
|
540
|
+
return !i.settings.wheelPropagation;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
i.event.bind(i.ownerDocument, 'keydown', function (e) {
|
|
548
|
+
if (e.isDefaultPrevented && e.isDefaultPrevented() || e.defaultPrevented) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if (!elementHovered() && !scrollbarFocused()) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement;
|
|
557
|
+
|
|
558
|
+
if (activeElement) {
|
|
559
|
+
if (activeElement.tagName === 'IFRAME') {
|
|
560
|
+
activeElement = activeElement.contentDocument.activeElement;
|
|
561
|
+
} else {
|
|
562
|
+
// go deeper if element is a webcomponent
|
|
563
|
+
while (activeElement.shadowRoot) {
|
|
564
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (isEditable(activeElement)) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
var deltaX = 0;
|
|
574
|
+
var deltaY = 0;
|
|
575
|
+
|
|
576
|
+
switch (e.which) {
|
|
577
|
+
case 37:
|
|
578
|
+
// left
|
|
579
|
+
if (e.metaKey) {
|
|
580
|
+
deltaX = -i.contentWidth;
|
|
581
|
+
} else if (e.altKey) {
|
|
582
|
+
deltaX = -i.containerWidth;
|
|
583
|
+
} else {
|
|
584
|
+
deltaX = -30;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
break;
|
|
588
|
+
|
|
589
|
+
case 38:
|
|
590
|
+
// up
|
|
591
|
+
if (e.metaKey) {
|
|
592
|
+
deltaY = i.contentHeight;
|
|
593
|
+
} else if (e.altKey) {
|
|
594
|
+
deltaY = i.containerHeight;
|
|
595
|
+
} else {
|
|
596
|
+
deltaY = 30;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
break;
|
|
600
|
+
|
|
601
|
+
case 39:
|
|
602
|
+
// right
|
|
603
|
+
if (e.metaKey) {
|
|
604
|
+
deltaX = i.contentWidth;
|
|
605
|
+
} else if (e.altKey) {
|
|
606
|
+
deltaX = i.containerWidth;
|
|
607
|
+
} else {
|
|
608
|
+
deltaX = 30;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
break;
|
|
612
|
+
|
|
613
|
+
case 40:
|
|
614
|
+
// down
|
|
615
|
+
if (e.metaKey) {
|
|
616
|
+
deltaY = -i.contentHeight;
|
|
617
|
+
} else if (e.altKey) {
|
|
618
|
+
deltaY = -i.containerHeight;
|
|
619
|
+
} else {
|
|
620
|
+
deltaY = -30;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
break;
|
|
624
|
+
|
|
625
|
+
case 32:
|
|
626
|
+
// space bar
|
|
627
|
+
if (e.shiftKey) {
|
|
628
|
+
deltaY = i.containerHeight;
|
|
629
|
+
} else {
|
|
630
|
+
deltaY = -i.containerHeight;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
break;
|
|
634
|
+
|
|
635
|
+
case 33:
|
|
636
|
+
// page up
|
|
637
|
+
deltaY = i.containerHeight;
|
|
638
|
+
break;
|
|
639
|
+
|
|
640
|
+
case 34:
|
|
641
|
+
// page down
|
|
642
|
+
deltaY = -i.containerHeight;
|
|
643
|
+
break;
|
|
644
|
+
|
|
645
|
+
case 36:
|
|
646
|
+
// home
|
|
647
|
+
deltaY = i.contentHeight;
|
|
648
|
+
break;
|
|
649
|
+
|
|
650
|
+
case 35:
|
|
651
|
+
// end
|
|
652
|
+
deltaY = -i.contentHeight;
|
|
653
|
+
break;
|
|
654
|
+
|
|
655
|
+
default:
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (i.settings.suppressScrollX && deltaX !== 0) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (i.settings.suppressScrollY && deltaY !== 0) {
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
element.scrollTop -= deltaY;
|
|
668
|
+
element.scrollLeft += deltaX;
|
|
669
|
+
updateGeometry(i);
|
|
670
|
+
|
|
671
|
+
if (shouldPreventDefault(deltaX, deltaY)) {
|
|
672
|
+
e.preventDefault();
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
var wheel = function (i) {
|
|
678
|
+
var element = i.element;
|
|
679
|
+
|
|
680
|
+
function shouldPreventDefault(deltaX, deltaY) {
|
|
681
|
+
var roundedScrollTop = Math.floor(element.scrollTop);
|
|
682
|
+
var isTop = element.scrollTop === 0;
|
|
683
|
+
var isBottom = roundedScrollTop + element.offsetHeight === element.scrollHeight;
|
|
684
|
+
var isLeft = element.scrollLeft === 0;
|
|
685
|
+
var isRight = element.scrollLeft + element.offsetWidth === element.scrollWidth;
|
|
686
|
+
var hitsBound; // pick axis with primary direction
|
|
687
|
+
|
|
688
|
+
if (Math.abs(deltaY) > Math.abs(deltaX)) {
|
|
689
|
+
hitsBound = isTop || isBottom;
|
|
690
|
+
} else {
|
|
691
|
+
hitsBound = isLeft || isRight;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
return hitsBound ? !i.settings.wheelPropagation : true;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
function getDeltaFromEvent(e) {
|
|
698
|
+
var deltaX = e.deltaX;
|
|
699
|
+
var deltaY = -1 * e.deltaY;
|
|
700
|
+
|
|
701
|
+
if (typeof deltaX === 'undefined' || typeof deltaY === 'undefined') {
|
|
702
|
+
// OS X Safari
|
|
703
|
+
deltaX = -1 * e.wheelDeltaX / 6;
|
|
704
|
+
deltaY = e.wheelDeltaY / 6;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (e.deltaMode && e.deltaMode === 1) {
|
|
708
|
+
// Firefox in deltaMode 1: Line scrolling
|
|
709
|
+
deltaX *= 10;
|
|
710
|
+
deltaY *= 10;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (deltaX !== deltaX && deltaY !== deltaY
|
|
714
|
+
/* NaN checks */
|
|
715
|
+
) {
|
|
716
|
+
// IE in some mouse drivers
|
|
717
|
+
deltaX = 0;
|
|
718
|
+
deltaY = e.wheelDelta;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
if (e.shiftKey) {
|
|
722
|
+
// reverse axis with shift key
|
|
723
|
+
return [-deltaY, -deltaX];
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
return [deltaX, deltaY];
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
function shouldBeConsumedByChild(target, deltaX, deltaY) {
|
|
730
|
+
// FIXME: this is a workaround for <select> issue in FF and IE #571
|
|
731
|
+
if (!env.isWebKit && element.querySelector('select:focus')) {
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (!element.contains(target)) {
|
|
736
|
+
return false;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
var cursor = target;
|
|
740
|
+
|
|
741
|
+
while (cursor && cursor !== element) {
|
|
742
|
+
if (cursor.classList.contains(cls.element.consuming)) {
|
|
743
|
+
return true;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
var style = get(cursor);
|
|
747
|
+
var overflow = [style.overflow, style.overflowX, style.overflowY].join(''); // if scrollable
|
|
748
|
+
|
|
749
|
+
if (overflow.match(/(scroll|auto)/)) {
|
|
750
|
+
var maxScrollTop = cursor.scrollHeight - cursor.clientHeight;
|
|
751
|
+
|
|
752
|
+
if (maxScrollTop > 0) {
|
|
753
|
+
if (!(cursor.scrollTop === 0 && deltaY > 0) && !(cursor.scrollTop === maxScrollTop && deltaY < 0)) {
|
|
754
|
+
return true;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
var maxScrollLeft = cursor.scrollWidth - cursor.clientWidth;
|
|
759
|
+
|
|
760
|
+
if (maxScrollLeft > 0) {
|
|
761
|
+
if (!(cursor.scrollLeft === 0 && deltaX < 0) && !(cursor.scrollLeft === maxScrollLeft && deltaX > 0)) {
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
cursor = cursor.parentNode;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function mousewheelHandler(e) {
|
|
774
|
+
var ref = getDeltaFromEvent(e);
|
|
775
|
+
var deltaX = ref[0];
|
|
776
|
+
var deltaY = ref[1];
|
|
777
|
+
|
|
778
|
+
if (shouldBeConsumedByChild(e.target, deltaX, deltaY)) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
var shouldPrevent = false;
|
|
783
|
+
|
|
784
|
+
if (!i.settings.useBothWheelAxes) {
|
|
785
|
+
// deltaX will only be used for horizontal scrolling and deltaY will
|
|
786
|
+
// only be used for vertical scrolling - this is the default
|
|
787
|
+
element.scrollTop -= deltaY * i.settings.wheelSpeed;
|
|
788
|
+
element.scrollLeft += deltaX * i.settings.wheelSpeed;
|
|
789
|
+
} else if (i.scrollbarYActive && !i.scrollbarXActive) {
|
|
790
|
+
// only vertical scrollbar is active and useBothWheelAxes option is
|
|
791
|
+
// active, so let's scroll vertical bar using both mouse wheel axes
|
|
792
|
+
if (deltaY) {
|
|
793
|
+
element.scrollTop -= deltaY * i.settings.wheelSpeed;
|
|
794
|
+
} else {
|
|
795
|
+
element.scrollTop += deltaX * i.settings.wheelSpeed;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
shouldPrevent = true;
|
|
799
|
+
} else if (i.scrollbarXActive && !i.scrollbarYActive) {
|
|
800
|
+
// useBothWheelAxes and only horizontal bar is active, so use both
|
|
801
|
+
// wheel axes for horizontal bar
|
|
802
|
+
if (deltaX) {
|
|
803
|
+
element.scrollLeft += deltaX * i.settings.wheelSpeed;
|
|
804
|
+
} else {
|
|
805
|
+
element.scrollLeft -= deltaY * i.settings.wheelSpeed;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
shouldPrevent = true;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
updateGeometry(i);
|
|
812
|
+
shouldPrevent = shouldPrevent || shouldPreventDefault(deltaX, deltaY);
|
|
813
|
+
|
|
814
|
+
if (shouldPrevent && !e.ctrlKey) {
|
|
815
|
+
e.stopPropagation();
|
|
816
|
+
e.preventDefault();
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
if (typeof window.onwheel !== 'undefined') {
|
|
821
|
+
i.event.bind(element, 'wheel', mousewheelHandler);
|
|
822
|
+
} else if (typeof window.onmousewheel !== 'undefined') {
|
|
823
|
+
i.event.bind(element, 'mousewheel', mousewheelHandler);
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
var touch = function (i) {
|
|
828
|
+
if (!env.supportsTouch && !env.supportsIePointer) {
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
var element = i.element;
|
|
833
|
+
|
|
834
|
+
function shouldPrevent(deltaX, deltaY) {
|
|
835
|
+
var scrollTop = Math.floor(element.scrollTop);
|
|
836
|
+
var scrollLeft = element.scrollLeft;
|
|
837
|
+
var magnitudeX = Math.abs(deltaX);
|
|
838
|
+
var magnitudeY = Math.abs(deltaY);
|
|
839
|
+
|
|
840
|
+
if (magnitudeY > magnitudeX) {
|
|
841
|
+
// user is perhaps trying to swipe up/down the page
|
|
842
|
+
if (deltaY < 0 && scrollTop === i.contentHeight - i.containerHeight || deltaY > 0 && scrollTop === 0) {
|
|
843
|
+
// set prevent for mobile Chrome refresh
|
|
844
|
+
return window.scrollY === 0 && deltaY > 0 && env.isChrome;
|
|
845
|
+
}
|
|
846
|
+
} else if (magnitudeX > magnitudeY) {
|
|
847
|
+
// user is perhaps trying to swipe left/right across the page
|
|
848
|
+
if (deltaX < 0 && scrollLeft === i.contentWidth - i.containerWidth || deltaX > 0 && scrollLeft === 0) {
|
|
849
|
+
return true;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return true;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function applyTouchMove(differenceX, differenceY) {
|
|
857
|
+
element.scrollTop -= differenceY;
|
|
858
|
+
element.scrollLeft -= differenceX;
|
|
859
|
+
updateGeometry(i);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
var startOffset = {};
|
|
863
|
+
var startTime = 0;
|
|
864
|
+
var speed = {};
|
|
865
|
+
var easingLoop = null;
|
|
866
|
+
|
|
867
|
+
function getTouch(e) {
|
|
868
|
+
if (e.targetTouches) {
|
|
869
|
+
return e.targetTouches[0];
|
|
870
|
+
} else {
|
|
871
|
+
// Maybe IE pointer
|
|
872
|
+
return e;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
function shouldHandle(e) {
|
|
877
|
+
if (e.pointerType && e.pointerType === 'pen' && e.buttons === 0) {
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
if (e.targetTouches && e.targetTouches.length === 1) {
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
if (e.pointerType && e.pointerType !== 'mouse' && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) {
|
|
886
|
+
return true;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
return false;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
function touchStart(e) {
|
|
893
|
+
if (!shouldHandle(e)) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
var touch = getTouch(e);
|
|
898
|
+
startOffset.pageX = touch.pageX;
|
|
899
|
+
startOffset.pageY = touch.pageY;
|
|
900
|
+
startTime = new Date().getTime();
|
|
901
|
+
|
|
902
|
+
if (easingLoop !== null) {
|
|
903
|
+
clearInterval(easingLoop);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
function shouldBeConsumedByChild(target, deltaX, deltaY) {
|
|
908
|
+
if (!element.contains(target)) {
|
|
909
|
+
return false;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
var cursor = target;
|
|
913
|
+
|
|
914
|
+
while (cursor && cursor !== element) {
|
|
915
|
+
if (cursor.classList.contains(cls.element.consuming)) {
|
|
916
|
+
return true;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
var style = get(cursor);
|
|
920
|
+
var overflow = [style.overflow, style.overflowX, style.overflowY].join(''); // if scrollable
|
|
921
|
+
|
|
922
|
+
if (overflow.match(/(scroll|auto)/)) {
|
|
923
|
+
var maxScrollTop = cursor.scrollHeight - cursor.clientHeight;
|
|
924
|
+
|
|
925
|
+
if (maxScrollTop > 0) {
|
|
926
|
+
if (!(cursor.scrollTop === 0 && deltaY > 0) && !(cursor.scrollTop === maxScrollTop && deltaY < 0)) {
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
var maxScrollLeft = cursor.scrollLeft - cursor.clientWidth;
|
|
932
|
+
|
|
933
|
+
if (maxScrollLeft > 0) {
|
|
934
|
+
if (!(cursor.scrollLeft === 0 && deltaX < 0) && !(cursor.scrollLeft === maxScrollLeft && deltaX > 0)) {
|
|
935
|
+
return true;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
cursor = cursor.parentNode;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
return false;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
function touchMove(e) {
|
|
947
|
+
if (shouldHandle(e)) {
|
|
948
|
+
var touch = getTouch(e);
|
|
949
|
+
var currentOffset = {
|
|
950
|
+
pageX: touch.pageX,
|
|
951
|
+
pageY: touch.pageY
|
|
952
|
+
};
|
|
953
|
+
var differenceX = currentOffset.pageX - startOffset.pageX;
|
|
954
|
+
var differenceY = currentOffset.pageY - startOffset.pageY;
|
|
955
|
+
|
|
956
|
+
if (shouldBeConsumedByChild(e.target, differenceX, differenceY)) {
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
applyTouchMove(differenceX, differenceY);
|
|
961
|
+
startOffset = currentOffset;
|
|
962
|
+
var currentTime = new Date().getTime();
|
|
963
|
+
var timeGap = currentTime - startTime;
|
|
964
|
+
|
|
965
|
+
if (timeGap > 0) {
|
|
966
|
+
speed.x = differenceX / timeGap;
|
|
967
|
+
speed.y = differenceY / timeGap;
|
|
968
|
+
startTime = currentTime;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
if (shouldPrevent(differenceX, differenceY)) {
|
|
972
|
+
e.preventDefault();
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
function touchEnd() {
|
|
978
|
+
if (i.settings.swipeEasing) {
|
|
979
|
+
clearInterval(easingLoop);
|
|
980
|
+
easingLoop = setInterval(function () {
|
|
981
|
+
if (i.isInitialized) {
|
|
982
|
+
clearInterval(easingLoop);
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
if (!speed.x && !speed.y) {
|
|
987
|
+
clearInterval(easingLoop);
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
|
|
992
|
+
clearInterval(easingLoop);
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
applyTouchMove(speed.x * 30, speed.y * 30);
|
|
997
|
+
speed.x *= 0.8;
|
|
998
|
+
speed.y *= 0.8;
|
|
999
|
+
}, 10);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
if (env.supportsTouch) {
|
|
1004
|
+
i.event.bind(element, 'touchstart', touchStart);
|
|
1005
|
+
i.event.bind(element, 'touchmove', touchMove);
|
|
1006
|
+
i.event.bind(element, 'touchend', touchEnd);
|
|
1007
|
+
} else if (env.supportsIePointer) {
|
|
1008
|
+
if (window.PointerEvent) {
|
|
1009
|
+
i.event.bind(element, 'pointerdown', touchStart);
|
|
1010
|
+
i.event.bind(element, 'pointermove', touchMove);
|
|
1011
|
+
i.event.bind(element, 'pointerup', touchEnd);
|
|
1012
|
+
} else if (window.MSPointerEvent) {
|
|
1013
|
+
i.event.bind(element, 'MSPointerDown', touchStart);
|
|
1014
|
+
i.event.bind(element, 'MSPointerMove', touchMove);
|
|
1015
|
+
i.event.bind(element, 'MSPointerUp', touchEnd);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
var defaultSettings = function () {
|
|
1021
|
+
return {
|
|
1022
|
+
handlers: ['click-rail', 'drag-thumb', 'keyboard', 'wheel', 'touch'],
|
|
1023
|
+
maxScrollbarLength: null,
|
|
1024
|
+
minScrollbarLength: null,
|
|
1025
|
+
scrollingThreshold: 1000,
|
|
1026
|
+
scrollXMarginOffset: 0,
|
|
1027
|
+
scrollYMarginOffset: 0,
|
|
1028
|
+
suppressScrollX: false,
|
|
1029
|
+
suppressScrollY: false,
|
|
1030
|
+
swipeEasing: true,
|
|
1031
|
+
useBothWheelAxes: false,
|
|
1032
|
+
wheelPropagation: true,
|
|
1033
|
+
wheelSpeed: 1
|
|
1034
|
+
};
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
var handlers = {
|
|
1038
|
+
'click-rail': clickRail,
|
|
1039
|
+
'drag-thumb': dragThumb,
|
|
1040
|
+
keyboard: keyboard,
|
|
1041
|
+
wheel: wheel,
|
|
1042
|
+
touch: touch
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
var PerfectScrollbar = function PerfectScrollbar(element, userSettings) {
|
|
1046
|
+
var this$1 = this;
|
|
1047
|
+
if (userSettings === void 0) userSettings = {};
|
|
1048
|
+
|
|
1049
|
+
if (typeof element === 'string') {
|
|
1050
|
+
element = document.querySelector(element);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
if (!element || !element.nodeName) {
|
|
1054
|
+
throw new Error('no element is specified to initialize PerfectScrollbar');
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
this.element = element;
|
|
1058
|
+
element.classList.add(cls.main);
|
|
1059
|
+
this.settings = defaultSettings();
|
|
1060
|
+
|
|
1061
|
+
for (var key in userSettings) {
|
|
1062
|
+
this$1.settings[key] = userSettings[key];
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
this.containerWidth = null;
|
|
1066
|
+
this.containerHeight = null;
|
|
1067
|
+
this.contentWidth = null;
|
|
1068
|
+
this.contentHeight = null;
|
|
1069
|
+
|
|
1070
|
+
var focus = function () {
|
|
1071
|
+
return element.classList.add(cls.state.focus);
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
var blur = function () {
|
|
1075
|
+
return element.classList.remove(cls.state.focus);
|
|
1076
|
+
};
|
|
1077
|
+
|
|
1078
|
+
this.isRtl = get(element).direction === 'rtl';
|
|
1079
|
+
|
|
1080
|
+
this.isNegativeScroll = function () {
|
|
1081
|
+
var originalScrollLeft = element.scrollLeft;
|
|
1082
|
+
var result = null;
|
|
1083
|
+
element.scrollLeft = -1;
|
|
1084
|
+
result = element.scrollLeft < 0;
|
|
1085
|
+
element.scrollLeft = originalScrollLeft;
|
|
1086
|
+
return result;
|
|
1087
|
+
}();
|
|
1088
|
+
|
|
1089
|
+
this.negativeScrollAdjustment = this.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
|
|
1090
|
+
this.event = new EventManager();
|
|
1091
|
+
this.ownerDocument = element.ownerDocument || document;
|
|
1092
|
+
this.scrollbarXRail = div(cls.element.rail('x'));
|
|
1093
|
+
element.appendChild(this.scrollbarXRail);
|
|
1094
|
+
this.scrollbarX = div(cls.element.thumb('x'));
|
|
1095
|
+
this.scrollbarXRail.appendChild(this.scrollbarX);
|
|
1096
|
+
this.scrollbarX.setAttribute('tabindex', 0);
|
|
1097
|
+
this.event.bind(this.scrollbarX, 'focus', focus);
|
|
1098
|
+
this.event.bind(this.scrollbarX, 'blur', blur);
|
|
1099
|
+
this.scrollbarXActive = null;
|
|
1100
|
+
this.scrollbarXWidth = null;
|
|
1101
|
+
this.scrollbarXLeft = null;
|
|
1102
|
+
var railXStyle = get(this.scrollbarXRail);
|
|
1103
|
+
this.scrollbarXBottom = parseInt(railXStyle.bottom, 10);
|
|
1104
|
+
|
|
1105
|
+
if (isNaN(this.scrollbarXBottom)) {
|
|
1106
|
+
this.isScrollbarXUsingBottom = false;
|
|
1107
|
+
this.scrollbarXTop = toInt(railXStyle.top);
|
|
1108
|
+
} else {
|
|
1109
|
+
this.isScrollbarXUsingBottom = true;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
this.railBorderXWidth = toInt(railXStyle.borderLeftWidth) + toInt(railXStyle.borderRightWidth); // Set rail to display:block to calculate margins
|
|
1113
|
+
|
|
1114
|
+
set(this.scrollbarXRail, {
|
|
1115
|
+
display: 'block'
|
|
1116
|
+
});
|
|
1117
|
+
this.railXMarginWidth = toInt(railXStyle.marginLeft) + toInt(railXStyle.marginRight);
|
|
1118
|
+
set(this.scrollbarXRail, {
|
|
1119
|
+
display: ''
|
|
1120
|
+
});
|
|
1121
|
+
this.railXWidth = null;
|
|
1122
|
+
this.railXRatio = null;
|
|
1123
|
+
this.scrollbarYRail = div(cls.element.rail('y'));
|
|
1124
|
+
element.appendChild(this.scrollbarYRail);
|
|
1125
|
+
this.scrollbarY = div(cls.element.thumb('y'));
|
|
1126
|
+
this.scrollbarYRail.appendChild(this.scrollbarY);
|
|
1127
|
+
this.scrollbarY.setAttribute('tabindex', 0);
|
|
1128
|
+
this.event.bind(this.scrollbarY, 'focus', focus);
|
|
1129
|
+
this.event.bind(this.scrollbarY, 'blur', blur);
|
|
1130
|
+
this.scrollbarYActive = null;
|
|
1131
|
+
this.scrollbarYHeight = null;
|
|
1132
|
+
this.scrollbarYTop = null;
|
|
1133
|
+
var railYStyle = get(this.scrollbarYRail);
|
|
1134
|
+
this.scrollbarYRight = parseInt(railYStyle.right, 10);
|
|
1135
|
+
|
|
1136
|
+
if (isNaN(this.scrollbarYRight)) {
|
|
1137
|
+
this.isScrollbarYUsingRight = false;
|
|
1138
|
+
this.scrollbarYLeft = toInt(railYStyle.left);
|
|
1139
|
+
} else {
|
|
1140
|
+
this.isScrollbarYUsingRight = true;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
this.scrollbarYOuterWidth = this.isRtl ? outerWidth(this.scrollbarY) : null;
|
|
1144
|
+
this.railBorderYWidth = toInt(railYStyle.borderTopWidth) + toInt(railYStyle.borderBottomWidth);
|
|
1145
|
+
set(this.scrollbarYRail, {
|
|
1146
|
+
display: 'block'
|
|
1147
|
+
});
|
|
1148
|
+
this.railYMarginHeight = toInt(railYStyle.marginTop) + toInt(railYStyle.marginBottom);
|
|
1149
|
+
set(this.scrollbarYRail, {
|
|
1150
|
+
display: ''
|
|
1151
|
+
});
|
|
1152
|
+
this.railYHeight = null;
|
|
1153
|
+
this.railYRatio = null;
|
|
1154
|
+
this.reach = {
|
|
1155
|
+
x: element.scrollLeft <= 0 ? 'start' : element.scrollLeft >= this.contentWidth - this.containerWidth ? 'end' : null,
|
|
1156
|
+
y: element.scrollTop <= 0 ? 'start' : element.scrollTop >= this.contentHeight - this.containerHeight ? 'end' : null
|
|
1157
|
+
};
|
|
1158
|
+
this.isAlive = true;
|
|
1159
|
+
this.settings.handlers.forEach(function (handlerName) {
|
|
1160
|
+
return handlers[handlerName](this$1);
|
|
1161
|
+
});
|
|
1162
|
+
this.lastScrollTop = Math.floor(element.scrollTop); // for onScroll only
|
|
1163
|
+
|
|
1164
|
+
this.lastScrollLeft = element.scrollLeft; // for onScroll only
|
|
1165
|
+
|
|
1166
|
+
this.event.bind(this.element, 'scroll', function (e) {
|
|
1167
|
+
return this$1.onScroll(e);
|
|
1168
|
+
});
|
|
1169
|
+
updateGeometry(this);
|
|
1170
|
+
};
|
|
1171
|
+
|
|
1172
|
+
PerfectScrollbar.prototype.update = function update() {
|
|
1173
|
+
if (!this.isAlive) {
|
|
1174
|
+
return;
|
|
1175
|
+
} // Recalcuate negative scrollLeft adjustment
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
this.negativeScrollAdjustment = this.isNegativeScroll ? this.element.scrollWidth - this.element.clientWidth : 0; // Recalculate rail margins
|
|
1179
|
+
|
|
1180
|
+
set(this.scrollbarXRail, {
|
|
1181
|
+
display: 'block'
|
|
1182
|
+
});
|
|
1183
|
+
set(this.scrollbarYRail, {
|
|
1184
|
+
display: 'block'
|
|
1185
|
+
});
|
|
1186
|
+
this.railXMarginWidth = toInt(get(this.scrollbarXRail).marginLeft) + toInt(get(this.scrollbarXRail).marginRight);
|
|
1187
|
+
this.railYMarginHeight = toInt(get(this.scrollbarYRail).marginTop) + toInt(get(this.scrollbarYRail).marginBottom); // Hide scrollbars not to affect scrollWidth and scrollHeight
|
|
1188
|
+
|
|
1189
|
+
set(this.scrollbarXRail, {
|
|
1190
|
+
display: 'none'
|
|
1191
|
+
});
|
|
1192
|
+
set(this.scrollbarYRail, {
|
|
1193
|
+
display: 'none'
|
|
1194
|
+
});
|
|
1195
|
+
updateGeometry(this);
|
|
1196
|
+
processScrollDiff(this, 'top', 0, false, true);
|
|
1197
|
+
processScrollDiff(this, 'left', 0, false, true);
|
|
1198
|
+
set(this.scrollbarXRail, {
|
|
1199
|
+
display: ''
|
|
1200
|
+
});
|
|
1201
|
+
set(this.scrollbarYRail, {
|
|
1202
|
+
display: ''
|
|
1203
|
+
});
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
PerfectScrollbar.prototype.onScroll = function onScroll(e) {
|
|
1207
|
+
if (!this.isAlive) {
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
updateGeometry(this);
|
|
1212
|
+
processScrollDiff(this, 'top', this.element.scrollTop - this.lastScrollTop);
|
|
1213
|
+
processScrollDiff(this, 'left', this.element.scrollLeft - this.lastScrollLeft);
|
|
1214
|
+
this.lastScrollTop = Math.floor(this.element.scrollTop);
|
|
1215
|
+
this.lastScrollLeft = this.element.scrollLeft;
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1218
|
+
PerfectScrollbar.prototype.destroy = function destroy() {
|
|
1219
|
+
if (!this.isAlive) {
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
this.event.unbindAll();
|
|
1224
|
+
remove(this.scrollbarX);
|
|
1225
|
+
remove(this.scrollbarY);
|
|
1226
|
+
remove(this.scrollbarXRail);
|
|
1227
|
+
remove(this.scrollbarYRail);
|
|
1228
|
+
this.removePsClasses(); // unset elements
|
|
1229
|
+
|
|
1230
|
+
this.element = null;
|
|
1231
|
+
this.scrollbarX = null;
|
|
1232
|
+
this.scrollbarY = null;
|
|
1233
|
+
this.scrollbarXRail = null;
|
|
1234
|
+
this.scrollbarYRail = null;
|
|
1235
|
+
this.isAlive = false;
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
PerfectScrollbar.prototype.removePsClasses = function removePsClasses() {
|
|
1239
|
+
this.element.className = this.element.className.split(' ').filter(function (name) {
|
|
1240
|
+
return !name.match(/^ps([-_].+|)$/);
|
|
1241
|
+
}).join(' ');
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
const debounce = function (func, wait, immediate) {
|
|
1245
|
+
let timeout;
|
|
1246
|
+
return function () {
|
|
1247
|
+
let context = this;
|
|
1248
|
+
let args = arguments;
|
|
1249
|
+
|
|
1250
|
+
let later = function () {
|
|
1251
|
+
timeout = null;
|
|
1252
|
+
|
|
1253
|
+
if (!immediate) {
|
|
1254
|
+
func.apply(context, args);
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
let callNow = immediate && !timeout;
|
|
1259
|
+
clearTimeout(timeout);
|
|
1260
|
+
timeout = setTimeout(later, wait);
|
|
1261
|
+
|
|
1262
|
+
if (callNow) {
|
|
1263
|
+
func.apply(context, args);
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
const touchEvents = function () {
|
|
1269
|
+
let result = false;
|
|
1270
|
+
|
|
1271
|
+
if ('ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch) {
|
|
1272
|
+
result = true;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
return result;
|
|
1276
|
+
};
|
|
1277
|
+
|
|
1278
|
+
class AbstractUIComponent {
|
|
1279
|
+
// Init callback
|
|
1280
|
+
onInit() {
|
|
1281
|
+
let onInit = this.opts.onInit;
|
|
1282
|
+
|
|
1283
|
+
if (typeof onInit === 'function') {
|
|
1284
|
+
onInit.call(this.el);
|
|
1285
|
+
}
|
|
1286
|
+
} // Update callback
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
onUpdate() {
|
|
1290
|
+
let onUpdate = this.opts.onUpdate;
|
|
1291
|
+
|
|
1292
|
+
if (typeof onUpdate === 'function') {
|
|
1293
|
+
onUpdate.call(this.el);
|
|
1294
|
+
}
|
|
1295
|
+
} // Destroy callback
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
onDestroy() {
|
|
1299
|
+
let onDestroy = this.opts.onDestroy;
|
|
1300
|
+
|
|
1301
|
+
if (typeof onDestroy === 'function') {
|
|
1302
|
+
onDestroy.call(this.el);
|
|
1303
|
+
}
|
|
1304
|
+
} // Show callback
|
|
1305
|
+
|
|
1306
|
+
|
|
1307
|
+
onShow() {
|
|
1308
|
+
let onShow = this.opts.onShow;
|
|
1309
|
+
|
|
1310
|
+
if (typeof onShow === 'function') {
|
|
1311
|
+
onShow.call(this.el);
|
|
1312
|
+
}
|
|
1313
|
+
} // Close callback
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
onClose() {
|
|
1317
|
+
let onClose = this.opts.onClose;
|
|
1318
|
+
|
|
1319
|
+
if (typeof onClose === 'function') {
|
|
1320
|
+
onClose.call(this.el);
|
|
1321
|
+
}
|
|
1322
|
+
} // Debug log
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
log(...args) {
|
|
1326
|
+
if (this.debug) {
|
|
1327
|
+
if (typeof this.debug === 'function') {
|
|
1328
|
+
this.debug(...args);
|
|
1329
|
+
} else {
|
|
1330
|
+
console.log(...args);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
const NAME = 'coolDropdown';
|
|
1338
|
+
const DATA_KEY = 'plugin_coolDropdown';
|
|
1339
|
+
|
|
1340
|
+
class Dropdown extends AbstractUIComponent {
|
|
1341
|
+
constructor(el, opts) {
|
|
1342
|
+
super();
|
|
1343
|
+
this.opts = {};
|
|
1344
|
+
|
|
1345
|
+
if (window.Cool.settings.dropdown) {
|
|
1346
|
+
$.extend(true, this.opts, $.fn[NAME].defaults, window.Cool.settings.dropdown, opts);
|
|
1347
|
+
} else {
|
|
1348
|
+
$.extend(true, this.opts, $.fn[NAME].defaults, opts);
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
this.el = el;
|
|
1352
|
+
this.debug = this.opts.debug;
|
|
1353
|
+
this.init();
|
|
1354
|
+
} // Init plugin
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
init() {
|
|
1358
|
+
$.when(this.buildCache()).then(() => {
|
|
1359
|
+
this.buildScroll();
|
|
1360
|
+
this.bindEvents();
|
|
1361
|
+
this.onInit();
|
|
1362
|
+
});
|
|
1363
|
+
} // Remove plugin instance completely
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
destroy() {
|
|
1367
|
+
this.unbindEvents();
|
|
1368
|
+
this.$el.removeData(DATA_KEY);
|
|
1369
|
+
this.onDestroy();
|
|
1370
|
+
} // Update plugin data
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
update() {
|
|
1374
|
+
this.buildCache();
|
|
1375
|
+
this.onUpdate();
|
|
1376
|
+
} // Cache DOM nodes for performance
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
buildCache() {
|
|
1380
|
+
this.$el = $(this.el);
|
|
1381
|
+
this.$el.addClass('dropdown-trigger');
|
|
1382
|
+
this.$container = this.$el.parent('.dropdown');
|
|
1383
|
+
this.id = 'dropdown-' + this.generateUUID();
|
|
1384
|
+
this.animation = this.$el.data('animation') ? this.$el.data('animation') : this.opts.animation;
|
|
1385
|
+
this.animationIn = this.$el.data('animationIn') ? this.$el.data('animationIn') : this.opts.animationIn;
|
|
1386
|
+
this.animationOut = this.$el.data('animationOut') ? this.$el.data('animationOut') : this.opts.animationOut;
|
|
1387
|
+
this.animationSpeed = this.$el.data('animationSpeed') ? this.$el.data('animationSpeed') : this.opts.animationSpeed;
|
|
1388
|
+
this.offset = this.$el.data('offset') ? this.$el.data('offset') : this.opts.offset;
|
|
1389
|
+
this.minWidth = this.$el.data('minWidth') ? this.$el.data('minWidth') : this.opts.minWidth;
|
|
1390
|
+
this.scroll = this.$el.data('scroll') ? this.$el.data('scroll') : this.opts.scroll;
|
|
1391
|
+
this.scrollContentHeight = this.$el.data('scrollContentHeight') ? this.$el.data('scrollContentHeight') : this.opts.scrollContentHeight;
|
|
1392
|
+
this.closeOnItemClick = this.$el.data('closeOnItemClick') ? this.$el.data('closeOnItemClick') : this.opts.closeOnItemClick;
|
|
1393
|
+
this.content = this.$el.data('content') ? this.$el.data('content') : this.opts.content;
|
|
1394
|
+
this.contentOpen = false;
|
|
1395
|
+
|
|
1396
|
+
if (this.$container.hasClass('dropup')) {
|
|
1397
|
+
this.placement = 'top';
|
|
1398
|
+
} else if (this.$container.hasClass('dropright')) {
|
|
1399
|
+
this.placement = 'right';
|
|
1400
|
+
} else if (this.$container.hasClass('dropbottom')) {
|
|
1401
|
+
this.placement = 'bottom';
|
|
1402
|
+
} else {
|
|
1403
|
+
this.placement = 'left';
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
if (typeof this.content === 'function') {
|
|
1407
|
+
let menuRight = this.opts.align === 'end' ? ' dropdown-menu-right' : '';
|
|
1408
|
+
this.$dropdown = $(`
|
|
1409
|
+
<div class="dropdown-menu${menuRight}" id="${this.id}">
|
|
1410
|
+
${this.content}
|
|
1411
|
+
</div>
|
|
1412
|
+
`);
|
|
1413
|
+
$.when(this.$el.after(this.$dropdown)).then(() => {
|
|
1414
|
+
this.$scrollableContent = this.$dropdown.find('.dropdown-scrollable-content') ? this.$dropdown.find('.dropdown-scrollable-content') : false;
|
|
1415
|
+
this.$dropdown.hasClass('dropdown-menu-right') ? this.align = 'end' : this.align = 'start';
|
|
1416
|
+
this.$dropdownItem = this.$dropdown.find('.dropdown-item');
|
|
1417
|
+
|
|
1418
|
+
if (this.minWidth) {
|
|
1419
|
+
this.$dropdown.css('min-width', this.minWidth + 'px');
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
this.log(this.$el);
|
|
1423
|
+
this.log(this.$container);
|
|
1424
|
+
this.log(this.$dropdown);
|
|
1425
|
+
this.log(this.$scrollableContent);
|
|
1426
|
+
this.log('Id: ' + this.id);
|
|
1427
|
+
this.log('Animation: ' + this.animation);
|
|
1428
|
+
this.log('Animation in: ' + this.animationIn);
|
|
1429
|
+
this.log('Animation out: ' + this.animationOut);
|
|
1430
|
+
this.log('Animation speed: ' + this.animationSpeed);
|
|
1431
|
+
this.log('Offset: ' + this.offset);
|
|
1432
|
+
this.log('Min width: ' + this.minWidth);
|
|
1433
|
+
this.log('Content: ' + this.content);
|
|
1434
|
+
this.log('Scroll: ' + this.scroll);
|
|
1435
|
+
this.log('Scroll content height: ' + this.scrollContentHeight + 'px');
|
|
1436
|
+
return true;
|
|
1437
|
+
});
|
|
1438
|
+
} else {
|
|
1439
|
+
this.$dropdown = this.$el.next('.dropdown-menu') ? this.$el.next('.dropdown-menu') : false;
|
|
1440
|
+
this.$dropdown.hasClass('dropdown-menu-right') ? this.align = 'end' : this.align = 'start';
|
|
1441
|
+
this.$scrollableContent = this.$dropdown.find('.dropdown-scrollable-content') ? this.$dropdown.find('.dropdown-scrollable-content') : false;
|
|
1442
|
+
this.$dropdownItem = this.$dropdown.find('.dropdown-item');
|
|
1443
|
+
|
|
1444
|
+
if (this.minWidth) {
|
|
1445
|
+
this.$dropdown.css('min-width', this.minWidth + 'px');
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
this.log(this.$el);
|
|
1449
|
+
this.log(this.$container);
|
|
1450
|
+
this.log(this.$dropdown);
|
|
1451
|
+
this.log(this.$scrollableContent);
|
|
1452
|
+
this.log('Id: ' + this.id);
|
|
1453
|
+
this.log('Animation: ' + this.animation);
|
|
1454
|
+
this.log('Animation in: ' + this.animationIn);
|
|
1455
|
+
this.log('Animation out: ' + this.animationOut);
|
|
1456
|
+
this.log('Animation speed: ' + this.animationSpeed);
|
|
1457
|
+
this.log('Offset: ' + this.offset);
|
|
1458
|
+
this.log('Min width: ' + this.minWidth);
|
|
1459
|
+
this.log('Content: ' + this.opts.content);
|
|
1460
|
+
this.log('Scroll: ' + this.scroll);
|
|
1461
|
+
this.log('Scroll content height: ' + this.scrollContentHeight + 'px');
|
|
1462
|
+
return true;
|
|
1463
|
+
}
|
|
1464
|
+
} // Build scroll
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
buildScroll() {
|
|
1468
|
+
if (this.opts.scroll && this.$scrollableContent.length) {
|
|
1469
|
+
this.$scrollableContent.css({
|
|
1470
|
+
'max-height': this.scrollContentHeight + 'px'
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1473
|
+
if (touchEvents()) {
|
|
1474
|
+
this.$scrollableContent.css({
|
|
1475
|
+
'overflow-y': 'auto'
|
|
1476
|
+
});
|
|
1477
|
+
} else {
|
|
1478
|
+
this.$scrollableContent.css({
|
|
1479
|
+
'overflow-y': 'auto'
|
|
1480
|
+
});
|
|
1481
|
+
this.scroll = new PerfectScrollbar(this.$scrollableContent[0], {
|
|
1482
|
+
wheelSpeed: 1,
|
|
1483
|
+
wheelPropagation: false,
|
|
1484
|
+
minScrollbarLength: 20
|
|
1485
|
+
});
|
|
1486
|
+
this.$scrollableContent.addClass('ps-show-rail-y');
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
} // Bind events that trigger methods
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
bindEvents() {
|
|
1493
|
+
let self = this;
|
|
1494
|
+
this.$el.on('click' + '.' + NAME, () => {
|
|
1495
|
+
if (this.contentOpen) {
|
|
1496
|
+
this.close();
|
|
1497
|
+
} else {
|
|
1498
|
+
this.show();
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
this.$dropdownItem.on('click' + '.' + NAME, function () {
|
|
1502
|
+
if (self.closeOnItemClick) {
|
|
1503
|
+
self.close();
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
self.onItemClick(this);
|
|
1507
|
+
});
|
|
1508
|
+
$(document).on('touchstart click', e => {
|
|
1509
|
+
if (!this.$el.is(e.target) && !this.$dropdown.is(e.target) && this.$dropdown.has(e.target).length === 0 && this.contentOpen) {
|
|
1510
|
+
this.close();
|
|
1511
|
+
}
|
|
1512
|
+
});
|
|
1513
|
+
$(window).on('resize', debounce(() => {
|
|
1514
|
+
this.setPosition();
|
|
1515
|
+
this.onUpdate();
|
|
1516
|
+
}, 250));
|
|
1517
|
+
} // Unbind events that trigger methods
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
unbindEvents() {
|
|
1521
|
+
this.$el.off('.' + NAME);
|
|
1522
|
+
} // Generate UUID
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
generateUUID() {
|
|
1526
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
1527
|
+
let r = Math.random() * 16 | 0,
|
|
1528
|
+
v = c == 'x' ? r : r & 0x3 | 0x8;
|
|
1529
|
+
return v.toString(16);
|
|
1530
|
+
});
|
|
1531
|
+
} // Set positions
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
setPosition(placement) {
|
|
1535
|
+
if (typeof str === 'undefined' || str === null) {
|
|
1536
|
+
placement = this.placement;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
let dropdownWidth = this.$dropdown.outerWidth(true);
|
|
1540
|
+
let dropdownHeight = this.$dropdown.outerHeight(true);
|
|
1541
|
+
let dropdownTriggerWidth = this.$el.outerWidth(true);
|
|
1542
|
+
let dropdownTriggerHeight = this.$el.outerHeight(true);
|
|
1543
|
+
let dropdownTriggerPosX = this.$el.position().left;
|
|
1544
|
+
let dropdownTriggerPosY = this.$el.position().top;
|
|
1545
|
+
let dropdownPosX;
|
|
1546
|
+
let dropdownPosY;
|
|
1547
|
+
|
|
1548
|
+
if (placement === 'top') {
|
|
1549
|
+
if (this.align === 'end') {
|
|
1550
|
+
dropdownPosX = dropdownTriggerWidth - dropdownWidth;
|
|
1551
|
+
} else {
|
|
1552
|
+
dropdownPosX = dropdownTriggerPosX;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
dropdownPosY = dropdownTriggerPosY - dropdownHeight;
|
|
1556
|
+
} else if (placement === 'right') {
|
|
1557
|
+
dropdownPosX = dropdownTriggerPosX + dropdownTriggerWidth;
|
|
1558
|
+
dropdownPosY = dropdownTriggerPosY;
|
|
1559
|
+
} else if (placement === 'bottom') {
|
|
1560
|
+
if (this.align === 'end') {
|
|
1561
|
+
dropdownPosX = dropdownTriggerWidth - dropdownWidth;
|
|
1562
|
+
} else {
|
|
1563
|
+
dropdownPosX = dropdownTriggerPosX;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
dropdownPosY = dropdownTriggerPosY + dropdownTriggerHeight;
|
|
1567
|
+
} else if (placement === 'left') {
|
|
1568
|
+
dropdownPosX = dropdownTriggerPosX - dropdownWidth;
|
|
1569
|
+
dropdownPosY = dropdownTriggerPosY;
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
if (this.offset) {
|
|
1573
|
+
let offsets = this.offset.split(',');
|
|
1574
|
+
let offsetX = offsets[0];
|
|
1575
|
+
let offsetY = offsets[1];
|
|
1576
|
+
dropdownPosX += parseInt(offsetX, 10);
|
|
1577
|
+
dropdownPosY += parseInt(offsetY, 10);
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
this.$dropdown.css({
|
|
1581
|
+
position: 'absolute',
|
|
1582
|
+
top: '0px',
|
|
1583
|
+
left: '0px',
|
|
1584
|
+
transform: 'translate3d(' + Math.round(dropdownPosX) + 'px, ' + Math.round(dropdownPosY) + 'px, 0px)',
|
|
1585
|
+
'will-change': 'transform'
|
|
1586
|
+
});
|
|
1587
|
+
this.log('Dropdown trigger width: ' + dropdownTriggerWidth + 'px');
|
|
1588
|
+
this.log('Dropdown trigger height: ' + dropdownTriggerHeight + 'px');
|
|
1589
|
+
this.log('Dropdown trigger position x: ' + dropdownTriggerPosX + 'px');
|
|
1590
|
+
this.log('Dropdown trigger position Y: ' + dropdownTriggerPosY + 'px');
|
|
1591
|
+
this.log('Dropdown width: ' + dropdownWidth + 'px');
|
|
1592
|
+
this.log('Dropdown height: ' + dropdownHeight + 'px');
|
|
1593
|
+
this.log('Dropdown position x: ' + dropdownPosX + 'px');
|
|
1594
|
+
this.log('Dropdown position y: ' + dropdownPosY + 'px');
|
|
1595
|
+
} // Show
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
show() {
|
|
1599
|
+
if (!this.$dropdown || this.$dropdown.hasClass('show')) {
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
this.setPosition();
|
|
1604
|
+
|
|
1605
|
+
if (this.animation) {
|
|
1606
|
+
this.$dropdown.attr('x-placement', this.placement + '-' + this.align);
|
|
1607
|
+
this.$dropdown.addClass(this.animationSpeed);
|
|
1608
|
+
this.$dropdown.animateCss(this.animationIn);
|
|
1609
|
+
this.$dropdown.addClass('show');
|
|
1610
|
+
this.$dropdown.attr('id', this.id);
|
|
1611
|
+
this.$el.attr('data-dropdown', this.id);
|
|
1612
|
+
} else {
|
|
1613
|
+
this.$dropdown.attr('x-placement', this.placement + '-' + this.align);
|
|
1614
|
+
this.$dropdown.addClass('show');
|
|
1615
|
+
this.$dropdown.attr('id', this.id);
|
|
1616
|
+
this.$el.attr('data-dropdown', this.id);
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
if (this.opts.scroll && this.scroll && this.$scrollableContent.length) {
|
|
1620
|
+
this.$scrollableContent[0].scrollTop = 1;
|
|
1621
|
+
this.$scrollableContent[0].scrollTop = 0;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
this.contentOpen = true;
|
|
1625
|
+
this.onShow();
|
|
1626
|
+
} // Close
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
close() {
|
|
1630
|
+
if (!this.$dropdown) {
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
if (this.animation && !this.$dropdown.hasClass('animated')) {
|
|
1635
|
+
this.$dropdown.animateCss(this.animationOut, () => {
|
|
1636
|
+
this.$dropdown.removeClass('show');
|
|
1637
|
+
this.$el.removeAttr('data-dropdown');
|
|
1638
|
+
});
|
|
1639
|
+
} else {
|
|
1640
|
+
this.$dropdown.removeClass('show');
|
|
1641
|
+
this.$el.removeAttr('data-dropdown');
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
this.contentOpen = false;
|
|
1645
|
+
this.onClose();
|
|
1646
|
+
} // Item callback
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
onItemClick(el) {
|
|
1650
|
+
let onItemClick = this.opts.onItemClick;
|
|
1651
|
+
|
|
1652
|
+
if (typeof onItemClick === 'function') {
|
|
1653
|
+
onItemClick.call(el);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
static _jQueryInterface(config) {
|
|
1658
|
+
return this.each(function () {
|
|
1659
|
+
let data = $(this).data(DATA_KEY);
|
|
1660
|
+
|
|
1661
|
+
const _config = typeof config === 'object' && config;
|
|
1662
|
+
|
|
1663
|
+
if (!data) {
|
|
1664
|
+
data = new Dropdown(this, _config);
|
|
1665
|
+
$(this).data(DATA_KEY, data);
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
if (typeof config === 'string') {
|
|
1669
|
+
if (typeof data[config] === 'undefined') {
|
|
1670
|
+
throw new TypeError(`No method named "${config}"`);
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
data[config]();
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
if (typeof $ !== 'undefined') {
|
|
1681
|
+
// jQuery
|
|
1682
|
+
const JQUERY_NO_CONFLICT = $.fn[NAME];
|
|
1683
|
+
$.fn[NAME] = Dropdown._jQueryInterface;
|
|
1684
|
+
$.fn[NAME].Constructor = Dropdown;
|
|
1685
|
+
|
|
1686
|
+
$.fn[NAME].noConflict = () => {
|
|
1687
|
+
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
|
1688
|
+
return Dropdown._jQueryInterface;
|
|
1689
|
+
};
|
|
1690
|
+
|
|
1691
|
+
$.fn[NAME].defaults = {
|
|
1692
|
+
animation: true,
|
|
1693
|
+
animationIn: 'zoomIn',
|
|
1694
|
+
animationOut: 'zoomOut',
|
|
1695
|
+
animationSpeed: 'fastest',
|
|
1696
|
+
offset: null,
|
|
1697
|
+
minWidth: null,
|
|
1698
|
+
align: 'start',
|
|
1699
|
+
closeOnItemClick: true,
|
|
1700
|
+
content: false,
|
|
1701
|
+
scroll: true,
|
|
1702
|
+
scrollContentHeight: 100,
|
|
1703
|
+
onInit: null,
|
|
1704
|
+
onUpdate: null,
|
|
1705
|
+
onDestroy: null,
|
|
1706
|
+
onShow: null,
|
|
1707
|
+
onClose: null,
|
|
1708
|
+
onItemClick: null,
|
|
1709
|
+
debug: false
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
return Dropdown;
|
|
1714
|
+
|
|
1715
|
+
}));
|
|
1716
|
+
//# sourceMappingURL=dropdown.js.map
|