webshims-rails 1.14.1 → 1.14.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/extras/modernizr-custom.js +0 -0
  4. data/vendor/assets/javascripts/webshims/polyfiller.js +3 -8
  5. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js +0 -0
  6. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/flashcanvas.js +0 -0
  7. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/flashcanvas.swf +0 -0
  8. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/proxy.php +0 -0
  9. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/save.php +0 -0
  10. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js +0 -0
  11. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flash10canvas.swf +0 -0
  12. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flash9canvas.swf +0 -0
  13. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flashcanvas.js +0 -0
  14. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/proxy.php +0 -0
  15. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/save.php +0 -0
  16. data/vendor/assets/javascripts/webshims/shims/color-picker.js +2 -2
  17. data/vendor/assets/javascripts/webshims/shims/combos/1.js +66 -43
  18. data/vendor/assets/javascripts/webshims/shims/combos/10.js +66 -31
  19. data/vendor/assets/javascripts/webshims/shims/combos/11.js +66 -31
  20. data/vendor/assets/javascripts/webshims/shims/combos/12.js +96 -59
  21. data/vendor/assets/javascripts/webshims/shims/combos/13.js +96 -59
  22. data/vendor/assets/javascripts/webshims/shims/combos/14.js +0 -0
  23. data/vendor/assets/javascripts/webshims/shims/combos/15.js +4 -1
  24. data/vendor/assets/javascripts/webshims/shims/combos/16.js +70 -44
  25. data/vendor/assets/javascripts/webshims/shims/combos/17.js +66 -31
  26. data/vendor/assets/javascripts/webshims/shims/combos/18.js +1241 -1126
  27. data/vendor/assets/javascripts/webshims/shims/combos/19.js +1272 -1214
  28. data/vendor/assets/javascripts/webshims/shims/combos/2.js +66 -43
  29. data/vendor/assets/javascripts/webshims/shims/combos/20.js +1272 -1214
  30. data/vendor/assets/javascripts/webshims/shims/combos/21.js +61 -92
  31. data/vendor/assets/javascripts/webshims/shims/combos/22.js +30 -16
  32. data/vendor/assets/javascripts/webshims/shims/combos/23.js +66 -43
  33. data/vendor/assets/javascripts/webshims/shims/combos/25.js +41 -85
  34. data/vendor/assets/javascripts/webshims/shims/combos/26.js +1556 -2316
  35. data/vendor/assets/javascripts/webshims/shims/combos/27.js +12 -10
  36. data/vendor/assets/javascripts/webshims/shims/combos/28.js +4 -1
  37. data/vendor/assets/javascripts/webshims/shims/combos/29.js +0 -0
  38. data/vendor/assets/javascripts/webshims/shims/combos/3.js +0 -0
  39. data/vendor/assets/javascripts/webshims/shims/combos/30.js +0 -0
  40. data/vendor/assets/javascripts/webshims/shims/combos/31.js +0 -0
  41. data/vendor/assets/javascripts/webshims/shims/combos/32.js +1175 -1095
  42. data/vendor/assets/javascripts/webshims/shims/combos/33.js +0 -0
  43. data/vendor/assets/javascripts/webshims/shims/combos/34.js +30 -16
  44. data/vendor/assets/javascripts/webshims/shims/combos/4.js +0 -0
  45. data/vendor/assets/javascripts/webshims/shims/combos/5.js +66 -31
  46. data/vendor/assets/javascripts/webshims/shims/combos/6.js +66 -31
  47. data/vendor/assets/javascripts/webshims/shims/combos/7.js +66 -43
  48. data/vendor/assets/javascripts/webshims/shims/combos/8.js +66 -43
  49. data/vendor/assets/javascripts/webshims/shims/combos/9.js +66 -31
  50. data/vendor/assets/javascripts/webshims/shims/combos/97.js +63 -28
  51. data/vendor/assets/javascripts/webshims/shims/combos/98.js +149 -74
  52. data/vendor/assets/javascripts/webshims/shims/combos/99.js +149 -74
  53. data/vendor/assets/javascripts/webshims/shims/combos/comboinfo.json +1 -1
  54. data/vendor/assets/javascripts/webshims/shims/details.js +0 -0
  55. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +0 -0
  56. data/vendor/assets/javascripts/webshims/shims/es5.js +1175 -1095
  57. data/vendor/assets/javascripts/webshims/shims/excanvas.js +0 -0
  58. data/vendor/assets/javascripts/webshims/shims/filereader.js +10 -9
  59. data/vendor/assets/javascripts/webshims/shims/form-combat.js +0 -0
  60. data/vendor/assets/javascripts/webshims/shims/form-core.js +0 -0
  61. data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +0 -0
  62. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +0 -0
  63. data/vendor/assets/javascripts/webshims/shims/form-fixrangechange.js +0 -0
  64. data/vendor/assets/javascripts/webshims/shims/form-message.js +0 -0
  65. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +0 -0
  66. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +0 -0
  67. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +40 -11
  68. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +4 -1
  69. data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +2 -1
  70. data/vendor/assets/javascripts/webshims/shims/form-validation.js +80 -47
  71. data/vendor/assets/javascripts/webshims/shims/form-validators.js +19 -8
  72. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +21 -1
  73. data/vendor/assets/javascripts/webshims/shims/geolocation.js +0 -0
  74. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ar.js +0 -0
  75. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ch-CN.js +0 -0
  76. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-cs.js +0 -0
  77. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-de.js +0 -0
  78. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-el.js +0 -0
  79. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-en.js +0 -0
  80. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-es.js +0 -0
  81. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-fa.js +130 -0
  82. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-fr.js +0 -0
  83. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-he.js +0 -0
  84. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-hi.js +0 -0
  85. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-hu.js +0 -0
  86. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-it.js +0 -0
  87. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ja.js +0 -0
  88. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-lt.js +0 -0
  89. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-nl.js +0 -0
  90. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pl.js +0 -0
  91. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pt-BR.js +0 -0
  92. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pt-PT.js +0 -0
  93. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pt.js +0 -0
  94. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ru.js +0 -0
  95. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-sv.js +0 -0
  96. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-zh-CN.js +0 -0
  97. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-zh-TW.js +130 -0
  98. data/vendor/assets/javascripts/webshims/shims/jajax.js +0 -0
  99. data/vendor/assets/javascripts/webshims/shims/jme/_icons.scss +186 -0
  100. data/vendor/assets/javascripts/webshims/shims/jme/b.js +63 -28
  101. data/vendor/assets/javascripts/webshims/shims/jme/c.js +86 -46
  102. data/vendor/assets/javascripts/webshims/shims/jme/controls.css +317 -211
  103. data/vendor/assets/javascripts/webshims/shims/jme/controls.scss +59 -223
  104. data/vendor/assets/javascripts/webshims/shims/jme/jme.eot +0 -0
  105. data/vendor/assets/javascripts/webshims/shims/jme/jme.svg +0 -0
  106. data/vendor/assets/javascripts/webshims/shims/jme/jme.ttf +0 -0
  107. data/vendor/assets/javascripts/webshims/shims/jme/jme.woff +0 -0
  108. data/vendor/assets/javascripts/webshims/shims/jme/mediacontrols-lazy.js +66 -14
  109. data/vendor/assets/javascripts/webshims/shims/jme/p.js +0 -0
  110. data/vendor/assets/javascripts/webshims/shims/jpicker/ChangeLog.txt +0 -0
  111. data/vendor/assets/javascripts/webshims/shims/jpicker/ReadMe.txt +0 -0
  112. data/vendor/assets/javascripts/webshims/shims/jpicker/images/AlphaBar.png +0 -0
  113. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Bars.png +0 -0
  114. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Maps.png +0 -0
  115. data/vendor/assets/javascripts/webshims/shims/jpicker/images/NoColor.png +0 -0
  116. data/vendor/assets/javascripts/webshims/shims/jpicker/images/bar-opacity.png +0 -0
  117. data/vendor/assets/javascripts/webshims/shims/jpicker/images/map-opacity.png +0 -0
  118. data/vendor/assets/javascripts/webshims/shims/jpicker/images/mappoint.gif +0 -0
  119. data/vendor/assets/javascripts/webshims/shims/jpicker/images/picker.gif +0 -0
  120. data/vendor/assets/javascripts/webshims/shims/jpicker/images/preview-opacity.png +0 -0
  121. data/vendor/assets/javascripts/webshims/shims/jpicker/images/rangearrows.gif +0 -0
  122. data/vendor/assets/javascripts/webshims/shims/jpicker/jpicker.css +55 -48
  123. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +66 -43
  124. data/vendor/assets/javascripts/webshims/shims/mediaelement-debug.js +833 -0
  125. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +31 -76
  126. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +0 -0
  127. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +0 -0
  128. data/vendor/assets/javascripts/webshims/shims/moxie/flash/Moxie.cdn.swf +0 -0
  129. data/vendor/assets/javascripts/webshims/shims/moxie/flash/Moxie.min.swf +0 -0
  130. data/vendor/assets/javascripts/webshims/shims/moxie/js/moxie.js +1542 -2303
  131. data/vendor/assets/javascripts/webshims/shims/moxie/silverlight/Moxie.cdn.xap +0 -0
  132. data/vendor/assets/javascripts/webshims/shims/moxie/silverlight/Moxie.min.xap +0 -0
  133. data/vendor/assets/javascripts/webshims/shims/picture.js +160 -79
  134. data/vendor/assets/javascripts/webshims/shims/plugins/jquery.ui.position.js +0 -0
  135. data/vendor/assets/javascripts/webshims/shims/promise.js +0 -0
  136. data/vendor/assets/javascripts/webshims/shims/range-ui.js +26 -20
  137. data/vendor/assets/javascripts/webshims/shims/sizzle.js +0 -0
  138. data/vendor/assets/javascripts/webshims/shims/styles/color-picker.png +0 -0
  139. data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +444 -326
  140. data/vendor/assets/javascripts/webshims/shims/styles/forms-picker.css +379 -300
  141. data/vendor/assets/javascripts/webshims/shims/styles/progress.gif +0 -0
  142. data/vendor/assets/javascripts/webshims/shims/styles/progress.png +0 -0
  143. data/vendor/assets/javascripts/webshims/shims/styles/scss/_api-forms-ext.scss +8 -8
  144. data/vendor/assets/javascripts/webshims/shims/styles/scss/_api-shim.scss +0 -0
  145. data/vendor/assets/javascripts/webshims/shims/styles/scss/_extends.scss +0 -14
  146. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +104 -85
  147. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-picker.scss +20 -32
  148. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim-ext.scss +0 -0
  149. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +14 -34
  150. data/vendor/assets/javascripts/webshims/shims/styles/shim-ext.css +920 -728
  151. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +471 -391
  152. data/vendor/assets/javascripts/webshims/shims/styles/widget.eot +0 -0
  153. data/vendor/assets/javascripts/webshims/shims/styles/widget.svg +0 -0
  154. data/vendor/assets/javascripts/webshims/shims/styles/widget.ttf +0 -0
  155. data/vendor/assets/javascripts/webshims/shims/styles/widget.woff +0 -0
  156. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  157. data/vendor/assets/javascripts/webshims/shims/swfmini-embed.js +0 -0
  158. data/vendor/assets/javascripts/webshims/shims/swfmini.js +0 -0
  159. data/vendor/assets/javascripts/webshims/shims/track-ui.js +0 -0
  160. data/vendor/assets/javascripts/webshims/shims/track.js +30 -16
  161. metadata +8 -4
  162. data/vendor/assets/javascripts/webshims/shims/styles/config.rb +0 -12
  163. data/vendor/assets/javascripts/webshims/shims/swf/filereader.swf +0 -0
@@ -628,6 +628,23 @@ webshims.register('form-number-date-api', function($, webshims, window, document
628
628
  return val * 1;
629
629
  };
630
630
  var createOpts = ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex'];
631
+ var normalizeTouch = (function(){
632
+ var types = {
633
+ touchstart: 1,
634
+ touchend: 1,
635
+ touchmove: 1
636
+ };
637
+ var normalize = ['pageX', 'pageY'];
638
+ return function(e){
639
+ if(types[e.type] && e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length){
640
+ for(var i = 0; i < normalize.length; i++){
641
+ e[normalize[i]] = e.originalEvent.touches[0][normalize[i]];
642
+ }
643
+
644
+ }
645
+ return e;
646
+ };
647
+ })();
631
648
  var rangeProto = {
632
649
  _create: function(){
633
650
  var i;
@@ -946,23 +963,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
946
963
  }
947
964
  };
948
965
  })();
949
- var normalizeTouch = (function(){
950
- var types = {
951
- touchstart: 1,
952
- touchend: 1,
953
- touchmove: 1
954
- };
955
- var normalize = ['pageX', 'pageY'];
956
- return function(e){
957
- if(types[e.type] && e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length){
958
- for(var i = 0; i < normalize.length; i++){
959
- e[normalize[i]] = e.originalEvent.touches[0][normalize[i]];
960
- }
961
-
962
- }
963
- return e;
964
- };
965
- })();
966
+
966
967
  var updateValue = function(val, animate){
967
968
  if(val != o.value){
968
969
  that.value(val, false, animate);
@@ -982,7 +983,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
982
983
  }
983
984
  };
