webshims-rails 1.12.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -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
 
@@ -2309,7 +2313,13 @@ webshims.register('form-core', function($, webshims, window, document, undefined
2309
2313
  lazyLoad('WINDOWLOAD');
2310
2314
 
2311
2315
  if(webshims.isReady('form-datalist-lazy')){
2312
- this._lazyCreate(opts);
2316
+ if(window.QUnit){
2317
+ that._lazyCreate(opts);
2318
+ } else {
2319
+ setTimeout(function(){
2320
+ that._lazyCreate(opts);
2321
+ }, 9);
2322
+ }
2313
2323
  } else {
2314
2324
  $(opts.input).one('focus', lazyLoad);
2315
2325
  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
 
@@ -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);;(function($){
1144
+ })();
1145
+ });
1146
+ ;(function($){
1143
1147
 
1144
1148
  var id = 0;
1145
1149
  var isNumber = function(string){
@@ -1156,8 +1160,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1156
1160
  _create: function(){
1157
1161
  var i;
1158
1162
 
1159
-
1160
- 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>');
1163
+ 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>');
1161
1164
  this.trail = $('.ws-range-track', this.element);
1162
1165
  this.range = $('.ws-range-progress', this.element);
1163
1166
  this.thumb = $('.ws-range-thumb', this.trail);
@@ -1179,7 +1182,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1179
1182
  },
1180
1183
  value: $.noop,
1181
1184
  _value: function(val, _noNormalize, animate){
1182
- var left, posDif, textValue;
1185
+ var left, posDif;
1183
1186
  var o = this.options;
1184
1187
  var oVal = val;
1185
1188
  var thumbStyle = {};
@@ -1195,7 +1198,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1195
1198
  left = 100 * ((val - o.min) / (o.max - o.min));
1196
1199
 
1197
1200
  if(this._init && val == o.value && oVal == val){return;}
1198
- this.options.value = val;
1201
+ o.value = val;
1199
1202
 
1200
1203
  if($.fn.stop){
1201
1204
  this.thumb.stop();
@@ -1203,6 +1206,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1203
1206
  }
1204
1207
 
1205
1208
  rangeStyle[this.dirs.width] = left+'%';
1209
+
1206
1210
  if(this.vertical){
1207
1211
  left = Math.abs(left - 100);
1208
1212
  }
@@ -1229,15 +1233,26 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1229
1233
  this.options._change(val);
1230
1234
  }
1231
1235
 
1232
- textValue = this.options.textValue ? this.options.textValue(this.options.value) : this.options.options[this.options.value] || this.options.value;
1236
+ this._setValueMarkup();
1237
+ },
1238
+ _setValueMarkup: function(){
1239
+ var o = this.options;
1240
+ var textValue = o.textValue ? o.textValue(this.options.value) : o.options[o.value] || o.value;
1233
1241
  this.element.attr({
1234
1242
  'aria-valuenow': this.options.value,
1235
1243
  'aria-valuetext': textValue
1236
1244
  });
1237
- this.thumb.attr({
1245
+ $('span', this.thumb).attr({
1238
1246
  'data-value': this.options.value,
1239
1247
  'data-valuetext': textValue
1240
1248
  });
1249
+ if(o.selectedOption){
1250
+ $(o.selectedOption).removeClass('ws-selected-option');
1251
+ o.selectedOption = null;
1252
+ }
1253
+ if(o.value in o.options){
1254
+ o.selectedOption = $('[data-value="'+o.value+'"].ws-range-ticks').addClass('ws-selected-option');
1255
+ }
1241
1256
  },
1242
1257
  initDataList: function(){
1243
1258
  if(this.orig){
@@ -1280,9 +1295,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1280
1295
  $.each(o.options, function(val, label){
1281
1296
  if(!isNumber(val) || val < min || val > max){return;}
1282
1297
  var left = 100 * ((val - min) / (max - min));
1283
- var attr = '';
1298
+ var attr = 'data-value="'+val+'"';
1284
1299
  if(label){
1285
- attr += 'data-label="'+label+'"';
1300
+ attr += ' data-label="'+label+'"';
1286
1301
  if(o.showLabels){
1287
1302
  attr += ' title="'+label+'"';
1288
1303
  }
@@ -1295,6 +1310,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1295
1310
  $('<span class="ws-range-ticks"'+ attr +' style="'+(that.dirs.left)+': '+left+'%;" />').appendTo(trail)
1296
1311
  );
1297
1312
  });
1313
+ if(o.value in o.options){
1314
+ this._setValueMarkup();
1315
+ }
1298
1316
  },
1299
1317
  readonly: function(val){
1300
1318
  val = !!val;
@@ -1338,12 +1356,13 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1338
1356
  var step = val == 'any' ? 'any' : retDefault(val, 1);
1339
1357
 
1340
1358
  if(o.stepping){
1341
- if(step != 'any' && o.stepping % step){
1342
- webshims.error('wrong stepping value for type range:'+ (o.stepping % step));
1343
- } else {
1344
- step = o.stepping;
1345
- }
1359
+ webshims.error('stepping was removed. Use stepfactor instead.');
1360
+ }
1361
+
1362
+ if(o.stepfactor && step != 'any'){
1363
+ step *= o.stepfactor;
1346
1364
  }
1365
+
1347
1366
  o.step = step;
1348
1367
  this.value(this.options.value);
1349
1368
  },
@@ -1381,11 +1400,11 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1381
1400
  var val, valModStep, alignValue, step;
1382
1401
 
1383
1402
  if(pos <= 0){
1384
- val = this.options[this.dirs.min];
1403
+ val = this.options[this.dirs[this.isRtl ? 'max' : 'min']];
1385
1404
  } else if(pos > 100) {
1386
- val = this.options[this.dirs.max];
1405
+ val = this.options[this.dirs[this.isRtl ? 'min' : 'max']];
1387
1406
  } else {
1388
- if(this.vertical){
1407
+ if(this.vertical || this.isRtl){
1389
1408
  pos = Math.abs(pos - 100);
1390
1409
  }
1391
1410
  val = ((this.options.max - this.options.min) * (pos / 100)) + this.options.min;
@@ -1470,17 +1489,20 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1470
1489
  return e;
1471
1490
  };
1472
1491
  })();
1492
+ var updateValue = function(val, animate){
1493
+ if(val != o.value){
1494
+ that.value(val, false, animate);
1495
+ eventTimer.call('input', val);
1496
+ }
1497
+ };
1473
1498
  var setValueFromPos = function(e, animate){
1474
1499
  if(e.type == 'touchmove'){
1475
1500
  e.preventDefault();
1476
1501
  normalizeTouch(e);
1477
1502
  }
1478
1503
 
1479
- var val = that.getStepedValueFromPos((e[that.dirs.mouse] - leftOffset) * widgetUnits);
1480
- if(val != o.value){
1481
- that.value(val, false, animate);
1482
- eventTimer.call('input', val);
1483
- }
1504
+ updateValue(that.getStepedValueFromPos((e[that.dirs.mouse] - leftOffset) * widgetUnits), animate);
1505
+
1484
1506
  if(e && e.type == 'mousemove'){
1485
1507
  e.preventDefault();
1486
1508
  }
@@ -1518,7 +1540,12 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1518
1540
  outerWidth = that.thumb[that.dirs.outerWidth]();
1519
1541
  leftOffset = leftOffset[that.dirs.pos];
1520
1542
  widgetUnits = 100 / widgetUnits;
1521
- setValueFromPos(e, o.animate);
1543
+
1544
+ if(e.target.className == 'ws-range-ticks'){
1545
+ updateValue(e.target.getAttribute('data-value'), o.animate);
1546
+ } else {
1547
+ setValueFromPos(e, o.animate);
1548
+ }
1522
1549
  isActive = true;
1523
1550
  $(document)
1524
1551
  .on(e.type == 'touchstart' ?
@@ -1564,6 +1591,13 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1564
1591
  var step = true;
1565
1592
  var code = e.keyCode;
1566
1593
  if(!o.readonly && !o.disabled){
1594
+ if(that.isRtl){
1595
+ if(code == 39){
1596
+ code = 37;
1597
+ } else if(code == 37){
1598
+ code = 39;
1599
+ }
1600
+ }
1567
1601
  if (code == 39 || code == 38) {
1568
1602
  that.doStep(1);
1569
1603
  } else if (code == 37 || code == 40) {
@@ -1663,10 +1697,17 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1663
1697
  {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'} :
1664
1698
  {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'}
1665
1699
  ;
1700
+ if(!this.vertical && this.element.css('direction') == 'rtl'){
1701
+ this.isRtl = true;
1702
+ this.dirs.left = 'right';
1703
+ this.dirs.right = 'left';
1704
+ this.dirs.marginLeft = 'marginRight';
1705
+ }
1666
1706
  this.element
1667
1707
  [this.vertical ? 'addClass' : 'removeClass']('vertical-range')
1668
- [this.vertical ? 'addClass' : 'removeClass']('horizontal-range')
1708
+ [this.isRtl ? 'addClass' : 'removeClass']('ws-is-rtl')
1669
1709
  ;
1710
+ this.updateMetrics = this.posCenter;
1670
1711
  this.posCenter();
1671
1712
  }
1672
1713
  };
@@ -1703,7 +1744,8 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1703
1744
  if(window.webshims && webshims.isReady){
1704
1745
  webshims.isReady('range-ui', true);
1705
1746
  }
1706
- })(window.webshims ? webshims.$ : jQuery);;webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
1747
+ })(window.webshims ? webshims.$ : jQuery);
1748
+ ;webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
1707
1749
  "use strict";
1708
1750
  var curCfg;
1709
1751
  var formcfg = webshims.formcfg;
@@ -1713,9 +1755,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1713
1755
  e.stopImmediatePropagation();
1714
1756
  };
1715
1757
  var getMonthOptions = function(opts){
1716
- var selectName = 'monthSelect'+opts.formatMonthNames;
1758
+ var selectName = 'monthSelect'+opts.monthNames;
1717
1759
  if(!curCfg[selectName]){
1718
- var labels = curCfg.date[opts.formatMonthNames] || monthDigits;
1760
+ var labels = curCfg.date[opts.monthNames] || monthDigits;
1719
1761
  curCfg[selectName] = ('<option value=""></option>')+$.map(monthDigits, function(val, i){
1720
1762
  return '<option value="'+val+'"]>'+labels[i]+'</option>';
1721
1763
  }).join('');
@@ -1740,13 +1782,39 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1740
1782
  curCfg.patterns[name+'Obj'] = obj;
1741
1783
  }
1742
1784
  };
1785
+ var createYearSelect = function(obj, opts){
1786
+ var options, nowY, max, min;
1787
+ if(opts.yearSelect){
1788
+ nowY = parseInt(opts.value.split('-')[0], 10);
1789
+ max = opts.max.split('-');
1790
+ min = opts.min.split('-');
1791
+ options = webshims.picker.createYearSelect(nowY || parseInt(min[0], 10) || parseInt(max[0], 10) || nowYear, max, min);
1792
+ options.unshift('<option />');
1793
+ $(obj.elements)
1794
+ .filter('select.yy')
1795
+ .html(options.join(''))
1796
+ .each(function(){
1797
+ if(!nowY){
1798
+ $('option[selected]', this).removeAttr('selected');
1799
+ $(this).val();
1800
+ }
1801
+ })
1802
+ ;
1803
+ }
1804
+ };
1743
1805
  var splitInputs = {
1744
1806
  date: {
1745
1807
  _create: function(opts){
1746
1808
  var obj = {
1747
- splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]]
1809
+ splits: []
1748
1810
  };
1749
1811
 
1812
+ if(opts.yearSelect){
1813
+ obj.splits.push($('<select class="yy"></select>')[0]);
1814
+ } else {
1815
+ obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
1816
+ }
1817
+
1750
1818
  if(opts.monthSelect){
1751
1819
  obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
1752
1820
  } else {
@@ -1759,6 +1827,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1759
1827
  }
1760
1828
 
1761
1829
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]];
1830
+ createYearSelect(obj, opts);
1762
1831
  return obj;
1763
1832
  },
1764
1833
  sort: function(element){
@@ -1783,8 +1852,15 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1783
1852
  _create: function(opts){
1784
1853
 
1785
1854
  var obj = {
1786
- splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0]]
1855
+ splits: []
1787
1856
  };
1857
+
1858
+ if(opts.yearSelect){
1859
+ obj.splits.push($('<select class="yy"></select>')[0]);
1860
+ } else {
1861
+ obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
1862
+ }
1863
+
1788
1864
  if(opts.monthSelect){
1789
1865
  obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
1790
1866
  } else {
@@ -1795,6 +1871,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1795
1871
  }
1796
1872
 
1797
1873
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
1874
+ createYearSelect(obj, opts);
1798
1875
  return obj;
1799
1876
  },
