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
@@ -15,8 +15,7 @@
15
15
  _create: function(){
16
16
  var i;
17
17
 
18
-
19
- 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>');
18
+ 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>');
20
19
  this.trail = $('.ws-range-track', this.element);
21
20
  this.range = $('.ws-range-progress', this.element);
22
21
  this.thumb = $('.ws-range-thumb', this.trail);
@@ -38,7 +37,7 @@
38
37
  },
39
38
  value: $.noop,
40
39
  _value: function(val, _noNormalize, animate){
41
- var left, posDif, textValue;
40
+ var left, posDif;
42
41
  var o = this.options;
43
42
  var oVal = val;
44
43
  var thumbStyle = {};
@@ -54,7 +53,7 @@
54
53
  left = 100 * ((val - o.min) / (o.max - o.min));
55
54
 
56
55
  if(this._init && val == o.value && oVal == val){return;}
57
- this.options.value = val;
56
+ o.value = val;
58
57
 
59
58
  if($.fn.stop){
60
59
  this.thumb.stop();
@@ -62,6 +61,7 @@
62
61
  }
63
62
 
64
63
  rangeStyle[this.dirs.width] = left+'%';
64
+
65
65
  if(this.vertical){
66
66
  left = Math.abs(left - 100);
67
67
  }
@@ -88,15 +88,26 @@
88
88
  this.options._change(val);
89
89
  }
90
90
 