984
985
  var remove = function(e){
985
- if(e && e.type == 'mouseup'){
986
+ if(e && (e.type == 'mouseup' || e.type == 'touchend')){
986
987
  eventTimer.call('input', o.value);
987
988
  eventTimer.call('change', o.value);
988
989
  }
@@ -1003,6 +1004,8 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1003
1004
  $(document).off('mousemove touchmove', setValueFromPos).off('mouseup touchend', remove);
1004
1005
  $(window).off('blur', removeWin);
1005
1006
  if(!o.readonly && !o.disabled){
1007
+ eventTimer.init('input', o.value);
1008
+ eventTimer.init('change', o.value);
1006
1009
  normalizeTouch(e);
1007
1010
  that.element.trigger('focus');
1008
1011
  that.addRemoveClass('ws-active', true);
@@ -1038,8 +1041,10 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1038
1041
  'touchstart mousedown': add,
1039
1042
  focus: function(e){
1040
1043
  if(!o.disabled && !hasFocus){
1041
- eventTimer.init('input', o.value);
1042
- eventTimer.init('change', o.value);
1044
+ if(!isActive){
1045
+ eventTimer.init('input', o.value);
1046
+ eventTimer.init('change', o.value);
1047
+ }
1043
1048
  that.addRemoveClass('ws-focus', true);
1044
1049
  that.updateMetrics();
1045
1050
  }
@@ -1225,6 +1230,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1225
1230
  obj._create.call(obj);
1226
1231
  });
1227
1232
  };
1233
+ $.fn.rangeUI.normalizeTouch = normalizeTouch;
1228
1234
  if(window.webshims && webshims.isReady){
1229
1235
  webshims.isReady('range-ui', true);
1230
1236
  }
@@ -1932,11 +1938,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1932
1938
  if( steps[this.type] && typeof steps[this.type].start == 'object'){
1933
1939
  steps[this.type].start = this.asNumber(steps[this.type].start);
1934
1940
  }
1935
-
1936
- if(!webshims.picker[this.type]){
1937
- o.buttonOnly = false;
1938
- }
1939
-
1941
+
1940
1942
  for(i = 0; i < createOpts.length; i++){
1941
1943
  if(o[createOpts[i]] != null){
1942
1944
  this[createOpts[i]](o[createOpts[i]], o[createOpts[i]]);
@@ -2166,7 +2168,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2166
2168
  wsWidgetProto._create.apply(this, arguments);
2167
2169
  this._init = false;
2168
2170
 
2169
- this.buttonWrapper.html('<span unselectable="on" class="step-controls"><span class="step-up"></span><span class="step-down"></span></span>');
2171
+ this.buttonWrapper.html('<span unselectable="on" class="step-controls"><span class="step-up step-control"></span><span class="step-down step-control"></span></span>');
2170
2172
 
2171
2173
  if(this.type == 'number'){
2172
2174
  this.inputElements.attr('inputmode', 'numeric');
@@ -2349,7 +2351,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2349
2351
  }
2350
2352
 
2351
2353
  touch = changedTouches[0];
2352
- if(Math.abs(touchData.x - touch.pageX) > 40 || Math.abs(touchData.y - touch.pageY) > 40 || Date.now() - touchData.now > 600){
2354
+ if(Math.abs(touchData.x - touch.pageX) > 40 || Math.abs(touchData.y - touch.pageY) > 40 || Date.now() - touchData.now > 300){
2353
2355
  return;
2354
2356
  }
2355
2357
  e.preventDefault();
@@ -2547,7 +2549,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2547
2549
  }
2548
2550
  };
2549
2551
  return function(prop){
2550
- if(prop == 'value' && !data.options.inlinePicker){return;}
2552
+ if(prop == 'value' && (!data.options.inlinePicker || data._handledValue )){return;}
2551
2553
  popover.isDirty = true;
2552
2554
 
2553
2555
  if(popover.isVisible){
@@ -2606,6 +2608,13 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2606
2608
  }
2607
2609
  show();
2608
2610
  };
2611
+ var toogle = function(){
2612
+ if(popover.openedByFocus || !popover.isVisible){
2613
+ open();
2614
+ } else {
2615
+ popover.hide();
2616
+ }
2617
+ }
2609
2618
 
2610
2619
 
2611
2620
  options.containerElements.push(popover.element[0]);
@@ -2646,7 +2655,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2646
2655
  }
2647
2656
 
2648
2657
 
2649
- opener.wsTouchClick(open);
2658
+ opener.wsTouchClick(toogle);
2650
2659
 
2651
2660
  if(options.inlinePicker){
2652
2661
  popover.openedByFocus = true;
@@ -2998,9 +3007,9 @@ webshims.register('form-number-date-api', function($, webshims, window, document
2998
3007
  }
2999
3008
 
3000
3009
  data.shim.element.on('change input', stopPropagation).addClass(cNames+' '+webshims.shadowClass);
3001
-
3010
+
3002
3011
  if(data.shim.buttonWrapper){
3003
-
3012
+
3004
3013
  data.shim.buttonWrapper.addClass('input-button-size-'+(data.shim.buttonWrapper.children().filter(isVisible).length)+' '+webshims.shadowClass);
3005
3014
 
3006
3015
  if(data.shim.buttonWrapper.filter(isVisible).length){
@@ -3157,6 +3166,32 @@ webshims.register('form-number-date-api', function($, webshims, window, document
3157
3166
  ;
3158
3167
  });
3159
3168
  };
3169
+
3170
+
3171
+ if($('<input />').prop('labels') == null){
3172
+ webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
3173
+ prop: {
3174
+ get: function(){
3175
+ if(this.type == 'hidden'){return null;}
3176
+ var id = this.id;
3177
+ var labels = $(this)
3178
+ .closest('label')
3179
+ .filter(function(){
3180
+ var hFor = (this.attributes['for'] || {});
3181
+ return (!hFor.specified || hFor.value == id);
3182
+ })
3183
+ ;
3184
+
3185
+ if(id) {
3186
+ labels = labels.add('label[for="'+ id +'"]');
3187
+ }
3188
+ return labels.get();
3189
+ },
3190
+ writeable: false
3191
+ }
3192
+ });
3193
+ }
3194
+
3160
3195
  if(formcfg._isLoading){
3161
3196
  $(formcfg).one('change', init);
3162
3197
  } else {
@@ -5,14 +5,50 @@
5
5
  setTimeout(function(){
6
6
  webshims.isReady('es5', true);
7
7
  });
8
- /**
9
- * Brings an environment as close to ECMAScript 5 compliance
10
- * as is possible with the facilities of erstwhile engines.
11
- *
12
- * Annotated ES5: http://es5.github.com/ (specific links below)
13
- * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
14
- * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
15
- */
8
+ /**
9
+ * Brings an environment as close to ECMAScript 5 compliance
10
+ * as is possible with the facilities of erstwhile engines.
11
+ *
12
+ * Annotated ES5: http://es5.github.com/ (specific links below)
13
+ * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
14
+ * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
15
+ */
16
+
17
+ // Shortcut to an often accessed properties, in order to avoid multiple
18
+ // dereference that costs universally.
19
+ var call = Function.prototype.call;
20
+ var prototypeOfArray = Array.prototype;
21
+ var prototypeOfObject = Object.prototype;
22
+ var _Array_slice_ = prototypeOfArray.slice;
23
+ var array_splice = Array.prototype.splice;
24
+ var array_push = Array.prototype.push;
25
+ var array_unshift = Array.prototype.unshift;
26
+
27
+ // Having a toString local variable name breaks in Opera so use _toString.
28
+ var _toString = prototypeOfObject.toString;
29
+
30
+ var isFunction = function (val) {
31
+ return prototypeOfObject.toString.call(val) === '[object Function]';
32
+ };
33
+ var isRegex = function (val) {
34
+ return prototypeOfObject.toString.call(val) === '[object RegExp]';
35
+ };
36
+ var isArray = function isArray(obj) {
37
+ return _toString.call(obj) === "[object Array]";
38
+ };
39
+ var isArguments = function isArguments(value) {
40
+ var str = _toString.call(value);
41
+ var isArgs = str === '[object Arguments]';
42
+ if (!isArgs) {
43
+ isArgs = !isArray(str)
44
+ && value !== null
45
+ && typeof value === 'object'
46
+ && typeof value.length === 'number'
47
+ && value.length >= 0
48
+ && isFunction(value.callee);
49
+ }
50
+ return isArgs;
51
+ };
16
52
 
17
53
  //
18
54
  // Function
@@ -22,150 +58,157 @@ setTimeout(function(){
22
58
  // ES-5 15.3.4.5
23
59
  // http://es5.github.com/#x15.3.4.5
24
60
 
25
- function Empty() {}
61
+ function Empty() {}
26
62
 
27
- if (!Function.prototype.bind) {
28
- Function.prototype.bind = function bind(that) { // .length is 1
29
- // 1. Let Target be the this value.
30
- var target = this;
31
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
32
- if (typeof target != "function") {
33
- throw new TypeError("Function.prototype.bind called on incompatible " + target);
34
- }
35
- // 3. Let A be a new (possibly empty) internal list of all of the
36
- // argument values provided after thisArg (arg1, arg2 etc), in order.
37
- // XXX slicedArgs will stand in for "A" if used
38
- var args = _Array_slice_.call(arguments, 1); // for normal call
39
- // 4. Let F be a new native ECMAScript object.
40
- // 11. Set the [[Prototype]] internal property of F to the standard
41
- // built-in Function prototype object as specified in 15.3.3.1.
42
- // 12. Set the [[Call]] internal property of F as described in
43
- // 15.3.4.5.1.
44
- // 13. Set the [[Construct]] internal property of F as described in
45
- // 15.3.4.5.2.
46
- // 14. Set the [[HasInstance]] internal property of F as described in
47
- // 15.3.4.5.3.
48
- var bound = function () {
49
-
50
- if (this instanceof bound) {
51
- // 15.3.4.5.2 [[Construct]]
52
- // When the [[Construct]] internal method of a function object,
53
- // F that was created using the bind function is called with a
54
- // list of arguments ExtraArgs, the following steps are taken:
55
- // 1. Let target be the value of F's [[TargetFunction]]
56
- // internal property.
57
- // 2. If target has no [[Construct]] internal method, a
58
- // TypeError exception is thrown.
59
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
60
- // property.
61
- // 4. Let args be a new list containing the same values as the
62
- // list boundArgs in the same order followed by the same
63
- // values as the list ExtraArgs in the same order.
64
- // 5. Return the result of calling the [[Construct]] internal
65
- // method of target providing args as the arguments.
66
-
67
- var result = target.apply(
68
- this,
69
- args.concat(_Array_slice_.call(arguments))
70
- );
71
- if (Object(result) === result) {
72
- return result;
73
- }
74
- return this;
75
-
76
- } else {
77
- // 15.3.4.5.1 [[Call]]
78
- // When the [[Call]] internal method of a function object, F,
79
- // which was created using the bind function is called with a
80
- // this value and a list of arguments ExtraArgs, the following
81
- // steps are taken:
82
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
83
- // property.
84
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
85
- // property.
86
- // 3. Let target be the value of F's [[TargetFunction]] internal
87
- // property.
88
- // 4. Let args be a new list containing the same values as the
89
- // list boundArgs in the same order followed by the same
90
- // values as the list ExtraArgs in the same order.
91
- // 5. Return the result of calling the [[Call]] internal method
92
- // of target providing boundThis as the this value and
93
- // providing args as the arguments.
94
-
95
- // equiv: target.call(this, ...boundArgs, ...args)
96
- return target.apply(
97
- that,
98
- args.concat(_Array_slice_.call(arguments))
99
- );
100
-
101
- }
63
+ if (!Function.prototype.bind) {
64
+ Function.prototype.bind = function bind(that) { // .length is 1
65
+ // 1. Let Target be the this value.
66
+ var target = this;
67
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
68
+ if (!isFunction(target)) {
69
+ throw new TypeError("Function.prototype.bind called on incompatible " + target);
70
+ }
71
+ // 3. Let A be a new (possibly empty) internal list of all of the
72
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
73
+ // XXX slicedArgs will stand in for "A" if used
74
+ var args = _Array_slice_.call(arguments, 1); // for normal call
75
+ // 4. Let F be a new native ECMAScript object.
76
+ // 11. Set the [[Prototype]] internal property of F to the standard
77
+ // built-in Function prototype object as specified in 15.3.3.1.
78
+ // 12. Set the [[Call]] internal property of F as described in
79
+ // 15.3.4.5.1.
80
+ // 13. Set the [[Construct]] internal property of F as described in
81
+ // 15.3.4.5.2.
82
+ // 14. Set the [[HasInstance]] internal property of F as described in
83
+ // 15.3.4.5.3.
84
+ var binder = function () {
85
+
86
+ if (this instanceof bound) {
87
+ // 15.3.4.5.2 [[Construct]]
88
+ // When the [[Construct]] internal method of a function object,
89
+ // F that was created using the bind function is called with a
90
+ // list of arguments ExtraArgs, the following steps are taken:
91
+ // 1. Let target be the value of F's [[TargetFunction]]
92
+ // internal property.
93
+ // 2. If target has no [[Construct]] internal method, a
94
+ // TypeError exception is thrown.
95
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
96
+ // property.
97
+ // 4. Let args be a new list containing the same values as the
98
+ // list boundArgs in the same order followed by the same
99
+ // values as the list ExtraArgs in the same order.
100
+ // 5. Return the result of calling the [[Construct]] internal
101
+ // method of target providing args as the arguments.
102
+
103
+ var result = target.apply(
104
+ this,
105
+ args.concat(_Array_slice_.call(arguments))
106
+ );
107
+ if (Object(result) === result) {
108
+ return result;
109
+ }
110
+ return this;
102
111
 
103
- };
104
- if(target.prototype) {
105
- Empty.prototype = target.prototype;
106
- bound.prototype = new Empty();
107
- // Clean up dangling references.
108
- Empty.prototype = null;
109
- }
110
- // XXX bound.length is never writable, so don't even try
111
- //
112
- // 15. If the [[Class]] internal property of Target is "Function", then
113
- // a. Let L be the length property of Target minus the length of A.
114
- // b. Set the length own property of F to either 0 or L, whichever is
115
- // larger.
116
- // 16. Else set the length own property of F to 0.
117
- // 17. Set the attributes of the length own property of F to the values
118
- // specified in 15.3.5.1.
119
-
120
- // TODO
121
- // 18. Set the [[Extensible]] internal property of F to true.
122
-
123
- // TODO
124
- // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
125
- // 20. Call the [[DefineOwnProperty]] internal method of F with
126
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
127
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
128
- // false.
129
- // 21. Call the [[DefineOwnProperty]] internal method of F with
130
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
131
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
132
- // and false.
133
-
134
- // TODO
135
- // NOTE Function objects created using Function.prototype.bind do not
136
- // have a prototype property or the [[Code]], [[FormalParameters]], and
137
- // [[Scope]] internal properties.
138
- // XXX can't delete prototype in pure-js.
139
-
140
- // 22. Return F.
141
- return bound;
142
- };
143
- }
112
+ } else {
113
+ // 15.3.4.5.1 [[Call]]
114
+ // When the [[Call]] internal method of a function object, F,
115
+ // which was created using the bind function is called with a
116
+ // this value and a list of arguments ExtraArgs, the following
117
+ // steps are taken:
118
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
119
+ // property.
120
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
121
+ // property.
122
+ // 3. Let target be the value of F's [[TargetFunction]] internal
123
+ // property.
124
+ // 4. Let args be a new list containing the same values as the
125
+ // list boundArgs in the same order followed by the same
126
+ // values as the list ExtraArgs in the same order.
127
+ // 5. Return the result of calling the [[Call]] internal method
128
+ // of target providing boundThis as the this value and
129
+ // providing args as the arguments.
130
+
131
+ // equiv: target.call(this, ...boundArgs, ...args)
132
+ return target.apply(
133
+ that,
134
+ args.concat(_Array_slice_.call(arguments))
135
+ );
136
+
137
+ }
138
+
139
+ };
140
+
141
+ // 15. If the [[Class]] internal property of Target is "Function", then
142
+ // a. Let L be the length property of Target minus the length of A.
143
+ // b. Set the length own property of F to either 0 or L, whichever is
144
+ // larger.
145
+ // 16. Else set the length own property of F to 0.
146
+
147
+ var boundLength = Math.max(0, target.length - args.length);
148
+
149
+ // 17. Set the attributes of the length own property of F to the values
150
+ // specified in 15.3.5.1.
151
+ var boundArgs = [];
152
+ for (var i = 0; i < boundLength; i++) {
153
+ boundArgs.push("$" + i);
154
+ }
155
+
156
+ // XXX Build a dynamic function with desired amount of arguments is the only
157
+ // way to set the length property of a function.
158
+ // In environments where Content Security Policies enabled (Chrome extensions,
159
+ // for ex.) all use of eval or Function costructor throws an exception.
160
+ // However in all of these environments Function.prototype.bind exists
161
+ // and so this code will never be executed.
162
+ var bound = Function("binder", "return function (" + boundArgs.join(",") + "){return binder.apply(this,arguments)}")(binder);
163
+
164
+ if (target.prototype) {
165
+ Empty.prototype = target.prototype;
166
+ bound.prototype = new Empty();
167
+ // Clean up dangling references.
168
+ Empty.prototype = null;
169
+ }
170
+
171
+ // TODO
172
+ // 18. Set the [[Extensible]] internal property of F to true.
173
+
174
+ // TODO
175
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
176
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
177
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
178
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
179
+ // false.
180
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
181
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
182
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
183
+ // and false.
184
+
185
+ // TODO
186
+ // NOTE Function objects created using Function.prototype.bind do not
187
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
188
+ // [[Scope]] internal properties.
189
+ // XXX can't delete prototype in pure-js.
190
+
191
+ // 22. Return F.
192
+ return bound;
193
+ };
194
+ }
144
195
 
145
- // Shortcut to an often accessed properties, in order to avoid multiple
146
- // dereference that costs universally.
147
196
  // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
148
197
  // us it in defining shortcuts.
149
- var call = Function.prototype.call;
150
- var prototypeOfArray = Array.prototype;
151
- var prototypeOfObject = Object.prototype;
152
- var _Array_slice_ = prototypeOfArray.slice;
153
- // Having a toString local variable name breaks in Opera so use _toString.
154
- var _toString = call.bind(prototypeOfObject.toString);
155
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
198
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
156
199
 
157
200
  // If JS engine supports accessors creating shortcuts.
158
- var defineGetter;
159
- var defineSetter;
160
- var lookupGetter;
161
- var lookupSetter;
162
- var supportsAccessors;
163
- if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
164
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
165
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
166
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
167
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
168
- }
201
+ var defineGetter;
202
+ var defineSetter;
203
+ var lookupGetter;
204
+ var lookupSetter;
205
+ var supportsAccessors;
206
+ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
207
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
208
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
209
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
210
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
211
+ }
169
212
 
170
213
  //
171
214
  // Array
@@ -174,127 +217,63 @@ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
174
217
 
175
218
  // ES5 15.4.4.12
176
219
  // http://es5.github.com/#x15.4.4.12
177
- // Default value for second param
178
- // [bugfix, ielt9, old browsers]
179
- // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
180
- if ([1,2].splice(0).length != 2) {
181
- var array_splice = Array.prototype.splice;
182
-
183
- if(function() { // test IE < 9 to splice bug - see issue #138
184
- function makeArray(l) {
185
- var a = [];
186
- while (l--) {
187
- a.unshift(l)
188
- }
189
- return a
190
- }
191
-
192
- var array = []
193
- , lengthBefore
194
- ;
195
-
196
- array.splice.bind(array, 0, 0).apply(null, makeArray(20));
197
- array.splice.bind(array, 0, 0).apply(null, makeArray(26));
198
-
199
- lengthBefore = array.length; //20
200
- array.splice(5, 0, "XXX"); // add one element
201
-
202
- if(lengthBefore + 1 == array.length) {
203
- return true;// has right splice implementation without bugs
204
- }
205
- // else {
206
- // IE8 bug
207
- // }
208
- }()) {//IE 6/7
209
- Array.prototype.splice = function(start, deleteCount) {
210
- if (!arguments.length) {
211
- return [];
212
- } else {
213
- return array_splice.apply(this, [
214
- start === void 0 ? 0 : start,
215
- deleteCount === void 0 ? (this.length - start) : deleteCount
216
- ].concat(_Array_slice_.call(arguments, 2)))
217
- }
218
- };
219
- }
220
- else {//IE8
221
- Array.prototype.splice = function(start, deleteCount) {
222
- var result
223
- , args = _Array_slice_.call(arguments, 2)
224
- , addElementsCount = args.length
225
- ;
226
-
227
- if(!arguments.length) {
228
- return [];
229
- }
230
-
231
- if(start === void 0) { // default
232
- start = 0;
233
- }
234
- if(deleteCount === void 0) { // default
235
- deleteCount = this.length - start;
236
- }
237
-
238
- if(addElementsCount > 0) {
239
- if(deleteCount <= 0) {
240
- if(start == this.length) { // tiny optimisation #1
241
- this.push.apply(this, args);
242
- return [];
243
- }
244
-
245
- if(start == 0) { // tiny optimisation #2
246
- this.unshift.apply(this, args);
247
- return [];
248
- }
249
- }
250
-
251
- // Array.prototype.splice implementation
252
- result = _Array_slice_.call(this, start, start + deleteCount);// delete part
253
- args.push.apply(args, _Array_slice_.call(this, start + deleteCount, this.length));// right part
254
- args.unshift.apply(args, _Array_slice_.call(this, 0, start));// left part
255
-
256
- // delete all items from this array and replace it to 'left part' + _Array_slice_.call(arguments, 2) + 'right part'
257
- args.unshift(0, this.length);
258
-
259
- array_splice.apply(this, args);
260
-
261
- return result;
262
- }
263
-
264
- return array_splice.call(this, start, deleteCount);
265
- }
266
-
267
- }
268
- }
220
+ var spliceWorksWithEmptyObject = (function () {
221
+ var obj = {};
222
+ Array.prototype.splice.call(obj, 0, 0, 1);
223
+ return obj.length === 1;
224
+ }());
225
+ var omittingSecondSpliceArgIsNoop = [1].splice(0).length === 0;
226
+ var spliceNoopReturnsEmptyArray = (function () {
227
+ var a = [1, 2];
228
+ var result = a.splice();
229
+ return a.length === 2 && isArray(result) && result.length === 0;
230
+ }());
231
+ if (spliceNoopReturnsEmptyArray) {
232
+ // Safari 5.0 bug where .split() returns undefined
233
+ Array.prototype.splice = function splice(start, deleteCount) {
234
+ if (arguments.length === 0) { return []; }
235
+ else { return array_splice.apply(this, arguments); }
236
+ };
237
+ }
238
+ if (!omittingSecondSpliceArgIsNoop || !spliceWorksWithEmptyObject) {
239
+ Array.prototype.splice = function splice(start, deleteCount) {
240
+ if (arguments.length === 0) { return []; }
241
+ var args = arguments;
242
+ this.length = Math.max(toInteger(this.length), 0);
243
+ if (arguments.length > 0 && typeof deleteCount !== 'number') {
244
+ args = _Array_slice_.call(arguments);
245
+ if (args.length < 2) { args.push(toInteger(deleteCount)); }
246
+ else { args[1] = toInteger(deleteCount); }
247
+ }
248
+ return array_splice.apply(this, args);
249
+ };
250
+ }
269
251
 
270
252
  // ES5 15.4.4.12
271
253
  // http://es5.github.com/#x15.4.4.13
272
254
  // Return len+argCount.
273
255
  // [bugfix, ielt8]
274
- // IE < 8 bug: [].unshift(0) == undefined but should be "1"
275
- if ([].unshift(0) != 1) {
276
- var array_unshift = Array.prototype.unshift;
277
- Array.prototype.unshift = function() {
278
- array_unshift.apply(this, arguments);
279
- return this.length;
280
- };
281
- }
256
+ // IE < 8 bug: [].unshift(0) === undefined but should be "1"
257
+ if ([].unshift(0) !== 1) {
258
+ Array.prototype.unshift = function () {
259
+ array_unshift.apply(this, arguments);
260
+ return this.length;
261
+ };
262
+ }
282
263
 
283
264
  // ES5 15.4.3.2
284
265
  // http://es5.github.com/#x15.4.3.2
285
266
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
286
- if (!Array.isArray) {
287
- Array.isArray = function isArray(obj) {
288
- return _toString(obj) == "[object Array]";
289
- };
290
- }
267
+ if (!Array.isArray) {
268
+ Array.isArray = isArray;
269
+ }
291
270
 
292
271
  // The IsCallable() check in the Array functions
293
272
  // has been replaced with a strict check on the
294
273
  // internal class of the object to trap cases where
295
274
  // the provided function was actually a regular
296
275
  // expression literal, which in V8 and
297
- // JavaScriptCore is a typeof "function". Only in
276
+ // JavaScriptCore is a typeof "function". Only in
298
277
  // V8 are regular expression literals permitted as
299
278
  // reduce parameters, so it is desirable in the
300
279
  // general case for the shim to match the more
@@ -307,302 +286,328 @@ if (!Array.isArray) {
307
286
 
308
287
  // Check failure of by-index access of string characters (IE < 9)
309
288
  // and failure of `0 in boxedString` (Rhino)
310
- var boxedString = Object("a"),
311
- splitString = boxedString[0] != "a" || !(0 in boxedString);
312
-
313
- if (!Array.prototype.forEach) {
314
- Array.prototype.forEach = function forEach(fun /*, thisp*/) {
315
- var object = toObject(this),
316
- self = splitString && _toString(this) == "[object String]" ?
317
- this.split("") :
318
- object,
319
- thisp = arguments[1],
320
- i = -1,
321
- length = self.length >>> 0;
322
-
323
- // If no callback function or if callback is not a callable function
324
- if (_toString(fun) != "[object Function]") {
325
- throw new TypeError(); // TODO message
326
- }
289
+ var boxedString = Object("a");
290
+ var splitString = boxedString[0] !== "a" || !(0 in boxedString);
291
+
292
+ var properlyBoxesContext = function properlyBoxed(method) {
293
+ // Check node 0.6.21 bug where third parameter is not boxed
294
+ var properlyBoxesNonStrict = true;
295
+ var properlyBoxesStrict = true;
296
+ if (method) {
297
+ method.call('foo', function (_, __, context) {
298
+ if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
299
+ });
327
300
 
328
- while (++i < length) {
329
- if (i in self) {
330
- // Invoke the callback function with call, passing arguments:
331
- // context, property value, property key, thisArg object
332
- // context
333
- fun.call(thisp, self[i], i, object);
334
- }
335
- }
336
- };
337
- }
301
+ method.call([1], function () {
302
+ 'use strict';
303
+ properlyBoxesStrict = typeof this === 'string';
304
+ }, 'x');
305
+ }
306
+ return !!method && properlyBoxesNonStrict && properlyBoxesStrict;
307
+ };
308
+
309
+ if (!Array.prototype.forEach || !properlyBoxesContext(Array.prototype.forEach)) {
310
+ Array.prototype.forEach = function forEach(fun /*, thisp*/) {
311
+ var object = toObject(this),
312
+ self = splitString && _toString.call(this) === "[object String]" ?
313
+ this.split("") :
314
+ object,
315
+ thisp = arguments[1],
316
+ i = -1,
317
+ length = self.length >>> 0;
318
+
319
+ // If no callback function or if callback is not a callable function
320
+ if (!isFunction(fun)) {
321
+ throw new TypeError(); // TODO message
322
+ }
323
+
324
+ while (++i < length) {
325
+ if (i in self) {
326
+ // Invoke the callback function with call, passing arguments:
327
+ // context, property value, property key, thisArg object
328
+ // context
329
+ fun.call(thisp, self[i], i, object);
330
+ }
331
+ }
332
+ };
333
+ }
338
334
 
339
335
  // ES5 15.4.4.19
340
336
  // http://es5.github.com/#x15.4.4.19
341
337
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
342
- if (!Array.prototype.map) {
343
- Array.prototype.map = function map(fun /*, thisp*/) {
344
- var object = toObject(this),
345
- self = splitString && _toString(this) == "[object String]" ?
346
- this.split("") :
347
- object,
348
- length = self.length >>> 0,
349
- result = Array(length),
350
- thisp = arguments[1];
351
-
352
- // If no callback function or if callback is not a callable function
353
- if (_toString(fun) != "[object Function]") {
354
- throw new TypeError(fun + " is not a function");
355
- }
338
+ if (!Array.prototype.map || !properlyBoxesContext(Array.prototype.map)) {
339
+ Array.prototype.map = function map(fun /*, thisp*/) {
340
+ var object = toObject(this),
341
+ self = splitString && _toString.call(this) === "[object String]" ?
342
+ this.split("") :
343
+ object,
344
+ length = self.length >>> 0,
345
+ result = Array(length),
346
+ thisp = arguments[1];
347
+
348
+ // If no callback function or if callback is not a callable function
349
+ if (!isFunction(fun)) {
350
+ throw new TypeError(fun + " is not a function");
351
+ }
356
352
 
357
- for (var i = 0; i < length; i++) {
358
- if (i in self)
359
- result[i] = fun.call(thisp, self[i], i, object);
360
- }
361
- return result;
362
- };
363
- }
353
+ for (var i = 0; i < length; i++) {
354
+ if (i in self) {
355
+ result[i] = fun.call(thisp, self[i], i, object);
356
+ }
357
+ }
358
+ return result;
359
+ };
360
+ }
364
361
 
365
362
  // ES5 15.4.4.20
366
363
  // http://es5.github.com/#x15.4.4.20
367
364
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
368
- if (!Array.prototype.filter) {
369
- Array.prototype.filter = function filter(fun /*, thisp */) {
370
- var object = toObject(this),
371
- self = splitString && _toString(this) == "[object String]" ?
372
- this.split("") :
373
- object,
374
- length = self.length >>> 0,
375
- result = [],
376
- value,
377
- thisp = arguments[1];
378
-
379
- // If no callback function or if callback is not a callable function
380
- if (_toString(fun) != "[object Function]") {
381
- throw new TypeError(fun + " is not a function");
382
- }
365
+ if (!Array.prototype.filter || !properlyBoxesContext(Array.prototype.filter)) {
366
+ Array.prototype.filter = function filter(fun /*, thisp */) {
367
+ var object = toObject(this),
368
+ self = splitString && _toString.call(this) === "[object String]" ?
369
+ this.split("") :
370
+ object,
371
+ length = self.length >>> 0,
372
+ result = [],
373
+ value,
374
+ thisp = arguments[1];
375
+
376
+ // If no callback function or if callback is not a callable function
377
+ if (!isFunction(fun)) {
378
+ throw new TypeError(fun + " is not a function");
379
+ }
383
380
 
384
- for (var i = 0; i < length; i++) {
385
- if (i in self) {
386
- value = self[i];
387
- if (fun.call(thisp, value, i, object)) {
388
- result.push(value);
389
- }
390
- }
391
- }
392
- return result;
393
- };
394
- }
381
+ for (var i = 0; i < length; i++) {
382
+ if (i in self) {
383
+ value = self[i];
384
+ if (fun.call(thisp, value, i, object)) {
385
+ result.push(value);
386
+ }
387
+ }
388
+ }
389
+ return result;
390
+ };
391
+ }
395
392
 
396
393
  // ES5 15.4.4.16
397
394
  // http://es5.github.com/#x15.4.4.16
398
395
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
399
- if (!Array.prototype.every) {
400
- Array.prototype.every = function every(fun /*, thisp */) {
401
- var object = toObject(this),
402
- self = splitString && _toString(this) == "[object String]" ?
403
- this.split("") :
404
- object,
405
- length = self.length >>> 0,
406
- thisp = arguments[1];
407
-
408
- // If no callback function or if callback is not a callable function
409
- if (_toString(fun) != "[object Function]") {
410
- throw new TypeError(fun + " is not a function");
411
- }
396
+ if (!Array.prototype.every || !properlyBoxesContext(Array.prototype.every)) {
397
+ Array.prototype.every = function every(fun /*, thisp */) {
398
+ var object = toObject(this),
399
+ self = splitString && _toString.call(this) === "[object String]" ?
400
+ this.split("") :
401
+ object,
402
+ length = self.length >>> 0,
403
+ thisp = arguments[1];
404
+
405
+ // If no callback function or if callback is not a callable function
406
+ if (!isFunction(fun)) {
407
+ throw new TypeError(fun + " is not a function");
408
+ }
412
409
 
413
- for (var i = 0; i < length; i++) {
414
- if (i in self && !fun.call(thisp, self[i], i, object)) {
415
- return false;
416
- }
417
- }
418
- return true;
419
- };
420
- }
410
+ for (var i = 0; i < length; i++) {
411
+ if (i in self && !fun.call(thisp, self[i], i, object)) {
412
+ return false;
413
+ }
414
+ }
415
+ return true;
416
+ };
417
+ }
421
418
 
422
419
  // ES5 15.4.4.17
423
420
  // http://es5.github.com/#x15.4.4.17
424
421
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
425
- if (!Array.prototype.some) {
426
- Array.prototype.some = function some(fun /*, thisp */) {
427
- var object = toObject(this),
428
- self = splitString && _toString(this) == "[object String]" ?
429
- this.split("") :
430
- object,
431
- length = self.length >>> 0,
432
- thisp = arguments[1];
433
-
434
- // If no callback function or if callback is not a callable function
435
- if (_toString(fun) != "[object Function]") {
436
- throw new TypeError(fun + " is not a function");
437
- }
422
+ if (!Array.prototype.some || !properlyBoxesContext(Array.prototype.some)) {
423
+ Array.prototype.some = function some(fun /*, thisp */) {
424
+ var object = toObject(this),
425
+ self = splitString && _toString.call(this) === "[object String]" ?
426
+ this.split("") :
427
+ object,
428
+ length = self.length >>> 0,
429
+ thisp = arguments[1];
430
+
431
+ // If no callback function or if callback is not a callable function
432
+ if (!isFunction(fun)) {
433
+ throw new TypeError(fun + " is not a function");
434
+ }
438
435
 
439
- for (var i = 0; i < length; i++) {
440
- if (i in self && fun.call(thisp, self[i], i, object)) {
441
- return true;
442
- }
443
- }
444
- return false;
445
- };
446
- }
436
+ for (var i = 0; i < length; i++) {
437
+ if (i in self && fun.call(thisp, self[i], i, object)) {
438
+ return true;
439
+ }
440
+ }
441
+ return false;
442
+ };
443
+ }
447
444
 
448
445
  // ES5 15.4.4.21
449
446
  // http://es5.github.com/#x15.4.4.21
450
447
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
451
- if (!Array.prototype.reduce) {
452
- Array.prototype.reduce = function reduce(fun /*, initial*/) {
453
- var object = toObject(this),
454
- self = splitString && _toString(this) == "[object String]" ?
455
- this.split("") :
456
- object,
457
- length = self.length >>> 0;
458
-
459
- // If no callback function or if callback is not a callable function
460
- if (_toString(fun) != "[object Function]") {
461
- throw new TypeError(fun + " is not a function");
462
- }
448
+ var reduceCoercesToObject = false;
449
+ if (Array.prototype.reduce) {
450
+ reduceCoercesToObject = typeof Array.prototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
451
+ }
452
+ if (!Array.prototype.reduce || !reduceCoercesToObject) {
453
+ Array.prototype.reduce = function reduce(fun /*, initial*/) {
454
+ var object = toObject(this),
455
+ self = splitString && _toString.call(this) === "[object String]" ?
456
+ this.split("") :
457
+ object,
458
+ length = self.length >>> 0;
459
+
460
+ // If no callback function or if callback is not a callable function
461
+ if (!isFunction(fun)) {
462
+ throw new TypeError(fun + " is not a function");
463
+ }
463
464
 
464
- // no value to return if no initial value and an empty array
465
- if (!length && arguments.length == 1) {
466
- throw new TypeError("reduce of empty array with no initial value");
467
- }
465
+ // no value to return if no initial value and an empty array
466
+ if (!length && arguments.length === 1) {
467
+ throw new TypeError("reduce of empty array with no initial value");
468
+ }
468
469
 
469
- var i = 0;
470
- var result;
471
- if (arguments.length >= 2) {
472
- result = arguments[1];
473
- } else {
474
- do {
475
- if (i in self) {
476
- result = self[i++];
477
- break;
478
- }
479
-
480
- // if array contains no values, no initial value to return
481
- if (++i >= length) {
482
- throw new TypeError("reduce of empty array with no initial value");
483
- }
484
- } while (true);
485
- }
470
+ var i = 0;
471
+ var result;
472
+ if (arguments.length >= 2) {
473
+ result = arguments[1];
474
+ } else {
475
+ do {
476
+ if (i in self) {
477
+ result = self[i++];
478
+ break;
479
+ }
486
480
 
487
- for (; i < length; i++) {
488
- if (i in self) {
489
- result = fun.call(void 0, result, self[i], i, object);
490
- }
491
- }
481
+ // if array contains no values, no initial value to return
482
+ if (++i >= length) {
483
+ throw new TypeError("reduce of empty array with no initial value");
484
+ }
485
+ } while (true);
486
+ }
492
487
 
493
- return result;
494
- };
495
- }
488
+ for (; i < length; i++) {
489
+ if (i in self) {
490
+ result = fun.call(void 0, result, self[i], i, object);
491
+ }
492
+ }
493
+
494
+ return result;
495
+ };
496
+ }
496
497
 
497
498
  // ES5 15.4.4.22
498
499
  // http://es5.github.com/#x15.4.4.22
499
500
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
500
- if (!Array.prototype.reduceRight) {
501
- Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
502
- var object = toObject(this),
503
- self = splitString && _toString(this) == "[object String]" ?
504
- this.split("") :
505
- object,
506
- length = self.length >>> 0;
507
-
508
- // If no callback function or if callback is not a callable function
509
- if (_toString(fun) != "[object Function]") {
510
- throw new TypeError(fun + " is not a function");
511
- }
501
+ var reduceRightCoercesToObject = false;
502
+ if (Array.prototype.reduceRight) {
503
+ reduceRightCoercesToObject = typeof Array.prototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
504
+ }
505
+ if (!Array.prototype.reduceRight || !reduceRightCoercesToObject) {
506
+ Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
507
+ var object = toObject(this),
508
+ self = splitString && _toString.call(this) === "[object String]" ?
509
+ this.split("") :
510
+ object,
511
+ length = self.length >>> 0;
512
+
513
+ // If no callback function or if callback is not a callable function
514
+ if (!isFunction(fun)) {
515
+ throw new TypeError(fun + " is not a function");
516
+ }
512
517
 
513
- // no value to return if no initial value, empty array
514
- if (!length && arguments.length == 1) {
515
- throw new TypeError("reduceRight of empty array with no initial value");
516
- }
518
+ // no value to return if no initial value, empty array
519
+ if (!length && arguments.length === 1) {
520
+ throw new TypeError("reduceRight of empty array with no initial value");
521
+ }
517
522
 
518
- var result, i = length - 1;
519
- if (arguments.length >= 2) {
520
- result = arguments[1];
521
- } else {
522
- do {
523
- if (i in self) {
524
- result = self[i--];
525
- break;
526
- }
527
-
528
- // if array contains no values, no initial value to return
529
- if (--i < 0) {
530
- throw new TypeError("reduceRight of empty array with no initial value");
531
- }
532
- } while (true);
533
- }
523
+ var result, i = length - 1;
524
+ if (arguments.length >= 2) {
525
+ result = arguments[1];
526
+ } else {
527
+ do {
528
+ if (i in self) {
529
+ result = self[i--];
530
+ break;
531
+ }
534
532
 
535
- if (i < 0) {
536
- return result;
537
- }
533
+ // if array contains no values, no initial value to return
534
+ if (--i < 0) {
535
+ throw new TypeError("reduceRight of empty array with no initial value");
536
+ }
537
+ } while (true);
538
+ }
538
539
 
539
- do {
540
- if (i in this) {
541
- result = fun.call(void 0, result, self[i], i, object);
542
- }
543
- } while (i--);
540
+ if (i < 0) {
541
+ return result;
542
+ }
544
543
 
545
- return result;
546
- };
547
- }
544
+ do {
545
+ if (i in self) {
546
+ result = fun.call(void 0, result, self[i], i, object);
547
+ }
548
+ } while (i--);
549
+
550
+ return result;
551
+ };
552
+ }
548
553
 
549
554
  // ES5 15.4.4.14
550
555
  // http://es5.github.com/#x15.4.4.14
551
556
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
552
- if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
553
- Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
554
- var self = splitString && _toString(this) == "[object String]" ?
555
- this.split("") :
556
- toObject(this),
557
- length = self.length >>> 0;
558
-
559
- if (!length) {
560
- return -1;
561
- }
557
+ if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) !== -1)) {
558
+ Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
559
+ var self = splitString && _toString.call(this) === "[object String]" ?
560
+ this.split("") :
561
+ toObject(this),
562
+ length = self.length >>> 0;
563
+
564
+ if (!length) {
565
+ return -1;
566
+ }
562
567
 
563
- var i = 0;
564
- if (arguments.length > 1) {
565
- i = toInteger(arguments[1]);
566
- }
568
+ var i = 0;
569
+ if (arguments.length > 1) {
570
+ i = toInteger(arguments[1]);
571
+ }
567
572
 
568
- // handle negative indices
569
- i = i >= 0 ? i : Math.max(0, length + i);
570
- for (; i < length; i++) {
571
- if (i in self && self[i] === sought) {
572
- return i;
573
- }
574
- }
575
- return -1;
576
- };
577
- }
573
+ // handle negative indices
574
+ i = i >= 0 ? i : Math.max(0, length + i);
575
+ for (; i < length; i++) {
576
+ if (i in self && self[i] === sought) {
577
+ return i;
578
+ }
579
+ }
580
+ return -1;
581
+ };
582
+ }
578
583
 