1800
1877
  sort: function(element){
@@ -1814,7 +1891,8 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1814
1891
  };
1815
1892
 
1816
1893
  var nowDate = new Date(new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 ));
1817
- nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime()
1894
+ var nowYear = nowDate.getFullYear();
1895
+ nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime();
1818
1896
  var steps = {
1819
1897
  number: {
1820
1898
  step: 1
@@ -2024,9 +2102,6 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2024
2102
  $(document).triggerHandler('wslocalechange');
2025
2103
  };
2026
2104
 
2027
-
2028
-
2029
-
2030
2105
  curCfg = webshims.activeLang(formcfg);
2031
2106
 
2032
2107
  triggerLocaleChange();
@@ -2051,7 +2126,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2051
2126
 
2052
2127
 
2053
2128
  var formatVal = {
2054
- number: function(val){
2129
+ number: function(val, o){
2055
2130
  return (val+'').replace(/\,/g, '').replace(/\./, curCfg.numberFormat['.']);
2056
2131
  },
2057
2132
  time: function(val){
@@ -2088,7 +2163,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2088
2163
  var names;
2089
2164
  var p = val.split('-');
2090
2165
  if(p[0] && p[1]){
2091
- names = curCfg.date[options.formatMonthNames] || curCfg.date[options.monthNames] || curCfg.date.monthNames;
2166
+ names = curCfg.date[options.monthNames] || curCfg.date.monthNames;
2092
2167
  p[1] = names[(p[1] * 1) - 1];
2093
2168
  if(options && options.splitInput){
2094
2169
  val = [p[0] || '', p[1] || ''];
@@ -2409,7 +2484,15 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2409
2484
  })
2410
2485
  .on({
2411
2486
  'change input focus focusin blur focusout': function(e){
2487
+ var oVal, nVal;
2412
2488
  $(e.target).trigger('ws__'+e.type);
2489
+ if(o.toFixed && o.type == 'number' && e.type == 'change'){
2490
+ oVal = that.element.prop('value');
2491
+ nVal = that.toFixed(oVal, true);
2492
+ if(oVal != nVal){
2493
+ that.element[0].value = nVal;
2494
+ }
2495
+ }
2413
2496
  }
2414
2497
  })
2415
2498
 
@@ -2558,11 +2641,14 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2558
2641
  this.inputElements.attr('inputmode', 'numeric');
2559
2642
  }
2560
2643
 
2561
-
2562
-
2563
2644
  if((!o.max && typeof o.relMax == 'number') || (!o.min && typeof o.relMin == 'number')){
2564
- webshims.error('relMax/relMin are not supported anymore')
2645
+ webshims.error('relMax/relMin are not supported anymore calculate at set it your own.');
2646
+ }
2647
+
2648
+ if(this.options.relDefaultValue){
2649
+ webshims.warn('relDefaultValue was removed use startValue instead!');
2565
2650
  }
2651
+
2566
2652
  this._init = true;
2567
2653
  },
2568
2654
  createOpts: ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'defaultValue', 'value', 'required'],
@@ -2573,17 +2659,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2573
2659
  this.inputElements = $(create.elements).prependTo(this.element).filter('input, select');
2574
2660
  }