91
- textValue = this.options.textValue ? this.options.textValue(this.options.value) : this.options.options[this.options.value] || this.options.value;
91
+ this._setValueMarkup();
92
+ },
93
+ _setValueMarkup: function(){
94
+ var o = this.options;
95
+ var textValue = o.textValue ? o.textValue(this.options.value) : o.options[o.value] || o.value;
92
96
  this.element.attr({
93
97
  'aria-valuenow': this.options.value,
94
98
  'aria-valuetext': textValue
95
99
  });
96
- this.thumb.attr({
100
+ $('span', this.thumb).attr({
97
101
  'data-value': this.options.value,
98
102
  'data-valuetext': textValue
99
103
  });
104
+ if(o.selectedOption){
105
+ $(o.selectedOption).removeClass('ws-selected-option');
106
+ o.selectedOption = null;
107
+ }
108
+ if(o.value in o.options){
109
+ o.selectedOption = $('[data-value="'+o.value+'"].ws-range-ticks').addClass('ws-selected-option');
110
+ }
100
111
  },
101
112
  initDataList: function(){
102
113
  if(this.orig){
@@ -139,9 +150,9 @@
139
150
  $.each(o.options, function(val, label){
140
151
  if(!isNumber(val) || val < min || val > max){return;}
141
152
  var left = 100 * ((val - min) / (max - min));
142
- var attr = '';
153
+ var attr = 'data-value="'+val+'"';
143
154
  if(label){
144
- attr += 'data-label="'+label+'"';
155
+ attr += ' data-label="'+label+'"';
145
156
  if(o.showLabels){
146
157
  attr += ' title="'+label+'"';
147
158
  }
@@ -154,6 +165,9 @@
154
165
  $('<span class="ws-range-ticks"'+ attr +' style="'+(that.dirs.left)+': '+left+'%;" />').appendTo(trail)
155
166
  );
156
167
  });
168
+ if(o.value in o.options){
169
+ this._setValueMarkup();
170
+ }
157
171
  },
158
172
  readonly: function(val){
159
173
  val = !!val;
@@ -197,12 +211,13 @@
197
211
  var step = val == 'any' ? 'any' : retDefault(val, 1);
198
212
 
199
213
  if(o.stepping){
200
- if(step != 'any' && o.stepping % step){
201
- webshims.error('wrong stepping value for type range:'+ (o.stepping % step));
202
- } else {
203
- step = o.stepping;
204
- }
214
+ webshims.error('stepping was removed. Use stepfactor instead.');
215
+ }
216
+
217
+ if(o.stepfactor && step != 'any'){
218
+ step *= o.stepfactor;
205
219
  }
220
+
206
221
  o.step = step;
207
222
  this.value(this.options.value);
208
223
  },
@@ -240,11 +255,11 @@
240
255
  var val, valModStep, alignValue, step;
241
256
 
242
257
  if(pos <= 0){
243
- val = this.options[this.dirs.min];
258
+ val = this.options[this.dirs[this.isRtl ? 'max' : 'min']];
244
259
  } else if(pos > 100) {
245
- val = this.options[this.dirs.max];
260
+ val = this.options[this.dirs[this.isRtl ? 'min' : 'max']];
246
261
  } else {
247
- if(this.vertical){
262
+ if(this.vertical || this.isRtl){
248
263
  pos = Math.abs(pos - 100);
249
264
  }
250
265
  val = ((this.options.max - this.options.min) * (pos / 100)) + this.options.min;
@@ -329,17 +344,20 @@
329
344
  return e;
330
345
  };
331
346
  })();
347
+ var updateValue = function(val, animate){
348
+ if(val != o.value){
349
+ that.value(val, false, animate);
350
+ eventTimer.call('input', val);
351
+ }
352
+ };
332
353
  var setValueFromPos = function(e, animate){
333
354
  if(e.type == 'touchmove'){
334
355
  e.preventDefault();
335
356
  normalizeTouch(e);
336
357
  }
337
358
 
338
- var val = that.getStepedValueFromPos((e[that.dirs.mouse] - leftOffset) * widgetUnits);
339
- if(val != o.value){
340
- that.value(val, false, animate);
341
- eventTimer.call('input', val);
342
- }
359
+ updateValue(that.getStepedValueFromPos((e[that.dirs.mouse] - leftOffset) * widgetUnits), animate);
360
+
343
361
  if(e && e.type == 'mousemove'){
344
362
  e.preventDefault();
345
363
  }
@@ -377,7 +395,12 @@
377
395
  outerWidth = that.thumb[that.dirs.outerWidth]();
378
396
  leftOffset = leftOffset[that.dirs.pos];
379
397
  widgetUnits = 100 / widgetUnits;
380
- setValueFromPos(e, o.animate);
398
+
399
+ if(e.target.className == 'ws-range-ticks'){
400
+ updateValue(e.target.getAttribute('data-value'), o.animate);
401
+ } else {
402
+ setValueFromPos(e, o.animate);
403
+ }
381
404
  isActive = true;
382
405
  $(document)
383
406
  .on(e.type == 'touchstart' ?
@@ -423,6 +446,13 @@
423
446
  var step = true;
424
447
  var code = e.keyCode;
425
448
  if(!o.readonly && !o.disabled){
449
+ if(that.isRtl){
450
+ if(code == 39){
451
+ code = 37;
452
+ } else if(code == 37){
453
+ code = 39;
454
+ }
455
+ }
426
456
  if (code == 39 || code == 38) {
427
457
  that.doStep(1);
428
458
  } else if (code == 37 || code == 40) {
@@ -522,10 +552,17 @@
522
552
  {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'} :
523
553
  {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'}
524
554
  ;
555
+ if(!this.vertical && this.element.css('direction') == 'rtl'){
556
+ this.isRtl = true;
557
+ this.dirs.left = 'right';
558
+ this.dirs.right = 'left';
559
+ this.dirs.marginLeft = 'marginRight';
560
+ }
525
561
  this.element
526
562
  [this.vertical ? 'addClass' : 'removeClass']('vertical-range')
527
- [this.vertical ? 'addClass' : 'removeClass']('horizontal-range')
563
+ [this.isRtl ? 'addClass' : 'removeClass']('ws-is-rtl')
528
564
  ;
565
+ this.updateMetrics = this.posCenter;
529
566
  this.posCenter();
530
567
  }
531
568
  };
@@ -562,7 +599,8 @@
562
599
  if(window.webshims && webshims.isReady){
563
600
  webshims.isReady('range-ui', true);
564
601
  }
565
- })(window.webshims ? webshims.$ : jQuery);;webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
602
+ })(window.webshims ? webshims.$ : jQuery);
603
+ ;webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
566
604
  "use strict";
567
605
  var curCfg;
568
606
  var formcfg = webshims.formcfg;
@@ -572,9 +610,9 @@
572
610
  e.stopImmediatePropagation();
573
611
  };
574
612
  var getMonthOptions = function(opts){
575
- var selectName = 'monthSelect'+opts.formatMonthNames;
613
+ var selectName = 'monthSelect'+opts.monthNames;
576
614
  if(!curCfg[selectName]){
577
- var labels = curCfg.date[opts.formatMonthNames] || monthDigits;
615
+ var labels = curCfg.date[opts.monthNames] || monthDigits;
578
616
  curCfg[selectName] = ('<option value=""></option>')+$.map(monthDigits, function(val, i){
579
617
  return '<option value="'+val+'"]>'+labels[i]+'</option>';
580
618
  }).join('');
@@ -599,13 +637,39 @@
599
637
  curCfg.patterns[name+'Obj'] = obj;
600
638
  }
601
639
  };
640
+ var createYearSelect = function(obj, opts){
641
+ var options, nowY, max, min;
642
+ if(opts.yearSelect){
643
+ nowY = parseInt(opts.value.split('-')[0], 10);
644
+ max = opts.max.split('-');
645
+ min = opts.min.split('-');
646
+ options = webshims.picker.createYearSelect(nowY || parseInt(min[0], 10) || parseInt(max[0], 10) || nowYear, max, min);
647
+ options.unshift('<option />');
648
+ $(obj.elements)
649
+ .filter('select.yy')
650
+ .html(options.join(''))
651
+ .each(function(){
652
+ if(!nowY){
653
+ $('option[selected]', this).removeAttr('selected');
654
+ $(this).val();
655
+ }
656
+ })
657
+ ;
658
+ }
659
+ };
602
660
  var splitInputs = {
603
661
  date: {
604
662
  _create: function(opts){
605
663
  var obj = {
606
- splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]]
664
+ splits: []
607
665
  };
608
666
 
667
+ if(opts.yearSelect){
668
+ obj.splits.push($('<select class="yy"></select>')[0]);
669
+ } else {
670
+ obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
671
+ }
672
+
609
673
  if(opts.monthSelect){
610
674
  obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
611
675
  } else {
@@ -618,6 +682,7 @@
618
682
  }
619
683
 
620
684
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]];
685
+ createYearSelect(obj, opts);
621
686
  return obj;
