webshims-rails 1.11.6.1 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/polyfiller.js +126 -72
  4. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js +9 -4
  5. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/flashcanvas.js +32 -26
  6. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/flashcanvas.swf +0 -0
  7. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/proxy.php +25 -4
  8. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/save.php +9 -3
  9. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js +9 -4
  10. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flash10canvas.swf +0 -0
  11. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flash9canvas.swf +0 -0
  12. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flashcanvas.js +36 -30
  13. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/proxy.php +25 -4
  14. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/save.php +9 -3
  15. data/vendor/assets/javascripts/webshims/shims/combos/1.js +13 -6
  16. data/vendor/assets/javascripts/webshims/shims/combos/10.js +156 -143
  17. data/vendor/assets/javascripts/webshims/shims/combos/11.js +97 -84
  18. data/vendor/assets/javascripts/webshims/shims/combos/12.js +2 -4
  19. data/vendor/assets/javascripts/webshims/shims/combos/13.js +1 -2
  20. data/vendor/assets/javascripts/webshims/shims/combos/14.js +956 -2819
  21. data/vendor/assets/javascripts/webshims/shims/combos/15.js +73 -67
  22. data/vendor/assets/javascripts/webshims/shims/combos/16.js +75 -71
  23. data/vendor/assets/javascripts/webshims/shims/combos/17.js +118 -89
  24. data/vendor/assets/javascripts/webshims/shims/combos/18.js +119 -91
  25. data/vendor/assets/javascripts/webshims/shims/combos/19.js +62 -65
  26. data/vendor/assets/javascripts/webshims/shims/combos/2.js +73 -67
  27. data/vendor/assets/javascripts/webshims/shims/combos/20.js +61 -63
  28. data/vendor/assets/javascripts/webshims/shims/combos/21.js +3 -6
  29. data/vendor/assets/javascripts/webshims/shims/combos/22.js +1 -2
  30. data/vendor/assets/javascripts/webshims/shims/combos/23.js +1 -2
  31. data/vendor/assets/javascripts/webshims/shims/combos/24.js +22 -12
  32. data/vendor/assets/javascripts/webshims/shims/combos/25.js +63 -67
  33. data/vendor/assets/javascripts/webshims/shims/combos/26.js +59 -59
  34. data/vendor/assets/javascripts/webshims/shims/combos/27.js +1 -2
  35. data/vendor/assets/javascripts/webshims/shims/combos/28.js +1915 -0
  36. data/vendor/assets/javascripts/webshims/shims/combos/29.js +817 -0
  37. data/vendor/assets/javascripts/webshims/shims/combos/3.js +71 -63
  38. data/vendor/assets/javascripts/webshims/shims/combos/30.js +72 -65
  39. data/vendor/assets/javascripts/webshims/shims/combos/31.js +71 -63
  40. data/vendor/assets/javascripts/webshims/shims/combos/32.js +2343 -0
  41. data/vendor/assets/javascripts/webshims/shims/combos/33.js +897 -0
  42. data/vendor/assets/javascripts/webshims/shims/combos/4.js +59 -59
  43. data/vendor/assets/javascripts/webshims/shims/combos/5.js +119 -91
  44. data/vendor/assets/javascripts/webshims/shims/combos/6.js +120 -93
  45. data/vendor/assets/javascripts/webshims/shims/combos/7.js +74 -69
  46. data/vendor/assets/javascripts/webshims/shims/combos/8.js +73 -67
  47. data/vendor/assets/javascripts/webshims/shims/combos/9.js +157 -145
  48. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +58 -57
  49. data/vendor/assets/javascripts/webshims/shims/form-combat.js +0 -1
  50. data/vendor/assets/javascripts/webshims/shims/form-core.js +12 -3
  51. data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +4 -3
  52. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +20 -3
  53. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +78 -71
  54. data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +21 -10
  55. data/vendor/assets/javascripts/webshims/shims/form-validation.js +39 -27
  56. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +173 -128
  57. data/vendor/assets/javascripts/webshims/shims/i18n/{formcfg-ch-ZN.js → formcfg-ch-CN.js} +0 -0
  58. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-en.js +0 -2
  59. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-zh-CN.js +65 -0
  60. data/vendor/assets/javascripts/webshims/shims/plugins/jquery.ui.position.js +1 -1
  61. data/vendor/assets/javascripts/webshims/shims/range-ui.js +18 -11
  62. data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +221 -153
  63. data/vendor/assets/javascripts/webshims/shims/styles/progress.gif +0 -0
  64. data/vendor/assets/javascripts/webshims/shims/styles/progress.png +0 -0
  65. data/vendor/assets/javascripts/webshims/shims/styles/scss/_extends.scss +5 -0
  66. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +273 -177
  67. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +113 -98
  68. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +114 -88
  69. data/vendor/assets/javascripts/webshims/shims/track-ui.js +2 -2
  70. metadata +10 -7
  71. data/vendor/assets/javascripts/webshims/extras/mousepress.js +0 -60
  72. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Thumbs.db +0 -0
  73. data/vendor/assets/javascripts/webshims/shims/json-storage.js +0 -316
  74. data/vendor/assets/javascripts/webshims/shims/mediagroup.js +0 -29
@@ -18,7 +18,7 @@
18
18
 
19
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>');
20
20
  this.trail = $('.ws-range-track', this.element);
21
- this.range = $('.ws-range-progress ', this.element);
21
+ this.range = $('.ws-range-progress', this.element);
22
22
  this.thumb = $('.ws-range-thumb', this.trail);
23
23
 
24
24
  this.updateMetrics();
@@ -38,7 +38,7 @@
38
38
  },
39
39
  value: $.noop,
40
40
  _value: function(val, _noNormalize, animate){
41
- var left, posDif;
41
+ var left, posDif, textValue;
42
42
  var o = this.options;
43
43
  var oVal = val;
44
44
  var thumbStyle = {};
@@ -87,9 +87,15 @@
87
87
  if(this.orig && (oVal != val || (!this._init && this.orig.value != val)) ){
88
88
  this.options._change(val);
89
89
  }
90
+
91
+ textValue = this.options.textValue ? this.options.textValue(this.options.value) : this.options.options[this.options.value] || this.options.value;
90
92
  this.element.attr({
91
93
  'aria-valuenow': this.options.value,
92
- 'aria-valuetext': this.options.textValue ? this.options.textValue(this.options.value) : this.options.options[this.options.value] || this.options.value
94
+ 'aria-valuetext': textValue
95
+ });
96
+ this.thumb.attr({
97
+ 'data-value': this.options.value,
98
+ 'data-valuetext': textValue
93
99
  });
94
100
  },
95
101
  initDataList: function(){
@@ -133,13 +139,19 @@
133
139
  $.each(o.options, function(val, label){
134
140
  if(!isNumber(val) || val < min || val > max){return;}
135
141
  var left = 100 * ((val - min) / (max - min));
136
- var title = o.showLabels && label ? ' title="'+ label +'"' : '';
142
+ var attr = '';
143
+ if(label){
144
+ attr += 'data-label="'+label+'"';
145
+ if(o.showLabels){
146
+ attr += ' title="'+label+'"';
147
+ }
148
+ }
137
149
  if(that.vertical){
138
150
  left = Math.abs(left - 100);
139
151
  }
140
152
 
141
153
  that.posCenter(
142
- $('<span class="ws-range-ticks"'+ title +' data-label="'+label+'" style="'+(that.dirs.left)+': '+left+'%;" />').appendTo(trail)
154
+ $('<span class="ws-range-ticks"'+ attr +' style="'+(that.dirs.left)+': '+left+'%;" />').appendTo(trail)
143
155
  );
144
156
  });
145
157
  },
@@ -548,33 +560,36 @@
548
560
  });
549
561
  };
550
562
  if(window.webshims && webshims.isReady){
551
- webshims.ready('es5', function(){
552
- webshims.isReady('range-ui', true);
553
- });
554
- if(webshims._polyfill){
555
- webshims._polyfill(['es5']);
556
- }
563
+ webshims.isReady('range-ui', true);
557
564
  }
558
- })(window.webshims ? webshims.$ : jQuery);
559
- webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
565
+ })(window.webshims ? webshims.$ : jQuery);;webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
560
566
  "use strict";
561
567
  var curCfg;
562
568
  var formcfg = webshims.formcfg;
569
+ var hasFormValidation = Modernizr.formvalidation && !webshims.bugs.bustedValidity;
563
570
  var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
564
571
  var stopPropagation = function(e){
565
572
  e.stopImmediatePropagation();
566
573
  };
567
- var getMonthOptions = (function(){
568
- var str;
569
- return function(){
570
- if(!str){
571
- str = ('<option value=""></option>')+$.map(monthDigits, function(val){
572
- return '<option value="'+val+'"]>'+val+'</option>';
573
- }).join('');
574
- }
575
- return str;
576
- };
577
- })();
574
+ var getMonthOptions = function(opts){
575
+ var selectName = 'monthSelect'+opts.formatMonthNames;
576
+ if(!curCfg[selectName]){
577
+ var labels = curCfg.date[opts.formatMonthNames] || monthDigits;
578
+ curCfg[selectName] = ('<option value=""></option>')+$.map(monthDigits, function(val, i){
579
+ return '<option value="'+val+'"]>'+labels[i]+'</option>';
580
+ }).join('');
581
+ }
582
+ return curCfg[selectName];
583
+ };
584
+ var daySelect = '<select class="dd"><option value=""></option>'+ (function(){
585
+ var i = 1;
586
+ var opts = [];
587
+ while(i < 32){
588
+ opts.push('<option>'+ ((i < 10) ? '0'+ i : i) +'</option>' );
589
+ i++;
590
+ }
591
+ return opts.join('');
592
+ })() +'</select>';
578
593
  var createFormat = function(name){
579
594
  if(!curCfg.patterns[name+'Obj']){
580
595
  var obj = {};
@@ -588,15 +603,19 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
588
603
  date: {
589
604
  _create: function(opts){
590
605
  var obj = {
591
- splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" />')[0]]
606
+ splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]]
592
607
  };
608
+
593
609
  if(opts.monthSelect){
594
610
  obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
595
611
  } else {
596
612
  obj.splits.push($('<input type="text" class="mm" inputmode="numeric" maxlength="2" size="2" />')[0]);
597
613
  }
598
- obj.splits.push($('<input type="text" class="dd ws-spin" inputmode="numeric" maxlength="2" size="2" />')[0]);
599
-
614
+ if(opts.daySelect){
615
+ obj.splits.push($(daySelect)[0]);
616
+ } else {
617
+ obj.splits.push($('<input type="text" class="dd ws-spin" inputmode="numeric" maxlength="2" size="2" />')[0]);
618
+ }
600
619
 
601
620
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]];
602
621
  return obj;
@@ -626,7 +645,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
626
645
  splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0]]
627
646
  };
