romo 0.17.0 → 0.17.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fe66b6570bc33ace62de2e8fd9c4346714ea4a4
4
- data.tar.gz: 9cc7f175aa978376a86f4a85d005fdab750a817f
3
+ metadata.gz: 217361e9543ff348d3315d69454971dce89254f1
4
+ data.tar.gz: dd28175c1f05929102d1f06b4846b83a6ee1eb34
5
5
  SHA512:
6
- metadata.gz: 29b9803211c7b536f484844996ade3def60287dbdd6a6d06b4af646f899c35f88d9dbef95fdcc036707d6a706569fc21e74fec50c7ed09028d4ef0b9ea9ad9e6
7
- data.tar.gz: e9cbde2242c2fcc0b332f6ed53081388bb750a2d9d05e919d1c1144cd53e7599371093768025d020e0c82bd1ef0e6170e1d18d4b946336034a17ff185dfa8f0e
6
+ metadata.gz: f4c569de6a994ed66af85e1e187a1f00aaab08390d550e95eae5816a9a250fba13e490b349f1a26934e6c8bebf27e21afc4abf842d95b76821e696bebf0fd541
7
+ data.tar.gz: d81fd57f559711ce1f7097ad8204505f627621a2edd4e633d6d234b1917b907d6b75684e5864dd96a0fb6a6caa9875bee4d048466ae15b0d51d2c57575f58cb4
@@ -27,6 +27,8 @@ $spacingSize0: $spacingSize1 * 0.35;
27
27
  $spacingSize2: $spacingSize1 * 2;
28
28
 
29
29
  $inputHeight: ($baseLineHeight / 2) * 3; /* 30px */
30
+ $inputFilterHeight: $baseLineHeight; /* 20px */
31
+
30
32
  $inputSize1: 220px;
31
33
  $inputSize0: $inputSize1 - 120px;
32
34
  $inputSize2: $inputSize1 + 120px;
@@ -26,7 +26,8 @@ label { display: block; }
26
26
 
27
27
  .romo-form input,
28
28
  .romo-form select,
29
- .romo-form textarea {
29
+ .romo-form textarea,
30
+ input.romo-select-dropdown-option-filter {
30
31
  font-size: 100%;
31
32
  @include rm-push;
32
33
  @include align-middle;
@@ -42,8 +43,15 @@ label { display: block; }
42
43
  }
43
44
  }
44
45
 
45
- .romo-form input { *overflow: visible; line-height: normal; }
46
- .romo-form textarea { overflow: auto; @include align-top; }
46
+ .romo-form input,
47
+ input.romo-select-dropdown-option-filter {
48
+ *overflow: visible;
49
+ line-height: normal;
50
+ }
51
+
52
+ .romo-form textarea {
53
+ overflow: auto; @include align-top;
54
+ }
47
55
 
48
56
  .romo-form label,
49
57
  .romo-form select,
@@ -58,7 +66,9 @@ label { display: block; }
58
66
  .romo-form textarea[disabled],
59
67
  .romo-form input[readonly],
60
68
  .romo-form select[readonly],
61
- .romo-form textarea[readonly] { cursor: $notAllowedCursor; }
69
+ .romo-form textarea[readonly],
70
+ input.romo-select-dropdown-option-filter[disabled],
71
+ input.romo-select-dropdown-option-filter[readonly] { cursor: $notAllowedCursor; }
62
72
 
