webshims-rails 1.12.0 → 1.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/extras/modernizr-custom.js +440 -440
  4. data/vendor/assets/javascripts/webshims/polyfiller.js +132 -91
  5. data/vendor/assets/javascripts/webshims/shims/combos/10.js +248 -91
  6. data/vendor/assets/javascripts/webshims/shims/combos/11.js +237 -84
  7. data/vendor/assets/javascripts/webshims/shims/combos/15.js +21 -8
  8. data/vendor/assets/javascripts/webshims/shims/combos/16.js +21 -8
  9. data/vendor/assets/javascripts/webshims/shims/combos/17.js +237 -84
  10. data/vendor/assets/javascripts/webshims/shims/combos/18.js +237 -84
  11. data/vendor/assets/javascripts/webshims/shims/combos/19.js +11 -7
  12. data/vendor/assets/javascripts/webshims/shims/combos/2.js +18 -8
  13. data/vendor/assets/javascripts/webshims/shims/combos/20.js +11 -7
  14. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1 -1
  15. data/vendor/assets/javascripts/webshims/shims/combos/22.js +1 -1
  16. data/vendor/assets/javascripts/webshims/shims/combos/24.js +9 -6
  17. data/vendor/assets/javascripts/webshims/shims/combos/25.js +11 -7
  18. data/vendor/assets/javascripts/webshims/shims/combos/26.js +11 -7
  19. data/vendor/assets/javascripts/webshims/shims/combos/28.js +10 -1
  20. data/vendor/assets/javascripts/webshims/shims/combos/3.js +11 -7
  21. data/vendor/assets/javascripts/webshims/shims/combos/30.js +18 -8
  22. data/vendor/assets/javascripts/webshims/shims/combos/31.js +18 -8
  23. data/vendor/assets/javascripts/webshims/shims/combos/32.js +7 -1
  24. data/vendor/assets/javascripts/webshims/shims/combos/33.js +7 -1
  25. data/vendor/assets/javascripts/webshims/shims/combos/4.js +11 -7
  26. data/vendor/assets/javascripts/webshims/shims/combos/5.js +237 -84
  27. data/vendor/assets/javascripts/webshims/shims/combos/6.js +244 -85
  28. data/vendor/assets/javascripts/webshims/shims/combos/7.js +18 -8
  29. data/vendor/assets/javascripts/webshims/shims/combos/8.js +11 -7
  30. data/vendor/assets/javascripts/webshims/shims/combos/9.js +255 -92
  31. data/vendor/assets/javascripts/webshims/shims/details.js +1 -1
  32. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +10 -7
  33. data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +53 -56
  34. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +7 -1
  35. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +175 -60
  36. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +3 -0
  37. data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +6 -6
  38. data/vendor/assets/javascripts/webshims/shims/form-validation.js +77 -28
  39. data/vendor/assets/javascripts/webshims/shims/form-validators.js +24 -16
  40. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +40 -68
  41. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pl.js +4 -4
  42. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-sv.js +13 -6
  43. data/vendor/assets/javascripts/webshims/shims/range-ui.js +61 -24
  44. data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +278 -95
  45. data/vendor/assets/javascripts/webshims/shims/styles/progress.gif +0 -0
  46. data/vendor/assets/javascripts/webshims/shims/styles/scss/_api-forms-ext.scss +203 -0
  47. data/vendor/assets/javascripts/webshims/shims/styles/scss/_api-shim.scss +115 -0
  48. data/vendor/assets/javascripts/webshims/shims/styles/scss/_extends.scss +18 -2
  49. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +227 -113
  50. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +168 -159
  51. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +106 -69
  52. metadata +4 -7
  53. data/vendor/assets/javascripts/webshims/shims/styles/details-arrows.png +0 -0
  54. data/vendor/assets/javascripts/webshims/shims/styles/polyfill-loader.gif +0 -0
  55. data/vendor/assets/javascripts/webshims/shims/styles/range-track.png +0 -0
  56. data/vendor/assets/javascripts/webshims/shims/styles/vertical-range.png +0 -0
  57. data/vendor/assets/javascripts/webshims/shims/swf/localStorage.swf +0 -0
@@ -5,7 +5,7 @@ webshims.register('details', function($, webshims, window, doc, undefined, optio
5
5
  return details;
6
6
  }
7
7
  };
8
-
8
+
9
9
  var bindDetailsSummary = function(summary, details){
10
10
  summary = $(summary);
11
11
  details = $(details);
@@ -609,7 +609,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
609
609
  setTimeout(trigger, 0);
610
610
  }
