@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.
Files changed (199) hide show
  1. package/README.md +1 -0
  2. package/build/.eslintrc.json +10 -0
  3. package/build/banner.js +14 -0
  4. package/build/build-plugins.js +92 -0
  5. package/build/rollup.config.js +78 -0
  6. package/dist/css/cool-grid.css +3672 -0
  7. package/dist/css/cool-grid.css.map +30 -0
  8. package/dist/css/cool-grid.min.css +7 -0
  9. package/dist/css/cool-grid.min.css.map +1 -0
  10. package/dist/css/cool-reboot.css +281 -0
  11. package/dist/css/cool-reboot.css.map +58 -0
  12. package/dist/css/cool-reboot.min.css +7 -0
  13. package/dist/css/cool-reboot.min.css.map +1 -0
  14. package/dist/css/cool.css +14841 -0
  15. package/dist/css/cool.css.map +144 -0
  16. package/dist/css/cool.min.css +7 -0
  17. package/dist/css/cool.min.css.map +1 -0
  18. package/dist/js/cool.bundle.js +15304 -0
  19. package/dist/js/cool.bundle.js.map +1 -0
  20. package/dist/js/cool.bundle.min.js +45 -0
  21. package/dist/js/cool.bundle.min.js.map +1 -0
  22. package/dist/js/cool.esm.js +4766 -0
  23. package/dist/js/cool.esm.js.map +1 -0
  24. package/dist/js/cool.esm.min.js +7 -0
  25. package/dist/js/cool.esm.min.js.map +1 -0
  26. package/dist/js/cool.js +4948 -0
  27. package/dist/js/cool.js.map +1 -0
  28. package/dist/js/cool.min.js +7 -0
  29. package/dist/js/cool.min.js.map +1 -0
  30. package/html/index.html +892 -0
  31. package/js/dist/collapse.js +321 -0
  32. package/js/dist/collapse.js.map +1 -0
  33. package/js/dist/common.js +1474 -0
  34. package/js/dist/common.js.map +1 -0
  35. package/js/dist/cooldropdown.js +467 -0
  36. package/js/dist/cooldropdown.js.map +1 -0
  37. package/js/dist/coolpopover.js +391 -0
  38. package/js/dist/coolpopover.js.map +1 -0
  39. package/js/dist/coolsectiontabs.js +256 -0
  40. package/js/dist/coolsectiontabs.js.map +1 -0
  41. package/js/dist/coolselect.js +796 -0
  42. package/js/dist/coolselect.js.map +1 -0
  43. package/js/dist/cooltooltip.js +360 -0
  44. package/js/dist/cooltooltip.js.map +1 -0
  45. package/js/dist/coolui.js +73 -0
  46. package/js/dist/coolui.js.map +1 -0
  47. package/js/dist/dropdown.js +1716 -0
  48. package/js/dist/dropdown.js.map +1 -0
  49. package/js/dist/popover.js +587 -0
  50. package/js/dist/popover.js.map +1 -0
  51. package/js/dist/sectiontabs.js +263 -0
  52. package/js/dist/sectiontabs.js.map +1 -0
  53. package/js/dist/select.js +2029 -0
  54. package/js/dist/select.js.map +1 -0
  55. package/js/dist/tooltip.js +555 -0
  56. package/js/dist/tooltip.js.map +1 -0
  57. package/js/index.esm.js +21 -0
  58. package/js/index.umd.js +21 -0
  59. package/js/src/abstract-ui-component.js +70 -0
  60. package/js/src/collapse.js +258 -0
  61. package/js/src/common.js +280 -0
  62. package/js/src/dialog.js +570 -0
  63. package/js/src/dropdown.js +443 -0
  64. package/js/src/popover.js +615 -0
  65. package/js/src/section-tabs.js +204 -0
  66. package/js/src/select.js +832 -0
  67. package/js/src/toast.js +581 -0
  68. package/js/src/tooltip.js +575 -0
  69. package/js/src/util/animate-css.js +22 -0
  70. package/js/src/util/index.js +112 -0
  71. package/js/src/util/perfect-scrollbar.js +1316 -0
  72. package/less/alert.less +345 -0
  73. package/less/badge.less +38 -0
  74. package/less/bootstrap-noconflict.less +23 -0
  75. package/less/bootstrap.less +23 -0
  76. package/less/button-group.less +153 -0
  77. package/less/buttons.less +287 -0
  78. package/less/dialog-noconflict.less +174 -0
  79. package/less/dialog.less +203 -0
  80. package/less/dropdown.less +209 -0
  81. package/less/forms.less +770 -0
  82. package/less/images.less +242 -0
  83. package/less/input-group.less +163 -0
  84. package/less/list-group.less +73 -0
  85. package/less/mixins/aspect-ratio.less +23 -0
  86. package/less/mixins/border-radius.less +24 -0
  87. package/less/mixins/box-shadow.less +4 -0
  88. package/less/mixins/buttons.less +17 -0
  89. package/less/mixins/caret.less +51 -0
  90. package/less/mixins/clearfix.less +10 -0
  91. package/less/mixins/gradients.less +34 -0
  92. package/less/mixins/nav-divider.less +7 -0
  93. package/less/mixins/object-fit.less +13 -0
  94. package/less/mixins/reset-text.less +16 -0
  95. package/less/mixins.less +11 -0
  96. package/less/package.json +11 -0
  97. package/less/pagination.less +69 -0
  98. package/less/popover.less +143 -0
  99. package/less/project.sublime-workspace +774 -0
  100. package/less/reboot.less +235 -0
  101. package/less/section.less +793 -0
  102. package/less/select.less +150 -0
  103. package/less/tables.less +737 -0
  104. package/less/tabs.less +162 -0
  105. package/less/tooltip.less +87 -0
  106. package/less/type.less +71 -0
  107. package/less/utilities/align.less +27 -0
  108. package/less/utilities/animate.less +3512 -0
  109. package/less/utilities/background.less +70 -0
  110. package/less/utilities/borders.less +16 -0
  111. package/less/utilities/color.less +70 -0
  112. package/less/utilities/cursor.less +8 -0
  113. package/less/utilities/display.less +38 -0
  114. package/less/utilities/embed.less +61 -0
  115. package/less/utilities/flex.less +76 -0
  116. package/less/utilities/jquery-ui.less +116 -0
  117. package/less/utilities/lazyload.less +29 -0
  118. package/less/utilities/overflow.less +11 -0
  119. package/less/utilities/pace.less +25 -0
  120. package/less/utilities/placeholder.less +60 -0
  121. package/less/utilities/position.less +42 -0
  122. package/less/utilities/scrollbar.less +152 -0
  123. package/less/utilities/spacing.less +197 -0
  124. package/less/utilities/text.less +68 -0
  125. package/less/utilities/transform.less +7 -0
  126. package/less/utilities.less +21 -0
  127. package/less/variables.less +343 -0
  128. package/package.json +71 -0
  129. package/scss/LISENCE +15 -0
  130. package/scss/_alert.scss +125 -0
  131. package/scss/_badge.scss +58 -0
  132. package/scss/_button-group.scss +124 -0
  133. package/scss/_buttons.scss +206 -0
  134. package/scss/_custom-forms.scss +423 -0
  135. package/scss/_dialog.scss +149 -0
  136. package/scss/_dropdown.scss +234 -0
  137. package/scss/_forms.scss +257 -0
  138. package/scss/_frame.scss +523 -0
  139. package/scss/_functions.scss +114 -0
  140. package/scss/_grid.scss +35 -0
  141. package/scss/_images.scss +312 -0
  142. package/scss/_input-group.scss +245 -0
  143. package/scss/_list-group.scss +82 -0
  144. package/scss/_mixins.scss +32 -0
  145. package/scss/_navbar.scss +214 -0
  146. package/scss/_pagination.scss +79 -0
  147. package/scss/_popover.scss +165 -0
  148. package/scss/_reboot.scss +279 -0
  149. package/scss/_root.scss +15 -0
  150. package/scss/_section.scss +851 -0
  151. package/scss/_select.scss +166 -0
  152. package/scss/_tables.scss +707 -0
  153. package/scss/_tabs.scss +175 -0
  154. package/scss/_toast.scss +182 -0
  155. package/scss/_tooltip.scss +101 -0
  156. package/scss/_type.scss +90 -0
  157. package/scss/_utilities.scss +21 -0
  158. package/scss/_variables.scss +697 -0
  159. package/scss/cool-grid.scss +29 -0
  160. package/scss/cool-reboot.scss +11 -0
  161. package/scss/cool.scss +36 -0
  162. package/scss/mixins/_alert-variant.scss +40 -0
  163. package/scss/mixins/_aspect-ratio.scss +29 -0
  164. package/scss/mixins/_background-variant.scss +25 -0
  165. package/scss/mixins/_badge-variant.scss +13 -0
  166. package/scss/mixins/_breakpoints.scss +102 -0
  167. package/scss/mixins/_buttons.scss +104 -0
  168. package/scss/mixins/_caret.scss +80 -0
  169. package/scss/mixins/_clearfix.scss +10 -0
  170. package/scss/mixins/_float.scss +14 -0
  171. package/scss/mixins/_forms.scss +51 -0
  172. package/scss/mixins/_gradients.scss +40 -0
  173. package/scss/mixins/_grid-framework.scss +72 -0
  174. package/scss/mixins/_grid.scss +60 -0
  175. package/scss/mixins/_nav-divider.scss +9 -0
  176. package/scss/mixins/_object-fit.scss +16 -0
  177. package/scss/mixins/_reset-text.scss +19 -0
  178. package/scss/mixins/_text-emphasis.scss +21 -0
  179. package/scss/mixins/_text-hide.scss +10 -0
  180. package/scss/mixins/_text-truncate.scss +8 -0
  181. package/scss/project.sublime-workspace +491 -0
  182. package/scss/utilities/_align.scss +41 -0
  183. package/scss/utilities/_animate.scss +3512 -0
  184. package/scss/utilities/_background.scss +14 -0
  185. package/scss/utilities/_borders.scss +146 -0
  186. package/scss/utilities/_clearfix.scss +6 -0
  187. package/scss/utilities/_collapse.scss +33 -0
  188. package/scss/utilities/_cursor.scss +10 -0
  189. package/scss/utilities/_display.scss +16 -0
  190. package/scss/utilities/_embed.scss +78 -0
  191. package/scss/utilities/_flex.scss +50 -0
  192. package/scss/utilities/_lazyload.scss +31 -0
  193. package/scss/utilities/_overflow.scss +6 -0
  194. package/scss/utilities/_perfect-scrollbar.scss +154 -0
  195. package/scss/utilities/_placeholder.scss +76 -0
  196. package/scss/utilities/_position.scss +30 -0
  197. package/scss/utilities/_sizing.scss +32 -0
  198. package/scss/utilities/_spacing.scss +92 -0
  199. package/scss/utilities/_text.scss +97 -0