579
584
  // ES5 15.4.4.15
580
585
  // http://es5.github.com/#x15.4.4.15
581
586
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
582
- if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
583
- Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
584
- var self = splitString && _toString(this) == "[object String]" ?
585
- this.split("") :
586
- toObject(this),
587
- length = self.length >>> 0;
588
-
589
- if (!length) {
590
- return -1;
591
- }
592
- var i = length - 1;
593
- if (arguments.length > 1) {
594
- i = Math.min(i, toInteger(arguments[1]));
595
- }
596
- // handle negative indices
597
- i = i >= 0 ? i : length - Math.abs(i);
598
- for (; i >= 0; i--) {
599
- if (i in self && sought === self[i]) {
600
- return i;
601
- }
602
- }
603
- return -1;
604
- };
605
- }
587
+ if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) !== -1)) {
588
+ Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
589
+ var self = splitString && _toString.call(this) === "[object String]" ?
590
+ this.split("") :
591
+ toObject(this),
592
+ length = self.length >>> 0;
593
+
594
+ if (!length) {
595
+ return -1;
596
+ }
597
+ var i = length - 1;
598
+ if (arguments.length > 1) {
599
+ i = Math.min(i, toInteger(arguments[1]));
600
+ }
601
+ // handle negative indices
602
+ i = i >= 0 ? i : length - Math.abs(i);
603
+ for (; i >= 0; i--) {
604
+ if (i in self && sought === self[i]) {
605
+ return i;
606
+ }
607
+ }
608
+ return -1;
609
+ };
610
+ }
606
611
 