611
611
 
612
- }, (e.type == 'resize' && !window.requestAnimationFrame) ? 50 : 0);
612
+ }, (e.type == 'resize' && !window.requestAnimationFrame) ? 50 : 9);
613
613
  };
614
614
  })(),
615
615
  _create: function(){
@@ -634,7 +634,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
634
634
  setInterval(this.test, 600);
635
635
  $(this.test);
636
636
  webshims.ready('WINDOWLOAD', this.test);
637
- $(document).on('updatelayout pageinit collapsibleexpand shown.bs.modal shown.bs.collapse slid.bs.carousel', this.handler);
637
+ $(document).on('updatelayout.webshim pageinit popupafteropen panelbeforeopen tabsactivate collapsibleexpand shown.bs.modal shown.bs.collapse slid.bs.carousel', this.handler);
638
638
  $(window).on('resize', this.handler);
639
639
  (function(){
640
640
  var oldAnimate = $.fn.animate;
@@ -1081,10 +1081,10 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1081
1081
  });
1082
1082
 
1083
1083
  webshims.isReady('webshimLocalization', true);
1084
- });
1085
- //html5a11y
1086
- (function($, document){
1087
- if(!$.webshims.assumeARIA || ('content' in document.createElement('template'))){return;}
1084
+
1085
+ //html5a11y + hidden attribute
1086
+ (function(){
1087
+ if(('content' in document.createElement('template'))){return;}
1088
1088
 
1089
1089
  $(function(){
1090
1090
  var main = $('main').attr({role: 'main'});
@@ -1099,6 +1099,8 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1099
1099
  return;
1100
1100
  }
1101
1101
 
1102
+ webshims.defineNodeNamesBooleanProperty(['*'], 'hidden');
1103
+
1102
1104
  var elemMappings = {
1103
1105
  article: "article",
1104
1106
  aside: "complementary",
@@ -1139,4 +1141,5 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1139
1141
  }
1140
1142
  });
1141
1143
 
1142
- })(webshims.$, document);
1144
+ })();
1145
+ });
@@ -1,6 +1,6 @@
1
1
  webshims.register('form-datalist-lazy', function($, webshims, window, document, undefined, options){
2
2
 
3
- var listidIndex = 0;
3
+ var optionID = 0;
4
4
  var formsCFG = $.webshims.cfg.forms;
5
5
  var globStoredOptions = {};
6
6
  var getStoredOptions = function(name){
@@ -46,6 +46,9 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
46
46
  if(that._stopMouseOver && e && e.type == 'mouseenter'){return;}
47
47
  var items = $('li:not(.hidden-item)', that.shadowList);
48
48
  var select = (e.type == 'mousedown' || e.type == 'click');
49
+ if(select && $(opts.input).getNativeElement().triggerHandler('beforeselect', [$(e.currentTarget).find('.option-value').text()]) === false){
50
+ return (e.type != 'mousedown');
51
+ }
49
52
  that.markItem(items.index(e.currentTarget), select, items);
50
53
  if(e.type == 'click'){
51
54
  that.hideList();
@@ -77,8 +80,10 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
77
80
  var keyCode = e.keyCode;
78
81
  var activeItem;
79
82
  var items;
83
+ var doValue = that.options.noInlineValue ? 'onlyScroll' : true;
84
+
80
85
  if(keyCode == 40 && !that.showList()){
81
- that.markItem(that.index + 1, true);
86
+ that.markItem(that.index + 1, doValue);
82
87
  return false;
83
88
  }
84
89
 
@@ -86,11 +91,11 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
86
91
 
87
92
 
88
93
  if(keyCode == 38){
89
- that.markItem(that.index - 1, true);
94
+ that.markItem(that.index - 1, doValue);
90
95
  return false;
91
96
  }
92
97
  if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
93
- that.markItem(0, true);
98
+ that.markItem(0, doValue);
94
99
  return false;
95
100
  }
96
101
  if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
@@ -100,8 +105,14 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
100
105
  }
101
106
  if(keyCode == 13 || keyCode == 27){
102
107
  if (keyCode == 13){
108
+ if(that.isCompleted){
109
+ $.prop(opts.input, 'selectionStart', $.prop(opts.input, 'value').length);
110
+ }
103
111
  activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
104
- that.changeValue( $('li.active-item:not(.hidden-item)', that.shadowList) );
112
+ if($(opts.input).getNativeElement().triggerHandler('beforeselect', [activeItem.find('.option-value').text()]) === false){
113
+ return;
114
+ }
115
+ that.changeValue( activeItem );
105
116
  }
106
117
  that.hideList();
107
118
  if(formsCFG.customDatalist && activeItem && activeItem[0]){
@@ -166,60 +177,37 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
166
177
  this.lastUnfoundValue = '';
167
178
 
168
179
  if(!this.updateTimer){
169
- if(window.QUnit || (forceShow = ($(that.input).is(':focus') && ($(that.input).hasClass('list-focus') || $.prop(that.input, 'value'))) )){
180
+ if(window.QUnit || (forceShow = ($(that.input).is(':focus') && (that.options.focus || $.prop(that.input, 'value'))) )){
170
181
  that.updateListOptions(forceShow);
171
182
  } else {
172
183
  that.updateTimer = setTimeout(function(){
173
184
  that.updateListOptions();
174
185
  that = null;
175
- listidIndex = 1;
176
- }, 200 + (100 * listidIndex));
186
+ }, 200);
177
187
  }
178
188
  }
179
189
  },
180
190
  _updateOptions: function(){
181
191
  this.options = webshims.getOptions(this.input, 'list', options.list);
182
192
 
183
- if($(this.input).prop('multiple') && $(this.input).prop('type') == 'email'){
184
- this.options.multiple = true;
193
+ if($(this.input).prop('multiple')){
194
+ if($(this.input).prop('type') != 'email'){
195
+ webshims.warn('multiple only used on email and file type. Use data-list-multiple instead.');
196
+ } else {
197
+ this.options.multiple = true;
198
+ }
185
199
  }
200
+
201
+ if(this.options.noInlineValue && !this.options.valueCompletion){
202
+ $.attr(this.input, 'aria-autocomplete', 'list');
203
+ $.attr(this.input, 'aria-expanded', 'false');
204
+ }
205
+
186
206
 
187
207
  if( this.options.getOptionContent && !$.isFunction(this.options.getOptionContent) ){
188
208
  this.options.getOptionContent = false;
189
209
  }
190
210
 
191
- //depreacated option settings:
192
- if(options.getOptionContent){
193
- webshims.error('getOptionContent is depreacated use $(input).on("getoptioncontent")');
194
- }
195
-
196
- if($(this.input).hasClass('list-focus')){
197
- webshims.error(".list-focus is depreacated. Use focus option.");
198
- }
199
-
200
- if(options.datalistPopover && !this.options.popover){
201
- this.options.popover = options.datalistPopover;
202
- webshims.error("datalistPopover is depreacated. Use popover option.");
203
- }
204
-
205
- if($(this.input).hasClass('mark-option-text')){
206
- this.options.highlight = true;
207
- webshims.error(".mark-option-text is depreacated. Use highlight option.");
208
- }
209
-
210
- if($(this.input).hasClass('list-multiple')){
211
- this.options.multiple = true;
212
- webshims.error(".list-multiple is depreacated. Use multiple option.");
213
- }
214
-
215
- if($(this.input).hasClass('value-completion')){
216
- this.options.valueCompletion = true;
217
- webshims.error(".value-completion is depreacated. Use valueCompletion option.");
218
- }
219
-
220
- if(this.options.valueCompletion && this.options.multiple){
221
- webshims.warn("valueCompletion and multiple shouldn't be set together");
222
- }
223
211
  },
224
212
  updateListOptions: function(_forceShow){
225
213
  this.needsUpdate = false;
@@ -263,15 +251,13 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
263
251
 
264
252
  for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
265
253
  item = allOptions[rI];
266
- list[rI] = '<li class="'+ item.className +'" tabindex="-1" role="listitem">'+ this.getOptionContent(item) +'</li>';
254
+ list[rI] = '<li class="'+ item.className +'" tabindex="-1" role="listitem" id="wsoption-'+ (optionID++) +'">'+ this.getOptionContent(item) +'</li>';
267
255
  }
268
256
 
269
257
  this.arrayOptions = allOptions;
270
- this.popover.contentElement.html('<div class="datalist-box"><ul role="list">'+ list.join("\n") +'</ul></div>');
258
+ this.popover.contentElement.html('<div class="datalist-box"><ul role="listbox">'+ list.join("\n") +'</ul></div>');
271
259
 
272
- if(options.datalistCreated){
273
- options.datalistCreated.apply(this);
274
- }
260
+ $(this.input).removeAttr('aria-activedescendant').triggerHandler('datalistcreated', [{instance: this}]);
275
261
 
276
262
  if(_forceShow || this.popover.isVisible){
277
263
  this.showHideOptions();
@@ -291,7 +277,8 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
291
277
  }
292
278
  return content || '';
293
279
  },
294
- setCompletedValue: function(value, foundItem){
280
+ setCompletedValue: function(value, foundItem, length){
281
+ this.isCompleted = false;
295
282
 
296
283
  if(!this.options.valueCompletion || !foundItem || this.lastCompletedValue.length >= value.length ){
297
284
  this.lastCompletedValue = value;
@@ -306,7 +293,7 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
306
293
 
307
294
  if(value.length == end){
308
295
 
309
- newValue = value + foundItem.value.substr(value.length);
296
+ newValue = value + foundItem.value.substr(length.length);
310
297
 
311
298
  $(input).triggerHandler('triggerinput');
312
299
  $.prop(input, 'value', newValue);
@@ -319,7 +306,7 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
319
306
  $.prop(input, 'selectionEnd', newValue.length);
320
307
  }
321
308
  }, 0);
322
-
309
+ this.isCompleted = true;
323
310
  }
324
311
  },
325
312
  showHideOptions: function(_fromShowList){
@@ -406,7 +393,8 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
406
393
  this.lastUnfoundValue = value;
407
394
  this.hideList();
408
395
  } else {
409
- this.setCompletedValue(inputValue, firstFoundValue);
396
+ $(this.input).removeAttr('aria-activedescendant');
397
+ this.setCompletedValue(inputValue, firstFoundValue, value);
410
398
  this.lastUnfoundValue = false;
411
399
  }
412
400
  },
