webshims-rails 1.11.3.1 → 1.11.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) 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 +114 -104
  4. data/vendor/assets/javascripts/webshims/extras/mousepress.js +5 -5
  5. data/vendor/assets/javascripts/webshims/polyfiller.js +156 -207
  6. data/vendor/assets/javascripts/webshims/shims/$ajax.js +862 -0
  7. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/flashcanvas.js +20 -0
  8. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flashcanvas.js +20 -0
  9. data/vendor/assets/javascripts/webshims/shims/color-picker.js +12 -12
  10. data/vendor/assets/javascripts/webshims/shims/combos/1.js +62 -32
  11. data/vendor/assets/javascripts/webshims/shims/combos/10.js +192 -509
  12. data/vendor/assets/javascripts/webshims/shims/combos/11.js +96 -415
  13. data/vendor/assets/javascripts/webshims/shims/combos/12.js +36 -26
  14. data/vendor/assets/javascripts/webshims/shims/combos/13.js +36 -26
  15. data/vendor/assets/javascripts/webshims/shims/combos/14.js +1007 -359
  16. data/vendor/assets/javascripts/webshims/shims/combos/15.js +310 -235
  17. data/vendor/assets/javascripts/webshims/shims/combos/16.js +313 -237
  18. data/vendor/assets/javascripts/webshims/shims/combos/17.js +96 -415
  19. data/vendor/assets/javascripts/webshims/shims/combos/18.js +1003 -678
  20. data/vendor/assets/javascripts/webshims/shims/combos/19.js +1085 -387
  21. data/vendor/assets/javascripts/webshims/shims/combos/2.js +161 -127
  22. data/vendor/assets/javascripts/webshims/shims/combos/20.js +1086 -388
  23. data/vendor/assets/javascripts/webshims/shims/combos/21.js +168 -96
  24. data/vendor/assets/javascripts/webshims/shims/combos/22.js +36 -27
  25. data/vendor/assets/javascripts/webshims/shims/combos/23.js +2 -1
  26. data/vendor/assets/javascripts/webshims/shims/combos/24.js +411 -172
  27. data/vendor/assets/javascripts/webshims/shims/combos/25.js +1085 -387
  28. data/vendor/assets/javascripts/webshims/shims/combos/26.js +96 -94
  29. data/vendor/assets/javascripts/webshims/shims/combos/3.js +163 -140
  30. data/vendor/assets/javascripts/webshims/shims/combos/30.js +166 -141
  31. data/vendor/assets/javascripts/webshims/shims/combos/31.js +159 -126
  32. data/vendor/assets/javascripts/webshims/shims/combos/4.js +103 -109
  33. data/vendor/assets/javascripts/webshims/shims/combos/5.js +98 -417
  34. data/vendor/assets/javascripts/webshims/shims/combos/6.js +101 -418
  35. data/vendor/assets/javascripts/webshims/shims/combos/7.js +168 -142
  36. data/vendor/assets/javascripts/webshims/shims/combos/8.js +165 -141
  37. data/vendor/assets/javascripts/webshims/shims/combos/9.js +195 -510
  38. data/vendor/assets/javascripts/webshims/shims/details.js +2 -2
  39. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +96 -94
  40. data/vendor/assets/javascripts/webshims/shims/es5.js +908 -264
  41. data/vendor/assets/javascripts/webshims/shims/excanvas.js +16 -1
  42. data/vendor/assets/javascripts/webshims/shims/form-combat.js +147 -0
  43. data/vendor/assets/javascripts/webshims/shims/form-core.js +60 -31
  44. data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +114 -33
  45. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +3 -1
  46. data/vendor/assets/javascripts/webshims/shims/form-message.js +7 -15
  47. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +2 -2
  48. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +88 -410
  49. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +143 -93
  50. data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +268 -79
  51. data/vendor/assets/javascripts/webshims/shims/form-validation.js +116 -81
  52. data/vendor/assets/javascripts/webshims/shims/form-validators.js +23 -10
  53. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +605 -9
  54. data/vendor/assets/javascripts/webshims/shims/geolocation.js +51 -39
  55. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-de.js +78 -33
  56. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-en.js +24 -6
  57. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-nl.js +110 -49
  58. data/vendor/assets/javascripts/webshims/shims/json-storage.js +3 -1
  59. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +2 -1
  60. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +81 -30
  61. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +131 -54
  62. data/vendor/assets/javascripts/webshims/shims/plugins/jquery.ui.position.js +497 -0
  63. data/vendor/assets/javascripts/webshims/shims/range-ui.js +8 -5
  64. data/vendor/assets/javascripts/webshims/shims/sizzle.js +2026 -0
  65. data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +401 -521
  66. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +1 -1
  67. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +94 -82
  68. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +250 -321
  69. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  70. data/vendor/assets/javascripts/webshims/shims/track-ui.js +1 -1
  71. data/vendor/assets/javascripts/webshims/shims/track.js +34 -25
  72. metadata +7 -3
@@ -450,100 +450,58 @@ var swfmini = function() {
450
450
  };
451
451
  }();
452
452
 
453
+ // Copyright 2009-2012 by contributors, MIT License
453
454
  // vim: ts=4 sts=4 sw=4 expandtab
454
- // -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
455
- // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
456
- // -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
457
- // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
458
- // -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
459
- // -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
460
- // -- kossnocorp Sasha Koss XXX TODO License or CLA
461
- // -- bryanforbes Bryan Forbes XXX TODO License or CLA
462
- // -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
463
- // -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
464
- // -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
465
- // -- bbqsrc Brendan Molloy XXX TODO License or CLA
466
- // -- iwyg XXX TODO License or CLA
467
- // -- DomenicDenicola Domenic Denicola XXX TODO License or CLA
468
- // -- xavierm02 Montillet Xavier XXX TODO License or CLA
469
- // -- Raynos Raynos XXX TODO License or CLA
470
- // -- samsonjs Sami Samhuri XXX TODO License or CLA
471
- // -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
472
- // -- lexer Alexey Zakharov XXX TODO License or CLA
473
-
474
- /*!
475
- Copyright (c) 2009, 280 North Inc. http://280north.com/
476
- MIT License. http://github.com/280north/narwhal/blob/master/README.md
477
- */
478
455
 