607
612
  //
608
613
  // Object
@@ -611,52 +616,71 @@ if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
611
616
 
612
617
  // ES5 15.2.3.14
613
618
  // http://es5.github.com/#x15.2.3.14
614
- if (!Object.keys) {
615
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
616
- var hasDontEnumBug = true,
617
- dontEnums = [
618
- "toString",
619
- "toLocaleString",
620
- "valueOf",
621
- "hasOwnProperty",
622
- "isPrototypeOf",
623
- "propertyIsEnumerable",
624
- "constructor"
625
- ],
626
- dontEnumsLength = dontEnums.length;
627
-
628
- for (var key in {"toString": null}) {
629
- hasDontEnumBug = false;
630
- }
631
-
632
- Object.keys = function keys(object) {
633
-
634
- if (
635
- (typeof object != "object" && typeof object != "function") ||
636
- object === null
637
- ) {
638
- throw new TypeError("Object.keys called on a non-object");
639
- }
640
-
641
- var keys = [];
642
- for (var name in object) {
643
- if (owns(object, name)) {
644
- keys.push(name);
645
- }
646
- }
619
+ var keysWorksWithArguments = Object.keys && (function () {
620
+ return Object.keys(arguments).length === 2;
621
+ }(1, 2));
622
+ if (!Object.keys) {
623
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
624
+ var hasDontEnumBug = !({'toString': null}).propertyIsEnumerable('toString'),
625
+ hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
626
+ dontEnums = [
627
+ "toString",
628
+ "toLocaleString",
629
+ "valueOf",
630
+ "hasOwnProperty",
631
+ "isPrototypeOf",
632
+ "propertyIsEnumerable",
633
+ "constructor"
634
+ ],
635
+ dontEnumsLength = dontEnums.length;
636
+
637
+ Object.keys = function keys(object) {
638
+ var isFn = isFunction(object),
639
+ isArgs = isArguments(object),
640
+ isObject = object !== null && typeof object === 'object',
641
+ isString = isObject && _toString.call(object) === '[object String]';
642
+
643
+ if (!isObject && !isFn && !isArgs) {
644
+ throw new TypeError("Object.keys called on a non-object");
645
+ }
647
646
 
648
- if (hasDontEnumBug) {
649
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
650
- var dontEnum = dontEnums[i];
651
- if (owns(object, dontEnum)) {
652
- keys.push(dontEnum);
653
- }
654
- }
655
- }
656
- return keys;
657
- };
647
+ var theKeys = [];
648
+ var skipProto = hasProtoEnumBug && isFn;
649
+ if (isString || isArgs) {
650
+ for (var i = 0; i < object.length; ++i) {
651
+ theKeys.push(String(i));
652
+ }
653
+ } else {
654
+ for (var name in object) {
655
+ if (!(skipProto && name === 'prototype') && owns(object, name)) {
656
+ theKeys.push(String(name));
657
+ }
658
+ }
659
+ }
658
660
 
659
- }
661
+ if (hasDontEnumBug) {
662
+ var ctor = object.constructor,
663
+ skipConstructor = ctor && ctor.prototype === object;
664
+ for (var j = 0; j < dontEnumsLength; j++) {
665
+ var dontEnum = dontEnums[j];
666
+ if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
667
+ theKeys.push(dontEnum);
668
+ }
669
+ }
670
+ }
671
+ return theKeys;
672
+ };
673
+ } else if (!keysWorksWithArguments) {
674
+ // Safari 5.0 bug
675
+ var originalKeys = Object.keys;
676
+ Object.keys = function keys(object) {
677
+ if (isArguments(object)) {
678
+ return originalKeys(Array.prototype.slice.call(object));
679
+ } else {
680
+ return originalKeys(object);
681
+ }
682
+ };
683
+ }
660
684
 