@@ -443,14 +431,19 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
443
431
 
444
432
  that.shadowList.find('li.active-item').removeClass('active-item');
445
433
  that.popover.show(this.input);
446
-
434
+ $(this.input)
435
+ .attr({'aria-expanded': 'true'})
436
+ ;
447
437
 
448
438
  return true;
449
439
  },
450
440
  hideList: function(){
451
441
  if(!this.popover.isVisible){return false;}
452
442
  var that = this;
453
-
443
+ $(this.input)
444
+ .attr({'aria-expanded': 'false'})
445
+ .removeAttr('aria-activedescendant')
446
+ ;
454
447
 
455
448
  this.popover.hide();
456
449
  that.shadowList.removeClass('datalist-visible list-item-active');
@@ -519,12 +512,16 @@ webshims.register('form-datalist-lazy', function($, webshims, window, document,
519
512
  items.removeClass('active-item');
520
513
  this.shadowList.addClass('list-item-active');
521
514
  activeItem = items.filter(':eq('+ index +')').addClass('active-item');
522
-
515
+
523
516
  if(doValue){
524
- this.changeValue(activeItem);
517
+ if(doValue != 'onlyScroll'){
518
+ this.changeValue(activeItem);
519
+ } else {
520
+ $(this.input).attr('aria-activedescendant', activeItem.prop('id'));
521
+ }
525
522
  this.scrollIntoView(activeItem);
526
523
  }
527
524
  this.index = index;
528
525
  }
529
526
  });
