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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f188c7ec6458f78c8fac481fb5a55c9e26d12b12
4
- data.tar.gz: 2efa22bf82590430a69ae5b97f2f16a91787bcc7
5
2
  SHA512:
6
- metadata.gz: 0b341879e0b7413f8a207a8b674be4941907fc7fb5c3b4ce70226fd04f5da65ed7e5b72c2260dbedab021cd6d9c929aa7fce04d89e144b797b8f23c40adf6e54
7
- data.tar.gz: c62ca09016eefa8044f95fbdf1327185110d09a4341788ea246e0b052cce80dec4ae3665dec35f92267fc7ac7e569912067b8dcb749235f76def0dfd04966d3a
3
+ data.tar.gz: 808ea2ad05f17ec79e56d481ea45213ea7d5fd2e89d17165d05b03b6f25c2a4f6d831e00bd558b882ef6965eba96f424061ca7f305c9382c02ad7b4237cbd4b3
4
+ metadata.gz: 929531f2eac4058d404c755516b7996f9c073bad45a97b345b0004dbc501038202ce81cd8f817ed9f71bea0e1e41643fc719730110449ca79c22427e3b562e46
5
+ SHA1:
6
+ data.tar.gz: 7e903175bd957a7425036484e9b380bbcf622fd5
7
+ metadata.gz: c4b671aa8bc3a18ae06d71008c553e71dc1ba89a
@@ -0,0 +1,62 @@
1
+ @import 'css/romo/vars';
2
+ @import 'css/romo/mixins';
3
+
4
+ .romo {
5
+
6
+ .romo-color-select-wrapper {
7
+ display: inline-block;
8
+ text-align: left;
9
+ text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
10
+ cursor: pointer;
11
+ @include user-select(none);
12
+ position: relative;
13
+ }
14
+
15
+ .romo-color-select {
16
+ min-width: 50px;
17
+ font-weight: normal;
18
+ text-align: left;
19
+ padding-left: 6px;
20
+ padding-right: 6px;
21
+ }
22
+
23
+ .romo-color-select:focus,
24
+ .romo-color-select.romo-color-select-focus { @include input-focus; }
25
+
26
+ .romo-color-select:active,
27
+ .romo-color-select.active {
28
+ background-image: none;
29
+ outline: 0;
30
+ @include box-shadow((inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)));
31
+ }
32
+
33
+ .romo-color-select-text {
34
+ white-space: nowrap;
35
+ overflow: hidden;
36
+ display: inline-block;
37
+ width: 100%;
38
+ }
39
+
40
+ .romo-color-select-caret {
41
+ display: inline-block;
42
+ position: absolute;
43
+ vertical-align: middle;
44
+ cursor: pointer;
45
+ }
46
+
47
+ .romo-color-select-item {
48
+ @include pad0();
49
+ }
50
+ .romo-color-select-item-color,
51
+ .romo-color-select-item-name {
52
+ display: inline-block;
53
+ vertical-align: middle;
54
+ line-height: $lineHeight1;
55
+ }
56
+ .romo-color-select-item-color {
57
+ @include push0-right();
58
+ @include border1();
59
+ width: $lineHeight1;
60
+ }
61
+
62
+ }
@@ -0,0 +1,580 @@
1
+ var RomoColorSelect = RomoComponent(function(elem) {
2
+ this.elem = elem;
3
+
4
+ this.defaultCaretClass = undefined;
5
+ this.defaultCaretPaddingPx = 5;
6
+ this.defaultCaretWidthPx = 18;
7
+ this.defaultCaretPosition = 'right'
8
+
9
+ this.defaultValuesDelim = ',';
10
+ this.defaultOptionItems = this._buildDefaultOptionItems();
11
+
12
+ this.doRefreshColorItemsJson();
13
+ this.doInit();
14
+ this._bindElem();
15
+
16
+ Romo.trigger(this.elem, 'romoColorSelect:ready', [this]);
17
+ });
18
+
19
+ RomoColorSelect.prototype.doSetValue = function(value) {
20
+ var items, values, displayText;
21
+
22
+ items = Romo.array(value).map(Romo.proxy(function(v) {
23
+ return this.colorItems.find(function(i) { return i.value === v; });
24
+ }, this));
25
+ items = items.filter(function(i) { return i !== undefined; });
26
+ items = items.map(function(i) {
27
+ return {
28
+ 'value': i.value,
29
+ 'displayText': i.displayText
30
+ };
31
+ });
32
+ values = items.map(function(i) { return i.value; });
33
+
34
+ if (this.romoSelectedOptionsList !== undefined) {
35
+ displayText = '';
36
+ this.romoSelectedOptionsList.doSetItems(items);
37
+ } else if (items[0]) {
38
+ displayText = items[0].displayText;
39
+ this.romoOptionListDropdown.doSetSelectedItem(values[0]);
40
+ } else {
41
+ displayText = Romo.data(this.elem, 'romo-color-select-empty-option-display-text') || '';
42
+ this.romoOptionListDropdown.doSetSelectedItem(undefined);
43
+ }
44
+ this._setValuesAndDisplayText(values, displayText);
45
+ this._refreshUI();
46
+ }
47
+
48
+ RomoColorSelect.prototype.doRefreshColorItemsJson = function() {
49
+ var items, values;
50
+ itemTuples = Romo.data(this.elem, 'romo-color-select-items-json');
51
+ values = this._elemValues();
52
+
53
+ this.colorItems = itemTuples.map(Romo.proxy(function(itemTuple) {
54
+ return this._buildColorItem(values, {
55
+ 'value': itemTuple[0],
56
+ 'name': itemTuple[1]
57
+ });
58
+ }, this));
59
+ }
60
+
61
+ // private
62
+
63
+ RomoColorSelect.prototype._buildColorItem = function(elemValues, itemData) {
64
+ return {
65
+ 'value': itemData.value,
66
+ 'displayText': itemData.name,
67
+ 'displayHtml': this._buildColorItemDisplayHtml(itemData),
68
+ 'selected': elemValues.includes(itemData.value)
69
+ }
70
+ }
71
+
72
+ RomoColorSelect.prototype._buildColorItemDisplayHtml = function(itemData) {
73
+ return (
74
+ '<div class="romo-color-select-item">'+
75
+ '<div class="romo-color-select-item-color"'+
76
+ 'style="background-color: '+itemData.value+'">&nbsp;</div>'+
77
+ '<div class="romo-color-select-item-name">'+itemData.name+'</div>'+
78
+ '</div>'
79
+ );
80
+ }
81
+
82
+ RomoColorSelect.prototype._bindElem = function() {
83
+ this._bindOptionListDropdown();
84
+ this._bindSelectedOptionsList();
85
+
86
+ Romo.on(this.elem, 'romoColorSelect:triggerToggle', Romo.proxy(function(e) {
87
+ Romo.trigger(this.romoOptionListDropdown.elem, 'romoOptionListDropdown:triggerToggle', []);
88
+ }, this));
89
+ Romo.on(this.elem, 'romoColorSelect:triggerPopupOpen', Romo.proxy(function(e) {
90
+ Romo.trigger(this.romoOptionListDropdown.elem, 'romoOptionListDropdown:triggerPopupOpen', []);
91
+ }, this));
92
+ Romo.on(this.elem, 'romoColorSelect:triggerPopupClose', Romo.proxy(function(e) {
93
+ Romo.trigger(this.romoOptionListDropdown.elem, 'romoOptionListDropdown:triggerPopupClose', []);
94
+ }, this));
95
+ Romo.on(this.elem, 'romoColorSelect:triggerRefreshColorItemsJson', Romo.proxy(function(e) {
96
+ this.doRefreshColorItemsJson();
97
+ }, this));
98
+
99
+ this._setUnfilteredListItems();
100
+ this.doSetValue(this._elemValues());
101
+
102
+ if (Romo.attr(this.elem, 'id') !== undefined) {
103
+ var labelElem = Romo.f('label[for="'+Romo.attr(this.elem, 'id')+'"]');
104
+ Romo.on(labelElem, 'click', Romo.proxy(function(e) {
105
+ e.preventDefault();
106
+ this.romoOptionListDropdown.doFocus();
107
+ }, this));
108
+ }
109
+
110
+ Romo.on(window, "pageshow", Romo.proxy(function(e) {
111
+ this._refreshUI();
112
+ }, this));
113
+
114
+ Romo.on(this.elem, 'romoColorSelect:triggerSetValue', Romo.proxy(function(e, value) {
115
+ this.doSetValue(value)
116
+ }, this));
117
+ }
118
+
119
+ RomoColorSelect.prototype._bindSelectedOptionsList = function() {
120
+ this.romoSelectedOptionsList = undefined;
121
+ if (this.elem.multiple === true) {
122
+ if (Romo.data(this.elem, 'romo-color-select-multiple-item-class') !== undefined) {
123
+ Romo.setData(
124
+ this.romoOptionListDropdown.elem,
125
+ 'romo-selected-options-list-item-class',
126
+ Romo.data(this.elem, 'romo-color-select-multiple-item-class')
127
+ );
128
+ }
129
+ if (Romo.data(this.elem, 'romo-color-select-multiple-max-rows') !== undefined) {
130
+ Romo.setData(
131
+ this.romoOptionListDropdown.elem,
132
+ 'romo-selected-options-list-max-rows',
133
+ Romo.data(this.elem, 'romo-color-select-multiple-max-rows')
134
+ );
135
+ }
136
+
137
+ this.romoSelectedOptionsList = new RomoSelectedOptionsList(this.romoOptionListDropdown.elem);
138
+ Romo.on(
139
+ this.romoSelectedOptionsList.elem,
140
+ 'romoSelectedOptionsList:itemClick',
141
+ Romo.proxy(function(e, itemValue, romoSelectedOptionsList) {
142
+ var currentValues = this._elemValues();
143
+ var index = currentValues.indexOf(itemValue);
144
+ if (index > -1) {
145
+ currentValues.splice(index, 1);
146
+ this._setValuesAndDisplayText(currentValues, '');
147
+ }
148
+ this.romoSelectedOptionsList.doRemoveItem(itemValue);
149
+ this._refreshUI();
150
+
151
+ Romo.trigger(this.elem, 'change');
152
+ Romo.trigger(
153
+ this.elem,
154
+ 'romoSelect:multipleChange',
155
+ [currentValues, itemValue, this]
156
+ );
157
+ }, this)
158
+ );
159
+ Romo.on(
160
+ this.romoSelectedOptionsList.elem,
161
+ 'romoSelectedOptionsList:listClick',
162
+ Romo.proxy(function(e, romoSelectedOptionsList) {
163
+ Romo.trigger(this.romoOptionListDropdown.elem, 'romoDropdown:triggerPopupClose', []);
164
+ this.romoOptionListDropdown.doFocus(false);
165
+ }, this)
166
+ );
167
+
168
+ Romo.before(this.elemWrapper, this.romoSelectedOptionsList.elem);
169
+ this.romoSelectedOptionsList.doRefreshUI();
170
+ }
171
+ }
172
+
173
+ RomoColorSelect.prototype._bindOptionListDropdown = function() {
174
+ this.romoOptionListDropdown = new RomoOptionListDropdown(
175
+ this._buildOptionListDropdownElem()
176
+ );
177
+
178
+ Romo.on(
179
+ this.romoOptionListDropdown.elem,
180
+ 'romoOptionListDropdown:romoDropdown:toggle',
181
+ Romo.proxy(function(e, romoDropdown, optionListDropdown) {
182
+ Romo.trigger(this.elem, 'romoColorSelect:romoDropdown:toggle', [romoDropdown, this]);
183
+ }, this)
184
+ );
185
+ Romo.on(
186
+ this.romoOptionListDropdown.elem,
187
+ 'romoOptionListDropdown:romoDropdown:popupOpen',
188
+ Romo.proxy(function(e, romoDropdown, optionListDropdown) {
189
+ Romo.trigger(this.elem, 'romoColorSelect:romoDropdown:popupOpen', [romoDropdown, this]);
190
+ }, this)
191
+ );
192
+ Romo.on(
193
+ this.romoOptionListDropdown.elem,
194
+ 'romoOptionListDropdown:romoDropdown:popupClose',
195
+ Romo.proxy(function(e, romoDropdown, optionListDropdown) {
196
+ Romo.trigger(this.elem, 'romoColorSelect:romoDropdown:popupClose', [romoDropdown, this]);
197
+ }, this)
198
+ );
199
+
200
+ Romo.on(
201
+ this.romoOptionListDropdown.elem,
202
+ 'romoOptionListDropdown:filterChange',
203
+ Romo.proxy(function(e, filterValue, romoOptionListDropdown) {
204
+ var wbFilter = new RomoWordBoundaryFilter(filterValue, this.colorItems, function(item) {
205
+ // The romo word boundary filter by default considers a space, "-" and "_"
206
+ // as word boundaries. We want to also consider other non-word characters
207
+ // (such as ":", "/", ".", "?", "=", "&") as word boundaries as well.
208
+ return item.displayText.replace(/\W/g, ' ');
209
+ });
210
+
211
+ wbFilter.matchingItems.forEach(function(i){ i.hidden = false; });
212
+ wbFilter.notMatchingItems.forEach(function(i){ i.hidden = true; });
213
+
214
+ if (filterValue !== '') {
215
+ this._setFilteredListItems();
216
+ Romo.trigger(
217
+ this.romoOptionListDropdown.elem,
218
+ 'romoOptionListDropdown:triggerListOptionsUpdate',
219
+ [this.romoOptionListDropdown.optItemElems()[0]]
220
+ );
221
+ } else {
222
+ this._setUnfilteredListItems();
223
+ Romo.trigger(
224
+ this.elem,
225
+ 'romoOptionListDropdown:triggerListOptionsUpdate',
226
+ [this.romoOptionListDropdown.selectedItemElem()]
227
+ );
228
+ }
229
+ }, this)
230
+ );
231
+ Romo.on(
232
+ this.romoOptionListDropdown.elem,
233
+ 'romoOptionListDropdown:itemSelected',
234
+ Romo.proxy(function(e, itemValue, itemDisplayText, optionListDropdown) {
235
+ this.romoOptionListDropdown.doFocus();
236
+ Romo.trigger(this.elem, 'romoColorSelect:itemSelected', [itemValue, itemDisplayText, this]);
237
+ }, this)
238
+ );
239
+ Romo.on(
240
+ this.romoOptionListDropdown.elem,
241
+ 'romoOptionListDropdown:newItemSelected',
242
+ Romo.proxy(function(e, itemValue, itemDisplayText, optionListDropdown) {
243
+ if (this.romoSelectedOptionsList !== undefined) {
244
+ var currentValues = this._elemValues();
245
+ if (!currentValues.includes(itemValue)) {
246
+ this._setValuesAndDisplayText(currentValues.concat([itemValue]), '');
247
+ this.romoSelectedOptionsList.doAddItem({
248
+ 'value': itemValue,
249
+ 'displayText': itemDisplayText
250
+ });
251
+ }
252
+ } else {
253
+ this._setValuesAndDisplayText([itemValue], itemDisplayText);
254
+ }
255
+ this._refreshUI();
256
+ Romo.trigger(this.elem, 'romoColorSelect:newItemSelected', [itemValue, itemDisplayText, this]);
257
+ }, this)
258
+ );
259
+ Romo.on(
260
+ this.romoOptionListDropdown.elem,
261
+ 'romoOptionListDropdown:change',
262
+ Romo.proxy(function(e, newValue, prevValue, optionListDropdown) {
263
+ Romo.trigger(this.elem, 'change');
264
+ if (this.romoSelectedOptionsList !== undefined) {
265
+ Romo.trigger(
266
+ this.elem,
267
+ 'romoColorSelect:multipleChange',
268
+ [this._elemValues(), newValue, this]
269
+ );
270
+ } else {
271
+ Romo.trigger(this.elem, 'romoColorSelect:change', [newValue, prevValue, this]);
272
+ }
273
+
274
+ }, this)
275
+ );
276
+ }
277
+
278
+ RomoColorSelect.prototype._buildOptionListDropdownElem = function() {
279
+ var romoOptionListDropdownElem = Romo.elems(
280
+ '<div class="romo-color-select romo-btn" tabindex="0">'+
281
+ '<span class="romo-color-select-text"></span>'+
282
+ '</div>'
283
+ )[0];
284
+
285
+ Romo.setData(romoOptionListDropdownElem, 'romo-dropdown-overflow-x', 'hidden');
286
+ Romo.setData(romoOptionListDropdownElem, 'romo-dropdown-width', 'elem');
287
+ Romo.setData(
288
+ romoOptionListDropdownElem,
289
+ 'romo-option-list-focus-style-class',
290
+ 'romo-color-select-focus'
291
+ );
292
+
293
+ if (Romo.data(this.elem, 'romo-color-select-dropdown-position') !== undefined) {
294
+ Romo.setData(
295
+ romoOptionListDropdownElem,
296
+ 'romo-dropdown-position',
297
+ Romo.data(this.elem, 'romo-color-select-dropdown-position')
298
+ );
299
+ }
300
+ if (Romo.data(this.elem, 'romo-color-select-dropdown-style-class') !== undefined) {
301
+ Romo.setData(
302
+ romoOptionListDropdownElem,
303
+ 'romo-dropdown-style-class',
304
+ Romo.data(this.elem, 'romo-color-select-dropdown-style-class')
305
+ );
306
+ }
307
+ if (Romo.data(this.elem, 'romo-color-select-dropdown-min-height') !== undefined) {
308
+ Romo.setData(
309
+ romoOptionListDropdownElem,
310
+ 'romo-dropdown-min-height',
311
+ Romo.data(this.elem, 'romo-color-select-dropdown-min-height')
312
+ );
313
+ }
314
+ if (Romo.data(this.elem, 'romo-color-select-dropdown-max-height') !== undefined) {
315
+ Romo.setData(
316
+ romoOptionListDropdownElem,
317
+ 'romo-dropdown-max-height',
318
+ Romo.data(this.elem, 'romo-color-select-dropdown-max-height')
319
+ );
320
+ }
321
+ if (Romo.data(this.elem, 'romo-color-select-dropdown-height') !== undefined) {
322
+ Romo.setData(
323
+ romoOptionListDropdownElem,
324
+ 'romo-dropdown-height',
325
+ Romo.data(this.elem, 'romo-color-select-dropdown-height')
326
+ );
327
+ }
328
+ if (Romo.data(this.elem, 'romo-color-select-dropdown-append-to-closest') !== undefined) {
329
+ Romo.setData(
330
+ romoOptionListDropdownElem,
331
+ 'romo-dropdown-append-to-closest',
332
+ Romo.data(this.elem, 'romo-color-select-dropdown-append-to-closest')
333
+ );
334
+ }
335
+ if (Romo.data(this.elem, 'romo-color-select-dropdown-append-to') !== undefined) {
336
+ Romo.setData(
337
+ romoOptionListDropdownElem,
338
+ 'romo-dropdown-append-to',
339
+ Romo.data(this.elem, 'romo-color-select-dropdown-append-to')
340
+ );
341
+ }
342
+ if (Romo.data(this.elem, 'romo-color-select-filter-placeholder') !== undefined) {
343
+ Romo.setData(
344
+ romoOptionListDropdownElem,
345
+ 'romo-option-list-dropdown-filter-placeholder',
346
+ Romo.data(this.elem, 'romo-color-select-filter-placeholder')
347
+ );
348
+ }
349
+ if (Romo.data(this.elem, 'romo-color-select-filter-indicator') !== undefined) {
350
+ Romo.setData(
351
+ romoOptionListDropdownElem,
352
+ 'romo-option-list-dropdown-filter-indicator',
353
+ Romo.data(this.elem, 'romo-color-select-filter-indicator')
354
+ );
355
+ }
356
+ if (Romo.data(this.elem, 'romo-color-select-filter-indicator-width-px') !== undefined) {
357
+ Romo.setData(
358
+ romoOptionListDropdownElem,
359
+ 'romo-option-list-filter-indicator-width-px',
360
+ Romo.data(this.elem, 'romo-color-select-filter-indicator-width-px')
361
+ );
362
+ }
363
+ if (Romo.data(this.elem, 'romo-color-select-no-filter') !== undefined) {
364
+ Romo.setData(
365
+ romoOptionListDropdownElem,
366
+ 'romo-option-list-dropdown-no-filter',
367
+ Romo.data(this.elem, 'romo-color-select-no-filter')
368
+ );
369
+ }
370
+ if (Romo.data(this.elem, 'romo-color-select-open-on-focus') !== undefined) {
371
+ Romo.setData(
372
+ romoOptionListDropdownElem,
373
+ 'romo-option-list-dropdown-open-on-focus',
374
+ Romo.data(this.elem, 'romo-color-select-open-on-focus')
375
+ );
376
+ }
377
+
378
+ if (Romo.data(romoOptionListDropdownElem, 'romo-dropdown-max-height') === undefined) {
379
+ Romo.setData(romoOptionListDropdownElem, 'romo-dropdown-max-height', 'detect');
380
+ }
381
+
382
+ if (Romo.attr(this.elem, 'class') !== undefined) {
383
+ Romo.addClass(romoOptionListDropdownElem, Romo.attr(this.elem, 'class'));
384
+ }
385
+ if (Romo.attr(this.elem, 'style') !== undefined) {
386
+ Romo.setAttr(romoOptionListDropdownElem, 'style', Romo.attr(this.elem, 'style'));
387
+ }
388
+ Romo.setStyle(romoOptionListDropdownElem, 'width', Romo.width(this.elem)+'px');
389
+ if (Romo.attr(this.elem, 'disabled') !== undefined) {
390
+ Romo.setAttr(this.romoOptionListDropdown.elem, 'disabled', Romo.attr(this.elem, 'disabled'));
391
+ }
392
+
393
+ Romo.after(this.elem, romoOptionListDropdownElem);
394
+ Romo.hide(this.elem);
395
+
396
+ this.elemWrapper = Romo.elems('<div class="romo-color-select-wrapper"></div>')[0];
397
+ if (Romo.data(this.elem, 'romo-color-select-btn-group') === true) {
398
+ Romo.addClass(this.elemWrapper, 'romo-btn-group');
399
+ }
400
+ Romo.before(romoOptionListDropdownElem, this.elemWrapper);
401
+ Romo.append(this.elemWrapper, romoOptionListDropdownElem);
402
+ Romo.parentChildElems.add(this.elem, [this.elemWrapper]);
403
+
404
+ this.caretElem = undefined;
405
+ var caretClass = Romo.data(this.elem, 'romo-color-select-caret') || this.defaultCaretClass;
406
+ if (caretClass !== undefined && caretClass !== 'none') {
407
+ this.caretElem = Romo.elems('<i class="romo-color-select-caret '+caretClass+'"></i>')[0];
408
+ Romo.setStyle(
409
+ this.caretElem,
410
+ 'line-height',
411
+ Romo.css(romoOptionListDropdownElem, 'line-height')
412
+ );
413
+ Romo.on(this.caretElem, 'click', Romo.proxy(this._onCaretClick, this));
414
+ Romo.append(romoOptionListDropdownElem, this.caretElem);
415
+
416
+ var caretPaddingPx = this._getCaretPaddingPx();
417
+ var caretWidthPx = this._getCaretWidthPx();
418
+ var caretPosition = this._getCaretPosition();
419
+
420
+ // add a pixel to account for the default input border
421
+ Romo.setStyle(this.caretElem, caretPosition, caretPaddingPx+1+'px');
422
+
423
+ // left-side padding
424
+ // + caret width
425
+ // + right-side padding
426
+ var dropdownPaddingPx = caretPaddingPx + caretWidthPx + caretPaddingPx;
427
+ Romo.setStyle(
428
+ romoOptionListDropdownElem,
429
+ 'padding-'+caretPosition,
430
+ dropdownPaddingPx+'px'
431
+ );
432
+ }
433
+
434
+ return romoOptionListDropdownElem;
435
+ }
436
+
437
+ RomoColorSelect.prototype._setUnfilteredListItems = function() {
438
+ this.romoOptionListDropdown.doSetListItems(
439
+ this.defaultOptionItems.concat(this._buildOptionItems())
440
+ );
441
+ }
442
+
443
+ RomoColorSelect.prototype._setFilteredListItems = function() {
444
+ this.romoOptionListDropdown.doSetListItems(
445
+ this._buildOptionItems().concat(this._buildCustomOptionItems())
446
+ );
447
+ }
448
+
449
+ RomoColorSelect.prototype._buildOptionItems = function() {
450
+ return this.colorItems.filter(function(i) { return i.hidden !== true; }).map(function(i) {
451
+ return {
452
+ 'type': 'option',
453
+ 'value': i.value,
454
+ 'displayText': i.displayText,
455
+ 'displayHtml': i.displayHtml,
456
+ 'selected': i.selected
457
+ }
458
+ });
459
+ }
460
+
461
+ RomoColorSelect.prototype._buildDefaultOptionItems = function() {
462
+ var items = [];
463
+
464
+ if (Romo.data(this.elem, 'romo-color-select-empty-option') === true) {
465
+ var text = Romo.data(this.elem, 'romo-color-select-empty-option-display-text') || '';
466
+ items.push({
467
+ 'type': 'option',
468
+ 'value': '',
469
+ 'displayText': text,
470
+ 'displayHtml': '<span>'+text+'</span>'
471
+ });
472
+ }
473
+
474
+ return items;
475
+ }
476
+
477
+ RomoColorSelect.prototype._buildCustomOptionItems = function() {
478
+ var items = [];
479
+
480
+ var value = this.romoOptionListDropdown.optionFilterValue();
481
+ if (value !== '' && Romo.data(this.elem, 'romo-color-select-custom-option') === true) {
482
+ var prompt = Romo.data(this.elem, 'romo-color-select-custom-option-prompt');
483
+ if (prompt !== undefined) {
484
+ items.push({
485
+ 'type': 'optgroup',
486
+ 'label': prompt,
487
+ 'items': [this._buildCustomOptionItem(value)]
488
+ });
489
+ } else {
490
+ items.push(this._buildCustomOptionItem(value));
491
+ }
492
+ }
493
+
494
+ return items;
495
+ }
496
+
497
+ RomoColorSelect.prototype._buildCustomOptionItem = function(value) {
498
+ return {
499
+ 'type': 'option',
500
+ 'value': value,
501
+ 'displayText': value,
502
+ 'displayHtml': '<span>'+value+'</span>'
503
+ };
504
+ }
505
+
506
+ RomoColorSelect.prototype._setValuesAndDisplayText = function(newValues, displayText) {
507
+ this.elem.value = newValues.join(this._elemValuesDelim());
508
+ this.colorItems.forEach(function(colorItem) {
509
+ if (newValues.includes(colorItem.value)) {
510
+ colorItem.selected = true;
511
+ } else {
512
+ colorItem.selected = false;
513
+ }
514
+ });
515
+ Romo.setData(this.elem, 'romo-color-select-display-text', displayText);
516
+ }
517
+
518
+ RomoColorSelect.prototype._elemValues = function() {
519
+ return this.elem.value.split(this._elemValuesDelim()).filter(function(v){ return v !== ''; });
520
+ }
521
+
522
+ RomoColorSelect.prototype._elemValuesDelim = function() {
523
+ return Romo.data(this.elem, 'romo-color-select-values-delim') || this.defaultValuesDelim;
524
+ }
525
+
526
+ RomoColorSelect.prototype._refreshUI = function() {
527
+ if (this.romoSelectedOptionsList !== undefined) {
528
+ this.romoSelectedOptionsList.doRefreshUI();
529
+ }
530
+
531
+ var textElem = Romo.find(this.romoOptionListDropdown.elem, '.romo-color-select-text')[0];
532
+ var text = Romo.data(this.elem, 'romo-color-select-display-text') || '';
533
+ if (text === '') {
534
+ Romo.updateHtml(textElem, '<span>&nbsp;</span>');
535
+ } else {
536
+ Romo.updateText(textElem, text);
537
+ }
538
+ }
539
+
540
+ RomoColorSelect.prototype._getCaretPaddingPx = function() {
541
+ return (
542
+ Romo.data(this.elem, 'romo-color-select-caret-padding-px') ||
543
+ this.defaultCaretPaddingPx
544
+ );
545
+ }
546
+
547
+ RomoColorSelect.prototype._getCaretWidthPx = function() {
548
+ return (
549
+ Romo.data(this.elem, 'romo-color-select-caret-width-px') ||
550
+ this._parseCaretWidthPx()
551
+ );
552
+ }
553
+
554
+ RomoColorSelect.prototype._getCaretPosition = function() {
555
+ return (
556
+ Romo.data(this.elem, 'romo-color-select-caret-position') ||
557
+ this.defaultCaretPosition
558
+ );
559
+ }
560
+
561
+ RomoColorSelect.prototype._parseCaretWidthPx = function() {
562
+ var widthPx = Romo.width(this.caretElem);
563
+ if (isNaN(widthPx)) {
564
+ widthPx = this.defaultCaretWidthPx;
565
+ }
566
+ return widthPx;
567
+ }
568
+
569
+ // event functions
570
+
571
+ RomoColorSelect.prototype.romoEvFn._onCaretClick = function(e) {
572
+ if (this.elem.disabled === false) {
573
+ this.romoOptionListDropdown.doFocus();
574
+ Romo.trigger(this.elem, 'romoColorSelect:triggerPopupOpen');
575
+ }
576
+ }
577
+
578
+ // init
579
+
580
+ Romo.addElemsInitSelector('[data-romo-color-select-auto="true"]', RomoColorSelect);