661
685
  //
662
686
  // Date
@@ -670,256 +694,263 @@ if (!Object.keys) {
670
694
  // string format defined in 15.9.1.15. All fields are present in the String.
671
695
  // The time zone is always UTC, denoted by the suffix Z. If the time value of
672
696
  // this object is not a finite Number a RangeError exception is thrown.
673
- var negativeDate = -62198755200000,
674
- negativeYearString = "-000001";
675
- if (
676
- !Date.prototype.toISOString ||
677
- (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
678
- ) {
679
- Date.prototype.toISOString = function toISOString() {
680
- var result, length, value, year, month;
681
- if (!isFinite(this)) {
682
- throw new RangeError("Date.prototype.toISOString called on non-finite value.");
683
- }
697
+ var negativeDate = -62198755200000,
698
+ negativeYearString = "-000001";
699
+ if (
700
+ !Date.prototype.toISOString ||
701
+ (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
702
+ ) {
703
+ Date.prototype.toISOString = function toISOString() {
704
+ var result, length, value, year, month;
705
+ if (!isFinite(this)) {
706
+ throw new RangeError("Date.prototype.toISOString called on non-finite value.");
707
+ }
684
708
 
685
- year = this.getUTCFullYear();
686
-
687
- month = this.getUTCMonth();
688
- // see https://github.com/kriskowal/es5-shim/issues/111
689
- year += Math.floor(month / 12);
690
- month = (month % 12 + 12) % 12;
691
-
692
- // the date time string format is specified in 15.9.1.15.
693
- result = [month + 1, this.getUTCDate(),
694
- this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
695
- year = (
696
- (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
697
- ("00000" + Math.abs(year))
698
- .slice(0 <= year && year <= 9999 ? -4 : -6)
699
- );
700
-
701
- length = result.length;
702
- while (length--) {
703
- value = result[length];
704
- // pad months, days, hours, minutes, and seconds to have two
705
- // digits.
706
- if (value < 10) {
707
- result[length] = "0" + value;
708
- }
709
- }
710
- // pad milliseconds to have three digits.
711
- return (
712
- year + "-" + result.slice(0, 2).join("-") +
713
- "T" + result.slice(2).join(":") + "." +
714
- ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
715
- );
716
- };
717
- }
709
+ year = this.getUTCFullYear();
710
+
711
+ month = this.getUTCMonth();
712
+ // see https://github.com/es-shims/es5-shim/issues/111
713
+ year += Math.floor(month / 12);
714
+ month = (month % 12 + 12) % 12;
715
+
716
+ // the date time string format is specified in 15.9.1.15.
717
+ result = [month + 1, this.getUTCDate(), this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
718
+ year = (
719
+ (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
720
+ ("00000" + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6)
721
+ );
722
+
723
+ length = result.length;
724
+ while (length--) {
725
+ value = result[length];
726
+ // pad months, days, hours, minutes, and seconds to have two
727
+ // digits.
728
+ if (value < 10) {
729
+ result[length] = "0" + value;
730
+ }
731
+ }
732
+ // pad milliseconds to have three digits.
733
+ return (
734
+ year + "-" + result.slice(0, 2).join("-") +
735
+ "T" + result.slice(2).join(":") + "." +
736
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
737
+ );
738
+ };
739
+ }
718
740
 
719
741
 
720
742
  // ES5 15.9.5.44
721
743
  // http://es5.github.com/#x15.9.5.44
722
744
  // This function provides a String representation of a Date object for use by
723
745
  // JSON.stringify (15.12.3).
724
- var dateToJSONIsSupported = false;
725
- try {
726
- dateToJSONIsSupported = (
727
- Date.prototype.toJSON &&
728
- new Date(NaN).toJSON() === null &&
729
- new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
730
- Date.prototype.toJSON.call({ // generic
731
- toISOString: function () {
732
- return true;
733
- }
734
- })
735
- );
736
- } catch (e) {
737
- }
738
- if (!dateToJSONIsSupported) {
739
- Date.prototype.toJSON = function toJSON(key) {
740
- // When the toJSON method is called with argument key, the following
741
- // steps are taken:
742
-
743
- // 1. Let O be the result of calling ToObject, giving it the this
744
- // value as its argument.
745
- // 2. Let tv be toPrimitive(O, hint Number).
746
- var o = Object(this),
747
- tv = toPrimitive(o),
748
- toISO;
749
- // 3. If tv is a Number and is not finite, return null.
750
- if (typeof tv === "number" && !isFinite(tv)) {
751
- return null;
752
- }
753
- // 4. Let toISO be the result of calling the [[Get]] internal method of
754
- // O with argument "toISOString".
755
- toISO = o.toISOString;
756
- // 5. If IsCallable(toISO) is false, throw a TypeError exception.
757
- if (typeof toISO != "function") {
758
- throw new TypeError("toISOString property is not callable");
759
- }
760
- // 6. Return the result of calling the [[Call]] internal method of
761
- // toISO with O as the this value and an empty argument list.
762
- return toISO.call(o);
763
-
764
- // NOTE 1 The argument is ignored.
765
-
766
- // NOTE 2 The toJSON function is intentionally generic; it does not
767
- // require that its this value be a Date object. Therefore, it can be
768
- // transferred to other kinds of objects for use as a method. However,
769
- // it does require that any such object have a toISOString method. An
770
- // object is free to use the argument key to filter its
771
- // stringification.
772
- };
773
- }
746
+ var dateToJSONIsSupported = false;
747
+ try {
748
+ dateToJSONIsSupported = (
749
+ Date.prototype.toJSON &&
750
+ new Date(NaN).toJSON() === null &&
751
+ new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
752
+ Date.prototype.toJSON.call({ // generic
753
+ toISOString: function () {
754
+ return true;
755
+ }
756
+ })
757
+ );
758
+ } catch (e) {
759
+ }
760
+ if (!dateToJSONIsSupported) {
761
+ Date.prototype.toJSON = function toJSON(key) {
762
+ // When the toJSON method is called with argument key, the following
763
+ // steps are taken:
764
+
765
+ // 1. Let O be the result of calling ToObject, giving it the this
766
+ // value as its argument.
767
+ // 2. Let tv be toPrimitive(O, hint Number).
768
+ var o = Object(this),
769
+ tv = toPrimitive(o),
770
+ toISO;
771
+ // 3. If tv is a Number and is not finite, return null.
772
+ if (typeof tv === "number" && !isFinite(tv)) {
773
+ return null;
774
+ }
775
+ // 4. Let toISO be the result of calling the [[Get]] internal method of
776
+ // O with argument "toISOString".
777
+ toISO = o.toISOString;
778
+ // 5. If IsCallable(toISO) is false, throw a TypeError exception.
779
+ if (typeof toISO !== "function") {
780
+ throw new TypeError("toISOString property is not callable");
781
+ }
782
+ // 6. Return the result of calling the [[Call]] internal method of
783
+ // toISO with O as the this value and an empty argument list.
784
+ return toISO.call(o);
785
+
786
+ // NOTE 1 The argument is ignored.
787
+
788
+ // NOTE 2 The toJSON function is intentionally generic; it does not
789
+ // require that its this value be a Date object. Therefore, it can be
790
+ // transferred to other kinds of objects for use as a method. However,
791
+ // it does require that any such object have a toISOString method. An
792
+ // object is free to use the argument key to filter its
793
+ // stringification.
794
+ };
795
+ }
774
796
 
775
797
  // ES5 15.9.4.2
776
798
  // http://es5.github.com/#x15.9.4.2
777
799
  // based on work shared by Daniel Friesen (dantman)
778
800
  // http://gist.github.com/303249
779
- if (!Date.parse || "Date.parse is buggy") {
780
- // XXX global assignment won't work in embeddings that use
781
- // an alternate object for the context.
782
- Date = (function(NativeDate) {
783
-
784
- // Date.length === 7
785
- function Date(Y, M, D, h, m, s, ms) {
786
- var length = arguments.length;
787
- if (this instanceof NativeDate) {
788
- var date = length == 1 && String(Y) === Y ? // isString(Y)
789
- // We explicitly pass it through parse:
790
- new NativeDate(Date.parse(Y)) :
791
- // We have to manually make calls depending on argument
792
- // length here
793
- length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
794
- length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
795
- length >= 5 ? new NativeDate(Y, M, D, h, m) :
796
- length >= 4 ? new NativeDate(Y, M, D, h) :
797
- length >= 3 ? new NativeDate(Y, M, D) :
798
- length >= 2 ? new NativeDate(Y, M) :
799
- length >= 1 ? new NativeDate(Y) :
800
- new NativeDate();
801
- // Prevent mixups with unfixed Date object
802
- date.constructor = Date;
803
- return date;
804
- }
805
- return NativeDate.apply(this, arguments);
806
- };
801
+ var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
802
+ var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z'));
803
+ var doesNotParseY2KNewYear = isNaN(Date.parse("2000-01-01T00:00:00.000Z"));
804
+ if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
805
+ // XXX global assignment won't work in embeddings that use
806
+ // an alternate object for the context.
807
+ Date = (function (NativeDate) {
808
+
809
+ // Date.length === 7
810
+ function Date(Y, M, D, h, m, s, ms) {
811
+ var length = arguments.length;
812
+ if (this instanceof NativeDate) {
813
+ var date = length === 1 && String(Y) === Y ? // isString(Y)
814
+ // We explicitly pass it through parse:
815
+ new NativeDate(Date.parse(Y)) :
816
+ // We have to manually make calls depending on argument
817
+ // length here
818
+ length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
819
+ length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
820
+ length >= 5 ? new NativeDate(Y, M, D, h, m) :
821
+ length >= 4 ? new NativeDate(Y, M, D, h) :
822
+ length >= 3 ? new NativeDate(Y, M, D) :
823
+ length >= 2 ? new NativeDate(Y, M) :
824
+ length >= 1 ? new NativeDate(Y) :
825
+ new NativeDate();
826
+ // Prevent mixups with unfixed Date object
827
+ date.constructor = Date;
828
+ return date;
829
+ }
830
+ return NativeDate.apply(this, arguments);
831
+ }
807
832
 
808
- // 15.9.1.15 Date Time String Format.
809
- var isoDateExpression = new RegExp("^" +
810
- "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
811
- // 6-digit extended year
812
- "(?:-(\\d{2})" + // optional month capture
813
- "(?:-(\\d{2})" + // optional day capture
814
- "(?:" + // capture hours:minutes:seconds.milliseconds
815
- "T(\\d{2})" + // hours capture
816
- ":(\\d{2})" + // minutes capture
817
- "(?:" + // optional :seconds.milliseconds
818
- ":(\\d{2})" + // seconds capture
819
- "(?:(\\.\\d{1,}))?" + // milliseconds capture
820
- ")?" +
821
- "(" + // capture UTC offset component
822
- "Z|" + // UTC capture
823
- "(?:" + // offset specifier +/-hours:minutes
824
- "([-+])" + // sign capture
825
- "(\\d{2})" + // hours offset capture
826
- ":(\\d{2})" + // minutes offset capture
827
- ")" +
828
- ")?)?)?)?" +
829
- "$");
830
-
831
- var months = [
832
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
833
- ];
834
-
835
- function dayFromMonth(year, month) {
836
- var t = month > 1 ? 1 : 0;
837
- return (
838
- months[month] +
839
- Math.floor((year - 1969 + t) / 4) -
840
- Math.floor((year - 1901 + t) / 100) +
841
- Math.floor((year - 1601 + t) / 400) +
842
- 365 * (year - 1970)
843
- );
844
- }
833
+ // 15.9.1.15 Date Time String Format.
834
+ var isoDateExpression = new RegExp("^" +
835
+ "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
836
+ // 6-digit extended year
837
+ "(?:-(\\d{2})" + // optional month capture
838
+ "(?:-(\\d{2})" + // optional day capture
839
+ "(?:" + // capture hours:minutes:seconds.milliseconds
840
+ "T(\\d{2})" + // hours capture
841
+ ":(\\d{2})" + // minutes capture
842
+ "(?:" + // optional :seconds.milliseconds
843
+ ":(\\d{2})" + // seconds capture
844
+ "(?:(\\.\\d{1,}))?" + // milliseconds capture
845
+ ")?" +
846
+ "(" + // capture UTC offset component
847
+ "Z|" + // UTC capture
848
+ "(?:" + // offset specifier +/-hours:minutes
849
+ "([-+])" + // sign capture
850
+ "(\\d{2})" + // hours offset capture
851
+ ":(\\d{2})" + // minutes offset capture
852
+ ")" +
853
+ ")?)?)?)?" +
854
+ "$");
855
+
856
+ var months = [
857
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
858
+ ];
859
+
860
+ function dayFromMonth(year, month) {
861
+ var t = month > 1 ? 1 : 0;
862
+ return (
863
+ months[month] +
864
+ Math.floor((year - 1969 + t) / 4) -
865
+ Math.floor((year - 1901 + t) / 100) +
866
+ Math.floor((year - 1601 + t) / 400) +
867
+ 365 * (year - 1970)
868
+ );
869
+ }
845
870
 
846
- // Copy any custom methods a 3rd party library may have added
847
- for (var key in NativeDate) {
848
- Date[key] = NativeDate[key];
849
- }
871
+ function toUTC(t) {
872
+ return Number(new NativeDate(1970, 0, 1, 0, 0, 0, t));
873
+ }
850
874
 
851
- // Copy "native" methods explicitly; they may be non-enumerable
852
- Date.now = NativeDate.now;
853
- Date.UTC = NativeDate.UTC;
854
- Date.prototype = NativeDate.prototype;
855
- Date.prototype.constructor = Date;
856
-
857
- // Upgrade Date.parse to handle simplified ISO 8601 strings
858
- Date.parse = function parse(string) {
859
- var match = isoDateExpression.exec(string);
860
- if (match) {
861
- // parse months, days, hours, minutes, seconds, and milliseconds
862
- // provide default values if necessary
863
- // parse the UTC offset component
864
- var year = Number(match[1]),
865
- month = Number(match[2] || 1) - 1,
866
- day = Number(match[3] || 1) - 1,
867
- hour = Number(match[4] || 0),
868
- minute = Number(match[5] || 0),
869
- second = Number(match[6] || 0),
870
- millisecond = Math.floor(Number(match[7] || 0) * 1000),
871
- // When time zone is missed, local offset should be used
872
- // (ES 5.1 bug)
873
- // see https://bugs.ecmascript.org/show_bug.cgi?id=112
874
- offset = !match[4] || match[8] ?
875
- 0 : Number(new NativeDate(1970, 0)),
876
- signOffset = match[9] === "-" ? 1 : -1,
877
- hourOffset = Number(match[10] || 0),
878
- minuteOffset = Number(match[11] || 0),
879
- result;
880
- if (
881
- hour < (
882
- minute > 0 || second > 0 || millisecond > 0 ?
883
- 24 : 25
884
- ) &&
885
- minute < 60 && second < 60 && millisecond < 1000 &&
886
- month > -1 && month < 12 && hourOffset < 24 &&
887
- minuteOffset < 60 && // detect invalid offsets
888
- day > -1 &&
889
- day < (
890
- dayFromMonth(year, month + 1) -
891
- dayFromMonth(year, month)
892
- )
893
- ) {
894
- result = (
895
- (dayFromMonth(year, month) + day) * 24 +
896
- hour +
897
- hourOffset * signOffset
898
- ) * 60;
899
- result = (
900
- (result + minute + minuteOffset * signOffset) * 60 +
901
- second
902
- ) * 1000 + millisecond + offset;
903
- if (-8.64e15 <= result && result <= 8.64e15) {
904
- return result;
905
- }
906
- }
907
- return NaN;
908
- }
909
- return NativeDate.parse.apply(this, arguments);
910
- };
875
+ // Copy any custom methods a 3rd party library may have added
876
+ for (var key in NativeDate) {
877
+ Date[key] = NativeDate[key];
878
+ }
911
879
 
912
- return Date;
913
- })(Date);
914
- }
880
+ // Copy "native" methods explicitly; they may be non-enumerable
881
+ Date.now = NativeDate.now;
882
+ Date.UTC = NativeDate.UTC;
883
+ Date.prototype = NativeDate.prototype;
884
+ Date.prototype.constructor = Date;
885
+
886
+ // Upgrade Date.parse to handle simplified ISO 8601 strings
887
+ Date.parse = function parse(string) {
888
+ var match = isoDateExpression.exec(string);
889
+ if (match) {
890
+ // parse months, days, hours, minutes, seconds, and milliseconds
891
+ // provide default values if necessary
892
+ // parse the UTC offset component
893
+ var year = Number(match[1]),
894
+ month = Number(match[2] || 1) - 1,
895
+ day = Number(match[3] || 1) - 1,
896
+ hour = Number(match[4] || 0),
897
+ minute = Number(match[5] || 0),
898
+ second = Number(match[6] || 0),
899
+ millisecond = Math.floor(Number(match[7] || 0) * 1000),
900
+ // When time zone is missed, local offset should be used
901
+ // (ES 5.1 bug)
902
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=112
903
+ isLocalTime = Boolean(match[4] && !match[8]),
904
+ signOffset = match[9] === "-" ? 1 : -1,
905
+ hourOffset = Number(match[10] || 0),
906
+ minuteOffset = Number(match[11] || 0),
907
+ result;
908
+ if (
909
+ hour < (
910
+ minute > 0 || second > 0 || millisecond > 0 ?
911
+ 24 : 25
912
+ ) &&
913
+ minute < 60 && second < 60 && millisecond < 1000 &&
914
+ month > -1 && month < 12 && hourOffset < 24 &&
915
+ minuteOffset < 60 && // detect invalid offsets
916
+ day > -1 &&
917
+ day < (
918
+ dayFromMonth(year, month + 1) -
919
+ dayFromMonth(year, month)
920
+ )
921
+ ) {
922
+ result = (
923
+ (dayFromMonth(year, month) + day) * 24 +
924
+ hour +
925
+ hourOffset * signOffset
926
+ ) * 60;
927
+ result = (
928
+ (result + minute + minuteOffset * signOffset) * 60 +
929
+ second
930
+ ) * 1000 + millisecond;
931
+ if (isLocalTime) {
932
+ result = toUTC(result);
933
+ }
934
+ if (-8.64e15 <= result && result <= 8.64e15) {
935
+ return result;
936
+ }
937
+ }
938
+ return NaN;
939
+ }
940
+ return NativeDate.parse.apply(this, arguments);
941
+ };
942
+
943
+ return Date;
944
+ })(Date);
945
+ }
915
946
 
916
947
  // ES5 15.9.4.4
917
948
  // http://es5.github.com/#x15.9.4.4
918
- if (!Date.now) {
919
- Date.now = function now() {
920
- return new Date().getTime();
921
- };
922
- }
949
+ if (!Date.now) {
950
+ Date.now = function now() {
951
+ return new Date().getTime();
952
+ };
953
+ }
923
954
 
924
955
 
925
956
  //
@@ -929,152 +960,152 @@ if (!Date.now) {
929
960
 
930
961
  // ES5.1 15.7.4.5
931
962
  // http://es5.github.com/#x15.7.4.5
932
- 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") {
933
- // Hide these variables and functions
934
- (function () {
935
- var base, size, data, i;
936
-
937
- base = 1e7;
938
- size = 6;
939
- data = [0, 0, 0, 0, 0, 0];
940
-
941
- function multiply(n, c) {
942
- var i = -1;
943
- while (++i < size) {
944
- c += n * data[i];
945
- data[i] = c % base;
946
- c = Math.floor(c / base);
947
- }
948
- }
963
+ 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") {
964
+ // Hide these variables and functions
965
+ (function () {
966
+ var base, size, data, i;
967
+
968
+ base = 1e7;
969
+ size = 6;
970
+ data = [0, 0, 0, 0, 0, 0];
971
+
972
+ function multiply(n, c) {
973
+ var i = -1;
974
+ while (++i < size) {
975
+ c += n * data[i];
976
+ data[i] = c % base;
977
+ c = Math.floor(c / base);
978
+ }
979
+ }
949
980
 
950
- function divide(n) {
951
- var i = size, c = 0;
952
- while (--i >= 0) {
953
- c += data[i];
954
- data[i] = Math.floor(c / n);
955
- c = (c % n) * base;
956
- }
957
- }
981
+ function divide(n) {
982
+ var i = size, c = 0;
983
+ while (--i >= 0) {
984
+ c += data[i];
985
+ data[i] = Math.floor(c / n);
986
+ c = (c % n) * base;
987
+ }
988
+ }
958
989
 
959
- function toString() {
960
- var i = size;
961
- var s = '';
962
- while (--i >= 0) {
963
- if (s !== '' || i === 0 || data[i] !== 0) {
964
- var t = String(data[i]);
965
- if (s === '') {
966
- s = t;
967
- } else {
968
- s += '0000000'.slice(0, 7 - t.length) + t;
969
- }
970
- }
971
- }
972
- return s;
973
- }
990
+ function numToString() {
991
+ var i = size;
992
+ var s = '';
993
+ while (--i >= 0) {
994
+ if (s !== '' || i === 0 || data[i] !== 0) {
995
+ var t = String(data[i]);
996
+ if (s === '') {
997
+ s = t;
998
+ } else {
999
+ s += '0000000'.slice(0, 7 - t.length) + t;
1000
+ }
1001
+ }
1002
+ }
1003
+ return s;
1004
+ }
974
1005
 
975
- function pow(x, n, acc) {
976
- return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
977
- }
1006
+ function pow(x, n, acc) {
1007
+ return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
1008
+ }
978
1009
 
979
- function log(x) {
980
- var n = 0;
981
- while (x >= 4096) {
982
- n += 12;
983
- x /= 4096;
984
- }
985
- while (x >= 2) {
986
- n += 1;
987
- x /= 2;
988
- }
989
- return n;
990
- }
1010
+ function log(x) {
1011
+ var n = 0;
1012
+ while (x >= 4096) {
1013
+ n += 12;
1014
+ x /= 4096;
1015
+ }
1016
+ while (x >= 2) {
1017
+ n += 1;
1018
+ x /= 2;
1019
+ }
1020
+ return n;
1021
+ }
991
1022
 
992
- Number.prototype.toFixed = function (fractionDigits) {
993
- var f, x, s, m, e, z, j, k;
994
-
995
- // Test for NaN and round fractionDigits down
996
- f = Number(fractionDigits);
997
- f = f !== f ? 0 : Math.floor(f);
998
-
999
- if (f < 0 || f > 20) {
1000
- throw new RangeError("Number.toFixed called with invalid number of decimals");
1001
- }
1002
-
1003
- x = Number(this);
1004
-
1005
- // Test for NaN
1006
- if (x !== x) {
1007
- return "NaN";
1008
- }
1009
-
1010
- // If it is too big or small, return the string value of the number
1011
- if (x <= -1e21 || x >= 1e21) {
1012
- return String(x);
1013
- }
1014
-
1015
- s = "";
1016
-
1017
- if (x < 0) {
1018
- s = "-";
1019
- x = -x;
1020
- }
1021
-
1022
- m = "0";
1023
-
1024
- if (x > 1e-21) {
1025
- // 1e-21 < x < 1e21
1026
- // -70 < log2(x) < 70
1027
- e = log(x * pow(2, 69, 1)) - 69;
1028
- z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1029
- z *= 0x10000000000000; // Math.pow(2, 52);
1030
- e = 52 - e;
1031
-
1032
- // -18 < e < 122
1033
- // x = z / 2 ^ e
1034
- if (e > 0) {
1035
- multiply(0, z);
1036
- j = f;
1037
-
1038
- while (j >= 7) {
1039
- multiply(1e7, 0);
1040
- j -= 7;
1041
- }
1042
-
1043
- multiply(pow(10, j, 1), 0);
1044
- j = e - 1;
1045
-
1046
- while (j >= 23) {
1047
- divide(1 << 23);
1048
- j -= 23;
1049
- }
1050
-
1051
- divide(1 << j);
1052
- multiply(1, 1);
1053
- divide(2);
1054
- m = toString();
1055
- } else {
1056
- multiply(0, z);
1057
- multiply(1 << (-e), 0);
1058
- m = toString() + '0.00000000000000000000'.slice(2, 2 + f);
1059
- }
1060
- }
1061
-
1062
- if (f > 0) {
1063
- k = m.length;
1064
-
1065
- if (k <= f) {
1066
- m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1067
- } else {
1068
- m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1069
- }
1070
- } else {
1071
- m = s + m;
1072
- }
1073
-
1074
- return m;
1075
- }
1076
- }());
1077
- }
1023
+ Number.prototype.toFixed = function toFixed(fractionDigits) {
1024
+ var f, x, s, m, e, z, j, k;
1025
+
1026
+ // Test for NaN and round fractionDigits down
1027
+ f = Number(fractionDigits);
1028
+ f = f !== f ? 0 : Math.floor(f);
1029
+
1030
+ if (f < 0 || f > 20) {
1031
+ throw new RangeError("Number.toFixed called with invalid number of decimals");
1032
+ }
1033
+
1034
+ x = Number(this);
1035
+
1036
+ // Test for NaN
1037
+ if (x !== x) {
1038
+ return "NaN";
1039
+ }
1040
+
1041
+ // If it is too big or small, return the string value of the number
1042
+ if (x <= -1e21 || x >= 1e21) {
1043
+ return String(x);
1044
+ }
1045
+
1046
+ s = "";
1047
+
1048
+ if (x < 0) {
1049
+ s = "-";
1050
+ x = -x;
1051
+ }
1052
+
1053
+ m = "0";
1054
+
1055
+ if (x > 1e-21) {
1056
+ // 1e-21 < x < 1e21
1057
+ // -70 < log2(x) < 70
1058
+ e = log(x * pow(2, 69, 1)) - 69;
1059
+ z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1060
+ z *= 0x10000000000000; // Math.pow(2, 52);
1061
+ e = 52 - e;
1062
+
1063
+ // -18 < e < 122
1064
+ // x = z / 2 ^ e
1065
+ if (e > 0) {
1066
+ multiply(0, z);
1067
+ j = f;
1068
+
1069
+ while (j >= 7) {
1070
+ multiply(1e7, 0);
1071
+ j -= 7;
1072
+ }
1073
+
1074
+ multiply(pow(10, j, 1), 0);
1075
+ j = e - 1;
1076
+
1077
+ while (j >= 23) {
1078
+ divide(1 << 23);
1079
+ j -= 23;
1080
+ }
1081
+
1082
+ divide(1 << j);
1083
+ multiply(1, 1);
1084
+ divide(2);
1085
+ m = numToString();
1086
+ } else {
1087
+ multiply(0, z);
1088
+ multiply(1 << (-e), 0);
1089
+ m = numToString() + '0.00000000000000000000'.slice(2, 2 + f);
1090
+ }
1091
+ }
1092
+
1093
+ if (f > 0) {
1094
+ k = m.length;
1095
+
1096
+ if (k <= f) {
1097
+ m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1098
+ } else {
1099
+ m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1100
+ }
1101
+ } else {
1102
+ m = s + m;
1103
+ }
1104
+
1105
+ return m;
1106
+ };
1107
+ }());
1108
+ }
1078
1109
 
1079
1110
 
1080
1111
  //
@@ -1082,7 +1113,6 @@ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFix
1082
1113
  // ======
1083
1114
  //
1084
1115
 
1085
-
1086
1116
  // ES5 15.5.4.14
1087
1117
  // http://es5.github.com/#x15.5.4.14
1088
1118
 
@@ -1091,97 +1121,99 @@ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFix
1091
1121
  // do not perform the split correctly under obscure conditions.
1092
1122
  // See http://blog.stevenlevithan.com/archives/cross-browser-split
1093
1123
  // I've tested in many browsers and this seems to cover the deviant ones:
1094
- // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1095
- // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1096
- // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1097
- // [undefined, "t", undefined, "e", ...]
1098
- // ''.split(/.?/) should be [], not [""]
1099
- // '.'.split(/()()/) should be ["."], not ["", "", "."]
1100
-
1101
- var string_split = String.prototype.split;
1102
- if (
1103
- 'ab'.split(/(?:ab)*/).length !== 2 ||
1104
- '.'.split(/(.?)(.?)/).length !== 4 ||
1105
- 'tesst'.split(/(s)*/)[1] === "t" ||
1106
- ''.split(/.?/).length === 0 ||
1107
- '.'.split(/()()/).length > 1
1108
- ) {
1109
- (function () {
1110
- var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1111
-
1112
- String.prototype.split = function (separator, limit) {
1113
- var string = this;
1114
- if (separator === void 0 && limit === 0)
1115
- return [];
1116
-
1117
- // If `separator` is not a regex, use native split
1118
- if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
1119
- return string_split.apply(this, arguments);
1120
- }
1121
-
1122
- var output = [],
1123
- flags = (separator.ignoreCase ? "i" : "") +
1124
- (separator.multiline ? "m" : "") +
1125
- (separator.extended ? "x" : "") + // Proposed for ES6
1126
- (separator.sticky ? "y" : ""), // Firefox 3+
1127
- lastLastIndex = 0,
1128
- // Make `global` and avoid `lastIndex` issues by working with a copy
1129
- separator = new RegExp(separator.source, flags + "g"),
1130
- separator2, match, lastIndex, lastLength;
1131
- string += ""; // Type-convert
1132
- if (!compliantExecNpcg) {
1133
- // Doesn't need flags gy, but they don't hurt
1134
- separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1135
- }
1136
- /* Values for `limit`, per the spec:
1137
- * If undefined: 4294967295 // Math.pow(2, 32) - 1
1138
- * If 0, Infinity, or NaN: 0
1139
- * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1140
- * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1141
- * If other: Type-convert, then use the above rules
1142
- */
1143
- limit = limit === void 0 ?
1144
- -1 >>> 0 : // Math.pow(2, 32) - 1
1145
- limit >>> 0; // ToUint32(limit)
1146
- while (match = separator.exec(string)) {
1147
- // `separator.lastIndex` is not reliable cross-browser
1148
- lastIndex = match.index + match[0].length;
1149
- if (lastIndex > lastLastIndex) {
1150
- output.push(string.slice(lastLastIndex, match.index));
1151
- // Fix browsers whose `exec` methods don't consistently return `undefined` for
1152
- // nonparticipating capturing groups
1153
- if (!compliantExecNpcg && match.length > 1) {
1154
- match[0].replace(separator2, function () {
1155
- for (var i = 1; i < arguments.length - 2; i++) {
1156
- if (arguments[i] === void 0) {
1157
- match[i] = void 0;
1158
- }
1159
- }
1160
- });
1161
- }
1162
- if (match.length > 1 && match.index < string.length) {
1163
- Array.prototype.push.apply(output, match.slice(1));
1164
- }
1165
- lastLength = match[0].length;
1166
- lastLastIndex = lastIndex;
1167
- if (output.length >= limit) {
1168
- break;
1169
- }
1170
- }
1171
- if (separator.lastIndex === match.index) {
1172
- separator.lastIndex++; // Avoid an infinite loop
1173
- }
1174
- }
1175
- if (lastLastIndex === string.length) {
1176
- if (lastLength || !separator.test("")) {
1177
- output.push("");
1178
- }
1179
- } else {
1180
- output.push(string.slice(lastLastIndex));
1181
- }
1182
- return output.length > limit ? output.slice(0, limit) : output;
1183
- };
1184
- }());
1124
+ // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1125
+ // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1126
+ // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1127
+ // [undefined, "t", undefined, "e", ...]
1128
+ // ''.split(/.?/) should be [], not [""]
1129
+ // '.'.split(/()()/) should be ["."], not ["", "", "."]
1130
+
1131
+ var string_split = String.prototype.split;
1132
+ if (
1133
+ 'ab'.split(/(?:ab)*/).length !== 2 ||
1134
+ '.'.split(/(.?)(.?)/).length !== 4 ||
1135
+ 'tesst'.split(/(s)*/)[1] === "t" ||
1136
+ 'test'.split(/(?:)/, -1).length !== 4 ||
1137
+ ''.split(/.?/).length ||
1138
+ '.'.split(/()()/).length > 1
1139
+ ) {
1140
+ (function () {
1141
+ var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1142
+
1143
+ String.prototype.split = function (separator, limit) {
1144
+ var string = this;
1145
+ if (separator === void 0 && limit === 0) {
1146
+ return [];
1147
+ }
1148
+
1149
+ // If `separator` is not a regex, use native split
1150
+ if (_toString.call(separator) !== "[object RegExp]") {
1151
+ return string_split.call(this, separator, limit);
1152
+ }
1153
+
1154
+ var output = [],
1155
+ flags = (separator.ignoreCase ? "i" : "") +
1156
+ (separator.multiline ? "m" : "") +
1157
+ (separator.extended ? "x" : "") + // Proposed for ES6
1158
+ (separator.sticky ? "y" : ""), // Firefox 3+
1159
+ lastLastIndex = 0,
1160
+ // Make `global` and avoid `lastIndex` issues by working with a copy
1161
+ separator2, match, lastIndex, lastLength;
1162
+ separator = new RegExp(separator.source, flags + "g");
1163
+ string += ""; // Type-convert
1164
+ if (!compliantExecNpcg) {
1165
+ // Doesn't need flags gy, but they don't hurt
1166
+ separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1167
+ }
1168
+ /* Values for `limit`, per the spec:
1169
+ * If undefined: 4294967295 // Math.pow(2, 32) - 1
1170
+ * If 0, Infinity, or NaN: 0
1171
+ * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1172
+ * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1173
+ * If other: Type-convert, then use the above rules
1174
+ */
1175
+ limit = limit === void 0 ?
1176
+ -1 >>> 0 : // Math.pow(2, 32) - 1
1177
+ ToUint32(limit);
1178
+ while (match = separator.exec(string)) {
1179
+ // `separator.lastIndex` is not reliable cross-browser
1180
+ lastIndex = match.index + match[0].length;
1181
+ if (lastIndex > lastLastIndex) {
1182
+ output.push(string.slice(lastLastIndex, match.index));
1183
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
1184
+ // nonparticipating capturing groups
1185
+ if (!compliantExecNpcg && match.length > 1) {
1186
+ match[0].replace(separator2, function () {
1187
+ for (var i = 1; i < arguments.length - 2; i++) {
1188
+ if (arguments[i] === void 0) {
1189
+ match[i] = void 0;
1190
+ }
1191
+ }
1192
+ });
1193
+ }
1194
+ if (match.length > 1 && match.index < string.length) {
1195
+ Array.prototype.push.apply(output, match.slice(1));
1196
+ }
1197
+ lastLength = match[0].length;
1198
+ lastLastIndex = lastIndex;
1199
+ if (output.length >= limit) {
1200
+ break;
1201
+ }
1202
+ }
1203
+ if (separator.lastIndex === match.index) {
1204
+ separator.lastIndex++; // Avoid an infinite loop
1205
+ }
1206
+ }
1207
+ if (lastLastIndex === string.length) {
1208
+ if (lastLength || !separator.test("")) {
1209
+ output.push("");
1210
+ }
1211
+ } else {
1212
+ output.push(string.slice(lastLastIndex));
1213
+ }
1214
+ return output.length > limit ? output.slice(0, limit) : output;
1215
+ };
1216
+ }());
1185
1217
 
1186
1218
  // [bugfix, chrome]
1187
1219
  // If separator is undefined, then the result array contains just one String,
@@ -1189,56 +1221,100 @@ if (
1189
1221
  // then the output array is truncated so that it contains no more than limit
1190
1222
  // elements.
1191
1223
  // "0".split(undefined, 0) -> []
1192
- } else if ("0".split(void 0, 0).length) {
1193
- String.prototype.split = function(separator, limit) {
1194
- if (separator === void 0 && limit === 0) return [];
1195
- return string_split.apply(this, arguments);
1196
- }
1197
- }
1224
+ } else if ("0".split(void 0, 0).length) {
1225
+ String.prototype.split = function split(separator, limit) {
1226
+ if (separator === void 0 && limit === 0) { return []; }
1227
+ return string_split.call(this, separator, limit);
1228
+ };
1229
+ }
1198
1230
 
1231
+ var str_replace = String.prototype.replace;
1232
+ var replaceReportsGroupsCorrectly = (function () {
1233
+ var groups = [];
1234
+ 'x'.replace(/x(.)?/g, function (match, group) {
1235
+ groups.push(group);
1236
+ });
1237
+ return groups.length === 1 && typeof groups[0] === 'undefined';
1238
+ }());
1239
+
1240
+ if (!replaceReportsGroupsCorrectly) {
1241
+ String.prototype.replace = function replace(searchValue, replaceValue) {
1242
+ var isFn = isFunction(replaceValue);
1243
+ var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source);
1244
+ if (!isFn || !hasCapturingGroups) {
1245
+ return str_replace.call(this, searchValue, replaceValue);
1246
+ } else {
1247
+ var wrappedReplaceValue = function (match) {
1248
+ var length = arguments.length;
1249
+ var originalLastIndex = searchValue.lastIndex;
1250
+ searchValue.lastIndex = 0;
1251
+ var args = searchValue.exec(match);
1252
+ searchValue.lastIndex = originalLastIndex;
1253
+ args.push(arguments[length - 2], arguments[length - 1]);
1254
+ return replaceValue.apply(this, args);
1255
+ };
1256
+ return str_replace.call(this, searchValue, wrappedReplaceValue);
1257
+ }
1258
+ };
1259
+ }
1199
1260
 
1200
1261
  // ECMA-262, 3rd B.2.3
1201
- // Note an ECMAScript standart, although ECMAScript 3rd Edition has a
1262
+ // Not an ECMAScript standard, although ECMAScript 3rd Edition has a
1202
1263
  // non-normative section suggesting uniform semantics and it should be
1203
1264
  // normalized across all browsers
1204
1265
  // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1205
- if("".substr && "0b".substr(-1) !== "b") {
1206
- var string_substr = String.prototype.substr;
1207
- /**
1208
- * Get the substring of a string
1209
- * @param {integer} start where to start the substring
1210
- * @param {integer} length how many characters to return
1211
- * @return {string}
1212
- */
1213
- String.prototype.substr = function(start, length) {
1214
- return string_substr.call(
1215
- this,
1216
- start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1217
- length
1218
- );
1219
- }
1220
- }
1266
+ if ("".substr && "0b".substr(-1) !== "b") {
1267
+ var string_substr = String.prototype.substr;
1268
+ /**
1269
+ * Get the substring of a string
1270
+ * @param {integer} start where to start the substring
1271
+ * @param {integer} length how many characters to return
1272
+ * @return {string}
1273
+ */
1274
+ String.prototype.substr = function substr(start, length) {
1275
+ return string_substr.call(
1276
+ this,
1277
+ start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1278
+ length
1279
+ );
1280
+ };
1281
+ }
1221
1282
 
1222
1283
  // ES5 15.5.4.20
1223
- // http://es5.github.com/#x15.5.4.20
1224
- var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1225
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1226
- "\u2029\uFEFF";
1227
- if (!String.prototype.trim || ws.trim()) {
1228
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1229
- // http://perfectionkills.com/whitespace-deviations/
1230
- ws = "[" + ws + "]";
1231
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1232
- trimEndRegexp = new RegExp(ws + ws + "*$");
1233
- String.prototype.trim = function trim() {
1234
- if (this === void 0 || this === null) {
1235
- throw new TypeError("can't convert "+this+" to object");
1236
- }
1237
- return String(this)
1238
- .replace(trimBeginRegexp, "")
1239
- .replace(trimEndRegexp, "");
1240
- };
1241
- }
1284
+ // whitespace from: http://es5.github.io/#x15.5.4.20
1285
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1286
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1287
+ "\u2029\uFEFF";
1288
+ var zeroWidth = '\u200b';
1289
+ if (!String.prototype.trim || ws.trim() || !zeroWidth.trim()) {
1290
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1291
+ // http://perfectionkills.com/whitespace-deviations/
1292
+ ws = "[" + ws + "]";
1293
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1294
+ trimEndRegexp = new RegExp(ws + ws + "*$");
1295
+ String.prototype.trim = function trim() {
1296
+ if (this === void 0 || this === null) {
1297
+ throw new TypeError("can't convert " + this + " to object");
1298
+ }
1299
+ return String(this)
1300
+ .replace(trimBeginRegexp, "")
1301
+ .replace(trimEndRegexp, "");
1302
+ };
1303
+ }
1304
+
1305
+ // ES-5 15.1.2.2
1306
+ if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
1307
+ parseInt = (function (origParseInt) {
1308
+ var hexRegex = /^0[xX]/;
1309
+ return function parseIntES5(str, radix) {
1310
+ str = String(str).trim();
1311
+ if (!Number(radix)) {
1312
+ radix = hexRegex.test(str) ? 16 : 10;
1313
+ }
1314
+ return origParseInt(str, radix);
1315
+ };
1316
+ }(parseInt));
1317
+ }
1242
1318
 
1243
1319
  //
1244
1320
  // Util
@@ -1249,57 +1325,61 @@ if (!String.prototype.trim || ws.trim()) {
1249
1325
  // http://es5.github.com/#x9.4
1250
1326
  // http://jsperf.com/to-integer
1251
1327
 
1252
- function toInteger(n) {
1253
- n = +n;
1254
- if (n !== n) { // isNaN
1255
- n = 0;
1256
- } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
1257
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
1258
- }
1259
- return n;
1260
- }
1328
+ function toInteger(n) {
1329
+ n = +n;
1330
+ if (n !== n) { // isNaN
1331
+ n = 0;
1332
+ } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
1333
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
1334
+ }
1335
+ return n;
1336
+ }
1261
1337
 
1262
- function isPrimitive(input) {
1263
- var type = typeof input;
1264
- return (
1265
- input === null ||
1266
- type === "undefined" ||
1267
- type === "boolean" ||
1268
- type === "number" ||
1269
- type === "string"
1270
- );
1271
- }
1338
+ function isPrimitive(input) {
1339
+ var type = typeof input;
1340
+ return (
1341
+ input === null ||
1342
+ type === "undefined" ||
1343
+ type === "boolean" ||
1344
+ type === "number" ||
1345
+ type === "string"
1346
+ );
1347
+ }
1272
1348
 
1273
- function toPrimitive(input) {
1274
- var val, valueOf, toString;
1275
- if (isPrimitive(input)) {
1276
- return input;
1277
- }
1278
- valueOf = input.valueOf;
1279
- if (typeof valueOf === "function") {
1280
- val = valueOf.call(input);
1281
- if (isPrimitive(val)) {
1282
- return val;
1283
- }
1284
- }
1285
- toString = input.toString;
1286
- if (typeof toString === "function") {
1287
- val = toString.call(input);
1288
- if (isPrimitive(val)) {
1289
- return val;
1290
- }
1291
- }
1292
- throw new TypeError();
1293
- }
1349
+ function toPrimitive(input) {
1350
+ var val, valueOf, toStr;
1351
+ if (isPrimitive(input)) {
1352
+ return input;
1353
+ }
1354
+ valueOf = input.valueOf;
1355
+ if (isFunction(valueOf)) {
1356
+ val = valueOf.call(input);
1357
+ if (isPrimitive(val)) {
1358
+ return val;
1359
+ }
1360
+ }
1361
+ toStr = input.toString;
1362
+ if (isFunction(toStr)) {
1363
+ val = toStr.call(input);
1364
+ if (isPrimitive(val)) {
1365
+ return val;
1366
+ }
1367
+ }
1368
+ throw new TypeError();
1369
+ }
1294
1370
 
1295
1371
  // ES5 9.9
1296
1372
  // http://es5.github.com/#x9.9
1297
- var toObject = function (o) {
1298
- if (o == null) { // this matches both null and undefined
1299
- throw new TypeError("can't convert "+o+" to object");
1300
- }
1301
- return Object(o);
1302
- };
1373
+ var toObject = function (o) {
1374
+ if (o == null) { // this matches both null and undefined
1375
+ throw new TypeError("can't convert " + o + " to object");
1376
+ }
1377
+ return Object(o);
1378
+ };
1379
+
1380
+ var ToUint32 = function ToUint32(x) {
1381
+ return x >>> 0;
1382
+ };
1303
1383
 
1304
1384
  })();