530
- });
527
+ });
@@ -239,7 +239,13 @@ webshims.register('form-datalist', function($, webshims, window, document, undef
239
239
  lazyLoad('WINDOWLOAD');
240
240
 
241
241
  if(webshims.isReady('form-datalist-lazy')){
242
- this._lazyCreate(opts);
242
+ if(window.QUnit){
243
+ that._lazyCreate(opts);
244
+ } else {
245
+ setTimeout(function(){
246
+ that._lazyCreate(opts);
247
+ }, 9);
248
+ }
243
249
  } else {
244
250
  $(opts.input).one('focus', lazyLoad);
245
251
  webshims.ready('form-datalist-lazy', function(){
@@ -8,9 +8,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
8
8
  e.stopImmediatePropagation();
9
9
  };
10
10
  var getMonthOptions = function(opts){
11
- var selectName = 'monthSelect'+opts.formatMonthNames;
11
+ var selectName = 'monthSelect'+opts.monthNames;
12
12
  if(!curCfg[selectName]){
13
- var labels = curCfg.date[opts.formatMonthNames] || monthDigits;
13
+ var labels = curCfg.date[opts.monthNames] || monthDigits;
14
14
  curCfg[selectName] = ('<option value=""></option>')+$.map(monthDigits, function(val, i){
15
15
  return '<option value="'+val+'"]>'+labels[i]+'</option>';
16
16
  }).join('');
@@ -35,13 +35,39 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
35
35
  curCfg.patterns[name+'Obj'] = obj;
36
36
  }
37
37
  };
38
+ var createYearSelect = function(obj, opts){
39
+ var options, nowY, max, min;
40
+ if(opts.yearSelect){
41
+ nowY = parseInt(opts.value.split('-')[0], 10);
42
+ max = opts.max.split('-');
43
+ min = opts.min.split('-');
44
+ options = webshims.picker.createYearSelect(nowY || parseInt(min[0], 10) || parseInt(max[0], 10) || nowYear, max, min);
45
+ options.unshift('<option />');
46
+ $(obj.elements)
47
+ .filter('select.yy')
48
+ .html(options.join(''))
49
+ .each(function(){
50
+ if(!nowY){
51
+ $('option[selected]', this).removeAttr('selected');
52
+ $(this).val();
53
+ }
54
+ })
55
+ ;
56
+ }
57
+ };
38
58
  var splitInputs = {
39
59
  date: {
40
60
  _create: function(opts){
41
61
  var obj = {
42
- splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]]
62
+ splits: []
43
63
  };
44
64
 
65
+ if(opts.yearSelect){
66
+ obj.splits.push($('<select class="yy"></select>')[0]);
67
+ } else {
68
+ obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
69
+ }
70
+
45
71
  if(opts.monthSelect){
46
72
  obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
47
73
  } else {
@@ -54,6 +80,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
54
80
  }
55
81
 
56
82
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]];
83
+ createYearSelect(obj, opts);
57
84
  return obj;
58
85
  },
59
86
  sort: function(element){
@@ -78,8 +105,15 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
78
105
  _create: function(opts){
79
106
 
80
107
  var obj = {
81
- splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0]]
108
+ splits: []
82
109
  };
110
+
111
+ if(opts.yearSelect){
112
+ obj.splits.push($('<select class="yy"></select>')[0]);
113
+ } else {
114
+ obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
115
+ }
116
+
83
117
  if(opts.monthSelect){
84
118
  obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
85
119
  } else {
@@ -90,6 +124,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
90
124
  }
91
125
 
92
126
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
127
+ createYearSelect(obj, opts);
93
128
  return obj;
94
129
  },
95
130
  sort: function(element){
@@ -109,7 +144,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
109
144
  };
110
145
 
111
146
  var nowDate = new Date(new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 ));
