romo 0.20.10 → 0.20.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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(this.romoSelectDropdown.elem, 'romo-selected-options-list-item-class', Romo.data(this.elem, 'romo-select-multiple-item-class'));
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(this.romoSelectDropdown.elem, 'romo-selected-options-list-max-rows', Romo.data(this.elem, 'romo-select-multiple-max-rows'));
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(this.romoSelectedOptionsList.elem, 'romoSelectedOptionsList:itemClick', Romo.proxy(function(e, itemValue, romoSelectedOptionsList) {
82
- var currentValues = this._elemValues();
83
- var index = currentValues.indexOf(itemValue);
84
- if (index > -1) {
85
- currentValues.splice(index, 1);
86
- this._setValues(currentValues);
87
- }
88
- this.romoSelectedOptionsList.doRemoveItem(itemValue);
89
- this._refreshUI();
90
- }, this));
91
- Romo.on(this.romoSelectedOptionsList.elem, 'romoSelectedOptionsList:listClick', Romo.proxy(function(e, romoSelectedOptionsList) {
92
- Romo.trigger(this.romoSelectDropdown.elem, 'romoDropdown:triggerPopupClose', []);
93
- this.romoSelectDropdown.doFocus(false);
94
- }, this));
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(this.romoSelectDropdown.elem, 'romoSelectDropdown:romoDropdown:toggle', Romo.proxy(function(e, romoDropdown, romoSelectDropdown) {
105
- Romo.trigger(this.elem, 'romoSelect:romoDropdown:toggle', [romoDropdown, this]);
106
- }, this));
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]);
109
- }, this));
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]);
112
- }, this));
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(this.romoSelectDropdown.elem, 'romoSelectDropdown:itemSelected', Romo.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
115
- this.romoSelectDropdown.doFocus();
116
- Romo.trigger(this.elem, 'romoSelect:itemSelected', [itemValue, itemDisplayText, this]);
117
- }, this));
118
- Romo.on(this.romoSelectDropdown.elem, 'romoSelectDropdown:newItemSelected', Romo.proxy(function(e, itemValue, itemDisplayText, romoSelectDropdown) {
119
- if (this.romoSelectedOptionsList !== undefined) {
120
- var currentValues = this._elemValues();
121
- if (!currentValues.includes(itemValue)) {
122
- this._setValues(currentValues.concat([itemValue]));
123
- this.romoSelectedOptionsList.doAddItem({
124
- 'value': itemValue,
125
- 'displayText': itemDisplayText
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
- } else {
129
- this._setValues([itemValue]);
130
- }
131
- this._refreshUI();
132
- Romo.trigger(this.elem, 'romoSelect:newItemSelected', [itemValue, itemDisplayText, this]);
133
- }, this));
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]);
137
- }, this));
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('<div class="romo-select romo-btn" tabindex="0"><span class="romo-select-text"></span></div>')[0];
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(romoSelectDropdownElem, 'romo-dropdown-position', Romo.data(this.elem, 'romo-select-dropdown-position'));
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(romoSelectDropdownElem, 'romo-dropdown-style-class', Romo.data(this.elem, 'romo-select-dropdown-style-class'));
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(romoSelectDropdownElem, 'romo-dropdown-min-height', Romo.data(this.elem, 'romo-select-dropdown-min-height'));
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(romoSelectDropdownElem, 'romo-dropdown-max-height', Romo.data(this.elem, 'romo-select-dropdown-max-height'));
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(romoSelectDropdownElem, 'romo-dropdown-height', Romo.data(this.elem, 'romo-select-dropdown-height'));
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(romoSelectDropdownElem, 'romo-select-dropdown-filter-placeholder', Romo.data(this.elem, 'romo-select-filter-placeholder'));
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(romoSelectDropdownElem, 'romo-select-dropdown-filter-indicator', Romo.data(this.elem, 'romo-select-filter-indicator'));
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(romoSelectDropdownElem, 'romo-select-dropdown-filter-indicator-width-px', Romo.data(this.elem, 'romo-select-filter-indicator-width-px'));
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(romoSelectDropdownElem, 'romo-select-dropdown-no-filter', Romo.data(this.elem, 'romo-select-no-filter'));
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(romoSelectDropdownElem, 'romo-select-dropdown-custom-option', Romo.data(this.elem, 'romo-select-custom-option'));
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(romoSelectDropdownElem, 'romo-select-dropdown-custom-option-prompt', Romo.data(this.elem, 'romo-select-custom-option-prompt'));
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(romoSelectDropdownElem, 'romo-select-dropdown-open-on-focus', Romo.data(this.elem, 'romo-select-open-on-focus'));
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(this.caretElem, 'line-height', Romo.css(romoSelectDropdownElem, 'line-height'));
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(romoSelectDropdownElem, 'padding-'+caretPosition, dropdownPaddingPx+'px');
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(this.elem, 'romo-option-list-dropdown-no-filter', Romo.data(this.elem, 'romo-select-dropdown-no-filter'));
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(this.elem, 'romo-option-list-dropdown-filter-placeholder', Romo.data(this.elem, 'romo-select-dropdown-filter-placeholder'));
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(this.elem, 'romo-option-list-dropdown-filter-indicator', Romo.data(this.elem, 'romo-select-dropdown-filter-indicator'));
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(this.elem, 'romo-option-list-dropdown-filter-indicator-width-px', Romo.data(this.elem, 'romo-select-dropdown-filter-indicator-width-px'));
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(this.elem, 'romo-option-list-dropdown-open-on-focus', Romo.data(this.elem, 'romo-select-dropdown-open-on-focus'));
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(this.elem, 'romoOptionListDropdown:romoDropdown:toggle', Romo.proxy(function(e, romoDropdown) {
84
- Romo.trigger(this.elem, 'romoSelectDropdown:romoDropdown:toggle', [romoDropdown, this]);
85
- }, this));
86
- Romo.on(this.elem, 'romoOptionListDropdown:romoDropdown:popupOpen', Romo.proxy(function(e, romoDropdown) {
87
- Romo.trigger(this.elem, 'romoSelectDropdown:romoDropdown:popupOpen', [romoDropdown, this]);
88
- }, this));
89
- Romo.on(this.elem, 'romoOptionListDropdown:romoDropdown:popupClose', Romo.proxy(function(e, romoDropdown) {
90
- Romo.trigger(this.elem, 'romoSelectDropdown:romoDropdown:popupClose', [romoDropdown, this]);
91
- }, this));
92
- Romo.on(this.elem, 'romoOptionListDropdown:itemSelected', Romo.proxy(function(e, itemValue, itemDisplayText, romoOptionListDropdown) {
93
- Romo.trigger(this.elem, 'romoSelectDropdown:itemSelected', [itemValue, itemDisplayText, this]);
94
- }, this));
95
- Romo.on(this.elem, 'romoOptionListDropdown:newItemSelected', Romo.proxy(function(e, itemValue, itemDisplayText, romoOptionListDropdown) {
96
- var custOptElem = Romo.find(this.optionElemsParentElem, 'OPTION[data-romo-select-dropdown-custom-option="true"]')[0];
97
- if (Romo.find(this.optionElemsParentElem, 'OPTION[value="'+itemValue+'"]').length === 0){
98
- // a custom value is being selected. add a custom option elem and update its value/text
99
- if (custOptElem === undefined) {
100
- Romo.appendHtml(this.optionElemsParentElem, '<option data-romo-select-dropdown-custom-option="true"></option>');
101
- custOptElem = Romo.find(this.optionElemsParentElem, 'OPTION[data-romo-select-dropdown-custom-option="true"]')[0];
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.setAttr(custOptElem, 'value', itemValue);
104
- Romo.updateText(custOptElem, itemDisplayText);
105
- } else if (custOptElem !== undefined) {
106
- // a non custom value is being selected. remove any existing custom option
107
- Romo.remove(custOptElem);
108
- }
109
- Romo.trigger(this.elem, 'romoSelectDropdown:newItemSelected', [itemValue, itemDisplayText, this]);
110
- }, this));
111
- Romo.on(this.elem, 'romoOptionListDropdown:change', Romo.proxy(function(e, newValue, prevValue, romoOptionListDropdown) {
112
- Romo.trigger(this.elem, 'romoSelectDropdown:change', [newValue, prevValue, this]);
113
- }, this));
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(this.elem, 'romoOptionListDropdown:filterChange', Romo.proxy(function(e, filterValue, romoOptionListDropdown) {
129
- var elems = Romo.find(this.optionElemsParentElem, 'OPTION');
130
- var wbFilter = new RomoWordBoundaryFilter(filterValue, elems, function(elem) {
131
- // The romo word boundary filter by default considers a space, "-" and "_"
132
- // as word boundaries. We want to also consider other non-word characters
133
- // (such as ":", "/", ".", "?", "=", "&") as word boundaries as well.
134
- return elem.textContent.replace(/\W/g, ' ');
135
- });
136
-
137
- Romo.removeClass(wbFilter.matchingElems, this.filterHiddenClass);
138
- Romo.addClass(wbFilter.notMatchingElems, this.filterHiddenClass);
139
- this._setListItems();
140
-
141
- if (filterValue !== '') {
142
- Romo.trigger(this.romoOptionListDropdown.elem, 'romoOptionListDropdown:triggerListOptionsUpdate', [this.optItemElems()[0]]);
143
- } else {
144
- Romo.trigger(this.elem, 'romoOptionListDropdown:triggerListOptionsUpdate', [this.selectedItemElem()]);
145
- }
146
- }, this));
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(this.elem, 'romoOptionListDropdown:triggerListOptionsUpdate', [this.selectedItemElem()]);
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 list = [];
268
+ var items = [];
180
269
 
181
270
  optionElems.forEach(Romo.proxy(function(optElem) {
182
271
  if (optElem.tagName === "OPTION") {
183
- list.push(this._buildOptionItem(optElem));
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
- list.push(optGroupItem);
276
+ items.push(optGroupItem);
188
277
  }
189
278
  }
190
279
  }, this));
191
280
 
192
- return list;
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