622
687
  },
623
688
  sort: function(element){
@@ -642,8 +707,15 @@
642
707
  _create: function(opts){
643
708
 
644
709
  var obj = {
645
- splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0]]
710
+ splits: []
646
711
  };
712
+
713
+ if(opts.yearSelect){
714
+ obj.splits.push($('<select class="yy"></select>')[0]);
715
+ } else {
716
+ obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
717
+ }
718
+
647
719
  if(opts.monthSelect){
648
720
  obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
649
721
  } else {
@@ -654,6 +726,7 @@
654
726
  }
655
727
 
656
728
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
729
+ createYearSelect(obj, opts);
657
730
  return obj;
658
731
  },
659
732
  sort: function(element){
@@ -673,7 +746,8 @@
673
746
  };
674
747
 
675
748
  var nowDate = new Date(new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 ));
676
- nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime()
749
+ var nowYear = nowDate.getFullYear();
750
+ nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime();
677
751
  var steps = {
678
752
  number: {
679
753
  step: 1
@@ -883,9 +957,6 @@
883
957
  $(document).triggerHandler('wslocalechange');
884
958
  };
885
959
 
886
-
887
-
888
-
889
960
  curCfg = webshims.activeLang(formcfg);
890
961
 
891
962
  triggerLocaleChange();
@@ -910,7 +981,7 @@
910
981
 
911
982
 
912
983
  var formatVal = {
913
- number: function(val){
984
+ number: function(val, o){
914
985
  return (val+'').replace(/\,/g, '').replace(/\./, curCfg.numberFormat['.']);
915
986
  },
916
987
  time: function(val){
@@ -947,7 +1018,7 @@
947
1018
  var names;
948
1019
  var p = val.split('-');
949
1020
  if(p[0] && p[1]){
950
- names = curCfg.date[options.formatMonthNames] || curCfg.date[options.monthNames] || curCfg.date.monthNames;
1021
+ names = curCfg.date[options.monthNames] || curCfg.date.monthNames;
951
1022
  p[1] = names[(p[1] * 1) - 1];
952
1023
  if(options && options.splitInput){
953
1024
  val = [p[0] || '', p[1] || ''];
@@ -1268,7 +1339,15 @@
1268
1339
  })
1269
1340
  .on({
1270
1341
  'change input focus focusin blur focusout': function(e){
1342
+ var oVal, nVal;
1271
1343
  $(e.target).trigger('ws__'+e.type);
1344
+ if(o.toFixed && o.type == 'number' && e.type == 'change'){
1345
+ oVal = that.element.prop('value');
1346
+ nVal = that.toFixed(oVal, true);
1347
+ if(oVal != nVal){
1348
+ that.element[0].value = nVal;
1349
+ }
1350
+ }
1272
1351
  }
1273
1352
  })
1274
1353
 
@@ -1417,11 +1496,14 @@
1417
1496
  this.inputElements.attr('inputmode', 'numeric');
1418
1497
  }
1419
1498
 
1420
-
1421
-
1422
1499
  if((!o.max && typeof o.relMax == 'number') || (!o.min && typeof o.relMin == 'number')){
1423
- webshims.error('relMax/relMin are not supported anymore')
1500
+ webshims.error('relMax/relMin are not supported anymore calculate at set it your own.');
1424
1501
  }
1502
+
1503
+ if(this.options.relDefaultValue){
1504
+ webshims.warn('relDefaultValue was removed use startValue instead!');
1505
+ }
1506
+
1425
1507
  this._init = true;
1426
1508
  },
1427
1509
  createOpts: ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'defaultValue', 'value', 'required'],
@@ -1432,17 +1514,9 @@
1432
1514
  this.inputElements = $(create.elements).prependTo(this.element).filter('input, select');
1433
1515
  }