112
- nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime()
147
+ var nowYear = nowDate.getFullYear();
148
+ nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime();
113
149
  var steps = {
114
150
  number: {
115
151
  step: 1
@@ -319,9 +355,6 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
319
355
  $(document).triggerHandler('wslocalechange');
320
356
  };
321
357
 
322
-
323
-
324
-
325
358
  curCfg = webshims.activeLang(formcfg);
326
359
 
327
360
  triggerLocaleChange();
@@ -346,7 +379,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
346
379
 
347
380
 
348
381
  var formatVal = {
349
- number: function(val){
382
+ number: function(val, o){
350
383
  return (val+'').replace(/\,/g, '').replace(/\./, curCfg.numberFormat['.']);
351
384
  },
352
385
  time: function(val){
@@ -383,7 +416,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
383
416
  var names;
384
417
  var p = val.split('-');
385
418
  if(p[0] && p[1]){
386
- names = curCfg.date[options.formatMonthNames] || curCfg.date[options.monthNames] || curCfg.date.monthNames;
419
+ names = curCfg.date[options.monthNames] || curCfg.date.monthNames;
387
420
  p[1] = names[(p[1] * 1) - 1];
388
421
  if(options && options.splitInput){
389
422
  val = [p[0] || '', p[1] || ''];
@@ -704,7 +737,15 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
704
737
  })
705
738
  .on({
706
739
  'change input focus focusin blur focusout': function(e){
740
+ var oVal, nVal;
707
741
  $(e.target).trigger('ws__'+e.type);
742
+ if(o.toFixed && o.type == 'number' && e.type == 'change'){
743
+ oVal = that.element.prop('value');
744
+ nVal = that.toFixed(oVal, true);
745
+ if(oVal != nVal){
746
+ that.element[0].value = nVal;
747
+ }
748
+ }
708
749
  }
709
750
  })
710
751
 
@@ -853,11 +894,14 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
853
894
  this.inputElements.attr('inputmode', 'numeric');
854
895
  }
855
896
 
856
-
857
-
858
897
  if((!o.max && typeof o.relMax == 'number') || (!o.min && typeof o.relMin == 'number')){
859
- webshims.error('relMax/relMin are not supported anymore')
898
+ webshims.error('relMax/relMin are not supported anymore calculate at set it your own.');
860
899
  }
900
+
901
+ if(this.options.relDefaultValue){
902
+ webshims.warn('relDefaultValue was removed use startValue instead!');
903
+ }
904
+
861
905
  this._init = true;
862
906
  },
863
907
  createOpts: ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'defaultValue', 'value', 'required'],
@@ -868,17 +912,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
868
912
  this.inputElements = $(create.elements).prependTo(this.element).filter('input, select');
869
913
  }
