@finqu/cool 1.2.29 → 1.3.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 (206) hide show
  1. package/README.md +680 -1
  2. package/dist/css/cool.css +23575 -16644
  3. package/dist/css/cool.css.map +1 -154
  4. package/dist/css/cool.min.css +89 -3
  5. package/dist/css/cool.min.css.map +1 -1
  6. package/dist/js/cool.bundle.js +15402 -3800
  7. package/dist/js/cool.bundle.js.map +1 -1
  8. package/dist/js/cool.bundle.min.js +20 -8
  9. package/dist/js/cool.bundle.min.js.map +1 -1
  10. package/dist/js/cool.esm.js +4269 -3360
  11. package/dist/js/cool.esm.js.map +1 -1
  12. package/dist/js/cool.esm.min.js +9 -8
  13. package/dist/js/cool.esm.min.js.map +1 -1
  14. package/dist/js/cool.js +4271 -3362
  15. package/dist/js/cool.js.map +1 -1
  16. package/dist/js/cool.min.js +9 -8
  17. package/dist/js/cool.min.js.map +1 -1
  18. package/package.json +94 -61
  19. package/.babelrc.js +0 -20
  20. package/.browserslistrc +0 -13
  21. package/build/.eslintrc.json +0 -10
  22. package/build/banner.js +0 -14
  23. package/build/build-plugins.js +0 -92
  24. package/build/rollup.config.js +0 -46
  25. package/dist/css/cool-grid.css +0 -4390
  26. package/dist/css/cool-grid.css.map +0 -30
  27. package/dist/css/cool-grid.min.css +0 -7
  28. package/dist/css/cool-grid.min.css.map +0 -1
  29. package/dist/css/cool-reboot.css +0 -286
  30. package/dist/css/cool-reboot.css.map +0 -62
  31. package/dist/css/cool-reboot.min.css +0 -7
  32. package/dist/css/cool-reboot.min.css.map +0 -1
  33. package/html/index.html +0 -2703
  34. package/js/dist/collapse.js +0 -5535
  35. package/js/dist/collapse.js.map +0 -1
  36. package/js/dist/common.js +0 -21996
  37. package/js/dist/common.js.map +0 -1
  38. package/js/dist/cooldropdown.js +0 -467
  39. package/js/dist/cooldropdown.js.map +0 -1
  40. package/js/dist/coolpopover.js +0 -391
  41. package/js/dist/coolpopover.js.map +0 -1
  42. package/js/dist/coolsectiontabs.js +0 -256
  43. package/js/dist/coolsectiontabs.js.map +0 -1
  44. package/js/dist/coolselect.js +0 -796
  45. package/js/dist/coolselect.js.map +0 -1
  46. package/js/dist/cooltooltip.js +0 -360
  47. package/js/dist/cooltooltip.js.map +0 -1
  48. package/js/dist/coolui.js +0 -73
  49. package/js/dist/coolui.js.map +0 -1
  50. package/js/dist/dropdown.js +0 -27421
  51. package/js/dist/dropdown.js.map +0 -1
  52. package/js/dist/popover.js +0 -9472
  53. package/js/dist/popover.js.map +0 -1
  54. package/js/dist/sectiontabs.js +0 -4483
  55. package/js/dist/sectiontabs.js.map +0 -1
  56. package/js/dist/select.js +0 -37080
  57. package/js/dist/select.js.map +0 -1
  58. package/js/dist/tooltip.js +0 -8786
  59. package/js/dist/tooltip.js.map +0 -1
  60. package/js/index.esm.js +0 -21
  61. package/js/index.umd.js +0 -21
  62. package/js/src/abstract-ui-component.js +0 -81
  63. package/js/src/collapse.js +0 -286
  64. package/js/src/common.js +0 -296
  65. package/js/src/dialog.js +0 -579
  66. package/js/src/dropdown.js +0 -525
  67. package/js/src/popover.js +0 -632
  68. package/js/src/section-tabs.js +0 -215
  69. package/js/src/select.js +0 -1342
  70. package/js/src/toast.js +0 -581
  71. package/js/src/tooltip.js +0 -591
  72. package/js/src/util/animate-css.js +0 -22
  73. package/js/src/util/index.js +0 -122
  74. package/js/src/util/perfect-scrollbar.js +0 -1316
  75. package/less/alert.less +0 -345
  76. package/less/badge.less +0 -38
  77. package/less/bootstrap-noconflict.less +0 -23
  78. package/less/bootstrap.less +0 -23
  79. package/less/button-group.less +0 -153
  80. package/less/buttons.less +0 -287
  81. package/less/dialog-noconflict.less +0 -174
  82. package/less/dialog.less +0 -203
  83. package/less/dropdown.less +0 -209
  84. package/less/forms.less +0 -770
  85. package/less/images.less +0 -242
  86. package/less/input-group.less +0 -163
  87. package/less/list-group.less +0 -73
  88. package/less/mixins/aspect-ratio.less +0 -23
  89. package/less/mixins/border-radius.less +0 -24
  90. package/less/mixins/box-shadow.less +0 -4
  91. package/less/mixins/buttons.less +0 -17
  92. package/less/mixins/caret.less +0 -51
  93. package/less/mixins/clearfix.less +0 -10
  94. package/less/mixins/gradients.less +0 -34
  95. package/less/mixins/nav-divider.less +0 -7
  96. package/less/mixins/object-fit.less +0 -13
  97. package/less/mixins/reset-text.less +0 -16
  98. package/less/mixins.less +0 -11
  99. package/less/package.json +0 -11
  100. package/less/pagination.less +0 -69
  101. package/less/popover.less +0 -143
  102. package/less/project.sublime-workspace +0 -774
  103. package/less/reboot.less +0 -235
  104. package/less/section.less +0 -793
  105. package/less/select.less +0 -150
  106. package/less/tables.less +0 -737
  107. package/less/tabs.less +0 -162
  108. package/less/tooltip.less +0 -87
  109. package/less/type.less +0 -71
  110. package/less/utilities/align.less +0 -27
  111. package/less/utilities/animate.less +0 -3512
  112. package/less/utilities/background.less +0 -70
  113. package/less/utilities/borders.less +0 -16
  114. package/less/utilities/color.less +0 -70
  115. package/less/utilities/cursor.less +0 -8
  116. package/less/utilities/display.less +0 -38
  117. package/less/utilities/embed.less +0 -61
  118. package/less/utilities/flex.less +0 -76
  119. package/less/utilities/jquery-ui.less +0 -116
  120. package/less/utilities/lazyload.less +0 -29
  121. package/less/utilities/overflow.less +0 -11
  122. package/less/utilities/pace.less +0 -25
  123. package/less/utilities/placeholder.less +0 -60
  124. package/less/utilities/position.less +0 -42
  125. package/less/utilities/scrollbar.less +0 -152
  126. package/less/utilities/spacing.less +0 -197
  127. package/less/utilities/text.less +0 -68
  128. package/less/utilities/transform.less +0 -7
  129. package/less/utilities.less +0 -21
  130. package/less/variables.less +0 -343
  131. package/scss/LISENCE +0 -15
  132. package/scss/_alert.scss +0 -102
  133. package/scss/_badge.scss +0 -102
  134. package/scss/_button-group.scss +0 -129
  135. package/scss/_buttons.scss +0 -248
  136. package/scss/_custom-forms.scss +0 -444
  137. package/scss/_dialog.scss +0 -160
  138. package/scss/_dropdown.scss +0 -233
  139. package/scss/_forms.scss +0 -258
  140. package/scss/_frame.scss +0 -627
  141. package/scss/_functions.scss +0 -124
  142. package/scss/_grid.scss +0 -35
  143. package/scss/_images.scss +0 -361
  144. package/scss/_input-group.scss +0 -285
  145. package/scss/_list-group.scss +0 -82
  146. package/scss/_mixins.scss +0 -34
  147. package/scss/_navbar.scss +0 -290
  148. package/scss/_notification.scss +0 -13
  149. package/scss/_pagination.scss +0 -88
  150. package/scss/_popover.scss +0 -167
  151. package/scss/_reboot.scss +0 -284
  152. package/scss/_root.scss +0 -15
  153. package/scss/_section.scss +0 -977
  154. package/scss/_select.scss +0 -187
  155. package/scss/_tables.scss +0 -735
  156. package/scss/_tabs.scss +0 -178
  157. package/scss/_toast.scss +0 -182
  158. package/scss/_tooltip.scss +0 -101
  159. package/scss/_type.scss +0 -129
  160. package/scss/_utilities.scss +0 -23
  161. package/scss/_variables.scss +0 -823
  162. package/scss/cool-grid.scss +0 -29
  163. package/scss/cool-reboot.scss +0 -11
  164. package/scss/cool.scss +0 -37
  165. package/scss/mixins/_alert-variant.scss +0 -20
  166. package/scss/mixins/_aspect-ratio.scss +0 -29
  167. package/scss/mixins/_background-variant.scss +0 -25
  168. package/scss/mixins/_badge-variant.scss +0 -36
  169. package/scss/mixins/_breakpoints.scss +0 -102
  170. package/scss/mixins/_buttons.scss +0 -104
  171. package/scss/mixins/_caret.scss +0 -80
  172. package/scss/mixins/_clearfix.scss +0 -10
  173. package/scss/mixins/_float.scss +0 -14
  174. package/scss/mixins/_forms.scss +0 -67
  175. package/scss/mixins/_gradients.scss +0 -40
  176. package/scss/mixins/_grid-framework.scss +0 -72
  177. package/scss/mixins/_grid.scss +0 -60
  178. package/scss/mixins/_nav-divider.scss +0 -9
  179. package/scss/mixins/_notification-variant.scss +0 -7
  180. package/scss/mixins/_object-fit.scss +0 -16
  181. package/scss/mixins/_reset-text.scss +0 -19
  182. package/scss/mixins/_text-emphasis.scss +0 -21
  183. package/scss/mixins/_text-hide.scss +0 -10
  184. package/scss/mixins/_text-truncate.scss +0 -81
  185. package/scss/mixins/_visibility.scss +0 -7
  186. package/scss/project.sublime-workspace +0 -491
  187. package/scss/utilities/_align.scss +0 -41
  188. package/scss/utilities/_animate.scss +0 -3512
  189. package/scss/utilities/_background.scss +0 -14
  190. package/scss/utilities/_borders.scss +0 -146
  191. package/scss/utilities/_clearfix.scss +0 -6
  192. package/scss/utilities/_collapse.scss +0 -33
  193. package/scss/utilities/_cursor.scss +0 -22
  194. package/scss/utilities/_display.scss +0 -16
  195. package/scss/utilities/_embed.scss +0 -78
  196. package/scss/utilities/_flex.scss +0 -52
  197. package/scss/utilities/_lazyload.scss +0 -31
  198. package/scss/utilities/_overflow.scss +0 -6
  199. package/scss/utilities/_perfect-scrollbar.scss +0 -141
  200. package/scss/utilities/_placeholder.scss +0 -77
  201. package/scss/utilities/_position.scss +0 -30
  202. package/scss/utilities/_sizing.scss +0 -32
  203. package/scss/utilities/_spacing.scss +0 -92
  204. package/scss/utilities/_text.scss +0 -99
  205. package/scss/utilities/_user-select.scss +0 -14
  206. package/scss/utilities/_visibility.scss +0 -10
