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/select.js
CHANGED
@@ -1,59 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return new RomoSelect(element);
|
4
|
-
});
|
5
|
-
}
|
6
|
-
|
7
|
-
var RomoSelect = function(element) {
|
8
|
-
this.elem = $(element);
|
1
|
+
var RomoSelect = RomoComponent(function(elem) {
|
2
|
+
this.elem = elem;
|
9
3
|
|
10
4
|
this.defaultCaretClass = undefined;
|
11
5
|
this.defaultCaretPaddingPx = 5;
|
6
|
+
this.defaultCaretWidthPx = 18;
|
12
7
|
this.defaultCaretPosition = 'right'
|
13
8
|
|
14
9
|
this.doInit();
|
15
10
|
this._bindElem();
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
if (this.elem.attr('id') !== undefined) {
|
20
|
-
$('label[for="'+this.elem.attr('id')+'"]').on('click', $.proxy(function(e) {
|
21
|
-
this.romoSelectDropdown.doFocus();
|
22
|
-
}, this));
|
23
|
-
}
|
24
|
-
|
25
|
-
$(window).on("pageshow", $.proxy(function(e) {
|
26
|
-
this._refreshUI();
|
27
|
-
}, this));
|
28
|
-
|
29
|
-
this.elem.on('select:triggerSetValue', $.proxy(function(e, value) {
|
30
|
-
this.doSetValue(value)
|
31
|
-
}, this));
|
32
|
-
|
33
|
-
this.elem.trigger('select:ready', [this]);
|
34
|
-
}
|
35
|
-
|
36
|
-
RomoSelect.prototype.doInit = function() {
|
37
|
-
// override as needed
|
38
|
-
}
|
12
|
+
Romo.trigger(this.elem, 'romoSelect:ready', [this]);
|
13
|
+
});
|
39
14
|
|
40
15
|
RomoSelect.prototype.doSetValue = function(value) {
|
41
|
-
var values =
|
42
|
-
|
43
|
-
values = value;
|
44
|
-
} else {
|
45
|
-
values = [value];
|
46
|
-
}
|
47
|
-
values = values.filter($.proxy(function(v) {
|
48
|
-
return this.elem.find('OPTION[value="'+v+'"]')[0] !== undefined;
|
16
|
+
var values = Romo.array(value).filter(Romo.proxy(function(v) {
|
17
|
+
return Romo.find(this.elem, 'OPTION[value="'+v+'"]')[0] !== undefined;
|
49
18
|
}, this));
|
50
19
|
|
51
20
|
this._setValues(values);
|
52
21
|
if (this.romoSelectedOptionsList !== undefined) {
|
53
|
-
var items = values.map(
|
22
|
+
var items = values.map(Romo.proxy(function(value) {
|
54
23
|
return {
|
55
24
|
'value': value,
|
56
|
-
'displayText': this.elem
|
25
|
+
'displayText': Romo.find(this.elem, 'OPTION[value="'+value+'"]')[0].innerText.trim()
|
57
26
|
};
|
58
27
|
}, this));
|
59
28
|
this.romoSelectedOptionsList.doSetItems(items);
|
@@ -63,35 +32,53 @@ RomoSelect.prototype.doSetValue = function(value) {
|
|
63
32
|
this._refreshUI();
|
64
33
|
}
|
65
34
|
|
66
|
-
|
35
|
+
// private
|
67
36
|
|
68
37
|
RomoSelect.prototype._bindElem = function() {
|
69
38
|
this._bindSelectDropdown();
|
70
39
|
this._bindSelectedOptionsList();
|
71
40
|
|
72
|
-
this.elem
|
73
|
-
this.romoSelectDropdown.elem
|
41
|
+
Romo.on(this.elem, 'romoSelect:triggerToggle', Romo.proxy(function(e) {
|
42
|
+
Romo.trigger(this.romoSelectDropdown.elem, 'romoSelectDropdown:triggerToggle', []);
|
74
43
|
}, this));
|
75
|
-
this.elem
|
76
|
-
this.romoSelectDropdown.elem
|
44
|
+
Romo.on(this.elem, 'romoSelect:triggerPopupOpen', Romo.proxy(function(e) {
|
45
|
+
Romo.trigger(this.romoSelectDropdown.elem, 'romoSelectDropdown:triggerPopupOpen', []);
|
77
46
|
}, this));
|
78
|
-
this.elem
|
79
|
-
this.romoSelectDropdown.elem
|
47
|
+
Romo.on(this.elem, 'romoSelect:triggerPopupClose', Romo.proxy(function(e) {
|
48
|
+
Romo.trigger(this.romoSelectDropdown.elem, 'romoSelectDropdown:triggerPopupClose', []);
|
49
|
+
}, this));
|
50
|
+
|
51
|
+
this.doSetValue(this._elemValues());
|
52
|
+
|
53
|
+
if (Romo.attr(this.elem, 'id') !== undefined) {
|
54
|
+
var labelElem = Romo.f('label[for="'+Romo.attr(this.elem, 'id')+'"]');
|
55
|
+
Romo.on(labelElem, 'click', Romo.proxy(function(e) {
|
56
|
+
e.preventDefault();
|
57
|
+
this.romoSelectDropdown.doFocus();
|
58
|
+
}, this));
|
59
|
+
}
|
60
|
+
|
61
|
+
Romo.on(window, "pageshow", Romo.proxy(function(e) {
|
62
|
+
this._refreshUI();
|
63
|
+
}, this));
|
64
|
+
|
65
|
+
Romo.on(this.elem, 'romoSelect:triggerSetValue', Romo.proxy(function(e, value) {
|
66
|
+
this.doSetValue(value)
|
80
67
|
}, this));
|
81
68
|
}
|
82
69
|
|
83
70
|
RomoSelect.prototype._bindSelectedOptionsList = function() {
|
84
71
|
this.romoSelectedOptionsList = undefined;
|
85
|
-
if (this.elem.
|
86
|
-
if (this.elem
|
87
|
-
this.romoSelectDropdown.elem
|
72
|
+
if (this.elem.multiple === true) {
|
73
|
+
if (Romo.data(this.elem, 'romo-select-multiple-item-class') !== undefined) {
|
74
|
+
Romo.setData(this.romoSelectDropdown.elem, 'romo-selected-options-list-item-class', Romo.data(this.elem, 'romo-select-multiple-item-class'));
|
88
75
|
}
|
89
|
-
if (this.elem
|
90
|
-
this.romoSelectDropdown.elem
|
76
|
+
if (Romo.data(this.elem, 'romo-select-multiple-max-rows') !== undefined) {
|
77
|
+
Romo.setData(this.romoSelectDropdown.elem, 'romo-selected-options-list-max-rows', Romo.data(this.elem, 'romo-select-multiple-max-rows'));
|
91
78
|
}
|
92
79
|
|
93
80
|
this.romoSelectedOptionsList = new RomoSelectedOptionsList(this.romoSelectDropdown.elem);
|
94
|
-
this.romoSelectedOptionsList.elem
|
81
|
+
Romo.on(this.romoSelectedOptionsList.elem, 'romoSelectedOptionsList:itemClick', Romo.proxy(function(e, itemValue, romoSelectedOptionsList) {
|
95
82
|
var currentValues = this._elemValues();
|
96
83
|
var index = currentValues.indexOf(itemValue);
|
97
84
|
if (index > -1) {
|
@@ -101,34 +88,34 @@ RomoSelect.prototype._bindSelectedOptionsList = function() {
|
|
101
88
|
this.romoSelectedOptionsList.doRemoveItem(itemValue);
|
102
89
|
this._refreshUI();
|
103
90
|
}, this));
|
104
|
-
this.romoSelectedOptionsList.elem
|
105
|
-
this.romoSelectDropdown.elem
|
91
|
+
Romo.on(this.romoSelectedOptionsList.elem, 'romoSelectedOptionsList:listClick', Romo.proxy(function(e, romoSelectedOptionsList) {
|
92
|
+
Romo.trigger(this.romoSelectDropdown.elem, 'romoDropdown:triggerPopupClose', []);
|
106
93
|
this.romoSelectDropdown.doFocus(false);
|
107
94
|
}, this));
|
108
95
|
|
109
|
-
|
96
|
+
Romo.before(this.elemWrapper, this.romoSelectedOptionsList.elem);
|
110
97
|
this.romoSelectedOptionsList.doRefreshUI();
|
111
98
|
}
|
112
99
|
}
|
113
100
|
|
114
101
|
RomoSelect.prototype._bindSelectDropdown = function() {
|
115
|
-
this.romoSelectDropdown = this._buildSelectDropdownElem()
|
102
|
+
this.romoSelectDropdown = new RomoSelectDropdown(this._buildSelectDropdownElem(), this.elem);
|
116
103
|
|
117
|
-
this.romoSelectDropdown.elem
|
118
|
-
this.elem
|
104
|
+
Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:romoDropdown:toggle', Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
|
105
|
+
Romo.trigger(this.elem, 'romoSelect:romoDropdown:toggle', [romoDropdown, this]);
|
119
106
|
}, this));
|
120
|
-
this.romoSelectDropdown.elem
|
121
|
-
this.elem
|
107
|
+
Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:romoDropdown:popupOpen', Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
|
108
|
+
Romo.trigger(this.elem, 'romoSelect:romoDropdown:popupOpen', [romoDropdown, this]);
|
122
109
|
}, this));
|
123
|
-
this.romoSelectDropdown.elem
|
124
|
-
this.elem
|
110
|
+
Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:romoDropdown:popupClose', Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
|
111
|
+
Romo.trigger(this.elem, 'romoSelect:romoDropdown:popupClose', [romoDropdown, this]);
|
125
112
|
}, this));
|
126
113
|
|
127
|
-
this.romoSelectDropdown.elem
|
114
|
+
Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:itemSelected', Romo.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
|
128
115
|
this.romoSelectDropdown.doFocus();
|
129
|
-
this.elem
|
116
|
+
Romo.trigger(this.elem, 'romoSelect:itemSelected', [itemValue, itemDisplayText, this]);
|
130
117
|
}, this));
|
131
|
-
this.romoSelectDropdown.elem
|
118
|
+
Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:newItemSelected', Romo.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
|
132
119
|
if (this.romoSelectedOptionsList !== undefined) {
|
133
120
|
var currentValues = this._elemValues();
|
134
121
|
if (!currentValues.includes(itemValue)) {
|
@@ -142,100 +129,103 @@ RomoSelect.prototype._bindSelectDropdown = function() {
|
|
142
129
|
this._setValues([itemValue]);
|
143
130
|
}
|
144
131
|
this._refreshUI();
|
145
|
-
this.elem
|
132
|
+
Romo.trigger(this.elem, 'romoSelect:newItemSelected', [itemValue, itemDisplayText, this]);
|
146
133
|
}, this));
|
147
|
-
this.romoSelectDropdown.elem
|
148
|
-
this.elem
|
149
|
-
this.elem
|
134
|
+
Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:change', Romo.proxy(function(e, newValue, prevValue, romoSelectDropdown) {
|
135
|
+
Romo.trigger(this.elem, 'change');
|
136
|
+
Romo.trigger(this.elem, 'romoSelect:change', [newValue, prevValue, this]);
|
150
137
|
}, this));
|
151
138
|
}
|
152
139
|
|
153
140
|
RomoSelect.prototype._buildSelectDropdownElem = function() {
|
154
|
-
var romoSelectDropdownElem =
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
141
|
+
var romoSelectDropdownElem = Romo.elems('<div class="romo-select romo-btn" tabindex="0"><span class="romo-select-text"></span></div>')[0];
|
142
|
+
|
143
|
+
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-overflow-x', 'hidden');
|
144
|
+
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-width', 'elem');
|
145
|
+
|
146
|
+
if (Romo.data(this.elem, 'romo-select-dropdown-position') !== undefined) {
|
147
|
+
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-position', Romo.data(this.elem, 'romo-select-dropdown-position'));
|
148
|
+
}
|
149
|
+
if (Romo.data(this.elem, 'romo-select-dropdown-style-class') !== undefined) {
|
150
|
+
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-style-class', Romo.data(this.elem, 'romo-select-dropdown-style-class'));
|
151
|
+
}
|
152
|
+
if (Romo.data(this.elem, 'romo-select-dropdown-min-height') !== undefined) {
|
153
|
+
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-min-height', Romo.data(this.elem, 'romo-select-dropdown-min-height'));
|
154
|
+
}
|
155
|
+
if (Romo.data(this.elem, 'romo-select-dropdown-max-height') !== undefined) {
|
156
|
+
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-max-height', Romo.data(this.elem, 'romo-select-dropdown-max-height'));
|
157
|
+
}
|
158
|
+
if (Romo.data(this.elem, 'romo-select-dropdown-height') !== undefined) {
|
159
|
+
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-height', Romo.data(this.elem, 'romo-select-dropdown-height'));
|
165
160
|
}
|
166
|
-
if (this.elem
|
167
|
-
|
161
|
+
if (Romo.data(this.elem, 'romo-select-filter-placeholder') !== undefined) {
|
162
|
+
Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-filter-placeholder', Romo.data(this.elem, 'romo-select-filter-placeholder'));
|
168
163
|
}
|
169
|
-
if (this.elem
|
170
|
-
|
164
|
+
if (Romo.data(this.elem, 'romo-select-filter-indicator') !== undefined) {
|
165
|
+
Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-filter-indicator', Romo.data(this.elem, 'romo-select-filter-indicator'));
|
171
166
|
}
|
172
|
-
if (this.elem
|
173
|
-
|
167
|
+
if (Romo.data(this.elem, 'romo-select-filter-indicator-width-px') !== undefined) {
|
168
|
+
Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-filter-indicator-width-px', Romo.data(this.elem, 'romo-select-filter-indicator-width-px'));
|
174
169
|
}
|
175
|
-
if (this.elem
|
176
|
-
|
170
|
+
if (Romo.data(this.elem, 'romo-select-no-filter') !== undefined) {
|
171
|
+
Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-no-filter', Romo.data(this.elem, 'romo-select-no-filter'));
|
177
172
|
}
|
178
|
-
if (this.elem
|
179
|
-
|
173
|
+
if (Romo.data(this.elem, 'romo-select-custom-option') !== undefined) {
|
174
|
+
Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-custom-option', Romo.data(this.elem, 'romo-select-custom-option'));
|
180
175
|
}
|
181
|
-
if (this.elem
|
182
|
-
|
176
|
+
if (Romo.data(this.elem, 'romo-select-custom-option-prompt') !== undefined) {
|
177
|
+
Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-custom-option-prompt', Romo.data(this.elem, 'romo-select-custom-option-prompt'));
|
183
178
|
}
|
184
|
-
if (this.elem
|
185
|
-
|
179
|
+
if (Romo.data(this.elem, 'romo-select-open-on-focus') !== undefined) {
|
180
|
+
Romo.setData(romoSelectDropdownElem, 'romo-select-dropdown-open-on-focus', Romo.data(this.elem, 'romo-select-open-on-focus'));
|
186
181
|
}
|
187
182
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
if (this.elem
|
193
|
-
romoSelectDropdownElem.attr(
|
183
|
+
if (Romo.data(romoSelectDropdownElem, 'romo-dropdown-max-height') === undefined) {
|
184
|
+
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-max-height', 'detect');
|
185
|
+
}
|
186
|
+
|
187
|
+
if (Romo.attr(this.elem, 'class') !== undefined) {
|
188
|
+
Romo.addClass(romoSelectDropdownElem, Romo.attr(this.elem, 'class'));
|
189
|
+
}
|
190
|
+
if (Romo.attr(this.elem, 'style') !== undefined) {
|
191
|
+
Romo.setAttr(romoSelectDropdownElem, 'style', Romo.attr(this.elem, 'style'));
|
194
192
|
}
|
195
|
-
|
196
|
-
if (this.elem
|
197
|
-
this.romoSelectDropdown.elem
|
193
|
+
Romo.setStyle(romoSelectDropdownElem, 'width', Romo.css(this.elem, 'width'));
|
194
|
+
if (Romo.attr(this.elem, 'disabled') !== undefined) {
|
195
|
+
Romo.setAttr(this.romoSelectDropdown.elem, 'disabled', Romo.attr(this.elem, 'disabled'));
|
198
196
|
}
|
199
197
|
|
200
|
-
this.elem
|
201
|
-
this.elem
|
198
|
+
Romo.after(this.elem, romoSelectDropdownElem);
|
199
|
+
Romo.hide(this.elem);
|
202
200
|
|
203
|
-
this.elemWrapper =
|
204
|
-
if (this.elem
|
205
|
-
this.elemWrapper
|
201
|
+
this.elemWrapper = Romo.elems('<div class="romo-select-wrapper"></div>')[0];
|
202
|
+
if (Romo.data(this.elem, 'romo-select-btn-group') === true) {
|
203
|
+
Romo.addClass(this.elemWrapper, 'romo-btn-group');
|
206
204
|
}
|
207
|
-
|
208
|
-
this.elemWrapper
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
// meaning the select is removed and then re-added. if added immediately
|
214
|
-
// the "remove" part will incorrectly remove the wrapper.
|
215
|
-
setTimeout($.proxy(function() {
|
216
|
-
Romo.parentChildElems.add(this.elem, [this.elemWrapper]);
|
217
|
-
}, this), 1);
|
218
|
-
|
219
|
-
this.caretElem = $();
|
220
|
-
var caretClass = this.elem.data('romo-select-caret') || this.defaultCaretClass;
|
205
|
+
Romo.before(romoSelectDropdownElem, this.elemWrapper);
|
206
|
+
Romo.append(this.elemWrapper, romoSelectDropdownElem);
|
207
|
+
Romo.parentChildElems.add(this.elem, [this.elemWrapper]);
|
208
|
+
|
209
|
+
this.caretElem = undefined;
|
210
|
+
var caretClass = Romo.data(this.elem, 'romo-select-caret') || this.defaultCaretClass;
|
221
211
|
if (caretClass !== undefined && caretClass !== 'none') {
|
222
|
-
this.caretElem =
|
223
|
-
this.caretElem
|
224
|
-
this.caretElem
|
225
|
-
|
212
|
+
this.caretElem = Romo.elems('<i class="romo-select-caret '+caretClass+'"></i>')[0];
|
213
|
+
Romo.setStyle(this.caretElem, 'line-height', parseInt(Romo.css(romoSelectDropdownElem, "line-height"), 10)+'px');
|
214
|
+
Romo.on(this.caretElem, 'click', Romo.proxy(this._onCaretClick, this));
|
215
|
+
Romo.append(romoSelectDropdownElem, this.caretElem);
|
226
216
|
|
227
217
|
var caretPaddingPx = this._getCaretPaddingPx();
|
228
218
|
var caretWidthPx = this._getCaretWidthPx();
|
229
219
|
var caretPosition = this._getCaretPosition();
|
230
220
|
|
231
221
|
// add a pixel to account for the default input border
|
232
|
-
this.caretElem
|
222
|
+
Romo.setStyle(this.caretElem, caretPosition, caretPaddingPx+1+'px');
|
233
223
|
|
234
224
|
// left-side padding
|
235
225
|
// + caret width
|
236
226
|
// + right-side padding
|
237
227
|
var dropdownPaddingPx = caretPaddingPx + caretWidthPx + caretPaddingPx;
|
238
|
-
|
228
|
+
Romo.setStyle(romoSelectDropdownElem, 'padding-'+caretPosition, dropdownPaddingPx+'px');
|
239
229
|
}
|
240
230
|
|
241
231
|
return romoSelectDropdownElem;
|
@@ -250,72 +240,94 @@ RomoSelect.prototype._setValues = function(newValues) {
|
|
250
240
|
var setValues = newValues.filter(function(value) {
|
251
241
|
return currentValues.indexOf(value) === -1;
|
252
242
|
});
|
253
|
-
var unsetElems = unsetValues.
|
254
|
-
return
|
255
|
-
}, this)
|
256
|
-
var setElems = setValues.
|
257
|
-
return
|
258
|
-
}, this)
|
259
|
-
|
260
|
-
unsetElems.
|
261
|
-
|
262
|
-
|
263
|
-
|
243
|
+
var unsetElems = unsetValues.map(Romo.proxy(function(value) {
|
244
|
+
return Romo.find(this.elem, 'OPTION[value="'+value+'"]')[0];
|
245
|
+
}, this));
|
246
|
+
var setElems = setValues.map(Romo.proxy(function(value) {
|
247
|
+
return Romo.find(this.elem, 'OPTION[value="'+value+'"]')[0];
|
248
|
+
}, this));
|
249
|
+
|
250
|
+
unsetElems.forEach(Romo.proxy(function(unsetElem) {
|
251
|
+
Romo.rmAttr(unsetElem, 'selected');
|
252
|
+
unsetElem.selected = false;
|
253
|
+
}, this));
|
254
|
+
setElems.forEach(Romo.proxy(function(setElem) {
|
255
|
+
Romo.setAttr(setElem, 'selected', 'selected');
|
256
|
+
setElem.selected = true;
|
257
|
+
}, this));
|
264
258
|
}
|
265
259
|
|
266
260
|
RomoSelect.prototype._elemValues = function() {
|
267
|
-
var
|
268
|
-
if (
|
261
|
+
var selectedOptElems = Romo.find(this.elem, 'OPTION[selected]');
|
262
|
+
if (selectedOptElems.length === 0 && this.romoSelectedOptionsList === undefined) {
|
269
263
|
// if a non-multi select has no selected options, treat the first option as selected
|
270
|
-
|
264
|
+
var firstOptElem = Romo.find(this.elem, 'OPTION')[0];
|
265
|
+
if (firstOptElem !== undefined) {
|
266
|
+
selectedOptElems = [firstOptElem];
|
267
|
+
}
|
271
268
|
}
|
272
|
-
return
|
273
|
-
return (
|
269
|
+
return selectedOptElems.map(function(selectedOptElem) {
|
270
|
+
return (Romo.attr(selectedOptElem, 'value') || '');
|
274
271
|
});
|
275
272
|
}
|
276
273
|
|
277
274
|
RomoSelect.prototype._refreshUI = function() {
|
278
|
-
var text =
|
275
|
+
var text = '';
|
279
276
|
if (this.romoSelectedOptionsList !== undefined) {
|
280
|
-
text = '';
|
281
277
|
this.romoSelectedOptionsList.doRefreshUI();
|
282
|
-
} else {
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
278
|
+
} else if (this._elemValues().length !== 0) {
|
279
|
+
var optionElem = Romo.find(this.elem, 'OPTION[value="'+this._elemValues()[0]+'"]')[0];
|
280
|
+
if (optionElem !== undefined) {
|
281
|
+
text = optionElem.innerText.trim();
|
282
|
+
}
|
287
283
|
}
|
288
|
-
this.romoSelectDropdown.elem.find('.romo-select-text').html(text);
|
289
|
-
}
|
290
284
|
|
291
|
-
|
292
|
-
if (
|
293
|
-
|
294
|
-
|
285
|
+
var textElem = Romo.find(this.romoSelectDropdown.elem, '.romo-select-text')[0];
|
286
|
+
if (text === '') {
|
287
|
+
Romo.updateHtml(textElem, '<span> </span>');
|
288
|
+
} else {
|
289
|
+
Romo.updateText(textElem, text);
|
295
290
|
}
|
296
291
|
}
|
297
292
|
|
298
293
|
RomoSelect.prototype._getCaretPaddingPx = function() {
|
299
294
|
return (
|
300
|
-
this.elem
|
295
|
+
Romo.data(this.elem, 'romo-select-caret-padding-px') ||
|
301
296
|
this.defaultCaretPaddingPx
|
302
297
|
);
|
303
298
|
}
|
304
299
|
|
305
300
|
RomoSelect.prototype._getCaretWidthPx = function() {
|
306
301
|
return (
|
307
|
-
this.elem
|
308
|
-
|
302
|
+
Romo.data(this.elem, 'romo-select-caret-width-px') ||
|
303
|
+
this._parseCaretWidthPx()
|
309
304
|
);
|
310
305
|
}
|
311
306
|
|
312
307
|
RomoSelect.prototype._getCaretPosition = function() {
|
313
308
|
return (
|
314
|
-
this.elem
|
309
|
+
Romo.data(this.elem, 'romo-select-caret-position') ||
|
315
310
|
this.defaultCaretPosition
|
316
311
|
);
|
317
312
|
}
|
318
313
|
|
319
|
-
|
320
|
-
Romo.
|
321
|
-
|
314
|
+
RomoSelect.prototype._parseCaretWidthPx = function() {
|
315
|
+
var widthPx = parseInt(Romo.css(this.caretElem, "width"), 10);
|
316
|
+
if (isNaN(widthPx)) {
|
317
|
+
widthPx = this.defaultCaretWidthPx;
|
318
|
+
}
|
319
|
+
return widthPx;
|
320
|
+
}
|
321
|
+
|
322
|
+
// event functions
|
323
|
+
|
324
|
+
RomoSelect.prototype.romoEvFn._onCaretClick = function(e) {
|
325
|
+
if (this.elem.disabled === false) {
|
326
|
+
this.romoSelectDropdown.doFocus();
|
327
|
+
Romo.trigger(this.elem, 'romoSelect:triggerPopupOpen');
|
328
|
+
}
|
329
|
+
}
|
330
|
+
|
331
|
+
// init
|
332
|
+
|
333
|
+
Romo.addElemsInitSelector('[data-romo-select-auto="true"]', RomoSelect);
|