@@ -0,0 +1,4766 @@
1
+ /*!
2
+ * Cool UI 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
+ import 'jquery';
7
+
8
+ /*!
9
+ * perfect-scrollbar v1.4.0
10
+ * (c) 2018 Hyunje Jun
11
+ * @license MIT
12
+ */
13
+ function get(element) {
14
+ return getComputedStyle(element);
15
+ }
16
+
17
+ function set(element, obj) {
18
+ for (var key in obj) {
19
+ var val = obj[key];
20
+
21
+ if (typeof val === 'number') {
22
+ val = val + "px";
23
+ }
24
+
25
+ element.style[key] = val;
26
+ }
27
+
28
+ return element;
29
+ }
30
+
31
+ function div(className) {
32
+ var div = document.createElement('div');
33
+ div.className = className;
34
+ return div;
35
+ }
36
+
37
+ var elMatches = typeof Element !== 'undefined' && (Element.prototype.matches || Element.prototype.webkitMatchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector);
38
+
39
+ function matches(element, query) {
40
+ if (!elMatches) {
41
+ throw new Error('No element matching method supported');
42
+ }
43
+
44
+ return elMatches.call(element, query);
45
+ }
46
+
47
+ function remove(element) {
48
+ if (element.remove) {
49
+ element.remove();
50
+ } else {
51
+ if (element.parentNode) {
52
+ element.parentNode.removeChild(element);
53
+ }
54
+ }
55
+ }
56
+
57
+ function queryChildren(element, selector) {
58
+ return Array.prototype.filter.call(element.children, function (child) {
59
+ return matches(child, selector);
60
+ });
61
+ }
62
+
63
+ var cls = {
64
+ main: 'ps',
65
+ element: {
66
+ thumb: function thumb(x) {
67
+ return "ps__thumb-" + x;
68
+ },
69
+ rail: function rail(x) {
70
+ return "ps__rail-" + x;
71
+ },
72
+ consuming: 'ps__child--consume'
73
+ },
74
+ state: {
75
+ focus: 'ps--focus',
76
+ clicking: 'ps--clicking',
77
+ active: function active(x) {
78
+ return "ps--active-" + x;
79
+ },
80
+ scrolling: function scrolling(x) {
81
+ return "ps--scrolling-" + x;
82
+ }
83
+ }
84
+ };
85
+ /*
86
+ * Helper methods
87
+ */
88
+
89
+ var scrollingClassTimeout = {
90
+ x: null,
91
+ y: null
92
+ };
93
+
94
+ function addScrollingClass(i, x) {
95
+ var classList = i.element.classList;
96
+ var className = cls.state.scrolling(x);
97
+
98
+ if (classList.contains(className)) {
99
+ clearTimeout(scrollingClassTimeout[x]);
100
+ } else {
101
+ classList.add(className);
102
+ }
103
+ }
104
+
105
+ function removeScrollingClass(i, x) {
106
+ scrollingClassTimeout[x] = setTimeout(function () {
107
+ return i.isAlive && i.element.classList.remove(cls.state.scrolling(x));
108
+ }, i.settings.scrollingThreshold);
109
+ }
110
+
111
+ function setScrollingClassInstantly(i, x) {
112
+ addScrollingClass(i, x);
113
+ removeScrollingClass(i, x);
114
+ }
115
+
116
+ var EventElement = function EventElement(element) {
117
+ this.element = element;
118
+ this.handlers = {};
119
+ };
120
+
121
+ var prototypeAccessors = {
122
+ isEmpty: {
123
+ configurable: true
124
+ }
125
+ };
126
+
127
+ EventElement.prototype.bind = function bind(eventName, handler) {
128
+ if (typeof this.handlers[eventName] === 'undefined') {
129
+ this.handlers[eventName] = [];
130
+ }
131
+
132
+ this.handlers[eventName].push(handler);
133
+ this.element.addEventListener(eventName, handler, false);
134
+ };
135
+
136
+ EventElement.prototype.unbind = function unbind(eventName, target) {
137
+ var this$1 = this;
138
+ this.handlers[eventName] = this.handlers[eventName].filter(function (handler) {
139
+ if (target && handler !== target) {
140
+ return true;
141
+ }
142
+
143
+ this$1.element.removeEventListener(eventName, handler, false);
144
+ return false;
145
+ });
146
+ };
147
+
148
+ EventElement.prototype.unbindAll = function unbindAll() {
149
+ var this$1 = this;
150
+
151
+ for (var name in this$1.handlers) {
152
+ this$1.unbind(name);
153
+ }
154
+ };
155
+
156
+ prototypeAccessors.isEmpty.get = function () {
157
+ var this$1 = this;
158
+ return Object.keys(this.handlers).every(function (key) {
159
+ return this$1.handlers[key].length === 0;
160
+ });
161
+ };
162
+
163
+ Object.defineProperties(EventElement.prototype, prototypeAccessors);
164
+
165
+ var EventManager = function EventManager() {
166
+ this.eventElements = [];
167
+ };
168
+
169
+ EventManager.prototype.eventElement = function eventElement(element) {
170
+ var ee = this.eventElements.filter(function (ee) {
171
+ return ee.element === element;
172
+ })[0];
173
+
174
+ if (!ee) {
175
+ ee = new EventElement(element);
176
+ this.eventElements.push(ee);
177
+ }
178
+
179
+ return ee;
180
+ };
181
+
182
+ EventManager.prototype.bind = function bind(element, eventName, handler) {
183
+ this.eventElement(element).bind(eventName, handler);
184
+ };
185
+
186
+ EventManager.prototype.unbind = function unbind(element, eventName, handler) {
187
+ var ee = this.eventElement(element);
188
+ ee.unbind(eventName, handler);
189
+
190
+ if (ee.isEmpty) {
191
+ // remove
192
+ this.eventElements.splice(this.eventElements.indexOf(ee), 1);
193
+ }
194
+ };
195
+
196
+ EventManager.prototype.unbindAll = function unbindAll() {
197
+ this.eventElements.forEach(function (e) {
198
+ return e.unbindAll();
199
+ });
200
+ this.eventElements = [];
201
+ };
202
+
203
+ EventManager.prototype.once = function once(element, eventName, handler) {
204
+ var ee = this.eventElement(element);
205
+
206
+ var onceHandler = function onceHandler(evt) {
207
+ ee.unbind(eventName, onceHandler);
208
+ handler(evt);
209
+ };
210
+
211
+ ee.bind(eventName, onceHandler);
212
+ };
213
+
214
+ function createEvent(name) {
215
+ if (typeof window.CustomEvent === 'function') {
216
+ return new CustomEvent(name);
217
+ } else {
218
+ var evt = document.createEvent('CustomEvent');
219
+ evt.initCustomEvent(name, false, false, undefined);
220
+ return evt;
221
+ }
222
+ }
223
+
224
+ var processScrollDiff = function processScrollDiff(i, axis, diff, useScrollingClass, forceFireReachEvent) {
225
+ if (useScrollingClass === void 0) useScrollingClass = true;
226
+ if (forceFireReachEvent === void 0) forceFireReachEvent = false;
227
+ var fields;
228
+
229
+ if (axis === 'top') {
230
+ fields = ['contentHeight', 'containerHeight', 'scrollTop', 'y', 'up', 'down'];
231
+ } else if (axis === 'left') {
232
+ fields = ['contentWidth', 'containerWidth', 'scrollLeft', 'x', 'left', 'right'];
233
+ } else {
234
+ throw new Error('A proper axis should be provided');
235
+ }
236
+
237
+ processScrollDiff$1(i, diff, fields, useScrollingClass, forceFireReachEvent);
238
+ };
239
+
240
+ function processScrollDiff$1(i, diff, ref, useScrollingClass, forceFireReachEvent) {
241
+ var contentHeight = ref[0];
242
+ var containerHeight = ref[1];
243
+ var scrollTop = ref[2];
244
+ var y = ref[3];
245
+ var up = ref[4];
246
+ var down = ref[5];
247
+ if (useScrollingClass === void 0) useScrollingClass = true;
248
+ if (forceFireReachEvent === void 0) forceFireReachEvent = false;
249
+ var element = i.element; // reset reach
250
+
251
+ i.reach[y] = null; // 1 for subpixel rounding
252
+
253
+ if (element[scrollTop] < 1) {
254
+ i.reach[y] = 'start';
255
+ } // 1 for subpixel rounding
256
+
257
+
258
+ if (element[scrollTop] > i[contentHeight] - i[containerHeight] - 1) {
259
+ i.reach[y] = 'end';
260
+ }
261
+
262
+ if (diff) {
263
+ element.dispatchEvent(createEvent("ps-scroll-" + y));
264
+
265
+ if (diff < 0) {
266
+ element.dispatchEvent(createEvent("ps-scroll-" + up));
267
+ } else if (diff > 0) {
268
+ element.dispatchEvent(createEvent("ps-scroll-" + down));
269
+ }
270
+
271
+ if (useScrollingClass) {
272
+ setScrollingClassInstantly(i, y);
273
+ }
274
+ }
275
+
276
+ if (i.reach[y] && (diff || forceFireReachEvent)) {
277
+ element.dispatchEvent(createEvent("ps-" + y + "-reach-" + i.reach[y]));
278
+ }
279
+ }
280
+
281
+ function toInt(x) {
282
+ return parseInt(x, 10) || 0;
283
+ }
284
+
285
+ function isEditable(el) {
286
+ return matches(el, 'input,[contenteditable]') || matches(el, 'select,[contenteditable]') || matches(el, 'textarea,[contenteditable]') || matches(el, 'button,[contenteditable]');
287
+ }
288
+
289
+ function outerWidth(element) {
290
+ var styles = get(element);
291
+ return toInt(styles.width) + toInt(styles.paddingLeft) + toInt(styles.paddingRight) + toInt(styles.borderLeftWidth) + toInt(styles.borderRightWidth);
292
+ }
293
+
294
+ var env = {
295
+ isWebKit: typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style,
296
+ supportsTouch: typeof window !== 'undefined' && ('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
297
+ supportsIePointer: typeof navigator !== 'undefined' && navigator.msMaxTouchPoints,
298
+ isChrome: typeof navigator !== 'undefined' && /Chrome/i.test(navigator && navigator.userAgent)
299
+ };
300
+
301
+ var updateGeometry = function updateGeometry(i) {
302
+ var element = i.element;
303
+ var roundedScrollTop = Math.floor(element.scrollTop);
304
+ i.containerWidth = element.clientWidth;
305
+ i.containerHeight = element.clientHeight;
306
+ i.contentWidth = element.scrollWidth;
307
+ i.contentHeight = element.scrollHeight;
308
+
309
+ if (!element.contains(i.scrollbarXRail)) {
310
+ // clean up and append
311
+ queryChildren(element, cls.element.rail('x')).forEach(function (el) {
312
+ return remove(el);
313
+ });
314
+ element.appendChild(i.scrollbarXRail);
315
+ }
316
+
317
+ if (!element.contains(i.scrollbarYRail)) {
318
+ // clean up and append
319
+ queryChildren(element, cls.element.rail('y')).forEach(function (el) {
320
+ return remove(el);
321
+ });
322
+ element.appendChild(i.scrollbarYRail);
323
+ }
324
+
325
+ if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) {
326
+ i.scrollbarXActive = true;
327
+ i.railXWidth = i.containerWidth - i.railXMarginWidth;
328
+ i.railXRatio = i.containerWidth / i.railXWidth;
329
+ i.scrollbarXWidth = getThumbSize(i, toInt(i.railXWidth * i.containerWidth / i.contentWidth));
330
+ i.scrollbarXLeft = toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth));
331
+ } else {
332
+ i.scrollbarXActive = false;
333
+ }
334
+
335
+ if (!i.settings.suppressScrollY && i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight) {
336
+ i.scrollbarYActive = true;
337
+ i.railYHeight = i.containerHeight - i.railYMarginHeight;
338
+ i.railYRatio = i.containerHeight / i.railYHeight;
339
+ i.scrollbarYHeight = getThumbSize(i, toInt(i.railYHeight * i.containerHeight / i.contentHeight));
340
+ i.scrollbarYTop = toInt(roundedScrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight));
341
+ } else {
342
+ i.scrollbarYActive = false;
343
+ }
344
+
345
+ if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) {
346
+ i.scrollbarXLeft = i.railXWidth - i.scrollbarXWidth;
347
+ }
348
+
349
+ if (i.scrollbarYTop >= i.railYHeight - i.scrollbarYHeight) {
350
+ i.scrollbarYTop = i.railYHeight - i.scrollbarYHeight;
351
+ }
352
+
353
+ updateCss(element, i);
354
+
355
+ if (i.scrollbarXActive) {
356
+ element.classList.add(cls.state.active('x'));
357
+ } else {
358
+ element.classList.remove(cls.state.active('x'));
359
+ i.scrollbarXWidth = 0;
360
+ i.scrollbarXLeft = 0;
361
+ element.scrollLeft = 0;
362
+ }
363
+
364
+ if (i.scrollbarYActive) {
365
+ element.classList.add(cls.state.active('y'));
366
+ } else {
367
+ element.classList.remove(cls.state.active('y'));
368
+ i.scrollbarYHeight = 0;
369
+ i.scrollbarYTop = 0;
370
+ element.scrollTop = 0;
371
+ }
372
+ };
373
+
374
+ function getThumbSize(i, thumbSize) {
375
+ if (i.settings.minScrollbarLength) {
376
+ thumbSize = Math.max(thumbSize, i.settings.minScrollbarLength);
377
+ }
378
+
379
+ if (i.settings.maxScrollbarLength) {
380
+ thumbSize = Math.min(thumbSize, i.settings.maxScrollbarLength);
381
+ }
382
+
383
+ return thumbSize;
384
+ }
385
+
386
+ function updateCss(element, i) {
387
+ var xRailOffset = {
388
+ width: i.railXWidth
389
+ };
390
+ var roundedScrollTop = Math.floor(element.scrollTop);
391
+
392
+ if (i.isRtl) {
393
+ xRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth - i.contentWidth;
394
+ } else {
395
+ xRailOffset.left = element.scrollLeft;
396
+ }
397
+
398
+ if (i.isScrollbarXUsingBottom) {
399
+ xRailOffset.bottom = i.scrollbarXBottom - roundedScrollTop;
400
+ } else {
401
+ xRailOffset.top = i.scrollbarXTop + roundedScrollTop;
402
+ }
403
+
404
+ set(i.scrollbarXRail, xRailOffset);
405
+ var yRailOffset = {
406
+ top: roundedScrollTop,
407
+ height: i.railYHeight
408
+ };
409
+
410
+ if (i.isScrollbarYUsingRight) {
411
+ if (i.isRtl) {
412
+ yRailOffset.right = i.contentWidth - (i.negativeScrollAdjustment + element.scrollLeft) - i.scrollbarYRight - i.scrollbarYOuterWidth;
413
+ } else {
414
+ yRailOffset.right = i.scrollbarYRight - element.scrollLeft;
415
+ }
416
+ } else {
417
+ if (i.isRtl) {
418
+ yRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth * 2 - i.contentWidth - i.scrollbarYLeft - i.scrollbarYOuterWidth;
419
+ } else {
420
+ yRailOffset.left = i.scrollbarYLeft + element.scrollLeft;
421
+ }
422
+ }
423
+
424
+ set(i.scrollbarYRail, yRailOffset);
425
+ set(i.scrollbarX, {
426
+ left: i.scrollbarXLeft,
427
+ width: i.scrollbarXWidth - i.railBorderXWidth
428
+ });
429
+ set(i.scrollbarY, {
430
+ top: i.scrollbarYTop,
431
+ height: i.scrollbarYHeight - i.railBorderYWidth
432
+ });
433
+ }
434
+
435
+ var clickRail = function clickRail(i) {
436
+ i.event.bind(i.scrollbarY, 'mousedown', function (e) {
437
+ return e.stopPropagation();
438
+ });
439
+ i.event.bind(i.scrollbarYRail, 'mousedown', function (e) {
440
+ var positionTop = e.pageY - window.pageYOffset - i.scrollbarYRail.getBoundingClientRect().top;
441
+ var direction = positionTop > i.scrollbarYTop ? 1 : -1;
442
+ i.element.scrollTop += direction * i.containerHeight;
443
+ updateGeometry(i);
444
+ e.stopPropagation();
445
+ });
446
+ i.event.bind(i.scrollbarX, 'mousedown', function (e) {
447
+ return e.stopPropagation();
448
+ });
449
+ i.event.bind(i.scrollbarXRail, 'mousedown', function (e) {
450
+ var positionLeft = e.pageX - window.pageXOffset - i.scrollbarXRail.getBoundingClientRect().left;
451
+ var direction = positionLeft > i.scrollbarXLeft ? 1 : -1;
452
+ i.element.scrollLeft += direction * i.containerWidth;
453
+ updateGeometry(i);
454
+ e.stopPropagation();
455
+ });
456
+ };
457
+
458
+ var dragThumb = function dragThumb(i) {
459
+ bindMouseScrollHandler(i, ['containerWidth', 'contentWidth', 'pageX', 'railXWidth', 'scrollbarX', 'scrollbarXWidth', 'scrollLeft', 'x', 'scrollbarXRail']);
460
+ bindMouseScrollHandler(i, ['containerHeight', 'contentHeight', 'pageY', 'railYHeight', 'scrollbarY', 'scrollbarYHeight', 'scrollTop', 'y', 'scrollbarYRail']);
461
+ };
462
+
463
+ function bindMouseScrollHandler(i, ref) {
464
+ var containerHeight = ref[0];
465
+ var contentHeight = ref[1];
466
+ var pageY = ref[2];
467
+ var railYHeight = ref[3];
468
+ var scrollbarY = ref[4];
469
+ var scrollbarYHeight = ref[5];
470
+ var scrollTop = ref[6];
471
+ var y = ref[7];
472
+ var scrollbarYRail = ref[8];
473
+ var element = i.element;
474
+ var startingScrollTop = null;
475
+ var startingMousePageY = null;
476
+ var scrollBy = null;
477
+
478
+ function mouseMoveHandler(e) {
479
+ element[scrollTop] = startingScrollTop + scrollBy * (e[pageY] - startingMousePageY);
480
+ addScrollingClass(i, y);
481
+ updateGeometry(i);
482
+ e.stopPropagation();
483
+ e.preventDefault();
484
+ }
485
+
486
+ function mouseUpHandler() {
487
+ removeScrollingClass(i, y);
488
+ i[scrollbarYRail].classList.remove(cls.state.clicking);
489
+ i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
490
+ }
491
+
492
+ i.event.bind(i[scrollbarY], 'mousedown', function (e) {
493
+ startingScrollTop = element[scrollTop];
494
+ startingMousePageY = e[pageY];
495
+ scrollBy = (i[contentHeight] - i[containerHeight]) / (i[railYHeight] - i[scrollbarYHeight]);
496
+ i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
497
+ i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
498
+ i[scrollbarYRail].classList.add(cls.state.clicking);
499
+ e.stopPropagation();
500
+ e.preventDefault();
501
+ });
502
+ }
503
+
504
+ var keyboard = function keyboard(i) {
505
+ var element = i.element;
506
+
507
+ var elementHovered = function elementHovered() {
508
+ return matches(element, ':hover');
509
+ };
510
+
511
+ var scrollbarFocused = function scrollbarFocused() {
512
+ return matches(i.scrollbarX, ':focus') || matches(i.scrollbarY, ':focus');
513
+ };
514
+
515
+ function shouldPreventDefault(deltaX, deltaY) {
516
+ var scrollTop = Math.floor(element.scrollTop);
517
+
518
+ if (deltaX === 0) {
519
+ if (!i.scrollbarYActive) {
520
+ return false;
521
+ }
522
+
523
+ if (scrollTop === 0 && deltaY > 0 || scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0) {
524
+ return !i.settings.wheelPropagation;
525
+ }
526
+ }
527
+
528
+ var scrollLeft = element.scrollLeft;
529
+
530
+ if (deltaY === 0) {
531
+ if (!i.scrollbarXActive) {
532
+ return false;
533
+ }
534
+
535
+ if (scrollLeft === 0 && deltaX < 0 || scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0) {
536
+ return !i.settings.wheelPropagation;
537
+ }
538
+ }
539
+
540
+ return true;
541
+ }
542
+
543
+ i.event.bind(i.ownerDocument, 'keydown', function (e) {
544
+ if (e.isDefaultPrevented && e.isDefaultPrevented() || e.defaultPrevented) {
545
+ return;
546
+ }
547
+
548
+ if (!elementHovered() && !scrollbarFocused()) {
549
+ return;
550
+ }
551
+
552
+ var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement;
553
+
554
+ if (activeElement) {
555
+ if (activeElement.tagName === 'IFRAME') {
556
+ activeElement = activeElement.contentDocument.activeElement;
557
+ } else {
558
+ // go deeper if element is a webcomponent
559
+ while (activeElement.shadowRoot) {
560
+ activeElement = activeElement.shadowRoot.activeElement;
561
+ }
562
+ }
563
+
564
+ if (isEditable(activeElement)) {
565
+ return;
566
+ }
567
+ }
568
+
569
+ var deltaX = 0;
570
+ var deltaY = 0;
571
+
572
+ switch (e.which) {
573
+ case 37:
574
+ // left
575
+ if (e.metaKey) {
576
+ deltaX = -i.contentWidth;
577
+ } else if (e.altKey) {
578
+ deltaX = -i.containerWidth;
579
+ } else {
580
+ deltaX = -30;
581
+ }
582
+
583
+ break;
584
+
585
+ case 38:
586
+ // up
587
+ if (e.metaKey) {
588
+ deltaY = i.contentHeight;
589
+ } else if (e.altKey) {
590
+ deltaY = i.containerHeight;
591
+ } else {
592
+ deltaY = 30;
593
+ }
594
+
595
+ break;
596
+
597
+ case 39:
598
+ // right
599
+ if (e.metaKey) {
600
+ deltaX = i.contentWidth;
601
+ } else if (e.altKey) {
602
+ deltaX = i.containerWidth;
603
+ } else {
604
+ deltaX = 30;
605
+ }
606
+
607
+ break;
608
+
609
+ case 40:
610
+ // down
611
+ if (e.metaKey) {
612
+ deltaY = -i.contentHeight;
613
+ } else if (e.altKey) {
614
+ deltaY = -i.containerHeight;
615
+ } else {
616
+ deltaY = -30;
617
+ }
618
+
619
+ break;
620
+
621
+ case 32:
622
+ // space bar
623
+ if (e.shiftKey) {
624
+ deltaY = i.containerHeight;
625
+ } else {
626
+ deltaY = -i.containerHeight;
627
+ }
628
+
629
+ break;
630
+
631
+ case 33:
632
+ // page up
633
+ deltaY = i.containerHeight;
634
+ break;
635
+
636
+ case 34:
637
+ // page down
638
+ deltaY = -i.containerHeight;
639
+ break;
640
+
641
+ case 36:
642
+ // home
643
+ deltaY = i.contentHeight;
644
+ break;
645
+
646
+ case 35:
647
+ // end
648
+ deltaY = -i.contentHeight;
649
+ break;
650
+
651
+ default:
652
+ return;
653
+ }
654
+
655
+ if (i.settings.suppressScrollX && deltaX !== 0) {
656
+ return;
657
+ }
658
+
659
+ if (i.settings.suppressScrollY && deltaY !== 0) {
660
+ return;
661
+ }
662
+
663
+ element.scrollTop -= deltaY;
664
+ element.scrollLeft += deltaX;
665
+ updateGeometry(i);
666
+
667
+ if (shouldPreventDefault(deltaX, deltaY)) {
668
+ e.preventDefault();
669
+ }
670
+ });
671
+ };
672
+
673
+ var wheel = function wheel(i) {
674
+ var element = i.element;
675
+
676
+ function shouldPreventDefault(deltaX, deltaY) {
677
+ var roundedScrollTop = Math.floor(element.scrollTop);
678
+ var isTop = element.scrollTop === 0;
679
+ var isBottom = roundedScrollTop + element.offsetHeight === element.scrollHeight;
680
+ var isLeft = element.scrollLeft === 0;
681
+ var isRight = element.scrollLeft + element.offsetWidth === element.scrollWidth;
682
+ var hitsBound; // pick axis with primary direction
683
+
684
+ if (Math.abs(deltaY) > Math.abs(deltaX)) {
685
+ hitsBound = isTop || isBottom;
686
+ } else {
687
+ hitsBound = isLeft || isRight;
688
+ }
689
+
690
+ return hitsBound ? !i.settings.wheelPropagation : true;
691
+ }
692
+
693
+ function getDeltaFromEvent(e) {
694
+ var deltaX = e.deltaX;
695
+ var deltaY = -1 * e.deltaY;
696
+
697
+ if (typeof deltaX === 'undefined' || typeof deltaY === 'undefined') {
698
+ // OS X Safari
699
+ deltaX = -1 * e.wheelDeltaX / 6;
700
+ deltaY = e.wheelDeltaY / 6;
701
+ }
702
+
703
+ if (e.deltaMode && e.deltaMode === 1) {
704
+ // Firefox in deltaMode 1: Line scrolling
705
+ deltaX *= 10;
706
+ deltaY *= 10;
707
+ }
708
+
709
+ if (deltaX !== deltaX && deltaY !== deltaY
710
+ /* NaN checks */
711
+ ) {
712
+ // IE in some mouse drivers
713
+ deltaX = 0;
714
+ deltaY = e.wheelDelta;
715
+ }
716
+
717
+ if (e.shiftKey) {
718
+ // reverse axis with shift key
719
+ return [-deltaY, -deltaX];
720
+ }
721
+
722
+ return [deltaX, deltaY];
723
+ }
724
+
725
+ function shouldBeConsumedByChild(target, deltaX, deltaY) {
726
+ // FIXME: this is a workaround for <select> issue in FF and IE #571
727
+ if (!env.isWebKit && element.querySelector('select:focus')) {
728
+ return true;
729
+ }
730
+
731
+ if (!element.contains(target)) {
732
+ return false;
733
+ }
734
+
735
+ var cursor = target;
736
+
737
+ while (cursor && cursor !== element) {
738
+ if (cursor.classList.contains(cls.element.consuming)) {
739
+ return true;
740
+ }
741
+
742
+ var style = get(cursor);
743
+ var overflow = [style.overflow, style.overflowX, style.overflowY].join(''); // if scrollable
744
+
745
+ if (overflow.match(/(scroll|auto)/)) {
746
+ var maxScrollTop = cursor.scrollHeight - cursor.clientHeight;
747
+
748
+ if (maxScrollTop > 0) {
749
+ if (!(cursor.scrollTop === 0 && deltaY > 0) && !(cursor.scrollTop === maxScrollTop && deltaY < 0)) {
750
+ return true;
751
+ }
752
+ }
753
+
754
+ var maxScrollLeft = cursor.scrollWidth - cursor.clientWidth;
755
+
756
+ if (maxScrollLeft > 0) {
757
+ if (!(cursor.scrollLeft === 0 && deltaX < 0) && !(cursor.scrollLeft === maxScrollLeft && deltaX > 0)) {
758
+ return true;
759
+ }
760
+ }
761
+ }
762
+
763
+ cursor = cursor.parentNode;
764
+ }
765
+
766
+ return false;
767
+ }
768
+
769
+ function mousewheelHandler(e) {
770
+ var ref = getDeltaFromEvent(e);
771
+ var deltaX = ref[0];
772
+ var deltaY = ref[1];
773
+
774
+ if (shouldBeConsumedByChild(e.target, deltaX, deltaY)) {
775
+ return;
776
+ }
777
+
778
+ var shouldPrevent = false;
779
+
780
+ if (!i.settings.useBothWheelAxes) {
781
+ // deltaX will only be used for horizontal scrolling and deltaY will
782
+ // only be used for vertical scrolling - this is the default
783
+ element.scrollTop -= deltaY * i.settings.wheelSpeed;
784
+ element.scrollLeft += deltaX * i.settings.wheelSpeed;
785
+ } else if (i.scrollbarYActive && !i.scrollbarXActive) {
786
+ // only vertical scrollbar is active and useBothWheelAxes option is
787
+ // active, so let's scroll vertical bar using both mouse wheel axes
788
+ if (deltaY) {
789
+ element.scrollTop -= deltaY * i.settings.wheelSpeed;
790
+ } else {
791
+ element.scrollTop += deltaX * i.settings.wheelSpeed;
792
+ }
793
+
794
+ shouldPrevent = true;
795
+ } else if (i.scrollbarXActive && !i.scrollbarYActive) {
796
+ // useBothWheelAxes and only horizontal bar is active, so use both
797
+ // wheel axes for horizontal bar
798
+ if (deltaX) {
799
+ element.scrollLeft += deltaX * i.settings.wheelSpeed;
800
+ } else {
801
+ element.scrollLeft -= deltaY * i.settings.wheelSpeed;
802
+ }
803
+
804
+ shouldPrevent = true;
805
+ }
806
+
807
+ updateGeometry(i);
808
+ shouldPrevent = shouldPrevent || shouldPreventDefault(deltaX, deltaY);
809
+
810
+ if (shouldPrevent && !e.ctrlKey) {
811
+ e.stopPropagation();
812
+ e.preventDefault();
813
+ }
814
+ }
815
+
816
+ if (typeof window.onwheel !== 'undefined') {
817
+ i.event.bind(element, 'wheel', mousewheelHandler);
818
+ } else if (typeof window.onmousewheel !== 'undefined') {
819
+ i.event.bind(element, 'mousewheel', mousewheelHandler);
820
+ }
821
+ };
822
+
823
+ var touch = function touch(i) {
824
+ if (!env.supportsTouch && !env.supportsIePointer) {
825
+ return;
826
+ }
827
+
828
+ var element = i.element;
829
+
830
+ function shouldPrevent(deltaX, deltaY) {
831
+ var scrollTop = Math.floor(element.scrollTop);
832
+ var scrollLeft = element.scrollLeft;
833
+ var magnitudeX = Math.abs(deltaX);
834
+ var magnitudeY = Math.abs(deltaY);
835
+
836
+ if (magnitudeY > magnitudeX) {
837
+ // user is perhaps trying to swipe up/down the page
838
+ if (deltaY < 0 && scrollTop === i.contentHeight - i.containerHeight || deltaY > 0 && scrollTop === 0) {
839
+ // set prevent for mobile Chrome refresh
840
+ return window.scrollY === 0 && deltaY > 0 && env.isChrome;
841
+ }
842
+ } else if (magnitudeX > magnitudeY) {
843
+ // user is perhaps trying to swipe left/right across the page
844
+ if (deltaX < 0 && scrollLeft === i.contentWidth - i.containerWidth || deltaX > 0 && scrollLeft === 0) {
845
+ return true;
846
+ }
847
+ }
848
+
849
+ return true;
850
+ }
851
+
852
+ function applyTouchMove(differenceX, differenceY) {
853
+ element.scrollTop -= differenceY;
854
+ element.scrollLeft -= differenceX;
855
+ updateGeometry(i);
856
+ }
857
+
858
+ var startOffset = {};
859
+ var startTime = 0;
860
+ var speed = {};
861
+ var easingLoop = null;
862
+
863
+ function getTouch(e) {
864
+ if (e.targetTouches) {
865
+ return e.targetTouches[0];
866
+ } else {
867
+ // Maybe IE pointer
868
+ return e;
869
+ }
870
+ }
871
+
872
+ function shouldHandle(e) {
873
+ if (e.pointerType && e.pointerType === 'pen' && e.buttons === 0) {
874
+ return false;
875
+ }
876
+
877
+ if (e.targetTouches && e.targetTouches.length === 1) {
878
+ return true;
879
+ }
880
+
881
+ if (e.pointerType && e.pointerType !== 'mouse' && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) {
882
+ return true;
883
+ }
884
+
885
+ return false;
886
+ }
887
+
888
+ function touchStart(e) {
889
+ if (!shouldHandle(e)) {
890
+ return;
891
+ }
892
+
893
+ var touch = getTouch(e);
894
+ startOffset.pageX = touch.pageX;
895
+ startOffset.pageY = touch.pageY;
896
+ startTime = new Date().getTime();
897
+
898
+ if (easingLoop !== null) {
899
+ clearInterval(easingLoop);
900
+ }
901
+ }
902
+
903
+ function shouldBeConsumedByChild(target, deltaX, deltaY) {
904
+ if (!element.contains(target)) {
905
+ return false;
906
+ }
907
+
908
+ var cursor = target;
909
+
910
+ while (cursor && cursor !== element) {
911
+ if (cursor.classList.contains(cls.element.consuming)) {
912
+ return true;
913
+ }
914
+
915
+ var style = get(cursor);
916
+ var overflow = [style.overflow, style.overflowX, style.overflowY].join(''); // if scrollable
917
+
918
+ if (overflow.match(/(scroll|auto)/)) {
919
+ var maxScrollTop = cursor.scrollHeight - cursor.clientHeight;
920
+
921
+ if (maxScrollTop > 0) {
922
+ if (!(cursor.scrollTop === 0 && deltaY > 0) && !(cursor.scrollTop === maxScrollTop && deltaY < 0)) {
923
+ return true;
924
+ }
925
+ }
926
+
927
+ var maxScrollLeft = cursor.scrollLeft - cursor.clientWidth;
928
+
929
+ if (maxScrollLeft > 0) {
930
+ if (!(cursor.scrollLeft === 0 && deltaX < 0) && !(cursor.scrollLeft === maxScrollLeft && deltaX > 0)) {
931
+ return true;
932
+ }
933
+ }
934
+ }
935
+
936
+ cursor = cursor.parentNode;
937
+ }
938
+
939
+ return false;
940
+ }
941
+
942
+ function touchMove(e) {
943
+ if (shouldHandle(e)) {
944
+ var touch = getTouch(e);
945
+ var currentOffset = {
946
+ pageX: touch.pageX,
947
+ pageY: touch.pageY
948
+ };
949
+ var differenceX = currentOffset.pageX - startOffset.pageX;
950
+ var differenceY = currentOffset.pageY - startOffset.pageY;
951
+
952
+ if (shouldBeConsumedByChild(e.target, differenceX, differenceY)) {
953
+ return;
954
+ }
955
+
956
+ applyTouchMove(differenceX, differenceY);
957
+ startOffset = currentOffset;
958
+ var currentTime = new Date().getTime();
959
+ var timeGap = currentTime - startTime;
960
+
961
+ if (timeGap > 0) {
962
+ speed.x = differenceX / timeGap;
963
+ speed.y = differenceY / timeGap;
964
+ startTime = currentTime;
965
+ }
966
+
967
+ if (shouldPrevent(differenceX, differenceY)) {
968
+ e.preventDefault();
969
+ }
970
+ }
971
+ }
972
+
973
+ function touchEnd() {
974
+ if (i.settings.swipeEasing) {
975
+ clearInterval(easingLoop);
976
+ easingLoop = setInterval(function () {
977
+ if (i.isInitialized) {
978
+ clearInterval(easingLoop);
979
+ return;
980
+ }
981
+
982
+ if (!speed.x && !speed.y) {
983
+ clearInterval(easingLoop);
984
+ return;
985
+ }
986
+
987
+ if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
988
+ clearInterval(easingLoop);
989
+ return;
990
+ }
991
+
992
+ applyTouchMove(speed.x * 30, speed.y * 30);
993
+ speed.x *= 0.8;
994
+ speed.y *= 0.8;
995
+ }, 10);
996
+ }
997
+ }
998
+
999
+ if (env.supportsTouch) {
1000
+ i.event.bind(element, 'touchstart', touchStart);
1001
+ i.event.bind(element, 'touchmove', touchMove);
1002
+ i.event.bind(element, 'touchend', touchEnd);
1003
+ } else if (env.supportsIePointer) {
1004
+ if (window.PointerEvent) {
1005
+ i.event.bind(element, 'pointerdown', touchStart);
1006
+ i.event.bind(element, 'pointermove', touchMove);
1007
+ i.event.bind(element, 'pointerup', touchEnd);
1008
+ } else if (window.MSPointerEvent) {
1009
+ i.event.bind(element, 'MSPointerDown', touchStart);
1010
+ i.event.bind(element, 'MSPointerMove', touchMove);
1011
+ i.event.bind(element, 'MSPointerUp', touchEnd);
1012
+ }
1013
+ }
1014
+ };
1015
+
1016
+ var defaultSettings = function defaultSettings() {
1017
+ return {
1018
+ handlers: ['click-rail', 'drag-thumb', 'keyboard', 'wheel', 'touch'],
1019
+ maxScrollbarLength: null,
1020
+ minScrollbarLength: null,
1021
+ scrollingThreshold: 1000,
1022
+ scrollXMarginOffset: 0,
1023
+ scrollYMarginOffset: 0,
1024
+ suppressScrollX: false,
1025
+ suppressScrollY: false,
1026
+ swipeEasing: true,
1027
+ useBothWheelAxes: false,
1028
+ wheelPropagation: true,
1029
+ wheelSpeed: 1
1030
+ };
1031
+ };
1032
+
1033
+ var handlers = {
1034
+ 'click-rail': clickRail,
1035
+ 'drag-thumb': dragThumb,
1036
+ keyboard: keyboard,
1037
+ wheel: wheel,
1038
+ touch: touch
1039
+ };
1040
+
1041
+ var PerfectScrollbar = function PerfectScrollbar(element, userSettings) {
1042
+ var this$1 = this;
1043
+ if (userSettings === void 0) userSettings = {};
1044
+
1045
+ if (typeof element === 'string') {
1046
+ element = document.querySelector(element);
1047
+ }
1048
+
1049
+ if (!element || !element.nodeName) {
1050
+ throw new Error('no element is specified to initialize PerfectScrollbar');
1051
+ }
1052
+
1053
+ this.element = element;
1054
+ element.classList.add(cls.main);
1055
+ this.settings = defaultSettings();
1056
+
1057
+ for (var key in userSettings) {
1058
+ this$1.settings[key] = userSettings[key];
1059
+ }
1060
+
1061
+ this.containerWidth = null;
1062
+ this.containerHeight = null;
1063
+ this.contentWidth = null;
1064
+ this.contentHeight = null;
1065
+
1066
+ var focus = function focus() {
1067
+ return element.classList.add(cls.state.focus);
1068
+ };
1069
+
1070
+ var blur = function blur() {
1071
+ return element.classList.remove(cls.state.focus);
1072
+ };
1073
+
1074
+ this.isRtl = get(element).direction === 'rtl';
1075
+
1076
+ this.isNegativeScroll = function () {
1077
+ var originalScrollLeft = element.scrollLeft;
1078
+ var result = null;
1079
+ element.scrollLeft = -1;
1080
+ result = element.scrollLeft < 0;
1081
+ element.scrollLeft = originalScrollLeft;
1082
+ return result;
1083
+ }();
1084
+
1085
+ this.negativeScrollAdjustment = this.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
1086
+ this.event = new EventManager();
1087
+ this.ownerDocument = element.ownerDocument || document;
1088
+ this.scrollbarXRail = div(cls.element.rail('x'));
1089
+ element.appendChild(this.scrollbarXRail);
1090
+ this.scrollbarX = div(cls.element.thumb('x'));
1091
+ this.scrollbarXRail.appendChild(this.scrollbarX);
1092
+ this.scrollbarX.setAttribute('tabindex', 0);
1093
+ this.event.bind(this.scrollbarX, 'focus', focus);
1094
+ this.event.bind(this.scrollbarX, 'blur', blur);
1095
+ this.scrollbarXActive = null;
1096
+ this.scrollbarXWidth = null;
1097
+ this.scrollbarXLeft = null;
1098
+ var railXStyle = get(this.scrollbarXRail);
1099
+ this.scrollbarXBottom = parseInt(railXStyle.bottom, 10);
1100
+
1101
+ if (isNaN(this.scrollbarXBottom)) {
1102
+ this.isScrollbarXUsingBottom = false;
1103
+ this.scrollbarXTop = toInt(railXStyle.top);
1104
+ } else {
1105
+ this.isScrollbarXUsingBottom = true;
1106
+ }
1107
+
1108
+ this.railBorderXWidth = toInt(railXStyle.borderLeftWidth) + toInt(railXStyle.borderRightWidth); // Set rail to display:block to calculate margins
1109
+
1110
+ set(this.scrollbarXRail, {
1111
+ display: 'block'
1112
+ });
1113
+ this.railXMarginWidth = toInt(railXStyle.marginLeft) + toInt(railXStyle.marginRight);
1114
+ set(this.scrollbarXRail, {
1115
+ display: ''
1116
+ });
1117
+ this.railXWidth = null;
1118
+ this.railXRatio = null;
1119
+ this.scrollbarYRail = div(cls.element.rail('y'));
1120
+ element.appendChild(this.scrollbarYRail);
1121
+ this.scrollbarY = div(cls.element.thumb('y'));
1122
+ this.scrollbarYRail.appendChild(this.scrollbarY);
1123
+ this.scrollbarY.setAttribute('tabindex', 0);
1124
+ this.event.bind(this.scrollbarY, 'focus', focus);
1125
+ this.event.bind(this.scrollbarY, 'blur', blur);
1126
+ this.scrollbarYActive = null;
1127
+ this.scrollbarYHeight = null;
1128
+ this.scrollbarYTop = null;
1129
+ var railYStyle = get(this.scrollbarYRail);
1130
+ this.scrollbarYRight = parseInt(railYStyle.right, 10);
1131
+
1132
+ if (isNaN(this.scrollbarYRight)) {
1133
+ this.isScrollbarYUsingRight = false;
1134
+ this.scrollbarYLeft = toInt(railYStyle.left);
1135
+ } else {
1136
+ this.isScrollbarYUsingRight = true;
1137
+ }
1138
+
1139
+ this.scrollbarYOuterWidth = this.isRtl ? outerWidth(this.scrollbarY) : null;
1140
+ this.railBorderYWidth = toInt(railYStyle.borderTopWidth) + toInt(railYStyle.borderBottomWidth);
1141
+ set(this.scrollbarYRail, {
1142
+ display: 'block'
1143
+ });
1144
+ this.railYMarginHeight = toInt(railYStyle.marginTop) + toInt(railYStyle.marginBottom);
1145
+ set(this.scrollbarYRail, {
1146
+ display: ''
1147
+ });
1148
+ this.railYHeight = null;
1149
+ this.railYRatio = null;
1150
+ this.reach = {
1151
+ x: element.scrollLeft <= 0 ? 'start' : element.scrollLeft >= this.contentWidth - this.containerWidth ? 'end' : null,
1152
+ y: element.scrollTop <= 0 ? 'start' : element.scrollTop >= this.contentHeight - this.containerHeight ? 'end' : null
1153
+ };
1154
+ this.isAlive = true;
1155
+ this.settings.handlers.forEach(function (handlerName) {
1156
+ return handlers[handlerName](this$1);
1157
+ });
1158
+ this.lastScrollTop = Math.floor(element.scrollTop); // for onScroll only
1159
+
1160
+ this.lastScrollLeft = element.scrollLeft; // for onScroll only
1161
+
1162
+ this.event.bind(this.element, 'scroll', function (e) {
1163
+ return this$1.onScroll(e);
1164
+ });
1165
+ updateGeometry(this);
1166
+ };
1167
+
1168
+ PerfectScrollbar.prototype.update = function update() {
1169
+ if (!this.isAlive) {
1170
+ return;
1171
+ } // Recalcuate negative scrollLeft adjustment
1172
+
1173
+
1174
+ this.negativeScrollAdjustment = this.isNegativeScroll ? this.element.scrollWidth - this.element.clientWidth : 0; // Recalculate rail margins
1175
+
1176
+ set(this.scrollbarXRail, {
1177
+ display: 'block'
1178
+ });
1179
+ set(this.scrollbarYRail, {
1180
+ display: 'block'
1181
+ });
1182
+ this.railXMarginWidth = toInt(get(this.scrollbarXRail).marginLeft) + toInt(get(this.scrollbarXRail).marginRight);
1183
+ this.railYMarginHeight = toInt(get(this.scrollbarYRail).marginTop) + toInt(get(this.scrollbarYRail).marginBottom); // Hide scrollbars not to affect scrollWidth and scrollHeight
1184
+
1185
+ set(this.scrollbarXRail, {
1186
+ display: 'none'
1187
+ });
1188
+ set(this.scrollbarYRail, {
1189
+ display: 'none'
1190
+ });
1191
+ updateGeometry(this);
1192
+ processScrollDiff(this, 'top', 0, false, true);
1193
+ processScrollDiff(this, 'left', 0, false, true);
1194
+ set(this.scrollbarXRail, {
1195
+ display: ''
1196
+ });
1197
+ set(this.scrollbarYRail, {
1198
+ display: ''
1199
+ });
1200
+ };
1201
+
1202
+ PerfectScrollbar.prototype.onScroll = function onScroll(e) {
1203
+ if (!this.isAlive) {
1204
+ return;
1205
+ }
1206
+
1207
+ updateGeometry(this);
1208
+ processScrollDiff(this, 'top', this.element.scrollTop - this.lastScrollTop);
1209
+ processScrollDiff(this, 'left', this.element.scrollLeft - this.lastScrollLeft);
1210
+ this.lastScrollTop = Math.floor(this.element.scrollTop);
1211
+ this.lastScrollLeft = this.element.scrollLeft;
1212
+ };
1213
+
1214
+ PerfectScrollbar.prototype.destroy = function destroy() {
1215
+ if (!this.isAlive) {
1216
+ return;
1217
+ }
1218
+
1219
+ this.event.unbindAll();
1220
+ remove(this.scrollbarX);
1221
+ remove(this.scrollbarY);
1222
+ remove(this.scrollbarXRail);
1223
+ remove(this.scrollbarYRail);
1224
+ this.removePsClasses(); // unset elements
1225
+
1226
+ this.element = null;
1227
+ this.scrollbarX = null;
1228
+ this.scrollbarY = null;
1229
+ this.scrollbarXRail = null;
1230
+ this.scrollbarYRail = null;
1231
+ this.isAlive = false;
1232
+ };
1233
+
1234
+ PerfectScrollbar.prototype.removePsClasses = function removePsClasses() {
1235
+ this.element.className = this.element.className.split(' ').filter(function (name) {
1236
+ return !name.match(/^ps([-_].+|)$/);
1237
+ }).join(' ');
1238
+ };
1239
+
1240
+ $.fn.extend({
1241
+ animateCss: function animateCss(animationName, callback) {
1242
+ var el = this;
1243
+ var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
1244
+ el.addClass('animated ' + animationName).one(animationEnd, function (e) {
1245
+ $(this).removeClass('animated ' + animationName);
1246
+
1247
+ if (callback) {
1248
+ callback();
1249
+ }
1250
+ }).children().on(animationEnd, function (e) {
1251
+ e.stopPropagation();
1252
+ });
1253
+ }
1254
+ });
1255
+
1256
+ window.Cool = window.Cool || {};
1257
+ window.Cool.settings = window.Cool.settings || {};
1258
+
1259
+ class Common {
1260
+ static initialize(opts) {
1261
+ // There's an error if opts is not defined
1262
+ opts = opts || {}; // Save settings for later use
1263
+
1264
+ window.Cool.settings = opts; // Init plugins
1265
+
1266
+ $('[data-toggle="popover"]').coolPopover(opts.popover);
1267
+ $('[data-toggle="select"]').coolSelect(opts.select);
1268
+ $('[data-toggle="dropdown"]').coolDropdown(opts.dropdown);
1269
+ $('[data-toggle="tooltip"]').coolTooltip(opts.tooltip);
1270
+ $('[data-toggle="collapse"]').coolCollapse(opts.collapse);
1271
+ $('[data-toggle="section-tabs"]').coolSectionTabs(opts.sectionTabs);
1272
+ $('body').coolToast(opts.toast);
1273
+ $('body').coolDialog(opts.dialog); // Dom ready
1274
+
1275
+ $('html').addClass('dom-ready'); // Input group focus in
1276
+
1277
+ $(document).on('focus', '.form-control', function () {
1278
+ if (!$(this).hasClass('disabled') && $(this).not(':disabled') && !$(this).attr('readonly')) {
1279
+ let $inputGroup = $(this).closest('.input-group');
1280
+
1281
+ if (!$inputGroup.hasClass('input-group-focus')) {
1282
+ $inputGroup.addClass('input-group-focus');
1283
+ }
1284
+ }
1285
+ }); // Input group focus out
1286
+
1287
+ $(document).on('blur', '.form-control', function () {
1288
+ if (!$(this).hasClass('disabled') && $(this).not(':disabled') && !$(this).attr('readonly')) {
1289
+ let $inputGroup = $(this).closest('.input-group');
1290
+
1291
+ if ($inputGroup.hasClass('input-group-focus')) {
1292
+ $inputGroup.removeClass('input-group-focus');
1293
+ }
1294
+ }
1295
+ }); // Custom Form group
1296
+
1297
+ $('.form-label-group').each(function (i, formLabelGroup) {
1298
+ let $formLabelGroup = $(formLabelGroup);
1299
+ $formLabelGroup.find('input').on('blur input change', function () {
1300
+ let val = $(this).val();
1301
+
1302
+ if (val) {
1303
+ $(formLabelGroup).addClass('label-on-top');
1304
+ } else {
1305
+ $(formLabelGroup).removeClass('label-on-top');
1306
+ }
1307
+ }).trigger('change');
1308
+ }); // Table actions
1309
+
1310
+ $.each($('.table'), function () {
1311
+ if ($(this).find('[data-table-link], [data-table-btn]').length && !$(this).hasClass('table-hover')) {
1312
+ $(this).addClass('table-hover');
1313
+ }
1314
+ });
1315
+ $(document).on('click', '[data-table-link]', function (e) {
1316
+ let $container = $(this).parents('table, .table');
1317
+ let href = $(this).data('tableLink');
1318
+ let target = $(e.target);
1319
+ let exceptions = ['input', 'button', 'a', 'label', 'td.col-select'];
1320
+ let linkDisabled = false;
1321
+ $.each(exceptions, function (item) {
1322
+ if (target.is(item) || item == 'a' && target.parent().is(item)) {
1323
+ linkDisabled = true;
1324
+ }
1325
+ });
1326
+
1327
+ if ($container.hasClass('bulk-actions-active')) {
1328
+ linkDisabled = true;
1329
+ }
1330
+
1331
+ if (target.is('td, .td, img') && !linkDisabled) {
1332
+ if (e.ctrlKey || e.metaKey) {
1333
+ window.open(href, '_blank');
1334
+ } else {
1335
+ window.location.href = href;
1336
+ }
1337
+ } else {
1338
+ return;
1339
+ }
1340
+ });
1341
+ $(document).on('click', '[data-table-btn]', function (e) {
1342
+ let $container = $(this).parents('table, .table');
1343
+ let $self = $(this);
1344
+ let btn = $(this).data('tableButton');
1345
+ let target = $(e.target);
1346
+ let exceptions = ['input', 'button', 'a', 'label', 'td.col-select'];
1347
+ let btnDisabled = false;
1348
+
1349
+ if (!btn) {
1350
+ btn = $self.find('button')[0];
1351
+
1352
+ if (!btn) {
1353
+ return;
1354
+ }
1355
+ }
1356
+
1357
+ $.each(exceptions, function (item) {
1358
+ if (target.is(item) || item == 'a' && target.parent().is(item)) {
1359
+ btnDisabled = true;
1360
+ }
1361
+ });
1362
+
1363
+ if ($container.hasClass('bulk-actions-active')) {
1364
+ btnDisabled = true;
1365
+ }
1366
+
1367
+ if (target.is('td, .td, img') && !btnDisabled) {
1368
+ $(btn).click();
1369
+ } else {
1370
+ return;
1371
+ }
1372
+ }); // Force select element unfocus after change
1373
+
1374
+ $('select').on('change', function () {
1375
+ $(this).blur();
1376
+ }); // Tabs
1377
+
1378
+ $('.tab-toggler').on('click', function (e) {
1379
+ e.stopPropagation();
1380
+ $(this).parent().toggleClass('open');
1381
+ });
1382
+ $(document).on('click', function () {
1383
+ $('.tabs-container').removeClass('open');
1384
+ }); // Sidebar togglers
1385
+
1386
+ $('.sidebar-left-toggler').on('click', function (e) {
1387
+ e.stopPropagation();
1388
+ $(this).toggleClass('open');
1389
+ $('body').toggleClass('sidebar-left-open');
1390
+ });
1391
+ $('.sidebar-right-toggler').on('click', function (e) {
1392
+ e.stopPropagation();
1393
+ $(this).toggleClass('open');
1394
+ $('body').toggleClass('sidebar-right-open');
1395
+ }); // Sidebar scroll
1396
+
1397
+ $('.sidebar-content .ps__thumb-y').mousedown(function () {
1398
+ $(this).parent().parent().addClass('ps-mousedown-scroll');
1399
+ });
1400
+ $(document).mouseup(function () {
1401
+ if ($('.sidebar-content').hasClass('ps-mousedown-scroll')) {
1402
+ $('.sidebar-content').removeClass('ps-mousedown-scroll');
1403
+ }
1404
+ }); // Sidebar left scroll
1405
+
1406
+ let $sidebarLeft = $('.sidebar-left');
1407
+ let $sidebarLeftContent = $sidebarLeft.find('.sidebar-content');
1408
+
1409
+ if ($sidebarLeftContent.length) {
1410
+ let sidebarLeftScroll = new PerfectScrollbar($sidebarLeftContent[0], {
1411
+ wheelSpeed: 2,
1412
+ wheelPropagation: true,
1413
+ minScrollbarLength: 20,
1414
+ suppressScrollX: true
1415
+ });
1416
+ } // Sidebar tabs
1417
+
1418
+
1419
+ let $sidebarTabs = $(document).find('.sidebar-tab');
1420
+
1421
+ if ($sidebarTabs.length) {
1422
+ $.each($sidebarTabs, function (i, el) {
1423
+ let scrollContainer = $(el).find('.tab-content');
1424
+ const sidebarTabsScroll = new PerfectScrollbar(scrollContainer[0], {
1425
+ wheelSpeed: 2,
1426
+ wheelPropagation: true,
1427
+ minScrollbarLength: 20,
1428
+ suppressScrollX: true
1429
+ });
1430
+ });
1431
+ $('[name="sidebar-tab-select"]').on('click', function () {
1432
+ let val = $(this).val();
1433
+ let $tab = $('#sidebar-tab-' + val);
1434
+ $sidebarTabs.not($tab).removeClass('active');
1435
+ $tab.addClass('active');
1436
+ $('[name="sidebar-tab-select"]').not($(this)).removeClass('active');
1437
+ $(this).addClass('active');
1438
+
1439
+ if ($tab[0] == $sidebarTabs.first()[0]) {
1440
+ $sidebarTabs.not($tab).find('.tab-content').css({
1441
+ 'transform': 'translate3d(100%, 0px, 0px)'
1442
+ });
1443
+ } else if ($tab[0] == $sidebarTabs.last()[0]) {
1444
+ $sidebarTabs.not($tab).find('.tab-content').css({
1445
+ 'transform': 'translate3d(-100%, 0px, 0px)'
1446
+ });
1447
+ } else {
1448
+ $sidebarTabs.first().not($tab).find('.tab-content').css({
1449
+ 'transform': 'translate3d(-100%, 0px, 0px)'
1450
+ });
1451
+ $sidebarTabs.last().not($tab).find('.tab-content').css({
1452
+ 'transform': 'translate3d(100%, 0px, 0px)'
1453
+ });
1454
+ }
1455
+
1456
+ $tab.find('.tab-content').css({
1457
+ 'transform': 'none'
1458
+ });
1459
+ });
1460
+ }
1461
+ }
1462
+
1463
+ }
1464
+
1465
+ window.Cool.initialize = Common.initialize;
1466
+
1467
+ const debounce = function debounce(func, wait, immediate) {
1468
+ let timeout;
1469
+ return function () {
1470
+ let context = this;
1471
+ let args = arguments;
1472
+
1473
+ let later = function later() {
1474
+ timeout = null;
1475
+
1476
+ if (!immediate) {
1477
+ func.apply(context, args);
1478
+ }
1479
+ };
1480
+
1481
+ let callNow = immediate && !timeout;
1482
+ clearTimeout(timeout);
1483
+ timeout = setTimeout(later, wait);
1484
+
1485
+ if (callNow) {
1486
+ func.apply(context, args);
1487
+ }
1488
+ };
1489
+ };
1490
+
1491
+ const touchEvents = function touchEvents() {
1492
+ let result = false;
1493
+
1494
+ if ('ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch) {
1495
+ result = true;
1496
+ }
1497
+
1498
+ return result;
1499
+ };
1500
+
1501
+ class AbstractUIComponent {
1502
+ // Init callback
1503
+ onInit() {
1504
+ let onInit = this.opts.onInit;
1505
+
1506
+ if (typeof onInit === 'function') {
1507
+ onInit.call(this.el);
1508
+ }
1509
+ } // Update callback
1510
+
1511
+
1512
+ onUpdate() {
1513
+ let onUpdate = this.opts.onUpdate;
1514
+
1515
+ if (typeof onUpdate === 'function') {
1516
+ onUpdate.call(this.el);
1517
+ }
1518
+ } // Destroy callback
1519
+
1520
+
1521
+ onDestroy() {
1522
+ let onDestroy = this.opts.onDestroy;
1523
+
1524
+ if (typeof onDestroy === 'function') {
1525
+ onDestroy.call(this.el);
1526
+ }
1527
+ } // Show callback
1528
+
1529
+
1530
+ onShow() {
1531
+ let onShow = this.opts.onShow;
1532
+
1533
+ if (typeof onShow === 'function') {
1534
+ onShow.call(this.el);
1535
+ }
1536
+ } // Close callback
1537
+
1538
+
1539
+ onClose() {
1540
+ let onClose = this.opts.onClose;
1541
+
1542
+ if (typeof onClose === 'function') {
1543
+ onClose.call(this.el);
1544
+ }
1545
+ } // Debug log
1546
+
1547
+
1548
+ log() {
1549
+ if (this.debug) {
1550
+ if (typeof this.debug === 'function') {
1551
+ this.debug(...arguments);
1552
+ } else {
1553
+ console.log(...arguments);
1554
+ }
1555
+ }
1556
+ }
1557
+
1558
+ }
1559
+
1560
+ const NAME = 'coolPopover';
1561
+ const DATA_KEY = 'plugin_coolPopover';
1562
+
1563
+ class Popover extends AbstractUIComponent {
1564
+ constructor(el, opts) {
1565
+ super();
1566
+ this.opts = {};
1567
+
1568
+ if (window.Cool.settings.popover) {
1569
+ $.extend(true, this.opts, $.fn[NAME].defaults, window.Cool.settings.popover, opts);
1570
+ } else {
1571
+ $.extend(true, this.opts, $.fn[NAME].defaults, opts);
1572
+ }
1573
+
1574
+ this.el = el;
1575
+ this.debug = this.opts.debug;
1576
+ this.init();
1577
+ } // Init plugin
1578
+
1579
+
1580
+ init() {
1581
+ this.buildCache();
1582
+ this.bindEvents();
1583
+ this.onInit();
1584
+ } // Remove plugin instance completely
1585
+
1586
+
1587
+ destroy() {
1588
+ this.unbindEvents();
1589
+ this.$el.removeData(DATA_KEY);
1590
+ this.onDestroy();
1591
+ } // Update plugin data
1592
+
1593
+
1594
+ update() {
1595
+ this.buildCache();
1596
+ this.onUpdate();
1597
+ } // Cache DOM nodes for performance
1598
+
1599
+
1600
+ buildCache() {
1601
+ this.$el = $(this.el);
1602
+ this.$container = this.$el.data('container') ? $(this.$el.data('container')) : $(this.opts.container);
1603
+ this.id = 'popover-' + this.generateUUID();
1604
+ this.animation = this.$el.data('animation') ? this.$el.data('animation') : this.opts.animation;
1605
+ this.animationIn = this.$el.data('animationIn') ? this.$el.data('animationIn') : this.opts.animationIn;
1606
+ this.animationOut = this.$el.data('animationOut') ? this.$el.data('animationOut') : this.opts.animationOut;
1607
+ this.animationSpeed = this.$el.data('animationSpeed') ? this.$el.data('animationSpeed') : this.opts.animationSpeed;
1608
+ this.trigger = this.$el.data('trigger') ? this.$el.data('trigger') : this.opts.trigger;
1609
+ this.placement = this.$el.data('placement') ? this.$el.data('placement') : this.opts.placement;
1610
+ this.placementChanged = false;
1611
+ this.title = this.$el.data('title') ? this.$el.data('title') : this.opts.title;
1612
+ this.content = this.$el.data('content') ? this.$el.data('content') : this.opts.content;
1613
+ } // Bind events that trigger methods
1614
+
1615
+
1616
+ bindEvents() {
1617
+ if (this.trigger === 'click') {
1618
+ this.$el.on('click' + '.' + NAME, () => {
1619
+ if (this.$popover) {
1620
+ this.close();
1621
+ } else {
1622
+ this.show();
1623
+ }
1624
+ });
1625
+ } else if (this.trigger === 'hover') {
1626
+ this.$el.on('mouseenter' + '.' + NAME, () => {
1627
+ this.show();
1628
+ });
1629
+ this.$el.on('mouseleave' + '.' + NAME, () => {
1630
+ this.close();
1631
+ });
1632
+ } else if (this.trigger === 'focus') {
1633
+ this.$el.on('focusin' + '.' + NAME, () => {
1634
+ this.show();
1635
+ });
1636
+ this.$el.on('focusout' + '.' + NAME, () => {
1637
+ this.close();
1638
+ });
1639
+ }
1640
+
1641
+ $(window).on('resize', debounce(() => {
1642
+ if (this.$popover) {
1643
+ this.setPosition();
1644
+ this.onUpdate();
1645
+ }
1646
+ }, 250));
1647
+ } // Unbind events that trigger methods
1648
+
1649
+
1650
+ unbindEvents() {
1651
+ this.$el.off('.' + NAME);
1652
+ } // Generate UUID
1653
+
1654
+
1655
+ generateUUID() {
1656
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
1657
+ let r = Math.random() * 16 | 0,
1658
+ v = c == 'x' ? r : r & 0x3 | 0x8;
1659
+ return v.toString(16);
1660
+ });
1661
+ } // Build popover
1662
+
1663
+
1664
+ buildPopover() {
1665
+ let content;
1666
+
1667
+ if (typeof this.content === 'function') {
1668
+ content = this.content();
1669
+ } else {
1670
+ content = this.content;
1671
+ }
1672
+
1673
+ this.$popover = $("\n \t\t<div class=\"popover\" role=\"tooltip\" id=\"" + this.id + "\">\n\n\t\t\t <div class=\"arrow\"></div>\n\n\t\t\t <h3 class=\"popover-header\">" + this.title + "</h3>\n\n\t\t\t <div class=\"popover-body\">" + content + "</div>\n\n\t\t\t</div>\n \t");
1674
+ this.$container.append(this.$popover);
1675
+ this.$arrow = this.$popover.find('.arrow') ? this.$popover.find('.arrow') : false;
1676
+ this.log(this.$el);
1677
+ this.log(this.$container);
1678
+ this.log(this.$popover);
1679
+ this.log(this.$arrow);
1680
+ this.log('Id: ' + this.id);
1681
+ this.log('Trigger: ' + this.trigger);
1682
+ this.log('Placement: ' + this.placement);
1683
+ this.log('Animation: ' + this.animation);
1684
+ this.log('Animation in: ' + this.animationIn);
1685
+ this.log('Animation out: ' + this.animationOut);
1686
+ this.log('Animation speed: ' + this.animationSpeed);
1687
+ this.log('Title: ' + this.title);
1688
+ this.log('Content: ' + this.content);
1689
+ } // Set positions
1690
+
1691
+
1692
+ setPosition(placement) {
1693
+ if (typeof placement === 'undefined' || placement === null) {
1694
+ placement = this.placement;
1695
+ }
1696
+
1697
+ this.$popover.addClass('popover-' + placement);
1698
+ let containerInnerWidth = this.$container.innerWidth();
1699
+ let containerInnerHeight = this.$container.innerHeight();
1700
+ let popoverWidth = this.$popover.outerWidth(true);
1701
+ let popoverHeight = this.$popover.outerHeight(true);
1702
+ let popoverTriggerWidth = this.$el.outerWidth();
1703
+ let popoverTriggerHeight = this.$el.outerHeight();
1704
+ let popoverTriggerPosX = this.$el.position().left;
1705
+ let popoverTriggerPosY = this.$el.position().top;
1706
+ let arrowWidth = this.$arrow.outerWidth(true);
1707
+ let arrowHeight = this.$arrow.outerHeight(true);
1708
+ let arrowPos;
1709
+ let popoverPosX;
1710
+ let popoverPosY;
1711
+
1712
+ if (placement === 'top') {
1713
+ popoverPosX = Math.round(popoverTriggerPosX - (popoverWidth - popoverTriggerWidth) / 2);
1714
+ popoverPosY = Math.round(popoverTriggerPosY - popoverHeight);
1715
+ arrowPos = Math.round(popoverWidth / 2 - arrowWidth / 2);
1716
+ this.$arrow.css({
1717
+ left: arrowPos + 'px'
1718
+ });
1719
+ } else if (placement === 'right') {
1720
+ popoverPosX = Math.round(popoverTriggerPosX + popoverTriggerWidth);
1721
+ popoverPosY = Math.round(popoverTriggerPosY - (popoverHeight - popoverTriggerHeight) / 2);
1722
+ arrowPos = Math.round(popoverHeight / 2 - arrowHeight / 2);
1723
+ this.$arrow.css({
1724
+ top: arrowPos + 'px'
1725
+ });
1726
+ } else if (placement === 'bottom') {
1727
+ popoverPosX = Math.round(popoverTriggerPosX - (popoverWidth - popoverTriggerWidth) / 2);
1728
+ popoverPosY = Math.round(popoverTriggerPosY + popoverTriggerHeight);
1729
+ arrowPos = Math.round(popoverWidth / 2 - arrowWidth / 2);
1730
+ this.$arrow.css({
1731
+ left: arrowPos + 'px'
1732
+ });
1733
+ } else if (placement === 'left') {
1734
+ popoverPosX = Math.round(popoverTriggerPosX - popoverWidth);
1735
+ popoverPosY = Math.round(popoverTriggerPosY - (popoverHeight - popoverTriggerHeight) / 2);
1736
+ arrowPos = Math.round(popoverHeight / 2 - arrowHeight / 2);
1737
+ this.$arrow.css({
1738
+ top: arrowPos + 'px'
1739
+ });
1740
+ }
1741
+
1742
+ this.$popover.css({
1743
+ position: 'absolute',
1744
+ top: '0px',
1745
+ left: '0px',
1746
+ transform: 'translate3d(' + popoverPosX + 'px, ' + popoverPosY + 'px, 0px)',
1747
+ 'will-change': 'transform'
1748
+ }); // Correct placement if popover goes outside of container
1749
+
1750
+ let popoverOverflowCount = 0;
1751
+ let popoverPosition = {
1752
+ left: this.$popover.position().left,
1753
+ top: this.$popover.position().top,
1754
+ right: containerInnerWidth - (this.$popover.position().left + popoverWidth),
1755
+ bottom: containerInnerHeight - (this.$popover.position().top + popoverHeight)
1756
+ };
1757
+ let popoverOverflow = {
1758
+ left: false,
1759
+ top: false,
1760
+ right: false,
1761
+ bottom: false
1762
+ };
1763
+
1764
+ if (popoverPosition.right < 0) {
1765
+ popoverOverflow.right = true;
1766
+ popoverOverflowCount++;
1767
+ this.log('Popover overflowing from right');
1768
+ }
1769
+
1770
+ if (popoverPosition.left < 0) {
1771
+ popoverOverflow.left = true;
1772
+ popoverOverflowCount++;
1773
+ this.log('Popover overflowing from left');
1774
+ }
1775
+
1776
+ if (popoverPosition.bottom < 0) {
1777
+ popoverOverflow.bottom = true;
1778
+ popoverOverflowCount++;
1779
+ this.log('Popover overflowing from bottom');
1780
+ }
1781
+
1782
+ if (popoverPosition.top < 0) {
1783
+ popoverOverflow.top = true;
1784
+ popoverOverflowCount++;
1785
+ this.log('Popover overflowing from top');
1786
+ }
1787
+
1788
+ if (popoverOverflowCount > 0) {
1789
+ if (!this.placementChanged && popoverOverflow.left && popoverPosition.right > popoverWidth) {
1790
+ this.log('Changing popover placement to right');
1791
+ this.placementChanged = true;
1792
+ this.$popover.removeClass('popover-' + placement);
1793
+ this.$arrow.removeAttr('style');
1794
+ this.setPosition('right');
1795
+ } else if (!this.placementChanged && popoverOverflow.top && popoverPosition.top > popoverHeight) {
1796
+ this.log('Changing popover placement to bottom');
1797
+ this.placementChanged = true;
1798
+ this.$popover.removeClass('popover-' + placement);
1799
+ this.$arrow.removeAttr('style');
1800
+ this.setPosition('bottom');
1801
+ } else if (!this.placementChanged && popoverOverflow.right && popoverPosition.left > popoverWidth) {
1802
+ this.log('Changing popover placement to left');
1803
+ this.placementChanged = true;
1804
+ this.$popover.removeClass('popover-' + placement);
1805
+ this.$arrow.removeAttr('style');
1806
+ this.setPosition('left');
1807
+ } else if (!this.placementChanged && popoverOverflow.bottom && popoverPosition.top > popoverHeight) {
1808
+ this.log('Changing popover placement to top');
1809
+ this.placementChanged = true;
1810
+ this.$popover.removeClass('popover-' + placement);
1811
+ this.$arrow.removeAttr('style');
1812
+ this.setPosition('top');
1813
+ } else if (!this.placementChanged && (placement !== 'top' || placement !== 'bottom') && (popoverOverflow.left || popoverOverflow.right)) {
1814
+ if (popoverPosition.top > popoverPosition.bottom) {
1815
+ this.log('Changing popover placement to top');
1816
+ this.placementChanged = true;
1817
+ this.$popover.removeClass('popover-' + placement);
1818
+ this.$arrow.removeAttr('style');
1819
+ this.setPosition('top');
1820
+ } else {
1821
+ this.log('Changing popover placement to bottom');
1822
+ this.placementChanged = true;
1823
+ this.$popover.removeClass('popover-' + placement);
1824
+ this.$arrow.removeAttr('style');
1825
+ this.setPosition('bottom');
1826
+ }
1827
+ } else {
1828
+ this.fixPopoverPosition = true;
1829
+ }
1830
+
1831
+ if (this.fixPopoverPosition) {
1832
+ this.log('Adjusting popover size or position in order to popover fit in the container');
1833
+
1834
+ if (popoverOverflow.left) {
1835
+ this.log('Popover overflowing from left');
1836
+ let overflowAmount = Math.abs(popoverPosition.left);
1837
+ let excludePlacements = ['top', 'bottom'];
1838
+
1839
+ if (popoverTriggerPosX >= popoverPosX + overflowAmount && excludePlacements.indexOf(placement) < 0) {
1840
+ this.log('Popover adjusting width');
1841
+ popoverWidth -= overflowAmount;
1842
+ popoverPosX += overflowAmount;
1843
+ } else {
1844
+ this.log('Popover adjusting position x');
1845
+ popoverPosX += overflowAmount;
1846
+ arrowPos -= overflowAmount;
1847
+ }
1848
+ }
1849
+
1850
+ if (popoverOverflow.top) {
1851
+ this.log('Popover overflowing from top');
1852
+ let overflowAmount = Math.abs(popoverPosition.top);
1853
+ this.log('Popover adjusting position y');
1854
+ popoverPosY += overflowAmount;
1855
+ arrowPos -= overflowAmount;
1856
+ }
1857
+
1858
+ if (popoverOverflow.right) {
1859
+ this.log('Popover overflowing from right');
1860
+ let overflowAmount = Math.abs(popoverPosition.right);
1861
+ let excludePlacements = ['top', 'bottom'];
1862
+
1863
+ if (popoverTriggerPosX <= popoverPosX - overflowAmount && excludePlacements.indexOf(placement) < 0) {
1864
+ this.log('Popover adjusting width');
1865
+ popoverWidth -= overflowAmount;
1866
+ } else {
1867
+ this.log('Popover adjusting position x');
1868
+ popoverPosX -= overflowAmount;
1869
+ arrowPos += overflowAmount;
1870
+ }
1871
+ }
1872
+
1873
+ if (popoverOverflow.bottom) {
1874
+ this.log('Popover overflowing from bottom');
1875
+ let overflowAmount = Math.abs(popoverPosition.bottom);
1876
+ this.log('Popover adjusting position y');
1877
+ popoverPosY -= overflowAmount;
1878
+ arrowPos += overflowAmount;
1879
+ }
1880
+
1881
+ if (placement === 'top') {
1882
+ this.$arrow.css({
1883
+ left: arrowPos + 'px'
1884
+ });
1885
+ } else if (placement === 'right') {
1886
+ this.$arrow.css({
1887
+ top: arrowPos + 'px'
1888
+ });
1889
+ } else if (placement === 'bottom') {
1890
+ this.$arrow.css({
1891
+ left: arrowPos + 'px'
1892
+ });
1893
+ } else if (placement === 'left') {
1894
+ this.$arrow.css({
1895
+ top: arrowPos + 'px'
1896
+ });
1897
+ }
1898
+
1899
+ this.$popover.css({
1900
+ width: popoverWidth,
1901
+ transform: 'translate3d(' + popoverPosX + 'px, ' + popoverPosY + 'px, 0px)'
1902
+ });
1903
+ this.fixPopoverPosition = false;
1904
+ this.log('Popover placement changed: ' + this.placementChanged);
1905
+ this.log('Popover container inner width: ' + containerInnerWidth + 'px');
1906
+ this.log('Popover container inner height: ' + containerInnerHeight + 'px');
1907
+ this.log('Popover trigger width: ' + popoverTriggerWidth + 'px');
1908
+ this.log('Popover trigger height: ' + popoverTriggerHeight + 'px');
1909
+ this.log('popover trigger position x: ' + popoverTriggerPosX + 'px');
1910
+ this.log('Popover trigger position Y: ' + popoverTriggerPosY + 'px');
1911
+ this.log('Popover width: ' + popoverWidth + 'px');
1912
+ this.log('Popover height: ' + popoverHeight + 'px');
1913
+ this.log('Popover position x: ' + popoverPosX + 'px');
1914
+ this.log('Popover position y: ' + popoverPosY + 'px');
1915
+ this.log('Popover position left: ' + popoverPosition.left + 'px');
1916
+ this.log('Popover position top: ' + popoverPosition.top + 'px');
1917
+ this.log('Popover position right: ' + popoverPosition.right + 'px');
1918
+ this.log('Popover position bottom: ' + popoverPosition.bottom + 'px');
1919
+ }
1920
+ } else {
1921
+ this.log('Popover placement changed: ' + this.placementChanged);
1922
+ this.log('Popover container inner width: ' + containerInnerWidth + 'px');
1923
+ this.log('Popover container inner height: ' + containerInnerHeight + 'px');
1924
+ this.log('Popover trigger width: ' + popoverTriggerWidth + 'px');
1925
+ this.log('Popover trigger height: ' + popoverTriggerHeight + 'px');
1926
+ this.log('popover trigger position x: ' + popoverTriggerPosX + 'px');
1927
+ this.log('Popover trigger position Y: ' + popoverTriggerPosY + 'px');
1928
+ this.log('Popover width: ' + popoverWidth + 'px');
1929
+ this.log('Popover height: ' + popoverHeight + 'px');
1930
+ this.log('Popover position x: ' + popoverPosX + 'px');
1931
+ this.log('Popover position y: ' + popoverPosY + 'px');
1932
+ this.log('Popover position left: ' + popoverPosition.left + 'px');
1933
+ this.log('Popover position top: ' + popoverPosition.top + 'px');
1934
+ this.log('Popover position right: ' + popoverPosition.right + 'px');
1935
+ this.log('Popover position bottom: ' + popoverPosition.bottom + 'px');
1936
+ }
1937
+ } // Show
1938
+
1939
+
1940
+ show() {
1941
+ if (this.$popover) {
1942
+ return;
1943
+ }
1944
+
1945
+ this.buildPopover();
1946
+ this.setPosition();
1947
+
1948
+ if (this.animation) {
1949
+ this.$popover.addClass(this.animationSpeed);
1950
+ this.$popover.animateCss(this.animationIn);
1951
+ this.$popover.addClass('show');
1952
+ this.$popover.attr('id', this.id);
1953
+ this.$el.attr('data-popover', this.id);
1954
+ } else {
1955
+ this.$popover.addClass('show');
1956
+ this.$popover.attr('id', this.id);
1957
+ this.$el.attr('data-popover', this.id);
1958
+ }
1959
+
1960
+ this.onShow();
1961
+ } // Close
1962
+
1963
+
1964
+ close() {
1965
+ if (!this.$popover) {
1966
+ return;
1967
+ }
1968
+
1969
+ if (this.animation && !this.$popover.hasClass('animated')) {
1970
+ this.$popover.animateCss(this.animationOut, () => {
1971
+ this.$popover.remove();
1972
+ this.$el.removeAttr('data-popover');
1973
+ this.$popover = null;
1974
+ this.placementChanged = false;
1975
+ this.onClose();
1976
+ });
1977
+ } else {
1978
+ this.$popover.remove();
1979
+ this.$el.removeAttr('data-popover');
1980
+ this.$popover = null;
1981
+ this.placementChanged = false;
1982
+ this.onClose();
1983
+ }
1984
+ }
1985
+
1986
+ static _jQueryInterface(config) {
1987
+ return this.each(function () {
1988
+ let data = $(this).data(DATA_KEY);
1989
+
1990
+ const _config = typeof config === 'object' && config;
1991
+
1992
+ if (!data) {
1993
+ data = new Popover(this, _config);
1994
+ $(this).data(DATA_KEY, data);
1995
+ }
1996
+
1997
+ if (typeof config === 'string') {
1998
+ if (typeof data[config] === 'undefined') {
1999
+ throw new TypeError("No method named \"" + config + "\"");
2000
+ }
2001
+
2002
+ data[config]();
2003
+ }
2004
+ });
2005
+ }
2006
+
2007
+ }
2008
+
2009
+ if (typeof $ !== 'undefined') {
2010
+ // jQuery
2011
+ const JQUERY_NO_CONFLICT = $.fn[NAME];
2012
+ $.fn[NAME] = Popover._jQueryInterface;
2013
+ $.fn[NAME].Constructor = Popover;
2014
+
2015
+ $.fn[NAME].noConflict = () => {
2016
+ $.fn[NAME] = JQUERY_NO_CONFLICT;
2017
+ return Popover._jQueryInterface;
2018
+ };
2019
+
2020
+ $.fn[NAME].defaults = {
2021
+ container: '.content-inner',
2022
+ trigger: 'focus',
2023
+ placement: 'bottom',
2024
+ animation: true,
2025
+ animationIn: 'fadeIn',
2026
+ animationOut: 'fadeOut',
2027
+ animationSpeed: 'fastest',
2028
+ title: '',
2029
+ content: '',
2030
+ onInit: null,
2031
+ onUpdate: null,
2032
+ onDestroy: null,
2033
+ onShow: null,
2034
+ onClose: null,
2035
+ debug: false
2036
+ };
2037
+ }
2038
+
2039
+ const NAME$1 = 'coolSelect';
2040
+ const DATA_KEY$1 = 'plugin_coolSelect';
2041
+
2042
+ class Select extends AbstractUIComponent {
2043
+ constructor(el, opts) {
2044
+ super();
2045
+ this.opts = {};
2046
+
2047
+ if (window.Cool.settings.select) {
2048
+ $.extend(true, this.opts, $.fn[NAME$1].defaults, window.Cool.settings.select, opts);
2049
+ } else {
2050
+ $.extend(true, this.opts, $.fn[NAME$1].defaults, opts);
2051
+ }
2052
+
2053
+ this.el = el;
2054
+ this.debug = this.opts.debug;
2055
+ this.init();
2056
+ } // Init plugin
2057
+
2058
+
2059
+ init() {
2060
+ $.when(this.buildCache()).then(() => {
2061
+ this.buildScroll();
2062
+ this.bindEvents();
2063
+
2064
+ if (this.data[this.name].length > 0) {
2065
+ this.setData();
2066
+ }
2067
+
2068
+ this.onInit();
2069
+ });
2070
+ } // Remove plugin instance completely
2071
+
2072
+
2073
+ destroy() {
2074
+ this.unbindEvents();
2075
+ this.$el.removeData(DATA_KEY$1);
2076
+ this.onDestroy();
2077
+ } // Update plugin data
2078
+
2079
+
2080
+ update() {
2081
+ this.buildCache();
2082
+ this.bindEvents();
2083
+ this.onUpdate();
2084
+ } // Cache DOM nodes for performance
2085
+
2086
+
2087
+ buildCache() {
2088
+ this.$el = $(this.el);
2089
+ this.$selectHeader = this.$el.find('.select-header');
2090
+ this.$selectIconContainer = this.$selectHeader.find('.select-icon');
2091
+ this.name = this.$el.data('name') ? this.$el.data('name') : this.opts.name;
2092
+ this.scrollContentHeight = this.$el.data('scrollContentHeight') ? this.$el.data('scrollContentHeight') : this.opts.scrollContentHeight;
2093
+ this.items = this.$el.data('items') ? this.$el.data('items') : this.opts.items;
2094
+ this.data = {};
2095
+ this.data[this.name] = [];
2096
+ this.searchData = [];
2097
+ this.searchApi = this.$el.data('searchApi') ? this.$el.data('searchApi') : this.opts.searchApi;
2098
+ this.type = this.$el.data('type') ? this.$el.data('type') : this.opts.type;
2099
+ this.contentOpen = false;
2100
+
2101
+ if (this.$el.data('setData') && this.$el.data('setData') != '') {
2102
+ this.data = this.$el.data('setData');
2103
+ }
2104
+
2105
+ if (this.$el.find('.select-search')) {
2106
+ this.showSearch = true;
2107
+ } else {
2108
+ this.showSearch = this.$el.data('showSearch') ? this.$el.data('showSearch') : this.opts.showSearch;
2109
+ }
2110
+
2111
+ if (this.$el.find('.select-footer')) {
2112
+ this.showFooter = true;
2113
+ } else {
2114
+ this.showFooter = this.$el.data('showFooter') ? this.$el.data('showFooter') : this.opts.showFooter;
2115
+ }
2116
+
2117
+ if (this.items.length) {
2118
+ let items = this._renderItemList(this.items);
2119
+
2120
+ this.$select = $("\n <div class=\"select-content\">\n\n " + this._renderSearch() + "\n\n <div class=\"select-scrollable-content\">" + items + "</div>\n\n " + this._renderFooter() + "\n\n </div>\n ");
2121
+ this.$el.append(this.$select);
2122
+ this.$scrollableContent = this.$select.find('.select-scrollable-content') ? this.$select.find('.select-scrollable-content') : false;
2123
+ this.$selectItems = this.$select.find('.select-item');
2124
+ this.$selectLabels = this.$select.find('[data-label]');
2125
+
2126
+ if (this.showSearch) {
2127
+ this.$searchContainer = this.$select.find('.select-search');
2128
+ this.$searchInput = this.$select.find('[name="select-search"]');
2129
+ this.$searchIconContainer = this.$select.find('.select-search-icon');
2130
+ this.$clearSearchButton = this.$select.find('[data-clear-search]');
2131
+ }
2132
+
2133
+ if (this.showFooter) {
2134
+ this.$footerContainer = this.$select.find('.select-footer');
2135
+ this.$closeButton = this.$select.find('[data-select-close]');
2136
+ }
2137
+
2138
+ $.each(this.$selectLabels, function (i, el) {
2139
+ this.searchData.push({
2140
+ id: i,
2141
+ val: $(el).text().trim()
2142
+ });
2143
+ });
2144
+ this.log(this.$el);
2145
+ this.log(this.$select);
2146
+ this.log(this.$scrollableContent);
2147
+ this.log('Name: ' + this.name);
2148
+ this.log('Show search: ' + this.showSearch);
2149
+ this.log('Show footer: ' + this.showFooter);
2150
+ this.log('Scroll content height: ' + this.scrollContentHeight + 'px');
2151
+ this.log(this.items);
2152
+ this.log(this.searchData);
2153
+ } else {
2154
+ this.$select = this.$el.find('.select-content');
2155
+ this.$scrollableContent = this.$select.find('.select-scrollable-content');
2156
+ this.$selectItems = this.$select.find('.select-item');
2157
+ this.$selectLabels = this.$select.find('[data-label]');
2158
+
2159
+ if (this.showSearch) {
2160
+ this.$searchContainer = this.$select.find('.select-search');
2161
+ this.$searchInput = this.$select.find('[name="select-search"]');
2162
+ this.$searchIconContainer = this.$select.find('.select-search-icon');
2163
+ this.$clearSearchButton = this.$select.find('[data-clear-search]');
2164
+ }
2165
+
2166
+ if (this.showFooter) {
2167
+ this.$footerContainer = this.$select.find('.select-footer');
2168
+ this.$closeButton = this.$select.find('[data-select-close]');
2169
+ }
2170
+
2171
+ $.each(this.$selectLabels, (i, el) => {
2172
+ this.searchData.push({
2173
+ id: i,
2174
+ val: $(el).text().trim()
2175
+ });
2176
+ });
2177
+ this.log(this.$el);
2178
+ this.log(this.$select);
2179
+ this.log(this.$scrollableContent);
2180
+ this.log('Name: ' + this.name);
2181
+ this.log('Show search: ' + this.showSearch);
2182
+ this.log('Show footer: ' + this.showFooter);
2183
+ this.log('Scroll content height: ' + this.scrollContentHeight + 'px');
2184
+ this.log(this.items);
2185
+ this.log(this.searchData);
2186
+ return true;
2187
+ }
2188
+ } // Build scroll
2189
+
2190
+
2191
+ buildScroll() {
2192
+ if (this.$scrollableContent.length > 0) {
2193
+ let scrollContentHeight = this.scrollContentHeight;
2194
+
2195
+ if (this.showSearch) {
2196
+ scrollContentHeight = scrollContentHeight - (this.$searchContainer.outerHeight(true) || 0);
2197
+ }
2198
+
2199
+ if (this.showFooter) {
2200
+ scrollContentHeight = scrollContentHeight - (this.$footerContainer.outerHeight(true) || 0);
2201
+ }
2202
+
2203
+ this.$scrollableContent.css({
2204
+ 'max-height': scrollContentHeight - parseInt(this.$scrollableContent.css('marginTop'), 10) - parseInt(this.$scrollableContent.css('marginBottom'), 10) + 'px'
2205
+ });
2206
+
2207
+ if (touchEvents()) {
2208
+ this.$scrollableContent.css({
2209
+ 'overflow-y': 'auto'
2210
+ });
2211
+ } else {
2212
+ this.$scrollableContent.addClass('ps-dark');
2213
+ this.scroll = new PerfectScrollbar(this.$scrollableContent[0], {
2214
+ wheelSpeed: 1,
2215
+ wheelPropagation: false,
2216
+ minScrollbarLength: 20,
2217
+ scrollYMarginOffset: -1,
2218
+ suppressScrollY: true,
2219
+ suppressScrollX: true
2220
+ });
2221
+
2222
+ if (this.$scrollableContent[0].offsetHeight < this.$scrollableContent[0].scrollHeight) {
2223
+ this.$scrollableContent.addClass('ps-show-rail-y');
2224
+ this.scroll.settings.suppressScrollY = false;
2225
+ }
2226
+ }
2227
+ }
2228
+ } // Bind events that trigger methods
2229
+
2230
+
2231
+ bindEvents() {
2232
+ let self = this;
2233
+ this.$selectHeader.on('click' + '.' + NAME$1, () => {
2234
+ if (this.contentOpen) {
2235
+ this.close();
2236
+ } else {
2237
+ this.show();
2238
+ }
2239
+ });
2240
+ this.$el.on('change' + '.' + NAME$1, 'input[type="checkbox"]', function () {
2241
+ let val = $(this).val();
2242
+
2243
+ if (this.checked) {
2244
+ self.data[self.name].indexOf(val) === -1 ? self.data[self.name].push(val) : false;
2245
+ } else {
2246
+ self.data[self.name] = self.data[self.name].filter(n => n != val);
2247
+ }
2248
+
2249
+ self.onSelect(this);
2250
+ });
2251
+ this.$el.on('change' + '.' + NAME$1, 'input[type="radio"]', function () {
2252
+ let val = $(this).val();
2253
+
2254
+ if (this.checked) {
2255
+ self.data[self.name] = val;
2256
+ self.$select.find('input[type="radio"]').not($(this)).prop('checked', false);
2257
+ self.$select.find('input[type="radio"]').not($(this)).removeClass('checked');
2258
+ } else {
2259
+ self.data[self.name] = [];
2260
+ }
2261
+ });
2262
+ this.$el.on('click' + '.' + NAME$1, 'input[type="radio"]', function () {
2263
+ if ($(this).hasClass('checked')) {
2264
+ self.data[plugin.name] = [];
2265
+ $(this).prop('checked', false);
2266
+ $(this).removeClass('checked');
2267
+ } else {
2268
+ $(this).addClass('checked');
2269
+ }
2270
+
2271
+ self.onSelect(this);
2272
+ });
2273
+
2274
+ if (this.scroll) {
2275
+ this.$scrollableContent.find('.ps__thumb-y').mousedown(function () {
2276
+ self.$scrollableContent.addClass('ps-mousedown-scroll');
2277
+ });
2278
+ $(document).mouseup(function () {
2279
+ if (self.$scrollableContent.hasClass('ps-mousedown-scroll')) {
2280
+ self.$scrollableContent.removeClass('ps-mousedown-scroll');
2281
+ }
2282
+ });
2283
+ }
2284
+
2285
+ if (this.showSearch) {
2286
+ this.$searchInput.on('keydown' + '.' + NAME$1, debounce(function () {
2287
+ self.searchString = $(this).val().trim();
2288
+ self.search.call(self);
2289
+ }, 250));
2290
+ this.$searchInput.on('focusin' + '.' + NAME$1, function () {
2291
+ self.$searchContainer.addClass('focused');
2292
+ });
2293
+ this.$searchInput.on('focusout' + '.' + NAME$1, function () {
2294
+ self.$searchContainer.removeClass('focused');
2295
+ });
2296
+ this.$clearSearchButton.on('click' + '.' + NAME$1, function () {
2297
+ if (self.searchString.length) {
2298
+ self.$searchInput.val('');
2299
+ self.searchString = '';
2300
+ self.search.call(self);
2301
+ } else {
2302
+ return;
2303
+ }
2304
+ });
2305
+ }
2306
+
2307
+ if (this.showFooter) {
2308
+ this.$closeButton.on('click' + '.' + NAME$1, () => {
2309
+ this.close();
2310
+ });
2311
+ }
2312
+
2313
+ $(document).on('touchstart click', function (e) {
2314
+ if (!self.$el.is(e.target) && self.$el.has(e.target).length === 0 && self.contentOpen) {
2315
+ self.close.call(self);
2316
+ }
2317
+ });
2318
+ } // Unbind events that trigger methods
2319
+
2320
+
2321
+ unbindEvents() {
2322
+ this.$el.off('.' + NAME$1);
2323
+ } // Get data
2324
+
2325
+
2326
+ getData(data) {
2327
+ if (data) {
2328
+ return this.data[data];
2329
+ } else {
2330
+ return this.data;
2331
+ }
2332
+ } // Set data
2333
+
2334
+
2335
+ setData() {
2336
+ let self = this;
2337
+ let type = null;
2338
+ let faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2339
+ this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-check text-green icon\"></i>");
2340
+
2341
+ if (this.searchApi.length) {
2342
+ let searchUrl = this.searchApi;
2343
+ let itemCount = this.data[this.name].length;
2344
+ let currentCount = 0;
2345
+ this.data[this.name].forEach(function (value) {
2346
+ searchUrl += encodeURIComponent('#' + value);
2347
+ currentCount++;
2348
+
2349
+ if (currentCount !== itemCount) {
2350
+ searchUrl += '+';
2351
+ }
2352
+ });
2353
+ $.ajax({
2354
+ method: 'GET',
2355
+ url: searchUrl
2356
+ }).done(function (data) {
2357
+ let items = data.map(function (item) {
2358
+ if (item.name) {
2359
+ let label = item.name;
2360
+ } else if (item.label) {
2361
+ let label = item.label;
2362
+ } else if (item.value) {
2363
+ let label = item.value;
2364
+ }
2365
+
2366
+ return {
2367
+ id: item.id.toString(),
2368
+ label: label
2369
+ };
2370
+ });
2371
+ items = items.filter(function (item) {
2372
+ return self.data[self.name].indexOf(item.id) > -1;
2373
+ });
2374
+ let result = $(self._renderItemList(items));
2375
+ $.when(self.$scrollableContent.append(result)).then(function () {
2376
+ if (self.$scrollableContent[0].offsetHeight < self.$scrollableContent[0].scrollHeight) {
2377
+ self.scroll.update();
2378
+ self.scroll.settings.suppressScrollY = false;
2379
+ self.$scrollableContent.addClass('ps-show-rail-y');
2380
+ } else {
2381
+ self.scroll.update();
2382
+ self.scroll.settings.suppressScrollY = true;
2383
+ self.$scrollableContent.removeClass('ps-show-rail-y');
2384
+ }
2385
+
2386
+ if (self.$select.find(':input[type="checkbox"]').length) {
2387
+ type = 'checkbox';
2388
+ } else if (self.$select.find(':input[type="radio"]').length) {
2389
+ type = 'radio';
2390
+ }
2391
+
2392
+ if (type == 'checkbox') {
2393
+ self.data[self.name].forEach(function (value) {
2394
+ let $input = self.$select.find(':input').filter(function () {
2395
+ return this.value == value;
2396
+ });
2397
+ $input.prop('checked', true);
2398
+ self.onSelect($input[0]);
2399
+ });
2400
+ } else if (type == 'radio') {
2401
+ let $input = self.$select.find(':input').filter(function () {
2402
+ return this.value == self.data[self.name];
2403
+ });
2404
+ $input.prop('checked', true);
2405
+ $input.addClass('checked');
2406
+ self.onSelect($input[0]);
2407
+ }
2408
+ });
2409
+ });
2410
+ } else {
2411
+ if (this.$select.find(':input[type="checkbox"]').length) {
2412
+ type = 'checkbox';
2413
+ } else if (this.$select.find(':input[type="radio"]').length) {
2414
+ type = 'radio';
2415
+ }
2416
+
2417
+ if (type == 'checkbox') {
2418
+ this.data[this.name].forEach(function (value) {
2419
+ let $input = self.$select.find(':input').filter(function () {
2420
+ return this.value == value;
2421
+ });
2422
+ $input.prop('checked', true);
2423
+ self.onSelect($input[0]);
2424
+ });
2425
+ } else if (type == 'radio') {
2426
+ let $input = this.$select.find(':input').filter(function () {
2427
+ return this.value == self.data[self.name];
2428
+ });
2429
+ $input.prop('checked', true);
2430
+ $input.addClass('checked');
2431
+ this.onSelect($input[0]);
2432
+ }
2433
+ }
2434
+ } // Search
2435
+
2436
+
2437
+ search() {
2438
+ let self = this;
2439
+ let faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2440
+
2441
+ if (this.searchString.length) {
2442
+ if (this.searchApi.length) {
2443
+ this.$scrollableContent.find('input:not(:checked)').parents('.select-item').not('.static-item').remove();
2444
+ $.ajax({
2445
+ method: 'GET',
2446
+ url: this.searchApi + this.searchString
2447
+ }).done(function (data) {
2448
+ let items = data.map(function (item) {
2449
+ return {
2450
+ id: item.id.toString(),
2451
+ label: item.name || item.label || item.value || null
2452
+ };
2453
+ });
2454
+ items = items.filter(function (item) {
2455
+ return !(self.data[self.name].indexOf(item.id) > -1);
2456
+ }); // Remove 0 id from results
2457
+
2458
+ items = items.filter(function (item) {
2459
+ return [0].indexOf(item.id) > -1;
2460
+ });
2461
+ let result = $(self._renderItemList(items));
2462
+ $.when(self.$scrollableContent.append(result)).then(function () {
2463
+ let faNameSpace = self.opts.faPro ? 'fal' : 'fas';
2464
+ self.$searchIconContainer.html("<i class=\"" + faNameSpace + " fa-times icon\"></i>");
2465
+ self.$searchIconContainer.attr('data-clear-search', 'true');
2466
+
2467
+ if (self.$scrollableContent[0].offsetHeight < self.$scrollableContent[0].scrollHeight) {
2468
+ self.scroll.update();
2469
+ self.scroll.settings.suppressScrollY = false;
2470
+ self.$scrollableContent.addClass('ps-show-rail-y');
2471
+ } else {
2472
+ self.scroll.update();
2473
+ self.scroll.settings.suppressScrollY = true;
2474
+ self.$scrollableContent.removeClass('ps-show-rail-y');
2475
+ }
2476
+ });
2477
+ });
2478
+ } else {
2479
+ let results = this.searchData.filter(function (item) {
2480
+ return item.val.toLocaleLowerCase().indexOf(self.searchString.toLocaleLowerCase()) > -1;
2481
+ });
2482
+ this.$selectItems.removeClass('d-none');
2483
+ this.$selectItems.removeClass('visible');
2484
+ results.forEach(function (item) {
2485
+ $(self.$selectItems[item.id]).addClass('visible');
2486
+ });
2487
+ this.$selectItems.not('.visible').addClass('d-none');
2488
+ this.$searchIconContainer.html("<i class=\"" + faNameSpace + " fa-times icon\"></i>");
2489
+ this.$searchIconContainer.attr('data-clear-search', 'true');
2490
+ }
2491
+ } else {
2492
+ if (this.searchApi.length) {
2493
+ this.$scrollableContent.find('input:not(:checked)').parents('.select-item').not('.static-item').remove();
2494
+ this.$searchIconContainer.html("<i class=\"" + faNameSpace + " fa-search icon\"></i>");
2495
+ this.$searchIconContainer.attr('data-clear-search', '');
2496
+ } else {
2497
+ this.$selectItems.removeClass('d-none');
2498
+ this.$selectItems.removeClass('visible');
2499
+ this.$searchIconContainer.html("<i class=\"" + faNameSpace + " fa-search icon\"></i>");
2500
+ this.$searchIconContainer.attr('data-clear-search', '');
2501
+ }
2502
+ }
2503
+
2504
+ if (this.scroll) {
2505
+ this.scroll.update();
2506
+ }
2507
+
2508
+ this.onUpdate();
2509
+ } // Show
2510
+
2511
+
2512
+ show() {
2513
+ if (this.$el.hasClass('show')) {
2514
+ return;
2515
+ }
2516
+
2517
+ let $otherSelects = $('.select.show');
2518
+ let zindex = 1;
2519
+ let faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2520
+
2521
+ if ($otherSelects.length) {
2522
+ zindex = parseInt($otherSelects.first().css('z-index'), 10) + 2;
2523
+ }
2524
+
2525
+ this.$el.css({
2526
+ 'max-height': this.scrollContentHeight + this.$selectHeader.outerHeight(true) + 'px'
2527
+ });
2528
+ this.$el.addClass('show');
2529
+
2530
+ if (!$otherSelects.length) {
2531
+ zindex = parseInt(this.$el.css('z-index'), 10) + 1;
2532
+ }
2533
+
2534
+ this.$el.css({
2535
+ 'z-index': zindex
2536
+ });
2537
+
2538
+ if (this.scroll && this.$scrollableContent.length) {
2539
+ if (this.$scrollableContent[0].offsetHeight < this.$scrollableContent[0].scrollHeight) {
2540
+ this.$scrollableContent[0].scrollTop = 1;
2541
+ this.$scrollableContent[0].scrollTop = 0;
2542
+ }
2543
+ }
2544
+
2545
+ this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-angle-up icon\"></i>");
2546
+ this.contentOpen = true;
2547
+ this.onShow();
2548
+ } // Close
2549
+
2550
+
2551
+ close() {
2552
+ let self = this;
2553
+ let faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2554
+ this.$el.css('max-height', '');
2555
+ this.$el.removeClass('show');
2556
+ setTimeout(() => {
2557
+ self.$el.removeAttr('style');
2558
+ }, 300);
2559
+
2560
+ if (this.data[this.name].length > 0) {
2561
+ this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-check text-green icon\"></i>");
2562
+ } else {
2563
+ this.$selectIconContainer.html("<i class=\"" + faNameSpace + " fa-angle-down icon\"></i>");
2564
+ }
2565
+
2566
+ this.contentOpen = false;
2567
+ this.onClose();
2568
+ }
2569
+
2570
+ onSelect(el) {
2571
+ let onSelect = this.opts.onSelect;
2572
+
2573
+ if (typeof onSelect === 'function') {
2574
+ onSelect.call(el);
2575
+ }
2576
+ }
2577
+
2578
+ _renderItemList(items) {
2579
+ let html = '';
2580
+
2581
+ for (let i = 0; i < items.length; ++i) {
2582
+ html += "\n\n <div class=\"select-item\">\n\n <div class=\"select-item-" + this.type + "\">\n\n <div class=\"styled-" + this.type + "\">\">\n\n <input type=\"" + this.type + "\">\" id=\"select-" + this.name + "-" + items[i].id + "\" value=\"" + items[i].id + "\">\n\n <label for=\"select-" + this.name + "-" + items[i].id + "\">\n\n <span class=\"radio-inner\">\n <svg viewBox=\"0 0 18 18\">\n <polyline points=\"1.5 6 4.5 9 10.5 1\"></polyline>\n </svg>\n </span>\n\n <span class=\"" + this.type + "\">-label\" data-label>\n " + items[i].label + "\n </span>\n\n </label>\n\n </div>\n\n </div>\n\n </div>\n\n ";
2583
+ }
2584
+ }
2585
+
2586
+ _renderSearch() {
2587
+ if (!this.showSearch) {
2588
+ return '';
2589
+ }
2590
+
2591
+ let faNameSpace = this.opts.faPro ? 'fal' : 'fas';
2592
+ return "\n\n <div class=\"select-search\">\n\n <div class=\"select-search-input\">\n\n <input type=\"text\" name=\"select-search\" value=\"\" placeholder=\"" + this.opts.searchPlaceholder + "\">\n\n </div>\n\n <div class=\"select-search-icon\">\n\n <i class=\"" + faNameSpace + " fa-search icon\"></i>\n\n </div>\n\n </div>\n\n ";
2593
+ }
2594
+
2595
+ _renderFooter() {
2596
+ if (!this.showFooter) {
2597
+ return '';
2598
+ }
2599
+
2600
+ return "\n\n <div class=\"select-footer\">\n\n <button class=\"btn btn-primary\" type=\"button\" data-select-close>\n " + this.opts.btnCloseText + "\n </button>\n\n </div>\n\n ";
2601
+ }
2602
+
2603
+ static _jQueryInterface(config) {
2604
+ return this.each(function () {
2605
+ let data = $(this).data(DATA_KEY$1);
2606
+
2607
+ const _config = typeof config === 'object' && config;
2608
+
2609
+ if (!data) {
2610
+ data = new Select(this, _config);
2611
+ $(this).data(DATA_KEY$1, data);
2612
+ }
2613
+
2614
+ if (typeof config === 'string') {
2615
+ if (typeof data[config] === 'undefined') {
2616
+ throw new TypeError("No method named \"" + config + "\"");
2617
+ }
2618
+
2619
+ data[config]();
2620
+ }
2621
+ });
2622
+ }
2623
+
2624
+ }
2625
+
2626
+ if (typeof $ !== 'undefined') {
2627
+ // jQuery
2628
+ const JQUERY_NO_CONFLICT = $.fn[NAME$1];
2629
+ $.fn[NAME$1] = Select._jQueryInterface;
2630
+ $.fn[NAME$1].Constructor = Select;
2631
+
2632
+ $.fn[NAME$1].noConflict = () => {
2633
+ $.fn[NAME$1] = JQUERY_NO_CONFLICT;
2634
+ return Select._jQueryInterface;
2635
+ };
2636
+
2637
+ $.fn[NAME$1].defaults = {
2638
+ name: '',
2639
+ type: 'checkbox',
2640
+ scrollContentHeight: 100,
2641
+ faPro: false,
2642
+ items: [],
2643
+ showSearch: false,
2644
+ showFooter: false,
2645
+ searchApi: false,
2646
+ onInit: null,
2647
+ onUpdate: null,
2648
+ onDestroy: null,
2649
+ onShow: null,
2650
+ onClose: null,
2651
+ onSearch: null,
2652
+ onSelect: null,
2653
+ buildScroll: null,
2654
+ searchPlaceholder: null,
2655
+ btnCloseText: null,
2656
+ debug: false
2657
+ };
2658
+ }
2659
+
2660
+ const NAME$2 = 'coolDropdown';
2661
+ const DATA_KEY$2 = 'plugin_coolDropdown';
2662
+
2663
+ class Dropdown extends AbstractUIComponent {
2664
+ constructor(el, opts) {
2665
+ super();
2666
+ this.opts = {};
2667
+
2668
+ if (window.Cool.settings.dropdown) {
2669
+ $.extend(true, this.opts, $.fn[NAME$2].defaults, window.Cool.settings.dropdown, opts);
2670
+ } else {
2671
+ $.extend(true, this.opts, $.fn[NAME$2].defaults, opts);
2672
+ }
2673
+
2674
+ this.el = el;
2675
+ this.debug = this.opts.debug;
2676
+ this.init();
2677
+ } // Init plugin
2678
+
2679
+
2680
+ init() {
2681
+ $.when(this.buildCache()).then(() => {
2682
+ this.buildScroll();
2683
+ this.bindEvents();
2684
+ this.onInit();
2685
+ });
2686
+ } // Remove plugin instance completely
2687
+
2688
+
2689
+ destroy() {
2690
+ this.unbindEvents();
2691
+ this.$el.removeData(DATA_KEY$2);
2692
+ this.onDestroy();
2693
+ } // Update plugin data
2694
+
2695
+
2696
+ update() {
2697
+ this.buildCache();
2698
+ this.onUpdate();
2699
+ } // Cache DOM nodes for performance
2700
+
2701
+
2702
+ buildCache() {
2703
+ this.$el = $(this.el);
2704
+ this.$el.addClass('dropdown-trigger');
2705
+ this.$container = this.$el.parent('.dropdown');
2706
+ this.id = 'dropdown-' + this.generateUUID();
2707
+ this.animation = this.$el.data('animation') ? this.$el.data('animation') : this.opts.animation;
2708
+ this.animationIn = this.$el.data('animationIn') ? this.$el.data('animationIn') : this.opts.animationIn;
2709
+ this.animationOut = this.$el.data('animationOut') ? this.$el.data('animationOut') : this.opts.animationOut;
2710
+ this.animationSpeed = this.$el.data('animationSpeed') ? this.$el.data('animationSpeed') : this.opts.animationSpeed;
2711
+ this.offset = this.$el.data('offset') ? this.$el.data('offset') : this.opts.offset;
2712
+ this.minWidth = this.$el.data('minWidth') ? this.$el.data('minWidth') : this.opts.minWidth;
2713
+ this.scroll = this.$el.data('scroll') ? this.$el.data('scroll') : this.opts.scroll;
2714
+ this.scrollContentHeight = this.$el.data('scrollContentHeight') ? this.$el.data('scrollContentHeight') : this.opts.scrollContentHeight;
2715
+ this.closeOnItemClick = this.$el.data('closeOnItemClick') ? this.$el.data('closeOnItemClick') : this.opts.closeOnItemClick;
2716
+ this.content = this.$el.data('content') ? this.$el.data('content') : this.opts.content;
2717
+ this.contentOpen = false;
2718
+
2719
+ if (this.$container.hasClass('dropup')) {
2720
+ this.placement = 'top';
2721
+ } else if (this.$container.hasClass('dropright')) {
2722
+ this.placement = 'right';
2723
+ } else if (this.$container.hasClass('dropbottom')) {
2724
+ this.placement = 'bottom';
2725
+ } else {
2726
+ this.placement = 'left';
2727
+ }
2728
+
2729
+ if (typeof this.content === 'function') {
2730
+ let menuRight = this.opts.align === 'end' ? ' dropdown-menu-right' : '';
2731
+ this.$dropdown = $("\n <div class=\"dropdown-menu" + menuRight + "\" id=\"" + this.id + "\">\n " + this.content + "\n </div>\n ");
2732
+ $.when(this.$el.after(this.$dropdown)).then(() => {
2733
+ this.$scrollableContent = this.$dropdown.find('.dropdown-scrollable-content') ? this.$dropdown.find('.dropdown-scrollable-content') : false;
2734
+ this.$dropdown.hasClass('dropdown-menu-right') ? this.align = 'end' : this.align = 'start';
2735
+ this.$dropdownItem = this.$dropdown.find('.dropdown-item');
2736
+
2737
+ if (this.minWidth) {
2738
+ this.$dropdown.css('min-width', this.minWidth + 'px');
2739
+ }
2740
+
2741
+ this.log(this.$el);
2742
+ this.log(this.$container);
2743
+ this.log(this.$dropdown);
2744
+ this.log(this.$scrollableContent);
2745
+ this.log('Id: ' + this.id);
2746
+ this.log('Animation: ' + this.animation);
2747
+ this.log('Animation in: ' + this.animationIn);
2748
+ this.log('Animation out: ' + this.animationOut);
2749
+ this.log('Animation speed: ' + this.animationSpeed);
2750
+ this.log('Offset: ' + this.offset);
2751
+ this.log('Min width: ' + this.minWidth);
2752
+ this.log('Content: ' + this.content);
2753
+ this.log('Scroll: ' + this.scroll);
2754
+ this.log('Scroll content height: ' + this.scrollContentHeight + 'px');
2755
+ return true;
2756
+ });
2757
+ } else {
2758
+ this.$dropdown = this.$el.next('.dropdown-menu') ? this.$el.next('.dropdown-menu') : false;
2759
+ this.$dropdown.hasClass('dropdown-menu-right') ? this.align = 'end' : this.align = 'start';
2760
+ this.$scrollableContent = this.$dropdown.find('.dropdown-scrollable-content') ? this.$dropdown.find('.dropdown-scrollable-content') : false;
2761
+ this.$dropdownItem = this.$dropdown.find('.dropdown-item');
2762
+
2763
+ if (this.minWidth) {
2764
+ this.$dropdown.css('min-width', this.minWidth + 'px');
2765
+ }
2766
+
2767
+ this.log(this.$el);
2768
+ this.log(this.$container);
2769
+ this.log(this.$dropdown);
2770
+ this.log(this.$scrollableContent);
2771
+ this.log('Id: ' + this.id);
2772
+ this.log('Animation: ' + this.animation);
2773
+ this.log('Animation in: ' + this.animationIn);
2774
+ this.log('Animation out: ' + this.animationOut);
2775
+ this.log('Animation speed: ' + this.animationSpeed);
2776
+ this.log('Offset: ' + this.offset);
2777
+ this.log('Min width: ' + this.minWidth);
2778
+ this.log('Content: ' + this.opts.content);
2779
+ this.log('Scroll: ' + this.scroll);
2780
+ this.log('Scroll content height: ' + this.scrollContentHeight + 'px');
2781
+ return true;
2782
+ }
2783
+ } // Build scroll
2784
+
2785
+
2786
+ buildScroll() {
2787
+ if (this.opts.scroll && this.$scrollableContent.length) {
2788
+ this.$scrollableContent.css({
2789
+ 'max-height': this.scrollContentHeight + 'px'
2790
+ });
2791
+
2792
+ if (touchEvents()) {
2793
+ this.$scrollableContent.css({
2794
+ 'overflow-y': 'auto'
2795
+ });
2796
+ } else {
2797
+ this.$scrollableContent.css({
2798
+ 'overflow-y': 'auto'
2799
+ });
2800
+ this.scroll = new PerfectScrollbar(this.$scrollableContent[0], {
2801
+ wheelSpeed: 1,
2802
+ wheelPropagation: false,
2803
+ minScrollbarLength: 20
2804
+ });
2805
+ this.$scrollableContent.addClass('ps-show-rail-y');
2806
+ }
2807
+ }
2808
+ } // Bind events that trigger methods
2809
+
2810
+
2811
+ bindEvents() {
2812
+ let self = this;
2813
+ this.$el.on('click' + '.' + NAME$2, () => {
2814
+ if (this.contentOpen) {
2815
+ this.close();
2816
+ } else {
2817
+ this.show();
2818
+ }
2819
+ });
2820
+ this.$dropdownItem.on('click' + '.' + NAME$2, function () {
2821
+ if (self.closeOnItemClick) {
2822
+ self.close();
2823
+ }
2824
+
2825
+ self.onItemClick(this);
2826
+ });
2827
+ $(document).on('touchstart click', e => {
2828
+ if (!this.$el.is(e.target) && !this.$dropdown.is(e.target) && this.$dropdown.has(e.target).length === 0 && this.contentOpen) {
2829
+ this.close();
2830
+ }
2831
+ });
2832
+ $(window).on('resize', debounce(() => {
2833
+ this.setPosition();
2834
+ this.onUpdate();
2835
+ }, 250));
2836
+ } // Unbind events that trigger methods
2837
+
2838
+
2839
+ unbindEvents() {
2840
+ this.$el.off('.' + NAME$2);
2841
+ } // Generate UUID
2842
+
2843
+
2844
+ generateUUID() {
2845
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
2846
+ let r = Math.random() * 16 | 0,
2847
+ v = c == 'x' ? r : r & 0x3 | 0x8;
2848
+ return v.toString(16);
2849
+ });
2850
+ } // Set positions
2851
+
2852
+
2853
+ setPosition(placement) {
2854
+ if (typeof str === 'undefined' || str === null) {
2855
+ placement = this.placement;
2856
+ }
2857
+
2858
+ let dropdownWidth = this.$dropdown.outerWidth(true);
2859
+ let dropdownHeight = this.$dropdown.outerHeight(true);
2860
+ let dropdownTriggerWidth = this.$el.outerWidth(true);
2861
+ let dropdownTriggerHeight = this.$el.outerHeight(true);
2862
+ let dropdownTriggerPosX = this.$el.position().left;
2863
+ let dropdownTriggerPosY = this.$el.position().top;
2864
+ let dropdownPosX;
2865
+ let dropdownPosY;
2866
+
2867
+ if (placement === 'top') {
2868
+ if (this.align === 'end') {
2869
+ dropdownPosX = dropdownTriggerWidth - dropdownWidth;
2870
+ } else {
2871
+ dropdownPosX = dropdownTriggerPosX;
2872
+ }
2873
+
2874
+ dropdownPosY = dropdownTriggerPosY - dropdownHeight;
2875
+ } else if (placement === 'right') {
2876
+ dropdownPosX = dropdownTriggerPosX + dropdownTriggerWidth;
2877
+ dropdownPosY = dropdownTriggerPosY;
2878
+ } else if (placement === 'bottom') {
2879
+ if (this.align === 'end') {
2880
+ dropdownPosX = dropdownTriggerWidth - dropdownWidth;
2881
+ } else {
2882
+ dropdownPosX = dropdownTriggerPosX;
2883
+ }
2884
+
2885
+ dropdownPosY = dropdownTriggerPosY + dropdownTriggerHeight;
2886
+ } else if (placement === 'left') {
2887
+ dropdownPosX = dropdownTriggerPosX - dropdownWidth;
2888
+ dropdownPosY = dropdownTriggerPosY;
2889
+ }
2890
+
2891
+ if (this.offset) {
2892
+ let offsets = this.offset.split(',');
2893
+ let offsetX = offsets[0];
2894
+ let offsetY = offsets[1];
2895
+ dropdownPosX += parseInt(offsetX, 10);
2896
+ dropdownPosY += parseInt(offsetY, 10);
2897
+ }
2898
+
2899
+ this.$dropdown.css({
2900
+ position: 'absolute',
2901
+ top: '0px',
2902
+ left: '0px',
2903
+ transform: 'translate3d(' + Math.round(dropdownPosX) + 'px, ' + Math.round(dropdownPosY) + 'px, 0px)',
2904
+ 'will-change': 'transform'
2905
+ });
2906
+ this.log('Dropdown trigger width: ' + dropdownTriggerWidth + 'px');
2907
+ this.log('Dropdown trigger height: ' + dropdownTriggerHeight + 'px');
2908
+ this.log('Dropdown trigger position x: ' + dropdownTriggerPosX + 'px');
2909
+ this.log('Dropdown trigger position Y: ' + dropdownTriggerPosY + 'px');
2910
+ this.log('Dropdown width: ' + dropdownWidth + 'px');
2911
+ this.log('Dropdown height: ' + dropdownHeight + 'px');
2912
+ this.log('Dropdown position x: ' + dropdownPosX + 'px');
2913
+ this.log('Dropdown position y: ' + dropdownPosY + 'px');
2914
+ } // Show
2915
+
2916
+
2917
+ show() {
2918
+ if (!this.$dropdown || this.$dropdown.hasClass('show')) {
2919
+ return;
2920
+ }
2921
+
2922
+ this.setPosition();
2923
+
2924
+ if (this.animation) {
2925
+ this.$dropdown.attr('x-placement', this.placement + '-' + this.align);
2926
+ this.$dropdown.addClass(this.animationSpeed);
2927
+ this.$dropdown.animateCss(this.animationIn);
2928
+ this.$dropdown.addClass('show');
2929
+ this.$dropdown.attr('id', this.id);
2930
+ this.$el.attr('data-dropdown', this.id);
2931
+ } else {
2932
+ this.$dropdown.attr('x-placement', this.placement + '-' + this.align);
2933
+ this.$dropdown.addClass('show');
2934
+ this.$dropdown.attr('id', this.id);
2935
+ this.$el.attr('data-dropdown', this.id);
2936
+ }
2937
+
2938
+ if (this.opts.scroll && this.scroll && this.$scrollableContent.length) {
2939
+ this.$scrollableContent[0].scrollTop = 1;
2940
+ this.$scrollableContent[0].scrollTop = 0;
2941
+ }
2942
+
2943
+ this.contentOpen = true;
2944
+ this.onShow();
2945
+ } // Close
2946
+
2947
+
2948
+ close() {
2949
+ if (!this.$dropdown) {
2950
+ return;
2951
+ }
2952
+
2953
+ if (this.animation && !this.$dropdown.hasClass('animated')) {
2954
+ this.$dropdown.animateCss(this.animationOut, () => {
2955
+ this.$dropdown.removeClass('show');
2956
+ this.$el.removeAttr('data-dropdown');
2957
+ });
2958
+ } else {
2959
+ this.$dropdown.removeClass('show');
2960
+ this.$el.removeAttr('data-dropdown');
2961
+ }
2962
+
2963
+ this.contentOpen = false;
2964
+ this.onClose();
2965
+ } // Item callback
2966
+
2967
+
2968
+ onItemClick(el) {
2969
+ let onItemClick = this.opts.onItemClick;
2970
+
2971
+ if (typeof onItemClick === 'function') {
2972
+ onItemClick.call(el);
2973
+ }
2974
+ }
2975
+
2976
+ static _jQueryInterface(config) {
2977
+ return this.each(function () {
2978
+ let data = $(this).data(DATA_KEY$2);
2979
+
2980
+ const _config = typeof config === 'object' && config;
2981
+
2982
+ if (!data) {
2983
+ data = new Dropdown(this, _config);
2984
+ $(this).data(DATA_KEY$2, data);
2985
+ }
2986
+
2987
+ if (typeof config === 'string') {
2988
+ if (typeof data[config] === 'undefined') {
2989
+ throw new TypeError("No method named \"" + config + "\"");
2990
+ }
2991
+
2992
+ data[config]();
2993
+ }
2994
+ });
2995
+ }
2996
+
2997
+ }
2998
+
2999
+ if (typeof $ !== 'undefined') {
3000
+ // jQuery
3001
+ const JQUERY_NO_CONFLICT = $.fn[NAME$2];
3002
+ $.fn[NAME$2] = Dropdown._jQueryInterface;
3003
+ $.fn[NAME$2].Constructor = Dropdown;
3004
+
3005
+ $.fn[NAME$2].noConflict = () => {
3006
+ $.fn[NAME$2] = JQUERY_NO_CONFLICT;
3007
+ return Dropdown._jQueryInterface;
3008
+ };
3009
+
3010
+ $.fn[NAME$2].defaults = {
3011
+ animation: true,
3012
+ animationIn: 'zoomIn',
3013
+ animationOut: 'zoomOut',
3014
+ animationSpeed: 'fastest',
3015
+ offset: null,
3016
+ minWidth: null,
3017
+ align: 'start',
3018
+ closeOnItemClick: true,
3019
+ content: false,
3020
+ scroll: true,
3021
+ scrollContentHeight: 100,
3022
+ onInit: null,
3023
+ onUpdate: null,
3024
+ onDestroy: null,
3025
+ onShow: null,
3026
+ onClose: null,
3027
+ onItemClick: null,
3028
+ debug: false
3029
+ };
3030
+ }
3031
+
3032
+ const NAME$3 = 'coolTooltip';
3033
+ const DATA_KEY$3 = 'plugin_coolTooltip';
3034
+
3035
+ class Tooltip extends AbstractUIComponent {
3036
+ constructor(el, opts) {
3037
+ super();
3038
+ this.opts = {};
3039
+
3040
+ if (window.Cool.settings.tooltip) {
3041
+ $.extend(true, this.opts, $.fn[NAME$3].defaults, window.Cool.settings.tooltip, opts);
3042
+ } else {
3043
+ $.extend(true, this.opts, $.fn[NAME$3].defaults, opts);
3044
+ }
3045
+
3046
+ this.el = el;
3047
+ this.debug = this.opts.debug;
3048
+ this.init();
3049
+ } // Init plugin
3050
+
3051
+
3052
+ init() {
3053
+ this.buildCache();
3054
+ this.bindEvents();
3055
+ this.onInit();
3056
+ } // Remove plugin instance completely
3057
+
3058
+
3059
+ destroy() {
3060
+ this.unbindEvents();
3061
+ this.$el.removeData(DATA_KEY$3);
3062
+ this.onDestroy();
3063
+ } // Update plugin data
3064
+
3065
+
3066
+ update() {
3067
+ this.buildCache();
3068
+ this.onUpdate();
3069
+ } // Cache DOM nodes for performance
3070
+
3071
+
3072
+ buildCache() {
3073
+ this.$el = $(this.el);
3074
+ this.$container = this.$el.data('container') ? $(this.$el.data('container')) : $(this.opts.container);
3075
+ this.id = 'tooltip-' + this.generateUUID();
3076
+ this.animation = this.$el.data('animation') ? this.$el.data('animation') : this.opts.animation;
3077
+ this.animationIn = this.$el.data('animationIn') ? this.$el.data('animationIn') : this.opts.animationIn;
3078
+ this.animationOut = this.$el.data('animationOut') ? this.$el.data('animationOut') : this.opts.animationOut;
3079
+ this.animationSpeed = this.$el.data('animationSpeed') ? this.$el.data('animationSpeed') : this.opts.animationSpeed;
3080
+ this.placement = this.$el.data('placement') ? this.$el.data('placement') : this.opts.placement;
3081
+ this.placementChanged = false;
3082
+ this.content = this.$el.data('content') ? this.$el.data('content') : this.opts.content;
3083
+ } // Bind events that trigger methods
3084
+
3085
+
3086
+ bindEvents() {
3087
+ this.$el.on('mouseenter' + '.' + NAME$3, () => {
3088
+ this.show();
3089
+ });
3090
+ this.$el.on('mouseleave' + '.' + NAME$3, () => {
3091
+ this.close();
3092
+ });
3093
+ $(window).on('resize', debounce(() => {
3094
+ if (this.$tooltip) {
3095
+ this.setPosition();
3096
+ this.onUpdate();
3097
+ }
3098
+ }, 250));
3099
+ } // Unbind events that trigger methods
3100
+
3101
+
3102
+ unbindEvents() {
3103
+ this.$el.off('.' + NAME$3);
3104
+ } // Generate UUID
3105
+
3106
+
3107
+ generateUUID() {
3108
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
3109
+ let r = Math.random() * 16 | 0,
3110
+ v = c == 'x' ? r : r & 0x3 | 0x8;
3111
+ return v.toString(16);
3112
+ });
3113
+ } // Build tooltip
3114
+
3115
+
3116
+ buildTooltip() {
3117
+ this.$tooltip = $("\n\n <div class=\"tooltip\" role=\"tooltip\" id=\"" + this.id + "\">\n\n <div class=\"arrow\"></div>\n\n <div class=\"tooltip-inner\">" + this.content + "</div>\n\n </div>\n\n ");
3118
+ this.$container.append(this.$tooltip);
3119
+ this.$arrow = this.$tooltip.find('.arrow');
3120
+ this.log(this.$el);
3121
+ this.log(this.$container);
3122
+ this.log(this.$tooltip);
3123
+ this.log(this.$arrow);
3124
+ this.log('Id: ' + this.id);
3125
+ this.log('Animation: ' + this.animation);
3126
+ this.log('Animation in: ' + this.animationIn);
3127
+ this.log('Animation out: ' + this.animationOut);
3128
+ this.log('Animation speed: ' + this.animationSpeed);
3129
+ this.log('Placement: ' + this.placement);
3130
+ this.log('Content: ' + this.content);
3131
+ } // Set positions
3132
+
3133
+
3134
+ setPosition(placement) {
3135
+ if (typeof placement === 'undefined' || placement === null) {
3136
+ placement = this.placement;
3137
+ }
3138
+
3139
+ this.$tooltip.addClass('tooltip-' + placement);
3140
+ let containerInnerWidth = this.$container.innerWidth();
3141
+ let containerInnerHeight = this.$container.innerHeight();
3142
+ let tooltipWidth = this.$tooltip.outerWidth(true);
3143
+ let tooltipHeight = this.$tooltip.outerHeight(true);
3144
+ let tooltipTriggerWidth = this.$el.outerWidth();
3145
+ let tooltipTriggerHeight = this.$el.outerHeight();
3146
+ let tooltipTriggerPosX = this.$el.offset().left;
3147
+ let tooltipTriggerPosY = this.$el.offset().top;
3148
+ let arrowWidth = this.$arrow.outerWidth(true);
3149
+ let arrowHeight = this.$arrow.outerHeight(true);
3150
+ let arrowPos;
3151
+ let tooltipPosX;
3152
+ let tooltipPosY;
3153
+
3154
+ if (placement === 'top') {
3155
+ tooltipPosX = Math.round(tooltipTriggerPosX - (tooltipWidth - tooltipTriggerWidth) / 2);
3156
+ tooltipPosY = Math.round(tooltipTriggerPosY - tooltipHeight);
3157
+ arrowPos = Math.round(tooltipWidth / 2 - arrowWidth / 2);
3158
+ this.$arrow.css({
3159
+ left: arrowPos + 'px'
3160
+ });
3161
+ } else if (placement === 'right') {
3162
+ tooltipPosX = Math.round(tooltipTriggerPosX + tooltipTriggerWidth);
3163
+ tooltipPosY = Math.round(tooltipTriggerPosY - (tooltipHeight - tooltipTriggerHeight) / 2);
3164
+ arrowPos = Math.round(tooltipHeight / 2 - arrowHeight / 2);
3165
+ this.$arrow.css({
3166
+ top: arrowPos + 'px'
3167
+ });
3168
+ } else if (placement === 'bottom') {
3169
+ tooltipPosX = Math.round(tooltipTriggerPosX - (tooltipWidth - tooltipTriggerWidth) / 2);
3170
+ tooltipPosY = Math.round(tooltipTriggerPosY + tooltipTriggerHeight);
3171
+ arrowPos = Math.round(tooltipWidth / 2 - arrowWidth / 2);
3172
+ this.$arrow.css({
3173
+ left: arrowPos + 'px'
3174
+ });
3175
+ } else if (placement === 'left') {
3176
+ tooltipPosX = Math.round(tooltipTriggerPosX - tooltipWidth);
3177
+ tooltipPosY = Math.round(tooltipTriggerPosY - (tooltipHeight - tooltipTriggerHeight) / 2);
3178
+ arrowPos = Math.round(tooltipHeight / 2 - arrowHeight / 2);
3179
+ this.$arrow.css({
3180
+ top: arrowPos + 'px'
3181
+ });
3182
+ }
3183
+
3184
+ this.$tooltip.css({
3185
+ position: 'absolute',
3186
+ top: '0px',
3187
+ left: '0px',
3188
+ transform: 'translate3d(' + tooltipPosX + 'px, ' + tooltipPosY + 'px, 0px)',
3189
+ 'will-change': 'transform'
3190
+ }); // Correct placement if tooltip goes outside of container
3191
+
3192
+ let tooltipOverflowCount = 0;
3193
+ let tooltipPosition = {
3194
+ left: this.$tooltip.position().left,
3195
+ top: this.$tooltip.position().top,
3196
+ right: containerInnerWidth - (this.$tooltip.position().left + tooltipWidth),
3197
+ bottom: containerInnerHeight - (this.$tooltip.position().top + tooltipHeight)
3198
+ };
3199
+ let tooltipOverflow = {
3200
+ left: false,
3201
+ top: false,
3202
+ right: false,
3203
+ bottom: false
3204
+ };
3205
+
3206
+ if (tooltipPosition.right < 0) {
3207
+ tooltipOverflow.right = true;
3208
+ tooltipOverflowCount++;
3209
+ this.log('Tooltip overflowing from right');
3210
+ }
3211
+
3212
+ if (tooltipPosition.left < 0) {
3213
+ tooltipOverflow.left = true;
3214
+ tooltipOverflowCount++;
3215
+ this.log('Tooltip overflowing from left');
3216
+ }
3217
+
3218
+ if (tooltipPosition.bottom < 0) {
3219
+ tooltipOverflow.bottom = true;
3220
+ tooltipOverflowCount++;
3221
+ this.log('Tooltip overflowing from bottom');
3222
+ }
3223
+
3224
+ if (tooltipPosition.top < 0) {
3225
+ tooltipOverflow.top = true;
3226
+ tooltipOverflowCount++;
3227
+ this.log('Tooltip overflowing from top');
3228
+ }
3229
+
3230
+ if (tooltipOverflowCount > 0) {
3231
+ if (!this.placementChanged && tooltipOverflow.left && tooltipPosition.right > tooltipWidth) {
3232
+ this.log('Changing tooltip placement to right');
3233
+ this.placementChanged = true;
3234
+ this.$tooltip.removeClass('tooltip-' + placement);
3235
+ this.$arrow.removeAttr('style');
3236
+ this.setPosition('right');
3237
+ } else if (!this.placementChanged && tooltipOverflow.top && tooltipPosition.top > tooltipHeight) {
3238
+ this.log('Changing tooltip placement to bottom');
3239
+ this.placementChanged = true;
3240
+ this.$tooltip.removeClass('tooltip-' + placement);
3241
+ this.$arrow.removeAttr('style');
3242
+ this.setPosition('bottom');
3243
+ } else if (!this.placementChanged && tooltipOverflow.right && tooltipPosition.left > tooltipWidth) {
3244
+ this.log('Changing tooltip placement to left');
3245
+ this.placementChanged = true;
3246
+ this.$tooltip.removeClass('tooltip-' + placement);
3247
+ this.$arrow.removeAttr('style');
3248
+ this.setPosition('left');
3249
+ } else if (!this.placementChanged && tooltipOverflow.bottom && tooltipPosition.top > tooltipHeight) {
3250
+ this.log('Changing tooltip placement to top');
3251
+ this.placementChanged = true;
3252
+ this.$tooltip.removeClass('tooltip-' + placement);
3253
+ this.$arrow.removeAttr('style');
3254
+ this.setPosition('top');
3255
+ } else if (!this.placementChanged && (placement !== 'top' || placement !== 'bottom') && (tooltipOverflow.left || tooltipOverflow.right)) {
3256
+ if (tooltipPosition.top > tooltipPosition.bottom) {
3257
+ this.log('Changing tooltip placement to top');
3258
+ this.placementChanged = true;
3259
+ this.$tooltip.removeClass('tooltip-' + placement);
3260
+ this.$arrow.removeAttr('style');
3261
+ this.setPosition('top');
3262
+ } else {
3263
+ this.log('Changing tooltip placement to bottom');
3264
+ this.placementChanged = true;
3265
+ this.$tooltip.removeClass('tooltip-' + placement);
3266
+ this.$arrow.removeAttr('style');
3267
+ this.setPosition('bottom');
3268
+ }
3269
+ } else {
3270
+ this.fixTooltipPosition = true;
3271
+ }
3272
+
3273
+ if (this.fixTooltipPosition) {
3274
+ this.log('Adjusting tooltip size or position in order to tooltip fit in the container');
3275
+
3276
+ if (tooltipOverflow.left) {
3277
+ this.log('Tooltip overflowing from left');
3278
+ let overflowAmount = Math.abs(tooltipPosition.left);
3279
+ let excludePlacements = ['top', 'bottom'];
3280
+
3281
+ if (tooltipTriggerPosX >= tooltipPosX + overflowAmount && excludePlacements.indexOf(placement) < 0) {
3282
+ this.log('Tooltip adjusting width');
3283
+ tooltipWidth -= overflowAmount;
3284
+ tooltipPosX += overflowAmount;
3285
+ } else {
3286
+ this.log('Tooltip adjusting position x');
3287
+ tooltipPosX += overflowAmount;
3288
+ arrowPos -= overflowAmount;
3289
+ }
3290
+ }
3291
+
3292
+ if (tooltipOverflow.top) {
3293
+ this.log('Tooltip overflowing from top');
3294
+ let overflowAmount = Math.abs(tooltipPosition.top);
3295
+ this.log('Tooltip adjusting position y');
3296
+ tooltipPosY += overflowAmount;
3297
+ arrowPos -= overflowAmount;
3298
+ }
3299
+
3300
+ if (tooltipOverflow.right) {
3301
+ this.log('Tooltip overflowing from right');
3302
+ let overflowAmount = Math.abs(tooltipPosition.right);
3303
+ let excludePlacements = ['top', 'bottom'];
3304
+
3305
+ if (tooltipTriggerPosX <= tooltipPosX - overflowAmount && excludePlacements.indexOf(placement) < 0) {
3306
+ this.log('Tooltip adjusting width');
3307
+ tooltipWidth -= overflowAmount;
3308
+ } else {
3309
+ this.log('Tooltip adjusting position x');
3310
+ tooltipPosX -= overflowAmount;
3311
+ arrowPos += overflowAmount;
3312
+ }
3313
+ }
3314
+
3315
+ if (tooltipOverflow.bottom) {
3316
+ this.log('Tooltip overflowing from bottom');
3317
+ let overflowAmount = Math.abs(tooltipPosition.bottom);
3318
+ this.log('Tooltip adjusting position y');
3319
+ tooltipPosY -= overflowAmount;
3320
+ arrowPos += overflowAmount;
3321
+ }
3322
+
3323
+ if (placement === 'top') {
3324
+ this.$arrow.css({
3325
+ left: arrowPos + 'px'
3326
+ });
3327
+ } else if (placement === 'right') {
3328
+ this.$arrow.css({
3329
+ top: arrowPos + 'px'
3330
+ });
3331
+ } else if (placement === 'bottom') {
3332
+ this.$arrow.css({
3333
+ left: arrowPos + 'px'
3334
+ });
3335
+ } else if (placement === 'left') {
3336
+ this.$arrow.css({
3337
+ top: arrowPos + 'px'
3338
+ });
3339
+ }
3340
+
3341
+ this.$tooltip.css({
3342
+ width: tooltipWidth,
3343
+ transform: 'translate3d(' + tooltipPosX + 'px, ' + tooltipPosY + 'px, 0px)'
3344
+ });
3345
+ this.fixTooltipPosition = false;
3346
+ this.log('Tooltip placement changed: ' + this.placementChanged);
3347
+ this.log('Tooltip container inner width: ' + containerInnerWidth + 'px');
3348
+ this.log('Tooltip container inner height: ' + containerInnerHeight + 'px');
3349
+ this.log('Tooltip trigger width: ' + tooltipTriggerWidth + 'px');
3350
+ this.log('Tooltip trigger height: ' + tooltipTriggerHeight + 'px');
3351
+ this.log('Tooltip trigger position x: ' + tooltipTriggerPosX + 'px');
3352
+ this.log('Tooltip trigger position Y: ' + tooltipTriggerPosY + 'px');
3353
+ this.log('Tooltip width: ' + tooltipWidth + 'px');
3354
+ this.log('Tooltip height: ' + tooltipHeight + 'px');
3355
+ this.log('Tooltip position x: ' + tooltipPosX + 'px');
3356
+ this.log('Tooltip position y: ' + tooltipPosY + 'px');
3357
+ this.log('Tooltip position left: ' + tooltipPosition.left + 'px');
3358
+ this.log('Tooltip position top: ' + tooltipPosition.top + 'px');
3359
+ this.log('Tooltip position right: ' + tooltipPosition.right + 'px');
3360
+ this.log('Tooltip position bottom: ' + tooltipPosition.bottom + 'px');
3361
+ }
3362
+ } else {
3363
+ this.log('Tooltip placement changed: ' + this.placementChanged);
3364
+ this.log('Tooltip container inner width: ' + containerInnerWidth + 'px');
3365
+ this.log('Tooltip container inner height: ' + containerInnerHeight + 'px');
3366
+ this.log('Tooltip trigger width: ' + tooltipTriggerWidth + 'px');
3367
+ this.log('Tooltip trigger height: ' + tooltipTriggerHeight + 'px');
3368
+ this.log('Tooltip trigger position x: ' + tooltipTriggerPosX + 'px');
3369
+ this.log('Tooltip trigger position Y: ' + tooltipTriggerPosY + 'px');
3370
+ this.log('Tooltip width: ' + tooltipWidth + 'px');
3371
+ this.log('Tooltip height: ' + tooltipHeight + 'px');
3372
+ this.log('Tooltip position x: ' + tooltipPosX + 'px');
3373
+ this.log('Tooltip position y: ' + tooltipPosY + 'px');
3374
+ this.log('Tooltip position left: ' + tooltipPosition.left + 'px');
3375
+ this.log('Tooltip position top: ' + tooltipPosition.top + 'px');
3376
+ this.log('Tooltip position right: ' + tooltipPosition.right + 'px');
3377
+ this.log('Tooltip position bottom: ' + tooltipPosition.bottom + 'px');
3378
+ }
3379
+ } // Show
3380
+
3381
+
3382
+ show() {
3383
+ if (this.$tooltip) {
3384
+ return;
3385
+ }
3386
+
3387
+ this.buildTooltip();
3388
+ this.setPosition();
3389
+
3390
+ if (this.animation) {
3391
+ this.$tooltip.addClass(this.animationSpeed);
3392
+ this.$tooltip.animateCss(this.animationIn);
3393
+ this.$tooltip.addClass('show');
3394
+ this.$tooltip.attr('id', this.id);
3395
+ this.$el.attr('data-tooltip', this.id);
3396
+ } else {
3397
+ this.$tooltip.addClass('show');
3398
+ this.$tooltip.attr('id', this.id);
3399
+ this.$el.attr('data-tooltip', this.id);
3400
+ }
3401
+
3402
+ this.onShow();
3403
+ } // Close
3404
+
3405
+
3406
+ close() {
3407
+ if (!this.$tooltip) {
3408
+ return;
3409
+ }
3410
+
3411
+ if (this.animation && !this.$tooltip.hasClass('animated')) {
3412
+ this.$tooltip.animateCss(this.animationOut, () => {
3413
+ this.$tooltip.remove();
3414
+ this.$el.removeAttr('data-tooltip');
3415
+ this.$tooltip = null;
3416
+ this.placementChanged = false;
3417
+ this.onClose();
3418
+ });
3419
+ } else {
3420
+ this.$tooltip.remove();
3421
+ this.$el.removeAttr('data-tooltip');
3422
+ this.$tooltip = null;
3423
+ this.placementChanged = false;
3424
+ this.onClose();
3425
+ }
3426
+ }
3427
+
3428
+ static _jQueryInterface(config) {
3429
+ return this.each(function () {
3430
+ let data = $(this).data(DATA_KEY$3);
3431
+
3432
+ const _config = typeof config === 'object' && config;
3433
+
3434
+ if (!data) {
3435
+ data = new Tooltip(this, _config);
3436
+ $(this).data(DATA_KEY$3, data);
3437
+ }
3438
+
3439
+ if (typeof config === 'string') {
3440
+ if (typeof data[config] === 'undefined') {
3441
+ throw new TypeError("No method named \"" + config + "\"");
3442
+ }
3443
+
3444
+ data[config]();
3445
+ }
3446
+ });
3447
+ }
3448
+
3449
+ }
3450
+
3451
+ if (typeof $ !== 'undefined') {
3452
+ // jQuery
3453
+ const JQUERY_NO_CONFLICT = $.fn[NAME$3];
3454
+ $.fn[NAME$3] = Tooltip._jQueryInterface;
3455
+ $.fn[NAME$3].Constructor = Tooltip;
3456
+
3457
+ $.fn[NAME$3].noConflict = () => {
3458
+ $.fn[NAME$3] = JQUERY_NO_CONFLICT;
3459
+ return Tooltip._jQueryInterface;
3460
+ };
3461
+
3462
+ $.fn[NAME$3].defaults = {
3463
+ container: 'body',
3464
+ animation: false,
3465
+ animationIn: 'fadeIn',
3466
+ animationOut: 'fadeOut',
3467
+ animationSpeed: 'fastest',
3468
+ placement: 'bottom',
3469
+ content: '',
3470
+ onInit: null,
3471
+ onUpdate: null,
3472
+ onDestroy: null,
3473
+ onShow: null,
3474
+ onClose: null,
3475
+ debug: false
3476
+ };
3477
+ }
3478
+
3479
+ const NAME$4 = 'coolSectionTabs';
3480
+ const DATA_KEY$4 = 'plugin_coolSectionTabs';
3481
+
3482
+ class SectionTabs extends AbstractUIComponent {
3483
+ constructor(el, opts) {
3484
+ super();
3485
+ this.opts = {};
3486
+
3487
+ if (window.Cool.settings.sectionTabs) {
3488
+ $.extend(true, this.opts, $.fn[NAME$4].defaults, window.Cool.settings.sectionTabs, opts);
3489
+ } else {
3490
+ $.extend(true, this.opts, $.fn[NAME$4].defaults, opts);
3491
+ }
3492
+
3493
+ this.el = el;
3494
+ this.debug = this.opts.debug;
3495
+ this.init();
3496
+ } // Init plugin
3497
+
3498
+
3499
+ init() {
3500
+ this.buildCache();
3501
+ this.bindEvents();
3502
+ this.checkForChanges();
3503
+ this.onInit();
3504
+ } // Remove plugin instance completely
3505
+
3506
+
3507
+ destroy() {
3508
+ this.unbindEvents();
3509
+ this.$el.removeData(DATA_KEY$4);
3510
+ this.onDestroy();
3511
+ } // Update plugin data
3512
+
3513
+
3514
+ update() {
3515
+ this.buildCache();
3516
+ this.onUpdate();
3517
+ } // Cache DOM nodes for performance
3518
+
3519
+
3520
+ buildCache() {
3521
+ this.$el = $(this.el);
3522
+ this.$dropdownContainer = this.$el.find('.dropdown-container');
3523
+ this.$dropdownList = this.$el.find('.dropdown-list');
3524
+ this.tabsCount = this.$el.find('> .tab-item').length;
3525
+ this.tabs = this.$el.find('> .tab-item:visible');
3526
+ $.each(this.tabs, function (i, el) {
3527
+ $(el).data('width', $(el).outerWidth(true));
3528
+ });
3529
+ this.log(this.$el);
3530
+ this.log(this.$dropdownContainer);
3531
+ this.log(this.$dropdownList);
3532
+ this.log(this.tabsCount);
3533
+ } // Bind events that trigger methods
3534
+
3535
+
3536
+ bindEvents() {
3537
+ $(window).on('resize', debounce(() => {
3538
+ this.checkForChanges();
3539
+ }, 250));
3540
+ } // Unbind events that trigger methods
3541
+
3542
+
3543
+ unbindEvents() {
3544
+ this.$el.off('.' + this._name);
3545
+ } // Move to list
3546
+
3547
+
3548
+ moveToList(el) {
3549
+ $(el).insertBefore(this.$dropdownContainer);
3550
+ this.checkForChanges();
3551
+ } // Move to dropdown
3552
+
3553
+
3554
+ moveToDropdown(el) {
3555
+ $(el).appendTo(this.$dropdownList);
3556
+ this.checkForChanges();
3557
+ } // Overflow status
3558
+
3559
+
3560
+ overflowStatus() {
3561
+ if (this.$el[0].offsetWidth < this.$el[0].scrollWidth) {
3562
+ return true;
3563
+ } else {
3564
+ return false;
3565
+ }
3566
+ } // CheckForChanges
3567
+
3568
+
3569
+ checkForChanges() {
3570
+ let dropdownItems = this.$dropdownList.children();
3571
+ let moveableTabs = this.$el.find('> .tab-item').not(this.$dropdownContainer);
3572
+ let tabs = this.$el.find('> .tab-item:visible');
3573
+ let usedSpace = 0;
3574
+ $.each(tabs, function (i, el) {
3575
+ usedSpace += $(el).outerWidth(true);
3576
+ });
3577
+ let freeSpace = this.$el[0].offsetWidth - usedSpace;
3578
+
3579
+ if (dropdownItems.length > 0) {
3580
+ if (!this.$dropdownContainer.hasClass('visible')) {
3581
+ this.$dropdownContainer.addClass('visible');
3582
+ }
3583
+ } else {
3584
+ if (this.$dropdownContainer.hasClass('visible')) {
3585
+ this.$dropdownContainer.removeClass('visible');
3586
+ }
3587
+ }
3588
+
3589
+ if (this.overflowStatus() == true) {
3590
+ if (moveableTabs.length > 0) {
3591
+ this.moveToDropdown(moveableTabs.last());
3592
+ }
3593
+ } else {
3594
+ if (dropdownItems.length > 0) {
3595
+ if (freeSpace > dropdownItems.last().data('width')) {
3596
+ this.moveToList(dropdownItems.last());
3597
+ }
3598
+ }
3599
+ }
3600
+ }
3601
+
3602
+ static _jQueryInterface(config) {
3603
+ return this.each(function () {
3604
+ let data = $(this).data(DATA_KEY$4);
3605
+
3606
+ const _config = typeof config === 'object' && config;
3607
+
3608
+ if (!data) {
3609
+ data = new SectionTabs(this, _config);
3610
+ $(this).data(DATA_KEY$4, data);
3611
+ }
3612
+
3613
+ if (typeof config === 'string') {
3614
+ if (typeof data[config] === 'undefined') {
3615
+ throw new TypeError("No method named \"" + config + "\"");
3616
+ }
3617
+
3618
+ data[config]();
3619
+ }
3620
+ });
3621
+ }
3622
+
3623
+ }
3624
+
3625
+ if (typeof $ !== 'undefined') {
3626
+ // jQuery
3627
+ const JQUERY_NO_CONFLICT = $.fn[NAME$4];
3628
+ $.fn[NAME$4] = SectionTabs._jQueryInterface;
3629
+ $.fn[NAME$4].Constructor = SectionTabs;
3630
+
3631
+ $.fn[NAME$4].noConflict = () => {
3632
+ $.fn[NAME$4] = JQUERY_NO_CONFLICT;
3633
+ return SectionTabs._jQueryInterface;
3634
+ };
3635
+
3636
+ $.fn[NAME$4].defaults = {
3637
+ onInit: null,
3638
+ onUpdate: null,
3639
+ onDestroy: null,
3640
+ debug: false
3641
+ };
3642
+ }
3643
+
3644
+ const NAME$5 = 'coolCollapse';
3645
+ const DATA_KEY$5 = 'plugin_coolCollapse';
3646
+
3647
+ class Collapse extends AbstractUIComponent {
3648
+ constructor(el, opts) {
3649
+ super();
3650
+ this.opts = {};
3651
+
3652
+ if (window.Cool.settings.collapse) {
3653
+ $.extend(true, this.opts, $.fn[NAME$5].defaults, window.Cool.settings.dialog, opts);
3654
+ } else {
3655
+ $.extend(true, this.opts, $.fn[NAME$5].defaults, opts);
3656
+ }
3657
+
3658
+ this.el = el;
3659
+ this.debug = this.opts.debug;
3660
+ this.init();
3661
+ } // Init plugin
3662
+
3663
+
3664
+ init() {
3665
+ this.buildCache();
3666
+ this.bindEvents();
3667
+ this.onInit();
3668
+ } // Remove plugin instance completely
3669
+
3670
+
3671
+ destroy() {
3672
+ this.unbindEvents();
3673
+ this.$el.removeData(DATA_KEY$5);
3674
+ this.onDestroy();
3675
+ } // Update plugin data
3676
+
3677
+
3678
+ update() {
3679
+ this.buildCache();
3680
+ this.onUpdate();
3681
+ } // Cache DOM nodes for performance
3682
+
3683
+
3684
+ buildCache() {
3685
+ this.$el = $(this.el);
3686
+ this.$target = this.$el.data('target') ? $(document).find(this.$el.data('target')) : $(document).find(this.opts.target);
3687
+ this.expanded = this.$el.attr('aria-expanded') == 'true' ? true : false;
3688
+
3689
+ if (this.$target.length) {
3690
+ this.targetHeight = this.$target.height();
3691
+ this.$container = this.$target.closest('.section-collapse');
3692
+ this.$indicator = $(document).find('[data-collapse-indicator="' + this.$el.data('target') + '"]');
3693
+ } else {
3694
+ this.$target = $(this.$el).parent().find('.collapse');
3695
+ this.targetHeight = this.$target.height();
3696
+ this.$container = this.$target.closest('.section-collapse');
3697
+ this.$indicator = $(this.$el).parent().find('[data-collapse-indicator]');
3698
+ }
3699
+
3700
+ this.log(this.$el);
3701
+ this.log(this.$target);
3702
+ this.log(this.$container);
3703
+ this.log(this.$indicator);
3704
+ this.log('Expanded: ' + this.expanded);
3705
+ this.log('Target height: ' + this.targetHeight + 'px');
3706
+ } // Bind events that trigger methods
3707
+
3708
+
3709
+ bindEvents() {
3710
+ this.$el.on('click' + '.' + this.name, e => {
3711
+ if (this.expanded) {
3712
+ this.close();
3713
+ } else {
3714
+ this.show();
3715
+ }
3716
+ });
3717
+ $(window).on('resize', debounce(() => {
3718
+ if (this.$target.length) {
3719
+ this.targetHeight = this.$target.height();
3720
+ this.log('Target height: ' + this.targetHeight + 'px');
3721
+ }
3722
+ }, 250));
3723
+ } // Unbind events that trigger methods
3724
+
3725
+
3726
+ unbindEvents() {
3727
+ this.$el.off('.' + this.name);
3728
+ } // Which transition
3729
+
3730
+
3731
+ whichTransitionEvent() {
3732
+ let el = document.createElement('text-transition');
3733
+ let transEndEventNames = {
3734
+ 'WebkitTransition': 'webkitTransitionEnd',
3735
+ // Saf 6, Android Browser
3736
+ 'MozTransition': 'transitionend',
3737
+ // only for FF < 15
3738
+ 'transition': 'transitionend' // IE10, Opera, Chrome, FF 15+, Saf 7+
3739
+
3740
+ };
3741
+
3742
+ for (let t in transEndEventNames) {
3743
+ if (el.style[t] !== undefined) {
3744
+ return transEndEventNames[t];
3745
+ }
3746
+ }
3747
+ } // Show
3748
+
3749
+
3750
+ show() {
3751
+ this.$target.removeClass('collapse visible');
3752
+ this.$target.addClass('collapsing');
3753
+
3754
+ if (this.$el.is('button')) {
3755
+ this.$el.attr('disabled', true);
3756
+ }
3757
+
3758
+ if (this.$container.length) {
3759
+ this.$container.addClass('visible');
3760
+ }
3761
+
3762
+ this.$target.css('height');
3763
+ this.$target.css('height', this.targetHeight);
3764
+
3765
+ if (this.$indicator.length) {
3766
+ this.$indicator.addClass('visible');
3767
+ }
3768
+
3769
+ this.$target.one(this.whichTransitionEvent(), () => {
3770
+ this.$target.removeClass('collapsing');
3771
+
3772
+ if (this.$el.is('button')) {
3773
+ this.$el.attr('disabled', false);
3774
+ }
3775
+
3776
+ this.$target.removeAttr('style');
3777
+ this.$target.addClass('collapse visible');
3778
+ this.$el.attr('aria-expanded', true);
3779
+ this.$target.css('height', 'auto');
3780
+ this.expanded = true;
3781
+ });
3782
+ this.onShow();
3783
+ } // Close
3784
+
3785
+
3786
+ close() {
3787
+ this.$target.removeClass('collapse visible');
3788
+ this.$target.addClass('collapsing');
3789
+
3790
+ if (this.$el.is('button')) {
3791
+ this.$el.attr('disabled', true);
3792
+ }
3793
+
3794
+ if (this.$container.length) {
3795
+ this.$container.removeClass('visible');
3796
+ }
3797
+
3798
+ this.$target.css('height', this.$target.height());
3799
+ setTimeout(() => {
3800
+ this.$target.css('height', 0);
3801
+ }, 10);
3802
+
3803
+ if (this.$indicator.length && this.$indicator.hasClass('visible')) {
3804
+ this.$indicator.removeClass('visible');
3805
+ }
3806
+
3807
+ this.$target.one(this.whichTransitionEvent(), () => {
3808
+ this.$target.removeClass('collapsing');
3809
+
3810
+ if (this.$el.is('button')) {
3811
+ this.$el.attr('disabled', false);
3812
+ }
3813
+
3814
+ this.$target.removeAttr('style');
3815
+ this.$target.addClass('collapse');
3816
+ this.$el.attr('aria-expanded', false);
3817
+ this.expanded = false;
3818
+ });
3819
+ this.onClose();
3820
+ }
3821
+
3822
+ static _jQueryInterface(config) {
3823
+ return this.each(function () {
3824
+ let data = $(this).data(DATA_KEY$5);
3825
+
3826
+ const _config = typeof config === 'object' && config;
3827
+
3828
+ if (!data) {
3829
+ data = new Collapse(this, _config);
3830
+ $(this).data(DATA_KEY$5, data);
3831
+ }
3832
+
3833
+ if (typeof config === 'string') {
3834
+ if (typeof data[config] === 'undefined') {
3835
+ throw new TypeError("No method named \"" + config + "\"");
3836
+ }
3837
+
3838
+ data[config]();
3839
+ }
3840
+ });
3841
+ }
3842
+
3843
+ }
3844
+
3845
+ if (typeof $ !== 'undefined') {
3846
+ // jQuery
3847
+ const JQUERY_NO_CONFLICT = $.fn[NAME$5];
3848
+ $.fn[NAME$5] = Collapse._jQueryInterface;
3849
+ $.fn[NAME$5].Constructor = Collapse;
3850
+
3851
+ $.fn[NAME$5].noConflict = () => {
3852
+ $.fn[NAME$5] = JQUERY_NO_CONFLICT;
3853
+ return Collapse._jQueryInterface;
3854
+ };
3855
+
3856
+ $.fn[NAME$5].defaults = {
3857
+ target: null,
3858
+ onInit: null,
3859
+ onUpdate: null,
3860
+ onDestroy: null,
3861
+ onShow: null,
3862
+ onClose: null,
3863
+ debug: false
3864
+ };
3865
+ }
3866
+
3867
+ const NAME$6 = 'coolToast';
3868
+ const DATA_KEY$6 = 'plugin_coolToast';
3869
+
3870
+ class Toast {
3871
+ constructor(container, opts) {
3872
+ this.settings = {};
3873
+
3874
+ if (window.Cool.settings.toast) {
3875
+ $.extend(true, this.settings, $.fn[NAME$6].defaults, window.Cool.settings.toast, opts);
3876
+ } else {
3877
+ $.extend(true, this.settings, $.fn[NAME$6].defaults, opts);
3878
+ }
3879
+
3880
+ this.container = container;
3881
+ this.$container = $(this.container);
3882
+ this.debug = this.settings.debug;
3883
+ this.faPro = this.settings.faPro;
3884
+ this.toasts = [];
3885
+ this.queue = [];
3886
+ this.processingQueue = false;
3887
+ this.onInitialize = this.settings.onInitialize;
3888
+ this.onDestroy = this.settings.onDestroy;
3889
+ } // Add item to queue
3890
+
3891
+
3892
+ addQueue(toast) {
3893
+ this.queue.push(toast);
3894
+
3895
+ if (this.processingQueue) {
3896
+ return;
3897
+ }
3898
+
3899
+ return this.processQueue();
3900
+ } // Process queue
3901
+
3902
+
3903
+ processQueue() {
3904
+ if (this.processingQueue) {
3905
+ this.queue.shift();
3906
+ }
3907
+
3908
+ if (!this.queue.length) {
3909
+ this.processingQueue = false;
3910
+ return;
3911
+ }
3912
+
3913
+ this.processingQueue = true;
3914
+ return this.show(this.queue[0]);
3915
+ } // Init toast
3916
+
3917
+
3918
+ init(opts) {
3919
+ let settings = {};
3920
+ $.extend(true, settings, this.settings, opts);
3921
+ let toast = this.buildToast(settings);
3922
+ this.addQueue(toast);
3923
+ this.onInit(toast);
3924
+ return toast;
3925
+ } // Remove plugin instance completely
3926
+
3927
+
3928
+ destroy() {
3929
+ this.$container.removeData(DATA_KEY$6);
3930
+ this.onDestroy();
3931
+ } // Build toast
3932
+
3933
+
3934
+ buildToast(settings) {
3935
+ let toast = {
3936
+ uuid: 'toast-' + this.generateUUID(),
3937
+ placement: settings.placement,
3938
+ placementX: settings.placementX,
3939
+ placementY: settings.placementY,
3940
+ offset: settings.offset,
3941
+ animation: settings.animation,
3942
+ animationIn: settings.animationIn,
3943
+ animationOut: settings.animationOut,
3944
+ animationSpeed: settings.animationSpeed,
3945
+ dismiss: settings.dismiss,
3946
+ size: settings.size,
3947
+ header: settings.header,
3948
+ theme: settings.theme,
3949
+ title: settings.title,
3950
+ content: settings.content,
3951
+ template: settings.template,
3952
+ maxBodyHeight: settings.maxBodyHeight,
3953
+ onInit: settings.onInit,
3954
+ onShow: settings.onShow,
3955
+ onClose: settings.onClose
3956
+ };
3957
+
3958
+ if (typeof toast.content === 'function') {
3959
+ toast.$el = $(toast.template());
3960
+ } else {
3961
+ toast.$el = $(this._renderTemplate(toast));
3962
+ }
3963
+
3964
+ toast.$inner = toast.$el.find('.toast-inner');
3965
+ toast.$closeBtn = toast.$el.find('[data-toast-close]');
3966
+ this.log(toast);
3967
+ this.toasts.push(toast);
3968
+ return toast;
3969
+ } // Bind events that trigger methods
3970
+
3971
+
3972
+ bindEvents(toast) {
3973
+ let self = this;
3974
+ toast.$el.on('click', '[data-toast-close]', () => {
3975
+ if (toast.$el) {
3976
+ self.close(toast);
3977
+ }
3978
+ });
3979
+ $(window).on('resize', debounce(() => {
3980
+ if (toast.$el) {
3981
+ this.setPosition(toast);
3982
+ }
3983
+ }, 250));
3984
+ } // Generate UUID
3985
+
3986
+
3987
+ generateUUID() {
3988
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
3989
+ let r = Math.random() * 16 | 0,
3990
+ v = c == 'x' ? r : r & 0x3 | 0x8;
3991
+ return v.toString(16);
3992
+ });
3993
+ } // Set positions
3994
+
3995
+
3996
+ setPosition(toast, placement, placementY, placementX) {
3997
+ if (typeof placementY === 'undefined' || placementY === null) {
3998
+ placementY = toast.placementY;
3999
+ }
4000
+
4001
+ if (typeof placementX === 'undefined' || placementX === null) {
4002
+ placementX = toast.placementX;
4003
+ }
4004
+
4005
+ if (!placementX || !placementY) {
4006
+ placement = toast.placement;
4007
+ }
4008
+
4009
+ if (toast.offset) {
4010
+ let offsets = toast.offset.split(',');
4011
+ let offsetX = parseInt(offsets[0], 10);
4012
+ let offsetY = parseInt(offsets[1], 10);
4013
+ }
4014
+
4015
+ let toastWidth = toast.$el.outerWidth(true);
4016
+ let toastHeight = toast.$el.outerHeight(true);
4017
+ let toastPosX;
4018
+ let toastPosY;
4019
+
4020
+ if (placement) {
4021
+ if (placement === 'top-left') {
4022
+ toastPosX = 0;
4023
+ toastPosY = 0;
4024
+
4025
+ if (toast.offset) {
4026
+ toastPosX += offsetX;
4027
+ toastPosY += offsetY;
4028
+ } else {
4029
+ toastPosX += 30;
4030
+ toastPosY += 30;
4031
+ }
4032
+ } else if (placement === 'top-center') {
4033
+ toastPosX = this.$container.width() / 2 - toastWidth / 2;
4034
+ toastPosY = 0;
4035
+ this.log(this.$container.width);
4036
+
4037
+ if (toast.offset) {
4038
+ toastPosX += offsetX;
4039
+ toastPosY += offsetY;
4040
+ } else {
4041
+ toastPosY += 30;
4042
+ }
4043
+ } else if (placement === 'top-right') {
4044
+ toastPosX = this.$container.width() - toastWidth;
4045
+ toastPosY = 0;
4046
+
4047
+ if (toast.offset) {
4048
+ toastPosX += -offsetX;
4049
+ toastPosY += offsetY;
4050
+ } else {
4051
+ toastPosX += -30;
4052
+ toastPosY += 30;
4053
+ }
4054
+ } else if (placement === 'center-left') {
4055
+ toastPosX = 0;
4056
+ toastPosY = this.$container.height() / 2 - toastHeight / 2;
4057
+
4058
+ if (toast.offset) {
4059
+ toastPosX += offsetX;
4060
+ toastPosY += offsetY;
4061
+ } else {
4062
+ toastPosX += 30;
4063
+ }
4064
+ } else if (placement === 'center-center') {
4065
+ toastPosX = this.$container.width() / 2 - toastWidth / 2;
4066
+ toastPosY = this.$container.height() / 2 - toastHeight / 2;
4067
+
4068
+ if (toast.offset) {
4069
+ toastPosX += offsetX;
4070
+ toastPosY += offsetY;
4071
+ }
4072
+ } else if (placement === 'center-right') {
4073
+ toastPosX = this.$container.width() - toastWidth;
4074
+ toastPosY = this.$container.height() / 2 - toastHeight / 2;
4075
+
4076
+ if (toast.offset) {
4077
+ toastPosX += -offsetX;
4078
+ toastPosY += offsetY;
4079
+ } else {
4080
+ toastPosX += -30;
4081
+ }
4082
+ } else if (placement === 'bottom-left') {
4083
+ toastPosX = 0;
4084
+ toastPosY = this.$container.height() - toastHeight;
4085
+
4086
+ if (toast.offset) {
4087
+ toastPosX += offsetX;
4088
+ toastPosY += -offsetY;
4089
+ } else {
4090
+ toastPosX += 30;
4091
+ toastPosY += -30;
4092
+ }
4093
+ } else if (placement === 'bottom-center') {
4094
+ toastPosX = this.$container.width() / 2 - toastWidth / 2;
4095
+ toastPosY = this.$container.height() - toastHeight;
4096
+
4097
+ if (toast.offset) {
4098
+ toastPosX += offsetX;
4099
+ toastPosY += -offsetY;
4100
+ } else {
4101
+ toastPosY += -30;
4102
+ }
4103
+ } else if (placement === 'bottom-right') {
4104
+ toastPosX = this.$container.width() - toastWidth;
4105
+ toastPosY = this.$container.height() - toastHeight;
4106
+
4107
+ if (toast.offset) {
4108
+ toastPosX += -offsetX;
4109
+ toastPosY += -offsetY;
4110
+ } else {
4111
+ toastPosX += -30;
4112
+ toastPosY += -30;
4113
+ }
4114
+ }
4115
+ } else {
4116
+ toastPosX = placementX;
4117
+ toastPosY = placementY;
4118
+ }
4119
+
4120
+ toast.$el.css({
4121
+ position: 'absolute',
4122
+ top: '0px',
4123
+ left: '0px',
4124
+ transform: 'translate3d(' + toastPosX + 'px, ' + toastPosY + 'px, 0px)',
4125
+ 'will-change': 'transform'
4126
+ });
4127
+ this.log('Toast width: ' + toastWidth + 'px');
4128
+ this.log('Toast height: ' + toastHeight + 'px');
4129
+ this.log('Toast position Y: ' + toastPosX + 'px');
4130
+ this.log('Toast position x: ' + toastPosY + 'px');
4131
+ } // Show
4132
+
4133
+
4134
+ show(toast) {
4135
+ this.$container.append(toast.$el);
4136
+ this.bindEvents(toast);
4137
+ this.setPosition(toast);
4138
+
4139
+ if (toast.animation) {
4140
+ toast.$el.addClass('show');
4141
+ toast.$inner.addClass(toast.animationSpeed);
4142
+ toast.$inner.animateCss(toast.animationIn);
4143
+ } else {
4144
+ toast.$el.addClass('show');
4145
+ }
4146
+
4147
+ if (toast.dismiss) {
4148
+ setTimeout(() => {
4149
+ this.close(toast);
4150
+ }, toast.dismiss * 1000);
4151
+ }
4152
+
4153
+ this.onShow(toast);
4154
+ } // Close
4155
+
4156
+
4157
+ close(toast) {
4158
+ if (toast.animation && !toast.$inner.hasClass('animated')) {
4159
+ toast.$el.removeClass('show');
4160
+ toast.$inner.animateCss(toast.animationOut, () => {
4161
+ toast.$el.remove();
4162
+ this.toasts = $.grep(this.toasts, function (item) {
4163
+ return item.uuid != toast.uuid;
4164
+ });
4165
+ this.processQueue();
4166
+ this.onClose(toast);
4167
+ });
4168
+ } else {
4169
+ toast.$el.remove();
4170
+ this.toasts = $.grep(this.toasts, function (item) {
4171
+ return item.uuid != toast.uuid;
4172
+ });
4173
+ this.processQueue();
4174
+ this.onClose(toast);
4175
+ }
4176
+ } // Initialize callback
4177
+
4178
+
4179
+ onInitialize() {
4180
+ let onInitialize = this.onInitialize;
4181
+
4182
+ if (typeof onInitialize === 'function') {
4183
+ onInitialize.call(this.container);
4184
+ }
4185
+ } // Destroy callback
4186
+
4187
+
4188
+ onDestroy() {
4189
+ let onDestroy = this.onDestroy;
4190
+
4191
+ if (typeof onDestroy === 'function') {
4192
+ onDestroy.call(this.container);
4193
+ }
4194
+ } // Init callback
4195
+
4196
+
4197
+ onInit(toast) {
4198
+ let onInit = toast.onInit;
4199
+
4200
+ if (typeof onInit === 'function') {
4201
+ onInit.call(toast);
4202
+ }
4203
+ } // Show callback
4204
+
4205
+
4206
+ onShow(toast) {
4207
+ let onShow = toast.onShow;
4208
+
4209
+ if (typeof onShow === 'function') {
4210
+ onShow.call(toast);
4211
+ }
4212
+ } // Close callback
4213
+
4214
+
4215
+ onClose(toast) {
4216
+ let onClose = toast.onClose;
4217
+
4218
+ if (typeof onClose === 'function') {
4219
+ onClose.call(toast);
4220
+ }
4221
+ } // Debug log
4222
+
4223
+
4224
+ log() {
4225
+ if (this.debug) {
4226
+ if (typeof this.debug === 'function') {
4227
+ this.debug(...arguments);
4228
+ } else {
4229
+ console.log(...arguments);
4230
+ }
4231
+ }
4232
+ } // Render template
4233
+
4234
+
4235
+ _renderTemplate(toast) {
4236
+ let faNameSpace = this.faPro ? 'far' : 'fas';
4237
+ let content = '';
4238
+ let header = '';
4239
+ let body = '';
4240
+ let bodyCloseBtn = '';
4241
+
4242
+ if (typeof toast.content === 'function') {
4243
+ content = toast.content();
4244
+ } else {
4245
+ content = toast.content;
4246
+ }
4247
+
4248
+ if (toast.header) {
4249
+ header = "\n <div class=\"toast-header\">\n\n <span>" + toast.title + "</span>\n\n <button type=\"button\" data-toast-close>\n <i class=\"" + faNameSpace + " fa-times icon\"></i>\n </button>\n\n </div>\n ";
4250
+ } else {
4251
+ bodyCloseBtn = "\n <button type=\"button\" data-toast-close>\n\n <i class=\"" + faNameSpace + " fa-times icon\"></i>\n\n </button>\n ";
4252
+ }
4253
+
4254
+ body = "\n <div class=\"toast-body\">\n\n <span>" + content + "</span>\n " + bodyCloseBtn + "\n\n </div>\n ";
4255
+ return "\n <div class=\"toast toast-" + toast.size + " toast-" + toast.theme + "\" role=\"alert\" id=\"" + toast.uuid + "\">\n\n <div class=\"toast-inner\">\n\n " + header + "\n " + body + "\n\n </div>\n\n </div>\n ";
4256
+ }
4257
+
4258
+ static _jQueryInterface(config) {
4259
+ return this.each(function () {
4260
+ let data = $(this).data(DATA_KEY$6);
4261
+
4262
+ const _config = typeof config === 'object' && config;
4263
+
4264
+ if (!data) {
4265
+ data = new Toast(this, _config);
4266
+ $(this).data(DATA_KEY$6, data);
4267
+ }
4268
+
4269
+ if (typeof config === 'string') {
4270
+ if (typeof data[config] === 'undefined') {
4271
+ throw new TypeError("No method named \"" + config + "\"");
4272
+ }
4273
+
4274
+ data[config]();
4275
+ }
4276
+ });
4277
+ }
4278
+
4279
+ }
4280
+
4281
+ if (typeof $ !== 'undefined') {
4282
+ // jQuery
4283
+ const JQUERY_NO_CONFLICT = $.fn[NAME$6];
4284
+ $.fn[NAME$6] = Toast._jQueryInterface;
4285
+ $.fn[NAME$6].Constructor = Toast;
4286
+
4287
+ $.fn[NAME$6].noConflict = () => {
4288
+ $.fn[NAME$6] = JQUERY_NO_CONFLICT;
4289
+ return Toast._jQueryInterface;
4290
+ };
4291
+
4292
+ $.fn[NAME$6].defaults = {
4293
+ title: '',
4294
+ content: '',
4295
+ template: '',
4296
+ theme: 'dark',
4297
+ placement: 'bottom-center',
4298
+ placementX: null,
4299
+ placementY: null,
4300
+ animation: true,
4301
+ animationIn: 'slideInUp',
4302
+ animationOut: 'slideOutDown',
4303
+ animationSpeed: 'faster',
4304
+ offset: null,
4305
+ size: null,
4306
+ dismiss: 3,
4307
+ header: false,
4308
+ faPro: false,
4309
+ debug: false,
4310
+ onInitialize: null,
4311
+ onDestroy: null,
4312
+ onInit: null,
4313
+ onDestroy: null,
4314
+ onShow: null,
4315
+ onClose: null
4316
+ };
4317
+ }
4318
+
4319
+ const NAME$7 = 'coolDialog';
4320
+ const DATA_KEY$7 = 'plugin_coolDialog';
4321
+
4322
+ class Dialog {
4323
+ constructor(container, opts) {
4324
+ this.settings = {};
4325
+
4326
+ if (window.Cool.settings.dialog) {
4327
+ $.extend(true, this.settings, $.fn[NAME$7].defaults, window.Cool.settings.dialog, opts);
4328
+ } else {
4329
+ $.extend(true, this.settings, $.fn[NAME$7].defaults, opts);
4330
+ }
4331
+
4332
+ this.container = container;
4333
+ this.$container = $(this.container);
4334
+ this.debug = this.settings.debug;
4335
+ this.faPro = this.settings.faPro;
4336
+ this.dialogs = [];
4337
+ this.onInitialize = this.settings.onInitialize;
4338
+ this.onDestroy = this.settings.onDestroy;
4339
+ } // Init dialog
4340
+
4341
+
4342
+ init(opts) {
4343
+ let settings = {};
4344
+ $.extend(true, settings, this.settings, opts);
4345
+ let dialog = this.buildDialog(settings);
4346
+ this.show(dialog);
4347
+ this.bindEvents(dialog);
4348
+ this.onInit(dialog);
4349
+ return dialog;
4350
+ } // Remove plugin instance completely
4351
+
4352
+
4353
+ destroy() {
4354
+ this.$container.removeData(DATA_KEY$7);
4355
+ this.onDestroy();
4356
+ } // Build dialog
4357
+
4358
+
4359
+ buildDialog(settings) {
4360
+ let self = this;
4361
+ let dialog = {
4362
+ uuid: 'dialog-' + this.generateUUID(),
4363
+ title: settings.title,
4364
+ template: settings.template,
4365
+ body: settings.body,
4366
+ footer: settings.footer,
4367
+ size: settings.size,
4368
+ classes: settings.classes,
4369
+ centered: settings.centered,
4370
+ backdrop: settings.backdrop,
4371
+ preventScroll: settings.preventScroll,
4372
+ closeBtn: settings.closeBtn,
4373
+ animation: settings.animation,
4374
+ animationIn: settings.animationIn,
4375
+ animationOut: settings.animationOut,
4376
+ animationSpeed: settings.animationSpeed,
4377
+ callbacks: settings.callbacks,
4378
+ maxBodyHeight: settings.maxBodyHeight,
4379
+ actions: settings.actions,
4380
+ onInit: settings.onInit,
4381
+ onShow: settings.onShow,
4382
+ onClose: settings.onClose
4383
+ };
4384
+
4385
+ if (typeof dialog.template === 'function') {
4386
+ dialog.$el = $(dialog.template());
4387
+ } else {
4388
+ dialog.$el = $(this._renderTemplate(dialog));
4389
+ }
4390
+
4391
+ dialog.show = function () {
4392
+ self.show(dialog);
4393
+ };
4394
+
4395
+ dialog.close = function () {
4396
+ self.close(dialog);
4397
+ };
4398
+
4399
+ this.log(dialog);
4400
+ this.dialogs.push(dialog);
4401
+ return dialog;
4402
+ } // Bind events that trigger methods
4403
+
4404
+
4405
+ bindEvents(dialog) {
4406
+ let self = this;
4407
+ dialog.$el.on('click', '[data-dialog-close]', function (e) {
4408
+ dialog.$el.trigger('dialog.close');
4409
+
4410
+ if (typeof dialog.callbacks.close === 'function') {
4411
+ dialog.callbacks.close.call(self, function () {
4412
+ self.close(dialog);
4413
+ }, dialog);
4414
+ } else {
4415
+ self.close(dialog);
4416
+ }
4417
+ });
4418
+ dialog.$el.on('click', '[data-dialog-remove]', function (e) {
4419
+ dialog.$el.trigger('dialog.remove');
4420
+
4421
+ if (typeof dialog.callbacks.remove === 'function') {
4422
+ dialog.callbacks.remove.call(self, function () {
4423
+ self.close(dialog);
4424
+ }, dialog);
4425
+ }
4426
+ });
4427
+ dialog.$el.on('click', '[data-dialog-confirm]', debounce(function (e) {
4428
+ dialog.$el.trigger('dialog.close');
4429
+
4430
+ if (typeof dialog.callbacks.confirm === 'function') {
4431
+ dialog.callbacks.confirm.call(self, function () {
4432
+ self.close(dialog);
4433
+ }, dialog);
4434
+ } else {
4435
+ self.close(dialog);
4436
+ }
4437
+ }));
4438
+ } // Generate UUID
4439
+
4440
+
4441
+ generateUUID() {
4442
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
4443
+ let r = Math.random() * 16 | 0,
4444
+ v = c == 'x' ? r : r & 0x3 | 0x8;
4445
+ return v.toString(16);
4446
+ });
4447
+ } // Show
4448
+
4449
+
4450
+ show(dialog) {
4451
+ if (!this.$container.hasClass('has-dialogs')) {
4452
+ this.$container.addClass('has-dialogs');
4453
+ }
4454
+
4455
+ if (dialog.preventScroll && !this.$container.hasClass('dialog-prevent-scroll')) {
4456
+ this.$container.addClass('dialog-prevent-scroll');
4457
+ }
4458
+
4459
+ if (this.dialogs.length > 1) {
4460
+ let $prevDialog = $(this.dialogs).eq(-2)[0].$el;
4461
+ let zIndex = parseInt($prevDialog.css('z-index'), 10) + 1;
4462
+ dialog.$el.css('z-index', zIndex);
4463
+ $prevDialog.css({
4464
+ 'transition': 'opacity 0.3s',
4465
+ 'opacity': 0,
4466
+ 'visibility': 'visible'
4467
+ });
4468
+ }
4469
+
4470
+ if (dialog.backdrop && $('.dialog-backdrop').length < 1) {
4471
+ this.$container.append('<div class="dialog-backdrop"></div>');
4472
+ let checkForBackdrop = setInterval(() => {
4473
+ if (this.dialogs.length == 0 && $('.dialog-backdrop').length) {
4474
+ $('.dialog-backdrop').remove();
4475
+ clearInterval(checkForBackdrop);
4476
+ }
4477
+ }, 100);
4478
+ }
4479
+
4480
+ this.$container.append(dialog.$el);
4481
+
4482
+ if (dialog.animation) {
4483
+ dialog.$el.find('.dialog-content').addClass(dialog.animationSpeed).animateCss(dialog.animationIn);
4484
+ }
4485
+
4486
+ this.onShow(dialog);
4487
+ } // Close
4488
+
4489
+
4490
+ close(dialog) {
4491
+ let $prevDialog = null;
4492
+
4493
+ if (this.dialogs.length > 1) {
4494
+ $prevDialog = $(this.dialogs).eq(-2)[0].$el;
4495
+ }
4496
+
4497
+ if ($('.dialog[data-dialog-backdrop="true"]').length === 0 && $('.dialog-backdrop').length) {
4498
+ $('.dialog-backdrop').remove();
4499
+ }
4500
+
4501
+ if (dialog.animation) {
4502
+ dialog.$el.find('.dialog-content').animateCss(dialog.animationOut, () => {
4503
+ dialog.$el.remove();
4504
+ this.dialogs = $.grep(this.dialogs, function (item) {
4505
+ return item.uuid != dialog.uuid;
4506
+ });
4507
+
4508
+ if (this.dialogs.length == 0) {
4509
+ this.$container.removeClass('has-dialogs');
4510
+
4511
+ if (this.$container.hasClass('dialog-prevent-scroll')) {
4512
+ this.$container.removeClass('dialog-prevent-scroll');
4513
+ }
4514
+ } else {
4515
+ if ($prevDialog) {
4516
+ $prevDialog.css('opacity', 1);
4517
+ }
4518
+ }
4519
+ });
4520
+ } else {
4521
+ dialog.$el.remove();
4522
+ this.dialogs = $.grep(this.dialogs, function (item) {
4523
+ return item.uuid != dialog.uuid;
4524
+ });
4525
+
4526
+ if (this.dialogs.length == 0) {
4527
+ this.$container.removeClass('has-dialogs');
4528
+
4529
+ if (this.$container.hasClass('dialog-prevent-scroll')) {
4530
+ this.$container.removeClass('dialog-prevent-scroll');
4531
+ }
4532
+ } else {
4533
+ if ($prevDialog) {
4534
+ $prevDialog.css('opacity', 1);
4535
+ }
4536
+ }
4537
+ }
4538
+
4539
+ this.onClose(dialog);
4540
+ } // Initialize callback
4541
+
4542
+
4543
+ onInitialize() {
4544
+ let onInitialize = this.onInitialize;
4545
+
4546
+ if (typeof onInitialize === 'function') {
4547
+ onInitialize.call(this.container);
4548
+ }
4549
+ } // Destroy callback
4550
+
4551
+
4552
+ onDestroy() {
4553
+ let onDestroy = this.onDestroy;
4554
+
4555
+ if (typeof onDestroy === 'function') {
4556
+ onDestroy.call(this.container);
4557
+ }
4558
+ } // Init callback
4559
+
4560
+
4561
+ onInit(dialog) {
4562
+ let onInit = dialog.onInit;
4563
+
4564
+ if (typeof onInit === 'function') {
4565
+ onInit.call(dialog);
4566
+ }
4567
+ } // Show callback
4568
+
4569
+
4570
+ onShow(dialog) {
4571
+ let onShow = dialog.onShow;
4572
+
4573
+ if (typeof onShow === 'function') {
4574
+ onShow.call(dialog);
4575
+ }
4576
+ } // Close callback
4577
+
4578
+
4579
+ onClose(dialog) {
4580
+ let onClose = dialog.onClose;
4581
+
4582
+ if (typeof onClose === 'function') {
4583
+ onClose.call(dialog);
4584
+ }
4585
+ } // Debug log
4586
+
4587
+
4588
+ log() {
4589
+ if (this.debug) {
4590
+ if (typeof this.debug === 'function') {
4591
+ this.debug(...arguments);
4592
+ } else {
4593
+ console.log(...arguments);
4594
+ }
4595
+ }
4596
+ } // Render footer
4597
+
4598
+
4599
+ _renderFooter(dialog) {
4600
+ let footer = '';
4601
+
4602
+ if (typeof dialog.footer === 'function') {
4603
+ footer = dialog.footer();
4604
+ } else if (dialog.footer !== '' && dialog.footer !== false && dialog.footer !== true) {
4605
+ footer = dialog.footer;
4606
+ } else if (dialog.footer === true) {
4607
+ let btnCancel = '';
4608
+ let btnRemove = '';
4609
+ let btnConfirm = '';
4610
+ let btnStyle = '';
4611
+ let btnClasses = '';
4612
+ let btnAttrs = '';
4613
+
4614
+ if (dialog.actions.close.visible) {
4615
+ btnStyle = dialog.actions.close.primary ? 'btn-primary' : 'btn-secondary';
4616
+ btnClasses = dialog.actions.close.classes ? ' ' + dialog.actions.close.classes : '';
4617
+ btnAttrs = dialog.actions.close.attrs ? ' ' + dialog.actions.close.attrs : '';
4618
+ btnCancel = "\n <button type=\"button\" class=\"btn " + btnStyle + btnClasses + "\"" + btnAttrs + " data-dialog-close>\n " + dialog.actions.close.content + "\n </button>\n ";
4619
+ }
4620
+
4621
+ if (dialog.actions.remove.visible) {
4622
+ btnStyle = dialog.actions.remove.primary ? 'btn-primary' : 'btn-secondary';
4623
+ btnClasses = dialog.actions.remove.classes ? ' ' + dialog.actions.remove.classes : '';
4624
+ btnAttrs = dialog.actions.remove.attrs ? ' ' + dialog.actions.remove.attrs : '';
4625
+ btnRemove = "\n <button type=\"button\" class=\"btn " + btnStyle + btnClasses + "\"" + btnAttrs + " data-dialog-remove>\n " + dialog.actions.remove.content + "\n </button>\n ";
4626
+ }
4627
+
4628
+ if (dialog.actions.confirm.visible) {
4629
+ btnStyle = dialog.actions.confirm.primary ? 'btn-primary' : 'btn-secondary';
4630
+ btnClasses = dialog.actions.confirm.classes ? ' ' + dialog.actions.confirm.classes : '';
4631
+ btnAttrs = dialog.actions.confirm.attrs ? ' ' + dialog.actions.confirm.attrs : '';
4632
+ btnConfirm = "\n <button type=\"button\" class=\"btn " + btnStyle + btnClasses + "\"" + btnAttrs + " data-dialog-confirm>\n " + dialog.actions.confirm.content + "\n </button>\n ";
4633
+ }
4634
+
4635
+ footer = "\n " + btnCancel + "\n " + btnRemove + "\n " + btnConfirm + "\n ";
4636
+ } else {
4637
+ return footer;
4638
+ }
4639
+
4640
+ if (footer) {
4641
+ return "\n <div class=\"dialog-footer\">\n " + footer + "\n </div>\n ";
4642
+ }
4643
+ } // Render template
4644
+
4645
+
4646
+ _renderTemplate(dialog) {
4647
+ let faNameSpace = this.faPro ? 'far' : 'fas';
4648
+ let classes = dialog.classes ? ' ' + dialog.classes : '';
4649
+ let centered = dialog.centered ? ' dialog-centered' : '';
4650
+ let size = dialog.size ? ' dialog-' + dialog.size : '';
4651
+ let uuid = ' data-dialog-uuid="' + dialog.uuid + '"';
4652
+ let backdrop = dialog.backdrop ? ' data-dialog-backdrop="true"' : ' data-dialog-backdrop="false"';
4653
+ let title = dialog.title;
4654
+ let closeBtn = dialog.closeBtn ? "<button type=\"button\" data-dialog-close><i class=\"" + faNameSpace + " fa-times icon\"></i></button>" : '';
4655
+ let maxBodyHeight = dialog.maxBodyHeight ? ' style="max-height: ' + dialog.maxBodyHeight + 'px"' : '';
4656
+ let body = '';
4657
+
4658
+ let footer = this._renderFooter(dialog);
4659
+
4660
+ if (typeof dialog.body === 'function') {
4661
+ body = dialog.body();
4662
+ } else {
4663
+ body = dialog.body;
4664
+ }
4665
+
4666
+ return "\n <div class=\"dialog" + classes + centered + size + "\"" + uuid + backdrop + ">\n\n <div class=\"dialog-container\">\n\n <div class=\"dialog-content\">\n\n <div class=\"dialog-header\">\n\n <span class=\"dialog-title\">\n " + title + "\n </span>\n\n " + closeBtn + "\n\n </div>\n\n <div class=\"dialog-body\"" + maxBodyHeight + ">\n\n " + body + "\n\n </div>\n\n " + footer + "\n\n </div>\n\n </div>\n\n </div>\n ";
4667
+ }
4668
+
4669
+ static _jQueryInterface(config) {
4670
+ let data = $(this).data(DATA_KEY$7);
4671
+
4672
+ const _config = typeof config === 'object' && config;
4673
+
4674
+ if (!data) {
4675
+ data = new Dialog(this, _config);
4676
+ $(this).data(DATA_KEY$7, data);
4677
+ }
4678
+
4679
+ if (typeof config === 'string') {
4680
+ if (typeof data[config] === 'undefined') {
4681
+ throw new TypeError("No method named \"" + config + "\"");
4682
+ }
4683
+
4684
+ data[config]();
4685
+ }
4686
+ }
4687
+
4688
+ }
4689
+
4690
+ if (typeof $ !== 'undefined') {
4691
+ // jQuery
4692
+ const JQUERY_NO_CONFLICT = $.fn[NAME$7];
4693
+ $.fn[NAME$7] = Dialog._jQueryInterface;
4694
+ $.fn[NAME$7].Constructor = Dialog;
4695
+
4696
+ $.fn[NAME$7].noConflict = () => {
4697
+ $.fn[NAME$7] = JQUERY_NO_CONFLICT;
4698
+ return Dialog._jQueryInterface;
4699
+ };
4700
+
4701
+ $.fn[NAME$7].defaults = {
4702
+ title: '',
4703
+ template: '',
4704
+ body: '',
4705
+ footer: true,
4706
+ size: '',
4707
+ // sm/lg
4708
+ classes: '',
4709
+ centered: true,
4710
+ backdrop: true,
4711
+ preventScroll: true,
4712
+ closeBtn: true,
4713
+ animation: true,
4714
+ animationIn: 'zoomIn',
4715
+ animationOut: 'fadeOut',
4716
+ animationSpeed: 'fastest',
4717
+ callbacks: {},
4718
+ maxBodyHeight: window.innerHeight - 200,
4719
+ faPro: false,
4720
+ debug: true,
4721
+ onInitialize: null,
4722
+ onDestroy: null,
4723
+ onInit: null,
4724
+ onDestroy: null,
4725
+ onShow: null,
4726
+ onClose: null,
4727
+ actions: {
4728
+ close: {
4729
+ primary: false,
4730
+ visible: true,
4731
+ content: 'Close',
4732
+ classes: '',
4733
+ attrs: ''
4734
+ },
4735
+ remove: {
4736
+ primary: false,
4737
+ visible: true,
4738
+ content: 'Remove',
4739
+ classes: '',
4740
+ attrs: ''
4741
+ },
4742
+ confirm: {
4743
+ primary: true,
4744
+ visible: true,
4745
+ content: 'Confirm',
4746
+ classes: '',
4747
+ attrs: ''
4748
+ }
4749
+ }
4750
+ };
4751
+ }
4752
+
4753
+ var index_esm = {
4754
+ Common,
4755
+ Popover,
4756
+ Select,
4757
+ Dropdown,
4758
+ Tooltip,
4759
+ SectionTabs,
4760
+ Collapse,
4761
+ Toast,
4762
+ Dialog
4763
+ };
4764
+
4765
+ export default index_esm;
4766
+ //# sourceMappingURL=cool.esm.js.map