package/js/src/tooltip.js DELETED
@@ -1,591 +0,0 @@
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
- this.trigger = this.$el.data('trigger') ? this.$el.data('trigger') : this.opts.trigger;
67
- }
68
-
69
- // Bind events that trigger methods
70
- bindEvents() {
71
-
72
- if (this.trigger === 'auto') {
73
-
74
- this.$el.on('mouseenter'+'.'+NAME, () => {
75
-
76
- this.show();
77
- });
78
-
79
- this.$el.on('mouseleave'+'.'+NAME, () => {
80
-
81
- this.close();
82
- });
83
-
84
- this.$el.on('blur'+'.'+NAME, () => {
85
-
86
- this.close();
87
- });
88
- }
89
-
90
- this.$el.on('destroyed'+'.'+NAME, () => {
91
-
92
- this.close();
93
- });
94
-
95
- $(window).on('resize', debounce(() => {
96
-
97
- if (this.$tooltip) {
98
- this.setPosition();
99
- this.onUpdate();
100
- }
101
- }, 250));
102
- }
103
-
104
- // Unbind events that trigger methods
105
- unbindEvents() {
106
-
107
- this.$el.off('.'+NAME);
108
- }
109
-
110
- // Generate UUID
111
- generateUUID() {
112
-
113
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
114
- let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
115
- return v.toString(16);
116
- });
117
- }
118
-
119
- // Build tooltip
120
- buildTooltip() {
121
-
122
- this.$tooltip = $(`
123
-
124
- <div class="tooltip" role="tooltip" id="${this.id}">
125
-
126
- <div class="arrow"></div>
127
-
128
- <div class="tooltip-inner">${this.content}</div>
129
-
130
- </div>
131
-
132
- `);
133
-
134
- this.$container.append(this.$tooltip);
135
- this.$arrow = this.$tooltip.find('.arrow');
136
-
137
- this.log(this.$el);
138
- this.log(this.$container);
139
- this.log(this.$tooltip);
140
- this.log(this.$arrow);
141
- this.log('Id: '+this.id);
142
- this.log('Animation: '+this.animation);
143
- this.log('Animation in: '+this.animationIn);
144
- this.log('Animation out: '+this.animationOut);
145
- this.log('Animation speed: '+this.animationSpeed);
146
- this.log('Placement: '+this.placement);
147
- this.log('Content: '+this.content);
148
- this.log('Trigger: '+this.trigger);
149
- }
150
-
151
- // Set positions
152
- setPosition(placement) {
153
-
154
- if (typeof placement === 'undefined' || placement === null) {
155
- placement = this.placement;
156
- }
157
-
158
- this.$tooltip.addClass('tooltip-'+placement);
159
-
160
- let containerInnerWidth = this.$container.innerWidth();
161
- let containerInnerHeight = this.$container.innerHeight();
162
- let tooltipWidth = this.$tooltip.outerWidth(true);
163
- let tooltipHeight = this.$tooltip.outerHeight(true);
164
- let tooltipTriggerWidth = this.$el.outerWidth();
165
- let tooltipTriggerHeight = this.$el.outerHeight();
166
- let tooltipTriggerPosX = this.$el.offset().left;
167
- let tooltipTriggerPosY = this.$el.offset().top;
168
- let arrowWidth = this.$arrow.outerWidth(true);
169
- let arrowHeight = this.$arrow.outerHeight(true);
170
- let arrowPos;
171
- let tooltipPosX;
172
- let tooltipPosY;
173
-
174
- if (placement === 'top') {
175
-
176
- tooltipPosX = Math.round(tooltipTriggerPosX - (tooltipWidth - tooltipTriggerWidth) / 2);
177
- tooltipPosY = Math.round(tooltipTriggerPosY - tooltipHeight);
178
- arrowPos = Math.round(tooltipWidth / 2 - arrowWidth / 2);
179
-
180
- this.$arrow.css({
181
- left: arrowPos+'px'
182
- });
183
-
184
- } else if (placement === 'right') {
185
-
186
- tooltipPosX = Math.round(tooltipTriggerPosX + tooltipTriggerWidth);
187
- tooltipPosY = Math.round(tooltipTriggerPosY - (tooltipHeight - tooltipTriggerHeight) / 2);
188
- arrowPos = Math.round(tooltipHeight / 2 - arrowHeight / 2);
189
-
190
- this.$arrow.css({
191
- top: arrowPos+'px'
192
- });
193
-
194
- } else if (placement === 'bottom') {
195
-
196
- tooltipPosX = Math.round(tooltipTriggerPosX - (tooltipWidth - tooltipTriggerWidth) / 2);
197
- tooltipPosY = Math.round(tooltipTriggerPosY + tooltipTriggerHeight);
198
- arrowPos = Math.round(tooltipWidth / 2 - arrowWidth / 2);
199
-
200
- this.$arrow.css({
201
- left: arrowPos+'px'
202
- });
203
-
204
- } else if (placement === 'left') {
205
-
206
- tooltipPosX = Math.round(tooltipTriggerPosX - tooltipWidth);
207
- tooltipPosY = Math.round(tooltipTriggerPosY - (tooltipHeight - tooltipTriggerHeight) / 2);
208
- arrowPos = Math.round(tooltipHeight / 2 - arrowHeight / 2);
209
-
210
- this.$arrow.css({
211
- top: arrowPos+'px'
212
- });
213
- }
214
-
215
- this.$tooltip.css({
216
- position: 'absolute',
217
- top: '0px',
218
- left: '0px',
219
- transform: 'translate3d('+tooltipPosX+'px, '+tooltipPosY+'px, 0px)',
220
- 'will-change': 'transform'
221
- });
222
-
223
- // Correct placement if tooltip goes outside of container
224
- let tooltipOverflowCount = 0;
225
- let tooltipPosition = {
226
- left: this.$tooltip.position().left,
227
- top: this.$tooltip.position().top,
228
- right: containerInnerWidth - (this.$tooltip.position().left + tooltipWidth),
229
- bottom: containerInnerHeight - (this.$tooltip.position().top + tooltipHeight),
230
- };
231
- let tooltipOverflow = {
232
- left: false,
233
- top: false,
234
- right: false,
235
- bottom: false
236
- };
237
-
238
- if (tooltipPosition.right < 0) {
239
-
240
- tooltipOverflow.right = true;
241
- tooltipOverflowCount++;
242
-
243
- this.log('Tooltip overflowing from right');
244
- }
245
-
246
- if (tooltipPosition.left < 0) {
247
-
248
- tooltipOverflow.left = true;
249
- tooltipOverflowCount++;
250
-
251
- this.log('Tooltip overflowing from left');
252
- }
253
-
254
- if (tooltipPosition.bottom < 0) {
255
-
256
- tooltipOverflow.bottom = true;
257
- tooltipOverflowCount++;
258
-
259
- this.log('Tooltip overflowing from bottom');
260
- }
261
-
262
- if (tooltipPosition.top < 0) {
263
-
264
- tooltipOverflow.top = true;
265
- tooltipOverflowCount++;
266
-
267
- this.log('Tooltip overflowing from top');
268
- }
269
-
270
- if (tooltipOverflowCount > 0) {
271
-
272
- if (!this.placementChanged && tooltipOverflow.left && tooltipPosition.right > tooltipWidth) {
273
-
274
- this.log('Changing tooltip placement to right');
275
-
276
- this.placementChanged = true;
277
- this.$tooltip.removeClass('tooltip-'+placement);
278
- this.$arrow.removeAttr('style');
279
- this.setPosition('right');
280
-
281
- } else if (!this.placementChanged && tooltipOverflow.top && tooltipPosition.top > tooltipHeight) {
282
-
283
- this.log('Changing tooltip placement to bottom');
284
-
285
- this.placementChanged = true;
286
- this.$tooltip.removeClass('tooltip-'+placement);
287
- this.$arrow.removeAttr('style');
288
- this.setPosition('bottom');
289
-
290
- } else if (!this.placementChanged && tooltipOverflow.right && tooltipPosition.left > tooltipWidth) {
291
-
292
- this.log('Changing tooltip placement to left');
293
-
294
- this.placementChanged = true;
295
- this.$tooltip.removeClass('tooltip-'+placement);
296
- this.$arrow.removeAttr('style');
297
- this.setPosition('left');
298
-
299
- } else if (!this.placementChanged && tooltipOverflow.bottom && tooltipPosition.top > tooltipHeight) {
300
-
301
- this.log('Changing tooltip placement to top');
302
-
303
- this.placementChanged = true;
304
- this.$tooltip.removeClass('tooltip-'+placement);
305
- this.$arrow.removeAttr('style');
306
- this.setPosition('top');
307
-
308
- } else if (!this.placementChanged && (placement !== 'top' || placement !== 'bottom') && (tooltipOverflow.left || tooltipOverflow.right)) {
309
-
310
- if (tooltipPosition.top > tooltipPosition.bottom) {
311
-
312
- this.log('Changing tooltip placement to top');
313
-
314
- this.placementChanged = true;
315
- this.$tooltip.removeClass('tooltip-'+placement);
316
- this.$arrow.removeAttr('style');
317
- this.setPosition('top');
318
-
319
- } else {
320
-
321
- this.log('Changing tooltip placement to bottom');
322
-
323
- this.placementChanged = true;
324
- this.$tooltip.removeClass('tooltip-'+placement);
325
- this.$arrow.removeAttr('style');
326
- this.setPosition('bottom');
327
- }
328
-
329
- } else {
330
-
331
- this.fixTooltipPosition = true;
332
- }
333
-
334
- if (this.fixTooltipPosition) {
335
-
336
- this.log('Adjusting tooltip size or position in order to tooltip fit in the container');
337
-
338
- if (tooltipOverflow.left) {
339
-
340
- this.log('Tooltip overflowing from left');
341
-
342
- let overflowAmount = Math.abs(tooltipPosition.left);
343
- let excludePlacements = ['top', 'bottom'];
344
-
345
- if ((tooltipTriggerPosX >= tooltipPosX + overflowAmount) && excludePlacements.indexOf(placement) < 0) {
346
-
347
- this.log('Tooltip adjusting width');
348
-
349
- tooltipWidth -= overflowAmount;
350
- tooltipPosX += overflowAmount;
351
-
352
- } else {
353
-
354
- this.log('Tooltip adjusting position x');
355
-
356
- tooltipPosX += overflowAmount;
357
- arrowPos -= overflowAmount;
358
- }
359
- }
360
-
361
- if (tooltipOverflow.top) {
362
-
363
- this.log('Tooltip overflowing from top');
364
-
365
- let overflowAmount = Math.abs(tooltipPosition.top);
366
-
367
- this.log('Tooltip adjusting position y');
368
-
369
- tooltipPosY += overflowAmount;
370
- arrowPos -= overflowAmount;
371
- }
372
-
373
- if (tooltipOverflow.right) {
374
-
375
- this.log('Tooltip overflowing from right');
376
-
377
- let overflowAmount = Math.abs(tooltipPosition.right);
378
- let excludePlacements = ['top', 'bottom'];
379
-
380
- if ((tooltipTriggerPosX <= tooltipPosX - overflowAmount) && excludePlacements.indexOf(placement) < 0) {
381
-
382
- this.log('Tooltip adjusting width');
383
-
384
- tooltipWidth -= overflowAmount;
385
-
386
- } else {
387
-
388
- this.log('Tooltip adjusting position x');
389
-
390
- tooltipPosX -= overflowAmount;
391
- arrowPos += overflowAmount;
392
- }
393
- }
394
-
395
- if (tooltipOverflow.bottom) {
396
-
397
- this.log('Tooltip overflowing from bottom');
398
-
399
- let overflowAmount = Math.abs(tooltipPosition.bottom);
400
-
401
- this.log('Tooltip adjusting position y');
402
-
403
- tooltipPosY -= overflowAmount;
404
- arrowPos += overflowAmount;
405
- }
406
-
407
- if (placement === 'top') {
408
-
409
- this.$arrow.css({
410
- left: arrowPos+'px'
411
- });
412
-
413
- } else if (placement === 'right') {
414
-
415
- this.$arrow.css({
416
- top: arrowPos+'px'
417
- });
418
-
419
- } else if (placement === 'bottom') {
420
-
421
- this.$arrow.css({
422
- left: arrowPos+'px'
423
- });
424
-
425
- } else if (placement === 'left') {
426
-
427
- this.$arrow.css({
428
- top: arrowPos+'px'
429
- });
430
- }
431
-
432
- this.$tooltip.css({
433
- width: tooltipWidth,
434
- transform: 'translate3d('+tooltipPosX+'px, '+tooltipPosY+'px, 0px)'
435
- });
436
-
437
- this.fixTooltipPosition = false;
438
-
439
- this.log('Tooltip placement changed: '+this.placementChanged);
440
- this.log('Tooltip container inner width: '+containerInnerWidth+'px');
441
- this.log('Tooltip container inner height: '+containerInnerHeight+'px');
442
- this.log('Tooltip trigger width: '+tooltipTriggerWidth+'px');
443
- this.log('Tooltip trigger height: '+tooltipTriggerHeight+'px');
444
- this.log('Tooltip trigger position x: '+tooltipTriggerPosX+'px');
445
- this.log('Tooltip trigger position Y: '+tooltipTriggerPosY+'px');
446
- this.log('Tooltip width: '+tooltipWidth+'px');
447
- this.log('Tooltip height: '+tooltipHeight+'px');
448
- this.log('Tooltip position x: '+tooltipPosX+'px');
449
- this.log('Tooltip position y: '+tooltipPosY+'px');
450
- this.log('Tooltip position left: '+tooltipPosition.left+'px');
451
- this.log('Tooltip position top: '+tooltipPosition.top+'px');
452
- this.log('Tooltip position right: '+tooltipPosition.right+'px');
453
- this.log('Tooltip position bottom: '+tooltipPosition.bottom+'px');
454
- }
455
-
456
- } else {
457
-
458
- this.log('Tooltip placement changed: '+this.placementChanged);
459
- this.log('Tooltip container inner width: '+containerInnerWidth+'px');
460
- this.log('Tooltip container inner height: '+containerInnerHeight+'px');
461
- this.log('Tooltip trigger width: '+tooltipTriggerWidth+'px');
462
- this.log('Tooltip trigger height: '+tooltipTriggerHeight+'px');
463
- this.log('Tooltip trigger position x: '+tooltipTriggerPosX+'px');
464
- this.log('Tooltip trigger position Y: '+tooltipTriggerPosY+'px');
465
- this.log('Tooltip width: '+tooltipWidth+'px');
466
- this.log('Tooltip height: '+tooltipHeight+'px');
467
- this.log('Tooltip position x: '+tooltipPosX+'px');
468
- this.log('Tooltip position y: '+tooltipPosY+'px');
469
- this.log('Tooltip position left: '+tooltipPosition.left+'px');
470
- this.log('Tooltip position top: '+tooltipPosition.top+'px');
471
- this.log('Tooltip position right: '+tooltipPosition.right+'px');
472
- this.log('Tooltip position bottom: '+tooltipPosition.bottom+'px');
473
- }
474
- }
475
-
476
- // Show
477
- show() {
478
-
479
- if (this.$tooltip) {
480
- return;
481
- }
482
-
483
- this.buildTooltip();
484
- this.setPosition();
485
-
486
- if (this.animation) {
487
-
488
- this.$tooltip.addClass(this.animationSpeed);
489
- this.$tooltip.animateCss(this.animationIn);
490
- this.$tooltip.addClass('show');
491
- this.$tooltip.attr('id', this.id);
492
- this.$el.attr('data-tooltip', this.id);
493
-
494
- } else {
495
-
496
- this.$tooltip.addClass('show');
497
- this.$tooltip.attr('id', this.id);
498
- this.$el.attr('data-tooltip', this.id);
499
- }
500
-
501
- this.onShow();
502
- }
503
-
504
- // Close
505
- close() {
506
-
507
- if (!this.$tooltip) {
508
- return;
509
- }
510
-
511
- if (this.animation && !this.$tooltip.hasClass('animated')) {
512
-
513
- this.$tooltip.animateCss(this.animationOut, () => {
514
-
515
- this.$tooltip.remove();
516
- this.$el.removeAttr('data-tooltip');
517
- this.$tooltip = null;
518
- this.placementChanged = false;
519
-
520
- this.onClose();
521
- });
522
-
523
- } else {
524
-
525
- this.$tooltip.remove();
526
- this.$el.removeAttr('data-tooltip');
527
- this.$tooltip = null;
528
- this.placementChanged = false;
529
-
530
- this.onClose();
531
- }
532
- }
533
-
534
- static _jQueryInterface(config) {
535
-
536
- return this.each(function() {
537
-
538
- let data = $(this).data(DATA_KEY);
539
- const _config = typeof config === 'object' && config;
540
-
541
- if (!data) {
542
- data = new Tooltip(this, _config);
543
- $(this).data(DATA_KEY, data);
544
- }
545
-
546
- if (typeof config === 'string') {
547
-
548
- if (typeof data[config] === 'undefined') {
549
- throw new TypeError(`No method named "${config}"`)
550
- }
551
-
552
- data[config]()
553
- }
554
- });
555
- }
556
- }
557
-
558
- if (typeof $ !== 'undefined') {
559
-
560
- // jQuery
561
- const JQUERY_NO_CONFLICT = $.fn[NAME];
562
-
563
- $.fn[NAME] = Tooltip._jQueryInterface;
564
- $.fn[NAME].Constructor = Tooltip;
565
-
566
- $.fn[NAME].noConflict = () => {
567
-
568
- $.fn[NAME] = JQUERY_NO_CONFLICT;
569
-
570
- return Tooltip._jQueryInterface;
571
- }
572
-
573
- $.fn[NAME].defaults = {
574
- container: 'body',
575
- animation: false,
576
- animationIn: 'fadeIn',
577
- animationOut: 'fadeOut',
578
- animationSpeed: 'fastest',
579
- placement: 'bottom',
580
- content: '',
581
- trigger: 'auto',
582
- onInit: null,
583
- onUpdate: null,
584
- onDestroy: null,
585
- onShow: null,
586
- onClose: null,
587
- debug: false
588
- }
589
- }
590
-
591
- export default Tooltip;
@@ -1,22 +0,0 @@
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
- });