1305
1385
 
@@ -2077,6 +2157,23 @@ webshims.isReady('es5', true);
2077
2157
  return val * 1;
2078
2158
  };
2079
2159
  var createOpts = ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex'];
2160
+ var normalizeTouch = (function(){
2161
+ var types = {
2162
+ touchstart: 1,
2163
+ touchend: 1,
2164
+ touchmove: 1
2165
+ };
2166
+ var normalize = ['pageX', 'pageY'];
2167
+ return function(e){
2168
+ if(types[e.type] && e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length){
2169
+ for(var i = 0; i < normalize.length; i++){
2170
+ e[normalize[i]] = e.originalEvent.touches[0][normalize[i]];
2171
+ }
2172
+
2173
+ }
2174
+ return e;
2175
+ };
2176
+ })();
2080
2177
  var rangeProto = {
2081
2178
  _create: function(){
2082
2179
  var i;
@@ -2395,23 +2492,7 @@ webshims.isReady('es5', true);
2395
2492
  }
2396
2493
  };
2397
2494
  })();
2398
- var normalizeTouch = (function(){
2399
- var types = {
2400
- touchstart: 1,
2401
- touchend: 1,
2402
- touchmove: 1
2403
- };
2404
- var normalize = ['pageX', 'pageY'];
2405
- return function(e){
2406
- if(types[e.type] && e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length){
2407
- for(var i = 0; i < normalize.length; i++){
2408
- e[normalize[i]] = e.originalEvent.touches[0][normalize[i]];
2409
- }
2410
-
2411
- }
2412
- return e;
2413
- };
2414
- })();
2495
+
2415
2496
  var updateValue = function(val, animate){
2416
2497
  if(val != o.value){
2417
2498
  that.value(val, false, animate);
@@ -2431,7 +2512,7 @@ webshims.isReady('es5', true);
2431
2512
  }
2432
2513
  };
