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