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
@@ -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,7 +1141,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1139
1141
  }
1140
1142
  });
1141
1143
 
1142
- })(webshims.$, document);;
1144
+ })();
1145
+ });
1146
+ ;
1143
1147
  webshims.register('form-core', function($, webshims, window, document, undefined, options){
1144
1148
  "use strict";
1145
1149
 
@@ -1617,6 +1621,9 @@ $.event.special.invalid = {
1617
1621
  var notValid = !($(e.target).callProp('reportValidity'));
1618
1622
  if(notValid){
1619
1623
  e.stopImmediatePropagation();
1624
+ if(!options.noFormInvalid){
1625
+ $(e.target).trigger('invalid');
1626
+ }
1620
1627
  return false;
1621
1628
  }
1622
1629
  }
@@ -2652,7 +2659,13 @@ webshims.defineNodeNamesProperties(['input', 'button'], formSubmitterDescriptors
2652
2659
  lazyLoad('WINDOWLOAD');
2653
2660
 
2654
2661
  if(webshims.isReady('form-datalist-lazy')){
2655
- this._lazyCreate(opts);
2662
+ if(window.QUnit){
2663
+ that._lazyCreate(opts);
2664
+ } else {
2665
+ setTimeout(function(){
2666
+ that._lazyCreate(opts);
2667
+ }, 9);
2668
+ }
2656
2669
  } else {
2657
2670
  $(opts.input).one('focus', lazyLoad);
2658
2671
  webshims.ready('form-datalist-lazy', function(){
@@ -1060,7 +1060,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1060
1060
  setTimeout(trigger, 0);
1061
1061
  }
1062
1062
 
1063
- }, (e.type == 'resize' && !window.requestAnimationFrame) ? 50 : 0);
1063
+ }, (e.type == 'resize' && !window.requestAnimationFrame) ? 50 : 9);
1064
1064
  };
1065
1065
  })(),