1434
1516
  },
1435
-
1436
- getRelNumber: function(rel){
1437
- var start = steps[this.type].start || 0;
1438
- if(rel){
1439
- start += rel;
1440
- }
1441
- return start;
1442
- },
1443
1517
  addZero: addZero,
1444
1518
  _setStartInRange: function(){
1445
- var start = this.getRelNumber(this.options.relDefaultValue);
1519
+ var start = this.options.startValue && this.asNumber( this.options.startValue ) || steps[this.type].start || 0;
1446
1520
  if(!isNaN(this.minAsNumber) && start < this.minAsNumber){
1447
1521
  start = this.minAsNumber;
1448
1522
  } else if(!isNaN(this.maxAsNumber) && start > this.maxAsNumber){
@@ -1454,7 +1528,7 @@
1454
1528
  },
1455
1529
  reorderInputs: function(){
1456
1530
  if(splitInputs[this.type]){
1457
- var element = this.element;
1531
+ var element = this.element.attr('dir', curCfg.date.isRTL ? 'rtl' : 'ltr');
1458
1532
  splitInputs[this.type].sort(element, this.options);
1459
1533
  setTimeout(function(){
1460
1534
  var data = webshims.data(element);
@@ -1480,6 +1554,13 @@
1480
1554
  this.elemHelper.prop('value', val);
1481
1555
  this.options.defValue = "";
1482
1556
  }
1557
+ },
1558
+ toFixed: function(val, force){
1559
+ var o = this.options;
1560
+ if(o.toFixed && o.type == 'number' && val && this.valueAsNumber && (force || !this.element.is(':focus')) && (!o.fixOnlyFloat || (this.valueAsNumber % 1)) && !$(this.orig).is(':invalid')){
1561
+ val = formatVal[this.type](this.valueAsNumber.toFixed(o.toFixed), this.options);
1562
+ }
1563
+ return val;
1483
1564
  }
1484
1565
  });
1485
1566
 
@@ -1492,7 +1573,7 @@
1492
1573
  } else {
1493
1574
  this.elemHelper.prop(name, val);
1494
1575
  }
