romo 0.20.10 → 0.20.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/assets/css/romo/color_select.scss +62 -0
- data/assets/js/romo/color_select.js +580 -0
- data/assets/js/romo/dropdown.js +13 -5
- data/assets/js/romo/modal.js +16 -3
- data/assets/js/romo/option_list_dropdown.js +80 -26
- data/assets/js/romo/picker.js +225 -83
- data/assets/js/romo/select.js +192 -63
- data/assets/js/romo/select_dropdown.js +149 -60
- data/assets/js/romo/selected_options_list.js +32 -5
- data/assets/js/romo/tooltip.js +16 -2
- data/assets/js/romo/word_boundary_filter.js +11 -7
- data/lib/romo/dassets.rb +2 -0
- data/lib/romo/version.rb +1 -1
- data/test/unit/dassets_tests.rb +2 -0
- metadata +4 -2
data/assets/js/romo/select.js
CHANGED
@@ -71,27 +71,50 @@ RomoSelect.prototype._bindSelectedOptionsList = function() {
|
|
71
71
|
this.romoSelectedOptionsList = undefined;
|
72
72
|
if (this.elem.multiple === true) {
|
73
73
|
if (Romo.data(this.elem, 'romo-select-multiple-item-class') !== undefined) {
|
74
|
-
Romo.setData(
|
74
|
+
Romo.setData(
|
75
|
+
this.romoSelectDropdown.elem,
|
76
|
+
'romo-selected-options-list-item-class',
|
77
|
+
Romo.data(this.elem, 'romo-select-multiple-item-class')
|
78
|
+
);
|
75
79
|
}
|
76
80
|
if (Romo.data(this.elem, 'romo-select-multiple-max-rows') !== undefined) {
|
77
|
-
Romo.setData(
|
81
|
+
Romo.setData(
|
82
|
+
this.romoSelectDropdown.elem,
|
83
|
+
'romo-selected-options-list-max-rows',
|
84
|
+
Romo.data(this.elem, 'romo-select-multiple-max-rows')
|
85
|
+
);
|
78
86
|
}
|
79
87
|
|
80
88
|
this.romoSelectedOptionsList = new RomoSelectedOptionsList(this.romoSelectDropdown.elem);
|
81
|
-
Romo.on(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
currentValues.
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
89
|
+
Romo.on(
|
90
|
+
this.romoSelectedOptionsList.elem,
|
91
|
+
'romoSelectedOptionsList:itemClick',
|
92
|
+
Romo.proxy(function(e, itemValue, romoSelectedOptionsList) {
|
93
|
+
var currentValues = this._elemValues();
|
94
|
+
var index = currentValues.indexOf(itemValue);
|
95
|
+
if (index > -1) {
|
96
|
+
currentValues.splice(index, 1);
|
97
|
+
this._setValues(currentValues);
|
98
|
+
}
|
99
|
+
this.romoSelectedOptionsList.doRemoveItem(itemValue);
|
100
|
+
this._refreshUI();
|
101
|
+
|
102
|
+
Romo.trigger(this.elem, 'change');
|
103
|
+
Romo.trigger(
|
104
|
+
this.elem,
|
105
|
+
'romoSelect:multipleChange',
|
106
|
+
[currentValues, itemValue, this]
|
107
|
+
);
|
108
|
+
}, this)
|
109
|
+
);
|
110
|
+
Romo.on(
|
111
|
+
this.romoSelectedOptionsList.elem,
|
112
|
+
'romoSelectedOptionsList:listClick',
|
113
|
+
Romo.proxy(function(e, romoSelectedOptionsList) {
|
114
|
+
Romo.trigger(this.romoSelectDropdown.elem, 'romoDropdown:triggerPopupClose', []);
|
115
|
+
this.romoSelectDropdown.doFocus(false);
|
116
|
+
}, this)
|
117
|
+
);
|
95
118
|
|
96
119
|
Romo.before(this.elemWrapper, this.romoSelectedOptionsList.elem);
|
97
120
|
this.romoSelectedOptionsList.doRefreshUI();
|
@@ -101,83 +124,181 @@ RomoSelect.prototype._bindSelectedOptionsList = function() {
|
|
101
124
|
RomoSelect.prototype._bindSelectDropdown = function() {
|
102
125
|
this.romoSelectDropdown = new RomoSelectDropdown(this._buildSelectDropdownElem(), this.elem);
|
103
126
|
|
104
|
-
Romo.on(
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
127
|
+
Romo.on(
|
128
|
+
this.romoSelectDropdown.elem,
|
129
|
+
'romoSelectDropdown:romoDropdown:toggle',
|
130
|
+
Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
|
131
|
+
Romo.trigger(this.elem, 'romoSelect:romoDropdown:toggle', [romoDropdown, this]);
|
132
|
+
}, this)
|
133
|
+
);
|
134
|
+
Romo.on(
|
135
|
+
this.romoSelectDropdown.elem,
|
136
|
+
'romoSelectDropdown:romoDropdown:popupOpen',
|
137
|
+
Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
|
138
|
+
Romo.trigger(this.elem, 'romoSelect:romoDropdown:popupOpen', [romoDropdown, this]);
|
139
|
+
}, this)
|
140
|
+
);
|
141
|
+
Romo.on(
|
142
|
+
this.romoSelectDropdown.elem,
|
143
|
+
'romoSelectDropdown:romoDropdown:popupClose',
|
144
|
+
Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
|
145
|
+
Romo.trigger(this.elem, 'romoSelect:romoDropdown:popupClose', [romoDropdown, this]);
|
146
|
+
}, this)
|
147
|
+
);
|
113
148
|
|
114
|
-
Romo.on(
|
115
|
-
this.romoSelectDropdown.
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
149
|
+
Romo.on(
|
150
|
+
this.romoSelectDropdown.elem,
|
151
|
+
'romoSelectDropdown:itemSelected',
|
152
|
+
Romo.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
|
153
|
+
this.romoSelectDropdown.doFocus();
|
154
|
+
Romo.trigger(this.elem, 'romoSelect:itemSelected', [itemValue, itemDisplayText, this]);
|
155
|
+
}, this)
|
156
|
+
);
|
157
|
+
Romo.on(
|
158
|
+
this.romoSelectDropdown.elem,
|
159
|
+
'romoSelectDropdown:newItemSelected',
|
160
|
+
Romo.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
|
161
|
+
if (this.romoSelectedOptionsList !== undefined) {
|
162
|
+
var currentValues = this._elemValues();
|
163
|
+
if (!currentValues.includes(itemValue)) {
|
164
|
+
this._setValues(currentValues.concat([itemValue]));
|
165
|
+
this.romoSelectedOptionsList.doAddItem({
|
166
|
+
'value': itemValue,
|
167
|
+
'displayText': itemDisplayText
|
168
|
+
});
|
169
|
+
}
|
170
|
+
} else {
|
171
|
+
this._setValues([itemValue]);
|
127
172
|
}
|
128
|
-
|
129
|
-
this.
|
130
|
-
}
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
Romo.
|
136
|
-
|
137
|
-
|
173
|
+
this._refreshUI();
|
174
|
+
Romo.trigger(this.elem, 'romoSelect:newItemSelected', [itemValue, itemDisplayText, this]);
|
175
|
+
}, this)
|
176
|
+
);
|
177
|
+
Romo.on(
|
178
|
+
this.romoSelectDropdown.elem,
|
179
|
+
'romoSelectDropdown:change',
|
180
|
+
Romo.proxy(function(e, newValue, prevValue, romoSelectDropdown) {
|
181
|
+
Romo.trigger(this.elem, 'change');
|
182
|
+
if (this.romoSelectedOptionsList !== undefined) {
|
183
|
+
Romo.trigger(
|
184
|
+
this.elem,
|
185
|
+
'romoSelect:multipleChange',
|
186
|
+
[this._elemValues(), newValue, this]
|
187
|
+
);
|
188
|
+
} else {
|
189
|
+
Romo.trigger(this.elem, 'romoSelect:change', [newValue, prevValue, this]);
|
190
|
+
}
|
191
|
+
}, this)
|
192
|
+
);
|
138
193
|
}
|
139
194
|
|
140
195
|
RomoSelect.prototype._buildSelectDropdownElem = function() {
|
141
|
-
var romoSelectDropdownElem = Romo.elems(
|
196
|
+
var romoSelectDropdownElem = Romo.elems(
|
197
|
+
'<div class="romo-select romo-btn" tabindex="0">'+
|
198
|
+
'<span class="romo-select-text"></span>'+
|
199
|
+
'</div>'
|
200
|
+
)[0];
|
142
201
|
|
143
202
|
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-overflow-x', 'hidden');
|
144
203
|
Romo.setData(romoSelectDropdownElem, 'romo-dropdown-width', 'elem');
|
145
204
|
|
146
205
|
if (Romo.data(this.elem, 'romo-select-dropdown-position') !== undefined) {
|
147
|
-
Romo.setData(
|
206
|
+
Romo.setData(
|
207
|
+
romoSelectDropdownElem,
|
208
|
+
'romo-dropdown-position',
|
209
|
+
Romo.data(this.elem, 'romo-select-dropdown-position')
|
210
|
+
);
|
148
211
|
}
|
149
212
|
if (Romo.data(this.elem, 'romo-select-dropdown-style-class') !== undefined) {
|
150
|
-
Romo.setData(
|
213
|
+
Romo.setData(
|
214
|
+
romoSelectDropdownElem,
|
215
|
+
'romo-dropdown-style-class',
|
216
|
+
Romo.data(this.elem, 'romo-select-dropdown-style-class')
|
217
|
+
);
|
151
218
|
}
|
152
219
|
if (Romo.data(this.elem, 'romo-select-dropdown-min-height') !== undefined) {
|
153
|
-
Romo.setData(
|
220
|
+
Romo.setData(
|
221
|
+
romoSelectDropdownElem,
|
222
|
+
'romo-dropdown-min-height',
|
223
|
+
Romo.data(this.elem, 'romo-select-dropdown-min-height')
|
224
|
+
);
|
154
225
|
}
|
155
226
|
if (Romo.data(this.elem, 'romo-select-dropdown-max-height') !== undefined) {
|
156
|
-
Romo.setData(
|
227
|
+
Romo.setData(
|
228
|
+
romoSelectDropdownElem,
|
229
|
+
'romo-dropdown-max-height',
|
230
|
+
Romo.data(this.elem, 'romo-select-dropdown-max-height')
|
231
|
+
);
|
157
232
|
}
|
158
233
|
if (Romo.data(this.elem, 'romo-select-dropdown-height') !== undefined) {
|
159
|
-
Romo.setData(
|
234
|
+
Romo.setData(
|
235
|
+
romoSelectDropdownElem,
|
236
|
+
'romo-dropdown-height',
|
237
|
+
Romo.data(this.elem, 'romo-select-dropdown-height')
|
238
|
+
);
|
239
|
+
}
|
240
|
+
if (Romo.data(this.elem, 'romo-select-dropdown-append-to-closest') !== undefined) {
|
241
|
+
Romo.setData(
|
242
|
+
romoOptionListDropdownElem,
|
243
|
+
'romo-dropdown-append-to-closest',
|
244
|
+
Romo.data(this.elem, 'romo-select-dropdown-append-to-closest')
|
245
|
+
);
|
246
|
+
}
|
247
|
+
if (Romo.data(this.elem, 'romo-select-dropdown-append-to') !== undefined) {
|
248
|
+
Romo.setData(
|
249
|
+
romoOptionListDropdownElem,
|
250
|
+
'romo-dropdown-append-to',
|
251
|
+
Romo.data(this.elem, 'romo-select-dropdown-append-to')
|
252
|
+
);
|
160
253
|
}
|
161
254
|
if (Romo.data(this.elem, 'romo-select-filter-placeholder') !== undefined) {
|
162
|
-
Romo.setData(
|
255
|
+
Romo.setData(
|
256
|
+
romoSelectDropdownElem,
|
257
|
+
'romo-select-dropdown-filter-placeholder',
|
258
|
+
Romo.data(this.elem, 'romo-select-filter-placeholder')
|
259
|
+
);
|
163
260
|
}
|
164
261
|
if (Romo.data(this.elem, 'romo-select-filter-indicator') !== undefined) {
|
165
|
-
Romo.setData(
|
262
|
+
Romo.setData(
|
263
|
+
romoSelectDropdownElem,
|
264
|
+
'romo-select-dropdown-filter-indicator',
|
265
|
+
Romo.data(this.elem, 'romo-select-filter-indicator')
|
266
|
+
);
|
166
267
|
}
|
167
268
|
if (Romo.data(this.elem, 'romo-select-filter-indicator-width-px') !== undefined) {
|
168
|
-
Romo.setData(
|
269
|
+
Romo.setData(
|
270
|
+
romoSelectDropdownElem,
|
271
|
+
'romo-select-dropdown-filter-indicator-width-px',
|
272
|
+
Romo.data(this.elem, 'romo-select-filter-indicator-width-px')
|
273
|
+
);
|
169
274
|
}
|
170
275
|
if (Romo.data(this.elem, 'romo-select-no-filter') !== undefined) {
|
171
|
-
Romo.setData(
|
276
|
+
Romo.setData(
|
277
|
+
romoSelectDropdownElem,
|
278
|
+
'romo-select-dropdown-no-filter',
|
279
|
+
Romo.data(this.elem, 'romo-select-no-filter')
|
280
|
+
);
|
172
281
|
}
|
173
282
|
if (Romo.data(this.elem, 'romo-select-custom-option') !== undefined) {
|
174
|
-
Romo.setData(
|
283
|
+
Romo.setData(
|
284
|
+
romoSelectDropdownElem,
|
285
|
+
'romo-select-dropdown-custom-option',
|
286
|
+
Romo.data(this.elem, 'romo-select-custom-option')
|
287
|
+
);
|
175
288
|
}
|
176
289
|
if (Romo.data(this.elem, 'romo-select-custom-option-prompt') !== undefined) {
|
177
|
-
Romo.setData(
|
290
|
+
Romo.setData(
|
291
|
+
romoSelectDropdownElem,
|
292
|
+
'romo-select-dropdown-custom-option-prompt',
|
293
|
+
Romo.data(this.elem, 'romo-select-custom-option-prompt')
|
294
|
+
);
|
178
295
|
}
|
179
296
|
if (Romo.data(this.elem, 'romo-select-open-on-focus') !== undefined) {
|
180
|
-
Romo.setData(
|
297
|
+
Romo.setData(
|
298
|
+
romoSelectDropdownElem,
|
299
|
+
'romo-select-dropdown-open-on-focus',
|
300
|
+
Romo.data(this.elem, 'romo-select-open-on-focus')
|
301
|
+
);
|
181
302
|
}
|
182
303
|
|
183
304
|
if (Romo.data(romoSelectDropdownElem, 'romo-dropdown-max-height') === undefined) {
|
@@ -210,7 +331,11 @@ RomoSelect.prototype._buildSelectDropdownElem = function() {
|
|
210
331
|
var caretClass = Romo.data(this.elem, 'romo-select-caret') || this.defaultCaretClass;
|
211
332
|
if (caretClass !== undefined && caretClass !== 'none') {
|
212
333
|
this.caretElem = Romo.elems('<i class="romo-select-caret '+caretClass+'"></i>')[0];
|
213
|
-
Romo.setStyle(
|
334
|
+
Romo.setStyle(
|
335
|
+
this.caretElem,
|
336
|
+
'line-height',
|
337
|
+
Romo.css(romoSelectDropdownElem, 'line-height')
|
338
|
+
);
|
214
339
|
Romo.on(this.caretElem, 'click', Romo.proxy(this._onCaretClick, this));
|
215
340
|
Romo.append(romoSelectDropdownElem, this.caretElem);
|
216
341
|
|
@@ -225,7 +350,11 @@ RomoSelect.prototype._buildSelectDropdownElem = function() {
|
|
225
350
|
// + caret width
|
226
351
|
// + right-side padding
|
227
352
|
var dropdownPaddingPx = caretPaddingPx + caretWidthPx + caretPaddingPx;
|
228
|
-
Romo.setStyle(
|
353
|
+
Romo.setStyle(
|
354
|
+
romoSelectDropdownElem,
|
355
|
+
'padding-'+caretPosition,
|
356
|
+
dropdownPaddingPx+'px'
|
357
|
+
);
|
229
358
|
}
|
230
359
|
|
231
360
|
return romoSelectDropdownElem;
|
@@ -65,52 +65,125 @@ RomoSelectDropdown.prototype._bindElem = function() {
|
|
65
65
|
Romo.setData(this.elem, 'romo-option-list-focus-style-class', 'romo-select-focus');
|
66
66
|
|
67
67
|
if (Romo.data(this.elem, 'romo-select-dropdown-no-filter') !== undefined) {
|
68
|
-
Romo.setData(
|
68
|
+
Romo.setData(
|
69
|
+
this.elem,
|
70
|
+
'romo-option-list-dropdown-no-filter',
|
71
|
+
Romo.data(this.elem, 'romo-select-dropdown-no-filter')
|
72
|
+
);
|
69
73
|
}
|
70
74
|
if (Romo.data(this.elem, 'romo-select-dropdown-filter-placeholder') !== undefined) {
|
71
|
-
Romo.setData(
|
75
|
+
Romo.setData(
|
76
|
+
this.elem,
|
77
|
+
'romo-option-list-dropdown-filter-placeholder',
|
78
|
+
Romo.data(this.elem, 'romo-select-dropdown-filter-placeholder')
|
79
|
+
);
|
72
80
|
}
|
73
81
|
if (Romo.data(this.elem, 'romo-select-dropdown-filter-indicator') !== undefined) {
|
74
|
-
Romo.setData(
|
82
|
+
Romo.setData(
|
83
|
+
this.elem,
|
84
|
+
'romo-option-list-dropdown-filter-indicator',
|
85
|
+
Romo.data(this.elem, 'romo-select-dropdown-filter-indicator')
|
86
|
+
);
|
75
87
|
}
|
76
88
|
if (Romo.data(this.elem, 'romo-select-dropdown-filter-indicator-width-px') !== undefined) {
|
77
|
-
Romo.setData(
|
89
|
+
Romo.setData(
|
90
|
+
this.elem,
|
91
|
+
'romo-option-list-dropdown-filter-indicator-width-px',
|
92
|
+
Romo.data(this.elem, 'romo-select-dropdown-filter-indicator-width-px')
|
93
|
+
);
|
78
94
|
}
|
79
95
|
if (Romo.data(this.elem, 'romo-select-dropdown-open-on-focus') !== undefined) {
|
80
|
-
Romo.setData(
|
96
|
+
Romo.setData(
|
97
|
+
this.elem,
|
98
|
+
'romo-option-list-dropdown-open-on-focus',
|
99
|
+
Romo.data(this.elem, 'romo-select-dropdown-open-on-focus')
|
100
|
+
);
|
81
101
|
}
|
82
102
|
|
83
|
-
Romo.on(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
103
|
+
Romo.on(
|
104
|
+
this.elem,
|
105
|
+
'romoOptionListDropdown:romoDropdown:toggle',
|
106
|
+
Romo.proxy(function(e, romoDropdown) {
|
107
|
+
Romo.trigger(
|
108
|
+
this.elem,
|
109
|
+
'romoSelectDropdown:romoDropdown:toggle',
|
110
|
+
[romoDropdown, this]
|
111
|
+
);
|
112
|
+
}, this)
|
113
|
+
);
|
114
|
+
Romo.on(
|
115
|
+
this.elem,
|
116
|
+
'romoOptionListDropdown:romoDropdown:popupOpen',
|
117
|
+
Romo.proxy(function(e, romoDropdown) {
|
118
|
+
Romo.trigger(
|
119
|
+
this.elem,
|
120
|
+
'romoSelectDropdown:romoDropdown:popupOpen',
|
121
|
+
[romoDropdown, this]
|
122
|
+
);
|
123
|
+
}, this)
|
124
|
+
);
|
125
|
+
Romo.on(
|
126
|
+
this.elem,
|
127
|
+
'romoOptionListDropdown:romoDropdown:popupClose',
|
128
|
+
Romo.proxy(function(e, romoDropdown) {
|
129
|
+
Romo.trigger(
|
130
|
+
this.elem,
|
131
|
+
'romoSelectDropdown:romoDropdown:popupClose',
|
132
|
+
[romoDropdown, this]
|
133
|
+
);
|
134
|
+
}, this)
|
135
|
+
);
|
136
|
+
Romo.on(
|
137
|
+
this.elem,
|
138
|
+
'romoOptionListDropdown:itemSelected',
|
139
|
+
Romo.proxy(function(e, itemValue, itemDisplayText, romoOptionListDropdown) {
|
140
|
+
Romo.trigger(
|
141
|
+
this.elem,
|
142
|
+
'romoSelectDropdown:itemSelected',
|
143
|
+
[itemValue, itemDisplayText, this]
|
144
|
+
);
|
145
|
+
}, this)
|
146
|
+
);
|
147
|
+
Romo.on(
|
148
|
+
this.elem,
|
149
|
+
'romoOptionListDropdown:newItemSelected',
|
150
|
+
Romo.proxy(function(e, itemValue, itemDisplayText, romoOptionListDropdown) {
|
151
|
+
var custOptElem = Romo.find(
|
152
|
+
this.optionElemsParentElem,
|
153
|
+
'OPTION[data-romo-select-dropdown-custom-option="true"]'
|
154
|
+
)[0];
|
155
|
+
if (Romo.find(this.optionElemsParentElem, 'OPTION[value="'+itemValue+'"]').length === 0){
|
156
|
+
// a custom value is being selected. add a custom option elem and update its value/text
|
157
|
+
if (custOptElem === undefined) {
|
158
|
+
Romo.appendHtml(
|
159
|
+
this.optionElemsParentElem,
|
160
|
+
'<option data-romo-select-dropdown-custom-option="true"></option>'
|
161
|
+
);
|
162
|
+
custOptElem = Romo.find(
|
163
|
+
this.optionElemsParentElem,
|
164
|
+
'OPTION[data-romo-select-dropdown-custom-option="true"]'
|
165
|
+
)[0];
|
166
|
+
}
|
167
|
+
Romo.setAttr(custOptElem, 'value', itemValue);
|
168
|
+
Romo.updateText(custOptElem, itemDisplayText);
|
169
|
+
} else if (custOptElem !== undefined) {
|
170
|
+
// a non custom value is being selected. remove any existing custom option
|
171
|
+
Romo.remove(custOptElem);
|
102
172
|
}
|
103
|
-
Romo.
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
}
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
173
|
+
Romo.trigger(
|
174
|
+
this.elem,
|
175
|
+
'romoSelectDropdown:newItemSelected',
|
176
|
+
[itemValue, itemDisplayText, this]
|
177
|
+
);
|
178
|
+
}, this)
|
179
|
+
);
|
180
|
+
Romo.on(
|
181
|
+
this.elem,
|
182
|
+
'romoOptionListDropdown:change',
|
183
|
+
Romo.proxy(function(e, newValue, prevValue, romoOptionListDropdown) {
|
184
|
+
Romo.trigger(this.elem, 'romoSelectDropdown:change', [newValue, prevValue, this]);
|
185
|
+
}, this)
|
186
|
+
);
|
114
187
|
|
115
188
|
|
116
189
|
Romo.on(this.elem, 'romoSelectDropdown:triggerToggle', Romo.proxy(function(e) {
|
@@ -125,29 +198,45 @@ RomoSelectDropdown.prototype._bindElem = function() {
|
|
125
198
|
|
126
199
|
this.romoOptionListDropdown = new RomoOptionListDropdown(this.elem);
|
127
200
|
|
128
|
-
Romo.on(
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
201
|
+
Romo.on(
|
202
|
+
this.elem,
|
203
|
+
'romoOptionListDropdown:filterChange',
|
204
|
+
Romo.proxy(function(e, filterValue, romoOptionListDropdown) {
|
205
|
+
var elems = Romo.find(this.optionElemsParentElem, 'OPTION');
|
206
|
+
var wbFilter = new RomoWordBoundaryFilter(filterValue, elems, function(elem) {
|
207
|
+
// The romo word boundary filter by default considers a space, "-" and "_"
|
208
|
+
// as word boundaries. We want to also consider other non-word characters
|
209
|
+
// (such as ":", "/", ".", "?", "=", "&") as word boundaries as well.
|
210
|
+
return elem.textContent.replace(/\W/g, ' ');
|
211
|
+
});
|
212
|
+
|
213
|
+
Romo.removeClass(wbFilter.matchingItems, this.filterHiddenClass);
|
214
|
+
Romo.addClass(wbFilter.notMatchingItems, this.filterHiddenClass);
|
215
|
+
this._setListItems();
|
216
|
+
|
217
|
+
if (filterValue !== '') {
|
218
|
+
Romo.trigger(
|
219
|
+
this.romoOptionListDropdown.elem,
|
220
|
+
'romoOptionListDropdown:triggerListOptionsUpdate',
|
221
|
+
[this.optItemElems()[0]]
|
222
|
+
);
|
223
|
+
} else {
|
224
|
+
Romo.trigger(
|
225
|
+
this.elem,
|
226
|
+
'romoOptionListDropdown:triggerListOptionsUpdate',
|
227
|
+
[this.selectedItemElem()]
|
228
|
+
);
|
229
|
+
}
|
230
|
+
}, this)
|
231
|
+
);
|
147
232
|
|
148
233
|
this._sanitizeOptions();
|
149
234
|
this._setListItems();
|
150
|
-
Romo.trigger(
|
235
|
+
Romo.trigger(
|
236
|
+
this.elem,
|
237
|
+
'romoOptionListDropdown:triggerListOptionsUpdate',
|
238
|
+
[this.selectedItemElem()]
|
239
|
+
);
|
151
240
|
|
152
241
|
if (Romo.attr(this.elem, 'id') !== undefined) {
|
153
242
|
var labelElem = Romo.f('label[for="'+Romo.attr(this.elem, 'id')+'"]');
|
@@ -176,20 +265,20 @@ RomoSelectDropdown.prototype._setListItems = function() {
|
|
176
265
|
}
|
177
266
|
|
178
267
|
RomoSelectDropdown.prototype._buildOptionListItems = function(optionElems) {
|
179
|
-
var
|
268
|
+
var items = [];
|
180
269
|
|
181
270
|
optionElems.forEach(Romo.proxy(function(optElem) {
|
182
271
|
if (optElem.tagName === "OPTION") {
|
183
|
-
|
272
|
+
items.push(this._buildOptionItem(optElem));
|
184
273
|
} else if (optElem.tagName === "OPTGROUP") {
|
185
274
|
var optGroupItem = this._buildOptGroupItem(optElem);
|
186
275
|
if (optGroupItem.items.length !== 0) {
|
187
|
-
|
276
|
+
items.push(optGroupItem);
|
188
277
|
}
|
189
278
|
}
|
190
279
|
}, this));
|
191
280
|
|
192
|
-
return
|
281
|
+
return items;
|
193
282
|
}
|
194
283
|
|
195
284
|
RomoSelectDropdown.prototype._buildOptionItem = function(optionElem) {
|
@@ -245,7 +334,7 @@ RomoSelectDropdown.prototype._buildCustomOptionItem = function(value) {
|
|
245
334
|
'type': 'option',
|
246
335
|
'value': value,
|
247
336
|
'displayText': value,
|
248
|
-
'displayHtml': value
|
337
|
+
'displayHtml': '<span>'+value+'</span>'
|
249
338
|
};
|
250
339
|
}
|
251
340
|
|