2575
2661
  },
2576
-
2577
- getRelNumber: function(rel){
2578
- var start = steps[this.type].start || 0;
2579
- if(rel){
2580
- start += rel;
2581
- }
2582
- return start;
2583
- },
2584
2662
  addZero: addZero,
2585
2663
  _setStartInRange: function(){
2586
- var start = this.getRelNumber(this.options.relDefaultValue);
2664
+ var start = this.options.startValue && this.asNumber( this.options.startValue ) || steps[this.type].start || 0;
2587
2665
  if(!isNaN(this.minAsNumber) && start < this.minAsNumber){
2588
2666
  start = this.minAsNumber;
2589
2667
  } else if(!isNaN(this.maxAsNumber) && start > this.maxAsNumber){
@@ -2595,7 +2673,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2595
2673
  },
2596
2674
  reorderInputs: function(){
2597
2675
  if(splitInputs[this.type]){
2598
- var element = this.element;
2676
+ var element = this.element.attr('dir', curCfg.date.isRTL ? 'rtl' : 'ltr');
2599
2677
  splitInputs[this.type].sort(element, this.options);
2600
2678
  setTimeout(function(){
2601
2679
  var data = webshims.data(element);
@@ -2621,6 +2699,13 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2621
2699
  this.elemHelper.prop('value', val);
2622
2700
  this.options.defValue = "";
2623
2701
  }
2702
+ },
2703
+ toFixed: function(val, force){
2704
+ var o = this.options;
2705
+ if(o.toFixed && o.type == 'number' && val && this.valueAsNumber && (force || !this.element.is(':focus')) && (!o.fixOnlyFloat || (this.valueAsNumber % 1)) && !$(this.orig).is(':invalid')){
2706
+ val = formatVal[this.type](this.valueAsNumber.toFixed(o.toFixed), this.options);
2707
+ }
2708
+ return val;
2624
2709
  }
2625
2710
  });
2626
2711
 
@@ -2633,7 +2718,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2633
2718
  } else {
2634
2719
  this.elemHelper.prop(name, val);
2635
2720
  }
