@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,575 @@
1
+ import 'jquery';
2
+ import { debounce, touchEvents } from './util/index';
3
+ import AbstractUIComponent from './abstract-ui-component';
4
+
5
+ const NAME = 'coolTooltip';
6
+ const DATA_KEY = 'plugin_coolTooltip';
7
+
8
+ class Tooltip extends AbstractUIComponent {
9
+
10
+ constructor(el, opts) {
11
+
12
+ super();
13
+
14
+ this.opts = {};
15
+
16
+ if (window.Cool.settings.tooltip) {
17
+
18
+ $.extend(true, this.opts, $.fn[NAME].defaults, window.Cool.settings.tooltip, opts);
19
+
20
+ } else {
21
+
22
+ $.extend(true, this.opts, $.fn[NAME].defaults, opts);
23
+ }
24
+
25
+ this.el = el;
26
+ this.debug = this.opts.debug;
27
+ this.init();
28
+ }
29
+
30
+ // Init plugin
31
+ init() {
32
+
33
+ this.buildCache();
34
+ this.bindEvents();
35
+ this.onInit();
36
+ }
37
+
38
+ // Remove plugin instance completely
39
+ destroy() {
40
+
41
+ this.unbindEvents();
42
+ this.$el.removeData(DATA_KEY);
43
+ this.onDestroy();
44
+ }
45
+
46
+ // Update plugin data
47
+ update() {
48
+
49
+ this.buildCache();
50
+ this.onUpdate();
51
+ }
52
+
53
+ // Cache DOM nodes for performance
54
+ buildCache() {
55
+
56
+ this.$el = $(this.el);
57
+ this.$container = this.$el.data('container') ? $(this.$el.data('container')) : $(this.opts.container);
58
+ this.id = 'tooltip-'+this.generateUUID();
59
+ this.animation = this.$el.data('animation') ? this.$el.data('animation') : this.opts.animation;
60
+ this.animationIn = this.$el.data('animationIn') ? this.$el.data('animationIn') : this.opts.animationIn;
61
+ this.animationOut = this.$el.data('animationOut') ? this.$el.data('animationOut') : this.opts.animationOut;
62
+ this.animationSpeed = this.$el.data('animationSpeed') ? this.$el.data('animationSpeed') : this.opts.animationSpeed;
63
+ this.placement = this.$el.data('placement') ? this.$el.data('placement') : this.opts.placement;
64
+ this.placementChanged = false;
65
+ this.content = this.$el.data('content') ? this.$el.data('content') : this.opts.content;
66
+ }
67
+
68
+ // Bind events that trigger methods
69
+ bindEvents() {
70
+
71
+ this.$el.on('mouseenter'+'.'+NAME, () => {
72
+
73
+ this.show();
74
+ });
75
+
76
+ this.$el.on('mouseleave'+'.'+NAME, () => {
77
+
78
+ this.close();
79
+ });
80
+
81
+ $(window).on('resize', debounce(() => {
82
+
83
+ if (this.$tooltip) {
84
+ this.setPosition();
85
+ this.onUpdate();
86
+ }
87
+ }, 250));
88
+ }
89
+
90
+ // Unbind events that trigger methods
91
+ unbindEvents() {
92
+
93
+ this.$el.off('.'+NAME);
94
+ }
95
+
96
+ // Generate UUID
97
+ generateUUID() {
98
+
99
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
100
+ let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
101
+ return v.toString(16);
102
+ });
103
+ }
104
+
105
+ // Build tooltip
106
+ buildTooltip() {
107
+
108
+ this.$tooltip = $(`
109
+
110
+ <div class="tooltip" role="tooltip" id="${this.id}">
111
+
112
+ <div class="arrow"></div>
113
+
114
+ <div class="tooltip-inner">${this.content}</div>
115
+
116
+ </div>
117
+
118
+ `);
119
+
120
+ this.$container.append(this.$tooltip);
121
+ this.$arrow = this.$tooltip.find('.arrow');
122
+
123
+ this.log(this.$el);
124
+ this.log(this.$container);
125
+ this.log(this.$tooltip);
126
+ this.log(this.$arrow);
127
+ this.log('Id: '+this.id);
128
+ this.log('Animation: '+this.animation);
129
+ this.log('Animation in: '+this.animationIn);
130
+ this.log('Animation out: '+this.animationOut);
131
+ this.log('Animation speed: '+this.animationSpeed);
132
+ this.log('Placement: '+this.placement);
133
+ this.log('Content: '+this.content);
134
+ }
135
+
136
+ // Set positions
137
+ setPosition(placement) {
138
+
139
+ if (typeof placement === 'undefined' || placement === null) {
140
+ placement = this.placement;
141
+ }
142
+
143
+ this.$tooltip.addClass('tooltip-'+placement);
144
+
145
+ let containerInnerWidth = this.$container.innerWidth();
146
+ let containerInnerHeight = this.$container.innerHeight();
147
+ let tooltipWidth = this.$tooltip.outerWidth(true);
148
+ let tooltipHeight = this.$tooltip.outerHeight(true);
149
+ let tooltipTriggerWidth = this.$el.outerWidth();
150
+ let tooltipTriggerHeight = this.$el.outerHeight();
151
+ let tooltipTriggerPosX = this.$el.offset().left;
152
+ let tooltipTriggerPosY = this.$el.offset().top;
153
+ let arrowWidth = this.$arrow.outerWidth(true);
154
+ let arrowHeight = this.$arrow.outerHeight(true);
155
+ let arrowPos;
156
+ let tooltipPosX;
157
+ let tooltipPosY;
158
+
159
+ if (placement === 'top') {
160
+
161
+ tooltipPosX = Math.round(tooltipTriggerPosX - (tooltipWidth - tooltipTriggerWidth) / 2);
162
+ tooltipPosY = Math.round(tooltipTriggerPosY - tooltipHeight);
163
+ arrowPos = Math.round(tooltipWidth / 2 - arrowWidth / 2);
164
+
165
+ this.$arrow.css({
166
+ left: arrowPos+'px'
167
+ });
168
+
169
+ } else if (placement === 'right') {
170
+
171
+ tooltipPosX = Math.round(tooltipTriggerPosX + tooltipTriggerWidth);
172
+ tooltipPosY = Math.round(tooltipTriggerPosY - (tooltipHeight - tooltipTriggerHeight) / 2);
173
+ arrowPos = Math.round(tooltipHeight / 2 - arrowHeight / 2);
174
+
175
+ this.$arrow.css({
176
+ top: arrowPos+'px'
177
+ });
178
+
179
+ } else if (placement === 'bottom') {
180
+
181
+ tooltipPosX = Math.round(tooltipTriggerPosX - (tooltipWidth - tooltipTriggerWidth) / 2);
182
+ tooltipPosY = Math.round(tooltipTriggerPosY + tooltipTriggerHeight);
183
+ arrowPos = Math.round(tooltipWidth / 2 - arrowWidth / 2);
184
+
185
+ this.$arrow.css({
186
+ left: arrowPos+'px'
187
+ });
188
+
189
+ } else if (placement === 'left') {
190
+
191
+ tooltipPosX = Math.round(tooltipTriggerPosX - tooltipWidth);
192
+ tooltipPosY = Math.round(tooltipTriggerPosY - (tooltipHeight - tooltipTriggerHeight) / 2);
193
+ arrowPos = Math.round(tooltipHeight / 2 - arrowHeight / 2);
194
+
195
+ this.$arrow.css({
196
+ top: arrowPos+'px'
197
+ });
198
+ }
199
+
200
+ this.$tooltip.css({
201
+ position: 'absolute',
202
+ top: '0px',
203
+ left: '0px',
204
+ transform: 'translate3d('+tooltipPosX+'px, '+tooltipPosY+'px, 0px)',
205
+ 'will-change': 'transform'
206
+ });
207
+
208
+ // Correct placement if tooltip goes outside of container
209
+ let tooltipOverflowCount = 0;
210
+ let tooltipPosition = {
211
+ left: this.$tooltip.position().left,
212
+ top: this.$tooltip.position().top,
213
+ right: containerInnerWidth - (this.$tooltip.position().left + tooltipWidth),
214
+ bottom: containerInnerHeight - (this.$tooltip.position().top + tooltipHeight),
215
+ };
216
+ let tooltipOverflow = {
217
+ left: false,
218
+ top: false,
219
+ right: false,
220
+ bottom: false
221
+ };
222
+
223
+ if (tooltipPosition.right < 0) {
224
+
225
+ tooltipOverflow.right = true;
226
+ tooltipOverflowCount++;
227
+
228
+ this.log('Tooltip overflowing from right');
229
+ }
230
+
231
+ if (tooltipPosition.left < 0) {
232
+
233
+ tooltipOverflow.left = true;
234
+ tooltipOverflowCount++;
235
+
236
+ this.log('Tooltip overflowing from left');
237
+ }
238
+
239
+ if (tooltipPosition.bottom < 0) {
240
+
241
+ tooltipOverflow.bottom = true;
242
+ tooltipOverflowCount++;
243
+
244
+ this.log('Tooltip overflowing from bottom');
245
+ }
246
+
247
+ if (tooltipPosition.top < 0) {
248
+
249
+ tooltipOverflow.top = true;
250
+ tooltipOverflowCount++;
251
+
252
+ this.log('Tooltip overflowing from top');
253
+ }
254
+
255
+ if (tooltipOverflowCount > 0) {
256
+
257
+ if (!this.placementChanged && tooltipOverflow.left && tooltipPosition.right > tooltipWidth) {
258
+
259
+ this.log('Changing tooltip placement to right');
260
+
261
+ this.placementChanged = true;
262
+ this.$tooltip.removeClass('tooltip-'+placement);
263
+ this.$arrow.removeAttr('style');
264
+ this.setPosition('right');
265
+
266
+ } else if (!this.placementChanged && tooltipOverflow.top && tooltipPosition.top > tooltipHeight) {
267
+
268
+ this.log('Changing tooltip placement to bottom');
269
+
270
+ this.placementChanged = true;
271
+ this.$tooltip.removeClass('tooltip-'+placement);
272
+ this.$arrow.removeAttr('style');
273
+ this.setPosition('bottom');
274
+
275
+ } else if (!this.placementChanged && tooltipOverflow.right && tooltipPosition.left > tooltipWidth) {
276
+
277
+ this.log('Changing tooltip placement to left');
278
+
279
+ this.placementChanged = true;
280
+ this.$tooltip.removeClass('tooltip-'+placement);
281
+ this.$arrow.removeAttr('style');
282
+ this.setPosition('left');
283
+
284
+ } else if (!this.placementChanged && tooltipOverflow.bottom && tooltipPosition.top > tooltipHeight) {
285
+
286
+ this.log('Changing tooltip placement to top');
287
+
288
+ this.placementChanged = true;
289
+ this.$tooltip.removeClass('tooltip-'+placement);
290
+ this.$arrow.removeAttr('style');
291
+ this.setPosition('top');
292
+
293
+ } else if (!this.placementChanged && (placement !== 'top' || placement !== 'bottom') && (tooltipOverflow.left || tooltipOverflow.right)) {
294
+
295
+ if (tooltipPosition.top > tooltipPosition.bottom) {
296
+
297
+ this.log('Changing tooltip placement to top');
298
+
299
+ this.placementChanged = true;
300
+ this.$tooltip.removeClass('tooltip-'+placement);
301
+ this.$arrow.removeAttr('style');
302
+ this.setPosition('top');
303
+
304
+ } else {
305
+
306
+ this.log('Changing tooltip placement to bottom');
307
+
308
+ this.placementChanged = true;
309
+ this.$tooltip.removeClass('tooltip-'+placement);
310
+ this.$arrow.removeAttr('style');
311
+ this.setPosition('bottom');
312
+ }
313
+
314
+ } else {
315
+
316
+ this.fixTooltipPosition = true;
317
+ }
318
+
319
+ if (this.fixTooltipPosition) {
320
+
321
+ this.log('Adjusting tooltip size or position in order to tooltip fit in the container');
322
+
323
+ if (tooltipOverflow.left) {
324
+
325
+ this.log('Tooltip overflowing from left');
326
+
327
+ let overflowAmount = Math.abs(tooltipPosition.left);
328
+ let excludePlacements = ['top', 'bottom'];
329
+
330
+ if ((tooltipTriggerPosX >= tooltipPosX + overflowAmount) && excludePlacements.indexOf(placement) < 0) {
331
+
332
+ this.log('Tooltip adjusting width');
333
+
334
+ tooltipWidth -= overflowAmount;
335
+ tooltipPosX += overflowAmount;
336
+
337
+ } else {
338
+
339
+ this.log('Tooltip adjusting position x');
340
+
341
+ tooltipPosX += overflowAmount;
342
+ arrowPos -= overflowAmount;
343
+ }
344
+ }
345
+
346
+ if (tooltipOverflow.top) {
347
+
348
+ this.log('Tooltip overflowing from top');
349
+
350
+ let overflowAmount = Math.abs(tooltipPosition.top);
351
+
352
+ this.log('Tooltip adjusting position y');
353
+
354
+ tooltipPosY += overflowAmount;
355
+ arrowPos -= overflowAmount;
356
+ }
357
+
358
+ if (tooltipOverflow.right) {
359
+
360
+ this.log('Tooltip overflowing from right');
361
+
362
+ let overflowAmount = Math.abs(tooltipPosition.right);
363
+ let excludePlacements = ['top', 'bottom'];
364
+
365
+ if ((tooltipTriggerPosX <= tooltipPosX - overflowAmount) && excludePlacements.indexOf(placement) < 0) {
366
+
367
+ this.log('Tooltip adjusting width');
368
+
369
+ tooltipWidth -= overflowAmount;
370
+
371
+ } else {
372
+
373
+ this.log('Tooltip adjusting position x');
374
+
375
+ tooltipPosX -= overflowAmount;
376
+ arrowPos += overflowAmount;
377
+ }
378
+ }
379
+
380
+ if (tooltipOverflow.bottom) {
381
+
382
+ this.log('Tooltip overflowing from bottom');
383
+
384
+ let overflowAmount = Math.abs(tooltipPosition.bottom);
385
+
386
+ this.log('Tooltip adjusting position y');
387
+
388
+ tooltipPosY -= overflowAmount;
389
+ arrowPos += overflowAmount;
390
+ }
391
+
392
+ if (placement === 'top') {
393
+
394
+ this.$arrow.css({
395
+ left: arrowPos+'px'
396
+ });
397
+
398
+ } else if (placement === 'right') {
399
+
400
+ this.$arrow.css({
401
+ top: arrowPos+'px'
402
+ });
403
+
404
+ } else if (placement === 'bottom') {
405
+
406
+ this.$arrow.css({
407
+ left: arrowPos+'px'
408
+ });
409
+
410
+ } else if (placement === 'left') {
411
+
412
+ this.$arrow.css({
413
+ top: arrowPos+'px'
414
+ });
415
+ }
416
+
417
+ this.$tooltip.css({
418
+ width: tooltipWidth,
419
+ transform: 'translate3d('+tooltipPosX+'px, '+tooltipPosY+'px, 0px)'
420
+ });
421
+
422
+ this.fixTooltipPosition = false;
423
+
424
+ this.log('Tooltip placement changed: '+this.placementChanged);
425
+ this.log('Tooltip container inner width: '+containerInnerWidth+'px');
426
+ this.log('Tooltip container inner height: '+containerInnerHeight+'px');
427
+ this.log('Tooltip trigger width: '+tooltipTriggerWidth+'px');
428
+ this.log('Tooltip trigger height: '+tooltipTriggerHeight+'px');
429
+ this.log('Tooltip trigger position x: '+tooltipTriggerPosX+'px');
430
+ this.log('Tooltip trigger position Y: '+tooltipTriggerPosY+'px');
431
+ this.log('Tooltip width: '+tooltipWidth+'px');
432
+ this.log('Tooltip height: '+tooltipHeight+'px');
433
+ this.log('Tooltip position x: '+tooltipPosX+'px');
434
+ this.log('Tooltip position y: '+tooltipPosY+'px');
435
+ this.log('Tooltip position left: '+tooltipPosition.left+'px');
436
+ this.log('Tooltip position top: '+tooltipPosition.top+'px');
437
+ this.log('Tooltip position right: '+tooltipPosition.right+'px');
438
+ this.log('Tooltip position bottom: '+tooltipPosition.bottom+'px');
439
+ }
440
+
441
+ } else {
442
+
443
+ this.log('Tooltip placement changed: '+this.placementChanged);
444
+ this.log('Tooltip container inner width: '+containerInnerWidth+'px');
445
+ this.log('Tooltip container inner height: '+containerInnerHeight+'px');
446
+ this.log('Tooltip trigger width: '+tooltipTriggerWidth+'px');
447
+ this.log('Tooltip trigger height: '+tooltipTriggerHeight+'px');
448
+ this.log('Tooltip trigger position x: '+tooltipTriggerPosX+'px');
449
+ this.log('Tooltip trigger position Y: '+tooltipTriggerPosY+'px');
450
+ this.log('Tooltip width: '+tooltipWidth+'px');
451
+ this.log('Tooltip height: '+tooltipHeight+'px');
452
+ this.log('Tooltip position x: '+tooltipPosX+'px');
453
+ this.log('Tooltip position y: '+tooltipPosY+'px');
454
+ this.log('Tooltip position left: '+tooltipPosition.left+'px');
455
+ this.log('Tooltip position top: '+tooltipPosition.top+'px');
456
+ this.log('Tooltip position right: '+tooltipPosition.right+'px');
457
+ this.log('Tooltip position bottom: '+tooltipPosition.bottom+'px');
458
+ }
459
+ }
460
+
461
+ // Show
462
+ show() {
463
+
464
+ if (this.$tooltip) {
465
+ return;
466
+ }
467
+
468
+ this.buildTooltip();
469
+ this.setPosition();
470
+
471
+ if (this.animation) {
472
+
473
+ this.$tooltip.addClass(this.animationSpeed);
474
+ this.$tooltip.animateCss(this.animationIn);
475
+ this.$tooltip.addClass('show');
476
+ this.$tooltip.attr('id', this.id);
477
+ this.$el.attr('data-tooltip', this.id);
478
+
479
+ } else {
480
+
481
+ this.$tooltip.addClass('show');
482
+ this.$tooltip.attr('id', this.id);
483
+ this.$el.attr('data-tooltip', this.id);
484
+ }
485
+
486
+ this.onShow();
487
+ }
488
+
489
+ // Close
490
+ close() {
491
+
492
+ if (!this.$tooltip) {
493
+ return;
494
+ }
495
+
496
+ if (this.animation && !this.$tooltip.hasClass('animated')) {
497
+
498
+ this.$tooltip.animateCss(this.animationOut, () => {
499
+
500
+ this.$tooltip.remove();
501
+ this.$el.removeAttr('data-tooltip');
502
+ this.$tooltip = null;
503
+ this.placementChanged = false;
504
+
505
+ this.onClose();
506
+ });
507
+
508
+ } else {
509
+
510
+ this.$tooltip.remove();
511
+ this.$el.removeAttr('data-tooltip');
512
+ this.$tooltip = null;
513
+ this.placementChanged = false;
514
+
515
+ this.onClose();
516
+ }
517
+ }
518
+
519
+ static _jQueryInterface(config) {
520
+
521
+ return this.each(function() {
522
+
523
+ let data = $(this).data(DATA_KEY);
524
+ const _config = typeof config === 'object' && config;
525
+
526
+ if (!data) {
527
+ data = new Tooltip(this, _config);
528
+ $(this).data(DATA_KEY, data);
529
+ }
530
+
531
+ if (typeof config === 'string') {
532
+
533
+ if (typeof data[config] === 'undefined') {
534
+ throw new TypeError(`No method named "${config}"`)
535
+ }
536
+
537
+ data[config]()
538
+ }
539
+ });
540
+ }
541
+ }
542
+
543
+ if (typeof $ !== 'undefined') {
544
+
545
+ // jQuery
546
+ const JQUERY_NO_CONFLICT = $.fn[NAME];
547
+
548
+ $.fn[NAME] = Tooltip._jQueryInterface;
549
+ $.fn[NAME].Constructor = Tooltip;
550
+
551
+ $.fn[NAME].noConflict = () => {
552
+
553
+ $.fn[NAME] = JQUERY_NO_CONFLICT
554
+
555
+ return Tooltip._jQueryInterface
556
+ }
557
+
558
+ $.fn[NAME].defaults = {
559
+ container: 'body',
560
+ animation: false,
561
+ animationIn: 'fadeIn',
562
+ animationOut: 'fadeOut',
563
+ animationSpeed: 'fastest',
564
+ placement: 'bottom',
565
+ content: '',
566
+ onInit: null,
567
+ onUpdate: null,
568
+ onDestroy: null,
569
+ onShow: null,
570
+ onClose: null,
571
+ debug: false
572
+ }
573
+ }
574
+
575
+ export default Tooltip;
@@ -0,0 +1,22 @@
1
+ import 'jquery';
2
+
3
+ $.fn.extend({
4
+ animateCss: function (animationName, callback) {
5
+
6
+ var el = this;
7
+ var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
8
+
9
+ el.addClass('animated ' + animationName).one(animationEnd, function(e) {
10
+
11
+ $(this).removeClass('animated ' + animationName);
12
+
13
+ if (callback) {
14
+ callback();
15
+ }
16
+
17
+ }).children().on(animationEnd, function(e) {
18
+
19
+ e.stopPropagation();
20
+ });
21
+ }
22
+ });
@@ -0,0 +1,112 @@
1
+ import 'jquery';
2
+
3
+ const debounce = function (func, wait, immediate) {
4
+
5
+ let timeout;
6
+
7
+ return function() {
8
+
9
+ let context = this;
10
+ let args = arguments;
11
+ let later = function() {
12
+
13
+ timeout = null;
14
+
15
+ if (!immediate) {
16
+ func.apply(context, args)
17
+ };
18
+ };
19
+
20
+ let callNow = immediate && !timeout;
21
+
22
+ clearTimeout(timeout);
23
+
24
+ timeout = setTimeout(later, wait);
25
+
26
+ if (callNow) {
27
+ func.apply(context, args);
28
+ }
29
+ };
30
+ };
31
+
32
+ const shallowProperty = function(key) {
33
+
34
+ return function(obj) {
35
+
36
+ return obj == null ? void 0 : obj[key];
37
+ };
38
+ };
39
+
40
+ const isArrayLike = function(collection) {
41
+
42
+ let length = shallowProperty('length');
43
+
44
+ return typeof length == 'number' && length >= 0 && length <= Math.pow(2, 53) - 1;
45
+ };
46
+
47
+ const optimizeCb = function(func, context, argCount) {
48
+
49
+ if (context === void 0) {
50
+ return func;
51
+ }
52
+
53
+ switch (argCount == null ? 3 : argCount) {
54
+
55
+ case 1: return function(value) {
56
+ return func.call(context, value);
57
+ };
58
+
59
+ case 3: return function(value, index, collection) {
60
+ return func.call(context, value, index, collection);
61
+ };
62
+ case 4: return function(accumulator, value, index, collection) {
63
+ return func.call(context, accumulator, value, index, collection);
64
+ };
65
+ }
66
+
67
+ return function() {
68
+ return func.apply(context, arguments);
69
+ };
70
+ };
71
+
72
+ const each = function(obj, iteratee, context) {
73
+
74
+ iteratee = optimizeCb(iteratee, context);
75
+
76
+ let i;
77
+ let length;
78
+
79
+ if (isArrayLike(obj)) {
80
+
81
+ for (i = 0, length = obj.length; i < length; i++) {
82
+ iteratee(obj[i], i, obj);
83
+ }
84
+
85
+ } else {
86
+
87
+ let keys = Object.keys(obj);
88
+
89
+ for (i = 0, length = keys.length; i < length; i++) {
90
+ iteratee(obj[keys[i]], keys[i], obj);
91
+ }
92
+ }
93
+
94
+ return obj;
95
+ };
96
+
97
+ const touchEvents = function () {
98
+
99
+ let result = false;
100
+
101
+ if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
102
+ result = true;
103
+ }
104
+
105
+ return result;
106
+ };
107
+
108
+ export {
109
+ debounce,
110
+ touchEvents,
111
+ each
112
+ }