628
647
  if(opts.monthSelect){
629
- obj.splits.push($('<select class="mm ws-spin">'+getMonthOptions(opts)+'</select>')[0]);
648
+ obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
630
649
  } else {
631
650
  obj.splits.push($('<input type="text" class="mm ws-spin" />')[0]);
632
651
  if(opts.onlyMonthDigits){
@@ -1030,18 +1049,30 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1030
1049
  },
1031
1050
  date: function(val, opts, noCorrect){
1032
1051
  createFormat('d');
1033
- var i;
1034
- var obj;
1052
+ var tmp, obj;
1053
+ var ret = '';
1035
1054
  if(opts.splitInput){
1036
1055
  obj = {yy: 0, mm: 1, dd: 2};
1037
1056
  } else {
1038
1057
  obj = curCfg.patterns.dObj;
1039
1058
  val = val.split(curCfg.dFormat);
1040
1059
  }
1041
-
1042
- return (val.length == 3 && val[0] && val[1] && val[2] && (!noCorrect || (val[obj.yy].length > 3 && val[obj.mm].length == 2 && val[obj.dd].length == 2))) ?
1043
- ([addZero(val[obj.yy]), addZero(val[obj.mm]), addZero(val[obj.dd])]).join('-') :
1044
- ''
1060
+ if(val.length == 3 && val[0] && val[1] && val[2] && (!noCorrect || (val[obj.yy].length > 3 && val[obj.mm].length == 2 && val[obj.dd].length == 2))){
1061
+ if(val[obj.mm] > 12 && val[obj.dd] < 13){
1062
+ tmp = val[obj.dd];
1063
+ val[obj.dd] = val[obj.mm];
1064
+ val[obj.mm] = tmp;
1065
+ }
1066
+ if(val[obj.yy].length < 4){
1067
+ tmp = ((new Date()).getFullYear() +'').substr(0, 4 - val[obj.yy].length);
1068
+ if(val[obj.yy] > 50){
1069
+ tmp--;
1070
+ }
1071
+ val[obj.yy] = tmp + val[obj.yy];
1072
+ }
1073
+ ret = ([addZero(val[obj.yy]), addZero(val[obj.mm]), addZero(val[obj.dd])]).join('-');
1074
+ }
1075
+ return ret
1045
1076
  ;
1046
1077
  },
1047
1078
  color: function(val, opts){
@@ -1141,7 +1172,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1141
1172
  this.buttonWrapper = $('<span class="input-buttons '+this.type+'-input-buttons"></span>').insertAfter(this.element);
1142
1173
  this.options.containerElements.push(this.buttonWrapper[0]);
1143
1174
 
1144
- o.mirrorValidity = o.mirrorValidity && this.orig && Modernizr.formvalidation && !webshims.bugs.bustedValidity;
1175
+ o.mirrorValidity = o.mirrorValidity && this.orig && hasFormValidation;
1145
1176
 
1146
1177
  if(o.splitInput && this._addSplitInputs){
1147
1178
  if(o.monthSelect){
@@ -1245,7 +1276,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1245
1276
 
1246
1277
  if(this.type != 'color'){
1247
1278
  (function(){
1248
- var localeChange ;
1279
+ var localeChange, select, selectVal;
1249
1280
  if(!o.splitInput){
1250
1281
  localeChange = function(){
1251
1282
 
@@ -1260,6 +1291,12 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1260
1291
  } else {
1261
1292
  localeChange = function(){
1262
1293
  that.reorderInputs();
1294
+ if(o.monthSelect){
1295
+ select = that.inputElements.filter('select.mm');
1296
+ selectVal = select.prop('value');
1297
+ select.html(getMonthOptions(o));
1298
+ select.prop('value', selectVal);
1299
+ }
1263
1300
  };
1264
1301
  that.reorderInputs();
1265
1302
  }
@@ -1293,7 +1330,11 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1293
1330
  }
1294
1331
  if(options.splitInput && typeof placeholder == 'object'){
1295
1332
  $.each(this.splits, function(i, elem){
1296
- $.prop(elem, 'placeholder', placeholder[i]);
1333
+ if($.nodeName(elem, 'select')){
1334
+ $(elem).children('option:first-child').text(placeholder[i]);
1335
+ } else {
1336
+ $.prop(elem, 'placeholder', placeholder[i]);
1337
+ }
1297
1338
  });
1298
1339
  } else {
1299
1340
  this.element.prop('placeholder', placeholder);
@@ -1377,14 +1418,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1377
1418
  }
1378
1419
 
1379
1420
 
1380
- if(!o.min && typeof o.relMin == 'number'){
1381
- o.min = this.asValue(this.getRelNumber(o.relMin));
1382
- $.prop(this.orig, 'min', o.min);
1383
- }
1384
1421
 
1385
- if(!o.max && typeof o.relMax == 'number'){
1386
- o.max = this.asValue(this.getRelNumber(o.relMax));
1387
- $.prop(this.orig, 'max', o.max);
1422
+ if((!o.max && typeof o.relMax == 'number') || (!o.min && typeof o.relMin == 'number')){
1423
+ webshims.error('relMax/relMin are not supported anymore')
1388
1424
  }
1389
1425
  this._init = true;
1390
1426
  },
@@ -1453,6 +1489,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1453
1489
  if(!this._init || force || this.options[name] !== val){
1454
1490
  if(isValue){
1455
1491
  this._beforeValue(val);
1492
+ } else {
1493
+ this.elemHelper.prop(name, val);
1456
1494
  }
1457
1495
 
1458
1496
  val = formatVal[this.type](val, this.options);
@@ -1503,9 +1541,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1503
1541
 
1504
1542
  $.fn.spinbtnUI = function(opts){
1505
1543
  opts = $.extend({
1506
- monthNames: 'monthNames',
1507
- size: 1,
1508
- startView: 0
1544
+ monthNames: 'monthNames'
1509
1545
  }, opts);
1510
1546
  return this.each(function(){
1511
1547
  $.webshims.objectCreate(spinBtnProto, {
@@ -1577,10 +1613,12 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1577
1613
 
1578
1614
 
1579
1615
  picker.commonInit = function(data, popover){
1616
+ if(data._commonInit){return;}
1617
+ data._commonInit = true;
1580
1618
  var tabbable;
1581
1619
 
1582
1620
  popover.isDirty = true;
1583
-
1621
+
1584
1622
  popover.element.on('updatepickercontent pickerchange', function(){
1585
1623
  tabbable = false;
1586
1624
  });
@@ -1620,6 +1658,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1620
1658
  return function(prop){
1621
1659
  if(prop == 'value' && !data.options.inlinePicker){return;}
1622
1660
  popover.isDirty = true;
1661
+
1623
1662
  if(popover.isVisible){
1624
1663
  clearTimeout(timer);
1625
1664
  timer = setTimeout(update, 9);
@@ -1687,30 +1726,6 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1687
1726
 
1688
1727
  options.containerElements.push(popover.element[0]);
1689
1728
 
1690
- if(data.type != 'color'){
1691
- if(options.yearButtons){
1692
- options.startView = 2;
1693
- }
1694
- if(!options.startView){
1695
- options.startView = 0;
1696
- }
1697
-
1698
- if(data.type == 'time'){
1699
- options.minView = 3;
1700
- options.startView = 3;
1701
- }
1702
- if(!options.minView){
1703
- options.minView = 0;
1704
- }
1705
- if(options.startView < options.minView){
1706
- options.startView = options.minView;
1707
- webshims.warn("wrong config for minView/startView.");
1708
- }
1709
- if(!options.size){
1710
- options.size = 1;
1711
- }
1712
- }
1713
-
1714
1729
  popover.element
1715
1730
  .addClass(data.type+'-popover input-picker')
1716
1731
  .attr({role: 'application'})
@@ -1771,12 +1786,12 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1771
1786
  };
1772
1787
  data.inputElements.on({
1773
1788
  keydown: function(e){
1774
- if(e.keyCode == 40 && e.altKey){
1789
+ if(e.keyCode == 40 && e.altKey && !$.nodeName(e.target, 'select')){
1775
1790
  open();
1776
1791
  }
1777
1792
  },
1778
- focus: function(){
1779
- if(!popover.stopOpen && (options.buttonOnly || options.openOnFocus || (mouseFocus && options.openOnMouseFocus))){
1793
+ focus: function(e){
1794
+ if(!popover.stopOpen && (options.buttonOnly || options.openOnFocus || (mouseFocus && options.openOnMouseFocus)) && !$.nodeName(e.target, 'select')){
1780
1795
  popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
1781
1796
  show();
1782
1797
  } else {
@@ -1793,7 +1808,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1793
1808
  popover.activeElement.focus();
1794
1809
  }, 4);
1795
1810
  }
1796
- if(data.element.is(':focus')){
1811
+ if(data.element.is(':focus') && !$.nodeName(e.target, 'select')){
1797
1812
  popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
1798
1813
  show();
1799
1814
  }
@@ -2021,10 +2036,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2021
2036
  opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
2022
2037
  }
2023
2038
  }
2024
- if(opts.monthSelect){
2025
- opts.onlyMonthDigits = true;
2026
- }
2027
- if(opts.onlyMonthDigits){
2039
+
2040
+ if(opts.onlyMonthDigits || (!opts.formatMonthNames && opts.monthSelect)){
2028
2041
  opts.formatMonthNames = 'monthDigits';
2029
2042
  }
2030
2043
  data.shim = inputTypes[type]._create(opts);
@@ -2074,11 +2087,11 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2074
2087
 
2075
2088
  data.shim.element.on('change input', stopPropagation);
2076
2089
 
2077
- if(Modernizr.formvalidation){
2090
+ if(hasFormValidation){
2078
2091
  $(opts.orig).on('firstinvalid', function(e){
2079
2092
  if(!webshims.fromSubmit && isCheckValidity){return;}
2080
2093
  $(opts.orig).off('invalid.replacedwidgetbubble').on('invalid.replacedwidgetbubble', function(evt){
2081
- if(!e.isInvalidUIPrevented() && !evt.isDefaultPrevented()){
2094
+ if(!evt.isDefaultPrevented()){
2082
2095
  webshims.validityAlert.showFor( e.target );
2083
2096
  e.preventDefault();
2084
2097
  evt.preventDefault();
@@ -2105,7 +2118,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2105
2118
  };
2106
2119
 
2107
2120
 
2108
- if(Modernizr.formvalidation){
2121
+ if(hasFormValidation){
2109
2122
  ['input', 'form'].forEach(function(name){
2110
2123
  var desc = webshims.defineNodeNameProperty(name, 'checkValidity', {
2111
2124
  prop: {
@@ -2156,7 +2169,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2156
2169
  if(!modernizrInputTypes[name] || replace[name]){
2157
2170
  extendType(name, {
2158
2171
  _create: function(opts, set){
2159
- if(opts.monthSelect){
2172
+ if(opts.monthSelect || opts.daySelect){
2160
2173
  opts.splitInput = true;
2161
2174
  }
2162
2175
  if(opts.splitInput && !splitInputs[name]){
@@ -449,8 +449,7 @@ var swfmini = function() {
449
449
  }
450
450
  };
451
451
  }();
452
-
453
- (function(Modernizr, webshims){
452
+ ;(function(Modernizr, webshims){
454
453
  "use strict";
455
454
  var $ = webshims.$;
456
455
  var hasNative = Modernizr.audio && Modernizr.video;
@@ -1143,8 +1142,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
1143
1142
  }
1144
1143
  webshims.ready('track', loadTrackUi);
1145
1144
  });
1146
- })(Modernizr, webshims);
1147
- webshims.register('track', function($, webshims, window, document, undefined){
1145
+ })(Modernizr, webshims);;webshims.register('track', function($, webshims, window, document, undefined){
1148
1146
  "use strict";
1149
1147
  var mediaelement = webshims.mediaelement;
1150
1148
  var id = new Date().getTime();
@@ -691,8 +691,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
691
691
  }
692
692
  webshims.ready('track', loadTrackUi);
693
693
  });
694
- })(Modernizr, webshims);
695
- webshims.register('track', function($, webshims, window, document, undefined){
694
+ })(Modernizr, webshims);;webshims.register('track', function($, webshims, window, document, undefined){
696
695
  "use strict";
697
696
  var mediaelement = webshims.mediaelement;
698
697
  var id = new Date().getTime();
@@ -1,2904 +1,1041 @@
1
- // Copyright 2009-2012 by contributors, MIT License
2
- // vim: ts=4 sts=4 sw=4 expandtab
3
-
4
- (function () {
5
-
6
- /**
7
- * Brings an environment as close to ECMAScript 5 compliance
8
- * as is possible with the facilities of erstwhile engines.
9
- *
10
- * Annotated ES5: http://es5.github.com/ (specific links below)
11
- * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
12
- * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
13
- */
14
-
15
- //
16
- // Function
17
- // ========
18
- //
19
-
20
- // ES-5 15.3.4.5
21
- // http://es5.github.com/#x15.3.4.5
22
-
23
- function Empty() {}
24
-
25
- if (!Function.prototype.bind) {
26
- Function.prototype.bind = function bind(that) { // .length is 1
27
- // 1. Let Target be the this value.
28
- var target = this;
29
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
30
- if (typeof target != "function") {
31
- throw new TypeError("Function.prototype.bind called on incompatible " + target);
32
- }
33
- // 3. Let A be a new (possibly empty) internal list of all of the
34
- // argument values provided after thisArg (arg1, arg2 etc), in order.
35
- // XXX slicedArgs will stand in for "A" if used
36
- var args = _Array_slice_.call(arguments, 1); // for normal call
37
- // 4. Let F be a new native ECMAScript object.
38
- // 11. Set the [[Prototype]] internal property of F to the standard
39
- // built-in Function prototype object as specified in 15.3.3.1.
40
- // 12. Set the [[Call]] internal property of F as described in
41
- // 15.3.4.5.1.
42
- // 13. Set the [[Construct]] internal property of F as described in
43
- // 15.3.4.5.2.
44
- // 14. Set the [[HasInstance]] internal property of F as described in
45
- // 15.3.4.5.3.
46
- var bound = function () {
47
-
48
- if (this instanceof bound) {
49
- // 15.3.4.5.2 [[Construct]]
50
- // When the [[Construct]] internal method of a function object,
51
- // F that was created using the bind function is called with a
52
- // list of arguments ExtraArgs, the following steps are taken:
53
- // 1. Let target be the value of F's [[TargetFunction]]
54
- // internal property.
55
- // 2. If target has no [[Construct]] internal method, a
56
- // TypeError exception is thrown.
57
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
58
- // property.
59
- // 4. Let args be a new list containing the same values as the
60
- // list boundArgs in the same order followed by the same
61
- // values as the list ExtraArgs in the same order.
62
- // 5. Return the result of calling the [[Construct]] internal
63
- // method of target providing args as the arguments.
64
-
65
- var result = target.apply(
66
- this,
67
- args.concat(_Array_slice_.call(arguments))
68
- );
69
- if (Object(result) === result) {
70
- return result;
71
- }
72
- return this;
73
-
74
- } else {
75
- // 15.3.4.5.1 [[Call]]
76
- // When the [[Call]] internal method of a function object, F,
77
- // which was created using the bind function is called with a
78
- // this value and a list of arguments ExtraArgs, the following
79
- // steps are taken:
80
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
81
- // property.
82
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
83
- // property.
84
- // 3. Let target be the value of F's [[TargetFunction]] internal
85
- // property.
86
- // 4. Let args be a new list containing the same values as the
87
- // list boundArgs in the same order followed by the same
88
- // values as the list ExtraArgs in the same order.
89
- // 5. Return the result of calling the [[Call]] internal method
90
- // of target providing boundThis as the this value and
91
- // providing args as the arguments.
92
-
93
- // equiv: target.call(this, ...boundArgs, ...args)
94
- return target.apply(
95
- that,
96
- args.concat(_Array_slice_.call(arguments))
97
- );
98
-
99
- }
100
-
101
- };
102
- if(target.prototype) {
103
- Empty.prototype = target.prototype;
104
- bound.prototype = new Empty();
105
- // Clean up dangling references.
106
- Empty.prototype = null;
107
- }
108
- // XXX bound.length is never writable, so don't even try
109
- //
110
- // 15. If the [[Class]] internal property of Target is "Function", then
111
- // a. Let L be the length property of Target minus the length of A.
112
- // b. Set the length own property of F to either 0 or L, whichever is
113
- // larger.
114
- // 16. Else set the length own property of F to 0.
115
- // 17. Set the attributes of the length own property of F to the values
116
- // specified in 15.3.5.1.
117
-
118
- // TODO
119
- // 18. Set the [[Extensible]] internal property of F to true.
120
-
121
- // TODO
122
- // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
123
- // 20. Call the [[DefineOwnProperty]] internal method of F with
124
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
125
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
126
- // false.
127
- // 21. Call the [[DefineOwnProperty]] internal method of F with
128
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
129
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
130
- // and false.
131
-
132
- // TODO
133
- // NOTE Function objects created using Function.prototype.bind do not
134
- // have a prototype property or the [[Code]], [[FormalParameters]], and
135
- // [[Scope]] internal properties.
136
- // XXX can't delete prototype in pure-js.
137
-
138
- // 22. Return F.
139
- return bound;
140
- };
141
- }
142
-
143
- // Shortcut to an often accessed properties, in order to avoid multiple
144
- // dereference that costs universally.
145
- // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
146
- // us it in defining shortcuts.
147
- var call = Function.prototype.call;
148
- var prototypeOfArray = Array.prototype;
149
- var prototypeOfObject = Object.prototype;
150
- var _Array_slice_ = prototypeOfArray.slice;
151
- // Having a toString local variable name breaks in Opera so use _toString.
152
- var _toString = call.bind(prototypeOfObject.toString);
153
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
154
-
155
- // If JS engine supports accessors creating shortcuts.
156
- var defineGetter;
157
- var defineSetter;
158
- var lookupGetter;
159
- var lookupSetter;
160
- var supportsAccessors;
161
- if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
162
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
163
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
164
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
165
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
166
- }
167
-
168
- //
169
- // Array
170
- // =====
171
- //
172
-
173
- // ES5 15.4.4.12
174
- // http://es5.github.com/#x15.4.4.12
175
- // Default value for second param
176
- // [bugfix, ielt9, old browsers]
177
- // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
178
- if ([1,2].splice(0).length != 2) {
179
- var array_splice = Array.prototype.splice;
180
-
181
- if(function() { // test IE < 9 to splice bug - see issue #138
182
- function makeArray(l) {
183
- var a = [];
184
- while (l--) {
185
- a.unshift(l)
186
- }
187
- return a
188
- }
189
-
190
- var array = []
191
- , lengthBefore
192
- ;
193
-
194
- array.splice.bind(array, 0, 0).apply(null, makeArray(20));
195
- array.splice.bind(array, 0, 0).apply(null, makeArray(26));
196
-
197
- lengthBefore = array.length; //20
198
- array.splice(5, 0, "XXX"); // add one element
199
-
200
- if(lengthBefore + 1 == array.length) {
201
- return true;// has right splice implementation without bugs
202
- }
203
- // else {
204
- // IE8 bug
205
- // }
206
- }()) {//IE 6/7
207
- Array.prototype.splice = function(start, deleteCount) {
208
- if (!arguments.length) {
209
- return [];
210
- } else {
211
- return array_splice.apply(this, [
212
- start === void 0 ? 0 : start,
213
- deleteCount === void 0 ? (this.length - start) : deleteCount
214
- ].concat(_Array_slice_.call(arguments, 2)))
215
- }
216
- };
217
- }
218
- else {//IE8
219
- Array.prototype.splice = function(start, deleteCount) {
220
- var result
221
- , args = _Array_slice_.call(arguments, 2)
222
- , addElementsCount = args.length
223
- ;
224
-
225
- if(!arguments.length) {
226
- return [];
227
- }
228
-
229
- if(start === void 0) { // default
230
- start = 0;
231
- }
232
- if(deleteCount === void 0) { // default
233
- deleteCount = this.length - start;
234
- }
235
-
236
- if(addElementsCount > 0) {
237
- if(deleteCount <= 0) {
238
- if(start == this.length) { // tiny optimisation #1
239
- this.push.apply(this, args);
240
- return [];
241
- }
242
-
243
- if(start == 0) { // tiny optimisation #2
244
- this.unshift.apply(this, args);
245
- return [];
246
- }
247
- }
248
-
249
- // Array.prototype.splice implementation
250
- result = _Array_slice_.call(this, start, start + deleteCount);// delete part
251
- args.push.apply(args, _Array_slice_.call(this, start + deleteCount, this.length));// right part
252
- args.unshift.apply(args, _Array_slice_.call(this, 0, start));// left part
253
-
254
- // delete all items from this array and replace it to 'left part' + _Array_slice_.call(arguments, 2) + 'right part'
255
- args.unshift(0, this.length);
256
-
257
- array_splice.apply(this, args);
258
-
259
- return result;
260
- }
261
-
262
- return array_splice.call(this, start, deleteCount);
263
- }
264
-
265
- }
266
- }
267
-
268
- // ES5 15.4.4.12
269
- // http://es5.github.com/#x15.4.4.13
270
- // Return len+argCount.
271
- // [bugfix, ielt8]
272
- // IE < 8 bug: [].unshift(0) == undefined but should be "1"
273
- if ([].unshift(0) != 1) {
274
- var array_unshift = Array.prototype.unshift;
275
- Array.prototype.unshift = function() {
276
- array_unshift.apply(this, arguments);
277
- return this.length;
278
- };
279
- }
280
-
281
- // ES5 15.4.3.2
282
- // http://es5.github.com/#x15.4.3.2
283
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
284
- if (!Array.isArray) {
285
- Array.isArray = function isArray(obj) {
286
- return _toString(obj) == "[object Array]";
287
- };
288
- }
289
-
290
- // The IsCallable() check in the Array functions
291
- // has been replaced with a strict check on the
292
- // internal class of the object to trap cases where
293
- // the provided function was actually a regular
294
- // expression literal, which in V8 and
295
- // JavaScriptCore is a typeof "function". Only in
296
- // V8 are regular expression literals permitted as
297
- // reduce parameters, so it is desirable in the
298
- // general case for the shim to match the more
299
- // strict and common behavior of rejecting regular
300
- // expressions.
301
-
302
- // ES5 15.4.4.18
303
- // http://es5.github.com/#x15.4.4.18
304
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
305
-
306
- // Check failure of by-index access of string characters (IE < 9)
307
- // and failure of `0 in boxedString` (Rhino)
308
- var boxedString = Object("a"),
309
- splitString = boxedString[0] != "a" || !(0 in boxedString);
310
-
311
- if (!Array.prototype.forEach) {
312
- Array.prototype.forEach = function forEach(fun /*, thisp*/) {
313
- var object = toObject(this),
314
- self = splitString && _toString(this) == "[object String]" ?
315
- this.split("") :
316
- object,
317
- thisp = arguments[1],
318
- i = -1,
319
- length = self.length >>> 0;
320
-
321
- // If no callback function or if callback is not a callable function
322
- if (_toString(fun) != "[object Function]") {
323
- throw new TypeError(); // TODO message
324
- }
325
-
326
- while (++i < length) {
327
- if (i in self) {
328
- // Invoke the callback function with call, passing arguments:
329
- // context, property value, property key, thisArg object
330
- // context
331
- fun.call(thisp, self[i], i, object);
332
- }
333
- }
334
- };
335
- }
336
-
337
- // ES5 15.4.4.19
338
- // http://es5.github.com/#x15.4.4.19
339
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
340
- if (!Array.prototype.map) {
341
- Array.prototype.map = function map(fun /*, thisp*/) {
342
- var object = toObject(this),
343
- self = splitString && _toString(this) == "[object String]" ?
344
- this.split("") :
345
- object,
346
- length = self.length >>> 0,
347
- result = Array(length),
348
- thisp = arguments[1];
349
-
350
- // If no callback function or if callback is not a callable function
351
- if (_toString(fun) != "[object Function]") {
352
- throw new TypeError(fun + " is not a function");
353
- }
354
-
355
- for (var i = 0; i < length; i++) {
356
- if (i in self)
357
- result[i] = fun.call(thisp, self[i], i, object);
358
- }
359
- return result;
360
- };
361
- }
362
-
363
- // ES5 15.4.4.20
364
- // http://es5.github.com/#x15.4.4.20
365
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
366
- if (!Array.prototype.filter) {
367
- Array.prototype.filter = function filter(fun /*, thisp */) {
368
- var object = toObject(this),
369
- self = splitString && _toString(this) == "[object String]" ?
370
- this.split("") :
371
- object,
372
- length = self.length >>> 0,
373
- result = [],
374
- value,
375
- thisp = arguments[1];
376
-
377
- // If no callback function or if callback is not a callable function
378
- if (_toString(fun) != "[object Function]") {
379
- throw new TypeError(fun + " is not a function");
380
- }
381
-
382
- for (var i = 0; i < length; i++) {
383
- if (i in self) {
384
- value = self[i];
385
- if (fun.call(thisp, value, i, object)) {
386
- result.push(value);
387
- }
388
- }
389
- }
390
- return result;
391
- };
392
- }
393
-
394
- // ES5 15.4.4.16
395
- // http://es5.github.com/#x15.4.4.16
396
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
397
- if (!Array.prototype.every) {
398
- Array.prototype.every = function every(fun /*, thisp */) {
399
- var object = toObject(this),
400
- self = splitString && _toString(this) == "[object String]" ?
401
- this.split("") :
402
- object,
403
- length = self.length >>> 0,
404
- thisp = arguments[1];
405
-
406
- // If no callback function or if callback is not a callable function
407
- if (_toString(fun) != "[object Function]") {
408
- throw new TypeError(fun + " is not a function");
409
- }
410
-
411
- for (var i = 0; i < length; i++) {
412
- if (i in self && !fun.call(thisp, self[i], i, object)) {
413
- return false;
414
- }
415
- }
416
- return true;
417
- };
418
- }
419
-
420
- // ES5 15.4.4.17
421
- // http://es5.github.com/#x15.4.4.17
422
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
423
- if (!Array.prototype.some) {
424
- Array.prototype.some = function some(fun /*, thisp */) {
425
- var object = toObject(this),
426
- self = splitString && _toString(this) == "[object String]" ?
427
- this.split("") :
428
- object,
429
- length = self.length >>> 0,
430
- thisp = arguments[1];
431
-
432
- // If no callback function or if callback is not a callable function
433
- if (_toString(fun) != "[object Function]") {
434
- throw new TypeError(fun + " is not a function");
435
- }
436
-
437
- for (var i = 0; i < length; i++) {
438
- if (i in self && fun.call(thisp, self[i], i, object)) {
439
- return true;
440
- }
441
- }
442
- return false;
443
- };
444
- }
445
-
446
- // ES5 15.4.4.21
447
- // http://es5.github.com/#x15.4.4.21
448
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
449
- if (!Array.prototype.reduce) {
450
- Array.prototype.reduce = function reduce(fun /*, initial*/) {
451
- var object = toObject(this),
452
- self = splitString && _toString(this) == "[object String]" ?
453
- this.split("") :
454
- object,
455
- length = self.length >>> 0;
456
-
457
- // If no callback function or if callback is not a callable function
458
- if (_toString(fun) != "[object Function]") {
459
- throw new TypeError(fun + " is not a function");
460
- }
461
-
462
- // no value to return if no initial value and an empty array
463
- if (!length && arguments.length == 1) {
464
- throw new TypeError("reduce of empty array with no initial value");
465
- }
466
-
467
- var i = 0;
468
- var result;
469
- if (arguments.length >= 2) {
470
- result = arguments[1];
471
- } else {
472
- do {
473
- if (i in self) {
474
- result = self[i++];
475
- break;
476
- }
477
-
478
- // if array contains no values, no initial value to return
479
- if (++i >= length) {
480
- throw new TypeError("reduce of empty array with no initial value");
481
- }
482
- } while (true);
483
- }
484
-
485
- for (; i < length; i++) {
486
- if (i in self) {
487
- result = fun.call(void 0, result, self[i], i, object);
488
- }
489
- }
490
-
491
- return result;
492
- };
493
- }
494
-
495
- // ES5 15.4.4.22
496
- // http://es5.github.com/#x15.4.4.22
497
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
498
- if (!Array.prototype.reduceRight) {
499
- Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
500
- var object = toObject(this),
501
- self = splitString && _toString(this) == "[object String]" ?
502
- this.split("") :
503
- object,
504
- length = self.length >>> 0;
505
-
506
- // If no callback function or if callback is not a callable function
507
- if (_toString(fun) != "[object Function]") {
508
- throw new TypeError(fun + " is not a function");
509
- }
510
-
511
- // no value to return if no initial value, empty array
512
- if (!length && arguments.length == 1) {
513
- throw new TypeError("reduceRight of empty array with no initial value");
514
- }
515
-
516
- var result, i = length - 1;
517
- if (arguments.length >= 2) {
518
- result = arguments[1];
519
- } else {
520
- do {
521
- if (i in self) {
522
- result = self[i--];
523
- break;
524
- }
525
-
526
- // if array contains no values, no initial value to return
527
- if (--i < 0) {
528
- throw new TypeError("reduceRight of empty array with no initial value");
529
- }
530
- } while (true);
531
- }
532
-
533
- if (i < 0) {
534
- return result;
535
- }
536
-
537
- do {
538
- if (i in this) {
539
- result = fun.call(void 0, result, self[i], i, object);
540
- }
541
- } while (i--);
542
-
543
- return result;
544
- };
545
- }
546
-
547
- // ES5 15.4.4.14
548
- // http://es5.github.com/#x15.4.4.14
549
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
550
- if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
551
- Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
552
- var self = splitString && _toString(this) == "[object String]" ?
553
- this.split("") :
554
- toObject(this),
555
- length = self.length >>> 0;
556
-
557
- if (!length) {
558
- return -1;
559
- }
560
-
561
- var i = 0;
562
- if (arguments.length > 1) {
563
- i = toInteger(arguments[1]);
564
- }
565
-
566
- // handle negative indices
567
- i = i >= 0 ? i : Math.max(0, length + i);
568
- for (; i < length; i++) {
569
- if (i in self && self[i] === sought) {
570
- return i;
571
- }
572
- }
573
- return -1;
574
- };
575
- }
576
-
577
- // ES5 15.4.4.15
578
- // http://es5.github.com/#x15.4.4.15
579
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
580
- if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
581
- Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
582
- var self = splitString && _toString(this) == "[object String]" ?
583
- this.split("") :
584
- toObject(this),
585
- length = self.length >>> 0;
586
-
587
- if (!length) {
588
- return -1;
589
- }
590
- var i = length - 1;
591
- if (arguments.length > 1) {
592
- i = Math.min(i, toInteger(arguments[1]));
593
- }
594
- // handle negative indices
595
- i = i >= 0 ? i : length - Math.abs(i);
596
- for (; i >= 0; i--) {
597
- if (i in self && sought === self[i]) {
598
- return i;
599
- }
600
- }
601
- return -1;
602
- };
603
- }
604
-
605
- //
606
- // Object
607
- // ======
608
- //
609
-
610
- // ES5 15.2.3.14
611
- // http://es5.github.com/#x15.2.3.14
612
- if (!Object.keys) {
613
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
614
- var hasDontEnumBug = true,
615
- dontEnums = [
616
- "toString",
617
- "toLocaleString",
618
- "valueOf",
619
- "hasOwnProperty",
620
- "isPrototypeOf",
621
- "propertyIsEnumerable",
622
- "constructor"
623
- ],
624
- dontEnumsLength = dontEnums.length;
625
-
626
- for (var key in {"toString": null}) {
627
- hasDontEnumBug = false;
628
- }
629
-
630
- Object.keys = function keys(object) {
631
-
632
- if (
633
- (typeof object != "object" && typeof object != "function") ||
634
- object === null
635
- ) {
636
- throw new TypeError("Object.keys called on a non-object");
637
- }
638
-
639
- var keys = [];
640
- for (var name in object) {
641
- if (owns(object, name)) {
642
- keys.push(name);
643
- }
644
- }
645
-
646
- if (hasDontEnumBug) {
647
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
648
- var dontEnum = dontEnums[i];
649
- if (owns(object, dontEnum)) {
650
- keys.push(dontEnum);
651
- }
652
- }
653
- }
654
- return keys;
655
- };
656
-
657
- }
658
-
659
- //
660
- // Date
661
- // ====
662
- //
663
-
664
- // ES5 15.9.5.43
665
- // http://es5.github.com/#x15.9.5.43
666
- // This function returns a String value represent the instance in time
667
- // represented by this Date object. The format of the String is the Date Time
668
- // string format defined in 15.9.1.15. All fields are present in the String.
669
- // The time zone is always UTC, denoted by the suffix Z. If the time value of
670
- // this object is not a finite Number a RangeError exception is thrown.
671
- var negativeDate = -62198755200000,
672
- negativeYearString = "-000001";
673
- if (
674
- !Date.prototype.toISOString ||
675
- (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
676
- ) {
677
- Date.prototype.toISOString = function toISOString() {
678
- var result, length, value, year, month;
679
- if (!isFinite(this)) {
680
- throw new RangeError("Date.prototype.toISOString called on non-finite value.");
681
- }
682
-
683
- year = this.getUTCFullYear();
684
-
685
- month = this.getUTCMonth();
686
- // see https://github.com/kriskowal/es5-shim/issues/111
687
- year += Math.floor(month / 12);
688
- month = (month % 12 + 12) % 12;
689
-
690
- // the date time string format is specified in 15.9.1.15.
691
- result = [month + 1, this.getUTCDate(),
692
- this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
693
- year = (
694
- (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
695
- ("00000" + Math.abs(year))
696
- .slice(0 <= year && year <= 9999 ? -4 : -6)
697
- );
698
-
699
- length = result.length;
700
- while (length--) {
701
- value = result[length];
702
- // pad months, days, hours, minutes, and seconds to have two
703
- // digits.
704
- if (value < 10) {
705
- result[length] = "0" + value;
706
- }
707
- }
708
- // pad milliseconds to have three digits.
709
- return (
710
- year + "-" + result.slice(0, 2).join("-") +
711
- "T" + result.slice(2).join(":") + "." +
712
- ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
713
- );
714
- };
715
- }
716
-
717
-
718
- // ES5 15.9.5.44
719
- // http://es5.github.com/#x15.9.5.44
720
- // This function provides a String representation of a Date object for use by
721
- // JSON.stringify (15.12.3).
722
- var dateToJSONIsSupported = false;
723
- try {
724
- dateToJSONIsSupported = (
725
- Date.prototype.toJSON &&
726
- new Date(NaN).toJSON() === null &&
727
- new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
728
- Date.prototype.toJSON.call({ // generic
729
- toISOString: function () {
730
- return true;
731
- }
732
- })
733
- );
734
- } catch (e) {
735
- }
736
- if (!dateToJSONIsSupported) {
737
- Date.prototype.toJSON = function toJSON(key) {
738
- // When the toJSON method is called with argument key, the following
739
- // steps are taken:
740
-
741
- // 1. Let O be the result of calling ToObject, giving it the this
742
- // value as its argument.
743
- // 2. Let tv be toPrimitive(O, hint Number).
744
- var o = Object(this),
745
- tv = toPrimitive(o),
746
- toISO;
747
- // 3. If tv is a Number and is not finite, return null.
748
- if (typeof tv === "number" && !isFinite(tv)) {
749
- return null;
750
- }
751
- // 4. Let toISO be the result of calling the [[Get]] internal method of
752
- // O with argument "toISOString".
753
- toISO = o.toISOString;
754
- // 5. If IsCallable(toISO) is false, throw a TypeError exception.
755
- if (typeof toISO != "function") {
756
- throw new TypeError("toISOString property is not callable");
757
- }
758
- // 6. Return the result of calling the [[Call]] internal method of
759
- // toISO with O as the this value and an empty argument list.
760
- return toISO.call(o);
761
-
762
- // NOTE 1 The argument is ignored.
763
-
764
- // NOTE 2 The toJSON function is intentionally generic; it does not
765
- // require that its this value be a Date object. Therefore, it can be
766
- // transferred to other kinds of objects for use as a method. However,
767
- // it does require that any such object have a toISOString method. An
768
- // object is free to use the argument key to filter its
769
- // stringification.
770
- };
771
- }
772
-
773
- // ES5 15.9.4.2
774
- // http://es5.github.com/#x15.9.4.2
775
- // based on work shared by Daniel Friesen (dantman)
776
- // http://gist.github.com/303249
777
- if (!Date.parse || "Date.parse is buggy") {
778
- // XXX global assignment won't work in embeddings that use
779
- // an alternate object for the context.
780
- Date = (function(NativeDate) {
781
-
782
- // Date.length === 7
783
- function Date(Y, M, D, h, m, s, ms) {
784
- var length = arguments.length;
785
- if (this instanceof NativeDate) {
786
- var date = length == 1 && String(Y) === Y ? // isString(Y)
787
- // We explicitly pass it through parse:
788
- new NativeDate(Date.parse(Y)) :
789
- // We have to manually make calls depending on argument
790
- // length here
791
- length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
792
- length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
793
- length >= 5 ? new NativeDate(Y, M, D, h, m) :
794
- length >= 4 ? new NativeDate(Y, M, D, h) :
795
- length >= 3 ? new NativeDate(Y, M, D) :
796
- length >= 2 ? new NativeDate(Y, M) :
797
- length >= 1 ? new NativeDate(Y) :
798
- new NativeDate();
799
- // Prevent mixups with unfixed Date object
800
- date.constructor = Date;
801
- return date;
802
- }
803
- return NativeDate.apply(this, arguments);
804
- };
805
-
806
- // 15.9.1.15 Date Time String Format.
807
- var isoDateExpression = new RegExp("^" +
808
- "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
809
- // 6-digit extended year
810
- "(?:-(\\d{2})" + // optional month capture
811
- "(?:-(\\d{2})" + // optional day capture
812
- "(?:" + // capture hours:minutes:seconds.milliseconds
813
- "T(\\d{2})" + // hours capture
814
- ":(\\d{2})" + // minutes capture
815
- "(?:" + // optional :seconds.milliseconds
816
- ":(\\d{2})" + // seconds capture
817
- "(?:(\\.\\d{1,}))?" + // milliseconds capture
818
- ")?" +
819
- "(" + // capture UTC offset component
820
- "Z|" + // UTC capture
821
- "(?:" + // offset specifier +/-hours:minutes
822
- "([-+])" + // sign capture
823
- "(\\d{2})" + // hours offset capture
824
- ":(\\d{2})" + // minutes offset capture
825
- ")" +
826
- ")?)?)?)?" +
827
- "$");
828
-
829
- var months = [
830
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
831
- ];
832
-
833
- function dayFromMonth(year, month) {
834
- var t = month > 1 ? 1 : 0;
835
- return (
836
- months[month] +
837
- Math.floor((year - 1969 + t) / 4) -
838
- Math.floor((year - 1901 + t) / 100) +
839
- Math.floor((year - 1601 + t) / 400) +
840
- 365 * (year - 1970)
841
- );
842
- }
843
-
844
- // Copy any custom methods a 3rd party library may have added
845
- for (var key in NativeDate) {
846
- Date[key] = NativeDate[key];
847
- }
848
-
849
- // Copy "native" methods explicitly; they may be non-enumerable
850
- Date.now = NativeDate.now;
851
- Date.UTC = NativeDate.UTC;
852
- Date.prototype = NativeDate.prototype;
853
- Date.prototype.constructor = Date;
854
-
855
- // Upgrade Date.parse to handle simplified ISO 8601 strings
856
- Date.parse = function parse(string) {
857
- var match = isoDateExpression.exec(string);
858
- if (match) {
859
- // parse months, days, hours, minutes, seconds, and milliseconds
860
- // provide default values if necessary
861
- // parse the UTC offset component
862
- var year = Number(match[1]),
863
- month = Number(match[2] || 1) - 1,
864
- day = Number(match[3] || 1) - 1,
865
- hour = Number(match[4] || 0),
866
- minute = Number(match[5] || 0),
867
- second = Number(match[6] || 0),
868
- millisecond = Math.floor(Number(match[7] || 0) * 1000),
869
- // When time zone is missed, local offset should be used
870
- // (ES 5.1 bug)
871
- // see https://bugs.ecmascript.org/show_bug.cgi?id=112
872
- offset = !match[4] || match[8] ?
873
- 0 : Number(new NativeDate(1970, 0)),
874
- signOffset = match[9] === "-" ? 1 : -1,
875
- hourOffset = Number(match[10] || 0),
876
- minuteOffset = Number(match[11] || 0),
877
- result;
878
- if (
879
- hour < (
880
- minute > 0 || second > 0 || millisecond > 0 ?
881
- 24 : 25
882
- ) &&
883
- minute < 60 && second < 60 && millisecond < 1000 &&
884
- month > -1 && month < 12 && hourOffset < 24 &&
885
- minuteOffset < 60 && // detect invalid offsets
886
- day > -1 &&
887
- day < (
888
- dayFromMonth(year, month + 1) -
889
- dayFromMonth(year, month)
890
- )
891
- ) {
892
- result = (
893
- (dayFromMonth(year, month) + day) * 24 +
894
- hour +
895
- hourOffset * signOffset
896
- ) * 60;
897
- result = (
898
- (result + minute + minuteOffset * signOffset) * 60 +
899
- second
900
- ) * 1000 + millisecond + offset;
901
- if (-8.64e15 <= result && result <= 8.64e15) {
902
- return result;
903
- }
904
- }
905
- return NaN;
906
- }
907
- return NativeDate.parse.apply(this, arguments);
908
- };
909
-
910
- return Date;
911
- })(Date);
912
- }
913
-
914
- // ES5 15.9.4.4
915
- // http://es5.github.com/#x15.9.4.4
916
- if (!Date.now) {
917
- Date.now = function now() {
918
- return new Date().getTime();
919
- };
920
- }
921
-
922
-
923
- //
924
- // Number
925
- // ======
926
- //
927
-
928
- // ES5.1 15.7.4.5
929
- // http://es5.github.com/#x15.7.4.5
930
- if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' || (1000000000000000128).toFixed(0) !== "1000000000000000128") {
931
- // Hide these variables and functions
932
- (function () {
933
- var base, size, data, i;
934
-
935
- base = 1e7;
936
- size = 6;
937
- data = [0, 0, 0, 0, 0, 0];
938
-
939
- function multiply(n, c) {
940
- var i = -1;
941
- while (++i < size) {
942
- c += n * data[i];
943
- data[i] = c % base;
944
- c = Math.floor(c / base);
945
- }
946
- }
947
-
948
- function divide(n) {
949
- var i = size, c = 0;
950
- while (--i >= 0) {
951
- c += data[i];
952
- data[i] = Math.floor(c / n);
953
- c = (c % n) * base;
954
- }
955
- }
956
-
957
- function toString() {
958
- var i = size;
959
- var s = '';
960
- while (--i >= 0) {
961
- if (s !== '' || i === 0 || data[i] !== 0) {
962
- var t = String(data[i]);
963
- if (s === '') {
964
- s = t;
965
- } else {
966
- s += '0000000'.slice(0, 7 - t.length) + t;
967
- }
968
- }
969
- }
970
- return s;
971
- }
972
-
973
- function pow(x, n, acc) {
974
- return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
975
- }
976
-
977
- function log(x) {
978
- var n = 0;
979
- while (x >= 4096) {
980
- n += 12;
981
- x /= 4096;
982
- }
983
- while (x >= 2) {
984
- n += 1;
985
- x /= 2;
986
- }
987
- return n;
988
- }
989
-
990
- Number.prototype.toFixed = function (fractionDigits) {
991
- var f, x, s, m, e, z, j, k;
992
-
993
- // Test for NaN and round fractionDigits down
994
- f = Number(fractionDigits);
995
- f = f !== f ? 0 : Math.floor(f);
996
-
997
- if (f < 0 || f > 20) {
998
- throw new RangeError("Number.toFixed called with invalid number of decimals");
999
- }
1000
-
1001
- x = Number(this);
1002
-
1003
- // Test for NaN
1004
- if (x !== x) {
1005
- return "NaN";
1006
- }
1007
-
1008
- // If it is too big or small, return the string value of the number
1009
- if (x <= -1e21 || x >= 1e21) {
1010
- return String(x);
1011
- }
1012
-
1013
- s = "";
1014
-
1015
- if (x < 0) {
1016
- s = "-";
1017
- x = -x;
1018
- }
1019
-
1020
- m = "0";
1021
-
1022
- if (x > 1e-21) {
1023
- // 1e-21 < x < 1e21
1024
- // -70 < log2(x) < 70
1025
- e = log(x * pow(2, 69, 1)) - 69;
1026
- z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1027
- z *= 0x10000000000000; // Math.pow(2, 52);
1028
- e = 52 - e;
1029
-
1030
- // -18 < e < 122
1031
- // x = z / 2 ^ e
1032
- if (e > 0) {
1033
- multiply(0, z);
1034
- j = f;
1035
-
1036
- while (j >= 7) {
1037
- multiply(1e7, 0);
1038
- j -= 7;
1039
- }
1040
-
1041
- multiply(pow(10, j, 1), 0);
1042
- j = e - 1;
1043
-
1044
- while (j >= 23) {
1045
- divide(1 << 23);
1046
- j -= 23;
1047
- }
1048
-
1049
- divide(1 << j);
1050
- multiply(1, 1);
1051
- divide(2);
1052
- m = toString();
1053
- } else {
1054
- multiply(0, z);
1055
- multiply(1 << (-e), 0);
1056
- m = toString() + '0.00000000000000000000'.slice(2, 2 + f);
1057
- }
1058
- }
1059
-
1060
- if (f > 0) {
1061
- k = m.length;
1062
-
1063
- if (k <= f) {
1064
- m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1065
- } else {
1066
- m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1067
- }
1068
- } else {
1069
- m = s + m;
1070
- }
1071
-
1072
- return m;
1073
- }
1074
- }());
1075
- }
1076
-
1077
-
1078
- //
1079
- // String
1080
- // ======
1081
- //
1082
-
1083
-
1084
- // ES5 15.5.4.14
1085
- // http://es5.github.com/#x15.5.4.14
1086
-
1087
- // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
1088
- // Many browsers do not split properly with regular expressions or they
1089
- // do not perform the split correctly under obscure conditions.
1090
- // See http://blog.stevenlevithan.com/archives/cross-browser-split
1091
- // I've tested in many browsers and this seems to cover the deviant ones:
1092
- // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1093
- // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1094
- // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1095
- // [undefined, "t", undefined, "e", ...]
1096
- // ''.split(/.?/) should be [], not [""]
1097
- // '.'.split(/()()/) should be ["."], not ["", "", "."]
1098
-
1099
- var string_split = String.prototype.split;
1100
- if (
1101
- 'ab'.split(/(?:ab)*/).length !== 2 ||
1102
- '.'.split(/(.?)(.?)/).length !== 4 ||
1103
- 'tesst'.split(/(s)*/)[1] === "t" ||
1104
- ''.split(/.?/).length === 0 ||
1105
- '.'.split(/()()/).length > 1
1106
- ) {
1107
- (function () {
1108
- var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1109
-
1110
- String.prototype.split = function (separator, limit) {
1111
- var string = this;
1112
- if (separator === void 0 && limit === 0)
1113
- return [];
1114
-
1115
- // If `separator` is not a regex, use native split
1116
- if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
1117
- return string_split.apply(this, arguments);
1118
- }
1119
-
1120
- var output = [],
1121
- flags = (separator.ignoreCase ? "i" : "") +
1122
- (separator.multiline ? "m" : "") +
1123
- (separator.extended ? "x" : "") + // Proposed for ES6
1124
- (separator.sticky ? "y" : ""), // Firefox 3+
1125
- lastLastIndex = 0,
1126
- // Make `global` and avoid `lastIndex` issues by working with a copy
1127
- separator = new RegExp(separator.source, flags + "g"),
1128
- separator2, match, lastIndex, lastLength;
1129
- string += ""; // Type-convert
1130
- if (!compliantExecNpcg) {
1131
- // Doesn't need flags gy, but they don't hurt
1132
- separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1133
- }
1134
- /* Values for `limit`, per the spec:
1135
- * If undefined: 4294967295 // Math.pow(2, 32) - 1
1136
- * If 0, Infinity, or NaN: 0
1137
- * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1138
- * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1139
- * If other: Type-convert, then use the above rules
1140
- */
1141
- limit = limit === void 0 ?
1142
- -1 >>> 0 : // Math.pow(2, 32) - 1
1143
- limit >>> 0; // ToUint32(limit)
1144
- while (match = separator.exec(string)) {
1145
- // `separator.lastIndex` is not reliable cross-browser
1146
- lastIndex = match.index + match[0].length;
1147
- if (lastIndex > lastLastIndex) {
1148
- output.push(string.slice(lastLastIndex, match.index));
1149
- // Fix browsers whose `exec` methods don't consistently return `undefined` for
1150
- // nonparticipating capturing groups
1151
- if (!compliantExecNpcg && match.length > 1) {
1152
- match[0].replace(separator2, function () {
1153
- for (var i = 1; i < arguments.length - 2; i++) {
1154
- if (arguments[i] === void 0) {
1155
- match[i] = void 0;
1156
- }
1157
- }
1158
- });
1159
- }
1160
- if (match.length > 1 && match.index < string.length) {
1161
- Array.prototype.push.apply(output, match.slice(1));
1162
- }
1163
- lastLength = match[0].length;
1164
- lastLastIndex = lastIndex;
1165
- if (output.length >= limit) {
1166
- break;
1167
- }
1168
- }
1169
- if (separator.lastIndex === match.index) {
1170
- separator.lastIndex++; // Avoid an infinite loop
1171
- }
1172
- }
1173
- if (lastLastIndex === string.length) {
1174
- if (lastLength || !separator.test("")) {
1175
- output.push("");
1176
- }
1177
- } else {
1178
- output.push(string.slice(lastLastIndex));
1179
- }
1180
- return output.length > limit ? output.slice(0, limit) : output;
1181
- };
1182
- }());
1183
-
1184
- // [bugfix, chrome]
1185
- // If separator is undefined, then the result array contains just one String,
1186
- // which is the this value (converted to a String). If limit is not undefined,
1187
- // then the output array is truncated so that it contains no more than limit
1188
- // elements.
1189
- // "0".split(undefined, 0) -> []
1190
- } else if ("0".split(void 0, 0).length) {
1191
- String.prototype.split = function(separator, limit) {
1192
- if (separator === void 0 && limit === 0) return [];
1193
- return string_split.apply(this, arguments);
1194
- }
1195
- }
1196
-
1197
-
1198
- // ECMA-262, 3rd B.2.3
1199
- // Note an ECMAScript standart, although ECMAScript 3rd Edition has a
1200
- // non-normative section suggesting uniform semantics and it should be
1201
- // normalized across all browsers
1202
- // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1203
- if("".substr && "0b".substr(-1) !== "b") {
1204
- var string_substr = String.prototype.substr;
1205
- /**
1206
- * Get the substring of a string
1207
- * @param {integer} start where to start the substring
1208
- * @param {integer} length how many characters to return
1209
- * @return {string}
1210
- */
1211
- String.prototype.substr = function(start, length) {
1212
- return string_substr.call(
1213
- this,
1214
- start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1215
- length
1216
- );
1217
- }
1218
- }
1219
-
1220
- // ES5 15.5.4.20
1221
- // http://es5.github.com/#x15.5.4.20
1222
- var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1223
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1224
- "\u2029\uFEFF";
1225
- if (!String.prototype.trim || ws.trim()) {
1226
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1227
- // http://perfectionkills.com/whitespace-deviations/
1228
- ws = "[" + ws + "]";
1229
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1230
- trimEndRegexp = new RegExp(ws + ws + "*$");
1231
- String.prototype.trim = function trim() {
1232
- if (this === void 0 || this === null) {
1233
- throw new TypeError("can't convert "+this+" to object");
1234
- }
1235
- return String(this)
1236
- .replace(trimBeginRegexp, "")
1237
- .replace(trimEndRegexp, "");
1238
- };
1239
- }
1240
-
1241
- //
1242
- // Util
1243
- // ======
1244
- //
1245
-
1246
- // ES5 9.4
1247
- // http://es5.github.com/#x9.4
1248
- // http://jsperf.com/to-integer
1249
-
1250
- function toInteger(n) {
1251
- n = +n;
1252
- if (n !== n) { // isNaN
1253
- n = 0;
1254
- } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
1255
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
1256
- }
1257
- return n;
1258
- }
1259
-
1260
- function isPrimitive(input) {
1261
- var type = typeof input;
1262
- return (
1263
- input === null ||
1264
- type === "undefined" ||
1265
- type === "boolean" ||
1266
- type === "number" ||
1267
- type === "string"
1268
- );
1269
- }
1270
-
1271
- function toPrimitive(input) {
1272
- var val, valueOf, toString;
1273
- if (isPrimitive(input)) {
1274
- return input;
1275
- }
1276
- valueOf = input.valueOf;
1277
- if (typeof valueOf === "function") {
1278
- val = valueOf.call(input);
1279
- if (isPrimitive(val)) {
1280
- return val;
1281
- }
1282
- }
1283
- toString = input.toString;
1284
- if (typeof toString === "function") {
1285
- val = toString.call(input);
1286
- if (isPrimitive(val)) {
1287
- return val;
1288
- }
1289
- }
1290
- throw new TypeError();
1291
- }
1292
-
1293
- // ES5 9.9
1294
- // http://es5.github.com/#x9.9
1295
- var toObject = function (o) {
1296
- if (o == null) { // this matches both null and undefined
1297
- throw new TypeError("can't convert "+o+" to object");
1298
- }
1299
- return Object(o);
1300
- };
1301
-
1302
- })();
1303
-
1304
-
1305
-
1306
-
1307
- (function($, shims){
1308
- var defineProperty = 'defineProperty';
1309
- var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
1310
- //safari5 has defineProperty-interface, but it can't be used on dom-object
1311
- //only do this test in non-IE browsers, because this hurts dhtml-behavior in some IE8 versions
1312
- if (advancedObjectProperties && Object[defineProperty] && Object.prototype.__defineGetter__) {
1313
- (function(){
1314
- try {
1315
- var foo = document.createElement('foo');
1316
- Object[defineProperty](foo, 'bar', {
1317
- get: function(){
1318
- return true;
1319
- }
1320
- });
1321
- advancedObjectProperties = !!foo.bar;
1322
- }
1323
- catch (e) {
1324
- advancedObjectProperties = false;
1325
- }
1326
- foo = null;
1327
- })();
1328
- }
1329
-
1330
- Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)));
1331
- Modernizr.advancedObjectProperties = advancedObjectProperties;
1332
-
1333
- if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
1334
- var call = Function.prototype.call;
1335
- var prototypeOfObject = Object.prototype;
1336
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
1337
-
1338
- shims.objectCreate = function(proto, props, opts, no__proto__){
1339
- var o;
1340
- var f = function(){};
1341
-
1342
- f.prototype = proto;
1343
- o = new f();
1344
-
1345
- if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
1346
- o.__proto__ = proto;
1347
- }
1348
-
1349
- if(props){
1350
- shims.defineProperties(o, props);
1351
- }
1352
-
1353
- if(opts){
1354
- o.options = $.extend(true, {}, o.options || {}, opts);
1355
- opts = o.options;
1356
- }
1357
-
1358
- if(o._create && $.isFunction(o._create)){
1359
- o._create(opts);
1360
- }
1361
- return o;
1362
- };
1363
-
1364
- shims.defineProperties = function(object, props){
1365
- for (var name in props) {
1366
- if (owns(props, name)) {
1367
- shims.defineProperty(object, name, props[name]);
1368
- }
1369
- }
1370
- return object;
1371
- };
1372
-
1373
- var descProps = ['configurable', 'enumerable', 'writable'];
1374
- shims.defineProperty = function(proto, property, descriptor){
1375
- if(typeof descriptor != "object" || descriptor === null){return proto;}
1376
-
1377
- if(owns(descriptor, "value")){
1378
- proto[property] = descriptor.value;
1379
- return proto;
1380
- }
1381
-
1382
- if(proto.__defineGetter__){
1383
- if (typeof descriptor.get == "function") {
1384
- proto.__defineGetter__(property, descriptor.get);
1385
- }
1386
- if (typeof descriptor.set == "function"){
1387
- proto.__defineSetter__(property, descriptor.set);
1388
- }
1389
- }
1390
- return proto;
1391
- };
1392
-
1393
- shims.getPrototypeOf = function (object) {
1394
- return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
1395
- };
1396
-
1397
- //based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
1398
- shims.getOwnPropertyDescriptor = function(obj, prop){
1399
- if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
1400
- throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
1401
- }
1402
- var descriptor;
1403
- if(Object.defineProperty && Object.getOwnPropertyDescriptor){
1404
- try{
1405
- descriptor = Object.getOwnPropertyDescriptor(obj, prop);
1406
- return descriptor;
1407
- } catch(e){}
1408
- }
1409
- descriptor = {
1410
- configurable: true,
1411
- enumerable: true,
1412
- writable: true,
1413
- value: undefined
1414
- };
1415
- var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
1416
- setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
1417
- ;
1418
-
1419
- if (!getter && !setter) { // not an accessor so return prop
1420
- if(!owns(obj, prop)){
1421
- return;
1422
- }
1423
- descriptor.value = obj[prop];
1424
- return descriptor;
1425
- }
1426
-
1427
- // there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
1428
- delete descriptor.writable;
1429
- delete descriptor.value;
1430
- descriptor.get = descriptor.set = undefined;
1431
-
1432
- if(getter){
1433
- descriptor.get = getter;
1434
- }
1435
-
1436
- if(setter){
1437
- descriptor.set = setter;
1438
- }
1439
-
1440
- return descriptor;
1441
- };
1442
-
1443
- }
1444
- })(webshims.$, webshims);
1445
-
1446
-
1447
-
1448
- //DOM-Extension helper
1449
- webshims.register('dom-extend', function($, webshims, window, document, undefined){
1450
- "use strict";
1451
- var supportHrefNormalized = !('hrefNormalized' in $.support) || $.support.hrefNormalized;
1452
- var supportGetSetAttribute = !('getSetAttribute' in $.support) || $.support.getSetAttribute;
1453
- var has = Object.prototype.hasOwnProperty;
1454
- webshims.assumeARIA = supportGetSetAttribute || Modernizr.canvas || Modernizr.video || Modernizr.boxsizing;
1455
-
1456
- if($('<input type="email" />').attr('type') == 'text' || $('<form />').attr('novalidate') === "" || ('required' in $('<input />')[0].attributes)){
1457
- webshims.error("IE browser modes are busted in IE10+. Please test your HTML/CSS/JS with a real IE version or at least IETester or similiar tools");
1458
- }
1459
-
1460
- if('debug' in webshims){
1461
- webshims.error('Use webshims.setOptions("debug", true||false||"noCombo"); to debug flag');
1462
- }
1463
-
1464
- if (!webshims.cfg.no$Switch) {
1465
- var switch$ = function(){
1466
- if (window.jQuery && (!window.$ || window.jQuery == window.$) && !window.jQuery.webshims) {
1467
- webshims.error("jQuery was included more than once. Make sure to include it only once or try the $.noConflict(extreme) feature! Webshims and other Plugins might not work properly. Or set webshims.cfg.no$Switch to 'true'.");
1468
- if (window.$) {
1469
- window.$ = webshims.$;
1470
- }
1471
- window.jQuery = webshims.$;
1472
- }
1473
- if(webshims.M != Modernizr){
1474
- webshims.error("Modernizr was included more than once. Make sure to include it only once! Webshims and other scripts might not work properly.");
1475
- for(var i in Modernizr){
1476
- if(!(i in webshims.M)){
1477
- webshims.M[i] = Modernizr[i];
1478
- }
1479
- }
1480
- Modernizr = webshims.M;
1481
- }
1482
- };
1483
- switch$();
1484
- setTimeout(switch$, 90);
1485
- webshims.ready('DOM', switch$);
1486
- $(switch$);
1487
- webshims.ready('WINDOWLOAD', switch$);
1488
-
1489
- }
1490
- // (function(){
1491
- // var hostNames = {
1492
- // 'afarkas.github.io': 1,
1493
- // localhost: 1,
1494
- // '127.0.0.1': 1
1495
- // };
1496
- //
1497
- // if( webshims.cfg.debug && (hostNames[location.hostname] || location.protocol == 'file:') ){
1498
- // var list = $('<ul class="webshims-debug-list" />');
1499
- // webshims.errorLog.push = function(message){
1500
- // list.appendTo('body');
1501
- // $('<li style="display: none;">'+ message +'</li>')
1502
- // .appendTo(list)
1503
- // .slideDown()
1504
- // .delay(3000)
1505
- // .slideUp(function(){
1506
- // $(this).remove();
1507
- // if(!$('li', list).length){
1508
- // list.detach();
1509
- // }
1510
- // })
1511
- // ;
1512
- // };
1513
- // $.each(webshims.errorLog, function(i, message){
1514
- // webshims.errorLog.push(message);
1515
- // });
1516
- // }
1517
- // })();
1518
-
1519
- //shortcus
1520
- var modules = webshims.modules;
1521
- var listReg = /\s*,\s*/;
1522
-
1523
- //proxying attribute
1524
- var olds = {};
1525
- var havePolyfill = {};
1526
- var hasPolyfillMethod = {};
1527
- var extendedProps = {};
1528
- var extendQ = {};
1529
- var modifyProps = {};
1530
-
1531
- var oldVal = $.fn.val;
1532
- var singleVal = function(elem, name, val, pass, _argless){
1533
- return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
1534
- };
1535
-
1536
- //jquery mobile and jquery ui
1537
- if(!$.widget){
1538
- (function(){
1539
- var _cleanData = $.cleanData;
1540
- $.cleanData = function( elems ) {
1541
- if(!$.widget){
1542
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
1543
- try {
1544
- $( elem ).triggerHandler( "remove" );
1545
- // http://bugs.jquery.com/ticket/8235
1546
- } catch( e ) {}
1547
- }
1548
- }
1549
- _cleanData( elems );
1550
- };
1551
- })();
1552
- }
1553
-
1554
-
1555
- $.fn.val = function(val){
1556
- var elem = this[0];
1557
- if(arguments.length && val == null){
1558
- val = '';
1559
- }
1560
- if(!arguments.length){
1561
- if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
1562
- return $.prop(elem, 'value', val, 'val', true);
1563
- }
1564
- if($.isArray(val)){
1565
- return oldVal.apply(this, arguments);
1566
- }
1567
- var isFunction = $.isFunction(val);
1568
- return this.each(function(i){
1569
- elem = this;
1570
- if(elem.nodeType === 1){
1571
- if(isFunction){
1572
- var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
1573
- if(genVal == null){
1574
- genVal = '';
1575
- }
1576
- $.prop(elem, 'value', genVal, 'val') ;
1577
- } else {
1578
- $.prop(elem, 'value', val, 'val');
1579
- }
1580
- }
1581
- });
1582
- };
1583
- $.fn.onTrigger = function(evt, fn){
1584
- return this.on(evt, fn).each(fn);
1585
- };
1586
-
1587
- $.fn.onWSOff = function(evt, fn, trigger, evtDel){
1588
- if(!evtDel){
1589
- evtDel = document;
1590
- }
1591
- $(evtDel)[trigger ? 'onTrigger' : 'on'](evt, fn);
1592
- this.on('remove', function(e){
1593
- if(!e.originalEvent){
1594
- $(evtDel).off(evt, fn);
1595
- }
1596
- });
1597
- return this;
1598
- };
1599
-
1600
- var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
1601
- var elementData = function(elem, key, val){
1602
- elem = elem.jquery ? elem[0] : elem;
1603
- if(!elem){return val || {};}
1604
- var data = $.data(elem, dataID);
1605
- if(val !== undefined){
1606
- if(!data){
1607
- data = $.data(elem, dataID, {});
1608
- }
1609
- if(key){
1610
- data[key] = val;
1611
- }
1612
- }
1613
-
1614
- return key ? data && data[key] : data;
1615
- };
1616
-
1617
-
1618
- [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
1619
- $.fn[data.name] = function(){
1620
- var elems = [];
1621
- this.each(function(){
1622
- var shadowData = elementData(this, 'shadowData');
1623
- var elem = shadowData && shadowData[data.prop] || this;
1624
- if($.inArray(elem, elems) == -1){
1625
- elems.push(elem);
1626
- }
1627
- });
1628
- return this.pushStack(elems);
1629
- };
1630
- });
1631
-
1632
- //add support for $('video').trigger('play') in case extendNative is set to false
1633
- if(!webshims.cfg.extendNative && !webshims.cfg.noTriggerOverride){
1634
- (function(oldTrigger){
1635
- $.event.trigger = function(event, data, elem, onlyHandlers){
1636
-
1637
- if(!hasPolyfillMethod[event] || onlyHandlers || !elem || elem.nodeType !== 1){
1638
- return oldTrigger.apply(this, arguments);
1639
- }
1640
- var ret, isOrig, origName;
1641
- var origFn = elem[event];
1642
- var polyfilledFn = $.prop(elem, event);
1643
- var changeFn = polyfilledFn && origFn != polyfilledFn;
1644
- if(changeFn){
1645
- origName = '__ws'+event;
1646
- isOrig = (event in elem) && has.call(elem, event);
1647
- elem[event] = polyfilledFn;
1648
- elem[origName] = origFn;
1649
- }
1650
-
1651
- ret = oldTrigger.apply(this, arguments);
1652
- if (changeFn) {
1653
- if(isOrig){
1654
- elem[event] = origFn;
1655
- } else {
1656
- delete elem[event];
1657
- }
1658
- delete elem[origName];
1659
- }
1660
-
1661
- return ret;
1662
- };
1663
- })($.event.trigger);
1664
- }
1665
-
1666
- ['removeAttr', 'prop', 'attr'].forEach(function(type){
1667
- olds[type] = $[type];
1668
- $[type] = function(elem, name, value, pass, _argless){
1669
- var isVal = (pass == 'val');
1670
- var oldMethod = !isVal ? olds[type] : singleVal;
1671
- if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
1672
- return oldMethod(elem, name, value, pass, _argless);
1673
- }
1674
-
1675
- var nodeName = (elem.nodeName || '').toLowerCase();
1676
- var desc = extendedProps[nodeName];
1677
- var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
1678
- var propMethod;
1679
- var oldValMethod;
1680
- var ret;
1681
-
1682
-
1683
- if(!desc){
1684
- desc = extendedProps['*'];
1685
- }
1686
- if(desc){
1687
- desc = desc[name];
1688
- }
1689
-
1690
- if(desc){
1691
- propMethod = desc[curType];
1692
- }
1693
-
1694
- if(propMethod){
1695
- if(name == 'value'){
1696
- oldValMethod = propMethod.isVal;
1697
- propMethod.isVal = isVal;
1698
- }
1699
- if(curType === 'removeAttr'){
1700
- return propMethod.value.call(elem);
1701
- } else if(value === undefined){
1702
- return (propMethod.get) ?
1703
- propMethod.get.call(elem) :
1704
- propMethod.value
1705
- ;
1706
- } else if(propMethod.set) {
1707
- if(type == 'attr' && value === true){
1708
- value = name;
1709
- }
1710
-
1711
- ret = propMethod.set.call(elem, value);
1712
- }
1713
- if(name == 'value'){
1714
- propMethod.isVal = oldValMethod;
1715
- }
1716
- } else {
1717
- ret = oldMethod(elem, name, value, pass, _argless);
1718
- }
1719
- if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
1720
-
1721
- var boolValue;
1722
- if(curType == 'removeAttr'){
1723
- boolValue = false;
1724
- } else if(curType == 'prop'){
1725
- boolValue = !!(value);
1726
- } else {
1727
- boolValue = true;
1728
- }
1729
-
1730
- modifyProps[nodeName][name].forEach(function(fn){
1731
- if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
1732
- fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
1733
- }
1734
- });
1735
- }
1736
- return ret;
1737
- };
1738
-
1739
- extendQ[type] = function(nodeName, prop, desc){
1740
-
1741
- if(!extendedProps[nodeName]){
1742
- extendedProps[nodeName] = {};
1743
- }
1744
- if(!extendedProps[nodeName][prop]){
1745
- extendedProps[nodeName][prop] = {};
1746
- }
1747
- var oldDesc = extendedProps[nodeName][prop][type];
1748
- var getSup = function(propType, descriptor, oDesc){
1749
- var origProp;
1750
- if(descriptor && descriptor[propType]){
1751
- return descriptor[propType];
1752
- }
1753
- if(oDesc && oDesc[propType]){
1754
- return oDesc[propType];
1755
- }
1756
- if(type == 'prop' && prop == 'value'){
1757
- return function(value){
1758
- var elem = this;
1759
- return (desc.isVal) ?
1760
- singleVal(elem, prop, value, false, (arguments.length === 0)) :
1761
- olds[type](elem, prop, value)
1762
- ;
1763
- };
1764
- }
1765
- if(type == 'prop' && propType == 'value' && desc.value.apply){
1766
- origProp = '__ws'+prop;
1767
- hasPolyfillMethod[prop] = true;
1768
- return function(value){
1769
- var sup = this[origProp] || olds[type](this, prop);
1770
- if(sup && sup.apply){
1771
- sup = sup.apply(this, arguments);
1772
- }
1773
- return sup;
1774
- };
1775
- }
1776
- return function(value){
1777
- return olds[type](this, prop, value);
1778
- };
1779
- };
1780
- extendedProps[nodeName][prop][type] = desc;
1781
- if(desc.value === undefined){
1782
- if(!desc.set){
1783
- desc.set = desc.writeable ?
1784
- getSup('set', desc, oldDesc) :
1785
- (webshims.cfg.useStrict && prop == 'prop') ?
1786
- function(){throw(prop +' is readonly on '+ nodeName);} :
1787
- function(){webshims.info(prop +' is readonly on '+ nodeName);}
1788
- ;
1789
- }
1790
- if(!desc.get){
1791
- desc.get = getSup('get', desc, oldDesc);
1792
- }
1793
-
1794
- }
1795
-
1796
- ['value', 'get', 'set'].forEach(function(descProp){
1797
- if(desc[descProp]){
1798
- desc['_sup'+descProp] = getSup(descProp, oldDesc);
1799
- }
1800
- });
1801
- };
1802
-
1803
- });
1804
-
1805
- var extendNativeValue = (function(){
1806
- var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
1807
-
1808
- //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
1809
- var isExtendNativeSave = Modernizr.advancedObjectProperties && Modernizr.objectAccessor;
1810
- return function(nodeName, prop, desc){
1811
- var elem , elemProto;
1812
- if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
1813
- var sup = elem[prop];
1814
- desc._supvalue = function(){
1815
- if(sup && sup.apply){
1816
- return sup.apply(this, arguments);
1817
- }
1818
- return sup;
1819
- };
1820
- elemProto[prop] = desc.value;
1821
- } else {
1822
- desc._supvalue = function(){
1823
- var data = elementData(this, 'propValue');
1824
- if(data && data[prop] && data[prop].apply){
1825
- return data[prop].apply(this, arguments);
1826
- }
1827
- return data && data[prop];
1828
- };
1829
- initProp.extendValue(nodeName, prop, desc.value);
1830
- }
1831
- desc.value._supvalue = desc._supvalue;
1832
- };
1833
- })();
1834
-
1835
- var initProp = (function(){
1836
-
1837
- var initProps = {};
1838
-
1839
- webshims.addReady(function(context, contextElem){
1840
- var nodeNameCache = {};
1841
- var getElementsByName = function(name){
1842
- if(!nodeNameCache[name]){
1843
- nodeNameCache[name] = $(context.getElementsByTagName(name));
1844
- if(contextElem[0] && $.nodeName(contextElem[0], name)){
1845
- nodeNameCache[name] = nodeNameCache[name].add(contextElem);
1846
- }
1847
- }
1848
- };
1849
-
1850
-
1851
- $.each(initProps, function(name, fns){
1852
- getElementsByName(name);
1853
- if(!fns || !fns.forEach){
1854
- webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
1855
- return;
1856
- }
1857
- fns.forEach(function(fn){
1858
- nodeNameCache[name].each(fn);
1859
- });
1860
- });
1861
- nodeNameCache = null;
1862
- });
1863
-
1864
- var tempCache;
1865
- var emptyQ = $([]);
1866
- var createNodeNameInit = function(nodeName, fn){
1867
- if(!initProps[nodeName]){
1868
- initProps[nodeName] = [fn];
1869
- } else {
1870
- initProps[nodeName].push(fn);
1871
- }
1872
- if($.isDOMReady){
1873
- (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
1874
- }
1
+ webshims.register('form-native-extend', function($, webshims, window, doc, undefined, options){
2
+ "use strict";
3
+ var Modernizr = window.Modernizr;
4
+ var modernizrInputTypes = Modernizr.inputtypes;
5
+ if(!Modernizr.formvalidation || webshims.bugs.bustedValidity){return;}
6
+ var typeModels = webshims.inputTypes;
7
+ var runTest = false;
8
+ var validityRules = {};
9
+ var updateValidity = (function(){
10
+ var timer;
11
+ var getValidity = function(){
12
+ $(this).prop('validity');
1875
13
  };
1876
-
1877
- var elementExtends = {};
1878
- return {
1879
- createTmpCache: function(nodeName){
1880
- if($.isDOMReady){
1881
- tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
1882
- }
1883
- return tempCache || emptyQ;
1884
- },
1885
- flushTmpCache: function(){
1886
- tempCache = null;
1887
- },
1888
- content: function(nodeName, prop){
1889
- createNodeNameInit(nodeName, function(){
1890
- var val = $.attr(this, prop);
1891
- if(val != null){
1892
- $.attr(this, prop, val);
1893
- }
1894
- });
1895
- },
1896
- createElement: function(nodeName, fn){
1897
- createNodeNameInit(nodeName, fn);
1898
- },
1899
- extendValue: function(nodeName, prop, value){
1900
- createNodeNameInit(nodeName, function(){
1901
- $(this).each(function(){
1902
- var data = elementData(this, 'propValue', {});
1903
- data[prop] = this[prop];
1904
- this[prop] = value;
1905
- });
1906
- });
1907
- }
14
+ var update = function(){
15
+ $('input').each(getValidity);
16
+ };
17
+ return function(){
18
+ clearTimeout(timer);
19
+ timer = setTimeout(update, 9);
1908
20
  };
1909
21
  })();
1910
-
1911
- var createPropDefault = function(descs, removeType){
1912
- if(descs.defaultValue === undefined){
1913
- descs.defaultValue = '';
1914
- }
1915
- if(!descs.removeAttr){
1916
- descs.removeAttr = {
1917
- value: function(){
1918
- descs[removeType || 'prop'].set.call(this, descs.defaultValue);
1919
- descs.removeAttr._supvalue.call(this);
1920
- }
1921
- };
1922
- }
1923
- if(!descs.attr){
1924
- descs.attr = {};
22
+ webshims.addInputType = function(type, obj){
23
+ typeModels[type] = obj;
24
+ runTest = true;
25
+ //update validity of all implemented input types
26
+ if($.isDOMReady && Modernizr.formvalidation && !webshims.bugs.bustedValidity){
27
+ updateValidity();
1925
28
  }
1926
29
  };
1927
30
 
1928
- $.extend(webshims, {
1929
- getID: (function(){
1930
- var ID = new Date().getTime();
1931
- return function(elem){
1932
- elem = $(elem);
1933
- var id = elem.prop('id');
1934
- if(!id){
1935
- ID++;
1936
- id = 'ID-'+ ID;
1937
- elem.eq(0).prop('id', id);
1938
- }
1939
- return id;
1940
- };
1941
- })(),
1942
- implement: function(elem, type){
1943
- var data = elementData(elem, 'implemented') || elementData(elem, 'implemented', {});
1944
- if(data[type]){
1945
- webshims.warn(type +' already implemented for element #'+elem.id);
1946
- return false;
31
+ webshims.addValidityRule = function(type, fn){
32
+ validityRules[type] = fn;
33
+ };
34
+
35
+ $.each({typeMismatch: 'mismatch', badInput: 'bad'}, function(name, fn){
36
+ webshims.addValidityRule(name, function (input, val, cache, validityState){
37
+ if(val === ''){return false;}
38
+ var ret = validityState[name];
39
+ if(!('type' in cache)){
40
+ cache.type = (input[0].getAttribute('type') || '').toLowerCase();
1947
41
  }
1948
- data[type] = true;
1949
- return true;
1950
- },
1951
- extendUNDEFProp: function(obj, props){
1952
- $.each(props, function(name, prop){
1953
- if( !(name in obj) ){
1954
- obj[name] = prop;
1955
- }
1956
- });
1957
- },
1958
- getOptions: (function(){
1959
- var regs = {};
1960
- var regFn = function(f, upper){
1961
- return upper.toLowerCase();
1962
- };
1963
- return function(elem, name, bases){
1964
- var data = elementData(elem, 'cfg'+name);
1965
- var dataName;
1966
- var cfg = {};
1967
-
1968
- if(data){
1969
- return data;
1970
- }
1971
- data = $(elem).data();
1972
-
1973
- if(!bases){
1974
- bases = [true, {}];
1975
- } else if(!Array.isArray(bases)){
1976
- bases = [true, {}, bases];
1977
- } else {
1978
- bases.unshift(true, {});
1979
- }
1980
-
1981
- if(data && data[name]){
1982
- if(typeof data[name] == 'object'){
1983
- bases.push(data[name]);
1984
- } else {
1985
- webshims.error('data-'+ name +' attribute has to be a valid JSON, was: '+ data[name]);
1986
- }
1987
- }
1988
-
1989
- if(!regs[name]){
1990
- regs[name] = new RegExp('^'+ name +'([A-Z])');
1991
- }
1992
-
1993
- for(dataName in data){
1994
- if(regs[name].test(dataName)){
1995
- cfg[dataName.replace(regs[name], regFn)] = data[dataName];
1996
- }
1997
- }
1998
- bases.push(cfg);
1999
-
2000
- return elementData(elem, 'cfg'+name, $.extend.apply($, bases));
2001
- };
2002
- })(),
2003
- //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
2004
- createPropDefault: createPropDefault,
2005
- data: elementData,
2006
- moveToFirstEvent: function(elem, eventType, bindType){
2007
- var events = ($._data(elem, 'events') || {})[eventType];
2008
- var fn;
2009
42
 
2010
- if(events && events.length > 1){
2011
- fn = events.pop();
2012
- if(!bindType){
2013
- bindType = 'bind';
2014
- }
2015
- if(bindType == 'bind' && events.delegateCount){
2016
- events.splice( events.delegateCount, 0, fn);
2017
- } else {
2018
- events.unshift( fn );
2019
- }
2020
-
2021
-
43
+ if(typeModels[cache.type] && typeModels[cache.type][fn]){
44
+ ret = typeModels[cache.type][fn](val, input);
2022
45
  }
2023
- elem = null;
2024
- },
2025
- addShadowDom: (function(){
2026
- var resizeTimer;
2027
- var lastHeight;
2028
- var lastWidth;
2029
-
2030
- var docObserve = {
2031
- init: false,
2032
- runs: 0,
2033
- test: function(){
2034
- var height = docObserve.getHeight();
2035
- var width = docObserve.getWidth();
46
+ return ret || false;
47
+ });
48
+ });
49
+
50
+ var formsExtModule = webshims.modules['form-number-date-api'];
51
+ var overrideValidity = formsExtModule.loaded && !formsExtModule.test();
52
+ var validityProps = ['customError', 'badInput','typeMismatch','rangeUnderflow','rangeOverflow','stepMismatch','tooLong', 'tooShort','patternMismatch','valueMissing','valid'];
53
+
54
+ var validityChanger = ['value'];
55
+ var validityElements = [];
56
+ var testValidity = function(elem, init){
57
+ if(!elem && !runTest){return;}
58
+ var type = (elem.getAttribute && elem.getAttribute('type') || elem.type || '').toLowerCase();
59
+ if(typeModels[type]){
60
+ $.prop(elem, 'validity');
61
+ }
62
+ };
63
+
64
+ var oldSetCustomValidity = {};
65
+ ['input', 'textarea', 'select'].forEach(function(name){
66
+ var desc = webshims.defineNodeNameProperty(name, 'setCustomValidity', {
67
+ prop: {
68
+ value: function(error){
69
+ error = error+'';
70
+ var elem = (name == 'input') ? $(this).getNativeElement()[0] : this;
71
+ desc.prop._supvalue.call(elem, error);
2036
72
 
2037
- if(height != docObserve.height || width != docObserve.width){
2038
- docObserve.height = height;
2039
- docObserve.width = width;
2040
- docObserve.handler({type: 'docresize'});
2041
- docObserve.runs++;
2042
- if(docObserve.runs < 9){
2043
- setTimeout(docObserve.test, 90);
2044
- }
2045
- } else {
2046
- docObserve.runs = 0;
2047
- }
2048
- },
2049
- handler: function(e){
2050
- clearTimeout(resizeTimer);
2051
- resizeTimer = setTimeout(function(){
2052
- if(e.type == 'resize'){
2053
- var width = $(window).width();
2054
- var height = $(window).width();
2055
- if(height == lastHeight && width == lastWidth){
2056
- return;
2057
- }
2058
- lastHeight = height;
2059
- lastWidth = width;
2060
-
2061
- docObserve.height = docObserve.getHeight();
2062
- docObserve.width = docObserve.getWidth();
2063
-
2064
- }
2065
- $(document).triggerHandler('updateshadowdom');
2066
- }, (e.type == 'resize') ? 50 : 9);
2067
- },
2068
- _create: function(){
2069
- $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
2070
- var body = document.body;
2071
- var doc = document.documentElement;
2072
- docObserve[type] = function(){
2073
- return Math.max(
2074
- body[ "scroll" + name ], doc[ "scroll" + name ],
2075
- body[ "offset" + name ], doc[ "offset" + name ],
2076
- doc[ "client" + name ]
2077
- );
2078
- };
2079
- });
2080
- },
2081
- start: function(){
2082
- if(!this.init && document.body){
2083
- this.init = true;
2084
- this._create();
2085
- this.height = docObserve.getHeight();
2086
- this.width = docObserve.getWidth();
2087
- setInterval(this.test, 600);
2088
- $(this.test);
2089
- webshims.ready('WINDOWLOAD', this.test);
2090
- $(document).on('updatelayout pageinit collapsibleexpand shown.bs.modal shown.bs.collapse slid.bs.carousel', this.handler);
2091
- $(window).on('resize', this.handler);
2092
- (function(){
2093
- var oldAnimate = $.fn.animate;
2094
- var animationTimer;
2095
-
2096
- $.fn.animate = function(){
2097
- clearTimeout(animationTimer);
2098
- animationTimer = setTimeout(function(){
2099
- docObserve.test();
2100
- }, 99);
2101
-
2102
- return oldAnimate.apply(this, arguments);
2103
- };
2104
- })();
73
+
74
+ if(overrideValidity){
75
+ webshims.data(elem, 'hasCustomError', !!(error));
76
+ testValidity(elem);
2105
77
  }
2106
78
  }
2107
- };
2108
-
79
+ }
80
+ });
81
+ oldSetCustomValidity[name] = desc.prop._supvalue;
82
+ });
83
+
84
+
85
+ if(overrideValidity){
86
+ validityChanger.push('min');
87
+ validityChanger.push('max');
88
+ validityChanger.push('step');
89
+ validityElements.push('input');
90
+ }
91
+
92
+
93
+ if(overrideValidity){
94
+ var stopValidity;
95
+ validityElements.forEach(function(nodeName){
2109
96
 
2110
- webshims.docObserve = function(){
2111
- webshims.ready('DOM', function(){
2112
- docObserve.start();
2113
- if($.support.boxSizing == null){
2114
- $(function(){
2115
- if($.support.boxSizing){
2116
- docObserve.handler({type: 'boxsizing'});
2117
- }
2118
- });
2119
- }
2120
- });
2121
- };
2122
- return function(nativeElem, shadowElem, opts){
2123
- if(nativeElem && shadowElem){
2124
- opts = opts || {};
2125
- if(nativeElem.jquery){
2126
- nativeElem = nativeElem[0];
2127
- }
2128
- if(shadowElem.jquery){
2129
- shadowElem = shadowElem[0];
2130
- }
2131
- var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
2132
- var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
2133
- var shadowFocusElementData = {};
2134
- if(!opts.shadowFocusElement){
2135
- opts.shadowFocusElement = shadowElem;
2136
- } else if(opts.shadowFocusElement){
2137
- if(opts.shadowFocusElement.jquery){
2138
- opts.shadowFocusElement = opts.shadowFocusElement[0];
2139
- }
2140
- shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
2141
- }
2142
-
2143
- $(nativeElem).on('remove', function(e){
2144
- if (!e.originalEvent) {
2145
- setTimeout(function(){
2146
- $(shadowElem).remove();
2147
- }, 4);
97
+ var oldDesc = webshims.defineNodeNameProperty(nodeName, 'validity', {
98
+ prop: {
99
+ get: function(){
100
+ if(stopValidity){return;}
101
+ var elem = (nodeName == 'input') ? $(this).getNativeElement()[0] : this;
102
+
103
+ var validity = oldDesc.prop._supget.call(elem);
104
+
105
+ if(!validity){
106
+ return validity;
2148
107
  }
2149
- });
2150
-
2151
- nativeData.hasShadow = shadowElem;
2152
- shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
2153
- shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
2154
- nativeElement: nativeElem,
2155
- shadowElement: shadowElem,
2156
- shadowFocusElement: opts.shadowFocusElement
2157
- };
2158
- if(opts.shadowChilds){
2159
- opts.shadowChilds.each(function(){
2160
- elementData(this, 'shadowData', shadowData.shadowData);
108
+ var validityState = {};
109
+ validityProps.forEach(function(prop){
110
+ validityState[prop] = validity[prop] || false;
2161
111
  });
2162
- }
2163
-
2164
- if(opts.data){
2165
- shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
2166
- }
2167
- opts = null;
2168
- }
2169
- webshims.docObserve();
2170
- };
2171
- })(),
2172
- propTypes: {
2173
- standard: function(descs, name){
2174
- createPropDefault(descs);
2175
- if(descs.prop){return;}
2176
- descs.prop = {
2177
- set: function(val){
2178
- descs.attr.set.call(this, ''+val);
2179
- },
2180
- get: function(){
2181
- return descs.attr.get.call(this) || descs.defaultValue;
2182
- }
2183
- };
2184
-
2185
- },
2186
- "boolean": function(descs, name){
2187
-
2188
- createPropDefault(descs);
2189
- if(descs.prop){return;}
2190
- descs.prop = {
2191
- set: function(val){
2192
- if(val){
2193
- descs.attr.set.call(this, "");
2194
- } else {
2195
- descs.removeAttr.value.call(this);
112
+
113
+ if( !$.prop(elem, 'willValidate') ){
114
+ return validityState;
2196
115
  }
2197
- },
2198
- get: function(){
2199
- return descs.attr.get.call(this) != null;
2200
- }
2201
- };
2202
- },
2203
- "src": (function(){
2204
- var anchor = document.createElement('a');
2205
- anchor.style.display = "none";
2206
- return function(descs, name){
2207
-
2208
- createPropDefault(descs);
2209
- if(descs.prop){return;}
2210
- descs.prop = {
2211
- set: function(val){
2212
- descs.attr.set.call(this, val);
2213
- },
2214
- get: function(){
2215
- var href = this.getAttribute(name);
2216
- var ret;
2217
- if(href == null){return '';}
2218
-
2219
- anchor.setAttribute('href', href+'' );
2220
-
2221
- if(!supportHrefNormalized){
2222
- try {
2223
- $(anchor).insertAfter(this);
2224
- ret = anchor.getAttribute('href', 4);
2225
- } catch(er){
2226
- ret = anchor.getAttribute('href', 4);
116
+ stopValidity = true;
117
+ var jElm = $(elem),
118
+ cache = {type: (elem.getAttribute && elem.getAttribute('type') || elem.type || '').toLowerCase(), nodeName: (elem.nodeName || '').toLowerCase()},
119
+ val = jElm.val(),
120
+ customError = !!(webshims.data(elem, 'hasCustomError')),
121
+ setCustomMessage
122
+ ;
123
+ stopValidity = false;
124
+ validityState.customError = customError;
125
+
126
+ if( validityState.valid && validityState.customError ){
127
+ validityState.valid = false;
128
+ } else if(!validityState.valid) {
129
+ var allFalse = true;
130
+ $.each(validityState, function(name, prop){
131
+ if(prop){
132
+ allFalse = false;
133
+ return false;
2227
134
  }
2228
- $(anchor).detach();
135
+ });
136
+
137
+ if(allFalse){
138
+ validityState.valid = true;
2229
139
  }
2230
- return ret || anchor.href;
140
+
2231
141
  }
2232
- };
2233
- };
2234
- })(),
2235
- enumarated: function(descs, name){
2236
-
2237
- createPropDefault(descs);
2238
- if(descs.prop){return;}
2239
- descs.prop = {
2240
- set: function(val){
2241
- descs.attr.set.call(this, val);
2242
- },
2243
- get: function(){
2244
- var val = (descs.attr.get.call(this) || '').toLowerCase();
2245
- if(!val || descs.limitedTo.indexOf(val) == -1){
2246
- val = descs.defaultValue;
142
+
143
+ $.each(validityRules, function(rule, fn){
144
+ validityState[rule] = fn(jElm, val, cache, validityState);
145
+ if( validityState[rule] && (validityState.valid || !setCustomMessage) && ((typeModels[cache.type])) ) {
146
+ oldSetCustomValidity[nodeName].call(elem, webshims.createValidationMessage(elem, rule));
147
+ validityState.valid = false;
148
+ setCustomMessage = true;
2247
149
  }
2248
- return val;
150
+ });
151
+ if(validityState.valid){
152
+ oldSetCustomValidity[nodeName].call(elem, '');
153
+ webshims.data(elem, 'hasCustomError', false);
2249
154
  }
2250
- };
155
+ return validityState;
156
+ },
157
+ writeable: false
158
+
2251
159
  }
2252
-
2253
- // ,unsignedLong: $.noop
2254
- // ,"doubble": $.noop
2255
- // ,"long": $.noop
2256
- // ,tokenlist: $.noop
2257
- // ,settableTokenlist: $.noop
2258
- },
2259
- reflectProperties: function(nodeNames, props){
2260
- if(typeof props == 'string'){
2261
- props = props.split(listReg);
2262
- }
2263
- props.forEach(function(prop){
2264
- webshims.defineNodeNamesProperty(nodeNames, prop, {
2265
- prop: {
2266
- set: function(val){
2267
- $.attr(this, prop, val);
2268
- },
2269
- get: function(){
2270
- return $.attr(this, prop) || '';
2271
- }
2272
- }
2273
- });
2274
160
  });
2275
- },
2276
- defineNodeNameProperty: function(nodeName, prop, descs){
2277
- havePolyfill[prop] = true;
2278
-
2279
- if(descs.reflect){
2280
- if(descs.propType && !webshims.propTypes[descs.propType]){
2281
- webshims.error('could not finde propType '+ descs.propType);
2282
- } else {
2283
- webshims.propTypes[descs.propType || 'standard'](descs, prop);
2284
- }
2285
-
2286
- }
2287
-
2288
- ['prop', 'attr', 'removeAttr'].forEach(function(type){
2289
- var desc = descs[type];
2290
- if(desc){
2291
- if(type === 'prop'){
2292
- desc = $.extend({writeable: true}, desc);
2293
- } else {
2294
- desc = $.extend({}, desc, {writeable: true});
2295
- }
2296
-
2297
- extendQ[type](nodeName, prop, desc);
2298
- if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
2299
- extendNativeValue(nodeName, prop, desc);
2300
- }
2301
- descs[type] = desc;
2302
- }
161
+ });
162
+
163
+ validityChanger.forEach(function(prop){
164
+ webshims.onNodeNamesPropertyModify(validityElements, prop, function(s){
165
+ testValidity(this);
2303
166
  });
2304
- if(descs.initAttr){
2305
- initProp.content(nodeName, prop);
2306
- }
2307
- return descs;
2308
- },
167
+ });
2309
168
 
2310
- defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
2311
- var olddesc;
2312
- for(var prop in descs){
2313
- if(!_noTmpCache && descs[prop].initAttr){
2314
- initProp.createTmpCache(name);
2315
- }
2316
- if(propType){
2317
- if(descs[prop][propType]){
2318
- //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
2319
- } else {
2320
- descs[prop][propType] = {};
2321
- ['value', 'set', 'get'].forEach(function(copyProp){
2322
- if(copyProp in descs[prop]){
2323
- descs[prop][propType][copyProp] = descs[prop][copyProp];
2324
- delete descs[prop][copyProp];
2325
- }
2326
- });
2327
- }
2328
- }
2329
- descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
2330
- }
2331
- if(!_noTmpCache){
2332
- initProp.flushTmpCache();
2333
- }
2334
- return descs;
2335
- },
169
+ if(doc.addEventListener){
170
+ var inputThrottle;
171
+ var testPassValidity = function(e){
172
+ if(!('form' in e.target)){return;}
173
+ clearTimeout(inputThrottle);
174
+ testValidity(e.target);
175
+ };
176
+
177
+ doc.addEventListener('change', testPassValidity, true);
178
+
179
+
180
+ doc.addEventListener('input', function(e){
181
+ clearTimeout(inputThrottle);
182
+ inputThrottle = setTimeout(function(){
183
+ testValidity(e.target);
184
+ }, 290);
185
+ }, true);
186
+ }
2336
187
 
2337
- createElement: function(nodeName, create, descs){
2338
- var ret;
2339
- if($.isFunction(create)){
2340
- create = {
2341
- after: create
2342
- };
2343
- }
2344
- initProp.createTmpCache(nodeName);
2345
- if(create.before){
2346
- initProp.createElement(nodeName, create.before);
2347
- }
2348
- if(descs){
2349
- ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
188
+ var validityElementsSel = validityElements.join(',');
189
+
190
+ webshims.addReady(function(context, elem){
191
+ if(runTest){
192
+ $(validityElementsSel, context).add(elem.filter(validityElementsSel)).each(function(){
193
+ testValidity(this);
194
+ });
2350
195
  }
2351
- if(create.after){
2352
- initProp.createElement(nodeName, create.after);
196
+ });
197
+
198
+
199
+ } //end: overrideValidity
200
+
201
+ webshims.defineNodeNameProperty('input', 'type', {
202
+ prop: {
203
+ get: function(){
204
+ var elem = this;
205
+ var type = (elem.getAttribute && elem.getAttribute('type') || '').toLowerCase();
206
+ return (webshims.inputTypes[type]) ? type : elem.type;
2353
207
  }
2354
- initProp.flushTmpCache();
2355
- return ret;
208
+ }
209
+ });
210
+
211
+
212
+ });;webshims.register('form-message', function($, webshims, window, document, undefined, options){
213
+ "use strict";
214
+ if(options.lazyCustomMessages){
215
+ options.customMessages = true;
216
+ }
217
+ var validityMessages = webshims.validityMessages;
218
+
219
+ var implementProperties = options.customMessages ? ['customValidationMessage'] : [];
220
+
221
+ validityMessages.en = $.extend(true, {
222
+ typeMismatch: {
223
+ defaultMessage: 'Please enter a valid value.',
224
+ email: 'Please enter an email address.',
225
+ url: 'Please enter a URL.'
2356
226
  },
2357
- onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
2358
- if(typeof nodeNames == 'string'){
2359
- nodeNames = nodeNames.split(listReg);
2360
- }
2361
- if($.isFunction(desc)){
2362
- desc = {set: desc};
2363
- }
2364
-
2365
- nodeNames.forEach(function(name){
2366
- if(!modifyProps[name]){
2367
- modifyProps[name] = {};
2368
- }
2369
- if(typeof props == 'string'){
2370
- props = props.split(listReg);
2371
- }
2372
- if(desc.initAttr){
2373
- initProp.createTmpCache(name);
2374
- }
2375
- props.forEach(function(prop){
2376
- if(!modifyProps[name][prop]){
2377
- modifyProps[name][prop] = [];
2378
- havePolyfill[prop] = true;
2379
- }
2380
- if(desc.set){
2381
- if(only){
2382
- desc.set.only = only;
2383
- }
2384
- modifyProps[name][prop].push(desc.set);
2385
- }
2386
-
2387
- if(desc.initAttr){
2388
- initProp.content(name, prop);
2389
- }
2390
- });
2391
- initProp.flushTmpCache();
2392
-
2393
- });
227
+ badInput: {
228
+ defaultMessage: 'Please enter a valid value.',
229
+ number: 'Please enter a number.',
230
+ date: 'Please enter a date.',
231
+ time: 'Please enter a time.',
232
+ range: 'Invalid input.',
233
+ month: 'Please enter a valid value.',
234
+ "datetime-local": 'Please enter a datetime.'
2394
235
  },
2395
- defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
2396
- if(!descs){
2397
- descs = {};
2398
- }
2399
- if($.isFunction(descs)){
2400
- descs.set = descs;
2401
- }
2402
- webshims.defineNodeNamesProperty(elementNames, prop, {
2403
- attr: {
2404
- set: function(val){
2405
- this.setAttribute(prop, val);
2406
- if(descs.set){
2407
- descs.set.call(this, true);
2408
- }
2409
- },
2410
- get: function(){
2411
- var ret = this.getAttribute(prop);
2412
- return (ret == null) ? undefined : prop;
2413
- }
2414
- },
2415
- removeAttr: {
2416
- value: function(){
2417
- this.removeAttribute(prop);
2418
- if(descs.set){
2419
- descs.set.call(this, false);
2420
- }
2421
- }
2422
- },
2423
- reflect: true,
2424
- propType: 'boolean',
2425
- initAttr: descs.initAttr || false
2426
- });
236
+ rangeUnderflow: {
237
+ defaultMessage: 'Value must be greater than or equal to {%min}.'
2427
238
  },
2428
- contentAttr: function(elem, name, val){
2429
- if(!elem.nodeName){return;}
2430
- var attr;
2431
- if(val === undefined){
2432
- attr = (elem.attributes[name] || {});
2433
- val = attr.specified ? attr.value : null;
2434
- return (val == null) ? undefined : val;
2435
- }
2436
-
2437
- if(typeof val == 'boolean'){
2438
- if(!val){
2439
- elem.removeAttribute(name);
2440
- } else {
2441
- elem.setAttribute(name, name);
2442
- }
2443
- } else {
2444
- elem.setAttribute(name, val);
2445
- }
239
+ rangeOverflow: {
240
+ defaultMessage: 'Value must be less than or equal to {%max}.'
2446
241
  },
2447
-
2448
- activeLang: (function(){
2449
- var curLang = [];
2450
- var langDatas = [];
2451
- var loading = {};
2452
- var load = function(src, obj, loadingLang){
2453
- obj._isLoading = true;
2454
- if(loading[src]){
2455
- loading[src].push(obj);
2456
- } else {
2457
- loading[src] = [obj];
2458
- webshims.loader.loadScript(src, function(){
2459
- if(loadingLang == curLang.join()){
2460
- $.each(loading[src], function(i, obj){
2461
- select(obj);
2462
- });
2463
- }
2464
- delete loading[src];
2465
- });
2466
- }
2467
- };
2468
- var select = function(obj){
2469
- var oldLang = obj.__active;
2470
- var selectLang = function(i, lang){
2471
- obj._isLoading = false;
2472
- if(obj[lang] || obj.availableLangs.indexOf(lang) != -1){
2473
- if(obj[lang]){
2474
- obj.__active = obj[lang];
2475
- } else {
2476
- load(obj.langSrc+lang, obj, curLang.join());
2477
- }
2478
- return false;
2479
- }
2480
- };
2481
- $.each(curLang, selectLang);
2482
- if(!obj.__active){
2483
- obj.__active = obj[''];
2484
- }
2485
- if(oldLang != obj.__active){
2486
- $(obj).trigger('change');
242
+ stepMismatch: 'Invalid input.',
243
+ tooLong: 'Please enter at most {%maxlength} character(s). You entered {%valueLen}.',
244
+ tooShort: 'Please enter at least {%minlength} character(s). You entered {%valueLen}.',
245
+ patternMismatch: 'Invalid input. {%title}',
246
+ valueMissing: {
247
+ defaultMessage: 'Please fill out this field.',
248
+ checkbox: 'Please check this box if you want to proceed.'
249
+ }
250
+ }, (validityMessages.en || validityMessages['en-US'] || {}));
251
+
252
+ if(typeof validityMessages['en'].valueMissing == 'object'){
253
+ ['select', 'radio'].forEach(function(type){
254
+ validityMessages.en.valueMissing[type] = validityMessages.en.valueMissing[type] || 'Please select an option.';
255
+ });
256
+ }
257
+ if(typeof validityMessages.en.rangeUnderflow == 'object'){
258
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
259
+ validityMessages.en.rangeUnderflow[type] = validityMessages.en.rangeUnderflow[type] || 'Value must be at or after {%min}.';
260
+ });
261
+ }
262
+ if(typeof validityMessages.en.rangeOverflow == 'object'){
263
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
264
+ validityMessages.en.rangeOverflow[type] = validityMessages.en.rangeOverflow[type] || 'Value must be at or before {%max}.';
265
+ });
266
+ }
267
+ if(!validityMessages['en-US']){
268
+ validityMessages['en-US'] = $.extend(true, {}, validityMessages.en);
269
+ }
270
+ if(!validityMessages['en-GB']){
271
+ validityMessages['en-GB'] = $.extend(true, {}, validityMessages.en);
272
+ }
273
+ if(!validityMessages['en-AU']){
274
+ validityMessages['en-AU'] = $.extend(true, {}, validityMessages.en);
275
+ }
276
+ validityMessages[''] = validityMessages[''] || validityMessages['en-US'];
277
+
278
+ validityMessages.de = $.extend(true, {
279
+ typeMismatch: {
280
+ defaultMessage: '{%value} ist in diesem Feld nicht zulässig.',
281
+ email: '{%value} ist keine gültige E-Mail-Adresse.',
282
+ url: '{%value} ist kein(e) gültige(r) Webadresse/Pfad.'
283
+ },
284
+ badInput: {
285
+ defaultMessage: 'Geben Sie einen zulässigen Wert ein.',
286
+ number: 'Geben Sie eine Nummer ein.',
287
+ date: 'Geben Sie ein Datum ein.',
288
+ time: 'Geben Sie eine Uhrzeit ein.',
289
+ month: 'Geben Sie einen Monat mit Jahr ein.',
290
+ range: 'Geben Sie eine Nummer.',
291
+ "datetime-local": 'Geben Sie ein Datum mit Uhrzeit ein.'
292
+ },
293
+ rangeUnderflow: {
294
+ defaultMessage: '{%value} ist zu niedrig. {%min} ist der unterste Wert, den Sie benutzen können.'
295
+ },
296
+ rangeOverflow: {
297
+ defaultMessage: '{%value} ist zu hoch. {%max} ist der oberste Wert, den Sie benutzen können.'
298
+ },
299
+ stepMismatch: 'Der Wert {%value} ist in diesem Feld nicht zulässig. Hier sind nur bestimmte Werte zulässig. {%title}',
300
+ tooLong: 'Der eingegebene Text ist zu lang! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%maxlength} das Maximum.',
301
+ tooShort: 'Der eingegebene Text ist zu kurz! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%minlength} das Minimum.',
302
+ patternMismatch: '{%value} hat für dieses Eingabefeld ein falsches Format. {%title}',
303
+ valueMissing: {
304
+ defaultMessage: 'Bitte geben Sie einen Wert ein.',
305
+ checkbox: 'Bitte aktivieren Sie das Kästchen.'
306
+ }
307
+ }, (validityMessages.de || {}));
308
+
309
+ if(typeof validityMessages.de.valueMissing == 'object'){
310
+ ['select', 'radio'].forEach(function(type){
311
+ validityMessages.de.valueMissing[type] = validityMessages.de.valueMissing[type] || 'Bitte wählen Sie eine Option aus.';
312
+ });
313
+ }
314
+ if(typeof validityMessages.de.rangeUnderflow == 'object'){
315
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
316
+ validityMessages.de.rangeUnderflow[type] = validityMessages.de.rangeUnderflow[type] || '{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.';
317
+ });
318
+ }
319
+ if(typeof validityMessages.de.rangeOverflow == 'object'){
320
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
321
+ validityMessages.de.rangeOverflow[type] = validityMessages.de.rangeOverflow[type] || '{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.';
322
+ });
323
+ }
324
+
325
+ var currentValidationMessage = validityMessages[''];
326
+ var getMessageFromObj = function(message, elem){
327
+ if(message && typeof message !== 'string'){
328
+ message = message[ $.prop(elem, 'type') ] || message[ (elem.nodeName || '').toLowerCase() ] || message[ 'defaultMessage' ];
329
+ }
330
+ return message || '';
331
+ };
332
+ var valueVals = {
333
+ value: 1,
334
+ min: 1,
335
+ max: 1
336
+ };
337
+
338
+ webshims.createValidationMessage = function(elem, name){
339
+ var widget;
340
+ var type = $.prop(elem, 'type');
341
+ var message = getMessageFromObj(currentValidationMessage[name], elem);
342
+ if(!message && name == 'badInput'){
343
+ message = getMessageFromObj(currentValidationMessage.typeMismatch, elem);
344
+ }
345
+ if(!message && name == 'typeMismatch'){
346
+ message = getMessageFromObj(currentValidationMessage.badInput, elem);
347
+ }
348
+ if(!message){
349
+ message = getMessageFromObj(validityMessages[''][name], elem) || $.prop(elem, 'validationMessage');
350
+ webshims.info('could not find errormessage for: '+ name +' / '+ type +'. in language: '+webshims.activeLang());
351
+ }
352
+ if(message){
353
+ ['value', 'min', 'max', 'title', 'maxlength', 'minlength', 'label'].forEach(function(attr){
354
+ if(message.indexOf('{%'+attr) === -1){return;}
355
+ var val = ((attr == 'label') ? $.trim($('label[for="'+ elem.id +'"]', elem.form).text()).replace(/\*$|:$/, '') : $.prop(elem, attr)) || '';
356
+ if(name == 'patternMismatch' && attr == 'title' && !val){
357
+ webshims.error('no title for patternMismatch provided. Always add a title attribute.');
2487
358
  }
2488
- };
2489
- return function(lang){
2490
- var shortLang;
2491
- if(typeof lang == 'string'){
2492
- if(curLang[0] != lang){
2493
- curLang = [lang];
2494
- shortLang = curLang[0].split('-')[0];
2495
- if(shortLang && shortLang != lang){
2496
- curLang.push(shortLang);
2497
- }
2498
- langDatas.forEach(select);
359
+ if(valueVals[attr]){
360
+ if(!widget){
361
+ widget = $(elem).getShadowElement().data('wsWidget'+type);
2499
362
  }
2500
- } else if(typeof lang == 'object'){
2501
- if(!lang.__active){
2502
- langDatas.push(lang);
2503
- select(lang);
363
+ if(widget && widget.formatValue){
364
+ val = widget.formatValue(val, false);
2504
365
  }
2505
- return lang.__active;
2506
366
  }
2507
- return curLang[0];
2508
- };
2509
- })()
367
+ message = message.replace('{%'+ attr +'}', val);
368
+ if('value' == attr){
369
+ message = message.replace('{%valueLen}', val.length);
370
+ }
371
+
372
+ });
373
+ }
374
+
375
+ return message || '';
376
+ };
377
+
378
+
379
+ if(!Modernizr.formvalidation || webshims.bugs.bustedValidity){
380
+ implementProperties.push('validationMessage');
381
+ }
382
+
383
+ currentValidationMessage = webshims.activeLang(validityMessages);
384
+
385
+ $(validityMessages).on('change', function(e, data){
386
+ currentValidationMessage = validityMessages.__active;
2510
387
  });
2511
388
 
2512
- $.each({
2513
- defineNodeNamesProperty: 'defineNodeNameProperty',
2514
- defineNodeNamesProperties: 'defineNodeNameProperties',
2515
- createElements: 'createElement'
2516
- }, function(name, baseMethod){
2517
- webshims[name] = function(names, a, b, c){
2518
- if(typeof names == 'string'){
2519
- names = names.split(listReg);
389
+ implementProperties.forEach(function(messageProp){
390
+
391
+ webshims.defineNodeNamesProperty(['fieldset', 'output', 'button'], messageProp, {
392
+ prop: {
393
+ value: '',
394
+ writeable: false
2520
395
  }
2521
- var retDesc = {};
2522
- names.forEach(function(nodeName){
2523
- retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
396
+ });
397
+ ['input', 'select', 'textarea'].forEach(function(nodeName){
398
+ var desc = webshims.defineNodeNameProperty(nodeName, messageProp, {
399
+ prop: {
400
+ get: function(){
401
+ var elem = this;
402
+ var message = '';
403
+ if(!$.prop(elem, 'willValidate')){
404
+ return message;
405
+ }
406
+
407
+ var validity = $.prop(elem, 'validity') || {valid: 1};
408
+
409
+ if(validity.valid){return message;}
410
+ message = webshims.getContentValidationMessage(elem, validity);
411
+
412
+ if(message){return message;}
413
+
414
+ if(validity.customError && elem.nodeName){
415
+ message = (Modernizr.formvalidation && !webshims.bugs.bustedValidity && desc.prop._supget) ? desc.prop._supget.call(elem) : webshims.data(elem, 'customvalidationMessage');
416
+ if(message){return message;}
417
+ }
418
+ $.each(validity, function(name, prop){
419
+ if(name == 'valid' || !prop){return;}
420
+
421
+ message = webshims.createValidationMessage(elem, name);
422
+ if(message){
423
+ return false;
424
+ }
425
+ });
426
+
427
+ return message || '';
428
+ },
429
+ writeable: false
430
+ }
2524
431
  });
2525
- return retDesc;
2526
- };
432
+ });
433
+
2527
434
  });
2528
-
2529
- webshims.isReady('webshimLocalization', true);
2530
435
  });
2531
- //html5a11y
2532
- (function($, document){
2533
- if(!$.webshims.assumeARIA || ('content' in document.createElement('template'))){return;}
2534
-
2535
- $(function(){
2536
- var main = $('main').attr({role: 'main'});
2537
- if(main.length > 1){
2538
- webshims.error('only one main element allowed in document');
2539
- } else if(main.is('article *, section *')) {
2540
- webshims.error('main not allowed inside of article/section elements');
2541
- }
2542
- });
2543
-
2544
- if(('hidden' in document.createElement('a'))){
2545
- return;
436
+ ;webshims.register('form-number-date-api', function($, webshims, window, document, undefined, options){
437
+ "use strict";
438
+ if(!webshims.addInputType){
439
+ webshims.error("you can not call forms-ext feature after calling forms feature. call both at once instead: $.webshims.polyfill('forms forms-ext')");
2546
440
  }
2547
441
 
2548
- var elemMappings = {
2549
- article: "article",
2550
- aside: "complementary",
2551
- section: "region",
2552
- nav: "navigation",
2553
- address: "contentinfo"
2554
- };
2555
- var addRole = function(elem, role){
2556
- var hasRole = elem.getAttribute('role');
2557
- if (!hasRole) {
2558
- elem.setAttribute('role', role);
2559
- }
2560
- };
442
+ if(!webshims.getStep){
443
+ webshims.getStep = function(elem, type){
444
+ var step = $.attr(elem, 'step');
445
+ if(step === 'any'){
446
+ return step;
447
+ }
448
+ type = type || getType(elem);
449
+ if(!typeModels[type] || !typeModels[type].step){
450
+ return step;
451
+ }
452
+ step = typeProtos.number.asNumber(step);
453
+ return ((!isNaN(step) && step > 0) ? step : typeModels[type].step) * (typeModels[type].stepScaleFactor || 1);
454
+ };
455
+ }
456
+ if(!webshims.addMinMaxNumberToCache){
457
+ webshims.addMinMaxNumberToCache = function(attr, elem, cache){
458
+ if (!(attr+'AsNumber' in cache)) {
459
+ cache[attr+'AsNumber'] = typeModels[cache.type].asNumber(elem.attr(attr));
460
+ if(isNaN(cache[attr+'AsNumber']) && (attr+'Default' in typeModels[cache.type])){
461
+ cache[attr+'AsNumber'] = typeModels[cache.type][attr+'Default'];
462
+ }
463
+ }
464
+ };
465
+ }
2561
466
 
467
+ var nan = parseInt('NaN', 10),
468
+ doc = document,
469
+ typeModels = webshims.inputTypes,
470
+ isNumber = function(string){
471
+ return (typeof string == 'number' || (string && string == string * 1));
472
+ },
473
+ supportsType = function(type){
474
+ return ($('<input type="'+type+'" />').prop('type') === type);
475
+ },
476
+ getType = function(elem){
477
+ return (elem.getAttribute('type') || '').toLowerCase();
478
+ },
479
+ isDateTimePart = function(string){
480
+ return (string && !(isNaN(string * 1)));
481
+ },
482
+ addMinMaxNumberToCache = webshims.addMinMaxNumberToCache,
483
+ addleadingZero = function(val, len){
484
+ val = ''+val;
485
+ len = len - val.length;
486
+ for(var i = 0; i < len; i++){
487
+ val = '0'+val;
488
+ }
489
+ return val;
490
+ },
491
+ EPS = 1e-7,
492
+ typeBugs = webshims.bugs.bustedValidity
493
+ ;
2562
494
 
2563
- $.webshims.addReady(function(context, contextElem){
2564
- $.each(elemMappings, function(name, role){
2565
- var elems = $(name, context).add(contextElem.filter(name));
2566
- for (var i = 0, len = elems.length; i < len; i++) {
2567
- addRole(elems[i], role);
495
+ webshims.addValidityRule('stepMismatch', function(input, val, cache, validityState){
496
+ if(val === ''){return false;}
497
+ if(!('type' in cache)){
498
+ cache.type = getType(input[0]);
499
+ }
500
+ if(cache.type == 'week'){return false;}
501
+ var base, attrVal;
502
+ var ret = (validityState || {}).stepMismatch || false;
503
+ if(typeModels[cache.type] && typeModels[cache.type].step){
504
+ if( !('step' in cache) ){
505
+ cache.step = webshims.getStep(input[0], cache.type);
2568
506
  }
2569
- });
2570
- if (context === document) {
2571
- var header = document.getElementsByTagName('header')[0];
2572
- var footers = document.getElementsByTagName('footer');
2573
- var footerLen = footers.length;
2574
507
 
2575
- if (header && !$(header).closest('section, article')[0]) {
2576
- addRole(header, 'banner');
508
+ if(cache.step == 'any'){return false;}
509
+
510
+ if(!('valueAsNumber' in cache)){
511
+ cache.valueAsNumber = typeModels[cache.type].asNumber( val );
2577
512
  }
2578
- if (!footerLen) {
2579
- return;
513
+ if(isNaN(cache.valueAsNumber)){return false;}
514
+
515
+ addMinMaxNumberToCache('min', input, cache);
516
+ base = cache.minAsNumber;
517
+
518
+ if(isNaN(base) && (attrVal = input.prop('defaultValue'))){
519
+ base = typeModels[cache.type].asNumber( attrVal );
2580
520
  }
2581
- var footer = footers[footerLen - 1];
2582
- if (!$(footer).closest('section, article')[0]) {
2583
- addRole(footer, 'contentinfo');
521
+
522
+ if(isNaN(base)){
523
+ base = typeModels[cache.type].stepBase || 0;
2584
524
  }
525
+
526
+ ret = Math.abs((cache.valueAsNumber - base) % cache.step);
527
+
528
+ ret = !( ret <= EPS || Math.abs(ret - cache.step) <= EPS );
2585
529
  }
530
+ return ret;
2586
531
  });
2587
532
 
2588
- })(webshims.$, document);
2589
-
2590
- //JSON
2591
- (function(){
2592
- if('JSON'in window && JSON.stringify && JSON.parse){return;}
2593
-
2594
- if(!this.JSON){this.JSON={};}(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}());
2595
-
2596
- })();
2597
-
2598
- //modified version from http://gist.github.com/350433
2599
- //using window.name for sessionStorage and cookies for localStorage
2600
-
2601
- (function () {
2602
- var $ = webshims.$ || jQuery;
2603
- webshims.error("The json-storage is depreacated. IE8+ supports this feature. No one should need a polyfill anymore!");
2604
-
2605
- if ('localStorage' in window && 'sessionStorage' in window) {
2606
- $.webshims.isReady('json-storage', true);
2607
- return;
2608
- }
2609
-
2610
-
2611
- var storageNameError = function(name){
2612
- if(name && name.indexOf && name.indexOf(';') != -1){
2613
- setTimeout(function(){
2614
- $.webshims.warn("Bad key for localStorage: ; in localStorage. name was: "+ name);
2615
- }, 0);
2616
- }
2617
- };
2618
- var winData;
2619
- var selfWindow = false;
2620
- $.each(['opener', 'top', 'parent'], function(i, name){
2621
- try {
2622
- winData = window[name];
2623
- if(winData && 'name' in winData){
2624
- var test = winData.name;
2625
- return false;
2626
- } else {
2627
- winData = false;
2628
- }
2629
- } catch(e){
2630
- winData = false;
2631
- }
2632
- });
2633
- if(!winData){
2634
- winData = window;
2635
- selfWindow = true;
2636
- }
2637
- var setWindowData = function(data){
2638
- if(!selfWindow){
2639
- try {
2640
- window.name = data;
2641
- } catch(e){}
2642
- }
2643
- try {
2644
- winData.name = data;
2645
- } catch(e){
2646
- winData = window;
2647
- selfWindow = true;
2648
- }
2649
- };
2650
- var getWindowData = function(){
2651
- var data;
2652
- if(!selfWindow){
2653
- try {
2654
- data = window.name;
2655
- } catch(e){}
2656
- }
2657
- if(!data){
2658
- try {
2659
- data = winData.name;
2660
- } catch(e){
2661
- winData = window;
2662
- selfWindow = true;
2663
- }
2664
- }
2665
- return data;
2666
- };
2667
- var Storage = function (type) {
2668
- function createCookie(name, value, days) {
2669
- var date, expires;
2670
-
2671
- if (days) {
2672
- date = new Date();
2673
- date.setTime(date.getTime()+(days*24*60*60*1000));
2674
- expires = "; expires="+date.toGMTString();
2675
- } else {
2676
- expires = "";
2677
- }
2678
- document.cookie = name+"="+value+expires+"; path=/";
2679
- }
2680
533
 
2681
- function readCookie(name) {
2682
- var nameEQ = name + "=",
2683
- ca = document.cookie.split(';'),
2684
- i, c;
2685
-
2686
- for (i=0; i < ca.length; i++) {
2687
- c = ca[i];
2688
- while (c.charAt(0)==' ') {
2689
- c = c.substring(1,c.length);
534
+
535
+ [{name: 'rangeOverflow', attr: 'max', factor: 1}, {name: 'rangeUnderflow', attr: 'min', factor: -1}].forEach(function(data, i){
536
+ webshims.addValidityRule(data.name, function(input, val, cache, validityState) {
537
+ var ret = (validityState || {})[data.name] || false;
538
+ if(val === ''){return ret;}
539
+ if (!('type' in cache)) {
540
+ cache.type = getType(input[0]);
2690
541
  }
2691
-
2692
- if (c.indexOf(nameEQ) === 0) {
2693
- return c.substring(nameEQ.length,c.length);
542
+ if (typeModels[cache.type] && typeModels[cache.type].asNumber) {
543
+ if(!('valueAsNumber' in cache)){
544
+ cache.valueAsNumber = typeModels[cache.type].asNumber( val );
545
+ }
546
+ if(isNaN(cache.valueAsNumber)){
547
+ return false;
548
+ }
549
+
550
+ addMinMaxNumberToCache(data.attr, input, cache);
551
+
552
+ if(isNaN(cache[data.attr+'AsNumber'])){
553
+ return ret;
554
+ }
555
+ ret = ( cache[data.attr+'AsNumber'] * data.factor < cache.valueAsNumber * data.factor - EPS );
2694
556
  }
2695
- }
2696
- return null;
2697
- }
557
+ return ret;
558
+ });
559
+ });
2698
560
 
2699
- function setData(data) {
2700
- data = JSON.stringify(data);
2701
- if (type == 'session') {
2702
- setWindowData(data);
2703
- } else {
2704
- createCookie('localStorage', data, 365);
2705
- }
2706
- }
561
+ webshims.reflectProperties(['input'], ['max', 'min', 'step']);
2707
562
 
2708
- function clearData() {
2709
- if (type == 'session') {
2710
- setWindowData('');
2711
- } else {
2712
- createCookie('localStorage', '', 365);
2713
- }
2714
- }
2715
563
 
2716
- function getData() {
2717
- var data;
2718
- if(type == 'session'){
2719
- data = getWindowData();
2720
- } else {
2721
- data = readCookie('localStorage');
564
+ //IDLs and methods, that aren't part of constrain validation, but strongly tight to it
565
+ var valueAsNumberDescriptor = webshims.defineNodeNameProperty('input', 'valueAsNumber', {
566
+ prop: {
567
+ get: function(){
568
+ var elem = this;
569
+ var type = getType(elem);
570
+ var ret = (typeModels[type] && typeModels[type].asNumber) ?
571
+ typeModels[type].asNumber($.prop(elem, 'value')) :
572
+ (valueAsNumberDescriptor.prop._supget && valueAsNumberDescriptor.prop._supget.apply(elem, arguments));
573
+ if(ret == null){
574
+ ret = nan;
575
+ }
576
+ return ret;
577
+ },
578
+ set: function(val){
579
+ var elem = this;
580
+ var type = getType(elem);
581
+ if(typeModels[type] && typeModels[type].numberToString){
582
+ //is NaN a number?
583
+ if(isNaN(val)){
584
+ $.prop(elem, 'value', '');
585
+ return;
586
+ }
587
+ var set = typeModels[type].numberToString(val);
588
+ if(set !== false){
589
+ $.prop(elem, 'value', set);
590
+ } else {
591
+ webshims.error('INVALID_STATE_ERR: DOM Exception 11');
592
+ }
593
+ } else if(valueAsNumberDescriptor.prop._supset) {
594
+ valueAsNumberDescriptor.prop._supset.apply(elem, arguments);
595
+ }
596
+ }
2722
597
  }
2723
- if(data){
2724
- try {
2725
- data = JSON.parse(data);
2726
- } catch(e){
2727
- data = {};
598
+ });
599
+
600
+ var valueAsDateDescriptor = webshims.defineNodeNameProperty('input', 'valueAsDate', {
601
+ prop: {
602
+ get: function(){
603
+ var elem = this;
604
+ var type = getType(elem);
605
+ return (typeModels[type] && typeModels[type].asDate && !typeModels[type].noAsDate) ?
606
+ typeModels[type].asDate($.prop(elem, 'value')) :
607
+ valueAsDateDescriptor.prop._supget && valueAsDateDescriptor.prop._supget.call(elem) || null;
608
+ },
609
+ set: function(value){
610
+ var elem = this;
611
+ var type = getType(elem);
612
+ if(typeModels[type] && typeModels[type].dateToString && !typeModels[type].noAsDate){
613
+
614
+ if(value === null){
615
+ $.prop(elem, 'value', '');
616
+ return '';
617
+ }
618
+ var set = typeModels[type].dateToString(value);
619
+ if(set !== false){
620
+ $.prop(elem, 'value', set);
621
+ return set;
622
+ } else {
623
+ webshims.error('INVALID_STATE_ERR: DOM Exception 11');
624
+ }
625
+ } else {
626
+ return valueAsDateDescriptor.prop._supset && valueAsDateDescriptor.prop._supset.apply(elem, arguments) || null;
627
+ }
2728
628
  }
2729
629
  }
2730
- return data || {};
2731
- }
630
+ });
2732
631
 
632
+ $.each({stepUp: 1, stepDown: -1}, function(name, stepFactor){
633
+ var stepDescriptor = webshims.defineNodeNameProperty('input', name, {
634
+ prop: {
635
+ value: function(factor){
636
+ var step, val, dateVal, valModStep, alignValue, cache, base, attrVal;
637
+ var type = getType(this);
638
+ if(typeModels[type] && typeModels[type].asNumber){
639
+ cache = {type: type};
640
+ if(!factor){
641
+ factor = 1;
642
+ webshims.warn("you should always use a factor for stepUp/stepDown");
643
+ }
644
+ factor *= stepFactor;
645
+
646
+ val = $.prop(this, 'valueAsNumber');
647
+
648
+ if(isNaN(val)){
649
+ webshims.info("valueAsNumber is NaN can't apply stepUp/stepDown ");
650
+ throw('invalid state error');
651
+ }
652
+
653
+ step = webshims.getStep(this, type);
654
+
655
+ if(step == 'any'){
656
+ webshims.info("step is 'any' can't apply stepUp/stepDown");
657
+ throw('invalid state error');
658
+ }
659
+
660
+ webshims.addMinMaxNumberToCache('min', $(this), cache);
661
+ webshims.addMinMaxNumberToCache('max', $(this), cache);
662
+
663
+ base = cache.minAsNumber;
664
+
665
+ if(isNaN(base) && (attrVal = $.prop(this, 'defaultValue'))){
666
+ base = typeModels[type].asNumber( attrVal );
667
+ }
668
+
669
+ if(!base){
670
+ base = 0;
671
+ }
672
+
673
+ step *= factor;
674
+
675
+ val = (val + step).toFixed(5) * 1;
676
+
677
+ valModStep = (val - base) % step;
678
+
679
+ if ( valModStep && (Math.abs(valModStep) > EPS) ) {
680
+ alignValue = val - valModStep;
681
+ alignValue += ( valModStep > 0 ) ? step : ( -step );
682
+ val = alignValue.toFixed(5) * 1;
683
+ }
684
+
685
+ if( (!isNaN(cache.maxAsNumber) && val > cache.maxAsNumber) || (!isNaN(cache.minAsNumber) && val < cache.minAsNumber) ){
686
+ webshims.info("max/min overflow can't apply stepUp/stepDown");
687
+ throw('invalid state error');
688
+ }
689
+
690
+ $.prop(this, 'valueAsNumber', val);
691
+
692
+ } else if(stepDescriptor.prop && stepDescriptor.prop._supvalue){
693
+ return stepDescriptor.prop._supvalue.apply(this, arguments);
694
+ } else {
695
+ webshims.info("no step method for type: "+ type);
696
+ throw('invalid state error');
697
+ }
698
+ }
699
+ }
700
+ });
701
+ });
2733
702
 
2734
- // initialise if there's already data
2735
- var data = getData();
703
+ /*
704
+ * ToDO: WEEK
705
+ */
706
+ // var getWeek = function(date){
707
+ // var time;
708
+ // var checkDate = new Date(date.getTime());
709
+ //
710
+ // checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
711
+ //
712
+ // time = checkDate.getTime();
713
+ // checkDate.setMonth(0);
714
+ // checkDate.setDate(1);
715
+ // return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
716
+ // };
717
+ //
718
+ // var setWeek = function(year, week){
719
+ // var date = new Date(year, 0, 1);
720
+ //
721
+ // week = (week - 1) * 86400000 * 7;
722
+ // date = new Date(date.getTime() + week);
723
+ // date.setDate(date.getDate() + 1 - (date.getDay() || 7));
724
+ // return date;
725
+ // };
2736
726
 
2737
- return {
2738
- clear: function () {
2739
- data = {};
2740
- clearData();
727
+ var typeProtos = {
728
+
729
+ number: {
730
+ bad: function(val){
731
+ return !(isNumber(val));
732
+ },
733
+ step: 1,
734
+ //stepBase: 0, 0 = default
735
+ stepScaleFactor: 1,
736
+ asNumber: function(str){
737
+ return (isNumber(str)) ? str * 1 : nan;
738
+ },
739
+ numberToString: function(num){
740
+ return (isNumber(num)) ? num : false;
741
+ }
742
+ },
743
+
744
+ range: {
745
+ minDefault: 0,
746
+ maxDefault: 100
2741
747
  },
2742
- getItem: function (key) {
2743
- return (key in data) ? data[key] : null;
748
+ color: {
749
+ bad: (function(){
750
+ var cReg = /^\u0023[a-f0-9]{6}$/;
751
+ return function(val){
752
+ return (!val || val.length != 7 || !(cReg.test(val)));
753
+ };
754
+ })()
2744
755
  },
2745
- key: function (i) {
2746
- // not perfect, but works
2747
- var ctr = 0;
2748
- for (var k in data) {
2749
- if (ctr == i) {
2750
- return k;
756
+ date: {
757
+ bad: function(val){
758
+ if(!val || !val.split || !(/\d$/.test(val))){return true;}
759
+ var i;
760
+ var valA = val.split(/\u002D/);
761
+ if(valA.length !== 3){return true;}
762
+ var ret = false;
763
+
764
+
765
+ if(valA[0].length < 4 || valA[1].length != 2 || valA[1] > 12 || valA[2].length != 2 || valA[2] > 33){
766
+ ret = true;
2751
767
  } else {
2752
- ctr++;
768
+ for(i = 0; i < 3; i++){
769
+ if(!isDateTimePart(valA[i])){
770
+ ret = true;
771
+ break;
772
+ }
773
+ }
774
+ }
775
+
776
+ return ret || (val !== this.dateToString( this.asDate(val, true) ) );
777
+ },
778
+ step: 1,
779
+ //stepBase: 0, 0 = default
780
+ stepScaleFactor: 86400000,
781
+ asDate: function(val, _noMismatch){
782
+ if(!_noMismatch && this.bad(val)){
783
+ return null;
2753
784
  }
785
+ return new Date(this.asNumber(val, true));
786
+ },
787
+ asNumber: function(str, _noMismatch){
788
+ var ret = nan;
789
+ if(_noMismatch || !this.bad(str)){
790
+ str = str.split(/\u002D/);
791
+ ret = Date.UTC(str[0], str[1] - 1, str[2]);
792
+ }
793
+ return ret;
794
+ },
795
+ numberToString: function(num){
796
+ return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
797
+ },
798
+ dateToString: function(date){
799
+ return (date && date.getFullYear) ? addleadingZero(date.getUTCFullYear(), 4) +'-'+ addleadingZero(date.getUTCMonth()+1, 2) +'-'+ addleadingZero(date.getUTCDate(), 2) : false;
2754
800
  }
2755
- return null;
2756
- },
2757
- removeItem: function (key) {
2758
- delete data[key];
2759
- setData(data);
2760
801
  },
2761
- setItem: function (key, value) {
2762
- storageNameError(key);
2763
- data[key] = value+''; // forces the value to a string
2764
- setData(data);
2765
- }
2766
- };
2767
- };
2768
-
2769
-
2770
-
2771
- if (!('sessionStorage' in window)) {window.sessionStorage = new Storage('session');}
2772
-
2773
-
2774
-
2775
- (function(){
2776
- var swfTimer;
2777
- var emptyString = '(empty string)+1287520303738';
2778
- var runStart;
2779
- var shim;
2780
- var localStorageSwfCallback = function(type){
2781
- clearTimeout(swfTimer);
2782
- var getType;
2783
- if(window.localStorage && (type != 'swf' || (shim && shim.key))){
2784
- $.webshims.isReady('json-storage', true);
2785
- return;
2786
- }
2787
-
2788
-
2789
- if(type === 'swf'){
2790
- shim = document.getElementById('swflocalstorageshim');
2791
- getType = shim ? typeof(shim.GetVariable) : 'undefined';
2792
-
2793
- //brute force flash getter
2794
- if( getType == 'undefined' ){
2795
- shim = document.swflocalstorageshim;
2796
- getType = shim ? typeof(shim.GetVariable) : 'undefined';
2797
- if( getType == 'undefined' ){
2798
- shim = window.localstorageshim;
2799
- getType = shim ? typeof(shim.GetVariable) : 'undefined';
802
+ /*
803
+ * ToDO: WEEK
804
+ */
805
+ // week: {
806
+ // bad: function(val){
807
+ // if(!val || !val.split){return true;}
808
+ // var valA = val.split('-W');
809
+ // var ret = true;
810
+ // if(valA.length == 2 && valA[0].length > 3 && valA.length == 2){
811
+ // ret = this.dateToString(setWeek(valA[0], valA[1])) != val;
812
+ // }
813
+ // return ret;
814
+ // },
815
+ // step: 1,
816
+ // stepScaleFactor: 604800000,
817
+ // stepBase: -259200000,
818
+ // asDate: function(str, _noMismatch){
819
+ // var ret = null;
820
+ // if(_noMismatch || !this.bad(str)){
821
+ // ret = str.split('-W');
822
+ // ret = setWeek(ret[0], ret[1]);
823
+ // }
824
+ // return ret;
825
+ // },
826
+ // asNumber: function(str, _noMismatch){
827
+ // var ret = nan;
828
+ // var date = this.asDate(str, _noMismatch);
829
+ // if(date && date.getUTCFullYear){
830
+ // ret = date.getTime();
831
+ // }
832
+ // return ret;
833
+ // },
834
+ // dateToString: function(date){
835
+ // var week, checkDate;
836
+ // var ret = false;
837
+ // if(date && date.getFullYear){
838
+ // week = getWeek(date);
839
+ // if(week == 1){
840
+ // checkDate = new Date(date.getTime());
841
+ // checkDate.setDate(checkDate.getDate() + 7);
842
+ // date.setUTCFullYear(checkDate.getUTCFullYear());
843
+ // }
844
+ // ret = addleadingZero(date.getUTCFullYear(), 4) +'-W'+addleadingZero(week, 2);
845
+ // }
846
+ // return ret;
847
+ // },
848
+ // numberToString: function(num){
849
+ // return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
850
+ // }
851
+ // },
852
+ time: {
853
+ bad: function(val, _getParsed){
854
+ if(!val || !val.split || !(/\d$/.test(val))){return true;}
855
+ val = val.split(/\u003A/);
856
+ if(val.length < 2 || val.length > 3){return true;}
857
+ var ret = false,
858
+ sFraction;
859
+ if(val[2]){
860
+ val[2] = val[2].split(/\u002E/);
861
+ sFraction = parseInt(val[2][1], 10);
862
+ val[2] = val[2][0];
2800
863
  }
2801
- }
2802
-
2803
- if(getType != 'undefined'){
2804
- window.localStorage = {};
2805
-
2806
- window.localStorage.clear = function(){
2807
- if(shim.clear){shim.clear();}
2808
- };
2809
- window.localStorage.key = function(i){
2810
- if(shim.key){shim.key(i);}
2811
- };
2812
- window.localStorage.removeItem = function(name){
2813
- if(shim.removeItem){shim.removeItem(name);}
2814
- };
2815
-
2816
- window.localStorage.setItem = function(name, val){
2817
- storageNameError(name);
2818
- val += '';
2819
- if(!val){
2820
- val = emptyString;
864
+ $.each(val, function(i, part){
865
+ if(!isDateTimePart(part) || part.length !== 2){
866
+ ret = true;
867
+ return false;
868
+ }
869
+ });
870
+ if(ret){return true;}
871
+ if(val[0] > 23 || val[0] < 0 || val[1] > 59 || val[1] < 0){
872
+ return true;
873
+ }
874
+ if(val[2] && (val[2] > 59 || val[2] < 0 )){
875
+ return true;
876
+ }
877
+ if(sFraction && isNaN(sFraction)){
878
+ return true;
879
+ }
880
+ if(sFraction){
881
+ if(sFraction < 100){
882
+ sFraction *= 100;
883
+ } else if(sFraction < 10){
884
+ sFraction *= 10;
2821
885
  }
2822
- if(shim.setItem){
2823
- shim.setItem(name, val);
886
+ }
887
+ return (_getParsed === true) ? [val, sFraction] : false;
888
+ },
889
+ step: 60,
890
+ stepBase: 0,
891
+ stepScaleFactor: 1000,
892
+ asDate: function(val){
893
+ val = new Date(this.asNumber(val));
894
+ return (isNaN(val)) ? null : val;
895
+ },
896
+ asNumber: function(val){
897
+ var ret = nan;
898
+ val = this.bad(val, true);
899
+ if(val !== true){
900
+ ret = Date.UTC('1970', 0, 1, val[0][0], val[0][1], val[0][2] || 0);
901
+ if(val[1]){
902
+ ret += val[1];
2824
903
  }
2825
- };
2826
- window.localStorage.getItem = function(name){
2827
- if(!shim.getItem){
2828
- return null;
904
+ }
905
+ return ret;
906
+ },
907
+ dateToString: function(date){
908
+ if(date && date.getUTCHours){
909
+ var str = addleadingZero(date.getUTCHours(), 2) +':'+ addleadingZero(date.getUTCMinutes(), 2),
910
+ tmp = date.getSeconds()
911
+ ;
912
+ if(tmp != "0"){
913
+ str += ':'+ addleadingZero(tmp, 2);
2829
914
  }
2830
- var val = shim.getItem(name, val);
2831
- if(val == emptyString){
2832
- val = '';
915
+ tmp = date.getUTCMilliseconds();
916
+ if(tmp != "0"){
917
+ str += '.'+ addleadingZero(tmp, 3);
2833
918
  }
2834
- return val;
2835
- };
2836
- $.webshims.log('flash-localStorage was implemented');
2837
- }
2838
- }
2839
- if(!('localStorage' in window)){
2840
- window.localStorage = new Storage('local');
2841
- $.webshims.warn('implement cookie-localStorage');
2842
- }
2843
- $.webshims.isReady('json-storage', true);
2844
- };
2845
- var storageCFG = $.webshims.cfg['json-storage'];
2846
- webshims.swfLocalStorage = {
2847
- show: function(){
2848
- if(storageCFG.exceededMessage){
2849
- $('#swflocalstorageshim-wrapper').prepend('<div class="polyfill-exceeded-message">'+ storageCFG.exceededMessage +'</div>');
919
+ return str;
920
+ } else {
921
+ return false;
922
+ }
2850
923
  }
2851
- $('#swflocalstorageshim-wrapper').css({
2852
- top: $(window).scrollTop() + 20,
2853
- left: ($(window).width() / 2) - ($('#swflocalstorageshim-wrapper').outerWidth() / 2)
2854
- });
2855
-
2856
924
  },
2857
- hide: function(success){
2858
- $('#swflocalstorageshim-wrapper')
2859
- .css({top: '', left: ''})
2860
- .find('div.polyfill-exceeded-message')
2861
- .remove()
2862
- ;
2863
- if(!success){
2864
- var err = new Error('DOMException: QUOTA_EXCEEDED_ERR');
2865
- err.code = 22;
2866
- err.name = 'DOMException';
2867
- throw(err);
925
+ month: {
926
+ bad: function(val){
927
+ return typeProtos.date.bad(val+'-01');
928
+ },
929
+ step: 1,
930
+ stepScaleFactor: false,
931
+ //stepBase: 0, 0 = default
932
+ asDate: function(val){
933
+ return new Date(typeProtos.date.asNumber(val+'-01'));
934
+ },
935
+ asNumber: function(val){
936
+ //1970-01
937
+ var ret = nan;
938
+ if(val && !this.bad(val)){
939
+ val = val.split(/\u002D/);
940
+ val[0] = (val[0] * 1) - 1970;
941
+ val[1] = (val[1] * 1) - 1;
942
+ ret = (val[0] * 12) + val[1];
943
+ }
944
+ return ret;
945
+ },
946
+ numberToString: function(num){
947
+ var mod;
948
+ var ret = false;
949
+ if(isNumber(num)){
950
+ mod = (num % 12);
951
+ num = ((num - mod) / 12) + 1970;
952
+ mod += 1;
953
+ if(mod < 1){
954
+ num -= 1;
955
+ mod += 12;
956
+ }
957
+ ret = addleadingZero(num, 4)+'-'+addleadingZero(mod, 2);
958
+
959
+ }
960
+
961
+ return ret;
962
+ },
963
+ dateToString: function(date){
964
+ if(date && date.getUTCHours){
965
+ var str = typeProtos.date.dateToString(date);
966
+ return (str.split && (str = str.split(/\u002D/))) ? str[0]+'-'+str[1] : false;
967
+ } else {
968
+ return false;
969
+ }
2868
970
  }
2869
- },
2870
- isReady: localStorageSwfCallback
971
+ }
972
+ ,'datetime-local': {
973
+ bad: function(val, _getParsed){
974
+ if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;}
975
+ val = val.split(/\u0054/);
976
+ return ( typeProtos.date.bad(val[0]) || typeProtos.time.bad(val[1], _getParsed) );
977
+ },
978
+ noAsDate: true,
979
+ asDate: function(val){
980
+ val = new Date(this.asNumber(val));
981
+
982
+ return (isNaN(val)) ? null : val;
983
+ },
984
+ asNumber: function(val){
985
+ var ret = nan;
986
+ var time = this.bad(val, true);
987
+ if(time !== true){
988
+ val = val.split(/\u0054/)[0].split(/\u002D/);
989
+
990
+ ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0);
991
+ if(time[1]){
992
+ ret += time[1];
993
+ }
994
+ }
995
+ return ret;
996
+ },
997
+ dateToString: function(date, _getParsed){
998
+ return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed);
999
+ }
1000
+ }
2871
1001
  };
2872
1002
 
2873
- // $.webshims.swfLocalStorage.storageEvent = function(newVal, oldVal, url){
2874
- //
2875
- // };
1003
+ if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month') || !supportsType('datetime-local')){
1004
+ typeProtos.range = $.extend({}, typeProtos.number, typeProtos.range);
1005
+ typeProtos.time = $.extend({}, typeProtos.date, typeProtos.time);
1006
+ typeProtos.month = $.extend({}, typeProtos.date, typeProtos.month);
1007
+ typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']);
1008
+ }
2876
1009
 
2877
- webshims.ready('DOM swfmini', function(){
2878
-
2879
- var swfmini = window.swfmini;
2880
- if(runStart || (('localStorage' in window) && document.getElementById('swflocalstorageshim')) ){return;}
2881
- runStart = true;
2882
- if(swfmini && swfmini.hasFlashPlayerVersion('8.0.0')){
2883
- $('body').append('<div id="swflocalstorageshim-wrapper"><div id="swflocalstorageshim" /></div>');
2884
- swfmini.embedSWF(webshims.cfg.basePath +'swf/localStorage.swf' +(webshims.cfg.addCacheBuster || ''), 'swflocalstorageshim', '295', '198', '8.0.0', null, {allowscriptaccess: 'always'}, {name: 'swflocalstorageshim'}, function(e){
2885
- if(!e.success && !window.localStorage){
2886
- localStorageSwfCallback();
2887
- }
2888
- });
2889
- clearTimeout(swfTimer);
2890
- swfTimer = setTimeout(function(){
2891
- if(!('localStorage' in window)){
2892
- webshims.warn('Add your development-directory to the local-trusted security sandbox: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html');
2893
- }
2894
- localStorageSwfCallback();
2895
- }, (location.protocol.indexOf('file') === 0) ? 500 : 9999);
2896
- } else {
2897
- localStorageSwfCallback();
1010
+ //
1011
+ ['number', 'month', 'range', 'date', 'time', 'color', 'datetime-local'].forEach(function(type){
1012
+ if(typeBugs || !supportsType(type)){
1013
+ webshims.addInputType(type, typeProtos[type]);
2898
1014
  }
2899
1015
  });
2900
- })();
2901
-
2902
-
2903
- })();
2904
-
1016
+
1017
+ if($('<input />').prop('labels') == null){
1018
+ webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
1019
+ prop: {
1020
+ get: function(){
1021
+ if(this.type == 'hidden'){return null;}
1022
+ var id = this.id;
1023
+ var labels = $(this)
1024
+ .closest('label')
1025
+ .filter(function(){
1026
+ var hFor = (this.attributes['for'] || {});
1027
+ return (!hFor.specified || hFor.value == id);
1028
+ })
1029
+ ;
1030
+
1031
+ if(id) {
1032
+ labels = labels.add('label[for="'+ id +'"]');
1033
+ }
1034
+ return labels.get();
1035
+ },
1036
+ writeable: false
1037
+ }
1038
+ });
1039
+ }
1040
+
1041
+ });