1066
1066
  _create: function(){
@@ -1085,7 +1085,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1085
1085
  setInterval(this.test, 600);
1086
1086
  $(this.test);
1087
1087
  webshims.ready('WINDOWLOAD', this.test);
1088
- $(document).on('updatelayout pageinit collapsibleexpand shown.bs.modal shown.bs.collapse slid.bs.carousel', this.handler);
1088
+ $(document).on('updatelayout.webshim pageinit popupafteropen panelbeforeopen tabsactivate collapsibleexpand shown.bs.modal shown.bs.collapse slid.bs.carousel', this.handler);
1089
1089
  $(window).on('resize', this.handler);
1090
1090
  (function(){
1091
1091
  var oldAnimate = $.fn.animate;
@@ -1532,10 +1532,10 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1532
1532
  });
1533
1533
 
1534
1534
  webshims.isReady('webshimLocalization', true);
1535
- });
1536
- //html5a11y
1537
- (function($, document){
1538
- if(!$.webshims.assumeARIA || ('content' in document.createElement('template'))){return;}
1535
+
1536
+ //html5a11y + hidden attribute
1537
+ (function(){
1538
+ if(('content' in document.createElement('template'))){return;}
1539
1539
 
1540
1540
  $(function(){
1541
1541
  var main = $('main').attr({role: 'main'});
@@ -1550,6 +1550,8 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1550
1550
  return;
1551
1551
  }
1552
1552
 
1553
+ webshims.defineNodeNamesBooleanProperty(['*'], 'hidden');
1554
+
1553
1555
  var elemMappings = {
1554
1556
  article: "article",
1555
1557
  aside: "complementary",
@@ -1590,7 +1592,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1590
1592
  }
1591
1593
  });
1592
1594
 
1593
- })(webshims.$, document);;
1595
+ })();
1596
+ });
1597
+ ;
1594
1598
  webshims.register('form-core', function($, webshims, window, document, undefined, options){
1595
1599
  "use strict";
1596
1600
 
@@ -2068,6 +2072,9 @@ $.event.special.invalid = {
2068
2072
  var notValid = !($(e.target).callProp('reportValidity'));
2069
2073
  if(notValid){
2070
2074
  e.stopImmediatePropagation();
2075
+ if(!options.noFormInvalid){
2076
+ $(e.target).trigger('invalid');
2077
+ }
2071
2078
  return false;
2072
2079
  }
2073
2080
  }
@@ -3103,7 +3110,13 @@ webshims.defineNodeNamesProperties(['input', 'button'], formSubmitterDescriptors
3103
3110
  lazyLoad('WINDOWLOAD');
3104
3111
 
3105
3112
  if(webshims.isReady('form-datalist-lazy')){
3106
- this._lazyCreate(opts);
3113
+ if(window.QUnit){
3114
+ that._lazyCreate(opts);
3115
+ } else {
3116
+ setTimeout(function(){
3117
+ that._lazyCreate(opts);
3118
+ }, 9);
3119
+ }
3107
3120
  } else {
3108
3121
  $(opts.input).one('focus', lazyLoad);
3109
3122
  webshims.ready('form-datalist-lazy', function(){
@@ -620,8 +620,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
620
620
  _create: function(){
621
621
  var i;
622
622
 
623
-
624
- this.element.addClass('ws-range').attr({role: 'slider'}).append('<span class="ws-range-min ws-range-progress" /><span class="ws-range-rail ws-range-track"><span class="ws-range-thumb" /></span>');
623
+ this.element.addClass('ws-range').attr({role: 'slider'}).append('<span class="ws-range-min ws-range-progress" /><span class="ws-range-rail ws-range-track"><span class="ws-range-thumb"><span data-value="" data-valuetext="" /></span></span>');
625
624
  this.trail = $('.ws-range-track', this.element);
626
625
  this.range = $('.ws-range-progress', this.element);
627
626
  this.thumb = $('.ws-range-thumb', this.trail);
@@ -643,7 +642,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
643
642
  },
644
643
  value: $.noop,
645
644
  _value: function(val, _noNormalize, animate){
646
- var left, posDif, textValue;
645
+ var left, posDif;
647
646
  var o = this.options;
648
647
  var oVal = val;
649
648
  var thumbStyle = {};
@@ -659,7 +658,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
659
658
  left = 100 * ((val - o.min) / (o.max - o.min));
660
659
 
661
660
  if(this._init && val == o.value && oVal == val){return;}
662
- this.options.value = val;
661
+ o.value = val;
663
662
 
664
663
  if($.fn.stop){
665
664
  this.thumb.stop();
@@ -667,6 +666,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
667
666
  }
668
667
 
669
668
  rangeStyle[this.dirs.width] = left+'%';
669
+
670
670
  if(this.vertical){
671
671
  left = Math.abs(left - 100);
672
672
  }
@@ -693,15 +693,26 @@ webshims.register('form-number-date-api', function($, webshims, window, document
693
693
  this.options._change(val);
694
694
  }
695
695
 
696
- textValue = this.options.textValue ? this.options.textValue(this.options.value) : this.options.options[this.options.value] || this.options.value;
696
+ this._setValueMarkup();
697
+ },
698
+ _setValueMarkup: function(){
699
+ var o = this.options;
700
+ var textValue = o.textValue ? o.textValue(this.options.value) : o.options[o.value] || o.value;
697
701
  this.element.attr({
698
702
  'aria-valuenow': this.options.value,
699
703
  'aria-valuetext': textValue
700
704
  });
701
- this.thumb.attr({
705
+ $('span', this.thumb).attr({
702
706
  'data-value': this.options.value,
703
707
  'data-valuetext': textValue
704
708
  });
709
+ if(o.selectedOption){
710
+ $(o.selectedOption).removeClass('ws-selected-option');
711
+ o.selectedOption = null;
712
+ }
713
+ if(o.value in o.options){
714
+ o.selectedOption = $('[data-value="'+o.value+'"].ws-range-ticks').addClass('ws-selected-option');
715
+ }
705
716
  },
706
717
  initDataList: function(){
707
718
  if(this.orig){
@@ -744,9 +755,9 @@ webshims.register('form-number-date-api', function($, webshims, window, document
744
755
  $.each(o.options, function(val, label){
745
756
  if(!isNumber(val) || val < min || val > max){return;}
746
757
  var left = 100 * ((val - min) / (max - min));
747
- var attr = '';
758
+ var attr = 'data-value="'+val+'"';
748
759
  if(label){
749
- attr += 'data-label="'+label+'"';
760
+ attr += ' data-label="'+label+'"';
750
761
  if(o.showLabels){
751
762
  attr += ' title="'+label+'"';
752
763
  }
@@ -759,6 +770,9 @@ webshims.register('form-number-date-api', function($, webshims, window, document
759
770
  $('<span class="ws-range-ticks"'+ attr +' style="'+(that.dirs.left)+': '+left+'%;" />').appendTo(trail)
760
771
  );
761
772
  });
773
+ if(o.value in o.options){
774
+ this._setValueMarkup();
775
+ }
762
776
  },
763
777
  readonly: function(val){
764
778
  val = !!val;
@@ -802,12 +816,13 @@ webshims.register('form-number-date-api', function($, webshims, window, document
802
816
  var step = val == 'any' ? 'any' : retDefault(val, 1);
803
817
 
804
818
  if(o.stepping){
805
- if(step != 'any' && o.stepping % step){
806
- webshims.error('wrong stepping value for type range:'+ (o.stepping % step));
807
- } else {
808
- step = o.stepping;
809
- }
819
+ webshims.error('stepping was removed. Use stepfactor instead.');
820
+ }
821
+
822
+ if(o.stepfactor && step != 'any'){
823
+ step *= o.stepfactor;
810
824
  }
825
+
811
826
  o.step = step;
812
827
  this.value(this.options.value);
813
828
  },
@@ -845,11 +860,11 @@ webshims.register('form-number-date-api', function($, webshims, window, document
845
860
  var val, valModStep, alignValue, step;
846
861
 
847
862
  if(pos <= 0){
848
- val = this.options[this.dirs.min];
863
+ val = this.options[this.dirs[this.isRtl ? 'max' : 'min']];
849
864
  } else if(pos > 100) {
850
- val = this.options[this.dirs.max];
865
+ val = this.options[this.dirs[this.isRtl ? 'min' : 'max']];
851
866
  } else {
852
- if(this.vertical){
867
+ if(this.vertical || this.isRtl){
853
868
  pos = Math.abs(pos - 100);
854
869
  }
855
870
  val = ((this.options.max - this.options.min) * (pos / 100)) + this.options.min;
@@ -934,17 +949,20 @@ webshims.register('form-number-date-api', function($, webshims, window, document
934
949
  return e;
935
950
  };
936
951
  })();
952
+ var updateValue = function(val, animate){
953
+ if(val != o.value){
954
+ that.value(val, false, animate);
955
+ eventTimer.call('input', val);
956
+ }
957
+ };
937
958
  var setValueFromPos = function(e, animate){
938
959
  if(e.type == 'touchmove'){
939
960
  e.preventDefault();
940
961
  normalizeTouch(e);
941
962
  }
942
963
 
943
- var val = that.getStepedValueFromPos((e[that.dirs.mouse] - leftOffset) * widgetUnits);
944
- if(val != o.value){
945
- that.value(val, false, animate);
946
- eventTimer.call('input', val);
947
- }
964
+ updateValue(that.getStepedValueFromPos((e[that.dirs.mouse] - leftOffset) * widgetUnits), animate);
965
+
948
966
  if(e && e.type == 'mousemove'){
949
967
  e.preventDefault();
950
968
  }
@@ -982,7 +1000,12 @@ webshims.register('form-number-date-api', function($, webshims, window, document
982
1000
  outerWidth = that.thumb[that.dirs.outerWidth]();
983
1001
  leftOffset = leftOffset[that.dirs.pos];
984
1002
  widgetUnits = 100 / widgetUnits;
985
- setValueFromPos(e, o.animate);
1003
+
1004
+ if(e.target.className == 'ws-range-ticks'){
1005
+ updateValue(e.target.getAttribute('data-value'), o.animate);
1006
+ } else {
1007
+ setValueFromPos(e, o.animate);
1008
+ }
986
1009
  isActive = true;
987
1010
  $(document)
988
1011
  .on(e.type == 'touchstart' ?
@@ -1028,6 +1051,13 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1028
1051
  var step = true;
1029
1052
  var code = e.keyCode;
1030
1053
  if(!o.readonly && !o.disabled){
1054
+ if(that.isRtl){
1055
+ if(code == 39){
1056
+ code = 37;
1057
+ } else if(code == 37){
1058
+ code = 39;
1059
+ }
1060
+ }
1031
1061
  if (code == 39 || code == 38) {
1032
1062
  that.doStep(1);
1033
1063
  } else if (code == 37 || code == 40) {
@@ -1127,10 +1157,17 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1127
1157
  {mouse: 'pageY', pos: 'top', min: 'max', max: 'min', left: 'top', right: 'bottom', width: 'height', innerWidth: 'innerHeight', innerHeight: 'innerWidth', outerWidth: 'outerHeight', outerHeight: 'outerWidth', marginTop: 'marginLeft', marginLeft: 'marginTop'} :
1128
1158
  {mouse: 'pageX', pos: 'left', min: 'min', max: 'max', left: 'left', right: 'right', width: 'width', innerWidth: 'innerWidth', innerHeight: 'innerHeight', outerWidth: 'outerWidth', outerHeight: 'outerHeight', marginTop: 'marginTop', marginLeft: 'marginLeft'}
1129
1159
  ;
1160
+ if(!this.vertical && this.element.css('direction') == 'rtl'){
1161
+ this.isRtl = true;
1162
+ this.dirs.left = 'right';
1163
+ this.dirs.right = 'left';
1164
+ this.dirs.marginLeft = 'marginRight';
1165
+ }
1130
1166
  this.element
1131
1167
  [this.vertical ? 'addClass' : 'removeClass']('vertical-range')
1132
- [this.vertical ? 'addClass' : 'removeClass']('horizontal-range')
1168
+ [this.isRtl ? 'addClass' : 'removeClass']('ws-is-rtl')
1133
1169
  ;
1170
+ this.updateMetrics = this.posCenter;
1134
1171
  this.posCenter();
1135
1172
  }
1136
1173
  };
@@ -1167,7 +1204,8 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1167
1204
  if(window.webshims && webshims.isReady){
1168
1205
  webshims.isReady('range-ui', true);
1169
1206
  }
1170
- })(window.webshims ? webshims.$ : jQuery);;webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
1207
+ })(window.webshims ? webshims.$ : jQuery);
1208
+ ;webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
1171
1209
  "use strict";
1172
1210
  var curCfg;
1173
1211
  var formcfg = webshims.formcfg;
@@ -1177,9 +1215,9 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1177
1215
  e.stopImmediatePropagation();
1178
1216
  };
1179
1217
  var getMonthOptions = function(opts){
1180
- var selectName = 'monthSelect'+opts.formatMonthNames;
1218
+ var selectName = 'monthSelect'+opts.monthNames;
1181
1219
  if(!curCfg[selectName]){
1182
- var labels = curCfg.date[opts.formatMonthNames] || monthDigits;
1220
+ var labels = curCfg.date[opts.monthNames] || monthDigits;
1183
1221
  curCfg[selectName] = ('<option value=""></option>')+$.map(monthDigits, function(val, i){
1184
1222
  return '<option value="'+val+'"]>'+labels[i]+'</option>';
1185
1223
  }).join('');
@@ -1204,13 +1242,39 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1204
1242
  curCfg.patterns[name+'Obj'] = obj;
1205
1243
  }
1206
1244
  };
1245
+ var createYearSelect = function(obj, opts){
1246
+ var options, nowY, max, min;
1247
+ if(opts.yearSelect){
1248
+ nowY = parseInt(opts.value.split('-')[0], 10);
1249
+ max = opts.max.split('-');
1250
+ min = opts.min.split('-');
1251
+ options = webshims.picker.createYearSelect(nowY || parseInt(min[0], 10) || parseInt(max[0], 10) || nowYear, max, min);
1252
+ options.unshift('<option />');
1253
+ $(obj.elements)
1254
+ .filter('select.yy')
1255
+ .html(options.join(''))
1256
+ .each(function(){
1257
+ if(!nowY){
1258
+ $('option[selected]', this).removeAttr('selected');
1259
+ $(this).val();
1260
+ }
1261
+ })
1262
+ ;
1263
+ }
1264
+ };
1207
1265
  var splitInputs = {
1208
1266
  date: {
1209
1267
  _create: function(opts){
1210
1268
  var obj = {
1211
- splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]]
1269
+ splits: []
1212
1270
  };
1213
1271
 
1272
+ if(opts.yearSelect){
1273
+ obj.splits.push($('<select class="yy"></select>')[0]);
1274
+ } else {
1275
+ obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
1276
+ }
1277
+
1214
1278
  if(opts.monthSelect){
1215
1279
  obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
1216
1280
  } else {
@@ -1223,6 +1287,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1223
1287
  }
1224
1288
 
1225
1289
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]];
1290
+ createYearSelect(obj, opts);
1226
1291
  return obj;
1227
1292
  },
1228
1293
  sort: function(element){
@@ -1247,8 +1312,15 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1247
1312
  _create: function(opts){
1248
1313
 
1249
1314
  var obj = {
1250
- splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0]]
1315
+ splits: []
1251
1316
  };
1317
+
1318
+ if(opts.yearSelect){
1319
+ obj.splits.push($('<select class="yy"></select>')[0]);
1320
+ } else {
1321
+ obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
1322
+ }
1323
+
1252
1324
  if(opts.monthSelect){
1253
1325
  obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
1254
1326
  } else {
@@ -1259,6 +1331,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1259
1331
  }
1260
1332
 
1261
1333
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
1334
+ createYearSelect(obj, opts);
1262
1335
  return obj;
1263
1336
  },
1264
1337
  sort: function(element){
@@ -1278,7 +1351,8 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1278
1351
  };
1279
1352
 
1280
1353
  var nowDate = new Date(new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 ));
1281
- nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime()
1354
+ var nowYear = nowDate.getFullYear();
1355
+ nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime();
1282
1356
  var steps = {
1283
1357
  number: {
1284
1358
  step: 1
@@ -1488,9 +1562,6 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1488
1562
  $(document).triggerHandler('wslocalechange');
1489
1563
  };
1490
1564
 
1491
-
1492
-
1493
-
1494
1565
  curCfg = webshims.activeLang(formcfg);
1495
1566
 
1496
1567
  triggerLocaleChange();
@@ -1515,7 +1586,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1515
1586
 
1516
1587
 
1517
1588
  var formatVal = {
1518
- number: function(val){
1589
+ number: function(val, o){
1519
1590
  return (val+'').replace(/\,/g, '').replace(/\./, curCfg.numberFormat['.']);
1520
1591
  },
1521
1592
  time: function(val){
@@ -1552,7 +1623,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1552
1623
  var names;
1553
1624
  var p = val.split('-');
1554
1625
  if(p[0] && p[1]){
1555
- names = curCfg.date[options.formatMonthNames] || curCfg.date[options.monthNames] || curCfg.date.monthNames;
1626
+ names = curCfg.date[options.monthNames] || curCfg.date.monthNames;
1556
1627
  p[1] = names[(p[1] * 1) - 1];
1557
1628
  if(options && options.splitInput){
1558
1629
  val = [p[0] || '', p[1] || ''];
@@ -1873,7 +1944,15 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1873
1944
  })
1874
1945
  .on({
1875
1946
  'change input focus focusin blur focusout': function(e){
1947
+ var oVal, nVal;
1876
1948
  $(e.target).trigger('ws__'+e.type);
1949
+ if(o.toFixed && o.type == 'number' && e.type == 'change'){
1950
+ oVal = that.element.prop('value');
1951
+ nVal = that.toFixed(oVal, true);
1952
+ if(oVal != nVal){
1953
+ that.element[0].value = nVal;
1954
+ }
1955
+ }
1877
1956
  }
1878
1957
  })
1879
1958
 
@@ -2022,11 +2101,14 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2022
2101
  this.inputElements.attr('inputmode', 'numeric');
2023
2102
  }
2024
2103
 
2025
-
2026
-
2027
2104
  if((!o.max && typeof o.relMax == 'number') || (!o.min && typeof o.relMin == 'number')){
2028
- webshims.error('relMax/relMin are not supported anymore')
2105
+ webshims.error('relMax/relMin are not supported anymore calculate at set it your own.');
2029
2106
  }
2107
+
2108
+ if(this.options.relDefaultValue){
2109
+ webshims.warn('relDefaultValue was removed use startValue instead!');
2110
+ }
2111
+
2030
2112
  this._init = true;
2031
2113
  },
2032
2114
  createOpts: ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'defaultValue', 'value', 'required'],
@@ -2037,17 +2119,9 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2037
2119
  this.inputElements = $(create.elements).prependTo(this.element).filter('input, select');
2038
2120
  }
2039
2121
  },
2040
-
2041
- getRelNumber: function(rel){
2042
- var start = steps[this.type].start || 0;
2043
- if(rel){
2044
- start += rel;
2045
- }
2046
- return start;
2047
- },
2048
2122
  addZero: addZero,
2049
2123
  _setStartInRange: function(){
2050
- var start = this.getRelNumber(this.options.relDefaultValue);
2124
+ var start = this.options.startValue && this.asNumber( this.options.startValue ) || steps[this.type].start || 0;
2051
2125
  if(!isNaN(this.minAsNumber) && start < this.minAsNumber){
2052
2126
  start = this.minAsNumber;
2053
2127
  } else if(!isNaN(this.maxAsNumber) && start > this.maxAsNumber){
@@ -2059,7 +2133,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2059
2133
  },
2060
2134
  reorderInputs: function(){
2061
2135
  if(splitInputs[this.type]){
2062
- var element = this.element;
2136
+ var element = this.element.attr('dir', curCfg.date.isRTL ? 'rtl' : 'ltr');
2063
2137
  splitInputs[this.type].sort(element, this.options);
2064
2138
  setTimeout(function(){
2065
2139
  var data = webshims.data(element);
@@ -2085,6 +2159,13 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2085
2159
  this.elemHelper.prop('value', val);
2086
2160
  this.options.defValue = "";
2087
2161
  }
2162
+ },
2163
+ toFixed: function(val, force){
2164
+ var o = this.options;
2165
+ if(o.toFixed && o.type == 'number' && val && this.valueAsNumber && (force || !this.element.is(':focus')) && (!o.fixOnlyFloat || (this.valueAsNumber % 1)) && !$(this.orig).is(':invalid')){
2166
+ val = formatVal[this.type](this.valueAsNumber.toFixed(o.toFixed), this.options);
2167
+ }
2168
+ return val;
2088
2169
  }
2089
2170
  });
2090
2171
 
@@ -2097,7 +2178,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2097
2178
  } else {
2098
2179
  this.elemHelper.prop(name, val);
2099
2180
  }
2100
-
2181
+
2101
2182
  val = formatVal[this.type](val, this.options);
2102
2183
  if(this.options.splitInput){
2103
2184
  $.each(this.splits, function(i, elem){
@@ -2109,7 +2190,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2109
2190
  }
2110
2191
  });
2111
2192
  } else {
2112
- this.element.prop(name, val);
2193
+ this.element.prop(name, this.toFixed(val));
2113
2194
  }
2114
2195
  this._propertyChange(name);
2115
2196
  this.mirrorValidity();
@@ -2126,6 +2207,9 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2126
2207
  this._setStartInRange();
2127
2208
  }
2128
2209
  this.options[name] = val;
2210
+ if(this._init){
2211
+ createYearSelect({elements: this.inputElements}, this.options);
2212
+ }
2129
2213
  this._propertyChange(name);
2130
2214
  this.mirrorValidity();
2131
2215
  };
@@ -2146,7 +2230,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2146
2230
 
2147
2231
  $.fn.spinbtnUI = function(opts){
2148
2232
  opts = $.extend({
2149
- monthNames: 'monthNames'
2233
+ monthNames: 'monthNamesShort'
2150
2234
  }, opts);
2151
2235
  return this.each(function(){
2152
2236
  $.webshims.objectCreate(spinBtnProto, {
@@ -2176,6 +2260,53 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2176
2260
  isVisible: true
2177
2261
  };
2178
2262
 
2263
+ picker.isInRange = function(value, max, min){
2264
+ return !((min[0] && min[0] > value[0]) || (max[0] && max[0] < value[0]));
2265
+ };
2266
+
2267
+
2268
+ picker.createYearSelect = function(value, max, min, valueAdd, stepper){
2269
+ if(!stepper){
2270
+ stepper = {start: value, step: 1, label: value};
2271
+ }
2272
+ var temp;
2273
+ var goUp = true;
2274
+ var goDown = true;
2275
+ var options = ['<option selected="">'+ stepper.label + '</option>'];
2276
+ var i = 0;
2277
+ var createOption = function(value, add){
2278
+ var value2, label;
2279
+ if(stepper.step > 1){
2280
+ value2 = value + stepper.step - 1;
2281
+ label = value+' – '+value2;
2282
+ } else {
2283
+ label = value;
2284
+ }
2285
+
2286
+ if(picker.isInRange([value], max, min) || (value2 && picker.isInRange([value2], max, min))){
2287
+ options[add]('<option value="'+ (value+valueAdd) +'">'+ label +'</option>');
2288
+ return true;
2289
+ }
2290
+ };
2291
+ if(!valueAdd){
2292
+ valueAdd = '';
2293
+ }
2294
+ while(i < 18 && (goUp || goDown)){
2295
+ i++;
2296
+ if(goUp){
2297
+ temp = stepper.start - (i * stepper.step);
2298
+ goUp = createOption(temp, 'unshift');
2299
+ }
2300
+ if(goDown){
2301
+ temp = stepper.start + (i * stepper.step);
2302
+ goDown = createOption(temp, 'push');
2303
+ }
2304
+
2305
+ }
2306
+
2307
+ return options;
2308
+ };
2309
+
2179
2310
  picker._genericSetFocus = function(element, _noFocus){
2180
2311
  element = $(element || this.activeButton);
2181
2312
 
@@ -2185,12 +2316,12 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2185
2316
  clearTimeout(that.timer);
2186
2317
  that.timer = setTimeout(function(){
2187
2318
  if(element[0]){
2188
- element[0].focus();
2319
+ element.trigger('focus');
2189
2320
  if(noTrigger !== true && !element.is(':focus')){
2190
2321
  setFocus(true);
2191
2322
  }
2192
2323
  }
2193
- }, that.popover.isVisible ? 99 : 360);
2324
+ }, that.popover.isVisible ? 0 : 360);
2194
2325
  };
2195
2326
  this.popover.activateElement(element);
2196
2327
  setFocus();
@@ -2403,7 +2534,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2403
2534
  popover.preventBlur();
2404
2535
  }
2405
2536
  },
2406
- mousedown: function(){
2537
+ mousedown: function(e){
2407
2538
  mouseFocus = true;
2408
2539
  setTimeout(resetMouseFocus, 9);
2409
2540
  if(options.buttonOnly && popover.isVisible && popover.activeElement){
@@ -2561,31 +2692,41 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2561
2692
  var updateStyles = function(){
2562
2693
  $(data.orig).removeClass('ws-important-hide');
2563
2694
  $.style( data.orig, 'display', '' );
2564
- var hasButtons, marginR, marginL;
2695
+ var hasButtons, marginR, marginL, left, right, isRtl;
2565
2696
  var correctWidth = 0.8;
2566
2697
  if(!init || data.orig.offsetWidth){
2567
2698
  hasButtons = data.buttonWrapper && data.buttonWrapper.filter(isVisible).length;
2568
- marginR = $.css( data.orig, 'marginRight');
2569
- data.element.css({
2570
- marginLeft: $.css( data.orig, 'marginLeft'),
2571
- marginRight: hasButtons ? 0 : marginR
2572
- });
2699
+
2700
+ isRtl = hasButtons && data.buttonWrapper.css('direction') == 'rtl';
2701
+ if(isRtl){
2702
+ left = 'Right';
2703
+ right = 'Left';
2704
+ } else {
2705
+ left = 'Left';
2706
+ right = 'Right';
2707
+ }
2708
+
2709
+ marginR = $.css( data.orig, 'margin'+right);
2710
+
2711
+ data.element
2712
+ .css('margin'+left, $.css( data.orig, 'margin'+left))
2713
+ .css('margin'+right, hasButtons ? 0 : marginR)
2714
+ ;
2573
2715
 
2574
2716
  if(hasButtons){
2575
- marginL = (parseInt(data.buttonWrapper.css('marginLeft'), 10) || 0);
2576
- data.element.css({paddingRight: ''});
2717
+ data.buttonWrapper[isRtl ? 'addClass' : 'removeClass']('ws-is-rtl');
2718
+ marginL = (parseInt(data.buttonWrapper.css('margin'+left), 10) || 0);
2719
+ data.element.css('padding'+right, '');
2577
2720
 
2578
2721
  if(marginL < 0){
2579
2722
  marginR = (parseInt(marginR, 10) || 0) + ((data.buttonWrapper.outerWidth() + marginL) * -1);
2580
- data.buttonWrapper.css('marginRight', marginR);
2723
+ data.buttonWrapper.css('margin'+right, marginR);
2581
2724
  data.element
2582
- .css({paddingRight: ''})
2583
- .css({
2584
- paddingRight: (parseInt( data.element.css('paddingRight'), 10) || 0) + data.buttonWrapper.outerWidth()
2585
- })
2725
+ .css('padding'+right, '')
2726
+ .css('padding'+right, (parseInt( data.element.css('padding'+right), 10) || 0) + data.buttonWrapper.outerWidth())
2586
2727
  ;
2587
2728
  } else {
2588
- data.buttonWrapper.css('marginRight', marginR);
2729
+ data.buttonWrapper.css('margin'+right, marginR);
2589
2730
  correctWidth = data.buttonWrapper.outerWidth(true) + correctWidth;
2590
2731
  }
2591
2732
  }
@@ -2603,7 +2744,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2603
2744
 
2604
2745
  var type = $.prop(this, 'type');
2605
2746
 
2606
- var i, opts, data, optsName, labels;
2747
+ var i, opts, data, optsName, labels, cNames;
2607
2748
  if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
2608
2749
  data = {};
2609
2750
  optsName = type;
@@ -2641,17 +2782,38 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2641
2782
  opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
2642
2783
  }
2643
2784
  }
2644
-
2645
- if(opts.onlyMonthDigits || (!opts.formatMonthNames && opts.monthSelect)){
2646
- opts.formatMonthNames = 'monthDigits';
2785
+ if(opts.formatMonthNames){
2786
+ webshims.error('formatMonthNames was renamded to monthNames');
2787
+ }
2788
+ if(opts.onlyMonthDigits){
2789
+ opts.monthNames = 'monthDigits';
2647
2790
  }
2648
2791
  data.shim = inputTypes[type]._create(opts);
2649
-
2792
+
2650
2793
  webshims.addShadowDom(this, data.shim.element, {
2651
2794
  data: data.shim || {}
2652
2795
  });
2653
2796
 
2654
2797
  data.shim.options.containerElements.push(data.shim.element[0]);
2798
+ cNames = $.prop(this, 'className');
2799
+ if(opts.classes){
2800
+ cNames += ' '+opts.classes;
2801
+ }
2802
+
2803
+ if(opts.splitInput || type == 'range'){
2804
+ cNames = cNames.replace('form-control', '');
2805
+ }
2806
+
2807
+ data.shim.element.on('change input', stopPropagation).addClass(cNames);
2808
+
2809
+ if(data.shim.buttonWrapper){
2810
+
2811
+ data.shim.buttonWrapper.addClass('input-button-size-'+(data.shim.buttonWrapper.children().filter(isVisible).length));
2812
+
2813
+ if(data.shim.buttonWrapper.filter(isVisible).length){
2814
+ data.shim.element.addClass('has-input-buttons');
2815
+ }
2816
+ }
2655
2817
 
2656
2818
  labelWidth($(this).getShadowFocusElement(), labels);
2657
2819
 
@@ -2683,14 +2845,13 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2683
2845
  $(opts.orig).trigger(hasFocus ? 'focusin' : 'focusout');
2684
2846
  }
2685
2847
  hasFocusTriggered = hasFocus;
2686
- }, 0);
2848
+ }, 9);
2687
2849
  }
2688
2850
  })
2689
2851
  ;
2690
2852
  })();
2691
-
2692
2853
 
2693
- data.shim.element.on('change input', stopPropagation);
2854
+
2694
2855
 
2695
2856
  if(hasFormValidation){
2696
2857
  $(opts.orig).on('firstinvalid', function(e){
@@ -2706,13 +2867,6 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2706
2867
  });
2707
2868
  }
2708
2869
 
2709
-
2710
- if(data.shim.buttonWrapper && data.shim.buttonWrapper.filter(isVisible).length){
2711
- data.shim.element.addClass('has-input-buttons');
2712
- }
2713
-
2714
- data.shim.element.addClass($.prop(this, 'className'));
2715
-
2716
2870
  if(opts.calculateWidth){
2717
2871
  sizeInput(data.shim);
2718
2872
  } else {
@@ -2774,7 +2928,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2774
2928
  if(!modernizrInputTypes[name] || replace[name]){
2775
2929
  extendType(name, {
2776
2930
  _create: function(opts, set){
2777
- if(opts.monthSelect || opts.daySelect){
2931
+ if(opts.monthSelect || opts.daySelect || opts.yearSelect){
2778
2932
  opts.splitInput = true;
2779
2933
  }
2780
2934
  if(opts.splitInput && !splitInputs[name]){
@@ -2793,7 +2947,6 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2793
2947
  if(webshims.picker && webshims.picker[name]){
2794
2948
  webshims.picker[name](data);
2795
2949
  }
2796
- data.buttonWrapper.addClass('input-button-size-'+(data.buttonWrapper.children().filter(isVisible).length));
2797
2950
  return data;
2798
2951
  }
2799
2952
  });