webshims-rails 1.12.7 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/polyfiller.js +12 -1
  4. data/vendor/assets/javascripts/webshims/shims/combos/1.js +4 -1
  5. data/vendor/assets/javascripts/webshims/shims/combos/10.js +7 -4
  6. data/vendor/assets/javascripts/webshims/shims/combos/11.js +7 -4
  7. data/vendor/assets/javascripts/webshims/shims/combos/14.js +23 -10
  8. data/vendor/assets/javascripts/webshims/shims/combos/15.js +7 -2
  9. data/vendor/assets/javascripts/webshims/shims/combos/16.js +7 -2
  10. data/vendor/assets/javascripts/webshims/shims/combos/17.js +28 -13
  11. data/vendor/assets/javascripts/webshims/shims/combos/18.js +28 -13
  12. data/vendor/assets/javascripts/webshims/shims/combos/19.js +5 -4
  13. data/vendor/assets/javascripts/webshims/shims/combos/2.js +4 -1
  14. data/vendor/assets/javascripts/webshims/shims/combos/20.js +5 -4
  15. data/vendor/assets/javascripts/webshims/shims/combos/21.js +5 -4
  16. data/vendor/assets/javascripts/webshims/shims/combos/25.js +5 -4
  17. data/vendor/assets/javascripts/webshims/shims/combos/28.js +24 -10
  18. data/vendor/assets/javascripts/webshims/shims/combos/29.js +20 -9
  19. data/vendor/assets/javascripts/webshims/shims/combos/3.js +7 -2
  20. data/vendor/assets/javascripts/webshims/shims/combos/30.js +7 -2
  21. data/vendor/assets/javascripts/webshims/shims/combos/31.js +4 -1
  22. data/vendor/assets/javascripts/webshims/shims/combos/32.js +21 -9
  23. data/vendor/assets/javascripts/webshims/shims/combos/33.js +21 -9
  24. data/vendor/assets/javascripts/webshims/shims/combos/4.js +3 -1
  25. data/vendor/assets/javascripts/webshims/shims/combos/5.js +28 -13
  26. data/vendor/assets/javascripts/webshims/shims/combos/6.js +28 -13
  27. data/vendor/assets/javascripts/webshims/shims/combos/7.js +7 -2
  28. data/vendor/assets/javascripts/webshims/shims/combos/8.js +7 -2
  29. data/vendor/assets/javascripts/webshims/shims/combos/9.js +7 -4
  30. data/vendor/assets/javascripts/webshims/shims/form-core.js +4 -1
  31. data/vendor/assets/javascripts/webshims/shims/form-message.js +3 -1
  32. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +20 -9
  33. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +7 -4
  34. data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +7 -1
  35. data/vendor/assets/javascripts/webshims/shims/form-validation.js +4 -4
  36. data/vendor/assets/javascripts/webshims/shims/form-validators.js +6 -3
  37. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +16 -13
  38. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +5 -4
  39. data/vendor/assets/javascripts/webshims/shims/picture.js +570 -0
  40. data/vendor/assets/javascripts/webshims/shims/promise.js +684 -0
  41. data/vendor/assets/javascripts/webshims/shims/styles/color-picker.png +0 -0
  42. data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +90 -38
  43. data/vendor/assets/javascripts/webshims/shims/styles/shim-ext.css +1039 -0
  44. data/vendor/assets/javascripts/webshims/shims/styles/widget.eot +0 -0
  45. data/vendor/assets/javascripts/webshims/shims/styles/widget.svg +12 -0
  46. data/vendor/assets/javascripts/webshims/shims/styles/widget.ttf +0 -0
  47. data/vendor/assets/javascripts/webshims/shims/styles/widget.woff +0 -0
  48. metadata +10 -10
  49. data/vendor/assets/javascripts/webshims/shims/styles/forms.png +0 -0
  50. data/vendor/assets/javascripts/webshims/shims/styles/scss/_api-forms-ext.scss +0 -219
  51. data/vendor/assets/javascripts/webshims/shims/styles/scss/_api-shim.scss +0 -115
  52. data/vendor/assets/javascripts/webshims/shims/styles/scss/_extends.scss +0 -31
  53. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +0 -479
  54. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-picker.scss +0 -488
  55. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim-ext.scss +0 -2
  56. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +0 -633
@@ -1434,7 +1434,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1434
1434
  }
