@finqu/cool 1.2.29 → 2.0.2

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