63
73
  .romo-form select {
64
74
  font-weight: normal;
@@ -82,7 +92,8 @@ label { display: block; }
82
92
  .romo-form input[type="url"],
83
93
  .romo-form input[type="search"],
84
94
  .romo-form input[type="tel"],
85
- .romo-form input[type="color"] {
95
+ .romo-form input[type="color"],
96
+ input.romo-select-dropdown-option-filter {
86
97
  font-weight: normal;
87
98
  background-color: $inputBgColor;
88
99
  @include border1;
@@ -104,7 +115,8 @@ label { display: block; }
104
115
  .romo-form input[type="url"]:focus,
105
116
  .romo-form input[type="search"]:focus,
106
117
  .romo-form input[type="tel"]:focus,
107
- .romo-form input[type="color"]:focus {
118
+ .romo-form input[type="color"]:focus,
119
+ input.romo-select-dropdown-option-filter:focus {
108
120
  @include input-focus;
109
121
  }
110
122
 
@@ -113,7 +125,9 @@ label { display: block; }
113
125
  .romo-form textarea[disabled],
114
126
  .romo-form input[readonly],
115
127
  .romo-form select[readonly],
116
- .romo-form textarea[readonly] { background-color: $inputDisabledColor; }
128
+ .romo-form textarea[readonly],
129
+ input.romo-select-dropdown-option-filter[disabled],
130
+ input.romo-select-dropdown-option-filter[readonly] { background-color: $inputDisabledColor; }
117
131
 
118
132
  .romo-form input[type="radio"][disabled],
119
133
  .romo-form input[type="checkbox"][disabled],
@@ -134,12 +148,17 @@ label { display: block; }
134
148
  .romo-form input[type="url"],
135
149
  .romo-form input[type="search"],
136
150
  .romo-form input[type="tel"],
137
- .romo-form input[type="color"] {
151
+ .romo-form input[type="color"],
152
+ input.romo-select-dropdown-option-filter {
138
153
  height: $inputHeight;
139
154
  line-height: $baseLineHeight;
140
155
  @include align-middle;
141
156
  }
142
157
 
158
+ input.romo-select-dropdown-option-filter {
159
+ height: $inputFilterHeight;
160
+ }
161
+
143
162
  .romo-form textarea,
144
163
  .romo-form input[type="text"],
145
164
  .romo-form input[type="password"],
@@ -154,12 +173,18 @@ label { display: block; }
154
173
  .romo-form input[type="url"],
155
174
  .romo-form input[type="search"],
156
175
  .romo-form input[type="tel"],
157
- .romo-form input[type="color"] {
176
+ .romo-form input[type="color"],
177
+ input.romo-select-dropdown-option-filter {
158
178
  display: inline-block;
159
179
  padding: 4px 6px;
160
180
  color: $inputColor;
161
181
  }
162
182
 
183
+ input.romo-select-dropdown-option-filter {
184
+ display: block;
185
+ width: 100%;
186
+ }
187
+
163
188
  .romo-form textarea,
164
189
  .romo-form select[multiple],
165
190
  .romo-form select[size] { height: auto; }
@@ -8,6 +8,7 @@
8
8
  .romo-indicator-text-input-indicator {
9
9
  display: inline-block;
10
10
  position: absolute;
11
+ top: 0px;
11
12
  right: 6px;
12
13
  vertical-align: middle;
13
14
  cursor: pointer;
@@ -22,7 +22,8 @@
22
22
  padding-right: 6px;
23
23
  }
24
24
 
25
- .romo-select:focus{ @include input-focus; }
25
+ .romo-select:focus,
26
+ .romo-select.romo-select-focus { @include input-focus; }
26
27
 
27
28
  .romo-select:active,
28
29
  .romo-select.active {
@@ -43,6 +44,12 @@
43
44
  vertical-align: middle;
44
45
  }
45
46
 
47
+ .romo-select-dropdown-option-filter-wrapper {
48
+ @include border1-bottom();
49
+ padding: 4px 0;
50
+ margin: 0 4px;
51
+ }
52
+
46
53
  .romo-select-option-list {
47
54
  cursor: pointer;
48
55
  font-weight: normal;
@@ -182,10 +182,79 @@
182
182
  // elem handling
183
183
 
184
184
  Romo.prototype.toArray = function(elems) {
185
- // converts a collection of elements (`$()`) to an array of nodes
185
+ // converts a collection of elements `$()` to an array of nodes
186
186
  return $.map(elems, function(node){ return node; })
187
187
  }
188
188
 
189
+ Romo.prototype.selectNext = function(elem, selector) {
190
+ // like `$().next()`, but takes a selector; returns first next elem that
191
+ // matches the given selector or an empty collection if non matches
192
+ var el = elem.next();
193
+ while(el.length) {
194
+ if (selector === undefined || el.is(selector)) {
195
+ return el;
196
+ }
197
+ el = el.next();
198
+ }
199
+ return el;
200
+ }
201
+
202
+ Romo.prototype.selectPrev = function(elem, selector) {
203
+ // like `$().prev()`, but takes a selector; returns first prev elem that
204
+ // matches the given selector or an empty collection if non matches
205
+ var el = elem.prev();
206
+ while(el.length) {
207
+ if (selector === undefined || el.is(selector)) {
208
+ return el;
209
+ }
210
+ el = el.prev();
211
+ }
212
+ return el;
213
+ }
214
+
215
+ // input handling
216
+
217
+ Romo.prototype.nonInputTextKeyCodes = function() {
218
+ // https://css-tricks.com/snippets/javascript/javascript-keycodes/
219
+ return [
220
+ 9, /* tab */
221
+ 13, /* enter */
222
+ 16, /* shift */
223
+ 17, /* ctrl */
224
+ 18, /* alt */
225
+ 19, /* pausebreak */
226
+ 20, /* capslock */
227
+ 27, /* escape */
228
+ 33, /* pageup */
229
+ 34, /* pagedown */
230
+ 35, /* end */
231
+ 36, /* home */
232
+ 37, /* leftarrow */
233
+ 38, /* uparrow */
234
+ 39, /* rightarrow */
235
+ 40, /* downarrow */
236
+ 45, /* insert */
237
+ 46, /* delete */
238
+ 91, /* leftwindowkey */
239
+ 92, /* rightwindowkey */
240
+ 93, /* selectkey */
241
+ 112, /* f1 */
242
+ 113, /* f2 */
243
+ 114, /* f3 */
244
+ 115, /* f4 */
245
+ 116, /* f5 */
246
+ 117, /* f6 */
247
+ 118, /* f7 */
248
+ 119, /* f8 */
249
+ 120, /* f9 */
250
+ 121, /* f10 */
251
+ 122, /* f11 */
252
+ 123, /* f12 */
253
+ 144, /* numlock */
254
+ 145, /* scrolllock */
255
+ ];
256
+ }
257
+
189
258
  // private
190
259
 
191
260
  Romo.prototype._addEventCallback = function(name, callback) {
@@ -6,20 +6,19 @@ $.fn.romoDatepicker = function() {
6
6
 
7
7
  var RomoDatepicker = function(element) {
8
8
  this.elem = $(element);
9
- this.defaultFormat = 'yyyy-mm-dd'
10
9
  this.monthNames = [
11
10
  "January", "February", "March", "April", "May", "June",
12
11
  "July", "August", "September", "October", "November", "December"
13
12
  ]
14
- this.defaultPrevClass = undefined;
15
- this.defaultNextClass = undefined;
16
- this.defaultIndicatorClass = undefined;
17
- this.defaultIndicatorWidthPx = 0;
18
- this.itemSelector = 'TD.romo-datepicker-day:not(.disabled)';
19
- this.calTable = $();
20
- this.date = undefined;
21
- this.today = this._getTodaysDate();
22
- this.prevValue = undefined;
13
+
14
+ this.defaultFormat = 'yyyy-mm-dd'
15
+ this.defaultPrevClass = undefined;
16
+ this.defaultNextClass = undefined;
17
+ this.itemSelector = 'TD.romo-datepicker-day:not(.disabled)';
18
+ this.calTable = $();
19
+ this.date = undefined;
20
+ this.today = this._getTodaysDate();
21
+ this.prevValue = undefined;
23
22
 
24
23
  this.doInit();
25
24
  this.doBindElem();
@@ -36,47 +35,22 @@ RomoDatepicker.prototype.doInit = function() {
36
35
  }
37
36
 
38
37
  RomoDatepicker.prototype.doBindElem = function() {
39
- var elemWrapper = $('<div class="romo-datepicker-wrapper"></div>');
40
- elemWrapper.css({'display': (this.elem.data('romo-datepicker-elem-display') || 'inline-block')});
41
- if (this.elem.data('romo-datepicker-btn-group') === true) {
42
- elemWrapper.addClass('romo-btn-group');
43
- }
44
-
45
- this.elem.before(elemWrapper);
46
- elemWrapper.append(this.elem);
47
-
48
- // the elem wrapper should be treated like a child elem. add it to Romo's
49
- // parent-child elems so it will be removed when the elem (input) is removed.
50
- // delay adding it b/c the `append` statement above is not a "move", it is
51
- // a "remove" and "add" so if added immediately the "remove" part will
52
- // incorrectly remove the wrapper. Any value will do - I chose 1 arbitrarily.
53
- setTimeout($.proxy(function() {
54
- Romo.parentChildElems.add(this.elem, [elemWrapper]);
55
- }, this), 1);
56
-
57
38
  this.elem.attr('autocomplete', 'off');
58
39
 
59
- this.indicatorElem = $();
60
- var indicatorClass = this.elem.data('romo-datepicker-indicator') || this.defaultIndicatorClass;
61
- if (indicatorClass !== undefined && indicatorClass !== 'none') {
62
- this.indicatorElem = $('<i class="romo-datepicker-indicator '+indicatorClass+'"></i>');
63
- this.indicatorElem.css({'line-height': this.elem.css('height')});
64
- if (this.elem.prop('disabled') === true) {
65
- this.indicatorElem.addClass('disabled');
66
- }
67
- if (this.elem.css('display') === 'none') {
68
- this._hide(this.indicatorElem);
69
- }
70
- this.indicatorElem.on('click', $.proxy(this.onIndicatorClick, this));
71
-
72
- var indicatorWidthPx = this.elem.data('romo-datepicker-indicator-width-px') || this.defaultIndicatorWidthPx;
73
- // left-side spacing
74
- // + indicator width
75
- // + right-side spacing
76
- var indicatorPaddingPx = 4 + indicatorWidthPx + 4;
77
- this.elem.css({'padding-right': indicatorPaddingPx + 'px'});
78
- this.elem.after(this.indicatorElem);
40
+ if (this.elem.data('romo-datepicker-indicator') !== undefined) {
41
+ this.elem.attr('data-romo-indicator-text-input-indicator', this.elem.data('romo-datepicker-indicator'));
79
42
  }
43
+ if (this.elem.data('romo-datepicker-indicator-width-px') !== undefined) {
44
+ this.elem.attr('data-romo-indicator-text-input-indicator-width-px', this.elem.data('romo-datepicker-indicator-width-px'));
45
+ }
46
+ if (this.elem.data('romo-datepicker-btn-group') === true) {
47
+ this.elem.attr('data-romo-indicator-text-input-btn-group', this.elem.data('romo-datepicker-btn-group'));
48
+ }
49
+ if (this.elem.data('romo-datepicker-elem-display') !== undefined) {
50
+ this.elem.attr('data-romo-indicator-text-input-elem-display', this.elem.data('romo-datepicker-elem-display'));
51
+ }
52
+
53
+ this.elem.romoIndicatorTextInput();
80
54
 
81
55
  this.prevValue = this.elem.val();
82
56
  this.elem.on('change', $.proxy(function(e) {
@@ -85,18 +59,24 @@ RomoDatepicker.prototype.doBindElem = function() {
85
59
  this.prevValue = newValue;
86
60
  }, this));
87
61
 
62
+ this.elem.on('indicatorTextInput:indicatorClick', $.proxy(function(e) {
63
+ this._clearBlurTimeout();
64
+ this.elem.trigger('datepicker:triggerPopupOpen');
65
+ }, this));
66
+
88
67
  this.elem.on('datepicker:triggerEnable', $.proxy(function(e) {
89
- this.doEnable();
68
+ this.elem.trigger('indicatorTextInput:triggerEnable', []);
90
69
  }, this));
91
70
  this.elem.on('datepicker:triggerDisable', $.proxy(function(e) {
92
- this.doDisable();
71
+ this.elem.trigger('indicatorTextInput:triggerDisable', []);
93
72
  }, this));
94
73
  this.elem.on('datepicker:triggerShow', $.proxy(function(e) {
95
- this.doShow();
74
+ this.elem.trigger('indicatorTextInput:triggerShow', []);
96
75
  }, this));
97
76
  this.elem.on('datepicker:triggerHide', $.proxy(function(e) {
98
- this.doHide();
77
+ this.elem.trigger('indicatorTextInput:triggerHide', []);
99
78
  }, this));
79
+
100
80
  this.elem.on('datepicker:triggerSetFormat', $.proxy(function(e) {
101
81
  this.doSetFormat();
102
82
  }, this));
@@ -117,28 +97,6 @@ RomoDatepicker.prototype.doSetDate = function(value) {
117
97
  }
118
98
  }
119
99
 
120
- RomoDatepicker.prototype.doEnable = function() {
121
- this.elem.prop('disabled', false);
122
- this.elem.removeClass('disabled');
123
- this.indicatorElem.removeClass('disabled');
124
- }
125
-
126
- RomoDatepicker.prototype.doDisable = function() {
127
- this.elem.prop('disabled', true);
128
- this.elem.addClass('disabled');
129
- this.indicatorElem.addClass('disabled');
130
- }
131
-
132
- RomoDatepicker.prototype.doShow = function() {
133
- this._show(this.elem);
134
- this._show(this.indicatorElem);
135
- }
136
-
137
- RomoDatepicker.prototype.doHide = function() {
138
- this._hide(this.elem);
139
- this._hide(this.indicatorElem);
140
- }
141
-
142
100
  RomoDatepicker.prototype.doBindDropdown = function() {
143
101
  this.elem.attr('data-romo-dropdown-disable-toggle', 'true');
144
102
  if (this.elem.data('romo-dropdown-width') === undefined) {
@@ -283,18 +241,6 @@ RomoDatepicker.prototype.onItemEnter = function(e) {
283
241
  this._highlightItem($(e.target));
284
242
  }
285
243
 
286
- RomoDatepicker.prototype.onIndicatorClick = function(e) {
287
- this._clearBlurTimeout();
288
- if (e !== undefined) {
289
- e.preventDefault();
290
- e.stopPropagation();
291
- }
292
- if (this.elem.prop('disabled') === false) {
293
- this.elem.focus();
294
- this.elem.trigger('datepicker:triggerPopupOpen');
295
- }
296
- }
297
-
298
244
  RomoDatepicker.prototype.onItemClick = function(e) {
299
245
  this._clearBlurTimeout();
300
246
  if (e !== undefined) {
@@ -278,6 +278,7 @@ RomoDropdown.prototype.onElemKeyUp = function(e) {
278
278
  if (this.popupElem.hasClass('romo-dropdown-open')) {
279
279
  if(e.keyCode === 27 /* Esc */ ) {
280
280
  this.doPopupClose();
281
+ this.elem.trigger('dropdown:popupClosedByEsc', [this]);
281
282
  return false;
282
283
  } else {
283
284
  return true;
@@ -321,6 +322,7 @@ RomoDropdown.prototype.doUnBindWindowBodyKeyUp = function() {
321
322
  RomoDropdown.prototype.onWindowBodyKeyUp = function(e) {
322
323
  if (e.keyCode === 27 /* Esc */) {
323
324
  this.doPopupClose();
325
+ this.elem.trigger('dropdown:popupClosedByEsc', [this]);
324
326
  }
325
327
  return true;
326
328
  }
@@ -333,7 +335,6 @@ RomoDropdown.prototype.onResizeWindow = function(e) {
333
335
  RomoDropdown.prototype.doPlacePopupElem = function() {
334
336
  if (this.elem.parents('.romo-modal-popup').size() !== 0) {
335
337
  this.popupElem.css({'position': 'fixed'});
336
- this.popupElem.offset(this.elem.offset());
337
338
  }
338
339
 
339
340
  var pos = $.extend({}, this.elem[0].getBoundingClientRect(), this.elem.offset());
@@ -360,6 +361,9 @@ RomoDropdown.prototype.doPlacePopupElem = function() {
360
361
  configHeight = bottomAvailHeight;
361
362
  }
362
363
 
364
+ // remove any height difference between the popup and content elems
365
+ // assumes popup height always greater than or equal to content height
366
+ configHeight = configHeight - (h - this.contentElem[0].offsetHeight);
363
367
  this.contentElem.css({'max-height': configHeight.toString() + 'px'});
364
368
  }
365
369
 
@@ -386,6 +390,10 @@ RomoDropdown.prototype.doPlacePopupElem = function() {
386
390
  break;
387
391
  }
388
392
 
393
+ $.extend(offset, {
394
+ top: this._roundPosOffsetVal(offset['top']),
395
+ left: this._roundPosOffsetVal(offset['left'])
396
+ });
389
397
  this.popupElem.offset(offset);
390
398
  }
391
399
 
@@ -420,6 +428,10 @@ RomoDropdown.prototype._getPopupMaxHeightDetectPad = function(position) {
420
428
  return this.elem.data('romo-dropdown-max-height-detect-pad-'+position) || this.elem.data('romo-dropdown-max-height-detect-pad') || 10;
421
429
  }
422
430
 
431
+ RomoDropdown.prototype._roundPosOffsetVal = function(value) {
432
+ return Math.round(value*100) / 100;
433
+ }
434
+
423
435
  Romo.onInitUI(function(e) {
424
436
  Romo.initUIElems(e, '[data-romo-dropdown-auto="true"]').romoDropdown();
425
437
  });
@@ -38,28 +38,17 @@ RomoIndicatorTextInput.prototype.doBindElem = function() {
38
38
  Romo.parentChildElems.add(this.elem, [elemWrapper]);
39
39
  }, this), 1);
40
40
 
41
- this.elem.attr('autocomplete', 'off');
42
-
43
41
  this.indicatorElem = $();
44
42
  var indicatorClass = this.elem.data('romo-indicator-text-input-indicator') || this.defaultIndicatorClass;
45
43
  if (indicatorClass !== undefined && indicatorClass !== 'none') {
46
44
  this.indicatorElem = $('<i class="romo-indicator-text-input-indicator '+indicatorClass+'"></i>');
47
- this.indicatorElem.css({'line-height': this.elem.css('height')});
48
- if (this.elem.prop('disabled') === true) {
49
- this.indicatorElem.addClass('disabled');
50
- }
51
- if (this.elem.css('display') === 'none') {
52
- this._hide(this.indicatorElem);
53
- }
45
+ this.elem.after(this.indicatorElem);
54
46
  this.indicatorElem.on('click', $.proxy(this.onIndicatorClick, this));
47
+ this.doPlaceIndicatorElem();
55
48
 
56
- var indicatorWidthPx = this.elem.data('romo-indicator-text-input-indicator-width-px') || this.defaultIndicatorWidthPx;
57
- // left-side spacing
58
- // + indicator width
59
- // + right-side spacing
60
- var indicatorPaddingPx = 4 + indicatorWidthPx + 4;
61
- this.elem.css({'padding-right': indicatorPaddingPx + 'px'});
62
- this.elem.after(this.indicatorElem);
49
+ this.elem.on('indicatorTextInput:triggerPlaceIndicator', $.proxy(function(e) {
50
+ this.doPlaceIndicatorElem();
51
+ }, this));
63
52
  }
64
53
 
65
54
  this.elem.on('indicatorTextInput:triggerEnable', $.proxy(function(e) {
@@ -76,6 +65,25 @@ RomoIndicatorTextInput.prototype.doBindElem = function() {
76
65
  }, this));
77
66
  }
78
67
 
68
+ RomoIndicatorTextInput.prototype.doPlaceIndicatorElem = function() {
69
+ if (this.indicatorElem !== undefined) {
70
+ this.indicatorElem.css({'line-height': this.elem.css('height')});
71
+ if (this.elem.prop('disabled') === true) {
72
+ this.indicatorElem.addClass('disabled');
73
+ }
74
+ if (this.elem.css('display') === 'none') {
75
+ this._hide(this.indicatorElem);
76
+ }
77
+
78
+ var indicatorWidthPx = this.elem.data('romo-indicator-text-input-indicator-width-px') || this.defaultIndicatorWidthPx;
79
+ // left-side spacing
80
+ // + indicator width
81
+ // + right-side spacing
82
+ var indicatorPaddingPx = 4 + indicatorWidthPx + 4;
83
+ this.elem.css({'padding-right': indicatorPaddingPx + 'px'});
84
+ }
85
+ }
86
+
79
87
  RomoIndicatorTextInput.prototype.doEnable = function() {
80
88
  this.elem.prop('disabled', false);
81
89
  this.elem.removeClass('disabled');
@@ -91,6 +99,7 @@ RomoIndicatorTextInput.prototype.doDisable = function() {
91
99
  RomoIndicatorTextInput.prototype.doShow = function() {
92
100
  this._show(this.elem);
93
101
  this._show(this.indicatorElem);
102
+ this.doPlaceIndicatorElem();
94
103
  }
95
104
 
96
105
  RomoIndicatorTextInput.prototype.doHide = function() {
@@ -105,6 +114,7 @@ RomoIndicatorTextInput.prototype.onIndicatorClick = function(e) {
105
114
  }
106
115
  if (this.elem.prop('disabled') === false) {
107
116
  this.elem.focus();
117
+ this.elem.trigger('indicatorTextInput:indicatorClick');
108
118
  }
109
119
  }
110
120
 
@@ -110,6 +110,18 @@ RomoSelect.prototype._buildSelectDropdownElem = function() {
110
110
  if (romoSelectDropdownElem.data('romo-dropdown-max-height') === undefined) {
111
111
  romoSelectDropdownElem.attr('data-romo-dropdown-max-height', 'detect');
112
112
  }
113
+ if (this.elem.data('romo-select-filter-placeholder') !== undefined) {
114
+ romoSelectDropdownElem.attr('data-romo-select-dropdown-filter-placeholder', this.elem.data('romo-select-filter-placeholder'));
115
+ }
116
+ if (this.elem.data('romo-select-filter-indicator') !== undefined) {
117
+ romoSelectDropdownElem.attr('data-romo-select-dropdown-filter-indicator', this.elem.data('romo-select-filter-indicator'));
118
+ }
119
+ if (this.elem.data('romo-select-filter-indicator-width-px') !== undefined) {
120
+ romoSelectDropdownElem.attr('data-romo-select-dropdown-filter-indicator-width-px', this.elem.data('romo-select-filter-indicator-width-px'));
121
+ }
122
+ if (this.elem.data('romo-select-no-filter') !== undefined) {
123
+ romoSelectDropdownElem.attr('data-romo-select-dropdown-no-filter', this.elem.data('romo-select-no-filter'));
124
+ }
113
125
 
114
126
  var classList = this.elem.attr('class') !== undefined ? this.elem.attr('class').split(/\s+/) : [];
115
127
  $.each(classList, function(idx, classItem) {
@@ -148,7 +160,7 @@ RomoSelect.prototype._buildSelectDropdownElem = function() {
148
160
  caret.css({'line-height': romoSelectDropdownElem.css('line-height')});
149
161
  caret.on('click', $.proxy(this.onCaretClick, this));
150
162
 
151
- var caretWidthPx = this.elem.data('romo-select-caret-width-px') || this.defaultCaretWidthPx;
163
+ var caretWidthPx = this.elem.data('romo-select-caret-width-px') || this.defaultCaretWidthPx;
152
164
  // left-side spacing
153
165
  // + caret width
154
166
  // - 1 px select styling optical illusion
@@ -5,13 +5,16 @@ $.fn.romoSelectDropdown = function(optionElemsParent) {
5
5
  }
6
6
 
7
7
  var RomoSelectDropdown = function(element, optionElemsParent) {
8
- this.elem = $(element);
9
- this.itemSelector = 'LI[data-romo-select-item="opt"]:not(.disabled)';
10
- this.prevValue = '';
8
+ this.elem = $(element);
9
+ this.prevValue = '';
11
10
 
12
- var optsParent = (optionElemsParent || this.elem.find('.romo-select-dropdown-options-parent'));
13
- this.optionElems = optsParent.children();
14
- this.optionList = this._buildOptionList(this.optionElems);
11
+ this.filterHiddenClass = 'romo-select-filter-hidden';
12
+ this.itemSelector = 'LI[data-romo-select-item="opt"]:not(.disabled):not(.'+this.filterHiddenClass+')';
13
+
14
+ var optsParent = (optionElemsParent || this.elem.find('.romo-select-dropdown-options-parent'));
15
+ this.optionElems = optsParent.children();
16
+ this.optionList = this._buildOptionList(this.optionElems);
17
+ this.optionFilter = undefined;
15
18
 
16
19
  this.doInit();
17
20
  this.doBindDropdown();
@@ -44,15 +47,10 @@ RomoSelectDropdown.prototype.doBindDropdown = function() {
44
47
  this.romoDropdown = this.elem.romoDropdown()[0];
45
48
  this.romoDropdown.doSetPopupZIndex(this.elem);
46
49
  this.romoDropdown.bodyElem.addClass('romo-select-option-list');
50
+
47
51
  this.romoDropdown.elem.on('dropdown:popupOpen', $.proxy(this.onPopupOpen, this));
48
52
  this.romoDropdown.elem.on('dropdown:popupClose', $.proxy(this.onPopupClose, this));
49
- this.romoDropdown.elem.on('blur', $.proxy(function(e) {
50
- this.blurTimeoutId = setTimeout($.proxy(function() {
51
- if (this.popupMouseDown !== true) {
52
- this.romoDropdown.elem.trigger('dropdown:triggerPopupClose', []);
53
- }
54
- }, this), 10);
55
- }, this));
53
+
56
54
  this.romoDropdown.elem.on('keydown', $.proxy(this.onElemKeyDown, this));
57
55
  this.romoDropdown.popupElem.on('keydown', $.proxy(this.onElemKeyDown, this));
58
56
 
@@ -77,6 +75,15 @@ RomoSelectDropdown.prototype.doBindDropdown = function() {
77
75
  }, this));
78
76
 
79
77
  this.romoDropdown.bodyElem.html('');
78
+
79
+ if (this.elem.data('romo-select-dropdown-no-filter') !== true) {
80
+ this.optionFilter = this._buildOptionFilter();
81
+ var optionFilterWrapper = $('<div class="romo-select-dropdown-option-filter-wrapper"></div>');
82
+ optionFilterWrapper.append(this.optionFilter);
83
+ this.romoDropdown.popupElem.prepend(optionFilterWrapper);
84
+ this.doBindDropdownOptionFilter();
85
+ }
86
+
80
87
  this.romoDropdown.bodyElem.append(this.optionList);
81
88
 
82
89
  this.romoDropdown.bodyElem.find(this.itemSelector).on('mouseenter', $.proxy(this.onItemEnter, this));
@@ -86,16 +93,116 @@ RomoSelectDropdown.prototype.doBindDropdown = function() {
86
93
  this.romoDropdown.popupElem.on('mouseup', $.proxy(this.onPopupMouseUp, this));
87
94
  }
88
95
 
96
+ RomoSelectDropdown.prototype.doBindDropdownOptionFilter = function() {
97
+ this.optionFilter.romoIndicatorTextInput();
98
+ this.optionFilter.romoOnkey();
99
+
100
+ this.romoDropdown.elem.on('focus', $.proxy(function(e) {
101
+ if (this.blurTimeoutId !== undefined) {
102
+ clearTimeout(this.blurTimeoutId);
103
+ }
104
+ // remove any manual elem focus when elem is actually focused
105
+ this.optionFilterFocused = false;
106
+ this.romoDropdown.elem.removeClass('romo-select-focus');
107
+ }, this));
108
+ this.romoDropdown.elem.on('blur', $.proxy(function(e) {
109
+ if (this.blurTimeoutId !== undefined) {
110
+ clearTimeout(this.blurTimeoutId);
111
+ }
112
+ // close the dropdown when elem is blurred
113
+ // remove any manual focus as well
114
+ this.romoDropdown.elem.removeClass('romo-select-focus');
115
+ this.blurTimeoutId = setTimeout($.proxy(function() {
116
+ if (this.popupMouseDown !== true && this.optionFilterFocused !== true) {
117
+ this.romoDropdown.elem.trigger('dropdown:triggerPopupClose', []);
118
+ }
119
+ }, this), 10);
120
+ }, this));
121
+ this.optionFilter.on('focus', $.proxy(function(e) {
122
+ if (this.blurTimeoutId !== undefined) {
123
+ clearTimeout(this.blurTimeoutId);
124
+ }
125
+ // manually make the elem focused when its filter is focused
126
+ this.optionFilterFocused = true;
127
+ this.romoDropdown.elem.addClass('romo-select-focus');
128
+ }, this));
129
+ this.optionFilter.on('blur', $.proxy(function(e) {
130
+ // remove any manual elem focus when its filter is blurred
131
+ this.optionFilterFocused = false;
132
+ this.romoDropdown.elem.removeClass('romo-select-focus');
133
+ }, this));
134
+
135
+ this.romoDropdown.elem.on('dropdown:popupOpen', $.proxy(function(e, dropdown) {
136
+ this.optionFilter.trigger('indicatorTextInput:triggerPlaceIndicator');
137
+ this.optionFilter.focus();
138
+ this.doFilterOptionElems();
139
+ }, this));
140
+ this.romoDropdown.elem.on('dropdown:popupClose', $.proxy(function(e, dropdown) {
141
+ this.optionFilter.val('');
142
+ }, this));
143
+ this.romoDropdown.elem.on('dropdown:popupClosedByEsc', $.proxy(function(e, dropdown) {
144
+ this.romoDropdown.elem.focus();
145
+ }, this));
146
+ this.optionFilter.on('click', $.proxy(function(e) {
147
+ if (e !== undefined) {
148
+ e.stopPropagation();
149
+ }
150
+ }, this));
151
+ this.romoDropdown.popupElem.on('click', $.proxy(function(e) {
152
+ this.optionFilter.focus();
153
+ }, this));
154
+
155
+ this.onkeySearchTimeout = undefined;
156
+ this.onkeySearchDelay = 100; // 0.1 secs, want it to be really responsive
157
+
158
+ this.optionFilter.on('onkey:trigger', $.proxy(function(e, triggerEvent, onkey) {
159
+ // TODO: incorp this timeout logic into the onkey component so don't have to repeat it
160
+ clearTimeout(this.onkeySearchTimeout);
161
+ this.onkeySearchTimeout = setTimeout($.proxy(function() {
162
+ if (Romo.nonInputTextKeyCodes().indexOf(triggerEvent.keyCode) === -1 /* Input Text */) {
163
+ this.doFilterOptionElems();
164
+ }
165
+ }, this), this.onkeySearchDelay);
166
+ }, this));
167
+ }
168
+
169
+ RomoSelectDropdown.prototype.doFilterOptionElems = function() {
170
+ var wbFilter = new RomoWordBoundaryFilter(
171
+ this.optionFilter.val(),
172
+ this.romoDropdown.bodyElem.find('LI[data-romo-select-item="opt"]'),
173
+ function(elem) {
174
+ return elem[0].textContent;
175
+ }
176
+ );
177
+
178
+ wbFilter.matchingElems.show();
179
+ wbFilter.notMatchingElems.hide();
180
+ wbFilter.matchingElems.removeClass(this.filterHiddenClass);
181
+ wbFilter.notMatchingElems.addClass(this.filterHiddenClass);
182
+
183
+ this.romoDropdown.doPlacePopupElem();
184
+ if (this.optionFilter.val() !== '') {
185
+ this._highlightItem(wbFilter.matchingElems.first());
186
+ this._scrollTopToItem(wbFilter.matchingElems.first());
187
+ } else {
188
+ this._highlightItem(this.selectedListing());
189
+ this._scrollTopToItem(this.selectedListing());
190
+ }
191
+ }
192
+
89
193
  RomoSelectDropdown.prototype.doSelectHighlightedItem = function() {
90
- var prevValue = this.prevValue;
91
- var newValue = this.romoDropdown.bodyElem.find('LI.romo-select-highlight').data('romo-select-option-value');
194
+ var curr = this._getHighlightedItem();
195
+ if (curr.length !== 0) {
196
+ var prevValue = this.prevValue;
197
+ var newValue = curr.data('romo-select-option-value');
92
198
 
93
- this.romoDropdown.doPopupClose();
94
- this.elem.trigger('selectDropdown:itemSelected', [newValue, prevValue, this]);
199
+ this.romoDropdown.doPopupClose();
200
+ this.elem.trigger('selectDropdown:itemSelected', [newValue, prevValue, this]);
95
201
 
96
- if (newValue !== prevValue) {
97
- this.doSetNewValue(newValue);
98
- this.elem.trigger('selectDropdown:change', [newValue, prevValue, this]);
202
+ if (newValue !== prevValue) {
203
+ this.doSetNewValue(newValue);
204
+ this.elem.trigger('selectDropdown:change', [newValue, prevValue, this]);
205
+ }
99
206
  }
100
207
  }
101
208
 
@@ -172,6 +279,9 @@ RomoSelectDropdown.prototype.onPopupOpenBodyKeyDown = function(e) {
172
279
  } else if (e.keyCode === 13 /* Enter */ ) {
173
280
  this.doSelectHighlightedItem();
174
281
  return false;
282
+ } else if (e.keyCode === 9 /* Tab */ ) {
283
+ e.preventDefault();
284
+ return false;
175
285
  } else {
176
286
  return true;
177
287
  }
@@ -180,9 +290,19 @@ RomoSelectDropdown.prototype.onPopupOpenBodyKeyDown = function(e) {
180
290
  RomoSelectDropdown.prototype.onElemKeyDown = function(e) {
181
291
  if (this.elem.hasClass('disabled') === false) {
182
292
  if (this.romoDropdown.popupElem.hasClass('romo-dropdown-open') === false) {
183
- if(e.keyCode === 40 /* Down */ ) {
293
+ if (e.keyCode === 40 /* Down */ || e.keyCode === 38 /* Up */) {
184
294
  this.romoDropdown.doPopupOpen();
185
295
  return false;
296
+ } else if (this.optionFilter !== undefined &&
297
+ Romo.nonInputTextKeyCodes().indexOf(e.keyCode) === -1 /* Input Text */) {
298
+ if (e.metaKey === false) {
299
+ // don't prevent default on Cmd-* keys (preserve Cmd-R refresh, etc)
300
+ e.preventDefault();
301
+ }
302
+ e.stopPropagation();
303
+ this.optionFilter.val(e.key);
304
+ this.romoDropdown.doPopupOpen();
305
+ return true;
186
306
  } else {
187
307
  return true;
188
308
  }
@@ -258,69 +378,74 @@ RomoSelectDropdown.prototype._buildOptGroupListItem = function(optGroupElem) {
258
378
  return item;
259
379
  }
260
380
 
261
- RomoSelectDropdown.prototype._nextListItem = function() {
262
- var listOrItemSelector = 'UL, '+this.itemSelector;
263
- var curr = this.romoDropdown.bodyElem.find('LI.romo-select-highlight');
264
- var next = this._nextAll(curr, listOrItemSelector).first();
381
+ RomoSelectDropdown.prototype._buildOptionFilter = function() {
382
+ var filter = $('<input type="text" class="romo-select-dropdown-option-filter"></input>');
265
383
 
266
- if (next.size() === 0) {
267
- next = this._nextAll(curr.closest('UL'), listOrItemSelector).first();
384
+ if (this.elem.data('romo-select-dropdown-filter-placeholder') !== undefined) {
385
+ filter.attr('placeholder', this.elem.data('romo-select-dropdown-filter-placeholder'));
268
386
  }
269
- if (next.size() !== 0 && next[0].tagName === 'UL') {
270
- next = next.find(this.itemSelector).first()
387
+ filter.attr('data-romo-indicator-text-input-elem-display', "block");
388
+ if (this.elem.data('romo-select-dropdown-filter-indicator') !== undefined) {
389
+ filter.attr('data-romo-indicator-text-input-indicator', this.elem.data('romo-select-dropdown-filter-indicator'));
271
390
  }
272
- if (next.size() === 0) {
273
- next = this.romoDropdown.bodyElem.find(this.itemSelector).first();
391
+ if (this.elem.data('romo-select-dropdown-filter-indicator-width-px') !== undefined) {
392
+ filter.attr('data-romo-indicator-text-input-indicator-width-px', this.elem.data('romo-select-dropdown-filter-indicator-width-px'));
274
393
  }
275
- return next;
276
- }
394
+ filter.attr('data-romo-form-disable-enter-submit', "true");
395
+ filter.attr('data-romo-onkey-on', "keydown");
277
396
 
278
- RomoSelectDropdown.prototype._prevListItem = function() {
279
- var listOrItemSelector = 'UL, '+this.itemSelector;
280
- var curr = this.romoDropdown.bodyElem.find('LI.romo-select-highlight');
281
- var prev = this._prevAll(curr, listOrItemSelector).last();
397
+ filter.attr('autocomplete', 'off');
282
398
 
283
- if (prev.size() === 0) {
284
- prev = this._prevAll(curr.closest('UL'), listOrItemSelector).last();
285
- }
286
- if (prev.size() !== 0 && prev[0].tagName === 'UL') {
287
- prev = prev.find(this.itemSelector).last()
288
- }
289
- if (prev.size() === 0) {
290
- prev = this.romoDropdown.bodyElem.find(this.itemSelector).last();
291
- }
292
- return prev;
399
+ return filter;
293
400
  }
294
401
 
295
- RomoSelectDropdown.prototype._nextAll = function(elem, selector) {
296
- var els = $();
297
- var el = elem.next();
298
- while( el.length ) {
299
- if (selector === undefined || el.is(selector)) {
300
- els = els.add(el);
402
+ RomoSelectDropdown.prototype._nextListItem = function() {
403
+ var curr = this._getHighlightedItem();
404
+ if (curr.length === 0) {
405
+ return curr;
406
+ }
407
+ var currList = curr.closest('UL');
408
+ var next = Romo.selectNext(curr, this.itemSelector);
409
+
410
+ while (next.length === 0) {
411
+ currList = Romo.selectNext(currList, 'UL');
412
+ if (currList.length !== 0) {
413
+ next = currList.find(this.itemSelector).first();
414
+ } else {
415
+ next = this.romoDropdown.bodyElem.find(this.itemSelector).first();
301
416
  }
302
- el = el.next();
303
417
  }
304
- return els;
418
+ return next;
305
419
  }
306
420
 
307
- RomoSelectDropdown.prototype._prevAll = function(elem, selector) {
308
- var els = $();
309
- var el = elem.prev();
310
- while( el.length ) {
311
- if (selector === undefined || el.is(selector)) {
312
- els = els.add(el);
421
+ RomoSelectDropdown.prototype._prevListItem = function() {
422
+ var curr = this._getHighlightedItem();
423
+ if (curr.length === 0) {
424
+ return curr;
425
+ }
426
+ var currList = curr.closest('UL');
427
+ var prev = Romo.selectPrev(curr, this.itemSelector);
428
+
429
+ while (prev.length === 0) {
430
+ currList = Romo.selectPrev(currList, 'UL');
431
+ if (currList.length !== 0) {
432
+ prev = currList.find(this.itemSelector).last();
433
+ } else {
434
+ prev = this.romoDropdown.bodyElem.find(this.itemSelector).last();
313
435
  }
314
- el = el.prev();
315
436
  }
316
- return els;
437
+ return prev;
317
438
  }
318
439
 
319
440
  RomoSelectDropdown.prototype._highlightItem = function(item) {
320
- this.romoDropdown.bodyElem.find('LI.romo-select-highlight').removeClass('romo-select-highlight');
441
+ this._getHighlightedItem().removeClass('romo-select-highlight');
321
442
  item.addClass('romo-select-highlight');
322
443
  }
323
444
 
445
+ RomoSelectDropdown.prototype._getHighlightedItem = function() {
446
+ return this.romoDropdown.bodyElem.find('LI.romo-select-highlight');
447
+ }
448
+
324
449
  Romo.onInitUI(function(e) {
325
450
  Romo.initUIElems(e, '[data-romo-select-dropdown-auto="true"]').romoSelectDropdown();
326
451
  });
@@ -10,15 +10,28 @@ var RomoSortable = function(element) {
10
10
  this.draggableSelector = '[data-romo-sortable-item="true"]';
11
11
  this.handleSelector = '[data-romo-sortable-handle="true"]';
12
12
 
13
- this.draggableElems = this.elem.find(this.draggableSelector);
14
- this.draggableElems.prop('draggable', 'true');
13
+ this.draggedElem = this.draggedIndex = this.draggableSelected = null;
14
+ this.draggedOverElem = this.dragDirection = this.lastY = null;
15
+
16
+ this.doInit();
17
+ this.doBindDraggables();
18
+ this.doInitPlaceholder();
19
+ this._resetGrabClasses();
20
+
21
+ this.elem.trigger('sortable:ready', [this]);
22
+ }
23
+
24
+ RomoSortable.prototype.doInit = function() {
25
+ // override as needed
26
+ }
15
27
 
16
- this.draggingClass = this.elem.data('romo-sortable-dragging-class') || '';
17
- this.dragOverClass = this.elem.data('romo-sortable-dragover-class') || '';
28
+ RomoSortable.prototype.doBindDraggables = function() {
29
+ this.draggingClass = this.elem.data('romo-sortable-dragging-class') || '';
30
+ this.dragOverClass = this.elem.data('romo-sortable-dragover-class') || '';
18
31
  this.placeholderClass = this.elem.data('romo-sortable-placeholder-class') || '';
19
32
 
20
- this.draggedElem = this.draggedIndex = this.draggableSelected = null;
21
- this.draggedOverElem = this.dragDirection = this.lastY = null;
33
+ this.draggableElems = this.elem.find(this.draggableSelector);
34
+ this.draggableElems.prop('draggable', 'true');
22
35
 
23
36
  this.elem.on('dragenter', $.proxy(this.onDragEnter, this));
24
37
  this.elem.on('dragover', $.proxy(this.onDragOver, this));
@@ -36,16 +49,6 @@ var RomoSortable = function(element) {
36
49
  handleElems.on('mousedown', $.proxy(this.onHandleMouseDown, this));
37
50
 
38
51
  $('body').on('mouseup', $.proxy(this.onWindowBodyMouseUp, this));
39
-
40
- this._resetGrabClasses();
41
- this.doInit();
42
- this.doInitPlaceholder();
43
-
44
- this.elem.trigger('sortable:ready', [this]);
45
- }
46
-
47
- RomoSortable.prototype.doInit = function() {
48
- // override as needed
49
52
  }
50
53
 
51
54
  RomoSortable.prototype.doInitPlaceholder = function() {
data/lib/romo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Romo
2
- VERSION = "0.17.0"
2
+ VERSION = "0.17.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: romo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2016-11-01 00:00:00 Z
13
+ date: 2016-11-08 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: assert