2636
-
2721
+
2637
2722
  val = formatVal[this.type](val, this.options);
2638
2723
  if(this.options.splitInput){
2639
2724
  $.each(this.splits, function(i, elem){
@@ -2645,7 +2730,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2645
2730
  }
2646
2731
  });
2647
2732
  } else {
2648
- this.element.prop(name, val);
2733
+ this.element.prop(name, this.toFixed(val));
2649
2734
  }
2650
2735
  this._propertyChange(name);
2651
2736
  this.mirrorValidity();
@@ -2662,6 +2747,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2662
2747
  this._setStartInRange();
2663
2748
  }
2664
2749
  this.options[name] = val;
2750
+ if(this._init){
2751
+ createYearSelect({elements: this.inputElements}, this.options);
2752
+ }
2665
2753
  this._propertyChange(name);
2666
2754
  this.mirrorValidity();
2667
2755
  };
@@ -2682,7 +2770,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2682
2770
 
2683
2771
  $.fn.spinbtnUI = function(opts){
2684
2772
  opts = $.extend({
2685
- monthNames: 'monthNames'
2773
+ monthNames: 'monthNamesShort'
2686
2774
  }, opts);
2687
2775
  return this.each(function(){
2688
2776
  $.webshims.objectCreate(spinBtnProto, {
@@ -2712,6 +2800,53 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2712
2800
  isVisible: true
2713
2801
  };
2714
2802
 
2803
+ picker.isInRange = function(value, max, min){
2804
+ return !((min[0] && min[0] > value[0]) || (max[0] && max[0] < value[0]));
2805
+ };
2806
+
2807
+
2808
+ picker.createYearSelect = function(value, max, min, valueAdd, stepper){
2809
+ if(!stepper){
2810
+ stepper = {start: value, step: 1, label: value};
2811
+ }
2812
+ var temp;
2813
+ var goUp = true;
2814
+ var goDown = true;
2815
+ var options = ['<option selected="">'+ stepper.label + '</option>'];
2816
+ var i = 0;
2817
+ var createOption = function(value, add){
2818
+ var value2, label;
2819
+ if(stepper.step > 1){
2820
+ value2 = value + stepper.step - 1;
2821
+ label = value+' – '+value2;
2822
+ } else {
2823
+ label = value;
2824
+ }
2825
+
2826
+ if(picker.isInRange([value], max, min) || (value2 && picker.isInRange([value2], max, min))){
2827
+ options[add]('<option value="'+ (value+valueAdd) +'">'+ label +'</option>');
2828
+ return true;
2829
+ }
2830
+ };
2831
+ if(!valueAdd){
2832
+ valueAdd = '';
2833
+ }
2834
+ while(i < 18 && (goUp || goDown)){
2835
+ i++;
2836
+ if(goUp){
2837
+ temp = stepper.start - (i * stepper.step);
2838
+ goUp = createOption(temp, 'unshift');
2839
+ }
2840
+ if(goDown){
2841
+ temp = stepper.start + (i * stepper.step);
2842
+ goDown = createOption(temp, 'push');
2843
+ }
2844
+
2845
+ }
2846
+
2847
+ return options;
2848
+ };
2849
+
2715
2850
  picker._genericSetFocus = function(element, _noFocus){
2716
2851
  element = $(element || this.activeButton);
2717
2852
 
@@ -2721,12 +2856,12 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2721
2856
  clearTimeout(that.timer);
2722
2857
  that.timer = setTimeout(function(){
2723
2858
  if(element[0]){
2724
- element[0].focus();
2859
+ element.trigger('focus');
2725
2860
  if(noTrigger !== true && !element.is(':focus')){
2726
2861
  setFocus(true);
2727
2862
  }
2728
2863
  }
2729
- }, that.popover.isVisible ? 99 : 360);
2864
+ }, that.popover.isVisible ? 0 : 360);
2730
2865
  };
2731
2866
  this.popover.activateElement(element);
2732
2867
  setFocus();
@@ -2939,7 +3074,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2939
3074
  popover.preventBlur();
2940
3075
  }
2941
3076
  },