870
914
  },
871
-
872
- getRelNumber: function(rel){
873
- var start = steps[this.type].start || 0;
874
- if(rel){
875
- start += rel;
876
- }
877
- return start;
878
- },
879
915
  addZero: addZero,
880
916
  _setStartInRange: function(){
881
- var start = this.getRelNumber(this.options.relDefaultValue);
917
+ var start = this.options.startValue && this.asNumber( this.options.startValue ) || steps[this.type].start || 0;
882
918
  if(!isNaN(this.minAsNumber) && start < this.minAsNumber){
883
919
  start = this.minAsNumber;
884
920
  } else if(!isNaN(this.maxAsNumber) && start > this.maxAsNumber){
@@ -890,7 +926,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
890
926
  },
891
927
  reorderInputs: function(){
892
928
  if(splitInputs[this.type]){
893
- var element = this.element;
929
+ var element = this.element.attr('dir', curCfg.date.isRTL ? 'rtl' : 'ltr');
894
930
  splitInputs[this.type].sort(element, this.options);
895
931
  setTimeout(function(){
896
932
  var data = webshims.data(element);
@@ -916,6 +952,13 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
916
952
  this.elemHelper.prop('value', val);
917
953
  this.options.defValue = "";
918
954
  }
955
+ },
956
+ toFixed: function(val, force){
957
+ var o = this.options;
958
+ if(o.toFixed && o.type == 'number' && val && this.valueAsNumber && (force || !this.element.is(':focus')) && (!o.fixOnlyFloat || (this.valueAsNumber % 1)) && !$(this.orig).is(':invalid')){
959
+ val = formatVal[this.type](this.valueAsNumber.toFixed(o.toFixed), this.options);
960
+ }
961
+ return val;
919
962
  }
920
963
  });
921
964
 
@@ -928,7 +971,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
928
971
  } else {
929
972
  this.elemHelper.prop(name, val);
930
973
  }
931
-
974
+
932
975
  val = formatVal[this.type](val, this.options);
933
976
  if(this.options.splitInput){
934
977
  $.each(this.splits, function(i, elem){
@@ -940,7 +983,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
940
983
  }
941
984
  });
942
985
  } else {
943
- this.element.prop(name, val);
986
+ this.element.prop(name, this.toFixed(val));
944
987
  }
945
988
  this._propertyChange(name);
946
989
  this.mirrorValidity();
@@ -957,6 +1000,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
957
1000
  this._setStartInRange();
958
1001
  }
959
1002
  this.options[name] = val;
1003
+ if(this._init){
1004
+ createYearSelect({elements: this.inputElements}, this.options);
1005
+ }
960
1006
  this._propertyChange(name);
961
1007
  this.mirrorValidity();
962
1008
  };
@@ -977,7 +1023,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
977
1023
 