1495
-
1576
+
1496
1577
  val = formatVal[this.type](val, this.options);
1497
1578
  if(this.options.splitInput){
1498
1579
  $.each(this.splits, function(i, elem){
@@ -1504,7 +1585,7 @@
1504
1585
  }
1505
1586
  });
1506
1587
  } else {
1507
- this.element.prop(name, val);
1588
+ this.element.prop(name, this.toFixed(val));
1508
1589
  }
1509
1590
  this._propertyChange(name);
1510
1591
  this.mirrorValidity();
@@ -1521,6 +1602,9 @@
1521
1602
  this._setStartInRange();
1522
1603
  }
1523
1604
  this.options[name] = val;
1605
+ if(this._init){
1606
+ createYearSelect({elements: this.inputElements}, this.options);
1607
+ }
1524
1608
  this._propertyChange(name);
1525
1609
  this.mirrorValidity();
1526
1610
  };
@@ -1541,7 +1625,7 @@
1541
1625
 
1542
1626
  $.fn.spinbtnUI = function(opts){
1543
1627
  opts = $.extend({
1544
- monthNames: 'monthNames'
1628
+ monthNames: 'monthNamesShort'
1545
1629
  }, opts);
1546
1630
  return this.each(function(){
1547
1631
  $.webshims.objectCreate(spinBtnProto, {
@@ -1571,6 +1655,53 @@
1571
1655
  isVisible: true
1572
1656
  };
1573
1657
 
1658
+ picker.isInRange = function(value, max, min){
1659
+ return !((min[0] && min[0] > value[0]) || (max[0] && max[0] < value[0]));
1660
+ };
1661
+
1662
+
1663
+ picker.createYearSelect = function(value, max, min, valueAdd, stepper){
1664
+ if(!stepper){
1665
+ stepper = {start: value, step: 1, label: value};
1666
+ }
1667
+ var temp;
1668
+ var goUp = true;
1669
+ var goDown = true;
1670
+ var options = ['<option selected="">'+ stepper.label + '</option>'];
1671
+ var i = 0;
1672
+ var createOption = function(value, add){
1673
+ var value2, label;
1674
+ if(stepper.step > 1){
1675
+ value2 = value + stepper.step - 1;
1676
+ label = value+' – '+value2;
1677
+ } else {
1678
+ label = value;
1679
+ }
1680
+
1681
+ if(picker.isInRange([value], max, min) || (value2 && picker.isInRange([value2], max, min))){
1682
+ options[add]('<option value="'+ (value+valueAdd) +'">'+ label +'</option>');
1683
+ return true;
1684
+ }
1685
+ };
1686
+ if(!valueAdd){
1687
+ valueAdd = '';
1688
+ }
1689
+ while(i < 18 && (goUp || goDown)){
1690
+ i++;
1691
+ if(goUp){
1692
+ temp = stepper.start - (i * stepper.step);
1693
+ goUp = createOption(temp, 'unshift');
1694
+ }
1695
+ if(goDown){
1696
+ temp = stepper.start + (i * stepper.step);
1697
+ goDown = createOption(temp, 'push');
1698
+ }
1699
+
1700
+ }
1701
+
1702
+ return options;
1703
+ };
1704
+
1574
1705
  picker._genericSetFocus = function(element, _noFocus){
1575
1706
  element = $(element || this.activeButton);
1576
1707
 
@@ -1580,12 +1711,12 @@
1580
1711
  clearTimeout(that.timer);
1581
1712
  that.timer = setTimeout(function(){
1582
1713
  if(element[0]){
1583
- element[0].focus();
1714
+ element.trigger('focus');
1584
1715
  if(noTrigger !== true && !element.is(':focus')){
1585
1716
  setFocus(true);
1586
1717
  }
1587
1718
  }
1588
- }, that.popover.isVisible ? 99 : 360);
1719
+ }, that.popover.isVisible ? 0 : 360);
1589
1720
  };
1590
1721
  this.popover.activateElement(element);
1591
1722
  setFocus();
@@ -1798,7 +1929,7 @@
1798
1929
  popover.preventBlur();
1799
1930
  }
1800
1931
  },
