uniform-ui 2.2.2 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assets/javascripts/uniform/checkbox.js +2 -2
- data/lib/assets/javascripts/uniform/component.js +65 -9
- data/lib/assets/javascripts/uniform/dom-helpers.js +32 -10
- data/lib/assets/javascripts/uniform/dropdown.js +106 -38
- data/lib/assets/javascripts/uniform/floating-label.js +3 -3
- data/lib/assets/javascripts/uniform/modal.js +21 -14
- data/lib/assets/javascripts/uniform/popover.js +186 -0
- data/lib/assets/javascripts/uniform/resizer.js +1 -1
- data/lib/assets/javascripts/uniform/select.js +51 -24
- data/lib/assets/javascripts/uniform/tooltip.js +18 -71
- data/lib/assets/javascripts/uniform.es5.js +1 -1
- data/lib/assets/javascripts/uniform.jquery.js +28 -0
- data/lib/assets/javascripts/uniform.js +3 -1
- data/lib/assets/stylesheets/uniform/components/alert.scss +2 -2
- data/lib/assets/stylesheets/uniform/components/buttons.scss +31 -15
- data/lib/assets/stylesheets/uniform/components/card.scss +3 -3
- data/lib/assets/stylesheets/uniform/components/dropdown.scss +23 -22
- data/lib/assets/stylesheets/uniform/components/form/checkbox-collection.scss +4 -4
- data/lib/assets/stylesheets/uniform/components/form/checkbox.scss +1 -1
- data/lib/assets/stylesheets/uniform/components/form/floating-label.scss +2 -1
- data/lib/assets/stylesheets/uniform/components/form/input-group.scss +2 -2
- data/lib/assets/stylesheets/uniform/components/form/tristate.scss +88 -0
- data/lib/assets/stylesheets/uniform/components/form.scss +12 -6
- data/lib/assets/stylesheets/uniform/components/grid.scss +21 -0
- data/lib/assets/stylesheets/uniform/components/label.scss +9 -7
- data/lib/assets/stylesheets/uniform/components/loaders.scss +39 -39
- data/lib/assets/stylesheets/uniform/components/nav.scss +8 -4
- data/lib/assets/stylesheets/uniform/components/row.scss +18 -10
- data/lib/assets/stylesheets/uniform/components/select.scss +42 -5
- data/lib/assets/stylesheets/uniform/components/table.scss +43 -9
- data/lib/assets/stylesheets/uniform/components/thumb.scss +1 -1
- data/lib/assets/stylesheets/uniform/components/tooltip.scss +8 -30
- data/lib/assets/stylesheets/uniform/defaults.scss +1 -6
- data/lib/assets/stylesheets/uniform/functions.scss +34 -4
- data/lib/assets/stylesheets/uniform/helpers/border.scss +10 -1
- data/lib/assets/stylesheets/uniform/helpers/colors.scss +3 -2
- data/lib/assets/stylesheets/uniform/helpers/position.scss +6 -0
- data/lib/assets/stylesheets/uniform/helpers/text.scss +11 -0
- data/lib/assets/stylesheets/uniform/helpers.scss +9 -3
- data/lib/assets/stylesheets/uniform/variables.scss +8 -6
- data/lib/uniform/version.rb +1 -1
- data/lib/uniform.rb +11 -3
- metadata +5 -4
@@ -0,0 +1,186 @@
|
|
1
|
+
import Component from './component';
|
2
|
+
import * as Helpers from './dom-helpers';
|
3
|
+
|
4
|
+
/*
|
5
|
+
Requirements
|
6
|
+
---
|
7
|
+
content: html|node
|
8
|
+
anchor: node
|
9
|
+
|
10
|
+
Options
|
11
|
+
---
|
12
|
+
align: [left|right|center|#%|#px] [top|center|bottom|#%|#px] | default: 'center bottom'
|
13
|
+
zIndex: # | default: unset
|
14
|
+
offset: {left: 0, top: 0}
|
15
|
+
*/
|
16
|
+
export default class Popover extends Component {
|
17
|
+
initialize (options) {
|
18
|
+
this.showing = false;
|
19
|
+
options = options || {};
|
20
|
+
this.options = {
|
21
|
+
zIndex: 2,
|
22
|
+
container: document.body,
|
23
|
+
align: 'center bottom',
|
24
|
+
anchor: document.body,
|
25
|
+
content: 'needs content',
|
26
|
+
offset: {left: 0, top: 0}
|
27
|
+
};
|
28
|
+
Object.assign(this.options, this.pick(options, Object.keys(this.options)));
|
29
|
+
|
30
|
+
this.listenTo(document, 'click', this.checkFocus);
|
31
|
+
this.listenTo(document, 'focusin', this.checkFocus);
|
32
|
+
this.listenTo(document, 'keyup', this.checkEscape);
|
33
|
+
this.listenTo(window, 'resize', () => {
|
34
|
+
this.resize.bind(this)()
|
35
|
+
});
|
36
|
+
|
37
|
+
if(typeof this.options.container == "string"){
|
38
|
+
this.options.container = Helpers.closest(this.options.anchor, this.options.container)
|
39
|
+
this.options.container = this.options.container || document.body
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
render () {
|
44
|
+
this.showing = true;
|
45
|
+
this.el.style.position = 'absolute';
|
46
|
+
this.el.style.zIndex = this.options.zIndex;
|
47
|
+
|
48
|
+
if(this.options.content instanceof Node)
|
49
|
+
this.el.appendChild(this.options.content);
|
50
|
+
else
|
51
|
+
this.el.innerHTML = this.options.content;
|
52
|
+
|
53
|
+
this.options.container.appendChild(this.el);
|
54
|
+
this.resize();
|
55
|
+
this.trigger('shown');
|
56
|
+
|
57
|
+
return this;
|
58
|
+
}
|
59
|
+
|
60
|
+
resize () {
|
61
|
+
this.setPosition();
|
62
|
+
|
63
|
+
var align = this.options.align.split(" ");
|
64
|
+
var reposition = false;
|
65
|
+
if (Helpers.offset(this.el).top + Helpers.outerHeight(this.el) > Math.max(document.body.offsetHeight, window.innerHeight)) {
|
66
|
+
align[1] = "top";
|
67
|
+
reposition = true;
|
68
|
+
}
|
69
|
+
if (Helpers.offset(this.el).top < 0) {
|
70
|
+
align[1] = "bottom";
|
71
|
+
reposition = true;
|
72
|
+
}
|
73
|
+
if (Helpers.offset(this.el).left < 0) {
|
74
|
+
align[0] = "right";
|
75
|
+
reposition = true;
|
76
|
+
}
|
77
|
+
if (Helpers.offset(this.el).left + Helpers.outerWidth(this.el) > document.body.offsetWidth) {
|
78
|
+
align[0] = "left";
|
79
|
+
reposition = true;
|
80
|
+
}
|
81
|
+
// if(reposition) this.setPosition(align.join(" "))
|
82
|
+
}
|
83
|
+
|
84
|
+
setPosition(align){
|
85
|
+
align = align || this.options.align;
|
86
|
+
var [leftAlign, topAlign] = align.split(" ");
|
87
|
+
leftAlign = leftAlign || "bottom";
|
88
|
+
|
89
|
+
var offset = Helpers.offset(this.options.anchor);
|
90
|
+
var container = this.options.container;
|
91
|
+
if(getComputedStyle(container)['position'] == "static") container = container.offsetParent;
|
92
|
+
if(!container) container = document.body;
|
93
|
+
|
94
|
+
var containerOffset = Helpers.offset(container);
|
95
|
+
offset = {
|
96
|
+
top: offset.top - containerOffset.top,
|
97
|
+
left: offset.left - containerOffset.left
|
98
|
+
}
|
99
|
+
|
100
|
+
var position = {};
|
101
|
+
if(leftAlign == 'left'){
|
102
|
+
position.right = Helpers.outerWidth(container) - offset.left;
|
103
|
+
} else if(leftAlign == 'center'){
|
104
|
+
position.left = offset.left + Helpers.outerWidth(this.options.anchor) / 2 - Helpers.outerWidth(this.el) / 2;
|
105
|
+
} else if (leftAlign == 'right'){
|
106
|
+
position.left = offset.left + Helpers.outerWidth(this.options.anchor);
|
107
|
+
} else if (leftAlign.includes("%")){
|
108
|
+
position.left = offset.left + Helpers.outerWidth(this.options.anchor) * parseInt(leftAlign) / 100;
|
109
|
+
} else if (leftAlign.includes("px")){
|
110
|
+
position.left = offset.left + Helpers.outerWidth(this.options.anchor) + parseInt(leftAlign);
|
111
|
+
}
|
112
|
+
|
113
|
+
if(topAlign == 'top'){
|
114
|
+
let height = Helpers.outerHeight(container);
|
115
|
+
if(container == document.body){
|
116
|
+
height = Math.max(height, document.documentElement.scrollHeight)
|
117
|
+
}
|
118
|
+
position.bottom = height - offset.top;
|
119
|
+
} else if(topAlign == 'center'){
|
120
|
+
position.top = offset.top + Helpers.outerHeight(this.options.anchor) / 2 - Helpers.outerHeight(this.el) / 2;
|
121
|
+
} else if (topAlign == 'bottom'){
|
122
|
+
position.top = offset.top + Helpers.outerHeight(this.options.anchor);
|
123
|
+
} else if (topAlign.includes("%")){
|
124
|
+
position.top = offset.top + Helpers.outerHeight(this.options.anchor) * parseInt(topAlign) / 100;
|
125
|
+
} else if (topAlign.includes("px")){
|
126
|
+
position.top = offset.top + Helpers.outerHeight(this.options.anchor) + parseInt(topAlign);
|
127
|
+
}
|
128
|
+
|
129
|
+
if(this.options.offset.left) position.left += parseInt(this.options.offset.left);
|
130
|
+
if(this.options.offset.left) position.right -= parseInt(this.options.offset.left);
|
131
|
+
if(this.options.offset.top) position.top += parseInt(this.options.offset.top);
|
132
|
+
if(this.options.offset.top) position.bottom -= parseInt(this.options.offset.top);
|
133
|
+
|
134
|
+
this.el.style.left = 'auto';
|
135
|
+
this.el.style.right = 'auto';
|
136
|
+
this.el.style.top = 'auto';
|
137
|
+
this.el.style.bottom = 'auto';
|
138
|
+
Helpers.removeClass(this.el, 'popover-left popover-right popover-center popover-top popover-bottom');
|
139
|
+
Helpers.addClass(this.el, 'popover-' + topAlign);
|
140
|
+
Helpers.addClass(this.el, 'popover-' + leftAlign);
|
141
|
+
Object.keys(position).forEach(function(key){
|
142
|
+
this.el.style[key] = position[key] + "px";
|
143
|
+
}, this);
|
144
|
+
}
|
145
|
+
|
146
|
+
checkFocus (e) {
|
147
|
+
if (e.defaultPrevented) return;
|
148
|
+
if (!this.showing) return;
|
149
|
+
if (e.target === this.el) return;
|
150
|
+
if (e.target == this.options.anchor) return;
|
151
|
+
if (this.el.contains(e.target)) return;
|
152
|
+
if (this.options.anchor.contains(e.target)) return;
|
153
|
+
this.hide();
|
154
|
+
}
|
155
|
+
|
156
|
+
checkEscape (e) {
|
157
|
+
if(e.which != 27) return;
|
158
|
+
this.hide();
|
159
|
+
}
|
160
|
+
|
161
|
+
isHidden() {
|
162
|
+
return !this.showing;
|
163
|
+
}
|
164
|
+
|
165
|
+
hide (options) {
|
166
|
+
options = options || {};
|
167
|
+
if(!this.showing) return;
|
168
|
+
this.el.style.display = 'none';
|
169
|
+
this.showing = false;
|
170
|
+
if(options.silent !== true) {
|
171
|
+
this.trigger('hidden');
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
show () {
|
176
|
+
if(this.showing) return;
|
177
|
+
this.el.style.display = 'block';
|
178
|
+
this.showing = true;
|
179
|
+
this.trigger('shown');
|
180
|
+
}
|
181
|
+
|
182
|
+
toggle(flag) {
|
183
|
+
flag = flag || this.showing;
|
184
|
+
if(flag) this.hide(); else this.show();
|
185
|
+
}
|
186
|
+
}
|
@@ -8,6 +8,7 @@ import * as Helpers from './dom-helpers';
|
|
8
8
|
limit: int | false - number of options to limit to, or false to not limit
|
9
9
|
showAll: function(select_options) to run if/when "Show All" is clicked
|
10
10
|
label: string, used for mobile menu
|
11
|
+
container: selector for where to render dropdown
|
11
12
|
*/
|
12
13
|
export default class Select extends Component {
|
13
14
|
|
@@ -22,22 +23,23 @@ export default class Select extends Component {
|
|
22
23
|
|
23
24
|
return false;
|
24
25
|
},
|
25
|
-
limit: 8
|
26
|
+
limit: 8,
|
27
|
+
container: document.body
|
26
28
|
}
|
27
29
|
|
28
30
|
Object.assign(this.options, this.pick(options, Object.keys(this.options)));
|
29
31
|
|
30
32
|
var showing, lastScrollPosition, select_options;
|
31
33
|
|
32
|
-
this.el
|
33
|
-
this.el
|
34
|
-
this.el
|
34
|
+
this.listenTo(this.el, 'change', this.updateSelect);
|
35
|
+
this.listenTo(this.el, 'close', this.hideOptions);
|
36
|
+
this.listenTo(this.el, 'revealed', this.resize);
|
35
37
|
this.el.uniformSelect = this;
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
this.listenTo(window, 'resize', this.resize);
|
40
|
+
this.listenTo(window, 'scroll', this.updatePosition);
|
41
|
+
this.listenTo(document, 'click', this.outsideClick);
|
42
|
+
this.listenTo(document, 'keyup', this.keyup);
|
41
43
|
|
42
44
|
this.activeIcon = document.createElement('span');
|
43
45
|
Helpers.addClass(this.activeIcon, 'uniformSelect-option-icon');
|
@@ -64,14 +66,15 @@ export default class Select extends Component {
|
|
64
66
|
this.container.appendChild(this.edit_button);
|
65
67
|
|
66
68
|
if (this.el.name) {
|
67
|
-
Helpers.addClass(this.container, this.name.toLowerCase().replace(/[^a-z0-9\-_]+/g, '-'));
|
69
|
+
Helpers.addClass(this.container, this.el.name.toLowerCase().replace(/[^a-z0-9\-_]+/g, '-'));
|
68
70
|
}
|
69
71
|
this.el.style.display = "none";
|
70
72
|
this.el.insertAdjacentElement('beforebegin', this.container);
|
71
73
|
this.updateSelect();
|
72
74
|
this.resize();
|
73
75
|
|
74
|
-
this.edit_button
|
76
|
+
this.listenTo(this.edit_button, 'click', this.showOptions);
|
77
|
+
this.listenTo(this.edit_button, 'click', '.uniformSelect-remove', this.removeSelection);
|
75
78
|
}
|
76
79
|
|
77
80
|
resize () {
|
@@ -85,7 +88,8 @@ export default class Select extends Component {
|
|
85
88
|
|
86
89
|
this.edit_button.innerHTML = '';
|
87
90
|
this.edit_button.style.width = "auto";
|
88
|
-
this.edit_button.style.
|
91
|
+
this.edit_button.style.maxWidth = "100%";
|
92
|
+
this.edit_button.style.minWidth = this.container.offsetWidth + "px";
|
89
93
|
|
90
94
|
Helpers.each(children, function(child){
|
91
95
|
this.edit_button.appendChild(child);
|
@@ -110,14 +114,14 @@ export default class Select extends Component {
|
|
110
114
|
}
|
111
115
|
this.select_options.style.fontSize = Helpers.css(this.el, 'font-size');
|
112
116
|
this.select_options.style.display = 'none';
|
113
|
-
|
117
|
+
this.options.container.appendChild(this.select_options);
|
114
118
|
|
115
119
|
Helpers.each(this.el.querySelectorAll('option'), function(el, index){
|
116
120
|
var button = Helpers.createElement("<button type='button' class='uniformSelect-option block outline text-left'>");
|
117
121
|
button.option = el;
|
118
122
|
button.textContent = el.textContent;
|
119
123
|
button.value = el.value;
|
120
|
-
if (button.textContent == "") button.innerHTML
|
124
|
+
if (button.textContent == "") button.innerHTML = "<span class='text-italic text-muted'>None</span>";
|
121
125
|
if(el.selected){
|
122
126
|
Helpers.addClass(button, 'active');
|
123
127
|
button.append(this.activeIcon.cloneNode(true));
|
@@ -125,23 +129,23 @@ export default class Select extends Component {
|
|
125
129
|
Helpers.addClass(button, 'hide');
|
126
130
|
}
|
127
131
|
this.select_options.append(button);
|
128
|
-
|
132
|
+
this.listenTo(button, 'click', this.selectOption);
|
129
133
|
}.bind(this));
|
130
134
|
|
131
135
|
var actions_el = Helpers.createElement('<div class="uniformSelect-options-actions"></div>');
|
132
136
|
if (this.options.limit && this.el.querySelectorAll('option').length > this.options.limit) {
|
133
137
|
var show_all_button = Helpers.createElement("<button type='button' class='uniformSelect-show-all outline blue' style='display: block; border: none'>Show All</button>");
|
134
|
-
|
138
|
+
this.listenTo(show_all_button, 'click', function(e){
|
135
139
|
Helpers.trigger(this.el, 'show_all');
|
136
140
|
if (this.options.showAll) this.options.showAll(this.select_options);
|
137
141
|
e.preventDefault();
|
138
142
|
e.stopPropagation();
|
139
|
-
}
|
143
|
+
})
|
140
144
|
actions_el.appendChild(show_all_button);
|
141
145
|
}
|
142
146
|
if (this.el.multiple) {
|
143
147
|
var done_button = Helpers.createElement("<button type='button' class='uniformSelect-done block outline blue'>Done</button>");
|
144
|
-
|
148
|
+
this.listenTo(done_button, 'click', this.hideOptions);
|
145
149
|
actions_el.appendChild(done_button);
|
146
150
|
}
|
147
151
|
if (!Helpers.is_empty(actions_el)) {
|
@@ -158,6 +162,7 @@ export default class Select extends Component {
|
|
158
162
|
Helpers.removeClass(this.select_options, 'fixed');
|
159
163
|
Helpers.removeClass(this.edit_button, 'active');
|
160
164
|
Helpers.removeClass(document.body, 'uniformModal-hideBody');
|
165
|
+
|
161
166
|
if(this.lastScrollPosition && window.innerWidth < 720) window.scrollTo(0, this.lastScrollPosition);
|
162
167
|
Helpers.trigger(this.el, 'hidden:options');
|
163
168
|
}
|
@@ -175,6 +180,9 @@ export default class Select extends Component {
|
|
175
180
|
this.lastScrollPosition = window.scrollY;
|
176
181
|
this.updatePosition();
|
177
182
|
Helpers.addClass(document.body, 'uniformModal-hideBody');
|
183
|
+
if (this.options.container == document.body) {
|
184
|
+
Helpers.removeClass(document.body, 'uniformModal-hideBody');
|
185
|
+
}
|
178
186
|
}
|
179
187
|
|
180
188
|
selectOption(e) {
|
@@ -189,11 +197,7 @@ export default class Select extends Component {
|
|
189
197
|
}
|
190
198
|
Helpers.toggleClass(e.currentTarget, 'active');
|
191
199
|
e.currentTarget.option.selected = Helpers.hasClass(e.currentTarget, 'active');
|
192
|
-
|
193
|
-
e.currentTarget.append(this.activeIcon.cloneNode(true));
|
194
|
-
} else {
|
195
|
-
Helpers.each(e.currentTarget.querySelectorAll('.uniformSelect-option-icon'), Helpers.remove);
|
196
|
-
}
|
200
|
+
this.updateOptions();
|
197
201
|
Helpers.trigger(this.el, 'change');
|
198
202
|
}
|
199
203
|
|
@@ -202,12 +206,24 @@ export default class Select extends Component {
|
|
202
206
|
var value = Helpers.map(Helpers.filter(this.el.querySelectorAll("option"), function(el){
|
203
207
|
return el.selected;
|
204
208
|
}), function(el){
|
205
|
-
return el.textContent;
|
206
|
-
}).join("
|
209
|
+
return this.el.multiple ? `<span class="uniformSelect-selection">${el.textContent}<span class="uniformSelect-remove"></span></span>` : el.textContent;
|
210
|
+
}.bind(this)).join(" ");
|
207
211
|
|
208
212
|
if (value == "") value = " ";
|
209
213
|
this.edit_button.querySelector('.text-js').innerHTML = value;
|
210
214
|
}
|
215
|
+
|
216
|
+
updateOptions () {
|
217
|
+
Helpers.each(this.select_options.querySelectorAll("button"), function(button) {
|
218
|
+
if(!button.option) return;
|
219
|
+
Helpers.toggleClass(button, 'active', button.option.selected);
|
220
|
+
if (Helpers.hasClass(button, 'active')) {
|
221
|
+
button.append(this.activeIcon.cloneNode(true));
|
222
|
+
} else {
|
223
|
+
Helpers.each(button.querySelectorAll('.uniformSelect-option-icon'), Helpers.remove);
|
224
|
+
}
|
225
|
+
}.bind(this))
|
226
|
+
}
|
211
227
|
|
212
228
|
updatePosition () {
|
213
229
|
if(!this.select_options) return;
|
@@ -232,4 +248,15 @@ export default class Select extends Component {
|
|
232
248
|
Helpers.addClass(this.select_options, 'fixed');
|
233
249
|
}
|
234
250
|
}
|
251
|
+
|
252
|
+
removeSelection(e) {
|
253
|
+
e.preventDefault();
|
254
|
+
var target = Helpers.filter(this.el.querySelectorAll("option"), function(el){
|
255
|
+
return el.innerText.trim() == e.target.parentNode.innerText.trim();
|
256
|
+
})[0];
|
257
|
+
if(!target) return;
|
258
|
+
target.selected = false;
|
259
|
+
this.updatePosition();
|
260
|
+
Helpers.trigger(this.el, 'change');
|
261
|
+
}
|
235
262
|
}
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import Component from './component';
|
2
|
+
import Popover from './popover';
|
2
3
|
import * as Helpers from './dom-helpers';
|
3
4
|
|
4
5
|
/*
|
5
6
|
message: html
|
6
7
|
align: top|bottom (default: top)
|
8
|
+
container: document.body
|
7
9
|
|
8
10
|
methods
|
9
11
|
------
|
@@ -17,6 +19,7 @@ export default class Tooltip extends Component {
|
|
17
19
|
options = options || {}
|
18
20
|
this.options = {
|
19
21
|
align: 'top',
|
22
|
+
container: document.body
|
20
23
|
};
|
21
24
|
Object.assign(this.options, this.pick(options, Object.keys(this.options)));
|
22
25
|
|
@@ -24,89 +27,33 @@ export default class Tooltip extends Component {
|
|
24
27
|
this.message = options.message;
|
25
28
|
options.el.tooltip = this;
|
26
29
|
|
27
|
-
this.el
|
28
|
-
this.el
|
30
|
+
this.listenTo(this.el, 'mouseenter', this.show);
|
31
|
+
this.listenTo(this.el, 'mouseleave', this.hide);
|
29
32
|
}
|
30
33
|
|
31
34
|
render () {
|
32
|
-
this.popup = Helpers.createElement('<div class="uniformTooltip-popup">' + this.message + '</div>');
|
33
|
-
this.popup.insertBefore(Helpers.createElement("<div class='uniformTooltip-pointer'></div>"), this.popup.firstChild);
|
34
|
-
this.el.appendChild(this.popup);
|
35
|
-
if (this.message.length > 100) {
|
36
|
-
this.popup.style.minWidth = "200px";
|
37
|
-
} else {
|
38
|
-
this.popup.style.whiteSpace = "nowrap";
|
39
|
-
}
|
40
|
-
|
41
|
-
if (this.popup.offsetWidth + Helpers.offset(this.popup).left > window.innerWidth) {
|
42
|
-
this.popup.style.left = window.innerWidth - this.popup.offsetWidth - Helpers.offset(this.popup).left + "px"
|
43
|
-
}
|
44
|
-
|
45
|
-
this.popup.style.display = "block";
|
46
|
-
if (this.options.align == "bottom" || Helpers.offset(this.popup).top < 0) {
|
47
|
-
Helpers.addClass(this.popup, '-align-bottom');
|
48
|
-
}
|
49
|
-
this.popup.style.display = 'none';
|
50
35
|
|
51
36
|
return this;
|
52
37
|
}
|
53
38
|
|
54
|
-
remove () {
|
55
|
-
this.el.parentNode.removeChild(this.el);
|
56
|
-
}
|
57
|
-
|
58
39
|
show () {
|
59
|
-
if(!this.popup) this.render();
|
60
40
|
if(!this.enabled) return;
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
this.
|
72
|
-
|
73
|
-
this.hide_after_show = false;
|
74
|
-
}.bind(this);
|
75
|
-
|
76
|
-
Helpers.once(this.popup, 'transitionend', endTransition);
|
77
|
-
Helpers.once(this.popup, 'msTransitionEnd', endTransition);
|
78
|
-
Helpers.once(this.popup, 'oTransitionEnd', endTransition);
|
79
|
-
|
80
|
-
if (Helpers.offset(this.popup).left < 0) this.popup.style.left = "0";
|
81
|
-
Helpers.addClass(this.el, 'active');
|
82
|
-
|
83
|
-
// TODO remove timeout usage... Not sure why this is necessary, but doesn't do css animation if not delayed.
|
84
|
-
setTimeout(function(){
|
85
|
-
Helpers.addClass(this.popup, '-reveal');
|
86
|
-
}.bind(this), 1);
|
41
|
+
this.popup = new Popover({
|
42
|
+
content: `<div class="uniformTooltip-popup">
|
43
|
+
<div class='uniformTooltip-pointer'></div>
|
44
|
+
${this.message}
|
45
|
+
</div>`,
|
46
|
+
anchor: this.el,
|
47
|
+
align: this.options.align == "top" ? `center top` : 'center 100%',
|
48
|
+
offset: {
|
49
|
+
top: -7
|
50
|
+
},
|
51
|
+
container: this.options.container
|
52
|
+
}).render();
|
87
53
|
}
|
88
54
|
|
89
55
|
hide () {
|
90
|
-
|
91
|
-
if (this.hiding || this.hidden) return;
|
92
|
-
this.hiding = true;
|
93
|
-
this.shown = false;
|
94
|
-
|
95
|
-
var endTransition = function (e) {
|
96
|
-
this.trigger('hidden');
|
97
|
-
Helpers.removeClass(this.el, 'active');
|
98
|
-
this.popup.style.display = 'none';
|
99
|
-
this.hiding = false;
|
100
|
-
this.hidden = true;
|
101
|
-
if (this.show_after_hide) this.show();
|
102
|
-
this.show_after_hide = false;
|
103
|
-
}.bind(this);
|
104
|
-
|
105
|
-
Helpers.once(this.popup, 'transitionend', endTransition);
|
106
|
-
Helpers.once(this.popup, 'msTransitionEnd', endTransition);
|
107
|
-
Helpers.once(this.popup, 'oTransitionEnd', endTransition);
|
108
|
-
|
109
|
-
Helpers.removeClass(this.popup, '-reveal');
|
56
|
+
this.popup.remove();
|
110
57
|
}
|
111
58
|
|
112
59
|
disable () {
|