978
1024
  $.fn.spinbtnUI = function(opts){
979
1025
  opts = $.extend({
980
- monthNames: 'monthNames'
1026
+ monthNames: 'monthNamesShort'
981
1027
  }, opts);
982
1028
  return this.each(function(){
983
1029
  $.webshims.objectCreate(spinBtnProto, {
@@ -1007,6 +1053,53 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1007
1053
  isVisible: true
1008
1054
  };
1009
1055
 
1056
+ picker.isInRange = function(value, max, min){
1057
+ return !((min[0] && min[0] > value[0]) || (max[0] && max[0] < value[0]));
1058
+ };
1059
+
1060
+
1061
+ picker.createYearSelect = function(value, max, min, valueAdd, stepper){
1062
+ if(!stepper){
1063
+ stepper = {start: value, step: 1, label: value};
1064
+ }
1065
+ var temp;
1066
+ var goUp = true;
1067
+ var goDown = true;
1068
+ var options = ['<option selected="">'+ stepper.label + '</option>'];
1069
+ var i = 0;
1070
+ var createOption = function(value, add){
1071
+ var value2, label;
1072
+ if(stepper.step > 1){
1073
+ value2 = value + stepper.step - 1;
1074
+ label = value+' – '+value2;
1075
+ } else {
1076
+ label = value;
1077
+ }
1078
+
1079
+ if(picker.isInRange([value], max, min) || (value2 && picker.isInRange([value2], max, min))){
1080
+ options[add]('<option value="'+ (value+valueAdd) +'">'+ label +'</option>');
1081
+ return true;
1082
+ }
1083
+ };
1084
+ if(!valueAdd){
1085
+ valueAdd = '';
1086
+ }
1087
+ while(i < 18 && (goUp || goDown)){
1088
+ i++;
1089
+ if(goUp){
1090
+ temp = stepper.start - (i * stepper.step);
1091
+ goUp = createOption(temp, 'unshift');
1092
+ }
1093
+ if(goDown){
1094
+ temp = stepper.start + (i * stepper.step);
1095
+ goDown = createOption(temp, 'push');
1096
+ }
1097
+
1098
+ }
1099
+
1100
+ return options;
1101
+ };
1102
+
1010
1103
  picker._genericSetFocus = function(element, _noFocus){
1011
1104
  element = $(element || this.activeButton);
1012
1105
 
@@ -1016,12 +1109,12 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1016
1109
  clearTimeout(that.timer);
1017
1110
  that.timer = setTimeout(function(){
1018
1111
  if(element[0]){
1019
- element[0].focus();
1112
+ element.trigger('focus');
1020
1113
  if(noTrigger !== true && !element.is(':focus')){
1021
1114
  setFocus(true);
1022
1115
  }
1023
1116
  }
1024
- }, that.popover.isVisible ? 99 : 360);
1117
+ }, that.popover.isVisible ? 0 : 360);
1025
1118
  };
1026
1119
  this.popover.activateElement(element);
1027
1120
  setFocus();
@@ -1234,7 +1327,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1234
1327
  popover.preventBlur();
1235
1328
  }
1236
1329
  },
