romo 0.19.10 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/css/romo/buttons.scss +1 -0
- data/assets/css/romo/modal.scss +5 -0
- data/assets/js/romo/ajax.js +75 -89
- data/assets/js/romo/base.js +699 -274
- data/assets/js/romo/currency_text_input.js +93 -83
- data/assets/js/romo/date.js +3 -3
- data/assets/js/romo/datepicker.js +227 -234
- data/assets/js/romo/dropdown.js +235 -344
- data/assets/js/romo/dropdown_form.js +77 -76
- data/assets/js/romo/form.js +215 -159
- data/assets/js/romo/indicator_text_input.js +64 -95
- data/assets/js/romo/inline.js +66 -59
- data/assets/js/romo/inline_form.js +74 -73
- data/assets/js/romo/modal.js +218 -294
- data/assets/js/romo/modal_form.js +83 -82
- data/assets/js/romo/onkey.js +25 -22
- data/assets/js/romo/option_list_dropdown.js +318 -298
- data/assets/js/romo/picker.js +175 -181
- data/assets/js/romo/select.js +177 -165
- data/assets/js/romo/select_dropdown.js +86 -93
- data/assets/js/romo/selected_options_list.js +66 -76
- data/assets/js/romo/sortable.js +154 -120
- data/assets/js/romo/{indicator.js → spinner.js} +74 -89
- data/assets/js/romo/tooltip.js +257 -271
- data/assets/js/romo/word_boundary_filter.js +7 -10
- data/lib/romo/dassets.rb +1 -1
- data/lib/romo/version.rb +1 -1
- data/test/unit/dassets_tests.rb +1 -1
- metadata +3 -3
data/assets/js/romo/tooltip.js
CHANGED
@@ -1,343 +1,268 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return new RomoTooltip(element);
|
4
|
-
});
|
5
|
-
}
|
1
|
+
var RomoTooltip = RomoComponent(function(elem) {
|
2
|
+
this.elem = elem;
|
6
3
|
|
7
|
-
|
8
|
-
this.
|
9
|
-
this.doInitPopup();
|
4
|
+
this.doInit();
|
5
|
+
this._bindElem();
|
10
6
|
|
11
|
-
this.
|
12
|
-
|
13
|
-
this.delayLeave = 0;
|
14
|
-
if (this.elem.data('romo-tooltip-delay') !== undefined && this.elem.data('romo-tooltip-delay') !== '') {
|
15
|
-
this.delayEnter = this.elem.data('romo-tooltip-delay');
|
16
|
-
this.delayLeave = this.elem.data('romo-tooltip-delay');
|
17
|
-
}
|
18
|
-
if (this.elem.data('romo-tooltip-delay-enter') !== undefined && this.elem.data('romo-tooltip-delay-enter') !== '') {
|
19
|
-
this.delayEnter = this.elem.data('romo-tooltip-delay-enter');
|
20
|
-
}
|
21
|
-
if (this.elem.data('romo-tooltip-delay-leave') !== undefined && this.elem.data('romo-tooltip-delay-leave') !== '') {
|
22
|
-
this.delayLeave = this.elem.data('romo-tooltip-delay-leave');
|
23
|
-
}
|
7
|
+
Romo.trigger(this.elem, 'romoTooltip:ready', [this]);
|
8
|
+
});
|
24
9
|
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
RomoTooltip.prototype.popupOpen = function() {
|
11
|
+
return Romo.hasClass(this.popupElem, 'romo-tooltip-open') === true;
|
12
|
+
}
|
28
13
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
this.elem.on('tooltip:triggerPopupClose', $.proxy(this.onPopupClose, this));
|
33
|
-
this.elem.on('tooltip:triggerSetContent', $.proxy(this.onSetContent, this));
|
34
|
-
$(window).on('resize', $.proxy(this.onResizeWindow, this))
|
14
|
+
RomoTooltip.prototype.popupClosed = function() {
|
15
|
+
return Romo.hasClass(this.popupElem, 'romo-tooltip-open') === false;
|
16
|
+
}
|
35
17
|
|
36
|
-
|
37
|
-
this.
|
38
|
-
|
39
|
-
|
18
|
+
RomoTooltip.prototype.doPopupOpen = function() {
|
19
|
+
var scrollParentElems = Romo.scrollableParents(this.elem).concat([window]);
|
20
|
+
Romo.on(scrollParentElems, 'scroll', Romo.proxy(this._onScrollableParentsScroll, this));
|
21
|
+
|
22
|
+
if (this.romoAjax !== undefined) {
|
23
|
+
this.romoAjax.doInvoke();
|
24
|
+
} else {
|
25
|
+
this._setBodyHtml(Romo.data(this.elem, 'romo-tooltip-content'));
|
40
26
|
}
|
27
|
+
Romo.addClass(this.popupElem, 'romo-tooltip-open');
|
28
|
+
this.doPlacePopupElem();
|
41
29
|
|
42
|
-
|
43
|
-
|
30
|
+
var bodyElem = Romo.f('body')[0];
|
31
|
+
Romo.on(bodyElem, 'romoModal:mousemove', Romo.proxy(this._onModalPopupChange, this));
|
32
|
+
Romo.on(bodyElem, 'romoPopupStack:popupClose', Romo.proxy(this._onModalPopupChange, this));
|
33
|
+
Romo.on(window, 'resize', Romo.proxy(this._onResizeWindow, this));
|
44
34
|
|
45
|
-
|
46
|
-
// override as needed
|
35
|
+
Romo.trigger(this.elem, 'romoTooltip:popupOpen', [this]);
|
47
36
|
}
|
48
37
|
|
49
|
-
RomoTooltip.prototype.
|
50
|
-
this.popupElem
|
51
|
-
this.popupElem.appendTo(this.elem.closest(this.elem.data('romo-tooltip-append-to-closest') || 'body'));
|
38
|
+
RomoTooltip.prototype.doPopupClose = function() {
|
39
|
+
Romo.removeClass(this.popupElem, 'romo-tooltip-open');
|
52
40
|
|
53
|
-
|
41
|
+
var scrollParentElems = Romo.scrollableParents(this.elem).concat([window]);
|
42
|
+
Romo.off(scrollParentElems, 'scroll', Romo.proxy(this._onScrollableParentsScroll, this));
|
54
43
|
|
55
|
-
|
56
|
-
|
44
|
+
var bodyElem = Romo.f('body')[0];
|
45
|
+
Romo.off(bodyElem, 'romoModal:mousemove', Romo.proxy(this._onModalPopupChange, this));
|
46
|
+
Romo.off(bodyElem, 'romoPopupStack:popupClose', Romo.proxy(this._onModalPopupChange, this));
|
47
|
+
Romo.off(window, 'resize', Romo.proxy(this._onResizeWindow, this));
|
57
48
|
|
58
|
-
|
59
|
-
|
49
|
+
Romo.trigger(this.elem, 'romoTooltip:popupClose', [this]);
|
50
|
+
}
|
60
51
|
|
61
|
-
|
52
|
+
RomoTooltip.prototype.doPlacePopupElem = function() {
|
53
|
+
var configHeight = Romo.data(this.elem, 'romo-tooltip-height') ||
|
54
|
+
Romo.data(this.elem, 'romo-tooltip-max-height');
|
55
|
+
var configPosition = this.popupPosition;
|
62
56
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
57
|
+
if (configHeight === 'detect' && (configPosition === 'top' || configPosition === 'bottom')) {
|
58
|
+
var popupHeight = this.popupElem.offsetHeight;
|
59
|
+
var topAvailHeight = this._getPopupMaxAvailableHeight('top');
|
60
|
+
var bottomAvailHeight = this._getPopupMaxAvailableHeight('bottom');
|
61
|
+
|
62
|
+
if (popupHeight < topAvailHeight && popupHeight < bottomAvailHeight) {
|
63
|
+
// if it fits both ways, use the config position way
|
64
|
+
configHeight = this._getPopupMaxAvailableHeight(configPosition);
|
65
|
+
} else if (topAvailHeight > bottomAvailHeight) {
|
66
|
+
configPosition = 'top';
|
67
|
+
configHeight = topAvailHeight;
|
68
|
+
} else {
|
69
|
+
configPosition = 'bottom';
|
70
|
+
configHeight = bottomAvailHeight;
|
68
71
|
}
|
69
|
-
})
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
// delay adding it b/c other components may `append` generated tooltips
|
74
|
-
// meaning the tooltip is removed and then re-added. if added immediately
|
75
|
-
// the "remove" part will incorrectly remove the popup.
|
76
|
-
setTimeout($.proxy(function() {
|
77
|
-
Romo.parentChildElems.add(this.elem, [this.popupElem]);
|
78
|
-
}, this), 1);
|
79
|
-
}
|
73
|
+
Romo.setStyle(this.bodyElem, 'max-height', configHeight.toString() + 'px');
|
74
|
+
}
|
80
75
|
|
81
|
-
|
82
|
-
this.
|
76
|
+
var elemRect = this.elem.getBoundingClientRect();
|
77
|
+
var elemOffset = Romo.offset(this.elem);
|
83
78
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
'min-height': this.elem.data('romo-tooltip-min-height'),
|
89
|
-
'height': this.elem.data('romo-tooltip-height')
|
90
|
-
});
|
79
|
+
var elemHeight = elemRect.height;
|
80
|
+
var elemWidth = elemRect.width;
|
81
|
+
var elemTop = elemOffset.top;
|
82
|
+
var elemLeft = elemOffset.left
|
91
83
|
|
92
|
-
|
93
|
-
|
94
|
-
}
|
95
|
-
if (this.elem.data('romo-tooltip-max-height') !== 'detect') {
|
96
|
-
this.bodyElem.css({
|
97
|
-
'max-height': this.elem.data('romo-tooltip-max-height')
|
98
|
-
});
|
99
|
-
}
|
100
|
-
}
|
84
|
+
var popupOffsetHeight = this.popupElem.offsetHeight;
|
85
|
+
var popupOffsetWidth = this.popupElem.offsetWidth;
|
101
86
|
|
102
|
-
|
103
|
-
this.bodyElem.css({
|
104
|
-
'min-width': '',
|
105
|
-
'max-width': '',
|
106
|
-
'width': '',
|
107
|
-
'min-height': '',
|
108
|
-
'max-height': '',
|
109
|
-
'height': '',
|
110
|
-
});
|
111
|
-
}
|
87
|
+
var pad = 6 + 1; // arrow size + spacing
|
112
88
|
|
113
|
-
|
114
|
-
this.romoAjax = this.elem.romoAjax()[0];
|
115
|
-
this.romoAjax.doUnbindElem(); // disable auto invoke on click
|
89
|
+
Romo.setData(this.popupElem, 'romo-tooltip-arrow-position', configPosition);
|
116
90
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
91
|
+
var posTop = undefined;
|
92
|
+
var posLeft = undefined;
|
93
|
+
switch (configPosition) {
|
94
|
+
case 'top':
|
95
|
+
posTop = elemTop - popupOffsetHeight - pad;
|
96
|
+
posLeft = elemLeft + (elemWidth / 2) - (popupOffsetWidth / 2);
|
97
|
+
break;
|
98
|
+
case 'bottom':
|
99
|
+
posTop = elemTop + elemHeight + pad;
|
100
|
+
posLeft = elemLeft + (elemWidth / 2) - (popupOffsetWidth / 2);
|
101
|
+
break;
|
102
|
+
case 'left':
|
103
|
+
posTop = elemTop + (elemHeight / 2) - (popupOffsetHeight / 2);
|
104
|
+
posLeft = elemLeft - popupOffsetWidth - pad;
|
105
|
+
break;
|
106
|
+
case 'right':
|
107
|
+
posTop = elemTop + (elemHeight / 2) - (popupOffsetHeight / 2);
|
108
|
+
posLeft = elemLeft + elemWidth + pad;
|
109
|
+
break;
|
110
|
+
}
|
130
111
|
|
131
|
-
|
132
|
-
this.
|
133
|
-
this.doInitBody();
|
134
|
-
this.doPlacePopupElem();
|
135
|
-
this.elem.trigger('tooltip:loadBodyStart', [this]);
|
112
|
+
Romo.setStyle(this.popupElem, 'top', posTop + 'px');
|
113
|
+
Romo.setStyle(this.popupElem, 'left', posLeft + 'px');
|
136
114
|
}
|
137
115
|
|
138
|
-
RomoTooltip.prototype.
|
139
|
-
Romo.
|
140
|
-
this.
|
116
|
+
RomoTooltip.prototype.doSetContent = function(value) {
|
117
|
+
Romo.setData(this.elem, 'romo-tooltip-content', value);
|
118
|
+
this._setBodyHtml(Romo.data(this.elem, 'romo-tooltip-content'));
|
141
119
|
this.doPlacePopupElem();
|
142
|
-
|
120
|
+
Romo.pushFn(Romo.proxy(this.doPlacePopupElem, this));
|
143
121
|
}
|
144
122
|
|
145
|
-
RomoTooltip.prototype.
|
146
|
-
|
123
|
+
RomoTooltip.prototype.doSetPopupZIndex = function(relativeElem) {
|
124
|
+
var relativeZIndex = Romo.parseZIndex(relativeElem);
|
125
|
+
Romo.setStyle(this.popupElem, 'z-index', relativeZIndex + 1100); // see z-index.css
|
147
126
|
}
|
148
127
|
|
149
|
-
|
150
|
-
if (e !== undefined) {
|
151
|
-
e.preventDefault();
|
152
|
-
}
|
153
|
-
|
154
|
-
this.hoverState = 'in';
|
155
|
-
if (this.elem.hasClass('disabled') === false) {
|
156
|
-
clearTimeout(this.timeout);
|
157
|
-
this.timeout = setTimeout($.proxy(function() {
|
158
|
-
if (this.hoverState ==='in') {
|
159
|
-
this.doPopupOpen();
|
160
|
-
}
|
161
|
-
}, this), this.delayEnter);
|
162
|
-
}
|
163
|
-
}
|
128
|
+
// private
|
164
129
|
|
165
|
-
RomoTooltip.prototype.
|
166
|
-
|
167
|
-
|
130
|
+
RomoTooltip.prototype._bindElem = function() {
|
131
|
+
this._bindPopup();
|
132
|
+
if (Romo.data(this.elem, 'romo-tooltip-content') === undefined) {
|
133
|
+
this._bindAjax();
|
168
134
|
}
|
135
|
+
this._bindBody();
|
169
136
|
|
170
137
|
this.hoverState = 'out';
|
171
|
-
|
172
|
-
|
173
|
-
this.timeout = setTimeout($.proxy(function() {
|
174
|
-
if (this.hoverState === 'out') {
|
175
|
-
this.doPopupClose();
|
176
|
-
}
|
177
|
-
}, this), this.delayLeave);
|
178
|
-
}
|
179
|
-
}
|
180
|
-
|
181
|
-
RomoTooltip.prototype.onResizeWindow = function(e) {
|
182
|
-
if (this.elem.hasClass('disabled') === false && this.hoverState === 'in') {
|
183
|
-
this.doPlacePopupElem();
|
184
|
-
}
|
185
|
-
}
|
138
|
+
this.delayEnter = 0;
|
139
|
+
this.delayLeave = 0;
|
186
140
|
|
187
|
-
|
188
|
-
|
189
|
-
|
141
|
+
if (Romo.data(this.elem, 'romo-tooltip-delay') !== undefined && Romo.data(this.elem, 'romo-tooltip-delay') !== '') {
|
142
|
+
this.delayEnter = Romo.data(this.elem, 'romo-tooltip-delay');
|
143
|
+
this.delayLeave = Romo.data(this.elem, 'romo-tooltip-delay');
|
190
144
|
}
|
191
|
-
|
192
|
-
|
193
|
-
this.doPopupOpen();
|
145
|
+
if (Romo.data(this.elem, 'romo-tooltip-delay-enter') !== undefined && Romo.data(this.elem, 'romo-tooltip-delay-enter') !== '') {
|
146
|
+
this.delayEnter = Romo.data(this.elem, 'romo-tooltip-delay-enter');
|
194
147
|
}
|
195
|
-
|
196
|
-
|
197
|
-
RomoTooltip.prototype.doPopupOpen = function() {
|
198
|
-
if (this.romoAjax !== undefined) {
|
199
|
-
this.romoAjax.doInvoke();
|
200
|
-
} else {
|
201
|
-
this._setBodyHtml(this.elem.data('romo-tooltip-content'));
|
148
|
+
if (Romo.data(this.elem, 'romo-tooltip-delay-leave') !== undefined && Romo.data(this.elem, 'romo-tooltip-delay-leave') !== '') {
|
149
|
+
this.delayLeave = Romo.data(this.elem, 'romo-tooltip-delay-leave');
|
202
150
|
}
|
203
|
-
this.popupElem.addClass('romo-tooltip-open');
|
204
|
-
this.doPlacePopupElem();
|
205
151
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
152
|
+
Romo.on(this.elem, 'mouseenter', Romo.proxy(this._onToggleEnter, this));
|
153
|
+
Romo.on(this.elem, 'mouseleave', Romo.proxy(this._onToggleLeave, this));
|
154
|
+
Romo.on(this.elem, 'romoTooltip:triggerPopupOpen', Romo.proxy(this._onPopupOpen, this));
|
155
|
+
Romo.on(this.elem, 'romoTooltip:triggerPopupClose', Romo.proxy(this._onPopupClose, this));
|
156
|
+
Romo.on(this.elem, 'romoTooltip:triggerSetContent', Romo.proxy(this._onSetContent, this));
|
211
157
|
|
212
|
-
|
158
|
+
Romo.on(window, 'resize', Romo.proxy(this._onResizeWindow, this))
|
213
159
|
}
|
214
160
|
|
215
|
-
RomoTooltip.prototype.
|
216
|
-
|
217
|
-
|
218
|
-
|
161
|
+
RomoTooltip.prototype._bindPopup = function() {
|
162
|
+
this.popupElem = Romo.elems('<div class="romo-tooltip-popup"><div class="romo-tooltip-arrow"></div><div class="romo-tooltip-body"></div></div>')[0];
|
163
|
+
var popupParentElem = Romo.closest(this.elem, Romo.data(this.elem, 'romo-tooltip-append-to-closest') || 'body');
|
164
|
+
Romo.append(popupParentElem, this.popupElem);
|
219
165
|
|
220
|
-
|
221
|
-
|
166
|
+
this.bodyElem = Romo.children(this.popupElem).find(Romo.proxy(function(childElem){
|
167
|
+
return Romo.is(childElem, '.romo-tooltip-body');
|
168
|
+
}, this));
|
169
|
+
if (Romo.data(this.elem, 'romo-tooltip-style-class') !== undefined) {
|
170
|
+
Romo.addClass(this.bodyElem, Romo.data(this.elem, 'romo-tooltip-style-class'));
|
222
171
|
}
|
223
|
-
}
|
224
172
|
|
225
|
-
|
226
|
-
this.popupElem
|
173
|
+
this.popupPosition = Romo.data(this.elem, 'romo-tooltip-position') || 'top';
|
174
|
+
Romo.setData(this.popupElem, 'romo-tooltip-position', this.popupPosition);
|
227
175
|
|
228
|
-
|
229
|
-
|
230
|
-
$('body').off('modal:popupclose', $.proxy(this.onModalPopupChange, this));
|
231
|
-
}
|
232
|
-
$(window).off('resize', $.proxy(this.onResizeWindow, this));
|
176
|
+
this.popupAlignment = Romo.data(this.elem, 'romo-tooltip-alignment') || 'center';
|
177
|
+
Romo.setData(this.popupElem, 'romo-tooltip-alignment', this.popupAlignment);
|
233
178
|
|
234
|
-
this.
|
235
|
-
}
|
179
|
+
this.doSetPopupZIndex(this.elem);
|
236
180
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
}
|
181
|
+
// don't propagate click events on the popup elem. this prevents the popup
|
182
|
+
// from closing when clicked (see body click event bind on popup open)
|
183
|
+
Romo.on(this.popupElem, 'click', function(e) {
|
184
|
+
e.stopPropagation();
|
185
|
+
})
|
243
186
|
|
244
|
-
|
245
|
-
if (e !== undefined) {
|
246
|
-
e.preventDefault();
|
247
|
-
}
|
248
|
-
this.doSetContent(value);
|
187
|
+
Romo.parentChildElems.add(this.elem, [this.popupElem]);
|
249
188
|
}
|
250
189
|
|
251
|
-
RomoTooltip.prototype.
|
252
|
-
this.elem
|
253
|
-
this.
|
254
|
-
this.doPlacePopupElem();
|
255
|
-
}
|
190
|
+
RomoTooltip.prototype._bindAjax = function() {
|
191
|
+
this.romoAjax = new RomoAjax(this.elem);
|
192
|
+
this.romoAjax.doUnbindElem(); // disable auto invoke on click
|
256
193
|
|
257
|
-
|
258
|
-
|
259
|
-
|
194
|
+
Romo.on(this.elem, 'romoAjax:callStart', Romo.proxy(function(e, romoAjax) {
|
195
|
+
this._loadBodyStart();
|
196
|
+
return false;
|
197
|
+
}, this));
|
198
|
+
Romo.on(this.elem, 'romoAjax:callSuccess', Romo.proxy(function(e, data, romoAjax) {
|
199
|
+
this._loadBodySuccess(data);
|
200
|
+
return false;
|
201
|
+
}, this));
|
202
|
+
Romo.on(this.elem, 'romoAjax:callError', Romo.proxy(function(e, xhr, romoAjax) {
|
203
|
+
this._loadBodyError(xhr);
|
204
|
+
return false;
|
205
|
+
}, this));
|
260
206
|
}
|
261
207
|
|
262
|
-
RomoTooltip.prototype.
|
263
|
-
|
264
|
-
this.popupElem.css({'position': 'fixed'});
|
265
|
-
}
|
266
|
-
|
267
|
-
var pos = $.extend({}, this.elem[0].getBoundingClientRect(), this.elem.offset());
|
268
|
-
var w = this.popupElem[0].offsetWidth;
|
269
|
-
var h = this.popupElem[0].offsetHeight;
|
270
|
-
var pad = 6 + 1; // arrow size + spacing
|
271
|
-
var offset = {};
|
272
|
-
|
273
|
-
var configHeight = this.elem.data('romo-tooltip-height') || this.elem.data('romo-tooltip-max-height');
|
274
|
-
var configPosition = this.popupPosition;
|
275
|
-
|
276
|
-
if (configHeight === 'detect' && (configPosition === 'top' || configPosition === 'bottom')) {
|
277
|
-
var popupHeight = this.popupElem.height();
|
278
|
-
var topAvailHeight = this._getPopupMaxAvailableHeight('top');
|
279
|
-
var bottomAvailHeight = this._getPopupMaxAvailableHeight('bottom');
|
208
|
+
RomoTooltip.prototype._bindBody = function() {
|
209
|
+
this._resetBody();
|
280
210
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
configPosition = 'top';
|
287
|
-
configHeight = topAvailHeight;
|
288
|
-
this.popupElem.attr('data-romo-tooltip-arrow-position', 'top');
|
289
|
-
} else {
|
290
|
-
configPosition = 'bottom';
|
291
|
-
configHeight = bottomAvailHeight;
|
292
|
-
this.popupElem.attr('data-romo-tooltip-arrow-position', 'bottom');
|
293
|
-
}
|
211
|
+
Romo.setStyle(this.bodyElem, 'min-width', Romo.data(this.elem, 'romo-tooltip-min-width'));
|
212
|
+
Romo.setStyle(this.bodyElem, 'max-width', Romo.data(this.elem, 'romo-tooltip-max-width'));
|
213
|
+
Romo.setStyle(this.bodyElem, 'width', Romo.data(this.elem, 'romo-tooltip-width'));
|
214
|
+
Romo.setStyle(this.bodyElem, 'min-height', Romo.data(this.elem, 'romo-tooltip-min-height'));
|
215
|
+
Romo.setStyle(this.bodyElem, 'height', Romo.data(this.elem, 'romo-tooltip-height'));
|
294
216
|
|
295
|
-
|
296
|
-
|
297
|
-
this.popupElem.attr('data-romo-tooltip-arrow-position', configPosition);
|
217
|
+
if (Romo.data(this.elem, 'romo-tooltip-max-height') === undefined) {
|
218
|
+
Romo.setData(this.elem, 'romo-tooltip-max-height', 'detect');
|
298
219
|
}
|
299
|
-
|
300
|
-
|
301
|
-
if(h > configHeight) {
|
302
|
-
h = configHeight;
|
220
|
+
if (Romo.data(this.elem, 'romo-tooltip-max-height') !== 'detect') {
|
221
|
+
Romo.setStyle(this.bodyElem, 'max-height', Romo.data(this.elem, 'romo-tooltip-max-height'));
|
303
222
|
}
|
223
|
+
}
|
304
224
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
$.extend(offset, { top: pos.top + pos.height / 2 - h / 2, left: pos.left - w - pad });
|
314
|
-
break;
|
315
|
-
case 'right':
|
316
|
-
$.extend(offset, { top: pos.top + pos.height / 2 - h / 2, left: pos.left + pos.width + pad });
|
317
|
-
break;
|
318
|
-
}
|
225
|
+
RomoTooltip.prototype._resetBody = function() {
|
226
|
+
Romo.rmStyle(this.bodyElem, 'min-width');
|
227
|
+
Romo.rmStyle(this.bodyElem, 'max-width');
|
228
|
+
Romo.rmStyle(this.bodyElem, 'width');
|
229
|
+
Romo.rmStyle(this.bodyElem, 'min-height');
|
230
|
+
Romo.rmStyle(this.bodyElem, 'max-height');
|
231
|
+
Romo.rmStyle(this.bodyElem, 'height');
|
232
|
+
}
|
319
233
|
|
320
|
-
|
234
|
+
RomoTooltip.prototype._loadBodyStart = function() {
|
235
|
+
this._setBodyHtml('');
|
236
|
+
this._bindBody();
|
237
|
+
this.doPlacePopupElem();
|
238
|
+
Romo.pushFn(Romo.proxy(this.doPlacePopupElem, this));
|
239
|
+
Romo.trigger(this.elem, 'romoTooltip:loadBodyStart', [this]);
|
321
240
|
}
|
322
241
|
|
323
|
-
RomoTooltip.prototype.
|
324
|
-
|
325
|
-
this.
|
242
|
+
RomoTooltip.prototype._loadBodySuccess = function(data) {
|
243
|
+
Romo.initUpdateHtml(this.bodyElem, data);
|
244
|
+
this._bindBody();
|
245
|
+
this.doPlacePopupElem();
|
246
|
+
Romo.pushFn(Romo.proxy(this.doPlacePopupElem, this));
|
247
|
+
Romo.trigger(this.elem, 'romoTooltip:loadBodySuccess', [data, this]);
|
326
248
|
}
|
327
249
|
|
328
|
-
|
250
|
+
RomoTooltip.prototype._loadBodyError = function(xhr) {
|
251
|
+
Romo.trigger(this.elem, 'romoTooltip:loadBodyError', [xhr, this]);
|
252
|
+
}
|
329
253
|
|
330
254
|
RomoTooltip.prototype._getPopupMaxAvailableHeight = function(position) {
|
331
255
|
var maxHeight = undefined;
|
332
256
|
|
333
257
|
switch (position) {
|
334
258
|
case 'top':
|
335
|
-
var elemTop = this.elem
|
259
|
+
var elemTop = this.elem.getBoundingClientRect().top;
|
336
260
|
maxHeight = elemTop - this._getPopupMaxHeightDetectPad(position);
|
337
261
|
break;
|
338
262
|
case 'bottom':
|
339
|
-
var
|
340
|
-
|
263
|
+
var viewportHeight = document.documentElement.clientHeight;
|
264
|
+
var elemBottom = this.elem.getBoundingClientRect().bottom;
|
265
|
+
maxHeight = viewportHeight - elemBottom - this._getPopupMaxHeightDetectPad(position);
|
341
266
|
break;
|
342
267
|
}
|
343
268
|
|
@@ -345,13 +270,74 @@ RomoTooltip.prototype._getPopupMaxAvailableHeight = function(position) {
|
|
345
270
|
}
|
346
271
|
|
347
272
|
RomoTooltip.prototype._getPopupMaxHeightDetectPad = function(position) {
|
348
|
-
return
|
273
|
+
return (
|
274
|
+
Romo.data(this.elem, 'romo-tooltip-max-height-detect-pad-'+position) ||
|
275
|
+
Romo.data(this.elem, 'romo-tooltip-max-height-detect-pad') ||
|
276
|
+
10
|
277
|
+
);
|
349
278
|
}
|
350
279
|
|
351
280
|
RomoTooltip.prototype._setBodyHtml = function(content) {
|
352
|
-
this.bodyElem
|
281
|
+
Romo.updateHtml(this.bodyElem, '<div>'+content+'</div>');
|
353
282
|
}
|
354
283
|
|
355
|
-
|
356
|
-
|
357
|
-
|
284
|
+
// event functions
|
285
|
+
|
286
|
+
RomoTooltip.prototype.romoEvFn._onToggleEnter = function(e) {
|
287
|
+
this.hoverState = 'in';
|
288
|
+
if (Romo.hasClass(this.elem, 'disabled') === false) {
|
289
|
+
clearTimeout(this.timeout);
|
290
|
+
this.timeout = setTimeout(Romo.proxy(function() {
|
291
|
+
if (this.hoverState ==='in') {
|
292
|
+
this.doPopupOpen();
|
293
|
+
}
|
294
|
+
}, this), this.delayEnter);
|
295
|
+
}
|
296
|
+
|
297
|
+
return false;
|
298
|
+
}
|
299
|
+
|
300
|
+
RomoTooltip.prototype.romoEvFn._onToggleLeave = function(e) {
|
301
|
+
this.hoverState = 'out';
|
302
|
+
if (Romo.hasClass(this.elem, 'disabled') === false) {
|
303
|
+
clearTimeout(this.timeout);
|
304
|
+
this.timeout = setTimeout(Romo.proxy(function() {
|
305
|
+
if (this.hoverState === 'out') {
|
306
|
+
this.doPopupClose();
|
307
|
+
}
|
308
|
+
}, this), this.delayLeave);
|
309
|
+
}
|
310
|
+
|
311
|
+
return false;
|
312
|
+
}
|
313
|
+
|
314
|
+
RomoTooltip.prototype.romoEvFn._onPopupOpen = function(e) {
|
315
|
+
if (Romo.hasClass(this.elem, 'disabled') === false) {
|
316
|
+
this.doPopupOpen();
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
320
|
+
RomoTooltip.prototype.romoEvFn._onPopupClose = function(e) {
|
321
|
+
this.doPopupClose();
|
322
|
+
}
|
323
|
+
|
324
|
+
RomoTooltip.prototype.romoEvFn._onModalPopupChange = function(e) {
|
325
|
+
this.doPopupClose();
|
326
|
+
}
|
327
|
+
|
328
|
+
RomoTooltip.prototype.romoEvFn._onSetContent = function(e, value) {
|
329
|
+
this.doSetContent(value);
|
330
|
+
}
|
331
|
+
|
332
|
+
RomoTooltip.prototype.romoEvFn._onScrollableParentsScroll = function(e) {
|
333
|
+
this.doPopupClose();
|
334
|
+
}
|
335
|
+
|
336
|
+
RomoTooltip.prototype.romoEvFn._onResizeWindow = function(e) {
|
337
|
+
this.doPlacePopupElem();
|
338
|
+
return true;
|
339
|
+
}
|
340
|
+
|
341
|
+
// init
|
342
|
+
|
343
|
+
Romo.addElemsInitSelector('[data-romo-tooltip-auto="true"]', RomoTooltip);
|
@@ -1,19 +1,19 @@
|
|
1
1
|
var RomoWordBoundaryFilter = function(filterString, setElems, getElemTextContentCallback) {
|
2
2
|
this.boundaryCharsRegex = /[\s-_]+/;
|
3
|
-
this.
|
4
|
-
this.
|
3
|
+
this.matchingElems = [];
|
4
|
+
this.notMatchingElems = [];
|
5
5
|
this.filters = filterString
|
6
6
|
.trim()
|
7
7
|
.toLowerCase()
|
8
8
|
.split(this.boundaryCharsRegex);
|
9
9
|
|
10
|
-
Romo.
|
11
|
-
var contentStack = getElemTextContentCallback(
|
10
|
+
Romo.array(setElems).forEach(Romo.proxy(function(elem) {
|
11
|
+
var contentStack = getElemTextContentCallback(elem)
|
12
12
|
.trim()
|
13
13
|
.toLowerCase()
|
14
14
|
.split(this.boundaryCharsRegex).reverse();
|
15
15
|
|
16
|
-
var match = this.filters.reduce(
|
16
|
+
var match = this.filters.reduce(Romo.proxy(function(filterMatch, filter) {
|
17
17
|
if (filterMatch === false) {
|
18
18
|
// short-circuit the reduce
|
19
19
|
return false;
|
@@ -33,12 +33,9 @@ var RomoWordBoundaryFilter = function(filterString, setElems, getElemTextContent
|
|
33
33
|
}, this), true);
|
34
34
|
|
35
35
|
if (match === true) {
|
36
|
-
this.
|
36
|
+
this.matchingElems.push(elem);
|
37
37
|
} else {
|
38
|
-
this.
|
38
|
+
this.notMatchingElems.push(elem);
|
39
39
|
}
|
40
40
|
}, this));
|
41
|
-
|
42
|
-
this.matchingElems = $(this.matchingNodes);
|
43
|
-
this.notMatchingElems = $(this.notMatchingNodes);
|
44
41
|
}
|