1801
- mousedown: function(){
1932
+ mousedown: function(e){
1802
1933
  mouseFocus = true;
1803
1934
  setTimeout(resetMouseFocus, 9);
1804
1935
  if(options.buttonOnly && popover.isVisible && popover.activeElement){
@@ -1956,31 +2087,41 @@
1956
2087
  var updateStyles = function(){
1957
2088
  $(data.orig).removeClass('ws-important-hide');
1958
2089
  $.style( data.orig, 'display', '' );
1959
- var hasButtons, marginR, marginL;
2090
+ var hasButtons, marginR, marginL, left, right, isRtl;
1960
2091
  var correctWidth = 0.8;
1961
2092
  if(!init || data.orig.offsetWidth){
1962
2093
  hasButtons = data.buttonWrapper && data.buttonWrapper.filter(isVisible).length;
1963
- marginR = $.css( data.orig, 'marginRight');
1964
- data.element.css({
1965
- marginLeft: $.css( data.orig, 'marginLeft'),
1966
- marginRight: hasButtons ? 0 : marginR
1967
- });
2094
+
2095
+ isRtl = hasButtons && data.buttonWrapper.css('direction') == 'rtl';
2096
+ if(isRtl){
2097
+ left = 'Right';
2098
+ right = 'Left';
2099
+ } else {
2100
+ left = 'Left';
2101
+ right = 'Right';
2102
+ }
2103
+
2104
+ marginR = $.css( data.orig, 'margin'+right);
2105
+
2106
+ data.element
2107
+ .css('margin'+left, $.css( data.orig, 'margin'+left))
2108
+ .css('margin'+right, hasButtons ? 0 : marginR)
2109
+ ;
1968
2110
 
1969
2111
  if(hasButtons){
1970
- marginL = (parseInt(data.buttonWrapper.css('marginLeft'), 10) || 0);
1971
- data.element.css({paddingRight: ''});
2112
+ data.buttonWrapper[isRtl ? 'addClass' : 'removeClass']('ws-is-rtl');
2113
+ marginL = (parseInt(data.buttonWrapper.css('margin'+left), 10) || 0);
2114
+ data.element.css('padding'+right, '');
1972
2115
 
1973
2116
  if(marginL < 0){
1974
2117
  marginR = (parseInt(marginR, 10) || 0) + ((data.buttonWrapper.outerWidth() + marginL) * -1);
1975
- data.buttonWrapper.css('marginRight', marginR);
2118
+ data.buttonWrapper.css('margin'+right, marginR);
1976
2119
  data.element
1977
- .css({paddingRight: ''})
1978
- .css({
1979
- paddingRight: (parseInt( data.element.css('paddingRight'), 10) || 0) + data.buttonWrapper.outerWidth()
1980
- })
2120
+ .css('padding'+right, '')
2121
+ .css('padding'+right, (parseInt( data.element.css('padding'+right), 10) || 0) + data.buttonWrapper.outerWidth())
1981
2122
  ;
1982
2123
  } else {
1983
- data.buttonWrapper.css('marginRight', marginR);
2124
+ data.buttonWrapper.css('margin'+right, marginR);
1984
2125
  correctWidth = data.buttonWrapper.outerWidth(true) + correctWidth;
1985
2126
  }
1986
2127
  }
@@ -1998,7 +2139,7 @@
1998
2139
 
1999
2140
  var type = $.prop(this, 'type');
2000
2141
 
2001
- var i, opts, data, optsName, labels;
2142
+ var i, opts, data, optsName, labels, cNames;
2002
2143
  if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
2003
2144
  data = {};
2004
2145
  optsName = type;
@@ -2036,17 +2177,38 @@
2036
2177
  opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
2037
2178
  }
2038
2179
  }
2039
-
2040
- if(opts.onlyMonthDigits || (!opts.formatMonthNames && opts.monthSelect)){
2041
- opts.formatMonthNames = 'monthDigits';
2180
+ if(opts.formatMonthNames){
2181
+ webshims.error('formatMonthNames was renamded to monthNames');
2182
+ }
2183
+ if(opts.onlyMonthDigits){
2184
+ opts.monthNames = 'monthDigits';
2042
2185
  }
2043
2186
  data.shim = inputTypes[type]._create(opts);
2044
-
2187
+
2045
2188
  webshims.addShadowDom(this, data.shim.element, {
2046
2189
  data: data.shim || {}
2047
2190
  });
2048
2191
 
2049
2192
  data.shim.options.containerElements.push(data.shim.element[0]);
2193
+ cNames = $.prop(this, 'className');
2194
+ if(opts.classes){
2195
+ cNames += ' '+opts.classes;
2196
+ }
2197
+
2198
+ if(opts.splitInput || type == 'range'){
2199
+ cNames = cNames.replace('form-control', '');
2200
+ }
2201
+
2202
+ data.shim.element.on('change input', stopPropagation).addClass(cNames);
2203
+
2204
+ if(data.shim.buttonWrapper){
2205
+
2206
+ data.shim.buttonWrapper.addClass('input-button-size-'+(data.shim.buttonWrapper.children().filter(isVisible).length));
2207
+
2208
+ if(data.shim.buttonWrapper.filter(isVisible).length){
2209
+ data.shim.element.addClass('has-input-buttons');
2210
+ }
2211
+ }
2050
2212
 
2051
2213
  labelWidth($(this).getShadowFocusElement(), labels);
2052
2214
 
@@ -2078,14 +2240,13 @@
2078
2240
  $(opts.orig).trigger(hasFocus ? 'focusin' : 'focusout');
2079
2241
  }
2080
2242
  hasFocusTriggered = hasFocus;
2081
- }, 0);
2243
+ }, 9);
2082
2244
  }
