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/modal.js
CHANGED
@@ -1,385 +1,309 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return new RomoModal(element);
|
4
|
-
});
|
5
|
-
}
|
6
|
-
|
7
|
-
var RomoModal = function(element) {
|
8
|
-
this.elem = $(element);
|
9
|
-
this.doInitPopup();
|
10
|
-
this.romoAjax = this.elem.romoAjax()[0];
|
11
|
-
this.romoAjax.doUnbindElem(); // disable auto invoke on click
|
12
|
-
|
13
|
-
if (this.elem.data('romo-modal-disable-click-invoke') !== true) {
|
14
|
-
this.elem.unbind('click');
|
15
|
-
this.elem.on('click', $.proxy(this.onToggleClick, this));
|
16
|
-
}
|
17
|
-
this.elem.on('modal:triggerToggle', $.proxy(this.onToggleClick, this));
|
18
|
-
this.elem.on('modal:triggerPopupOpen', $.proxy(this.onPopupOpen, this));
|
19
|
-
this.elem.on('modal:triggerPopupClose', $.proxy(this.onPopupClose, this));
|
20
|
-
this.elem.on('romoAjax:callStart', $.proxy(function(e, romoAjax) {
|
21
|
-
this.doLoadBodyStart();
|
22
|
-
return false;
|
23
|
-
}, this));
|
24
|
-
this.elem.on('romoAjax:callSuccess', $.proxy(function(e, data, romoAjax) {
|
25
|
-
this.doLoadBodySuccess(data);
|
26
|
-
return false;
|
27
|
-
}, this));
|
28
|
-
this.elem.on('romoAjax:callError', $.proxy(function(e, xhr, romoAjax) {
|
29
|
-
this.doLoadBodyError(xhr);
|
30
|
-
return false;
|
31
|
-
}, this));
|
32
|
-
|
33
|
-
this.doBindElemKeyUp();
|
1
|
+
var RomoModal = RomoComponent(function(elem) {
|
2
|
+
this.elem = elem;
|
34
3
|
|
35
4
|
this.doInit();
|
36
|
-
this.
|
5
|
+
this._bindElem();
|
37
6
|
|
38
|
-
this.elem
|
39
|
-
}
|
7
|
+
Romo.trigger(this.elem, 'romoModal:ready', [this]);
|
8
|
+
});
|
40
9
|
|
41
|
-
RomoModal.prototype.
|
42
|
-
|
10
|
+
RomoModal.prototype.popupOpen = function() {
|
11
|
+
return Romo.hasClass(this.popupElem, 'romo-modal-open') === true;
|
43
12
|
}
|
44
13
|
|
45
|
-
RomoModal.prototype.
|
46
|
-
this.popupElem
|
47
|
-
|
14
|
+
RomoModal.prototype.popupClosed = function() {
|
15
|
+
return Romo.hasClass(this.popupElem, 'romo-modal-open') === false;
|
16
|
+
}
|
48
17
|
|
49
|
-
|
50
|
-
if (this.
|
51
|
-
|
18
|
+
RomoModal.prototype.doToggle = function() {
|
19
|
+
if (this.popupOpen()) {
|
20
|
+
Romo.pushFn(Romo.proxy(this.doPopupClose, this));
|
21
|
+
} else {
|
22
|
+
Romo.pushFn(Romo.proxy(this.doPopupOpen, this));
|
52
23
|
}
|
24
|
+
Romo.trigger(this.elem, 'romoModal:toggle', [this]);
|
25
|
+
}
|
53
26
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
// meaning the modal is removed and then re-added. if added immediately
|
62
|
-
// the "remove" part will incorrectly remove the popup.
|
63
|
-
setTimeout($.proxy(function() {
|
64
|
-
Romo.parentChildElems.add(this.elem, [this.popupElem]);
|
65
|
-
}, this), 1);
|
27
|
+
RomoModal.prototype.doPopupOpen = function() {
|
28
|
+
Romo.popupStack.addElem(
|
29
|
+
this.popupElem,
|
30
|
+
Romo.proxy(this._openPopup, this),
|
31
|
+
Romo.proxy(this._closePopup, this),
|
32
|
+
Romo.proxy(this.doPlacePopupElem, this)
|
33
|
+
);
|
66
34
|
}
|
67
35
|
|
68
|
-
RomoModal.prototype.
|
69
|
-
this.
|
36
|
+
RomoModal.prototype.doPopupClose = function() {
|
37
|
+
Romo.popupStack.closeThru(this.popupElem);
|
38
|
+
}
|
70
39
|
|
71
|
-
|
72
|
-
|
73
|
-
|
40
|
+
RomoModal.prototype.doPlacePopupElem = function() {
|
41
|
+
var viewportHeight = document.documentElement.clientHeight;
|
42
|
+
var viewportWidth = document.documentElement.clientWidth;
|
43
|
+
|
44
|
+
if (Romo.data(this.elem, 'romo-modal-max-height') === 'detect') {
|
45
|
+
var pad = Romo.data(this.elem, 'romo-modal-max-height-detect-pad') || 10;
|
46
|
+
var contentTop = this.contentElem.getBoundingClientRect().top;
|
47
|
+
var contentBottom = this.contentElem.getBoundingClientRect().bottom;
|
48
|
+
var bodyBottom = this.bodyElem.getBoundingClientRect().bottom;
|
49
|
+
var padBottom = bodyBottom - contentBottom;
|
50
|
+
|
51
|
+
var maxHeight = viewportHeight - contentTop - padBottom - pad;
|
52
|
+
Romo.setStyle(this.contentElem, 'max-height', maxHeight.toString() + 'px');
|
74
53
|
}
|
75
54
|
|
76
|
-
|
77
|
-
this.
|
78
|
-
|
55
|
+
var popupOffsetHeight = this.popupElem.offsetHeight;
|
56
|
+
var popupOffsetWidth = this.popupElem.offsetWidth;
|
57
|
+
var minHeightWidth = 75;
|
58
|
+
var centerTop = (viewportHeight / 2) - (popupOffsetHeight / 2);
|
59
|
+
var centerLeft = (viewportWidth / 2) - (popupOffsetWidth / 2);
|
79
60
|
|
80
|
-
|
81
|
-
|
82
|
-
|
61
|
+
var offsetTop = viewportHeight * 0.15;
|
62
|
+
if (centerTop < offsetTop) { offsetTop = centerTop; }
|
63
|
+
if (offsetTop < minHeightWidth) { offsetTop = minHeightWidth; }
|
83
64
|
|
84
|
-
var
|
85
|
-
|
86
|
-
'max-width': this.elem.data('romo-modal-max-width'),
|
87
|
-
'width': this.elem.data('romo-modal-width'),
|
88
|
-
'min-height': this.elem.data('romo-modal-min-height'),
|
89
|
-
'height': this.elem.data('romo-modal-height'),
|
90
|
-
'overflow-x': 'auto',
|
91
|
-
'overflow-y': 'auto'
|
92
|
-
}
|
65
|
+
var offsetLeft = centerLeft;
|
66
|
+
if (offsetLeft < minHeightWidth) { offsetLeft = minHeightWidth; }
|
93
67
|
|
94
|
-
|
95
|
-
|
96
|
-
}
|
97
|
-
if (this.elem.data('romo-modal-max-height') !== 'detect') {
|
98
|
-
css['max-height'] = this.elem.data('romo-modal-max-height');
|
99
|
-
}
|
100
|
-
|
101
|
-
this.contentElem.css(css);
|
68
|
+
Romo.setStyle(this.popupElem, 'top', offsetTop + 'px');
|
69
|
+
Romo.setStyle(this.popupElem, 'left', offsetLeft + 'px');
|
102
70
|
}
|
103
71
|
|
104
|
-
|
105
|
-
this.contentElem.css({
|
106
|
-
'min-width': '',
|
107
|
-
'max-width': '',
|
108
|
-
'width': '',
|
109
|
-
'min-height': '',
|
110
|
-
'max-height': '',
|
111
|
-
'height': '',
|
112
|
-
'overflow': ''
|
113
|
-
});
|
114
|
-
|
115
|
-
this.closeElem.off('click', $.proxy(this.onPopupClose, this));
|
116
|
-
}
|
72
|
+
// private
|
117
73
|
|
118
|
-
RomoModal.prototype.
|
119
|
-
this.
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
74
|
+
RomoModal.prototype._openPopup = function() {
|
75
|
+
if (Romo.data(this.elem, 'romo-modal-content-elem') !== undefined) {
|
76
|
+
var contentElem = Romo.elems(Romo.data(this.elem, 'romo-modal-content-elem'))[0];
|
77
|
+
this._loadBodySuccess(contentElem.outerHTML);
|
78
|
+
} else {
|
79
|
+
this.romoAjax.doInvoke();
|
80
|
+
}
|
124
81
|
|
125
|
-
|
126
|
-
Romo.initHtml(this.bodyElem, data);
|
127
|
-
this.doInitBody();
|
82
|
+
Romo.addClass(this.popupElem, 'romo-modal-open');
|
128
83
|
this.doPlacePopupElem();
|
129
|
-
this.elem.trigger('modal:loadBodySuccess', [data, this]);
|
130
|
-
}
|
131
84
|
|
132
|
-
|
133
|
-
this.elem.trigger('modal:loadBodyError', [xhr, this]);
|
85
|
+
Romo.trigger(this.elem, 'romoModal:popupOpen', [this]);
|
134
86
|
}
|
135
87
|
|
136
|
-
RomoModal.prototype.
|
137
|
-
|
138
|
-
e.preventDefault();
|
139
|
-
}
|
88
|
+
RomoModal.prototype._closePopup = function() {
|
89
|
+
Romo.removeClass(this.popupElem, 'romo-modal-open');
|
140
90
|
|
141
|
-
if (this.elem
|
142
|
-
this.
|
91
|
+
if (Romo.data(this.elem, 'romo-modal-clear-content') === true) {
|
92
|
+
Romo.updateHtml(this.contentElem, '');
|
143
93
|
}
|
144
|
-
}
|
145
94
|
|
146
|
-
|
147
|
-
if (this.popupElem.hasClass('romo-modal-open')) {
|
148
|
-
setTimeout($.proxy(function() {
|
149
|
-
this.doPopupClose();
|
150
|
-
}, this), 100);
|
151
|
-
} else {
|
152
|
-
setTimeout($.proxy(function() {
|
153
|
-
this.doPopupOpen();
|
154
|
-
}, this), 100);
|
155
|
-
}
|
156
|
-
this.elem.trigger('modal:toggle', [this]);
|
95
|
+
Romo.trigger(this.elem, 'romoModal:popupClose', [this]);
|
157
96
|
}
|
158
97
|
|
159
|
-
RomoModal.prototype.
|
160
|
-
|
161
|
-
|
162
|
-
|
98
|
+
RomoModal.prototype._bindElem = function() {
|
99
|
+
this._bindPopup();
|
100
|
+
this._bindAjax();
|
101
|
+
this._bindBody();
|
163
102
|
|
164
|
-
if ((this.elem
|
165
|
-
|
166
|
-
setTimeout($.proxy(function() {
|
167
|
-
this.doPopupOpen();
|
168
|
-
}, this), 100);
|
103
|
+
if (Romo.data(this.elem, 'romo-modal-disable-click-invoke') !== true) {
|
104
|
+
Romo.on(this.elem, 'click', Romo.proxy(this._onToggle, this));
|
169
105
|
}
|
106
|
+
Romo.on(this.elem, 'romoModal:triggerToggle', Romo.proxy(this._onToggle, this));
|
107
|
+
Romo.on(this.elem, 'romoModal:triggerPopupOpen', Romo.proxy(this._onPopupOpen, this));
|
108
|
+
Romo.on(this.elem, 'romoModal:triggerPopupClose', Romo.proxy(this._onPopupClose, this));
|
170
109
|
}
|
171
110
|
|
172
|
-
RomoModal.prototype.
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
111
|
+
RomoModal.prototype._bindPopup = function() {
|
112
|
+
this.popupElem = Romo.elems('<div class="romo-modal-popup"><div class="romo-modal-body"></div></div>')[0];
|
113
|
+
var popupParentElem = Romo.closest(this.elem, Romo.data(this.elem, 'romo-dropdown-append-to-closest') || 'body');
|
114
|
+
Romo.append(popupParentElem, this.popupElem)
|
115
|
+
|
116
|
+
this.bodyElem = Romo.children(this.popupElem).find(Romo.proxy(function(childElem){
|
117
|
+
return Romo.is(childElem, '.romo-modal-body');
|
118
|
+
}, this));
|
119
|
+
if (Romo.data(this.elem, 'romo-modal-style-class') !== undefined) {
|
120
|
+
Romo.addClass(this.bodyElem, Romo.data(this.elem, 'romo-modal-style-class'));
|
177
121
|
}
|
178
122
|
|
179
|
-
this.
|
180
|
-
this.
|
123
|
+
this.contentElem = undefined;
|
124
|
+
this.closeElems = [];
|
125
|
+
this.dragElems = [];
|
181
126
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
}, this), 100);
|
127
|
+
Romo.parentChildElems.add(this.elem, [this.popupElem]);
|
128
|
+
Romo.on(this.popupElem, 'romoParentChildElems:childRemoved', Romo.proxy(function(e, childElem) {
|
129
|
+
Romo.popupStack.closeThru(this.popupElem);
|
130
|
+
}, this));
|
131
|
+
Romo.on(this.popupElem, 'romoPopupStack:popupClosedByEsc', Romo.proxy(function(e, romoPopupStack) {
|
132
|
+
Romo.trigger(this.elem, 'romoModal:popupClosedByEsc', [this]);
|
133
|
+
}, this));
|
190
134
|
|
191
|
-
|
192
|
-
this.doBindWindowBodyKeyUp();
|
135
|
+
}
|
193
136
|
|
194
|
-
|
195
|
-
|
137
|
+
RomoModal.prototype._bindAjax = function() {
|
138
|
+
this.romoAjax = new RomoAjax(this.elem);
|
139
|
+
this.romoAjax.doUnbindElem(); // disable auto invoke on click
|
196
140
|
|
197
|
-
this.elem
|
141
|
+
Romo.on(this.elem, 'romoAjax:callStart', Romo.proxy(function(e, romoAjax) {
|
142
|
+
this._loadBodyStart();
|
143
|
+
return false;
|
144
|
+
}, this));
|
145
|
+
Romo.on(this.elem, 'romoAjax:callSuccess', Romo.proxy(function(e, data, romoAjax) {
|
146
|
+
this._loadBodySuccess(data);
|
147
|
+
return false;
|
148
|
+
}, this));
|
149
|
+
Romo.on(this.elem, 'romoAjax:callError', Romo.proxy(function(e, xhr, romoAjax) {
|
150
|
+
this._loadBodyError(xhr);
|
151
|
+
return false;
|
152
|
+
}, this));
|
198
153
|
}
|
199
154
|
|
200
|
-
RomoModal.prototype.
|
201
|
-
|
202
|
-
e.preventDefault();
|
203
|
-
}
|
155
|
+
RomoModal.prototype._bindBody = function() {
|
156
|
+
this._resetBody();
|
204
157
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
158
|
+
var contentElems = Romo.find(this.bodyElem, '.romo-modal-content');
|
159
|
+
this.contentElem = contentElems[contentElems.length - 1];
|
160
|
+
if (this.contentElem === undefined) {
|
161
|
+
this.contentElem = this.bodyElem;
|
209
162
|
}
|
210
|
-
}
|
211
163
|
|
212
|
-
|
213
|
-
|
214
|
-
this.popupElem.removeClass('romo-modal-open');
|
164
|
+
this.closeElems = Romo.find(this.popupElem, '[data-romo-modal-close="true"]');
|
165
|
+
Romo.on(this.closeElems, 'click', Romo.proxy(this._onPopupClose, this));
|
215
166
|
|
216
|
-
|
217
|
-
this.
|
167
|
+
this.dragElems = Romo.find(this.popupElem, '[data-romo-modal-drag="true"]');
|
168
|
+
Romo.on(this.dragElems, 'mousedown', Romo.proxy(this._onMouseDown, this));
|
169
|
+
Romo.addClass(this.dragElems, 'romo-modal-grab');
|
218
170
|
|
219
|
-
|
220
|
-
this.
|
171
|
+
var css = {
|
172
|
+
'min-width': Romo.data(this.elem, 'romo-modal-min-width'),
|
173
|
+
'max-width': Romo.data(this.elem, 'romo-modal-max-width'),
|
174
|
+
'width': Romo.data(this.elem, 'romo-modal-width'),
|
175
|
+
'min-height': Romo.data(this.elem, 'romo-modal-min-height'),
|
176
|
+
'height': Romo.data(this.elem, 'romo-modal-height'),
|
177
|
+
'overflow-x': 'auto',
|
178
|
+
'overflow-y': 'auto'
|
179
|
+
}
|
221
180
|
|
222
|
-
|
223
|
-
|
181
|
+
if (Romo.data(this.elem, 'romo-modal-max-height') === undefined) {
|
182
|
+
Romo.setData(this.elem, 'romo-modal-max-height', 'detect');
|
183
|
+
}
|
184
|
+
if (Romo.data(this.elem, 'romo-modal-max-height') !== 'detect') {
|
185
|
+
css['max-height'] = Romo.data(this.elem, 'romo-modal-max-height');
|
186
|
+
}
|
224
187
|
|
225
|
-
|
226
|
-
|
227
|
-
this.contentElem.html('');
|
188
|
+
for (var key in css) {
|
189
|
+
Romo.setStyle(this.contentElem, key, css[key]);
|
228
190
|
}
|
191
|
+
}
|
229
192
|
|
230
|
-
|
193
|
+
RomoModal.prototype._resetBody = function() {
|
194
|
+
if (this.contentElem !== undefined) {
|
195
|
+
Romo.rmStyle(this.contentElem, 'min-width');
|
196
|
+
Romo.rmStyle(this.contentElem, 'max-width');
|
197
|
+
Romo.rmStyle(this.contentElem, 'width');
|
198
|
+
Romo.rmStyle(this.contentElem, 'min-height');
|
199
|
+
Romo.rmStyle(this.contentElem, 'max-height');
|
200
|
+
Romo.rmStyle(this.contentElem, 'height');
|
201
|
+
Romo.rmStyle(this.contentElem, 'overflow');
|
202
|
+
}
|
203
|
+
|
204
|
+
Romo.off(this.closeElems, 'click', Romo.proxy(this._onPopupClose, this));
|
231
205
|
}
|
232
206
|
|
233
|
-
RomoModal.prototype.
|
234
|
-
|
235
|
-
|
236
|
-
this.
|
237
|
-
|
207
|
+
RomoModal.prototype._loadBodyStart = function() {
|
208
|
+
Romo.updateHtml(this.bodyElem, '');
|
209
|
+
this._bindBody();
|
210
|
+
this.doPlacePopupElem();
|
211
|
+
Romo.pushFn(Romo.proxy(this.doPlacePopupElem, this));
|
212
|
+
Romo.trigger(this.elem, 'romoModal:loadBodyStart', [this]);
|
238
213
|
}
|
239
214
|
|
240
|
-
RomoModal.prototype.
|
241
|
-
this.
|
242
|
-
this.
|
215
|
+
RomoModal.prototype._loadBodySuccess = function(data) {
|
216
|
+
Romo.initUpdateHtml(this.bodyElem, data);
|
217
|
+
this._bindBody();
|
218
|
+
this.doPlacePopupElem();
|
219
|
+
Romo.pushFn(Romo.proxy(this.doPlacePopupElem, this));
|
220
|
+
Romo.trigger(this.elem, 'romoModal:loadBodySuccess', [data, this]);
|
221
|
+
}
|
243
222
|
|
244
|
-
|
245
|
-
this.
|
223
|
+
RomoModal.prototype._loadBodyError = function(xhr) {
|
224
|
+
Romo.trigger(this.elem, 'romoModal:loadBodyError', [xhr, this]);
|
225
|
+
}
|
246
226
|
|
247
|
-
|
248
|
-
this.
|
249
|
-
|
250
|
-
$(window).on('mouseup', $.proxy(this.onMouseUp, this));
|
227
|
+
RomoModal.prototype._dragStart = function(e) {
|
228
|
+
Romo.addClass(this.dragElems, 'romo-modal-grabbing');
|
229
|
+
Romo.removeClass(this.dragElems, 'romo-modal-grab');
|
251
230
|
|
252
|
-
|
253
|
-
}
|
231
|
+
Romo.popupStack.closeTo(this.popupElem);
|
254
232
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
e.
|
259
|
-
this.
|
260
|
-
|
233
|
+
Romo.setStyle(this.popupElem, 'width', Romo.css(this.popupElem, 'width'));
|
234
|
+
Romo.setStyle(this.popupElem, 'height', Romo.css(this.popupElem, 'height'));
|
235
|
+
|
236
|
+
this._dragDiffX = e.clientX - this.popupElem.offsetLeft;
|
237
|
+
this._dragDiffY = e.clientY - this.popupElem.offsetTop;
|
238
|
+
Romo.on(window, 'mousemove', Romo.proxy(this._onMouseMove, this));
|
239
|
+
Romo.on(window, 'mouseup', Romo.proxy(this._onMouseUp, this));
|
240
|
+
|
241
|
+
Romo.trigger(this.elem, "romoModal:dragStart", [this]);
|
261
242
|
}
|
262
243
|
|
263
|
-
RomoModal.prototype.
|
244
|
+
RomoModal.prototype._dragMove = function(clientX, clientY) {
|
264
245
|
var placeX = clientX - this._dragDiffX;
|
265
246
|
var placeY = clientY - this._dragDiffY;
|
266
|
-
this.popupElem
|
247
|
+
Romo.setStyle(this.popupElem, 'left', placeX+'px');
|
248
|
+
Romo.setStyle(this.popupElem, 'top', placeY+'px');
|
267
249
|
|
268
|
-
this.elem
|
250
|
+
Romo.trigger(this.elem, "romoModal:dragMove", [placeX, placeY, this]);
|
269
251
|
}
|
270
252
|
|
271
|
-
RomoModal.prototype.
|
272
|
-
|
273
|
-
|
274
|
-
this.doDragStop(e);
|
275
|
-
return false;
|
276
|
-
}
|
253
|
+
RomoModal.prototype._dragStop = function(e) {
|
254
|
+
Romo.addClass(this.dragElems, 'romo-modal-grab');
|
255
|
+
Romo.removeClass(this.dragElems, 'romo-modal-grabbing');
|
277
256
|
|
278
|
-
|
279
|
-
this.
|
280
|
-
this.dragElem.removeClass('romo-modal-grabbing');
|
281
|
-
this.popupElem.css('width', '');
|
282
|
-
this.popupElem.css('height', '');
|
257
|
+
Romo.rmStyle(this.popupElem, 'width');
|
258
|
+
Romo.rmStyle(this.popupElem, 'height');
|
283
259
|
|
284
|
-
|
285
|
-
|
260
|
+
Romo.off(window, 'mousemove', Romo.proxy(this._onMouseMove, this));
|
261
|
+
Romo.off(window, 'mouseup', Romo.proxy(this._onMouseUp, this));
|
286
262
|
delete this._dragDiffX;
|
287
263
|
delete this._dragDiffY;
|
288
264
|
|
289
|
-
this.elem
|
265
|
+
Romo.trigger(this.elem, "romoModal:dragStop", [this]);
|
290
266
|
}
|
291
267
|
|
292
|
-
|
293
|
-
this.elem.on('keyup', $.proxy(this.onElemKeyUp, this));
|
294
|
-
this.popupElem.on('keyup', $.proxy(this.onElemKeyUp, this));
|
295
|
-
}
|
268
|
+
// event functions
|
296
269
|
|
297
|
-
RomoModal.prototype.
|
298
|
-
|
299
|
-
this.popupElem.off('keyup', $.proxy(this.onElemKeyUp, this));
|
300
|
-
}
|
270
|
+
RomoModal.prototype.romoEvFn._onToggle = function(e) {
|
271
|
+
e.preventDefault();
|
301
272
|
|
302
|
-
|
303
|
-
|
304
|
-
if (this.popupElem.hasClass('romo-modal-open')) {
|
305
|
-
if(e.keyCode === 27 /* Esc */ ) {
|
306
|
-
this.doPopupClose();
|
307
|
-
return false;
|
308
|
-
} else {
|
309
|
-
return true;
|
310
|
-
}
|
311
|
-
} else {
|
312
|
-
return true;
|
313
|
-
}
|
273
|
+
if (Romo.hasClass(this.elem, 'disabled') === false) {
|
274
|
+
this.doToggle();
|
314
275
|
}
|
315
|
-
return true;
|
316
|
-
}
|
317
|
-
|
318
|
-
RomoModal.prototype.doBindWindowBodyClick = function() {
|
319
|
-
$('body').on('click', $.proxy(this.onWindowBodyClick, this));
|
320
276
|
}
|
321
277
|
|
322
|
-
RomoModal.prototype.
|
323
|
-
|
278
|
+
RomoModal.prototype.romoEvFn._onPopupOpen = function(e) {
|
279
|
+
if (Romo.hasClass(this.elem, 'disabled') === false && this.popupClosed()) {
|
280
|
+
this.doPopupOpen();
|
281
|
+
}
|
324
282
|
}
|
325
283
|
|
326
|
-
RomoModal.prototype.
|
327
|
-
|
328
|
-
if (e !== undefined && $(e.target).parents('.romo-modal-popup').size() === 0) {
|
284
|
+
RomoModal.prototype.romoEvFn._onPopupClose = function(e) {
|
285
|
+
if (Romo.hasClass(this.elem, 'disabled') === false && this.popupOpen()) {
|
329
286
|
this.doPopupClose();
|
330
287
|
}
|
331
|
-
return true;
|
332
|
-
}
|
333
|
-
|
334
|
-
RomoModal.prototype.doBindWindowBodyKeyUp = function() {
|
335
|
-
$('body').on('keyup', $.proxy(this.onWindowBodyKeyUp, this));
|
336
288
|
}
|
337
289
|
|
338
|
-
RomoModal.prototype.
|
339
|
-
|
290
|
+
RomoModal.prototype.romoEvFn._onMouseDown = function(e) {
|
291
|
+
this._dragStart(e);
|
292
|
+
return false;
|
340
293
|
}
|
341
294
|
|
342
|
-
RomoModal.prototype.
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
return true;
|
295
|
+
RomoModal.prototype.romoEvFn._onMouseMove = function(e) {
|
296
|
+
Romo.trigger(Romo.f('body')[0], 'romoModal:mousemove');
|
297
|
+
this._dragMove(e.clientX, e.clientY);
|
298
|
+
return false;
|
347
299
|
}
|
348
300
|
|
349
|
-
RomoModal.prototype.
|
350
|
-
this.
|
351
|
-
return
|
301
|
+
RomoModal.prototype.romoEvFn._onMouseUp = function(e) {
|
302
|
+
this._dragStop(e);
|
303
|
+
return false;
|
352
304
|
}
|
353
305
|
|
354
|
-
|
355
|
-
var w = this.popupElem[0].offsetWidth;
|
356
|
-
var h = this.popupElem[0].offsetHeight;
|
357
|
-
var min = 75;
|
358
|
-
var centerTop = $(window).height() / 2 - h / 2;
|
359
|
-
var centerLeft = $(window).width() / 2 - w / 2;
|
360
|
-
var css = {};
|
361
|
-
|
362
|
-
css.top = $(window).height() * 0.15;
|
363
|
-
if (centerTop < css.top) { css.top = centerTop; }
|
364
|
-
if (css.top < min) { css.top = min; }
|
365
|
-
|
366
|
-
css.left = centerLeft;
|
367
|
-
if (css.left < min) { css.left = min; }
|
368
|
-
|
369
|
-
this.popupElem.css(css);
|
370
|
-
|
371
|
-
if (this.elem.data('romo-modal-max-height') === 'detect') {
|
372
|
-
var pad = this.elem.data('romo-modal-max-height-detect-pad') || 10;
|
373
|
-
var contentTop = this.contentElem[0].getBoundingClientRect().top;
|
374
|
-
var contentBottom = this.contentElem[0].getBoundingClientRect().bottom;
|
375
|
-
var bodyBottom = this.bodyElem[0].getBoundingClientRect().bottom;
|
376
|
-
var padBottom = bodyBottom - contentBottom;
|
377
|
-
|
378
|
-
var maxHeight = $(window).height() - contentTop - padBottom - pad;
|
379
|
-
this.contentElem.css({'max-height': maxHeight.toString() + 'px'});
|
380
|
-
}
|
381
|
-
}
|
306
|
+
// init
|
382
307
|
|
383
|
-
Romo.
|
384
|
-
|
385
|
-
});
|
308
|
+
Romo.popupStack.addStyleClass('romo-modal-popup');
|
309
|
+
Romo.addElemsInitSelector('[data-romo-modal-auto="true"]', RomoModal);
|