1237
- mousedown: function(){
1330
+ mousedown: function(e){
1238
1331
  mouseFocus = true;
1239
1332
  setTimeout(resetMouseFocus, 9);
1240
1333
  if(options.buttonOnly && popover.isVisible && popover.activeElement){
@@ -1392,31 +1485,41 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1392
1485
  var updateStyles = function(){
1393
1486
  $(data.orig).removeClass('ws-important-hide');
1394
1487
  $.style( data.orig, 'display', '' );
1395
- var hasButtons, marginR, marginL;
1488
+ var hasButtons, marginR, marginL, left, right, isRtl;
1396
1489
  var correctWidth = 0.8;
1397
1490
  if(!init || data.orig.offsetWidth){
1398
1491
  hasButtons = data.buttonWrapper && data.buttonWrapper.filter(isVisible).length;
1399
- marginR = $.css( data.orig, 'marginRight');
1400
- data.element.css({
1401
- marginLeft: $.css( data.orig, 'marginLeft'),
1402
- marginRight: hasButtons ? 0 : marginR
1403
- });
1492
+
1493
+ isRtl = hasButtons && data.buttonWrapper.css('direction') == 'rtl';
1494
+ if(isRtl){
1495
+ left = 'Right';
1496
+ right = 'Left';
1497
+ } else {
1498
+ left = 'Left';
1499
+ right = 'Right';
1500
+ }
1501
+
1502
+ marginR = $.css( data.orig, 'margin'+right);
1503
+
1504
+ data.element
1505
+ .css('margin'+left, $.css( data.orig, 'margin'+left))
1506
+ .css('margin'+right, hasButtons ? 0 : marginR)
1507
+ ;
1404
1508
 
1405
1509
  if(hasButtons){
1406
- marginL = (parseInt(data.buttonWrapper.css('marginLeft'), 10) || 0);
1407
- data.element.css({paddingRight: ''});
1510
+ data.buttonWrapper[isRtl ? 'addClass' : 'removeClass']('ws-is-rtl');
1511
+ marginL = (parseInt(data.buttonWrapper.css('margin'+left), 10) || 0);
1512
+ data.element.css('padding'+right, '');
1408
1513
 
1409
1514
  if(marginL < 0){
1410
1515
  marginR = (parseInt(marginR, 10) || 0) + ((data.buttonWrapper.outerWidth() + marginL) * -1);
1411
- data.buttonWrapper.css('marginRight', marginR);
1516
+ data.buttonWrapper.css('margin'+right, marginR);
1412
1517
  data.element
1413
- .css({paddingRight: ''})
1414
- .css({
1415
- paddingRight: (parseInt( data.element.css('paddingRight'), 10) || 0) + data.buttonWrapper.outerWidth()
1416
- })
1518
+ .css('padding'+right, '')
1519
+ .css('padding'+right, (parseInt( data.element.css('padding'+right), 10) || 0) + data.buttonWrapper.outerWidth())
1417
1520
  ;
1418
1521
  } else {
1419
- data.buttonWrapper.css('marginRight', marginR);
1522
+ data.buttonWrapper.css('margin'+right, marginR);
1420
1523
  correctWidth = data.buttonWrapper.outerWidth(true) + correctWidth;
1421
1524
  }
1422
1525
  }
@@ -1434,7 +1537,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1434
1537
 
1435
1538
  var type = $.prop(this, 'type');
1436
1539
 
1437
- var i, opts, data, optsName, labels;
1540
+ var i, opts, data, optsName, labels, cNames;
1438
1541
  if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
1439
1542
  data = {};
1440
1543
  optsName = type;
@@ -1472,17 +1575,38 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1472
1575
  opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
1473
1576
  }
1474
1577
  }
1475
-
1476
- if(opts.onlyMonthDigits || (!opts.formatMonthNames && opts.monthSelect)){
1477
- opts.formatMonthNames = 'monthDigits';
1578
+ if(opts.formatMonthNames){
1579
+ webshims.error('formatMonthNames was renamded to monthNames');
1580
+ }
1581
+ if(opts.onlyMonthDigits){
1582
+ opts.monthNames = 'monthDigits';
1478
1583
  }
1479
1584
  data.shim = inputTypes[type]._create(opts);
1480
-
1585
+
1481
1586
  webshims.addShadowDom(this, data.shim.element, {
1482
1587
  data: data.shim || {}
1483
1588
  });
1484
1589
 
1485
1590
  data.shim.options.containerElements.push(data.shim.element[0]);
1591
+ cNames = $.prop(this, 'className');
1592
+ if(opts.classes){
1593
+ cNames += ' '+opts.classes;
1594
+ }
1595
+
1596
+ if(opts.splitInput || type == 'range'){
1597
+ cNames = cNames.replace('form-control', '');
1598
+ }
1599
+
1600
+ data.shim.element.on('change input', stopPropagation).addClass(cNames);
1601
+
1602
+ if(data.shim.buttonWrapper){
1603
+
1604
+ data.shim.buttonWrapper.addClass('input-button-size-'+(data.shim.buttonWrapper.children().filter(isVisible).length));
1605
+
1606
+ if(data.shim.buttonWrapper.filter(isVisible).length){
1607
+ data.shim.element.addClass('has-input-buttons');
1608
+ }
1609
+ }
1486
1610
 
1487
1611
  labelWidth($(this).getShadowFocusElement(), labels);
1488
1612
 
@@ -1514,14 +1638,13 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1514
1638
  $(opts.orig).trigger(hasFocus ? 'focusin' : 'focusout');
1515
1639
  }
1516
1640
  hasFocusTriggered = hasFocus;
1517
- }, 0);
1641
+ }, 9);
1518
1642
  }
1519
1643
  })
1520
1644
  ;
1521
1645
  })();
1522
-
1523
1646
 
1524
- data.shim.element.on('change input', stopPropagation);
1647
+
1525
1648
 
1526
1649
  if(hasFormValidation){
1527
1650
  $(opts.orig).on('firstinvalid', function(e){
@@ -1537,13 +1660,6 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1537
1660
  });
1538
1661
  }
1539
1662
 
1540
-
1541
- if(data.shim.buttonWrapper && data.shim.buttonWrapper.filter(isVisible).length){
1542
- data.shim.element.addClass('has-input-buttons');
1543
- }
1544
-
1545
- data.shim.element.addClass($.prop(this, 'className'));
1546
-
1547
1663
  if(opts.calculateWidth){
1548
1664
  sizeInput(data.shim);
1549
1665
  } else {
@@ -1605,7 +1721,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1605
1721
  if(!modernizrInputTypes[name] || replace[name]){
1606
1722
  extendType(name, {
1607
1723
  _create: function(opts, set){
1608
- if(opts.monthSelect || opts.daySelect){
1724
+ if(opts.monthSelect || opts.daySelect || opts.yearSelect){
1609
1725
  opts.splitInput = true;
1610
1726
  }
1611
1727
  if(opts.splitInput && !splitInputs[name]){
@@ -1624,7 +1740,6 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1624
1740
  if(webshims.picker && webshims.picker[name]){
1625
1741
  webshims.picker[name](data);
1626
1742
  }
1627
- data.buttonWrapper.addClass('input-button-size-'+(data.buttonWrapper.children().filter(isVisible).length));
1628
1743
  return data;
1629
1744
  }
1630
1745
  });