2942
- mousedown: function(){
3077
+ mousedown: function(e){
2943
3078
  mouseFocus = true;
2944
3079
  setTimeout(resetMouseFocus, 9);
2945
3080
  if(options.buttonOnly && popover.isVisible && popover.activeElement){
@@ -3097,31 +3232,41 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3097
3232
  var updateStyles = function(){
3098
3233
  $(data.orig).removeClass('ws-important-hide');
3099
3234
  $.style( data.orig, 'display', '' );
3100
- var hasButtons, marginR, marginL;
3235
+ var hasButtons, marginR, marginL, left, right, isRtl;
3101
3236
  var correctWidth = 0.8;
3102
3237
  if(!init || data.orig.offsetWidth){
3103
3238
  hasButtons = data.buttonWrapper && data.buttonWrapper.filter(isVisible).length;
3104
- marginR = $.css( data.orig, 'marginRight');
3105
- data.element.css({
3106
- marginLeft: $.css( data.orig, 'marginLeft'),
3107
- marginRight: hasButtons ? 0 : marginR
3108
- });
3239
+
3240
+ isRtl = hasButtons && data.buttonWrapper.css('direction') == 'rtl';
3241
+ if(isRtl){
3242
+ left = 'Right';
3243
+ right = 'Left';
3244
+ } else {
3245
+ left = 'Left';
3246
+ right = 'Right';
3247
+ }
3248
+
3249
+ marginR = $.css( data.orig, 'margin'+right);
3250
+
3251
+ data.element
3252
+ .css('margin'+left, $.css( data.orig, 'margin'+left))
3253
+ .css('margin'+right, hasButtons ? 0 : marginR)
3254
+ ;
3109
3255
 
3110
3256
  if(hasButtons){
3111
- marginL = (parseInt(data.buttonWrapper.css('marginLeft'), 10) || 0);
3112
- data.element.css({paddingRight: ''});
3257
+ data.buttonWrapper[isRtl ? 'addClass' : 'removeClass']('ws-is-rtl');
3258
+ marginL = (parseInt(data.buttonWrapper.css('margin'+left), 10) || 0);
3259
+ data.element.css('padding'+right, '');
3113
3260
 
3114
3261
  if(marginL < 0){
3115
3262
  marginR = (parseInt(marginR, 10) || 0) + ((data.buttonWrapper.outerWidth() + marginL) * -1);
3116
- data.buttonWrapper.css('marginRight', marginR);
3263
+ data.buttonWrapper.css('margin'+right, marginR);
3117
3264
  data.element
3118
- .css({paddingRight: ''})
3119
- .css({
3120
- paddingRight: (parseInt( data.element.css('paddingRight'), 10) || 0) + data.buttonWrapper.outerWidth()
3121
- })
3265
+ .css('padding'+right, '')
3266
+ .css('padding'+right, (parseInt( data.element.css('padding'+right), 10) || 0) + data.buttonWrapper.outerWidth())
3122
3267
  ;
3123
3268
  } else {
3124
- data.buttonWrapper.css('marginRight', marginR);
3269
+ data.buttonWrapper.css('margin'+right, marginR);
3125
3270
  correctWidth = data.buttonWrapper.outerWidth(true) + correctWidth;
3126
3271
  }
3127
3272
  }
@@ -3139,7 +3284,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3139
3284
 
3140
3285
  var type = $.prop(this, 'type');
3141
3286
 
3142
- var i, opts, data, optsName, labels;
3287
+ var i, opts, data, optsName, labels, cNames;
3143
3288
  if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
3144
3289
  data = {};
3145
3290
  optsName = type;
@@ -3177,17 +3322,38 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3177
3322
  opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
3178
3323
  }
3179
3324
  }
3180
-
3181
- if(opts.onlyMonthDigits || (!opts.formatMonthNames && opts.monthSelect)){
3182
- opts.formatMonthNames = 'monthDigits';
3325
+ if(opts.formatMonthNames){
3326
+ webshims.error('formatMonthNames was renamded to monthNames');
3327
+ }
3328
+ if(opts.onlyMonthDigits){
3329
+ opts.monthNames = 'monthDigits';
3183
3330
  }
3184
3331
  data.shim = inputTypes[type]._create(opts);
3185
-
3332
+
3186
3333
  webshims.addShadowDom(this, data.shim.element, {
3187
3334
  data: data.shim || {}
3188
3335
  });
3189
3336
 
3190
3337
  data.shim.options.containerElements.push(data.shim.element[0]);
3338
+ cNames = $.prop(this, 'className');
3339
+ if(opts.classes){
3340
+ cNames += ' '+opts.classes;
3341
+ }
3342
+
3343
+ if(opts.splitInput || type == 'range'){
3344
+ cNames = cNames.replace('form-control', '');
3345
+ }
3346
+
3347
+ data.shim.element.on('change input', stopPropagation).addClass(cNames);
3348
+
3349
+ if(data.shim.buttonWrapper){
3350
+
3351
+ data.shim.buttonWrapper.addClass('input-button-size-'+(data.shim.buttonWrapper.children().filter(isVisible).length));
3352
+
3353
+ if(data.shim.buttonWrapper.filter(isVisible).length){
3354
+ data.shim.element.addClass('has-input-buttons');
3355
+ }
3356
+ }
3191
3357
 
3192
3358
  labelWidth($(this).getShadowFocusElement(), labels);
3193
3359
 
@@ -3219,14 +3385,13 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3219
3385
  $(opts.orig).trigger(hasFocus ? 'focusin' : 'focusout');
3220
3386
  }
3221
3387
  hasFocusTriggered = hasFocus;
3222
- }, 0);
3388
+ }, 9);
3223
3389
  }
