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