2083
2245
  })
2084
2246
  ;
2085
2247
  })();
2086
-
2087
2248
 
2088
- data.shim.element.on('change input', stopPropagation);
2249
+
2089
2250
 
2090
2251
  if(hasFormValidation){
2091
2252
  $(opts.orig).on('firstinvalid', function(e){
@@ -2101,13 +2262,6 @@
2101
2262
  });
2102
2263
  }
2103
2264
 
2104
-
2105
- if(data.shim.buttonWrapper && data.shim.buttonWrapper.filter(isVisible).length){
2106
- data.shim.element.addClass('has-input-buttons');
2107
- }
2108
-
2109
- data.shim.element.addClass($.prop(this, 'className'));
2110
-
2111
2265
  if(opts.calculateWidth){
2112
2266
  sizeInput(data.shim);
2113
2267
  } else {
@@ -2169,7 +2323,7 @@
2169
2323
  if(!modernizrInputTypes[name] || replace[name]){
2170
2324
  extendType(name, {
2171
2325
  _create: function(opts, set){
2172
- if(opts.monthSelect || opts.daySelect){
2326
+ if(opts.monthSelect || opts.daySelect || opts.yearSelect){
2173
2327
  opts.splitInput = true;
2174
2328
  }
2175
2329
  if(opts.splitInput && !splitInputs[name]){
@@ -2188,7 +2342,6 @@
2188
2342
  if(webshims.picker && webshims.picker[name]){
2189
2343
  webshims.picker[name](data);
2190
2344
  }
2191
- data.buttonWrapper.addClass('input-button-size-'+(data.buttonWrapper.children().filter(isVisible).length));
2192
2345
  return data;
2193
2346
  }
2194
2347
  });