3224
3390
  })
3225
3391
  ;
3226
3392
  })();
3227
-
3228
3393
 
3229
- data.shim.element.on('change input', stopPropagation);
3394
+
3230
3395
 
3231
3396
  if(hasFormValidation){
3232
3397
  $(opts.orig).on('firstinvalid', function(e){
@@ -3242,13 +3407,6 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3242
3407
  });
3243
3408
  }
3244
3409
 
3245
-
3246
- if(data.shim.buttonWrapper && data.shim.buttonWrapper.filter(isVisible).length){
3247
- data.shim.element.addClass('has-input-buttons');
3248
- }
3249
-
3250
- data.shim.element.addClass($.prop(this, 'className'));
3251
-
3252
3410
  if(opts.calculateWidth){
3253
3411
  sizeInput(data.shim);
3254
3412
  } else {
@@ -3310,7 +3468,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3310
3468
  if(!modernizrInputTypes[name] || replace[name]){
3311
3469
  extendType(name, {
3312
3470
  _create: function(opts, set){
3313
- if(opts.monthSelect || opts.daySelect){
3471
+ if(opts.monthSelect || opts.daySelect || opts.yearSelect){
3314
3472
  opts.splitInput = true;
3315
3473
  }
3316
3474
  if(opts.splitInput && !splitInputs[name]){
@@ -3329,7 +3487,6 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3329
3487
  if(webshims.picker && webshims.picker[name]){
3330
3488
  webshims.picker[name](data);
3331
3489
  }
3332
- data.buttonWrapper.addClass('input-button-size-'+(data.buttonWrapper.children().filter(isVisible).length));
3333
3490
  return data;
3334
3491
  }
3335
3492
  });
@@ -3594,7 +3751,13 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
3594
3751
  lazyLoad('WINDOWLOAD');
3595
3752
 
3596
3753
  if(webshims.isReady('form-datalist-lazy')){
3597
- this._lazyCreate(opts);
3754
+ if(window.QUnit){
3755
+ that._lazyCreate(opts);
3756
+ } else {
3757
+ setTimeout(function(){
3758
+ that._lazyCreate(opts);
3759
+ }, 9);
3760
+ }
3598
3761
  } else {
3599
3762
  $(opts.input).one('focus', lazyLoad);
3600
3763
  webshims.ready('form-datalist-lazy', function(){