1435
1435
  if(!message){
1436
1436
  message = getMessageFromObj(validityMessages[''][name], elem) || $.prop(elem, 'validationMessage');
1437
- webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+webshims.activeLang());
1437
+ if(name != 'customError'){
1438
+ webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+webshims.activeLang());
1439
+ }
1438
1440
  }
1439
1441
  message = webshims.replaceValidationplaceholder(elem, message, name);
1440
1442
 
@@ -409,7 +409,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
409
409
  var stepDescriptor = webshims.defineNodeNameProperty('input', name, {
410
410
  prop: {
411
411
  value: function(factor){
412
- var step, val, dateVal, valModStep, alignValue, cache, base, attrVal;
412
+ var step, val, valModStep, alignValue, cache, base, attrVal;
413
413
  var type = getType(this);
414
414
  if(typeModels[type] && typeModels[type].asNumber){
415
415
  cache = {type: type};
@@ -419,12 +419,9 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
419
419
  }
420
420
  factor *= stepFactor;
421
421
 
422
- val = $.prop(this, 'valueAsNumber');
422
+
423
423
 
424
- if(isNaN(val)){
425
- webshims.info("valueAsNumber is NaN can't apply stepUp/stepDown ");
426
- throw('invalid state error');
427
- }
424
+
428
425
 
429
426
  step = webshims.getStep(this, type);
430
427
 
@@ -435,7 +432,21 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
435
432
 
436
433
  webshims.addMinMaxNumberToCache('min', $(this), cache);
437
434
  webshims.addMinMaxNumberToCache('max', $(this), cache);
438
-
435
+
436
+ val = $.prop(this, 'valueAsNumber');
437
+
438
+ if(factor > 0 && !isNaN(cache.minAsNumber) && (isNaN(val) || cache.minAsNumber > val)){
439
+ $.prop(this, 'valueAsNumber', cache.minAsNumber);
440
+ return;
441
+ } else if(factor < 0 && !isNaN(cache.maxAsNumber) && (isNaN(val) || cache.maxAsNumber < val)){
442
+ $.prop(this, 'valueAsNumber', cache.maxAsNumber);
443
+ return;
444
+ }
445
+
446
+ if(isNaN(val)){
447
+ val = 0;
448
+ }
449
+
439
450
  base = cache.minAsNumber;
440
451
 
441
452
  if(isNaN(base) && (attrVal = $.prop(this, 'defaultValue'))){
@@ -460,7 +471,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
460
471
 
461
472
  if( (!isNaN(cache.maxAsNumber) && val > cache.maxAsNumber) || (!isNaN(cache.minAsNumber) && val < cache.minAsNumber) ){
462
473
  webshims.info("max/min overflow can't apply stepUp/stepDown");
463
- throw('invalid state error');
474
+ return;
464
475
  }
465
476
 
466
477
  $.prop(this, 'valueAsNumber', val);
@@ -814,7 +825,8 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
814
825
  });
815
826
  }
816
827
 
817
- });;(function($){
828
+ });
829
+ ;(function($){
818
830
  "use strict";
819
831
 
820
832
  var isNumber = function(string){
@@ -2394,7 +2406,6 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
2394
2406
  }
2395
2407
  this.elemHelper.prop('valueAsNumber', start);
2396
2408
  this.options.defValue = this.elemHelper.prop('value');
2397
-
2398
2409
  },
2399
2410
  reorderInputs: function(){
2400
2411
  if(splitInputs[this.type]){
@@ -2461,7 +2472,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
2461
2472
  selectionEnd = this._getSelectionEnd(val);
2462
2473
  }
2463
2474
  this.element.prop(name, val);
2464
- if(selectionEnd){
2475
+ if(selectionEnd != null){
2465
2476
  this.element.prop('selectionEnd', selectionEnd);
2466
2477
  }
2467
2478
  }
@@ -2476,6 +2487,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
2476
2487
  spinBtnProto[name] = function(val){
2477
2488
  this.elemHelper.prop(name, val);
2478
2489
  this[numName] = this.asNumber(val);
2490
+
2479
2491
  if(this.valueAsNumber != null && (isNaN(this.valueAsNumber) || (!isNaN(this[numName]) && (this.valueAsNumber * factor) < (this[numName] * factor)))){
2480
2492
  this._setStartInRange();
2481
2493
  }
@@ -3112,11 +3124,11 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
3112
3124
 
3113
3125
  var type = $.prop(this, 'type');
3114
3126
 
3115
- var i, opts, data, optsName, labels, cNames;
3127
+ var i, opts, data, optsName, labels, cNames, hasInitialFocus;
3116
3128
  if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
3117
3129
  data = {};
3118
3130
  optsName = type;
3119
-
3131
+ hasInitialFocus = $(this).is(':focus');
3120
3132
  labels = $(this).jProp('labels');
3121
3133
  opts = $.extend(webshims.getOptions(this, type, [options.widgets, options[type], $($.prop(this, 'form')).data(type)]), {
3122
3134
  orig: this,
@@ -3241,6 +3253,9 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
3241
3253
  } else {
3242
3254
  $(this).css('display', 'none');
3243
3255
  }
3256
+ if(hasInitialFocus){
3257
+ $(this).getShadowFocusElement().trigger('focus');
3258
+ }
3244
3259
  }
3245
3260
 
3246
3261
  };
@@ -409,7 +409,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
409
409
  var stepDescriptor = webshims.defineNodeNameProperty('input', name, {
410
410
  prop: {
411
411
  value: function(factor){
412
- var step, val, dateVal, valModStep, alignValue, cache, base, attrVal;
412
+ var step, val, valModStep, alignValue, cache, base, attrVal;
413
413
  var type = getType(this);
414
414
  if(typeModels[type] && typeModels[type].asNumber){
415
415
  cache = {type: type};
@@ -419,12 +419,9 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
419
419
  }
420
420
  factor *= stepFactor;
421
421
 
422
- val = $.prop(this, 'valueAsNumber');
422
+
423
423
 
424
- if(isNaN(val)){
425
- webshims.info("valueAsNumber is NaN can't apply stepUp/stepDown ");
426
- throw('invalid state error');
427
- }
424
+
428
425
 
429
426
  step = webshims.getStep(this, type);
430
427
 
@@ -435,7 +432,21 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
435
432
 
436
433
  webshims.addMinMaxNumberToCache('min', $(this), cache);
437
434
  webshims.addMinMaxNumberToCache('max', $(this), cache);
438
-
435
+
436
+ val = $.prop(this, 'valueAsNumber');
437
+
438
+ if(factor > 0 && !isNaN(cache.minAsNumber) && (isNaN(val) || cache.minAsNumber > val)){
439
+ $.prop(this, 'valueAsNumber', cache.minAsNumber);
440
+ return;
441
+ } else if(factor < 0 && !isNaN(cache.maxAsNumber) && (isNaN(val) || cache.maxAsNumber < val)){
442
+ $.prop(this, 'valueAsNumber', cache.maxAsNumber);
443
+ return;
444
+ }
445
+
446
+ if(isNaN(val)){
447
+ val = 0;
448
+ }
449
+
439
450
  base = cache.minAsNumber;
440
451
 
441
452
  if(isNaN(base) && (attrVal = $.prop(this, 'defaultValue'))){
@@ -460,7 +471,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
460
471
 
461
472
  if( (!isNaN(cache.maxAsNumber) && val > cache.maxAsNumber) || (!isNaN(cache.minAsNumber) && val < cache.minAsNumber) ){
462
473
  webshims.info("max/min overflow can't apply stepUp/stepDown");
463
- throw('invalid state error');
474
+ return;
464
475
  }
465
476
 
466
477
  $.prop(this, 'valueAsNumber', val);
@@ -814,7 +825,8 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
814
825
  });
815
826
  }
816
827
 
817
- });;(function($){
828
+ });
829
+ ;(function($){
818
830
  "use strict";
819
831
 
820
832
  var isNumber = function(string){
@@ -2394,7 +2406,6 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
2394
2406
  }
2395
2407
  this.elemHelper.prop('valueAsNumber', start);
2396
2408
  this.options.defValue = this.elemHelper.prop('value');
2397
-
2398
2409
  },
2399
2410
  reorderInputs: function(){
2400
2411
  if(splitInputs[this.type]){
@@ -2461,7 +2472,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
2461
2472
  selectionEnd = this._getSelectionEnd(val);
2462
2473
  }
2463
2474
  this.element.prop(name, val);
2464
- if(selectionEnd){
2475
+ if(selectionEnd != null){
2465
2476
  this.element.prop('selectionEnd', selectionEnd);
2466
2477
  }
2467
2478
  }
@@ -2476,6 +2487,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
2476
2487
  spinBtnProto[name] = function(val){
2477
2488
  this.elemHelper.prop(name, val);
2478
2489
  this[numName] = this.asNumber(val);
2490
+
2479
2491
  if(this.valueAsNumber != null && (isNaN(this.valueAsNumber) || (!isNaN(this[numName]) && (this.valueAsNumber * factor) < (this[numName] * factor)))){
2480
2492
  this._setStartInRange();
2481
2493
  }
@@ -3112,11 +3124,11 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
3112
3124
 
3113
3125
  var type = $.prop(this, 'type');
3114
3126
 
3115
- var i, opts, data, optsName, labels, cNames;
3127
+ var i, opts, data, optsName, labels, cNames, hasInitialFocus;
3116
3128
  if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
3117
3129
  data = {};
3118
3130
  optsName = type;
3119
-
3131
+ hasInitialFocus = $(this).is(':focus');
3120
3132
  labels = $(this).jProp('labels');
3121
3133
  opts = $.extend(webshims.getOptions(this, type, [options.widgets, options[type], $($.prop(this, 'form')).data(type)]), {
3122
3134
  orig: this,
@@ -3241,6 +3253,9 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
3241
3253
  } else {
3242
3254
  $(this).css('display', 'none');
3243
3255
  }
3256
+ if(hasInitialFocus){
3257
+ $(this).getShadowFocusElement().trigger('focus');
3258
+ }
3244
3259
  }
3245
3260
 
3246
3261
  };
@@ -1622,6 +1622,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1622
1622
 
1623
1623
 
1624
1624
  webshims.getContentValidationMessage = function(elem, validity, key){
1625
+ var customRule;
1625
1626
  if(webshims.errorbox && webshims.errorbox.initIvalContentMessage){
1626
1627
  webshims.errorbox.initIvalContentMessage(elem);
1627
1628
  }
@@ -1636,7 +1637,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1636
1637
  }
1637
1638
  if(typeof message == 'object'){
1638
1639
  validity = validity || $.prop(elem, 'validity') || {valid: 1};
1639
- if(!validity.valid){
1640
+ if(validity.customError && (customRule = $.data(elem, 'customMismatchedRule')) && message[customRule] && typeof message[customRule] == 'string'){
1641
+ message = message[customRule];
1642
+ } else if(!validity.valid){
1640
1643
  $.each(validity, function(name, prop){
1641
1644
  if(prop && name != 'valid' && message[name]){
1642
1645
  message = message[name];
@@ -1938,7 +1941,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1938
1941
  }
1939
1942
  if(!message){
1940
1943
  message = getMessageFromObj(validityMessages[''][name], elem) || $.prop(elem, 'validationMessage');
1941
- webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+webshims.activeLang());
1944
+ if(name != 'customError'){
1945
+ webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+webshims.activeLang());
1946
+ }
1942
1947
  }
1943
1948
  message = webshims.replaceValidationplaceholder(elem, message, name);
1944
1949
 
@@ -1622,6 +1622,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1622
1622
 
1623
1623
 
1624
1624
  webshims.getContentValidationMessage = function(elem, validity, key){
1625
+ var customRule;
1625
1626
  if(webshims.errorbox && webshims.errorbox.initIvalContentMessage){
1626
1627
  webshims.errorbox.initIvalContentMessage(elem);
1627
1628
  }
@@ -1636,7 +1637,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1636
1637
  }
1637
1638
  if(typeof message == 'object'){
1638
1639
  validity = validity || $.prop(elem, 'validity') || {valid: 1};
1639
- if(!validity.valid){
1640
+ if(validity.customError && (customRule = $.data(elem, 'customMismatchedRule')) && message[customRule] && typeof message[customRule] == 'string'){
1641
+ message = message[customRule];
1642
+ } else if(!validity.valid){
1640
1643
  $.each(validity, function(name, prop){
1641
1644
  if(prop && name != 'valid' && message[name]){
1642
1645
  message = message[name];
@@ -1938,7 +1941,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1938
1941
  }
1939
1942
  if(!message){
1940
1943
  message = getMessageFromObj(validityMessages[''][name], elem) || $.prop(elem, 'validationMessage');
1941
- webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+webshims.activeLang());
1944
+ if(name != 'customError'){
1945
+ webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+webshims.activeLang());
1946
+ }
1942
1947
  }
1943
1948
  message = webshims.replaceValidationplaceholder(elem, message, name);
1944
1949
 
@@ -2769,7 +2769,6 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2769
2769
  }
2770
2770
  this.elemHelper.prop('valueAsNumber', start);
2771
2771
  this.options.defValue = this.elemHelper.prop('value');
2772
-
2773
2772
  },
2774
2773
  reorderInputs: function(){
2775
2774
  if(splitInputs[this.type]){
@@ -2836,7 +2835,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2836
2835
  selectionEnd = this._getSelectionEnd(val);
2837
2836
  }
2838
2837
  this.element.prop(name, val);
2839
- if(selectionEnd){
2838
+ if(selectionEnd != null){
2840
2839
  this.element.prop('selectionEnd', selectionEnd);
2841
2840
  }
2842
2841
  }
@@ -2851,6 +2850,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2851
2850
  spinBtnProto[name] = function(val){
2852
2851
  this.elemHelper.prop(name, val);
2853
2852
  this[numName] = this.asNumber(val);
2853
+
2854
2854
  if(this.valueAsNumber != null && (isNaN(this.valueAsNumber) || (!isNaN(this[numName]) && (this.valueAsNumber * factor) < (this[numName] * factor)))){
2855
2855
  this._setStartInRange();
2856
2856
  }
@@ -3487,11 +3487,11 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3487
3487
 
3488
3488
  var type = $.prop(this, 'type');
3489
3489
 
3490
- var i, opts, data, optsName, labels, cNames;
3490
+ var i, opts, data, optsName, labels, cNames, hasInitialFocus;
3491
3491
  if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
3492
3492
  data = {};
3493
3493
  optsName = type;
3494
-
3494
+ hasInitialFocus = $(this).is(':focus');
3495
3495
  labels = $(this).jProp('labels');
3496
3496
  opts = $.extend(webshims.getOptions(this, type, [options.widgets, options[type], $($.prop(this, 'form')).data(type)]), {
3497
3497
  orig: this,
@@ -3616,6 +3616,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3616
3616
  } else {
3617
3617
  $(this).css('display', 'none');
3618
3618
  }
3619
+ if(hasInitialFocus){
3620
+ $(this).getShadowFocusElement().trigger('focus');
3621
+ }
3619
3622
  }
3620
3623
 
3621
3624
  };
@@ -208,6 +208,7 @@ webshims.register('form-core', function($, webshims, window, document, undefined
208
208
 
209
209
 
210
210
  webshims.getContentValidationMessage = function(elem, validity, key){
211
+ var customRule;
211
212
  if(webshims.errorbox && webshims.errorbox.initIvalContentMessage){
212
213
  webshims.errorbox.initIvalContentMessage(elem);
213
214
  }
@@ -222,7 +223,9 @@ webshims.register('form-core', function($, webshims, window, document, undefined
222
223
  }
223
224
  if(typeof message == 'object'){
224
225
  validity = validity || $.prop(elem, 'validity') || {valid: 1};
225
- if(!validity.valid){
226
+ if(validity.customError && (customRule = $.data(elem, 'customMismatchedRule')) && message[customRule] && typeof message[customRule] == 'string'){
227
+ message = message[customRule];
228
+ } else if(!validity.valid){
226
229
  $.each(validity, function(name, prop){
227
230
  if(prop && name != 'valid' && message[name]){
228
231
  message = message[name];
@@ -243,7 +243,9 @@ webshims.register('form-message', function($, webshims, window, document, undefi
243
243
  }
244
244
  if(!message){
245
245
  message = getMessageFromObj(validityMessages[''][name], elem) || $.prop(elem, 'validationMessage');
246
- webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+webshims.activeLang());
246
+ if(name != 'customError'){
247
+ webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+webshims.activeLang());
248
+ }
247
249
  }
248
250
  message = webshims.replaceValidationplaceholder(elem, message, name);
249
251
 
@@ -198,7 +198,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
198
198
  var stepDescriptor = webshims.defineNodeNameProperty('input', name, {
199
199
  prop: {
200
200
  value: function(factor){
201
- var step, val, dateVal, valModStep, alignValue, cache, base, attrVal;
201
+ var step, val, valModStep, alignValue, cache, base, attrVal;
202
202
  var type = getType(this);
203
203
  if(typeModels[type] && typeModels[type].asNumber){
204
204
  cache = {type: type};
@@ -208,12 +208,9 @@ webshims.register('form-number-date-api', function($, webshims, window, document
208
208
  }
209
209
  factor *= stepFactor;
210
210
 
211
- val = $.prop(this, 'valueAsNumber');
211
+
212
212
 
213
- if(isNaN(val)){
214
- webshims.info("valueAsNumber is NaN can't apply stepUp/stepDown ");
215
- throw('invalid state error');
216
- }
213
+
217
214
 
218
215
  step = webshims.getStep(this, type);
219
216
 
@@ -224,7 +221,21 @@ webshims.register('form-number-date-api', function($, webshims, window, document
224
221
 
225
222
  webshims.addMinMaxNumberToCache('min', $(this), cache);
226
223
  webshims.addMinMaxNumberToCache('max', $(this), cache);
227
-
224
+
225
+ val = $.prop(this, 'valueAsNumber');
226
+
227
+ if(factor > 0 && !isNaN(cache.minAsNumber) && (isNaN(val) || cache.minAsNumber > val)){
228
+ $.prop(this, 'valueAsNumber', cache.minAsNumber);
229
+ return;
230
+ } else if(factor < 0 && !isNaN(cache.maxAsNumber) && (isNaN(val) || cache.maxAsNumber < val)){
231
+ $.prop(this, 'valueAsNumber', cache.maxAsNumber);
232
+ return;
233
+ }
234
+
235
+ if(isNaN(val)){
236
+ val = 0;
237
+ }
238
+
228
239
  base = cache.minAsNumber;
229
240
 
230
241
  if(isNaN(base) && (attrVal = $.prop(this, 'defaultValue'))){
@@ -249,7 +260,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
249
260
 
250
261
  if( (!isNaN(cache.maxAsNumber) && val > cache.maxAsNumber) || (!isNaN(cache.minAsNumber) && val < cache.minAsNumber) ){
251
262
  webshims.info("max/min overflow can't apply stepUp/stepDown");
252
- throw('invalid state error');
263
+ return;
253
264
  }
254
265
 
255
266
  $.prop(this, 'valueAsNumber', val);
@@ -603,4 +614,4 @@ webshims.register('form-number-date-api', function($, webshims, window, document
603
614
  });
604
615
  }
605
616
 
606
- });
617
+ });
@@ -964,7 +964,6 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
964
964
  }
965
965
  this.elemHelper.prop('valueAsNumber', start);
966
966
  this.options.defValue = this.elemHelper.prop('value');
967
-
968
967
  },
969
968
  reorderInputs: function(){
970
969
  if(splitInputs[this.type]){
@@ -1031,7 +1030,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1031
1030
  selectionEnd = this._getSelectionEnd(val);
1032
1031
  }
1033
1032
  this.element.prop(name, val);
1034
- if(selectionEnd){
1033
+ if(selectionEnd != null){
1035
1034
  this.element.prop('selectionEnd', selectionEnd);
1036
1035
  }
1037
1036
  }
@@ -1046,6 +1045,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1046
1045
  spinBtnProto[name] = function(val){
1047
1046
  this.elemHelper.prop(name, val);
1048
1047
  this[numName] = this.asNumber(val);
1048
+
1049
1049
  if(this.valueAsNumber != null && (isNaN(this.valueAsNumber) || (!isNaN(this[numName]) && (this.valueAsNumber * factor) < (this[numName] * factor)))){
1050
1050
  this._setStartInRange();
1051
1051
  }
@@ -1682,11 +1682,11 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1682
1682
 
1683
1683
  var type = $.prop(this, 'type');
1684
1684
 
1685
- var i, opts, data, optsName, labels, cNames;
1685
+ var i, opts, data, optsName, labels, cNames, hasInitialFocus;
1686
1686
  if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
1687
1687
  data = {};
1688
1688
  optsName = type;
1689
-
1689
+ hasInitialFocus = $(this).is(':focus');
1690
1690
  labels = $(this).jProp('labels');
1691
1691
  opts = $.extend(webshims.getOptions(this, type, [options.widgets, options[type], $($.prop(this, 'form')).data(type)]), {
1692
1692
  orig: this,
@@ -1811,6 +1811,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1811
1811
  } else {
1812
1812
  $(this).css('display', 'none');
1813
1813
  }
1814
+ if(hasInitialFocus){
1815
+ $(this).getShadowFocusElement().trigger('focus');
1816
+ }
1814
1817
  }
1815
1818
 
1816
1819
  };