2433
2514
  var remove = function(e){
2434
- if(e && e.type == 'mouseup'){
2515
+ if(e && (e.type == 'mouseup' || e.type == 'touchend')){
2435
2516
  eventTimer.call('input', o.value);
2436
2517
  eventTimer.call('change', o.value);
2437
2518
  }
@@ -2452,6 +2533,8 @@ webshims.isReady('es5', true);
2452
2533
  $(document).off('mousemove touchmove', setValueFromPos).off('mouseup touchend', remove);
2453
2534
  $(window).off('blur', removeWin);
2454
2535
  if(!o.readonly && !o.disabled){
2536
+ eventTimer.init('input', o.value);
2537
+ eventTimer.init('change', o.value);
2455
2538
  normalizeTouch(e);
2456
2539
  that.element.trigger('focus');
2457
2540
  that.addRemoveClass('ws-active', true);
@@ -2487,8 +2570,10 @@ webshims.isReady('es5', true);
2487
2570
  'touchstart mousedown': add,
2488
2571
  focus: function(e){
2489
2572
  if(!o.disabled && !hasFocus){
2490
- eventTimer.init('input', o.value);
2491
- eventTimer.init('change', o.value);
2573
+ if(!isActive){
2574
+ eventTimer.init('input', o.value);
2575
+ eventTimer.init('change', o.value);
2576
+ }
2492
2577
  that.addRemoveClass('ws-focus', true);
2493
2578
  that.updateMetrics();
2494
2579
  }
@@ -2674,6 +2759,7 @@ webshims.isReady('es5', true);
2674
2759
  obj._create.call(obj);
2675
2760
  });
2676
2761
  };
2762
+ $.fn.rangeUI.normalizeTouch = normalizeTouch;
2677
2763
  if(window.webshims && webshims.isReady){
2678
2764
  webshims.isReady('range-ui', true);
2679
2765
  }
@@ -3381,11 +3467,7 @@ webshims.isReady('es5', true);
3381
3467
  if( steps[this.type] && typeof steps[this.type].start == 'object'){
3382
3468
  steps[this.type].start = this.asNumber(steps[this.type].start);
3383
3469
  }
3384
-
3385
- if(!webshims.picker[this.type]){
3386
- o.buttonOnly = false;
3387
- }
3388
-
3470
+
3389
3471
  for(i = 0; i < createOpts.length; i++){
3390
3472
  if(o[createOpts[i]] != null){
3391
3473
  this[createOpts[i]](o[createOpts[i]], o[createOpts[i]]);
@@ -3615,7 +3697,7 @@ webshims.isReady('es5', true);
3615
3697
  wsWidgetProto._create.apply(this, arguments);
3616
3698
  this._init = false;
3617
3699
 
3618
- this.buttonWrapper.html('<span unselectable="on" class="step-controls"><span class="step-up"></span><span class="step-down"></span></span>');
3700
+ this.buttonWrapper.html('<span unselectable="on" class="step-controls"><span class="step-up step-control"></span><span class="step-down step-control"></span></span>');
3619
3701
 
3620
3702
  if(this.type == 'number'){
3621
3703
  this.inputElements.attr('inputmode', 'numeric');
@@ -3798,7 +3880,7 @@ webshims.isReady('es5', true);
3798
3880
  }
3799
3881
 
3800
3882
  touch = changedTouches[0];
3801
- if(Math.abs(touchData.x - touch.pageX) > 40 || Math.abs(touchData.y - touch.pageY) > 40 || Date.now() - touchData.now > 600){
3883
+ if(Math.abs(touchData.x - touch.pageX) > 40 || Math.abs(touchData.y - touch.pageY) > 40 || Date.now() - touchData.now > 300){
3802
3884
  return;
3803
3885
  }
3804
3886
  e.preventDefault();
@@ -3996,7 +4078,7 @@ webshims.isReady('es5', true);
3996
4078
  }
3997
4079
  };
3998
4080
  return function(prop){
3999
- if(prop == 'value' && !data.options.inlinePicker){return;}
4081
+ if(prop == 'value' && (!data.options.inlinePicker || data._handledValue )){return;}
4000
4082
  popover.isDirty = true;
4001
4083
 
4002
4084
  if(popover.isVisible){
@@ -4055,6 +4137,13 @@ webshims.isReady('es5', true);
4055
4137
  }
4056
4138
  show();
4057
4139
  };
4140
+ var toogle = function(){
4141
+ if(popover.openedByFocus || !popover.isVisible){
4142
+ open();
4143
+ } else {
4144
+ popover.hide();
4145
+ }
4146
+ }
4058
4147
 
4059
4148
 
4060
4149
  options.containerElements.push(popover.element[0]);
@@ -4095,7 +4184,7 @@ webshims.isReady('es5', true);
4095
4184
  }
4096
4185
 
4097
4186
 
4098
- opener.wsTouchClick(open);
4187
+ opener.wsTouchClick(toogle);
4099
4188
 
4100
4189
  if(options.inlinePicker){
4101
4190
  popover.openedByFocus = true;
@@ -4447,9 +4536,9 @@ webshims.isReady('es5', true);
4447
4536
  }
4448
4537
 
4449
4538
  data.shim.element.on('change input', stopPropagation).addClass(cNames+' '+webshims.shadowClass);
4450
-
4539
+
4451
4540
  if(data.shim.buttonWrapper){
4452
-
4541
+
4453
4542
  data.shim.buttonWrapper.addClass('input-button-size-'+(data.shim.buttonWrapper.children().filter(isVisible).length)+' '+webshims.shadowClass);
4454
4543
 
4455
4544
  if(data.shim.buttonWrapper.filter(isVisible).length){
@@ -4606,6 +4695,32 @@ webshims.isReady('es5', true);
4606
4695
  ;
4607
4696
  });
4608
4697
  };
4698
+
4699
+
4700
+ if($('<input />').prop('labels') == null){
4701
+ webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
4702
+ prop: {
4703
+ get: function(){
4704
+ if(this.type == 'hidden'){return null;}
4705
+ var id = this.id;
4706
+ var labels = $(this)
4707
+ .closest('label')
4708
+ .filter(function(){
4709
+ var hFor = (this.attributes['for'] || {});
4710
+ return (!hFor.specified || hFor.value == id);
4711
+ })
4712
+ ;
4713
+
4714
+ if(id) {
4715
+ labels = labels.add('label[for="'+ id +'"]');
4716
+ }
4717
+ return labels.get();
4718
+ },
4719
+ writeable: false
4720
+ }
4721
+ });
4722
+ }
4723
+
4609
4724
  if(formcfg._isLoading){
4610
4725
  $(formcfg).one('change', init);
4611
4726
  } else {