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