479
- (function (undefined) {
456
+ (function () {
480
457
 
481
458
  /**
482
459
  * Brings an environment as close to ECMAScript 5 compliance
483
460
  * as is possible with the facilities of erstwhile engines.
484
461
  *
485
- * ES5 Draft
486
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-050.pdf
487
- *
488
- * NOTE: this is a draft, and as such, the URL is subject to change. If the
489
- * link is broken, check in the parent directory for the latest TC39 PDF.
490
- * http://www.ecma-international.org/publications/files/drafts/
491
- *
492
- * Previous ES5 Draft
493
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
494
- * This is a broken link to the previous draft of ES5 on which most of the
495
- * numbered specification references and quotes herein were taken. Updating
496
- * these references and quotes to reflect the new document would be a welcome
497
- * volunteer project.
498
- *
499
- * @module
462
+ * Annotated ES5: http://es5.github.com/ (specific links below)
463
+ * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
464
+ * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
500
465
  */
501
466
 
502
- /*whatsupdoc*/
503
-
504
- // Shortcut to an often accessed properties, in order to avoid multiple
505
- // dereference that costs universally.
506
- // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
507
- // us it in defining shortcuts.
508
- var call = Function.prototype.call;
509
- var prototypeOfArray = Array.prototype;
510
- var prototypeOfObject = Object.prototype;
511
- var slice = prototypeOfArray.slice;
512
- var owns;
513
- var toString;
467
+ //
468
+ // Function
469
+ // ========
470
+ //
514
471
 
515
472
  // ES-5 15.3.4.5
516
- // http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
473
+ // http://es5.github.com/#x15.3.4.5
474
+
475
+ function Empty() {}
517
476
 
518
477
  if (!Function.prototype.bind) {
519
- Function.prototype.bind = function (that) { // .length is 1
478
+ Function.prototype.bind = function bind(that) { // .length is 1
520
479
  // 1. Let Target be the this value.
521
480
  var target = this;
522
481
  // 2. If IsCallable(Target) is false, throw a TypeError exception.
523
- if (typeof target != "function")
524
- throw new TypeError(); // TODO message
482
+ if (typeof target != "function") {
483
+ throw new TypeError("Function.prototype.bind called on incompatible " + target);
484
+ }
525
485
  // 3. Let A be a new (possibly empty) internal list of all of the
526
486
  // argument values provided after thisArg (arg1, arg2 etc), in order.
527
487
  // XXX slicedArgs will stand in for "A" if used
528
- var args = slice.call(arguments, 1); // for normal call
488
+ var args = _Array_slice_.call(arguments, 1); // for normal call
529
489
  // 4. Let F be a new native ECMAScript object.
530
- // 9. Set the [[Prototype]] internal property of F to the standard
490
+ // 11. Set the [[Prototype]] internal property of F to the standard
531
491
  // built-in Function prototype object as specified in 15.3.3.1.
532
- // 10. Set the [[Call]] internal property of F as described in
492
+ // 12. Set the [[Call]] internal property of F as described in
533
493
  // 15.3.4.5.1.
534
- // 11. Set the [[Construct]] internal property of F as described in
494
+ // 13. Set the [[Construct]] internal property of F as described in
535
495
  // 15.3.4.5.2.
536
- // 12. Set the [[HasInstance]] internal property of F as described in
496
+ // 14. Set the [[HasInstance]] internal property of F as described in
537
497
  // 15.3.4.5.3.
538
- // 13. The [[Scope]] internal property of F is unused and need not
539
- // exist.
540
498
  var bound = function () {
541
499
 
542
500
  if (this instanceof bound) {
543
501
  // 15.3.4.5.2 [[Construct]]
544
502
  // When the [[Construct]] internal method of a function object,
545
503
  // F that was created using the bind function is called with a
546
- // list of arguments ExtraArgs the following steps are taken:
504
+ // list of arguments ExtraArgs, the following steps are taken:
547
505
  // 1. Let target be the value of F's [[TargetFunction]]
548
506
  // internal property.
549
507
  // 2. If target has no [[Construct]] internal method, a
@@ -553,24 +511,23 @@ if (!Function.prototype.bind) {
553
511
  // 4. Let args be a new list containing the same values as the
554
512
  // list boundArgs in the same order followed by the same
555
513
  // values as the list ExtraArgs in the same order.
556
-
557
- var F = function(){};
558
- F.prototype = target.prototype;
559
- var self = new F;
514
+ // 5. Return the result of calling the [[Construct]] internal
515
+ // method of target providing args as the arguments.
560
516
 
561
517
  var result = target.apply(
562
- self,
563
- args.concat(slice.call(arguments))
518
+ this,
519
+ args.concat(_Array_slice_.call(arguments))
564
520
  );
565
- if (result !== null && Object(result) === result)
521
+ if (Object(result) === result) {
566
522
  return result;
567
- return self;
523
+ }
524
+ return this;
568
525
 
569
526
  } else {
570
527
  // 15.3.4.5.1 [[Call]]
571
528
  // When the [[Call]] internal method of a function object, F,
572
529
  // which was created using the bind function is called with a
573
- // this value and a list of arguments ExtraArgs the following
530
+ // this value and a list of arguments ExtraArgs, the following
574
531
  // steps are taken:
575
532
  // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
576
533
  // property.
@@ -578,59 +535,207 @@ if (!Function.prototype.bind) {
578
535
  // property.
579
536
  // 3. Let target be the value of F's [[TargetFunction]] internal
580
537
  // property.
581
- // 4. Let args be a new list containing the same values as the list
582
- // boundArgs in the same order followed by the same values as
583
- // the list ExtraArgs in the same order. 5. Return the
584
- // result of calling the [[Call]] internal method of target
585
- // providing boundThis as the this value and providing args
586
- // as the arguments.
538
+ // 4. Let args be a new list containing the same values as the
539
+ // list boundArgs in the same order followed by the same
540
+ // values as the list ExtraArgs in the same order.
541
+ // 5. Return the result of calling the [[Call]] internal method
542
+ // of target providing boundThis as the this value and
543
+ // providing args as the arguments.
587
544
 
588
545
  // equiv: target.call(this, ...boundArgs, ...args)
589
546
  return target.apply(
590
547
  that,
591
- args.concat(slice.call(arguments))
548
+ args.concat(_Array_slice_.call(arguments))
592
549
  );
593
550
 
594
551
  }
595
552
 
596
553
  };
554
+ if(target.prototype) {
555
+ Empty.prototype = target.prototype;
556
+ bound.prototype = new Empty();
557
+ // Clean up dangling references.
558
+ Empty.prototype = null;
559
+ }
597
560
  // XXX bound.length is never writable, so don't even try
598
561
  //
599
- // 16. The length own property of F is given attributes as specified in
600
- // 15.3.5.1.
601
- // TODO
602
- // 17. Set the [[Extensible]] internal property of F to true.
562
+ // 15. If the [[Class]] internal property of Target is "Function", then
563
+ // a. Let L be the length property of Target minus the length of A.
564
+ // b. Set the length own property of F to either 0 or L, whichever is
565
+ // larger.
566
+ // 16. Else set the length own property of F to 0.
567
+ // 17. Set the attributes of the length own property of F to the values
568
+ // specified in 15.3.5.1.
569
+
603
570
  // TODO
604
- // 18. Call the [[DefineOwnProperty]] internal method of F with
605
- // arguments "caller", PropertyDescriptor {[[Value]]: null,
606
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
607
- // false}, and false.
571
+ // 18. Set the [[Extensible]] internal property of F to true.
572
+
608
573
  // TODO
609
- // 19. Call the [[DefineOwnProperty]] internal method of F with
610
- // arguments "arguments", PropertyDescriptor {[[Value]]: null,
611
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
612
- // false}, and false.
574
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
575
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
576
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
577
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
578
+ // false.
579
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
580
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
581
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
582
+ // and false.
583
+
613
584
  // TODO
614
585
  // NOTE Function objects created using Function.prototype.bind do not
615
- // have a prototype property.
616
- // XXX can't delete it in pure-js.
586
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
587
+ // [[Scope]] internal properties.
588
+ // XXX can't delete prototype in pure-js.
589
+
590
+ // 22. Return F.
617
591
  return bound;
618
592
  };
619
593
  }
620
594
 
621
- toString = call.bind(prototypeOfObject.toString);
622
- owns = call.bind(prototypeOfObject.hasOwnProperty);
595
+ // Shortcut to an often accessed properties, in order to avoid multiple
596
+ // dereference that costs universally.
597
+ // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
598
+ // us it in defining shortcuts.
599
+ var call = Function.prototype.call;
600
+ var prototypeOfArray = Array.prototype;
601
+ var prototypeOfObject = Object.prototype;
602
+ var _Array_slice_ = prototypeOfArray.slice;
603
+ // Having a toString local variable name breaks in Opera so use _toString.
604
+ var _toString = call.bind(prototypeOfObject.toString);
605
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
623
606
 
607
+ // If JS engine supports accessors creating shortcuts.
608
+ var defineGetter;
609
+ var defineSetter;
610
+ var lookupGetter;
611
+ var lookupSetter;
612
+ var supportsAccessors;
613
+ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
614
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
615
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
616
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
617
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
618
+ }
624
619
 
625
620
  //
626
621
  // Array
627
622
  // =====
628
623
  //
629
624
 
625
+ // ES5 15.4.4.12
626
+ // http://es5.github.com/#x15.4.4.12
627
+ // Default value for second param
628
+ // [bugfix, ielt9, old browsers]
629
+ // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
630
+ if ([1,2].splice(0).length != 2) {
631
+ var array_splice = Array.prototype.splice;
632
+
633
+ if(function() { // test IE < 9 to splice bug - see issue #138
634
+ function makeArray(l) {
635
+ var a = [];
636
+ while (l--) {
637
+ a.unshift(l)
638
+ }
639
+ return a
640
+ }
641
+
642
+ var array = []
643
+ , lengthBefore
644
+ ;
645
+
646
+ array.splice.bind(array, 0, 0).apply(null, makeArray(20));
647
+ array.splice.bind(array, 0, 0).apply(null, makeArray(26));
648
+
649
+ lengthBefore = array.length; //20
650
+ array.splice(5, 0, "XXX"); // add one element
651
+
652
+ if(lengthBefore + 1 == array.length) {
653
+ return true;// has right splice implementation without bugs
654
+ }
655
+ // else {
656
+ // IE8 bug
657
+ // }
658
+ }()) {//IE 6/7
659
+ Array.prototype.splice = function(start, deleteCount) {
660
+ if (!arguments.length) {
661
+ return [];
662
+ } else {
663
+ return array_splice.apply(this, [
664
+ start === void 0 ? 0 : start,
665
+ deleteCount === void 0 ? (this.length - start) : deleteCount
666
+ ].concat(_Array_slice_.call(arguments, 2)))
667
+ }
668
+ };
669
+ }
670
+ else {//IE8
671
+ Array.prototype.splice = function(start, deleteCount) {
672
+ var result
673
+ , args = _Array_slice_.call(arguments, 2)
674
+ , addElementsCount = args.length
675
+ ;
676
+
677
+ if(!arguments.length) {
678
+ return [];
679
+ }
680
+
681
+ if(start === void 0) { // default
682
+ start = 0;
683
+ }
684
+ if(deleteCount === void 0) { // default
685
+ deleteCount = this.length - start;
686
+ }
687
+
688
+ if(addElementsCount > 0) {
689
+ if(deleteCount <= 0) {
690
+ if(start == this.length) { // tiny optimisation #1
691
+ this.push.apply(this, args);
692
+ return [];
693
+ }
694
+
695
+ if(start == 0) { // tiny optimisation #2
696
+ this.unshift.apply(this, args);
697
+ return [];
698
+ }
699
+ }
700
+
701
+ // Array.prototype.splice implementation
702
+ result = _Array_slice_.call(this, start, start + deleteCount);// delete part
703
+ args.push.apply(args, _Array_slice_.call(this, start + deleteCount, this.length));// right part
704
+ args.unshift.apply(args, _Array_slice_.call(this, 0, start));// left part
705
+
706
+ // delete all items from this array and replace it to 'left part' + _Array_slice_.call(arguments, 2) + 'right part'
707
+ args.unshift(0, this.length);
708
+
709
+ array_splice.apply(this, args);
710
+
711
+ return result;
712
+ }
713
+
714
+ return array_splice.call(this, start, deleteCount);
715
+ }
716
+
717
+ }
718
+ }
719
+
720
+ // ES5 15.4.4.12
721
+ // http://es5.github.com/#x15.4.4.13
722
+ // Return len+argCount.
723
+ // [bugfix, ielt8]
724
+ // IE < 8 bug: [].unshift(0) == undefined but should be "1"
725
+ if ([].unshift(0) != 1) {
726
+ var array_unshift = Array.prototype.unshift;
727
+ Array.prototype.unshift = function() {
728
+ array_unshift.apply(this, arguments);
729
+ return this.length;
730
+ };
731
+ }
732
+
630
733
  // ES5 15.4.3.2
734
+ // http://es5.github.com/#x15.4.3.2
735
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
631
736
  if (!Array.isArray) {
632
- Array.isArray = function (obj) {
633
- return toString(obj) == "[object Array]";
737
+ Array.isArray = function isArray(obj) {
738
+ return _toString(obj) == "[object Array]";
634
739
  };
635
740
  }
636
741
 
@@ -647,129 +752,169 @@ if (!Array.isArray) {
647
752
  // expressions.
648
753
 
649
754
  // ES5 15.4.4.18
650
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
755
+ // http://es5.github.com/#x15.4.4.18
756
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
757
+
758
+ // Check failure of by-index access of string characters (IE < 9)
759
+ // and failure of `0 in boxedString` (Rhino)
760
+ var boxedString = Object("a"),
761
+ splitString = boxedString[0] != "a" || !(0 in boxedString);
762
+
651
763
  if (!Array.prototype.forEach) {
652
- Array.prototype.forEach = function (fun /*, thisp*/) {
653
- var self = toObject(this),
764
+ Array.prototype.forEach = function forEach(fun /*, thisp*/) {
765
+ var object = toObject(this),
766
+ self = splitString && _toString(this) == "[object String]" ?
767
+ this.split("") :
768
+ object,
654
769
  thisp = arguments[1],
655
- i = 0,
770
+ i = -1,
656
771
  length = self.length >>> 0;
657
772
 
658
773
  // If no callback function or if callback is not a callable function
659
- if (toString(fun) != "[object Function]") {
774
+ if (_toString(fun) != "[object Function]") {
660
775
  throw new TypeError(); // TODO message
661
776
  }
662
777
 
663
- while (i < length) {
778
+ while (++i < length) {
664
779
  if (i in self) {
665
780
  // Invoke the callback function with call, passing arguments:
666
- // context, property value, property key, thisArg object context
667
- fun.call(thisp, self[i], i, self);
781
+ // context, property value, property key, thisArg object
782
+ // context
783
+ fun.call(thisp, self[i], i, object);
668
784
  }
669
- i++;
670
785
  }
671
786
  };
672
787
  }
673
788
 
674
789
  // ES5 15.4.4.19
790
+ // http://es5.github.com/#x15.4.4.19
675
791
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
676
792
  if (!Array.prototype.map) {
677
- Array.prototype.map = function (fun /*, thisp*/) {
678
- var self = toObject(this),
793
+ Array.prototype.map = function map(fun /*, thisp*/) {
794
+ var object = toObject(this),
795
+ self = splitString && _toString(this) == "[object String]" ?
796
+ this.split("") :
797
+ object,
679
798
  length = self.length >>> 0,
680
799
  result = Array(length),
681
800
  thisp = arguments[1];
682
801
 
683
802
  // If no callback function or if callback is not a callable function
684
- if (toString(fun) != "[object Function]") {
685
- throw new TypeError(); // TODO message
803
+ if (_toString(fun) != "[object Function]") {
804
+ throw new TypeError(fun + " is not a function");
686
805
  }
687
806
 
688
807
  for (var i = 0; i < length; i++) {
689
808
  if (i in self)
690
- result[i] = fun.call(thisp, self[i], i, self);
809
+ result[i] = fun.call(thisp, self[i], i, object);
691
810
  }
692
811
  return result;
693
812
  };
694
813
  }
695
814
 
696
815
  // ES5 15.4.4.20
816
+ // http://es5.github.com/#x15.4.4.20
817
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
697
818
  if (!Array.prototype.filter) {
698
- Array.prototype.filter = function (fun /*, thisp */) {
699
- var self = toObject(this),
819
+ Array.prototype.filter = function filter(fun /*, thisp */) {
820
+ var object = toObject(this),
821
+ self = splitString && _toString(this) == "[object String]" ?
822
+ this.split("") :
823
+ object,
700
824
  length = self.length >>> 0,
701
825
  result = [],
826
+ value,
702
827
  thisp = arguments[1];
703
828
 
704
829
  // If no callback function or if callback is not a callable function
705
- if (toString(fun) != "[object Function]") {
706
- throw new TypeError(); // TODO message
830
+ if (_toString(fun) != "[object Function]") {
831
+ throw new TypeError(fun + " is not a function");
707
832
  }
708
833
 
709
834
  for (var i = 0; i < length; i++) {
710
- if (i in self && fun.call(thisp, self[i], i, self))
711
- result.push(self[i]);
835
+ if (i in self) {
836
+ value = self[i];
837
+ if (fun.call(thisp, value, i, object)) {
838
+ result.push(value);
839
+ }
840
+ }
712
841
  }
713
842
  return result;
714
843
  };
715
844
  }
716
845
 
717
846
  // ES5 15.4.4.16
847
+ // http://es5.github.com/#x15.4.4.16
848
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
718
849
  if (!Array.prototype.every) {
719
- Array.prototype.every = function (fun /*, thisp */) {
720
- var self = toObject(this),
850
+ Array.prototype.every = function every(fun /*, thisp */) {
851
+ var object = toObject(this),
852
+ self = splitString && _toString(this) == "[object String]" ?
853
+ this.split("") :
854
+ object,
721
855
  length = self.length >>> 0,
722
856
  thisp = arguments[1];
723
857
 
724
858
  // If no callback function or if callback is not a callable function
725
- if (toString(fun) != "[object Function]") {
726
- throw new TypeError(); // TODO message
859
+ if (_toString(fun) != "[object Function]") {
860
+ throw new TypeError(fun + " is not a function");
727
861
  }
728
862
 
729
863
  for (var i = 0; i < length; i++) {
730
- if (i in self && !fun.call(thisp, self[i], i, self))
864
+ if (i in self && !fun.call(thisp, self[i], i, object)) {
731
865
  return false;
866
+ }
732
867
  }
733
868
  return true;
734
869
  };
735
870
  }
736
871
 
737
872
  // ES5 15.4.4.17
873
+ // http://es5.github.com/#x15.4.4.17
738
874
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
739
875
  if (!Array.prototype.some) {
740
- Array.prototype.some = function (fun /*, thisp */) {
741
- var self = toObject(this),
876
+ Array.prototype.some = function some(fun /*, thisp */) {
877
+ var object = toObject(this),
878
+ self = splitString && _toString(this) == "[object String]" ?
879
+ this.split("") :
880
+ object,
742
881
  length = self.length >>> 0,
743
882
  thisp = arguments[1];
744
883
 
745
884
  // If no callback function or if callback is not a callable function
746
- if (toString(fun) != "[object Function]") {
747
- throw new TypeError(); // TODO message
885
+ if (_toString(fun) != "[object Function]") {
886
+ throw new TypeError(fun + " is not a function");
748
887
  }
749
888
 
750
889
  for (var i = 0; i < length; i++) {
751
- if (i in self && fun.call(thisp, self[i], i, self))
890
+ if (i in self && fun.call(thisp, self[i], i, object)) {
752
891
  return true;
892
+ }
753
893
  }
754
894
  return false;
755
895
  };
756
896
  }
757
897
 
758
898
  // ES5 15.4.4.21
899
+ // http://es5.github.com/#x15.4.4.21
759
900
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
760
901
  if (!Array.prototype.reduce) {
761
- Array.prototype.reduce = function (fun /*, initial*/) {
762
- var self = toObject(this),
902
+ Array.prototype.reduce = function reduce(fun /*, initial*/) {
903
+ var object = toObject(this),
904
+ self = splitString && _toString(this) == "[object String]" ?
905
+ this.split("") :
906
+ object,
763
907
  length = self.length >>> 0;
764
908
 
765
909
  // If no callback function or if callback is not a callable function
766
- if (toString(fun) != "[object Function]") {
767
- throw new TypeError(); // TODO message
910
+ if (_toString(fun) != "[object Function]") {
911
+ throw new TypeError(fun + " is not a function");
768
912
  }
769
913
 
770
914
  // no value to return if no initial value and an empty array
771
- if (!length && arguments.length == 1)
772
- throw new TypeError(); // TODO message
915
+ if (!length && arguments.length == 1) {
916
+ throw new TypeError("reduce of empty array with no initial value");
917
+ }
773
918
 
774
919
  var i = 0;
775
920
  var result;
@@ -783,14 +928,16 @@ if (!Array.prototype.reduce) {
783
928
  }
784
929
 
785
930
  // if array contains no values, no initial value to return
786
- if (++i >= length)
787
- throw new TypeError(); // TODO message
931
+ if (++i >= length) {
932
+ throw new TypeError("reduce of empty array with no initial value");
933
+ }
788
934
  } while (true);
789
935
  }
790
936
 
791
937
  for (; i < length; i++) {
792
- if (i in self)
793
- result = fun.call(void 0, result, self[i], i, self);
938
+ if (i in self) {
939
+ result = fun.call(void 0, result, self[i], i, object);
940
+ }
794
941
  }
795
942
 
796
943
  return result;
@@ -798,20 +945,25 @@ if (!Array.prototype.reduce) {
798
945
  }
799
946
 
800
947
  // ES5 15.4.4.22
948
+ // http://es5.github.com/#x15.4.4.22
801
949
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
802
950
  if (!Array.prototype.reduceRight) {
803
- Array.prototype.reduceRight = function (fun /*, initial*/) {
804
- var self = toObject(this),
951
+ Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
952
+ var object = toObject(this),
953
+ self = splitString && _toString(this) == "[object String]" ?
954
+ this.split("") :
955
+ object,
805
956
  length = self.length >>> 0;
806
957
 
807
958
  // If no callback function or if callback is not a callable function
808
- if (toString(fun) != "[object Function]") {
809
- throw new TypeError(); // TODO message
959
+ if (_toString(fun) != "[object Function]") {
960
+ throw new TypeError(fun + " is not a function");
810
961
  }
811
962
 
812
963
  // no value to return if no initial value, empty array
813
- if (!length && arguments.length == 1)
814
- throw new TypeError(); // TODO message
964
+ if (!length && arguments.length == 1) {
965
+ throw new TypeError("reduceRight of empty array with no initial value");
966
+ }
815
967
 
816
968
  var result, i = length - 1;
817
969
  if (arguments.length >= 2) {
@@ -824,14 +976,20 @@ if (!Array.prototype.reduceRight) {
824
976
  }
825
977
 
826
978
  // if array contains no values, no initial value to return
827
- if (--i < 0)
828
- throw new TypeError(); // TODO message
979
+ if (--i < 0) {
980
+ throw new TypeError("reduceRight of empty array with no initial value");
981
+ }
829
982
  } while (true);
830
983
  }
831
984
 
985
+ if (i < 0) {
986
+ return result;
987
+ }
988
+
832
989
  do {
833
- if (i in this)
834
- result = fun.call(void 0, result, self[i], i, self);
990
+ if (i in this) {
991
+ result = fun.call(void 0, result, self[i], i, object);
992
+ }
835
993
  } while (i--);
836
994
 
837
995
  return result;
@@ -839,21 +997,26 @@ if (!Array.prototype.reduceRight) {
839
997
  }
840
998
 
841
999
  // ES5 15.4.4.14
1000
+ // http://es5.github.com/#x15.4.4.14
842
1001
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
843
- if (!Array.prototype.indexOf) {
844
- Array.prototype.indexOf = function (sought /*, fromIndex */ ) {
845
- var self = toObject(this),
1002
+ if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
1003
+ Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
1004
+ var self = splitString && _toString(this) == "[object String]" ?
1005
+ this.split("") :
1006
+ toObject(this),
846
1007
  length = self.length >>> 0;
847
1008
 
848
- if (!length)
1009
+ if (!length) {
849
1010
  return -1;
1011
+ }
850
1012
 
851
1013
  var i = 0;
852
- if (arguments.length > 1)
1014
+ if (arguments.length > 1) {
853
1015
  i = toInteger(arguments[1]);
1016
+ }
854
1017
 
855
1018
  // handle negative indices
856
- i = i >= 0 ? i : length - Math.abs(i);
1019
+ i = i >= 0 ? i : Math.max(0, length + i);
857
1020
  for (; i < length; i++) {
858
1021
  if (i in self && self[i] === sought) {
859
1022
  return i;
@@ -864,59 +1027,42 @@ if (!Array.prototype.indexOf) {
864
1027
  }
865
1028
 
866
1029
  // ES5 15.4.4.15
867
- if (!Array.prototype.lastIndexOf) {
868
- Array.prototype.lastIndexOf = function (sought /*, fromIndex */) {
869
- var self = toObject(this),
1030
+ // http://es5.github.com/#x15.4.4.15
1031
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
1032
+ if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
1033
+ Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
1034
+ var self = splitString && _toString(this) == "[object String]" ?
1035
+ this.split("") :
1036
+ toObject(this),
870
1037
  length = self.length >>> 0;
871
1038
 
872
- if (!length)
1039
+ if (!length) {
873
1040
  return -1;
1041
+ }
874
1042
  var i = length - 1;
875
- if (arguments.length > 1)
876
- i = toInteger(arguments[1]);
1043
+ if (arguments.length > 1) {
1044
+ i = Math.min(i, toInteger(arguments[1]));
1045
+ }
877
1046
  // handle negative indices
878
1047
  i = i >= 0 ? i : length - Math.abs(i);
879
1048
  for (; i >= 0; i--) {
880
- if (i in self && sought === self[i])
1049
+ if (i in self && sought === self[i]) {
881
1050
  return i;
1051
+ }
882
1052
  }
883
1053
  return -1;
884
1054
  };
885
1055
  }
886
1056
 
887
- //
888
- // Array
889
- // =====
890
- //
891
-
892
- // ES5 15.4.4.12
893
- // http://es5.github.com/#x15.4.4.12
894
- // Default value for second param
895
- // [bugfix, ielt9, old browsers]
896
- // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
897
- if([1,2].splice(0).length != 2) {
898
- var _origArraySplice = Array.prototype.splice;
899
-
900
- Array.prototype.splice = function(start, deleteCount) {
901
- if(!arguments.length)return [];
902
-
903
- return _origArraySplice.apply(this, [
904
- start === void 0 ? 0 : start,
905
- deleteCount === void 0 ? (this.length - start) : deleteCount
906
- ].concat(slice.call(arguments, 2)))
907
- };
908
- }
909
-
910
1057
  //
911
1058
  // Object
912
1059
  // ======
913
1060
  //
914
1061
 
915
-
916
1062
  // ES5 15.2.3.14
917
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
1063
+ // http://es5.github.com/#x15.2.3.14
918
1064
  if (!Object.keys) {
919
-
1065
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
920
1066
  var hasDontEnumBug = true,
921
1067
  dontEnums = [
922
1068
  "toString",
@@ -929,13 +1075,18 @@ if (!Object.keys) {
929
1075
  ],
930
1076
  dontEnumsLength = dontEnums.length;
931
1077
 
932
- for (var key in {"toString": null})
1078
+ for (var key in {"toString": null}) {
933
1079
  hasDontEnumBug = false;
1080
+ }
934
1081
 
935
1082
  Object.keys = function keys(object) {
936
1083
 
937
- if ((typeof object != "object" && typeof object != "function") || object === null)
1084
+ if (
1085
+ (typeof object != "object" && typeof object != "function") ||
1086
+ object === null
1087
+ ) {
938
1088
  throw new TypeError("Object.keys called on a non-object");
1089
+ }
939
1090
 
940
1091
  var keys = [];
941
1092
  for (var name in object) {
@@ -952,7 +1103,6 @@ if (!Object.keys) {
952
1103
  }
953
1104
  }
954
1105
  }
955
-
956
1106
  return keys;
957
1107
  };
958
1108
 
@@ -964,58 +1114,102 @@ if (!Object.keys) {
964
1114
  //
965
1115
 
966
1116
  // ES5 15.9.5.43
967
- // Format a Date object as a string according to a simplified subset of the ISO 8601
968
- // standard as defined in 15.9.1.15.
969
- if (!Date.prototype.toISOString) {
1117
+ // http://es5.github.com/#x15.9.5.43
1118
+ // This function returns a String value represent the instance in time
1119
+ // represented by this Date object. The format of the String is the Date Time
1120
+ // string format defined in 15.9.1.15. All fields are present in the String.
1121
+ // The time zone is always UTC, denoted by the suffix Z. If the time value of
1122
+ // this object is not a finite Number a RangeError exception is thrown.
1123
+ var negativeDate = -62198755200000,
1124
+ negativeYearString = "-000001";
1125
+ if (
1126
+ !Date.prototype.toISOString ||
1127
+ (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
1128
+ ) {
970
1129
  Date.prototype.toISOString = function toISOString() {
971
- var result, length, value;
972
- if (!isFinite(this))
973
- throw new RangeError;
1130
+ var result, length, value, year, month;
1131
+ if (!isFinite(this)) {
1132
+ throw new RangeError("Date.prototype.toISOString called on non-finite value.");
1133
+ }
1134
+
1135
+ year = this.getUTCFullYear();
1136
+
1137
+ month = this.getUTCMonth();
1138
+ // see https://github.com/kriskowal/es5-shim/issues/111
1139
+ year += Math.floor(month / 12);
1140
+ month = (month % 12 + 12) % 12;
974
1141
 
975
1142
  // the date time string format is specified in 15.9.1.15.
976
- result = [this.getUTCFullYear(), this.getUTCMonth() + 1, this.getUTCDate(),
1143
+ result = [month + 1, this.getUTCDate(),
977
1144
  this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
1145
+ year = (
1146
+ (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
1147
+ ("00000" + Math.abs(year))
1148
+ .slice(0 <= year && year <= 9999 ? -4 : -6)
1149
+ );
978
1150
 
979
1151
  length = result.length;
980
1152
  while (length--) {
981
1153
  value = result[length];
982
- // pad months, days, hours, minutes, and seconds to have two digits.
983
- if (value < 10)
1154
+ // pad months, days, hours, minutes, and seconds to have two
1155
+ // digits.
1156
+ if (value < 10) {
984
1157
  result[length] = "0" + value;
1158
+ }
985
1159
  }
986
1160
  // pad milliseconds to have three digits.
987
- return result.slice(0, 3).join("-") + "T" + result.slice(3).join(":") + "." +
988
- ("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
989
- }
990
- }
991
-
992
- // ES5 15.9.4.4
993
- if (!Date.now) {
994
- Date.now = function now() {
995
- return new Date().getTime();
1161
+ return (
1162
+ year + "-" + result.slice(0, 2).join("-") +
1163
+ "T" + result.slice(2).join(":") + "." +
1164
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
1165
+ );
996
1166
  };
997
1167
  }
998
1168
 
1169
+
999
1170
  // ES5 15.9.5.44
1000
- if (!Date.prototype.toJSON) {
1171
+ // http://es5.github.com/#x15.9.5.44
1172
+ // This function provides a String representation of a Date object for use by
1173
+ // JSON.stringify (15.12.3).
1174
+ var dateToJSONIsSupported = false;
1175
+ try {
1176
+ dateToJSONIsSupported = (
1177
+ Date.prototype.toJSON &&
1178
+ new Date(NaN).toJSON() === null &&
1179
+ new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
1180
+ Date.prototype.toJSON.call({ // generic
1181
+ toISOString: function () {
1182
+ return true;
1183
+ }
1184
+ })
1185
+ );
1186
+ } catch (e) {
1187
+ }
1188
+ if (!dateToJSONIsSupported) {
1001
1189
  Date.prototype.toJSON = function toJSON(key) {
1002
- // This function provides a String representation of a Date object for
1003
- // use by JSON.stringify (15.12.3). When the toJSON method is called
1004
- // with argument key, the following steps are taken:
1190
+ // When the toJSON method is called with argument key, the following
1191
+ // steps are taken:
1005
1192
 
1006
1193
  // 1. Let O be the result of calling ToObject, giving it the this
1007
1194
  // value as its argument.
1008
- // 2. Let tv be ToPrimitive(O, hint Number).
1195
+ // 2. Let tv be toPrimitive(O, hint Number).
1196
+ var o = Object(this),
1197
+ tv = toPrimitive(o),
1198
+ toISO;
1009
1199
  // 3. If tv is a Number and is not finite, return null.
1010
- // XXX
1200
+ if (typeof tv === "number" && !isFinite(tv)) {
1201
+ return null;
1202
+ }
1011
1203
  // 4. Let toISO be the result of calling the [[Get]] internal method of
1012
1204
  // O with argument "toISOString".
1205
+ toISO = o.toISOString;
1013
1206
  // 5. If IsCallable(toISO) is false, throw a TypeError exception.
1014
- if (typeof this.toISOString != "function")
1015
- throw new TypeError(); // TODO message
1207
+ if (typeof toISO != "function") {
1208
+ throw new TypeError("toISOString property is not callable");
1209
+ }
1016
1210
  // 6. Return the result of calling the [[Call]] internal method of
1017
- // toISO with O as the this value and an empty argument list.
1018
- return this.toISOString();
1211
+ // toISO with O as the this value and an empty argument list.
1212
+ return toISO.call(o);
1019
1213
 
1020
1214
  // NOTE 1 The argument is ignored.
1021
1215
 
@@ -1028,90 +1222,540 @@ if (!Date.prototype.toJSON) {
1028
1222
  };
1029
1223
  }
1030
1224
 
1225
+ // ES5 15.9.4.2
1226
+ // http://es5.github.com/#x15.9.4.2
1227
+ // based on work shared by Daniel Friesen (dantman)
1228
+ // http://gist.github.com/303249
1229
+ if (!Date.parse || "Date.parse is buggy") {
1230
+ // XXX global assignment won't work in embeddings that use
1231
+ // an alternate object for the context.
1232
+ Date = (function(NativeDate) {
1233
+
1234
+ // Date.length === 7
1235
+ function Date(Y, M, D, h, m, s, ms) {
1236
+ var length = arguments.length;
1237
+ if (this instanceof NativeDate) {
1238
+ var date = length == 1 && String(Y) === Y ? // isString(Y)
1239
+ // We explicitly pass it through parse:
1240
+ new NativeDate(Date.parse(Y)) :
1241
+ // We have to manually make calls depending on argument
1242
+ // length here
1243
+ length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
1244
+ length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
1245
+ length >= 5 ? new NativeDate(Y, M, D, h, m) :
1246
+ length >= 4 ? new NativeDate(Y, M, D, h) :
1247
+ length >= 3 ? new NativeDate(Y, M, D) :
1248
+ length >= 2 ? new NativeDate(Y, M) :
1249
+ length >= 1 ? new NativeDate(Y) :
1250
+ new NativeDate();
1251
+ // Prevent mixups with unfixed Date object
1252
+ date.constructor = Date;
1253
+ return date;
1254
+ }
1255
+ return NativeDate.apply(this, arguments);
1256
+ };
1257
+
1258
+ // 15.9.1.15 Date Time String Format.
1259
+ var isoDateExpression = new RegExp("^" +
1260
+ "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
1261
+ // 6-digit extended year
1262
+ "(?:-(\\d{2})" + // optional month capture
1263
+ "(?:-(\\d{2})" + // optional day capture
1264
+ "(?:" + // capture hours:minutes:seconds.milliseconds
1265
+ "T(\\d{2})" + // hours capture
1266
+ ":(\\d{2})" + // minutes capture
1267
+ "(?:" + // optional :seconds.milliseconds
1268
+ ":(\\d{2})" + // seconds capture
1269
+ "(?:(\\.\\d{1,}))?" + // milliseconds capture
1270
+ ")?" +
1271
+ "(" + // capture UTC offset component
1272
+ "Z|" + // UTC capture
1273
+ "(?:" + // offset specifier +/-hours:minutes
1274
+ "([-+])" + // sign capture
1275
+ "(\\d{2})" + // hours offset capture
1276
+ ":(\\d{2})" + // minutes offset capture
1277
+ ")" +
1278
+ ")?)?)?)?" +
1279
+ "$");
1280
+
1281
+ var months = [
1282
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
1283
+ ];
1284
+
1285
+ function dayFromMonth(year, month) {
1286
+ var t = month > 1 ? 1 : 0;
1287
+ return (
1288
+ months[month] +
1289
+ Math.floor((year - 1969 + t) / 4) -
1290
+ Math.floor((year - 1901 + t) / 100) +
1291
+ Math.floor((year - 1601 + t) / 400) +
1292
+ 365 * (year - 1970)
1293
+ );
1294
+ }
1295
+
1296
+ // Copy any custom methods a 3rd party library may have added
1297
+ for (var key in NativeDate) {
1298
+ Date[key] = NativeDate[key];
1299
+ }
1300
+
1301
+ // Copy "native" methods explicitly; they may be non-enumerable
1302
+ Date.now = NativeDate.now;
1303
+ Date.UTC = NativeDate.UTC;
1304
+ Date.prototype = NativeDate.prototype;
1305
+ Date.prototype.constructor = Date;
1306
+
1307
+ // Upgrade Date.parse to handle simplified ISO 8601 strings
1308
+ Date.parse = function parse(string) {
1309
+ var match = isoDateExpression.exec(string);
1310
+ if (match) {
1311
+ // parse months, days, hours, minutes, seconds, and milliseconds
1312
+ // provide default values if necessary
1313
+ // parse the UTC offset component
1314
+ var year = Number(match[1]),
1315
+ month = Number(match[2] || 1) - 1,
1316
+ day = Number(match[3] || 1) - 1,
1317
+ hour = Number(match[4] || 0),
1318
+ minute = Number(match[5] || 0),
1319
+ second = Number(match[6] || 0),
1320
+ millisecond = Math.floor(Number(match[7] || 0) * 1000),
1321
+ // When time zone is missed, local offset should be used
1322
+ // (ES 5.1 bug)
1323
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=112
1324
+ offset = !match[4] || match[8] ?
1325
+ 0 : Number(new NativeDate(1970, 0)),
1326
+ signOffset = match[9] === "-" ? 1 : -1,
1327
+ hourOffset = Number(match[10] || 0),
1328
+ minuteOffset = Number(match[11] || 0),
1329
+ result;
1330
+ if (
1331
+ hour < (
1332
+ minute > 0 || second > 0 || millisecond > 0 ?
1333
+ 24 : 25
1334
+ ) &&
1335
+ minute < 60 && second < 60 && millisecond < 1000 &&
1336
+ month > -1 && month < 12 && hourOffset < 24 &&
1337
+ minuteOffset < 60 && // detect invalid offsets
1338
+ day > -1 &&
1339
+ day < (
1340
+ dayFromMonth(year, month + 1) -
1341
+ dayFromMonth(year, month)
1342
+ )
1343
+ ) {
1344
+ result = (
1345
+ (dayFromMonth(year, month) + day) * 24 +
1346
+ hour +
1347
+ hourOffset * signOffset
1348
+ ) * 60;
1349
+ result = (
1350
+ (result + minute + minuteOffset * signOffset) * 60 +
1351
+ second
1352
+ ) * 1000 + millisecond + offset;
1353
+ if (-8.64e15 <= result && result <= 8.64e15) {
1354
+ return result;
1355
+ }
1356
+ }
1357
+ return NaN;
1358
+ }
1359
+ return NativeDate.parse.apply(this, arguments);
1360
+ };
1361
+
1362
+ return Date;
1363
+ })(Date);
1364
+ }
1365
+
1366
+ // ES5 15.9.4.4
1367
+ // http://es5.github.com/#x15.9.4.4
1368
+ if (!Date.now) {
1369
+ Date.now = function now() {
1370
+ return new Date().getTime();
1371
+ };
1372
+ }
1373
+
1031
1374
 
1032
1375
  //
1033
- // String
1376
+ // Number
1034
1377
  // ======
1035
1378
  //
1036
1379
 
1037
- // ES5 15.5.4.20
1038
- var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1039
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1040
- "\u2029\uFEFF";
1041
- if (!String.prototype.trim || ws.trim()) {
1042
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1043
- // http://perfectionkills.com/whitespace-deviations/
1044
- ws = "[" + ws + "]";
1045
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1046
- trimEndRegexp = new RegExp(ws + ws + "*$");
1047
- String.prototype.trim = function trim() {
1048
- return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
1049
- };
1380
+ // ES5.1 15.7.4.5
1381
+ // http://es5.github.com/#x15.7.4.5
1382
+ 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") {
1383
+ // Hide these variables and functions
1384
+ (function () {
1385
+ var base, size, data, i;
1386
+
1387
+ base = 1e7;
1388
+ size = 6;
1389
+ data = [0, 0, 0, 0, 0, 0];
1390
+
1391
+ function multiply(n, c) {
1392
+ var i = -1;
1393
+ while (++i < size) {
1394
+ c += n * data[i];
1395
+ data[i] = c % base;
1396
+ c = Math.floor(c / base);
1397
+ }
1398
+ }
1399
+
1400
+ function divide(n) {
1401
+ var i = size, c = 0;
1402
+ while (--i >= 0) {
1403
+ c += data[i];
1404
+ data[i] = Math.floor(c / n);
1405
+ c = (c % n) * base;
1406
+ }
1407
+ }
1408
+
1409
+ function toString() {
1410
+ var i = size;
1411
+ var s = '';
1412
+ while (--i >= 0) {
1413
+ if (s !== '' || i === 0 || data[i] !== 0) {
1414
+ var t = String(data[i]);
1415
+ if (s === '') {
1416
+ s = t;
1417
+ } else {
1418
+ s += '0000000'.slice(0, 7 - t.length) + t;
1419
+ }
1420
+ }
1421
+ }
1422
+ return s;
1423
+ }
1424
+
1425
+ function pow(x, n, acc) {
1426
+ return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
1427
+ }
1428
+
1429
+ function log(x) {
1430
+ var n = 0;
1431
+ while (x >= 4096) {
1432
+ n += 12;
1433
+ x /= 4096;
1434
+ }
1435
+ while (x >= 2) {
1436
+ n += 1;
1437
+ x /= 2;
1438
+ }
1439
+ return n;
1440
+ }
1441
+
1442
+ Number.prototype.toFixed = function (fractionDigits) {
1443
+ var f, x, s, m, e, z, j, k;
1444
+
1445
+ // Test for NaN and round fractionDigits down
1446
+ f = Number(fractionDigits);
1447
+ f = f !== f ? 0 : Math.floor(f);
1448
+
1449
+ if (f < 0 || f > 20) {
1450
+ throw new RangeError("Number.toFixed called with invalid number of decimals");
1451
+ }
1452
+
1453
+ x = Number(this);
1454
+
1455
+ // Test for NaN
1456
+ if (x !== x) {
1457
+ return "NaN";
1458
+ }
1459
+
1460
+ // If it is too big or small, return the string value of the number
1461
+ if (x <= -1e21 || x >= 1e21) {
1462
+ return String(x);
1463
+ }
1464
+
1465
+ s = "";
1466
+
1467
+ if (x < 0) {
1468
+ s = "-";
1469
+ x = -x;
1470
+ }
1471
+
1472
+ m = "0";
1473
+
1474
+ if (x > 1e-21) {
1475
+ // 1e-21 < x < 1e21
1476
+ // -70 < log2(x) < 70
1477
+ e = log(x * pow(2, 69, 1)) - 69;
1478
+ z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1479
+ z *= 0x10000000000000; // Math.pow(2, 52);
1480
+ e = 52 - e;
1481
+
1482
+ // -18 < e < 122
1483
+ // x = z / 2 ^ e
1484
+ if (e > 0) {
1485
+ multiply(0, z);
1486
+ j = f;
1487
+
1488
+ while (j >= 7) {
1489
+ multiply(1e7, 0);
1490
+ j -= 7;
1491
+ }
1492
+
1493
+ multiply(pow(10, j, 1), 0);
1494
+ j = e - 1;
1495
+
1496
+ while (j >= 23) {
1497
+ divide(1 << 23);
1498
+ j -= 23;
1499
+ }
1500
+
1501
+ divide(1 << j);
1502
+ multiply(1, 1);
1503
+ divide(2);
1504
+ m = toString();
1505
+ } else {
1506
+ multiply(0, z);
1507
+ multiply(1 << (-e), 0);
1508
+ m = toString() + '0.00000000000000000000'.slice(2, 2 + f);
1509
+ }
1510
+ }
1511
+
1512
+ if (f > 0) {
1513
+ k = m.length;
1514
+
1515
+ if (k <= f) {
1516
+ m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1517
+ } else {
1518
+ m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1519
+ }
1520
+ } else {
1521
+ m = s + m;
1522
+ }
1523
+
1524
+ return m;
1525
+ }
1526
+ }());
1050
1527
  }
1051
1528
 
1529
+
1530
+ //
1531
+ // String
1532
+ // ======
1533
+ //
1534
+
1535
+
1052
1536
  // ES5 15.5.4.14
1053
1537
  // http://es5.github.com/#x15.5.4.14
1538
+
1539
+ // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
1540
+ // Many browsers do not split properly with regular expressions or they
1541
+ // do not perform the split correctly under obscure conditions.
1542
+ // See http://blog.stevenlevithan.com/archives/cross-browser-split
1543
+ // I've tested in many browsers and this seems to cover the deviant ones:
1544
+ // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1545
+ // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1546
+ // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1547
+ // [undefined, "t", undefined, "e", ...]
1548
+ // ''.split(/.?/) should be [], not [""]
1549
+ // '.'.split(/()()/) should be ["."], not ["", "", "."]
1550
+
1551
+ var string_split = String.prototype.split;
1552
+ if (
1553
+ 'ab'.split(/(?:ab)*/).length !== 2 ||
1554
+ '.'.split(/(.?)(.?)/).length !== 4 ||
1555
+ 'tesst'.split(/(s)*/)[1] === "t" ||
1556
+ ''.split(/.?/).length === 0 ||
1557
+ '.'.split(/()()/).length > 1
1558
+ ) {
1559
+ (function () {
1560
+ var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1561
+
1562
+ String.prototype.split = function (separator, limit) {
1563
+ var string = this;
1564
+ if (separator === void 0 && limit === 0)
1565
+ return [];
1566
+
1567
+ // If `separator` is not a regex, use native split
1568
+ if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
1569
+ return string_split.apply(this, arguments);
1570
+ }
1571
+
1572
+ var output = [],
1573
+ flags = (separator.ignoreCase ? "i" : "") +
1574
+ (separator.multiline ? "m" : "") +
1575
+ (separator.extended ? "x" : "") + // Proposed for ES6
1576
+ (separator.sticky ? "y" : ""), // Firefox 3+
1577
+ lastLastIndex = 0,
1578
+ // Make `global` and avoid `lastIndex` issues by working with a copy
1579
+ separator = new RegExp(separator.source, flags + "g"),
1580
+ separator2, match, lastIndex, lastLength;
1581
+ string += ""; // Type-convert
1582
+ if (!compliantExecNpcg) {
1583
+ // Doesn't need flags gy, but they don't hurt
1584
+ separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1585
+ }
1586
+ /* Values for `limit`, per the spec:
1587
+ * If undefined: 4294967295 // Math.pow(2, 32) - 1
1588
+ * If 0, Infinity, or NaN: 0
1589
+ * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1590
+ * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1591
+ * If other: Type-convert, then use the above rules
1592
+ */
1593
+ limit = limit === void 0 ?
1594
+ -1 >>> 0 : // Math.pow(2, 32) - 1
1595
+ limit >>> 0; // ToUint32(limit)
1596
+ while (match = separator.exec(string)) {
1597
+ // `separator.lastIndex` is not reliable cross-browser
1598
+ lastIndex = match.index + match[0].length;
1599
+ if (lastIndex > lastLastIndex) {
1600
+ output.push(string.slice(lastLastIndex, match.index));
1601
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
1602
+ // nonparticipating capturing groups
1603
+ if (!compliantExecNpcg && match.length > 1) {
1604
+ match[0].replace(separator2, function () {
1605
+ for (var i = 1; i < arguments.length - 2; i++) {
1606
+ if (arguments[i] === void 0) {
1607
+ match[i] = void 0;
1608
+ }
1609
+ }
1610
+ });
1611
+ }
1612
+ if (match.length > 1 && match.index < string.length) {
1613
+ Array.prototype.push.apply(output, match.slice(1));
1614
+ }
1615
+ lastLength = match[0].length;
1616
+ lastLastIndex = lastIndex;
1617
+ if (output.length >= limit) {
1618
+ break;
1619
+ }
1620
+ }
1621
+ if (separator.lastIndex === match.index) {
1622
+ separator.lastIndex++; // Avoid an infinite loop
1623
+ }
1624
+ }
1625
+ if (lastLastIndex === string.length) {
1626
+ if (lastLength || !separator.test("")) {
1627
+ output.push("");
1628
+ }
1629
+ } else {
1630
+ output.push(string.slice(lastLastIndex));
1631
+ }
1632
+ return output.length > limit ? output.slice(0, limit) : output;
1633
+ };
1634
+ }());
1635
+
1054
1636
  // [bugfix, chrome]
1055
- // If separator is undefined, then the result array contains just one String, which is the this value (converted to a String). If limit is not undefined, then the output array is truncated so that it contains no more than limit elements.
1637
+ // If separator is undefined, then the result array contains just one String,
1638
+ // which is the this value (converted to a String). If limit is not undefined,
1639
+ // then the output array is truncated so that it contains no more than limit
1640
+ // elements.
1056
1641
  // "0".split(undefined, 0) -> []
1057
- if("0".split(void 0, 0).length) {
1058
- var oldSplit = String.prototype.split;
1642
+ } else if ("0".split(void 0, 0).length) {
1059
1643
  String.prototype.split = function(separator, limit) {
1060
- if(separator === void 0 && limit === 0)return [];
1061
- return oldSplit.apply(this, arguments);
1644
+ if (separator === void 0 && limit === 0) return [];
1645
+ return string_split.apply(this, arguments);
1062
1646
  }
1063
1647
  }
1064
1648
 
1649
+
1065
1650
  // ECMA-262, 3rd B.2.3
1066
- // Note an ECMAScript standart, although ECMAScript 3rd Edition has a non-normative section suggesting uniform semantics
1067
- // and it should be normalized across all browsers
1651
+ // Note an ECMAScript standart, although ECMAScript 3rd Edition has a
1652
+ // non-normative section suggesting uniform semantics and it should be
1653
+ // normalized across all browsers
1068
1654
  // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1069
1655
  if("".substr && "0b".substr(-1) !== "b") {
1070
- var oldSubstr = String.prototype.substr;
1656
+ var string_substr = String.prototype.substr;
1071
1657
  /**
1072
- * Get the substring of a string
1073
- * @param {integer} start where to start the substring
1074
- * @param {integer} length how many characters to return
1075
- * @return {string}
1076
- */
1658
+ * Get the substring of a string
1659
+ * @param {integer} start where to start the substring
1660
+ * @param {integer} length how many characters to return
1661
+ * @return {string}
1662
+ */
1077
1663
  String.prototype.substr = function(start, length) {
1078
- return oldSubstr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);
1664
+ return string_substr.call(
1665
+ this,
1666
+ start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1667
+ length
1668
+ );
1079
1669
  }
1080
1670
  }
1081
1671
 
1672
+ // ES5 15.5.4.20
1673
+ // http://es5.github.com/#x15.5.4.20
1674
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1675
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1676
+ "\u2029\uFEFF";
1677
+ if (!String.prototype.trim || ws.trim()) {
1678
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1679
+ // http://perfectionkills.com/whitespace-deviations/
1680
+ ws = "[" + ws + "]";
1681
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1682
+ trimEndRegexp = new RegExp(ws + ws + "*$");
1683
+ String.prototype.trim = function trim() {
1684
+ if (this === void 0 || this === null) {
1685
+ throw new TypeError("can't convert "+this+" to object");
1686
+ }
1687
+ return String(this)
1688
+ .replace(trimBeginRegexp, "")
1689
+ .replace(trimEndRegexp, "");
1690
+ };
1691
+ }
1692
+
1082
1693
  //
1083
1694
  // Util
1084
1695
  // ======
1085
1696
  //
1086
1697
 
1698
+ // ES5 9.4
1699
+ // http://es5.github.com/#x9.4
1087
1700
  // http://jsperf.com/to-integer
1088
- var toInteger = function (n) {
1701
+
1702
+ function toInteger(n) {
1089
1703
  n = +n;
1090
- if (n !== n) // isNaN
1091
- n = -1;
1092
- else if (n !== 0 && n !== (1/0) && n !== -(1/0))
1704
+ if (n !== n) { // isNaN
1705
+ n = 0;
1706
+ } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
1093
1707
  n = (n > 0 || -1) * Math.floor(Math.abs(n));
1708
+ }
1094
1709
  return n;
1095
- };
1710
+ }
1096
1711
 
1097
- var prepareString = "a"[0] != "a",
1098
- // ES5 9.9
1099
- toObject = function (o) {
1100
- if (o == null) { // this matches both null and undefined
1101
- throw new TypeError(); // TODO message
1712
+ function isPrimitive(input) {
1713
+ var type = typeof input;
1714
+ return (
1715
+ input === null ||
1716
+ type === "undefined" ||
1717
+ type === "boolean" ||
1718
+ type === "number" ||
1719
+ type === "string"
1720
+ );
1721
+ }
1722
+
1723
+ function toPrimitive(input) {
1724
+ var val, valueOf, toString;
1725
+ if (isPrimitive(input)) {
1726
+ return input;
1727
+ }
1728
+ valueOf = input.valueOf;
1729
+ if (typeof valueOf === "function") {
1730
+ val = valueOf.call(input);
1731
+ if (isPrimitive(val)) {
1732
+ return val;
1102
1733
  }
1103
- // If the implementation doesn't support by-index access of
1104
- // string characters (ex. IE < 7), split the string
1105
- if (prepareString && typeof o == "string" && o) {
1106
- return o.split("");
1734
+ }
1735
+ toString = input.toString;
1736
+ if (typeof toString === "function") {
1737
+ val = toString.call(input);
1738
+ if (isPrimitive(val)) {
1739
+ return val;
1107
1740
  }
1108
- return Object(o);
1109
- };
1741
+ }
1742
+ throw new TypeError();
1743
+ }
1744
+
1745
+ // ES5 9.9
1746
+ // http://es5.github.com/#x9.9
1747
+ var toObject = function (o) {
1748
+ if (o == null) { // this matches both null and undefined
1749
+ throw new TypeError("can't convert "+o+" to object");
1750
+ }
1751
+ return Object(o);
1752
+ };
1110
1753
 
1111
1754
  })();
1112
1755
 
1113
1756
 
1114
1757
 
1758
+
1115
1759
  (function($, shims){
1116
1760
  var defineProperty = 'defineProperty';
1117
1761
  var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
@@ -1265,8 +1909,8 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1265
1909
  webshims.error("IE browser modes are busted in IE10+. Please test your HTML/CSS/JS with a real IE version or at least IETester or similiar tools");
1266
1910
  }
1267
1911
 
1268
- if(!$.parseHTML){
1269
- webshims.error("Webshims needs jQuery 1.8+ to work properly. Please update your jQuery version or downgrade webshims.");
1912
+ if('debug' in webshims){
1913
+ webshims.error('Use webshims.setOptions("debug", true||false||"noCombo"); to debug flag');
1270
1914
  }
1271
1915
 
1272
1916
  if (!webshims.cfg.no$Switch) {
@@ -1302,7 +1946,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1302
1946
  // '127.0.0.1': 1
1303
1947
  // };
1304
1948
  //
1305
- // if( webshims.debug && (hostNames[location.hostname] || location.protocol == 'file:') ){
1949
+ // if( webshims.cfg.debug && (hostNames[location.hostname] || location.protocol == 'file:') ){
1306
1950
  // var list = $('<ul class="webshims-debug-list" />');
1307
1951
  // webshims.errorLog.push = function(message){
1308
1952
  // list.appendTo('body');
@@ -1734,7 +2378,6 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1734
2378
  };
1735
2379
 
1736
2380
  $.extend(webshims, {
1737
-
1738
2381
  getID: (function(){
1739
2382
  var ID = new Date().getTime();
1740
2383
  return function(elem){
@@ -1764,6 +2407,51 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1764
2407
  }
1765
2408
  });
1766
2409
  },
2410
+ getOptions: (function(){
2411
+ var regs = {};
2412
+ var regFn = function(f, upper){
2413
+ return upper.toLowerCase();
2414
+ };
2415
+ return function(elem, name, bases){
2416
+ var data = elementData(elem, 'cfg'+name);
2417
+ var dataName;
2418
+ var cfg = {};
2419
+
2420
+ if(data){
2421
+ return data;
2422
+ }
2423
+ data = $(elem).data();
2424
+
2425
+ if(!bases){
2426
+ bases = [true, {}];
2427
+ } else if(!Array.isArray(bases)){
2428
+ bases = [true, {}, bases];
2429
+ } else {
2430
+ bases.unshift(true, {});
2431
+ }
2432
+
2433
+ if(data && data[name]){
2434
+ if(typeof data[name] == 'object'){
2435
+ bases.push(data[name]);
2436
+ } else {
2437
+ webshims.error('data-'+ name +' attribute has to be a valid JSON, was: '+ data[name]);
2438
+ }
2439
+ }
2440
+
2441
+ if(!regs[name]){
2442
+ regs[name] = new RegExp('^'+ name +'([A-Z])');
2443
+ }
2444
+
2445
+ for(dataName in data){
2446
+ if(regs[name].test(dataName)){
2447
+ cfg[dataName.replace(regs[name], regFn)] = data[dataName];
2448
+ }
2449
+ }
2450
+ bases.push(cfg);
2451
+
2452
+ return elementData(elem, 'cfg'+name, $.extend.apply($, bases));
2453
+ };
2454
+ })(),
1767
2455
  //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
1768
2456
  createPropDefault: createPropDefault,
1769
2457
  data: elementData,
@@ -1851,7 +2539,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1851
2539
  setInterval(this.test, 600);
1852
2540
  $(this.test);
1853
2541
  webshims.ready('WINDOWLOAD', this.test);
1854
- $(document).on('updatelayout', this.handler);
2542
+ $(document).on('updatelayout pageinit collapsibleexpand shown.bs.modal shown.bs.collapse slid.bs.carousel', this.handler);
1855
2543
  $(window).on('resize', this.handler);
1856
2544
  (function(){
1857
2545
  var oldAnimate = $.fn.animate;
@@ -2209,109 +2897,67 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2209
2897
  }
2210
2898
  },
2211
2899
 
2212
- // set current Lang:
2213
- // - webshims.activeLang(lang:string);
2214
- // get current lang
2215
- // - webshims.activeLang();
2216
- // get current lang
2217
- // webshims.activeLang({
2218
- // register: moduleName:string,
2219
- // callback: callback:function
2220
- // });
2221
- // get/set including remoteLang
2222
- // - webshims.activeLang({
2223
- // module: moduleName:string,
2224
- // callback: callback:function,
2225
- // langObj: languageObj:array/object
2226
- // });
2227
2900
  activeLang: (function(){
2228
- var callbacks = [];
2229
- var registeredCallbacks = {};
2230
- var currentLang;
2231
- var shortLang;
2232
- var notLocal = /:\/\/|^\.*\//;
2233
- var loadRemoteLang = function(data, lang, options){
2234
- var langSrc;
2235
- if(lang && options && $.inArray(lang, options.availableLangs || options.availabeLangs || []) !== -1){
2236
- data.loading = true;
2237
- langSrc = options.langSrc;
2238
- if(!notLocal.test(langSrc)){
2239
- langSrc = webshims.cfg.basePath+langSrc;
2240
- }
2241
- webshims.loader.loadScript(langSrc+lang+'.js', function(){
2242
- if(data.langObj[lang]){
2243
- data.loading = false;
2244
- callLang(data, true);
2245
- } else {
2246
- $(function(){
2247
- if(data.langObj[lang]){
2248
- callLang(data, true);
2249
- }
2250
- data.loading = false;
2901
+ var curLang = [];
2902
+ var langDatas = [];
2903
+ var loading = {};
2904
+ var load = function(src, obj, loadingLang){
2905
+ obj._isLoading = true;
2906
+ if(loading[src]){
2907
+ loading[src].push(obj);
2908
+ } else {
2909
+ loading[src] = [obj];
2910
+ webshims.loader.loadScript(src, function(){
2911
+ if(loadingLang == curLang.join()){
2912
+ $.each(loading[src], function(i, obj){
2913
+ select(obj);
2251
2914
  });
2252
2915
  }
2916
+ delete loading[src];
2253
2917
  });
2254
- return true;
2255
2918
  }
2256
- return false;
2257
2919
  };
2258
- var callRegister = function(module){
2259
- if(registeredCallbacks[module]){
2260
- registeredCallbacks[module].forEach(function(data){
2261
- data.callback(currentLang, shortLang, '');
2262
- });
2263
- }
2264
- };
2265
- var callLang = function(data, _noLoop){
2266
- if(data.activeLang != currentLang && data.activeLang !== shortLang){
2267
- var options = modules[data.module].options;
2268
- if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
2269
- data.activeLang = currentLang;
2270
- data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
2271
- callRegister(data.module);
2272
- } else if( !_noLoop &&
2273
- !loadRemoteLang(data, currentLang, options) &&
2274
- !loadRemoteLang(data, shortLang, options) &&
2275
- data.langObj[''] && data.activeLang !== '' ) {
2276
- data.activeLang = '';
2277
- data.callback(data.langObj[''], currentLang);
2278
- callRegister(data.module);
2920
+ var select = function(obj){
2921
+ var oldLang = obj.__active;
2922
+ var selectLang = function(i, lang){
2923
+ obj._isLoading = false;
2924
+ if(obj[lang] || obj.availableLangs.indexOf(lang) != -1){
2925
+ if(obj[lang]){
2926
+ obj.__active = obj[lang];
2927
+ } else {
2928
+ load(obj.langSrc+lang, obj, curLang.join());
2929
+ }
2930
+ return false;
2279
2931
  }
2932
+ };
2933
+ $.each(curLang, selectLang);
2934
+ if(!obj.__active){
2935
+ obj.__active = obj[''];
2936
+ }
2937
+ if(oldLang != obj.__active){
2938
+ $(obj).trigger('change');
2280
2939
  }
2281
2940
  };
2282
-
2283
-
2284
- var activeLang = function(lang){
2285
-
2286
- if(typeof lang == 'string' && lang !== currentLang){
2287
- currentLang = lang;
2288
- shortLang = currentLang.split('-')[0];
2289
- if(currentLang == shortLang){
2290
- shortLang = false;
2941
+ return function(lang){
2942
+ var shortLang;
2943
+ if(typeof lang == 'string'){
2944
+ if(curLang[0] != lang){
2945
+ curLang = [lang];
2946
+ shortLang = curLang[0].split('-')[0];
2947
+ if(shortLang && shortLang != lang){
2948
+ curLang.push(shortLang);
2949
+ }
2950
+ langDatas.forEach(select);
2291
2951
  }
2292
- $.each(callbacks, function(i, data){
2293
- callLang(data);
2294
- });
2295
2952
  } else if(typeof lang == 'object'){
2296
-
2297
- if(lang.register){
2298
- if(!registeredCallbacks[lang.register]){
2299
- registeredCallbacks[lang.register] = [];
2300
- }
2301
- registeredCallbacks[lang.register].push(lang);
2302
- lang.callback(currentLang, shortLang, '');
2303
- } else {
2304
- if(!lang.activeLang){
2305
- lang.activeLang = '';
2306
- }
2307
- callbacks.push(lang);
2308
- callLang(lang);
2953
+ if(!lang.__active){
2954
+ langDatas.push(lang);
2955
+ select(lang);
2309
2956
  }
2957
+ return lang.__active;
2310
2958
  }
2311
- return currentLang;
2959
+ return curLang[0];
2312
2960
  };
2313
-
2314
- return activeLang;
2315
2961
  })()
2316
2962
  });
2317
2963
 
@@ -2437,7 +3083,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2437
3083
  var switchOptions = function(e){
2438
3084
  var media, error, parent;
2439
3085
  if(!options.preferFlash &&
2440
- ($(e.target).is('audio, video') || ((parent = e.target.parentNode) && $('source:last', parent)[0] == e.target)) &&
3086
+ ($(e.target).is('audio, video') || ((parent = e.target.parentNode) && $('source', parent).last()[0] == e.target)) &&
2441
3087
  (media = $(e.target).closest('audio, video')) && (error = media.prop('error')) && !noSwitch[error.code]
2442
3088
  ){
2443
3089
 
@@ -2945,6 +3591,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
2945
3591
  if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
2946
3592
  supLoad.prop._supvalue.apply(this, arguments);
2947
3593
  }
3594
+ $(this).triggerHandler('wsmediareload');
2948
3595
  }
2949
3596
  }
2950
3597
  });
@@ -3541,9 +4188,9 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3541
4188
  })();
3542
4189
 
3543
4190
 
3544
- var transformDimension = (function(){
4191
+ var getComputedDimension = (function(){
3545
4192
  var dimCache = {};
3546
- var getRealDims = function(data){
4193
+ var getVideoDims = function(data){
3547
4194
  var ret, poster, img;
3548
4195
  if(dimCache[data.currentSrc]){
3549
4196
  ret = dimCache[data.currentSrc];
@@ -3568,54 +4215,102 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3568
4215
  } else {
3569
4216
  delete dimCache[poster];
3570
4217
  }
4218
+ img.onload = null;
3571
4219
  };
3572
4220
  img.src = poster;
3573
- if(img.complete){
4221
+ if(img.complete && img.onload){
3574
4222
  img.onload();
3575
4223
  }
3576
4224
  }
3577
4225
  }
3578
4226
  return ret || {width: 300, height: data._elemNodeName == 'video' ? 150 : 50};
3579
4227
  };
3580
- return function(data){
3581
- var realDims, ratio;
3582
- var ret = data.elemDimensions;
4228
+
4229
+ var getCssStyle = function(elem, style){
4230
+ return elem.style[style] || (elem.currentStyle && elem.currentStyle[style]) || (window.getComputedStyle && (window.getComputedStyle( elem, null ) || {} )[style]) || '';
4231
+ };
4232
+ var minMaxProps = ['minWidth', 'maxWidth', 'minHeight', 'maxHeight'];
4233
+
4234
+ var addMinMax = function(elem, ret){
4235
+ var i, prop;
4236
+ var hasMinMax = false;
4237
+ for (i = 0; i < 4; i++) {
4238
+ prop = getCssStyle(elem, minMaxProps[i]);
4239
+ if(parseFloat(prop, 10)){
4240
+ hasMinMax = true;
4241
+ ret[minMaxProps[i]] = prop;
4242
+ }
4243
+ }
4244
+ return hasMinMax;
4245
+ };
4246
+ var retFn = function(data){
4247
+ var videoDims, ratio, hasMinMax;
4248
+ var elem = data._elem;
4249
+ var autos = {
4250
+ width: getCssStyle(elem, 'width') == 'auto',
4251
+ height: getCssStyle(elem, 'height') == 'auto'
4252
+ };
4253
+ var ret = {
4254
+ width: !autos.width && $(elem).width(),
4255
+ height: !autos.height && $(elem).height()
4256
+ };
3583
4257
 
3584
- if(ret.width == 'auto' || ret.height == 'auto'){
3585
- ret = $.extend({}, data.elemDimensions);
3586
- realDims = getRealDims(data);
3587
- ratio = realDims.width / realDims.height;
4258
+ if(autos.width || autos.height){
4259
+ videoDims = getVideoDims(data);
4260
+ ratio = videoDims.width / videoDims.height;
3588
4261
 
3589
- if(ret.width == 'auto' && ret.height == 'auto'){
3590
- ret = realDims;
3591
- } else if(ret.width == 'auto'){
3592
- data.shadowElem.css({height: ret.height});
3593
- ret.width = data.shadowElem.height() * ratio;
3594
- } else {
3595
- data.shadowElem.css({width: ret.width});
3596
- ret.height = data.shadowElem.width() / ratio;
4262
+ if(autos.width && autos.height){
4263
+ ret.width = videoDims.width;
4264
+ ret.height = videoDims.height;
4265
+ } else if(autos.width){
4266
+ ret.width = ret.height * ratio;
4267
+ } else if(autos.height){
4268
+ ret.height = ret.width / ratio;
4269
+ }
4270
+
4271
+ if(addMinMax(elem, ret)){
4272
+ data.shadowElem.css(ret);
4273
+ if(autos.width){
4274
+ ret.width = data.shadowElem.height() * ratio;
4275
+ }
4276
+ if(autos.height){
4277
+ ret.height = ((autos.width) ? ret.width : data.shadowElem.width()) / ratio;
4278
+ }
4279
+ if(autos.width && autos.height){
4280
+ data.shadowElem.css(ret);
4281
+ ret.height = data.shadowElem.width() / ratio;
4282
+ ret.width = ret.height * ratio;
4283
+
4284
+ data.shadowElem.css(ret);
4285
+ ret.width = data.shadowElem.height() * ratio;
4286
+ ret.height = ret.width / ratio;
4287
+
4288
+ }
4289
+ if(!Modernizr.video){
4290
+ ret.width = data.shadowElem.width();
4291
+ ret.height = data.shadowElem.height();
4292
+ }
3597
4293
  }
3598
4294
  }
3599
4295
  return ret;
3600
4296
  };
4297
+
4298
+ return retFn;
3601
4299
  })();
4300
+
3602
4301
  var setElementDimension = function(data, hasControls){
3603
4302
  var dims;
3604
- var elem = data._elem;
4303
+
3605
4304
  var box = data.shadowElem;
3606
- $(elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
4305
+ $(data._elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
3607
4306
 
3608
- if(data.isActive == 'third'){
4307
+ if(data.isActive == 'third' || data.activating == 'third'){
3609
4308
  if(data._elemNodeName == 'audio' && !hasControls){
3610
4309
  box.css({width: 0, height: 0});
3611
4310
  } else {
3612
- data.elemDimensions = {
3613
- width: elem.style.width || $.attr(elem, 'width') || $(elem).width(),
3614
- height: elem.style.height || $.attr(elem, 'height') || $(elem).height()
3615
- };
3616
- dims = transformDimension(data);
3617
- dims.minWidth = elem.style.minWidth;
3618
- dims.minHeight = elem.style.minHeight;
4311
+ data._elem.style.display = '';
4312
+ dims = getComputedDimension(data);
4313
+ data._elem.style.display = 'none';
3619
4314
  box.css(dims);
3620
4315
  }
3621
4316
  }
@@ -3674,6 +4369,8 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3674
4369
  }, 1);
3675
4370
  return;
3676
4371
  }
4372
+
4373
+ var attrStyle = {};
3677
4374
 
3678
4375
  if(loadedSwf < 1){
3679
4376
  loadedSwf = 1;
@@ -3684,7 +4381,8 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3684
4381
  data = webshims.data(elem, 'mediaelement');
3685
4382
  }
3686
4383
 
3687
- if($.attr(elem, 'height') || $.attr(elem, 'width')){
4384
+ if((attrStyle.height = $.attr(elem, 'height') || '') || (attrStyle.width = $.attr(elem, 'width') || '')){
4385
+ $(elem).css(attrStyle);
3688
4386
  webshims.warn("width or height content attributes used. Webshims prefers the usage of CSS (computed styles or inline styles) to detect size of a video/audio. It's really more powerfull.");
3689
4387
  }
3690
4388
 
@@ -3791,7 +4489,7 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3791
4489
  box.insertBefore(elem);
3792
4490
 
3793
4491
  if(hasNative){
3794
- $.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted'), paused: $.prop(elem, 'paused')});
4492
+ $.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted')});
3795
4493
  }
3796
4494
 
3797
4495
  webshims.addShadowDom(elem, box);