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
@@ -1,97 +1,55 @@
1
+ // Copyright 2009-2012 by contributors, MIT License
1
2
  // vim: ts=4 sts=4 sw=4 expandtab
2
- // -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
3
- // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
4
- // -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
5
- // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
6
- // -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
7
- // -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
8
- // -- kossnocorp Sasha Koss XXX TODO License or CLA
9
- // -- bryanforbes Bryan Forbes XXX TODO License or CLA
10
- // -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
11
- // -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
12
- // -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
13
- // -- bbqsrc Brendan Molloy XXX TODO License or CLA
14
- // -- iwyg XXX TODO License or CLA
15
- // -- DomenicDenicola Domenic Denicola XXX TODO License or CLA
16
- // -- xavierm02 Montillet Xavier XXX TODO License or CLA
17
- // -- Raynos Raynos XXX TODO License or CLA
18
- // -- samsonjs Sami Samhuri XXX TODO License or CLA
19
- // -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
20
- // -- lexer Alexey Zakharov XXX TODO License or CLA
21
-
22
- /*!
23
- Copyright (c) 2009, 280 North Inc. http://280north.com/
24
- MIT License. http://github.com/280north/narwhal/blob/master/README.md
25
- */
26
-
27
- (function (undefined) {
3
+
4
+ (function () {
28
5
 
29
6
  /**
30
7
  * Brings an environment as close to ECMAScript 5 compliance
31
8
  * as is possible with the facilities of erstwhile engines.
32
9
  *
33
- * ES5 Draft
34
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-050.pdf
35
- *
36
- * NOTE: this is a draft, and as such, the URL is subject to change. If the
37
- * link is broken, check in the parent directory for the latest TC39 PDF.
38
- * http://www.ecma-international.org/publications/files/drafts/
39
- *
40
- * Previous ES5 Draft
41
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
42
- * This is a broken link to the previous draft of ES5 on which most of the
43
- * numbered specification references and quotes herein were taken. Updating
44
- * these references and quotes to reflect the new document would be a welcome
45
- * volunteer project.
46
- *
47
- * @module
10
+ * Annotated ES5: http://es5.github.com/ (specific links below)
11
+ * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
12
+ * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
48
13
  */
49
14
 
50
- /*whatsupdoc*/
51
-
52
- // Shortcut to an often accessed properties, in order to avoid multiple
53
- // dereference that costs universally.
54
- // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
55
- // us it in defining shortcuts.
56
- var call = Function.prototype.call;
57
- var prototypeOfArray = Array.prototype;
58
- var prototypeOfObject = Object.prototype;
59
- var slice = prototypeOfArray.slice;
60
- var owns;
61
- var toString;
15
+ //
16
+ // Function
17
+ // ========
18
+ //
62
19
 
63
20
  // ES-5 15.3.4.5
64
- // http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
21
+ // http://es5.github.com/#x15.3.4.5
22
+
23
+ function Empty() {}
65
24
 
66
25
  if (!Function.prototype.bind) {
67
- Function.prototype.bind = function (that) { // .length is 1
26
+ Function.prototype.bind = function bind(that) { // .length is 1
68
27
  // 1. Let Target be the this value.
69
28
  var target = this;
70
29
  // 2. If IsCallable(Target) is false, throw a TypeError exception.
71
- if (typeof target != "function")
72
- throw new TypeError(); // TODO message
30
+ if (typeof target != "function") {
31
+ throw new TypeError("Function.prototype.bind called on incompatible " + target);
32
+ }
73
33
  // 3. Let A be a new (possibly empty) internal list of all of the
74
34
  // argument values provided after thisArg (arg1, arg2 etc), in order.
75
35
  // XXX slicedArgs will stand in for "A" if used
76
- var args = slice.call(arguments, 1); // for normal call
36
+ var args = _Array_slice_.call(arguments, 1); // for normal call
77
37
  // 4. Let F be a new native ECMAScript object.
78
- // 9. Set the [[Prototype]] internal property of F to the standard
38
+ // 11. Set the [[Prototype]] internal property of F to the standard
79
39
  // built-in Function prototype object as specified in 15.3.3.1.
80
- // 10. Set the [[Call]] internal property of F as described in
40
+ // 12. Set the [[Call]] internal property of F as described in
81
41
  // 15.3.4.5.1.
82
- // 11. Set the [[Construct]] internal property of F as described in
42
+ // 13. Set the [[Construct]] internal property of F as described in
83
43
  // 15.3.4.5.2.
84
- // 12. Set the [[HasInstance]] internal property of F as described in
44
+ // 14. Set the [[HasInstance]] internal property of F as described in
85
45
  // 15.3.4.5.3.
86
- // 13. The [[Scope]] internal property of F is unused and need not
87
- // exist.
88
46
  var bound = function () {
89
47
 
90
48
  if (this instanceof bound) {
91
49
  // 15.3.4.5.2 [[Construct]]
92
50
  // When the [[Construct]] internal method of a function object,
93
51
  // F that was created using the bind function is called with a
94
- // list of arguments ExtraArgs the following steps are taken:
52
+ // list of arguments ExtraArgs, the following steps are taken:
95
53
  // 1. Let target be the value of F's [[TargetFunction]]
96
54
  // internal property.
97
55
  // 2. If target has no [[Construct]] internal method, a
@@ -101,24 +59,23 @@ if (!Function.prototype.bind) {
101
59
  // 4. Let args be a new list containing the same values as the
102
60
  // list boundArgs in the same order followed by the same
103
61
  // values as the list ExtraArgs in the same order.
104
-
105
- var F = function(){};
106
- F.prototype = target.prototype;
107
- var self = new F;
62
+ // 5. Return the result of calling the [[Construct]] internal
63
+ // method of target providing args as the arguments.
108
64
 
109
65
  var result = target.apply(
110
- self,
111
- args.concat(slice.call(arguments))
66
+ this,
67
+ args.concat(_Array_slice_.call(arguments))
112
68
  );
113
- if (result !== null && Object(result) === result)
69
+ if (Object(result) === result) {
114
70
  return result;
115
- return self;
71
+ }
72
+ return this;
116
73
 
117
74
  } else {
118
75
  // 15.3.4.5.1 [[Call]]
119
76
  // When the [[Call]] internal method of a function object, F,
120
77
  // which was created using the bind function is called with a
121
- // this value and a list of arguments ExtraArgs the following
78
+ // this value and a list of arguments ExtraArgs, the following
122
79
  // steps are taken:
123
80
  // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
124
81
  // property.
@@ -126,59 +83,207 @@ if (!Function.prototype.bind) {
126
83
  // property.
127
84
  // 3. Let target be the value of F's [[TargetFunction]] internal
128
85
  // property.
129
- // 4. Let args be a new list containing the same values as the list
130
- // boundArgs in the same order followed by the same values as
131
- // the list ExtraArgs in the same order. 5. Return the
132
- // result of calling the [[Call]] internal method of target
133
- // providing boundThis as the this value and providing args
134
- // as the arguments.
86
+ // 4. Let args be a new list containing the same values as the
87
+ // list boundArgs in the same order followed by the same
88
+ // values as the list ExtraArgs in the same order.
89
+ // 5. Return the result of calling the [[Call]] internal method
90
+ // of target providing boundThis as the this value and
91
+ // providing args as the arguments.
135
92
 
136
93
  // equiv: target.call(this, ...boundArgs, ...args)
137
94
  return target.apply(
138
95
  that,
139
- args.concat(slice.call(arguments))
96
+ args.concat(_Array_slice_.call(arguments))
140
97
  );
141
98
 
142
99
  }
143
100
 
144
101
  };
102
+ if(target.prototype) {
103
+ Empty.prototype = target.prototype;
104
+ bound.prototype = new Empty();
105
+ // Clean up dangling references.
106
+ Empty.prototype = null;
107
+ }
145
108
  // XXX bound.length is never writable, so don't even try
146
109
  //
147
- // 16. The length own property of F is given attributes as specified in
148
- // 15.3.5.1.
149
- // TODO
150
- // 17. Set the [[Extensible]] internal property of F to true.
110
+ // 15. If the [[Class]] internal property of Target is "Function", then
111
+ // a. Let L be the length property of Target minus the length of A.
112
+ // b. Set the length own property of F to either 0 or L, whichever is
113
+ // larger.
114
+ // 16. Else set the length own property of F to 0.
115
+ // 17. Set the attributes of the length own property of F to the values
116
+ // specified in 15.3.5.1.
117
+
151
118
  // TODO
152
- // 18. Call the [[DefineOwnProperty]] internal method of F with
153
- // arguments "caller", PropertyDescriptor {[[Value]]: null,
154
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
155
- // false}, and false.
119
+ // 18. Set the [[Extensible]] internal property of F to true.
120
+
156
121
  // TODO
157
- // 19. Call the [[DefineOwnProperty]] internal method of F with
158
- // arguments "arguments", PropertyDescriptor {[[Value]]: null,
159
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
160
- // false}, and false.
122
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
123
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
124
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
125
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
126
+ // false.
127
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
128
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
129
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
130
+ // and false.
131
+
161
132
  // TODO
162
133
  // NOTE Function objects created using Function.prototype.bind do not
163
- // have a prototype property.
164
- // XXX can't delete it in pure-js.
134
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
135
+ // [[Scope]] internal properties.
136
+ // XXX can't delete prototype in pure-js.
137
+
138
+ // 22. Return F.
165
139
  return bound;
166
140
  };
167
141
  }
168
142
 
169
- toString = call.bind(prototypeOfObject.toString);
170
- owns = call.bind(prototypeOfObject.hasOwnProperty);
143
+ // Shortcut to an often accessed properties, in order to avoid multiple
144
+ // dereference that costs universally.
145
+ // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
146
+ // us it in defining shortcuts.
147
+ var call = Function.prototype.call;
148
+ var prototypeOfArray = Array.prototype;
149
+ var prototypeOfObject = Object.prototype;
150
+ var _Array_slice_ = prototypeOfArray.slice;
151
+ // Having a toString local variable name breaks in Opera so use _toString.
152
+ var _toString = call.bind(prototypeOfObject.toString);
153
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
171
154
 
155
+ // If JS engine supports accessors creating shortcuts.
156
+ var defineGetter;
157
+ var defineSetter;
158
+ var lookupGetter;
159
+ var lookupSetter;
160
+ var supportsAccessors;
161
+ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
162
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
163
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
164
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
165
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
166
+ }
172
167
 
173
168
  //
174
169
  // Array
175
170
  // =====
176
171
  //
177
172
 
173
+ // ES5 15.4.4.12
174
+ // http://es5.github.com/#x15.4.4.12
175
+ // Default value for second param
176
+ // [bugfix, ielt9, old browsers]
177
+ // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
178
+ if ([1,2].splice(0).length != 2) {
179
+ var array_splice = Array.prototype.splice;
180
+
181
+ if(function() { // test IE < 9 to splice bug - see issue #138
182
+ function makeArray(l) {
183
+ var a = [];
184
+ while (l--) {
185
+ a.unshift(l)
186
+ }
187
+ return a
188
+ }
189
+
190
+ var array = []
191
+ , lengthBefore
192
+ ;
193
+
194
+ array.splice.bind(array, 0, 0).apply(null, makeArray(20));
195
+ array.splice.bind(array, 0, 0).apply(null, makeArray(26));
196
+
197
+ lengthBefore = array.length; //20
198
+ array.splice(5, 0, "XXX"); // add one element
199
+
200
+ if(lengthBefore + 1 == array.length) {
201
+ return true;// has right splice implementation without bugs
202
+ }
203
+ // else {
204
+ // IE8 bug
205
+ // }
206
+ }()) {//IE 6/7
207
+ Array.prototype.splice = function(start, deleteCount) {
208
+ if (!arguments.length) {
209
+ return [];
210
+ } else {
211
+ return array_splice.apply(this, [
212
+ start === void 0 ? 0 : start,
213
+ deleteCount === void 0 ? (this.length - start) : deleteCount
214
+ ].concat(_Array_slice_.call(arguments, 2)))
215
+ }
216
+ };
217
+ }
218
+ else {//IE8
219
+ Array.prototype.splice = function(start, deleteCount) {
220
+ var result
221
+ , args = _Array_slice_.call(arguments, 2)
222
+ , addElementsCount = args.length
223
+ ;
224
+
225
+ if(!arguments.length) {
226
+ return [];
227
+ }
228
+
229
+ if(start === void 0) { // default
230
+ start = 0;
231
+ }
232
+ if(deleteCount === void 0) { // default
233
+ deleteCount = this.length - start;
234
+ }
235
+
236
+ if(addElementsCount > 0) {
237
+ if(deleteCount <= 0) {
238
+ if(start == this.length) { // tiny optimisation #1
239
+ this.push.apply(this, args);
240
+ return [];
241
+ }
242
+
243
+ if(start == 0) { // tiny optimisation #2
244
+ this.unshift.apply(this, args);
245
+ return [];
246
+ }
247
+ }
248
+
249
+ // Array.prototype.splice implementation
250
+ result = _Array_slice_.call(this, start, start + deleteCount);// delete part
251
+ args.push.apply(args, _Array_slice_.call(this, start + deleteCount, this.length));// right part
252
+ args.unshift.apply(args, _Array_slice_.call(this, 0, start));// left part
253
+
254
+ // delete all items from this array and replace it to 'left part' + _Array_slice_.call(arguments, 2) + 'right part'
255
+ args.unshift(0, this.length);
256
+
257
+ array_splice.apply(this, args);
258
+
259
+ return result;
260
+ }
261
+
262
+ return array_splice.call(this, start, deleteCount);
263
+ }
264
+
265
+ }
266
+ }
267
+
268
+ // ES5 15.4.4.12
269
+ // http://es5.github.com/#x15.4.4.13
270
+ // Return len+argCount.
271
+ // [bugfix, ielt8]
272
+ // IE < 8 bug: [].unshift(0) == undefined but should be "1"
273
+ if ([].unshift(0) != 1) {
274
+ var array_unshift = Array.prototype.unshift;
275
+ Array.prototype.unshift = function() {
276
+ array_unshift.apply(this, arguments);
277
+ return this.length;
278
+ };
279
+ }
280
+
178
281
  // ES5 15.4.3.2
282
+ // http://es5.github.com/#x15.4.3.2
283
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
179
284
  if (!Array.isArray) {
180
- Array.isArray = function (obj) {
181
- return toString(obj) == "[object Array]";
285
+ Array.isArray = function isArray(obj) {
286
+ return _toString(obj) == "[object Array]";
182
287
  };
183
288
  }
184
289
 
@@ -195,129 +300,169 @@ if (!Array.isArray) {
195
300
  // expressions.
196
301
 
197
302
  // ES5 15.4.4.18
198
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
303
+ // http://es5.github.com/#x15.4.4.18
304
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
305
+
306
+ // Check failure of by-index access of string characters (IE < 9)
307
+ // and failure of `0 in boxedString` (Rhino)
308
+ var boxedString = Object("a"),
309
+ splitString = boxedString[0] != "a" || !(0 in boxedString);
310
+
199
311
  if (!Array.prototype.forEach) {
200
- Array.prototype.forEach = function (fun /*, thisp*/) {
201
- var self = toObject(this),
312
+ Array.prototype.forEach = function forEach(fun /*, thisp*/) {
313
+ var object = toObject(this),
314
+ self = splitString && _toString(this) == "[object String]" ?
315
+ this.split("") :
316
+ object,
202
317
  thisp = arguments[1],
203
- i = 0,
318
+ i = -1,
204
319
  length = self.length >>> 0;
205
320
 
206
321
  // If no callback function or if callback is not a callable function
207
- if (toString(fun) != "[object Function]") {
322
+ if (_toString(fun) != "[object Function]") {
208
323
  throw new TypeError(); // TODO message
209
324
  }
210
325
 
211
- while (i < length) {
326
+ while (++i < length) {
212
327
  if (i in self) {
213
328
  // Invoke the callback function with call, passing arguments:
214
- // context, property value, property key, thisArg object context
215
- fun.call(thisp, self[i], i, self);
329
+ // context, property value, property key, thisArg object
330
+ // context
331
+ fun.call(thisp, self[i], i, object);
216
332
  }
217
- i++;
218
333
  }
219
334
  };
220
335
  }
221
336
 
222
337
  // ES5 15.4.4.19
338
+ // http://es5.github.com/#x15.4.4.19
223
339
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
224
340
  if (!Array.prototype.map) {
225
- Array.prototype.map = function (fun /*, thisp*/) {
226
- var self = toObject(this),
341
+ Array.prototype.map = function map(fun /*, thisp*/) {
342
+ var object = toObject(this),
343
+ self = splitString && _toString(this) == "[object String]" ?
344
+ this.split("") :
345
+ object,
227
346
  length = self.length >>> 0,
228
347
  result = Array(length),
229
348
  thisp = arguments[1];
230
349
 
231
350
  // If no callback function or if callback is not a callable function
232
- if (toString(fun) != "[object Function]") {
233
- throw new TypeError(); // TODO message
351
+ if (_toString(fun) != "[object Function]") {
352
+ throw new TypeError(fun + " is not a function");
234
353
  }
235
354
 
236
355
  for (var i = 0; i < length; i++) {
237
356
  if (i in self)
238
- result[i] = fun.call(thisp, self[i], i, self);
357
+ result[i] = fun.call(thisp, self[i], i, object);
239
358
  }
240
359
  return result;
241
360
  };
242
361
  }
243
362
 
244
363
  // ES5 15.4.4.20
364
+ // http://es5.github.com/#x15.4.4.20
365
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
245
366
  if (!Array.prototype.filter) {
246
- Array.prototype.filter = function (fun /*, thisp */) {
247
- var self = toObject(this),
367
+ Array.prototype.filter = function filter(fun /*, thisp */) {
368
+ var object = toObject(this),
369
+ self = splitString && _toString(this) == "[object String]" ?
370
+ this.split("") :
371
+ object,
248
372
  length = self.length >>> 0,
249
373
  result = [],
374
+ value,
250
375
  thisp = arguments[1];
251
376
 
252
377
  // If no callback function or if callback is not a callable function
253
- if (toString(fun) != "[object Function]") {
254
- throw new TypeError(); // TODO message
378
+ if (_toString(fun) != "[object Function]") {
379
+ throw new TypeError(fun + " is not a function");
255
380
  }
256
381
 
257
382
  for (var i = 0; i < length; i++) {
258
- if (i in self && fun.call(thisp, self[i], i, self))
259
- result.push(self[i]);
383
+ if (i in self) {
384
+ value = self[i];
385
+ if (fun.call(thisp, value, i, object)) {
386
+ result.push(value);
387
+ }
388
+ }
260
389
  }
261
390
  return result;
262
391
  };
263
392
  }
264
393
 
265
394
  // ES5 15.4.4.16
395
+ // http://es5.github.com/#x15.4.4.16
396
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
266
397
  if (!Array.prototype.every) {
267
- Array.prototype.every = function (fun /*, thisp */) {
268
- var self = toObject(this),
398
+ Array.prototype.every = function every(fun /*, thisp */) {
399
+ var object = toObject(this),
400
+ self = splitString && _toString(this) == "[object String]" ?
401
+ this.split("") :
402
+ object,
269
403
  length = self.length >>> 0,
270
404
  thisp = arguments[1];
271
405
 
272
406
  // If no callback function or if callback is not a callable function
273
- if (toString(fun) != "[object Function]") {
274
- throw new TypeError(); // TODO message
407
+ if (_toString(fun) != "[object Function]") {
408
+ throw new TypeError(fun + " is not a function");
275
409
  }
276
410
 
277
411
  for (var i = 0; i < length; i++) {
278
- if (i in self && !fun.call(thisp, self[i], i, self))
412
+ if (i in self && !fun.call(thisp, self[i], i, object)) {
279
413
  return false;
414
+ }
280
415
  }
281
416
  return true;
282
417
  };
283
418
  }
284
419
 
285
420
  // ES5 15.4.4.17
421
+ // http://es5.github.com/#x15.4.4.17
286
422
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
287
423
  if (!Array.prototype.some) {
288
- Array.prototype.some = function (fun /*, thisp */) {
289
- var self = toObject(this),
424
+ Array.prototype.some = function some(fun /*, thisp */) {
425
+ var object = toObject(this),
426
+ self = splitString && _toString(this) == "[object String]" ?
427
+ this.split("") :
428
+ object,
290
429
  length = self.length >>> 0,
291
430
  thisp = arguments[1];
292
431
 
293
432
  // If no callback function or if callback is not a callable function
294
- if (toString(fun) != "[object Function]") {
295
- throw new TypeError(); // TODO message
433
+ if (_toString(fun) != "[object Function]") {
434
+ throw new TypeError(fun + " is not a function");
296
435
  }
297
436
 
298
437
  for (var i = 0; i < length; i++) {
299
- if (i in self && fun.call(thisp, self[i], i, self))
438
+ if (i in self && fun.call(thisp, self[i], i, object)) {
300
439
  return true;
440
+ }
301
441
  }
302
442
  return false;
303
443
  };
304
444
  }
305
445
 
306
446
  // ES5 15.4.4.21
447
+ // http://es5.github.com/#x15.4.4.21
307
448
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
308
449
  if (!Array.prototype.reduce) {
309
- Array.prototype.reduce = function (fun /*, initial*/) {
310
- var self = toObject(this),
450
+ Array.prototype.reduce = function reduce(fun /*, initial*/) {
451
+ var object = toObject(this),
452
+ self = splitString && _toString(this) == "[object String]" ?
453
+ this.split("") :
454
+ object,
311
455
  length = self.length >>> 0;
312
456
 
313
457
  // If no callback function or if callback is not a callable function
314
- if (toString(fun) != "[object Function]") {
315
- throw new TypeError(); // TODO message
458
+ if (_toString(fun) != "[object Function]") {
459
+ throw new TypeError(fun + " is not a function");
316
460
  }
317
461
 
318
462
  // no value to return if no initial value and an empty array
319
- if (!length && arguments.length == 1)
320
- throw new TypeError(); // TODO message
463
+ if (!length && arguments.length == 1) {
464
+ throw new TypeError("reduce of empty array with no initial value");
465
+ }
321
466
 
322
467
  var i = 0;
323
468
  var result;
@@ -331,14 +476,16 @@ if (!Array.prototype.reduce) {
331
476
  }
332
477
 
333
478
  // if array contains no values, no initial value to return
334
- if (++i >= length)
335
- throw new TypeError(); // TODO message
479
+ if (++i >= length) {
480
+ throw new TypeError("reduce of empty array with no initial value");
481
+ }
336
482
  } while (true);
337
483
  }
338
484
 
339
485
  for (; i < length; i++) {
340
- if (i in self)
341
- result = fun.call(void 0, result, self[i], i, self);
486
+ if (i in self) {
487
+ result = fun.call(void 0, result, self[i], i, object);
488
+ }
342
489
  }
343
490
 
344
491
  return result;
@@ -346,20 +493,25 @@ if (!Array.prototype.reduce) {
346
493
  }
347
494
 
348
495
  // ES5 15.4.4.22
496
+ // http://es5.github.com/#x15.4.4.22
349
497
  // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
350
498
  if (!Array.prototype.reduceRight) {
351
- Array.prototype.reduceRight = function (fun /*, initial*/) {
352
- var self = toObject(this),
499
+ Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
500
+ var object = toObject(this),
501
+ self = splitString && _toString(this) == "[object String]" ?
502
+ this.split("") :
503
+ object,
353
504
  length = self.length >>> 0;
354
505
 
355
506
  // If no callback function or if callback is not a callable function
356
- if (toString(fun) != "[object Function]") {
357
- throw new TypeError(); // TODO message
507
+ if (_toString(fun) != "[object Function]") {
508
+ throw new TypeError(fun + " is not a function");
358
509
  }
359
510
 
360
511
  // no value to return if no initial value, empty array
361
- if (!length && arguments.length == 1)
362
- throw new TypeError(); // TODO message
512
+ if (!length && arguments.length == 1) {
513
+ throw new TypeError("reduceRight of empty array with no initial value");
514
+ }
363
515
 
364
516
  var result, i = length - 1;
365
517
  if (arguments.length >= 2) {
@@ -372,14 +524,20 @@ if (!Array.prototype.reduceRight) {
372
524
  }
373
525
 
374
526
  // if array contains no values, no initial value to return
375
- if (--i < 0)
376
- throw new TypeError(); // TODO message
527
+ if (--i < 0) {
528
+ throw new TypeError("reduceRight of empty array with no initial value");
529
+ }
377
530
  } while (true);
378
531
  }
379
532
 
533
+ if (i < 0) {
534
+ return result;
535
+ }
536
+
380
537
  do {
381
- if (i in this)
382
- result = fun.call(void 0, result, self[i], i, self);
538
+ if (i in this) {
539
+ result = fun.call(void 0, result, self[i], i, object);
540
+ }
383
541
  } while (i--);
384
542
 
385
543
  return result;
@@ -387,21 +545,26 @@ if (!Array.prototype.reduceRight) {
387
545
  }
388
546
 
389
547
  // ES5 15.4.4.14
548
+ // http://es5.github.com/#x15.4.4.14
390
549
  // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
391
- if (!Array.prototype.indexOf) {
392
- Array.prototype.indexOf = function (sought /*, fromIndex */ ) {
393
- var self = toObject(this),
550
+ if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
551
+ Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
552
+ var self = splitString && _toString(this) == "[object String]" ?
553
+ this.split("") :
554
+ toObject(this),
394
555
  length = self.length >>> 0;
395
556
 
396
- if (!length)
557
+ if (!length) {
397
558
  return -1;
559
+ }
398
560
 
399
561
  var i = 0;
400
- if (arguments.length > 1)
562
+ if (arguments.length > 1) {
401
563
  i = toInteger(arguments[1]);
564
+ }
402
565
 
403
566
  // handle negative indices
404
- i = i >= 0 ? i : length - Math.abs(i);
567
+ i = i >= 0 ? i : Math.max(0, length + i);
405
568
  for (; i < length; i++) {
406
569
  if (i in self && self[i] === sought) {
407
570
  return i;
@@ -412,59 +575,42 @@ if (!Array.prototype.indexOf) {
412
575
  }
413
576
 
414
577
  // ES5 15.4.4.15
415
- if (!Array.prototype.lastIndexOf) {
416
- Array.prototype.lastIndexOf = function (sought /*, fromIndex */) {
417
- var self = toObject(this),
578
+ // http://es5.github.com/#x15.4.4.15
579
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
580
+ if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
581
+ Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
582
+ var self = splitString && _toString(this) == "[object String]" ?
583
+ this.split("") :
584
+ toObject(this),
418
585
  length = self.length >>> 0;
419
586
 
420
- if (!length)
587
+ if (!length) {
421
588
  return -1;
589
+ }
422
590
  var i = length - 1;
423
- if (arguments.length > 1)
424
- i = toInteger(arguments[1]);
591
+ if (arguments.length > 1) {
592
+ i = Math.min(i, toInteger(arguments[1]));
593
+ }
425
594
  // handle negative indices
426
595
  i = i >= 0 ? i : length - Math.abs(i);
427
596
  for (; i >= 0; i--) {
428
- if (i in self && sought === self[i])
597
+ if (i in self && sought === self[i]) {
429
598
  return i;
599
+ }
430
600
  }
431
601
  return -1;
432
602
  };
433
603
  }
434
604
 
435
- //
436
- // Array
437
- // =====
438
- //
439
-
440
- // ES5 15.4.4.12
441
- // http://es5.github.com/#x15.4.4.12
442
- // Default value for second param
443
- // [bugfix, ielt9, old browsers]
444
- // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
445
- if([1,2].splice(0).length != 2) {
446
- var _origArraySplice = Array.prototype.splice;
447
-
448
- Array.prototype.splice = function(start, deleteCount) {
449
- if(!arguments.length)return [];
450
-
451
- return _origArraySplice.apply(this, [
452
- start === void 0 ? 0 : start,
453
- deleteCount === void 0 ? (this.length - start) : deleteCount
454
- ].concat(slice.call(arguments, 2)))
455
- };
456
- }
457
-
458
605
  //
459
606
  // Object
460
607
  // ======
461
608
  //
462
609
 
463
-
464
610
  // ES5 15.2.3.14
465
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
611
+ // http://es5.github.com/#x15.2.3.14
466
612
  if (!Object.keys) {
467
-
613
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
468
614
  var hasDontEnumBug = true,
469
615
  dontEnums = [
470
616
  "toString",
@@ -477,13 +623,18 @@ if (!Object.keys) {
477
623
  ],
478
624
  dontEnumsLength = dontEnums.length;
479
625
 
480
- for (var key in {"toString": null})
626
+ for (var key in {"toString": null}) {
481
627
  hasDontEnumBug = false;
628
+ }
482
629
 
483
630
  Object.keys = function keys(object) {
484
631
 
485
- if ((typeof object != "object" && typeof object != "function") || object === null)
632
+ if (
633
+ (typeof object != "object" && typeof object != "function") ||
634
+ object === null
635
+ ) {
486
636
  throw new TypeError("Object.keys called on a non-object");
637
+ }
487
638
 
488
639
  var keys = [];
489
640
  for (var name in object) {
@@ -500,7 +651,6 @@ if (!Object.keys) {
500
651
  }
501
652
  }
502
653
  }
503
-
504
654
  return keys;
505
655
  };
506
656
 
@@ -512,58 +662,102 @@ if (!Object.keys) {
512
662
  //
513
663
 
514
664
  // ES5 15.9.5.43
515
- // Format a Date object as a string according to a simplified subset of the ISO 8601
516
- // standard as defined in 15.9.1.15.
517
- if (!Date.prototype.toISOString) {
665
+ // http://es5.github.com/#x15.9.5.43
666
+ // This function returns a String value represent the instance in time
667
+ // represented by this Date object. The format of the String is the Date Time
668
+ // string format defined in 15.9.1.15. All fields are present in the String.
669
+ // The time zone is always UTC, denoted by the suffix Z. If the time value of
670
+ // this object is not a finite Number a RangeError exception is thrown.
671
+ var negativeDate = -62198755200000,
672
+ negativeYearString = "-000001";
673
+ if (
674
+ !Date.prototype.toISOString ||
675
+ (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
676
+ ) {
518
677
  Date.prototype.toISOString = function toISOString() {
519
- var result, length, value;
520
- if (!isFinite(this))
521
- throw new RangeError;
678
+ var result, length, value, year, month;
679
+ if (!isFinite(this)) {
680
+ throw new RangeError("Date.prototype.toISOString called on non-finite value.");
681
+ }
682
+
683
+ year = this.getUTCFullYear();
684
+
685
+ month = this.getUTCMonth();
686
+ // see https://github.com/kriskowal/es5-shim/issues/111
687
+ year += Math.floor(month / 12);
688
+ month = (month % 12 + 12) % 12;
522
689
 
523
690
  // the date time string format is specified in 15.9.1.15.
524
- result = [this.getUTCFullYear(), this.getUTCMonth() + 1, this.getUTCDate(),
691
+ result = [month + 1, this.getUTCDate(),
525
692
  this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
693
+ year = (
694
+ (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
695
+ ("00000" + Math.abs(year))
696
+ .slice(0 <= year && year <= 9999 ? -4 : -6)
697
+ );
526
698
 
527
699
  length = result.length;
528
700
  while (length--) {
529
701
  value = result[length];
530
- // pad months, days, hours, minutes, and seconds to have two digits.
531
- if (value < 10)
702
+ // pad months, days, hours, minutes, and seconds to have two
703
+ // digits.
704
+ if (value < 10) {
532
705
  result[length] = "0" + value;
706
+ }
533
707
  }
534
708
  // pad milliseconds to have three digits.
535
- return result.slice(0, 3).join("-") + "T" + result.slice(3).join(":") + "." +
536
- ("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
537
- }
538
- }
539
-
540
- // ES5 15.9.4.4
541
- if (!Date.now) {
542
- Date.now = function now() {
543
- return new Date().getTime();
709
+ return (
710
+ year + "-" + result.slice(0, 2).join("-") +
711
+ "T" + result.slice(2).join(":") + "." +
712
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
713
+ );
544
714
  };
545
715
  }
546
716
 
717
+
547
718
  // ES5 15.9.5.44
548
- if (!Date.prototype.toJSON) {
719
+ // http://es5.github.com/#x15.9.5.44
720
+ // This function provides a String representation of a Date object for use by
721
+ // JSON.stringify (15.12.3).
722
+ var dateToJSONIsSupported = false;
723
+ try {
724
+ dateToJSONIsSupported = (
725
+ Date.prototype.toJSON &&
726
+ new Date(NaN).toJSON() === null &&
727
+ new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
728
+ Date.prototype.toJSON.call({ // generic
729
+ toISOString: function () {
730
+ return true;
731
+ }
732
+ })
733
+ );
734
+ } catch (e) {
735
+ }
736
+ if (!dateToJSONIsSupported) {
549
737
  Date.prototype.toJSON = function toJSON(key) {
550
- // This function provides a String representation of a Date object for
551
- // use by JSON.stringify (15.12.3). When the toJSON method is called
552
- // with argument key, the following steps are taken:
738
+ // When the toJSON method is called with argument key, the following
739
+ // steps are taken:
553
740
 
554
741
  // 1. Let O be the result of calling ToObject, giving it the this
555
742
  // value as its argument.
556
- // 2. Let tv be ToPrimitive(O, hint Number).
743
+ // 2. Let tv be toPrimitive(O, hint Number).
744
+ var o = Object(this),
745
+ tv = toPrimitive(o),
746
+ toISO;
557
747
  // 3. If tv is a Number and is not finite, return null.
558
- // XXX
748
+ if (typeof tv === "number" && !isFinite(tv)) {
749
+ return null;
750
+ }
559
751
  // 4. Let toISO be the result of calling the [[Get]] internal method of
560
752
  // O with argument "toISOString".
753
+ toISO = o.toISOString;
561
754
  // 5. If IsCallable(toISO) is false, throw a TypeError exception.
562
- if (typeof this.toISOString != "function")
563
- throw new TypeError(); // TODO message
755
+ if (typeof toISO != "function") {
756
+ throw new TypeError("toISOString property is not callable");
757
+ }
564
758
  // 6. Return the result of calling the [[Call]] internal method of
565
- // toISO with O as the this value and an empty argument list.
566
- return this.toISOString();
759
+ // toISO with O as the this value and an empty argument list.
760
+ return toISO.call(o);
567
761
 
568
762
  // NOTE 1 The argument is ignored.
569
763
 
@@ -576,90 +770,540 @@ if (!Date.prototype.toJSON) {
576
770
  };
577
771
  }
578
772
 
773
+ // ES5 15.9.4.2
774
+ // http://es5.github.com/#x15.9.4.2
775
+ // based on work shared by Daniel Friesen (dantman)
776
+ // http://gist.github.com/303249
777
+ if (!Date.parse || "Date.parse is buggy") {
778
+ // XXX global assignment won't work in embeddings that use
779
+ // an alternate object for the context.
780
+ Date = (function(NativeDate) {
781
+
782
+ // Date.length === 7
783
+ function Date(Y, M, D, h, m, s, ms) {
784
+ var length = arguments.length;
785
+ if (this instanceof NativeDate) {
786
+ var date = length == 1 && String(Y) === Y ? // isString(Y)
787
+ // We explicitly pass it through parse:
788
+ new NativeDate(Date.parse(Y)) :
789
+ // We have to manually make calls depending on argument
790
+ // length here
791
+ length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
792
+ length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
793
+ length >= 5 ? new NativeDate(Y, M, D, h, m) :
794
+ length >= 4 ? new NativeDate(Y, M, D, h) :
795
+ length >= 3 ? new NativeDate(Y, M, D) :
796
+ length >= 2 ? new NativeDate(Y, M) :
797
+ length >= 1 ? new NativeDate(Y) :
798
+ new NativeDate();
799
+ // Prevent mixups with unfixed Date object
800
+ date.constructor = Date;
801
+ return date;
802
+ }
803
+ return NativeDate.apply(this, arguments);
804
+ };
805
+
806
+ // 15.9.1.15 Date Time String Format.
807
+ var isoDateExpression = new RegExp("^" +
808
+ "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
809
+ // 6-digit extended year
810
+ "(?:-(\\d{2})" + // optional month capture
811
+ "(?:-(\\d{2})" + // optional day capture
812
+ "(?:" + // capture hours:minutes:seconds.milliseconds
813
+ "T(\\d{2})" + // hours capture
814
+ ":(\\d{2})" + // minutes capture
815
+ "(?:" + // optional :seconds.milliseconds
816
+ ":(\\d{2})" + // seconds capture
817
+ "(?:(\\.\\d{1,}))?" + // milliseconds capture
818
+ ")?" +
819
+ "(" + // capture UTC offset component
820
+ "Z|" + // UTC capture
821
+ "(?:" + // offset specifier +/-hours:minutes
822
+ "([-+])" + // sign capture
823
+ "(\\d{2})" + // hours offset capture
824
+ ":(\\d{2})" + // minutes offset capture
825
+ ")" +
826
+ ")?)?)?)?" +
827
+ "$");
828
+
829
+ var months = [
830
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
831
+ ];
832
+
833
+ function dayFromMonth(year, month) {
834
+ var t = month > 1 ? 1 : 0;
835
+ return (
836
+ months[month] +
837
+ Math.floor((year - 1969 + t) / 4) -
838
+ Math.floor((year - 1901 + t) / 100) +
839
+ Math.floor((year - 1601 + t) / 400) +
840
+ 365 * (year - 1970)
841
+ );
842
+ }
843
+
844
+ // Copy any custom methods a 3rd party library may have added
845
+ for (var key in NativeDate) {
846
+ Date[key] = NativeDate[key];
847
+ }
848
+
849
+ // Copy "native" methods explicitly; they may be non-enumerable
850
+ Date.now = NativeDate.now;
851
+ Date.UTC = NativeDate.UTC;
852
+ Date.prototype = NativeDate.prototype;
853
+ Date.prototype.constructor = Date;
854
+
855
+ // Upgrade Date.parse to handle simplified ISO 8601 strings
856
+ Date.parse = function parse(string) {
857
+ var match = isoDateExpression.exec(string);
858
+ if (match) {
859
+ // parse months, days, hours, minutes, seconds, and milliseconds
860
+ // provide default values if necessary
861
+ // parse the UTC offset component
862
+ var year = Number(match[1]),
863
+ month = Number(match[2] || 1) - 1,
864
+ day = Number(match[3] || 1) - 1,
865
+ hour = Number(match[4] || 0),
866
+ minute = Number(match[5] || 0),
867
+ second = Number(match[6] || 0),
868
+ millisecond = Math.floor(Number(match[7] || 0) * 1000),
869
+ // When time zone is missed, local offset should be used
870
+ // (ES 5.1 bug)
871
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=112
872
+ offset = !match[4] || match[8] ?
873
+ 0 : Number(new NativeDate(1970, 0)),
874
+ signOffset = match[9] === "-" ? 1 : -1,
875
+ hourOffset = Number(match[10] || 0),
876
+ minuteOffset = Number(match[11] || 0),
877
+ result;
878
+ if (
879
+ hour < (
880
+ minute > 0 || second > 0 || millisecond > 0 ?
881
+ 24 : 25
882
+ ) &&
883
+ minute < 60 && second < 60 && millisecond < 1000 &&
884
+ month > -1 && month < 12 && hourOffset < 24 &&
885
+ minuteOffset < 60 && // detect invalid offsets
886
+ day > -1 &&
887
+ day < (
888
+ dayFromMonth(year, month + 1) -
889
+ dayFromMonth(year, month)
890
+ )
891
+ ) {
892
+ result = (
893
+ (dayFromMonth(year, month) + day) * 24 +
894
+ hour +
895
+ hourOffset * signOffset
896
+ ) * 60;
897
+ result = (
898
+ (result + minute + minuteOffset * signOffset) * 60 +
899
+ second
900
+ ) * 1000 + millisecond + offset;
901
+ if (-8.64e15 <= result && result <= 8.64e15) {
902
+ return result;
903
+ }
904
+ }
905
+ return NaN;
906
+ }
907
+ return NativeDate.parse.apply(this, arguments);
908
+ };
909
+
910
+ return Date;
911
+ })(Date);
912
+ }
913
+
914
+ // ES5 15.9.4.4
915
+ // http://es5.github.com/#x15.9.4.4
916
+ if (!Date.now) {
917
+ Date.now = function now() {
918
+ return new Date().getTime();
919
+ };
920
+ }
921
+
579
922
 
580
923
  //
581
- // String
924
+ // Number
582
925
  // ======
583
926
  //
584
927
 
585
- // ES5 15.5.4.20
586
- var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
587
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
588
- "\u2029\uFEFF";
589
- if (!String.prototype.trim || ws.trim()) {
590
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
591
- // http://perfectionkills.com/whitespace-deviations/
592
- ws = "[" + ws + "]";
593
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
594
- trimEndRegexp = new RegExp(ws + ws + "*$");
595
- String.prototype.trim = function trim() {
596
- return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
597
- };
928
+ // ES5.1 15.7.4.5
929
+ // http://es5.github.com/#x15.7.4.5
930
+ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' || (1000000000000000128).toFixed(0) !== "1000000000000000128") {
931
+ // Hide these variables and functions
932
+ (function () {
933
+ var base, size, data, i;
934
+
935
+ base = 1e7;
936
+ size = 6;
937
+ data = [0, 0, 0, 0, 0, 0];
938
+
939
+ function multiply(n, c) {
940
+ var i = -1;
941
+ while (++i < size) {
942
+ c += n * data[i];
943
+ data[i] = c % base;
944
+ c = Math.floor(c / base);
945
+ }
946
+ }
947
+
948
+ function divide(n) {
949
+ var i = size, c = 0;
950
+ while (--i >= 0) {
951
+ c += data[i];
952
+ data[i] = Math.floor(c / n);
953
+ c = (c % n) * base;
954
+ }
955
+ }
956
+
957
+ function toString() {
958
+ var i = size;
959
+ var s = '';
960
+ while (--i >= 0) {
961
+ if (s !== '' || i === 0 || data[i] !== 0) {
962
+ var t = String(data[i]);
963
+ if (s === '') {
964
+ s = t;
965
+ } else {
966
+ s += '0000000'.slice(0, 7 - t.length) + t;
967
+ }
968
+ }
969
+ }
970
+ return s;
971
+ }
972
+
973
+ function pow(x, n, acc) {
974
+ return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
975
+ }
976
+
977
+ function log(x) {
978
+ var n = 0;
979
+ while (x >= 4096) {
980
+ n += 12;
981
+ x /= 4096;
982
+ }
983
+ while (x >= 2) {
984
+ n += 1;
985
+ x /= 2;
986
+ }
987
+ return n;
988
+ }
989
+
990
+ Number.prototype.toFixed = function (fractionDigits) {
991
+ var f, x, s, m, e, z, j, k;
992
+
993
+ // Test for NaN and round fractionDigits down
994
+ f = Number(fractionDigits);
995
+ f = f !== f ? 0 : Math.floor(f);
996
+
997
+ if (f < 0 || f > 20) {
998
+ throw new RangeError("Number.toFixed called with invalid number of decimals");
999
+ }
1000
+
1001
+ x = Number(this);
1002
+
1003
+ // Test for NaN
1004
+ if (x !== x) {
1005
+ return "NaN";
1006
+ }
1007
+
1008
+ // If it is too big or small, return the string value of the number
1009
+ if (x <= -1e21 || x >= 1e21) {
1010
+ return String(x);
1011
+ }
1012
+
1013
+ s = "";
1014
+
1015
+ if (x < 0) {
1016
+ s = "-";
1017
+ x = -x;
1018
+ }
1019
+
1020
+ m = "0";
1021
+
1022
+ if (x > 1e-21) {
1023
+ // 1e-21 < x < 1e21
1024
+ // -70 < log2(x) < 70
1025
+ e = log(x * pow(2, 69, 1)) - 69;
1026
+ z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1027
+ z *= 0x10000000000000; // Math.pow(2, 52);
1028
+ e = 52 - e;
1029
+
1030
+ // -18 < e < 122
1031
+ // x = z / 2 ^ e
1032
+ if (e > 0) {
1033
+ multiply(0, z);
1034
+ j = f;
1035
+
1036
+ while (j >= 7) {
1037
+ multiply(1e7, 0);
1038
+ j -= 7;
1039
+ }
1040
+
1041
+ multiply(pow(10, j, 1), 0);
1042
+ j = e - 1;
1043
+
1044
+ while (j >= 23) {
1045
+ divide(1 << 23);
1046
+ j -= 23;
1047
+ }
1048
+
1049
+ divide(1 << j);
1050
+ multiply(1, 1);
1051
+ divide(2);
1052
+ m = toString();
1053
+ } else {
1054
+ multiply(0, z);
1055
+ multiply(1 << (-e), 0);
1056
+ m = toString() + '0.00000000000000000000'.slice(2, 2 + f);
1057
+ }
1058
+ }
1059
+
1060
+ if (f > 0) {
1061
+ k = m.length;
1062
+
1063
+ if (k <= f) {
1064
+ m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1065
+ } else {
1066
+ m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1067
+ }
1068
+ } else {
1069
+ m = s + m;
1070
+ }
1071
+
1072
+ return m;
1073
+ }
1074
+ }());
598
1075
  }
599
1076
 
1077
+
1078
+ //
1079
+ // String
1080
+ // ======
1081
+ //
1082
+
1083
+
600
1084
  // ES5 15.5.4.14
601
1085
  // http://es5.github.com/#x15.5.4.14
1086
+
1087
+ // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
1088
+ // Many browsers do not split properly with regular expressions or they
1089
+ // do not perform the split correctly under obscure conditions.
1090
+ // See http://blog.stevenlevithan.com/archives/cross-browser-split
1091
+ // I've tested in many browsers and this seems to cover the deviant ones:
1092
+ // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1093
+ // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1094
+ // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1095
+ // [undefined, "t", undefined, "e", ...]
1096
+ // ''.split(/.?/) should be [], not [""]
1097
+ // '.'.split(/()()/) should be ["."], not ["", "", "."]
1098
+
1099
+ var string_split = String.prototype.split;
1100
+ if (
1101
+ 'ab'.split(/(?:ab)*/).length !== 2 ||
1102
+ '.'.split(/(.?)(.?)/).length !== 4 ||
1103
+ 'tesst'.split(/(s)*/)[1] === "t" ||
1104
+ ''.split(/.?/).length === 0 ||
1105
+ '.'.split(/()()/).length > 1
1106
+ ) {
1107
+ (function () {
1108
+ var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1109
+
1110
+ String.prototype.split = function (separator, limit) {
1111
+ var string = this;
1112
+ if (separator === void 0 && limit === 0)
1113
+ return [];
1114
+
1115
+ // If `separator` is not a regex, use native split
1116
+ if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
1117
+ return string_split.apply(this, arguments);
1118
+ }
1119
+
1120
+ var output = [],
1121
+ flags = (separator.ignoreCase ? "i" : "") +
1122
+ (separator.multiline ? "m" : "") +
1123
+ (separator.extended ? "x" : "") + // Proposed for ES6
1124
+ (separator.sticky ? "y" : ""), // Firefox 3+
1125
+ lastLastIndex = 0,
1126
+ // Make `global` and avoid `lastIndex` issues by working with a copy
1127
+ separator = new RegExp(separator.source, flags + "g"),
1128
+ separator2, match, lastIndex, lastLength;
1129
+ string += ""; // Type-convert
1130
+ if (!compliantExecNpcg) {
1131
+ // Doesn't need flags gy, but they don't hurt
1132
+ separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1133
+ }
1134
+ /* Values for `limit`, per the spec:
1135
+ * If undefined: 4294967295 // Math.pow(2, 32) - 1
1136
+ * If 0, Infinity, or NaN: 0
1137
+ * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1138
+ * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1139
+ * If other: Type-convert, then use the above rules
1140
+ */
1141
+ limit = limit === void 0 ?
1142
+ -1 >>> 0 : // Math.pow(2, 32) - 1
1143
+ limit >>> 0; // ToUint32(limit)
1144
+ while (match = separator.exec(string)) {
1145
+ // `separator.lastIndex` is not reliable cross-browser
1146
+ lastIndex = match.index + match[0].length;
1147
+ if (lastIndex > lastLastIndex) {
1148
+ output.push(string.slice(lastLastIndex, match.index));
1149
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
1150
+ // nonparticipating capturing groups
1151
+ if (!compliantExecNpcg && match.length > 1) {
1152
+ match[0].replace(separator2, function () {
1153
+ for (var i = 1; i < arguments.length - 2; i++) {
1154
+ if (arguments[i] === void 0) {
1155
+ match[i] = void 0;
1156
+ }
1157
+ }
1158
+ });
1159
+ }
1160
+ if (match.length > 1 && match.index < string.length) {
1161
+ Array.prototype.push.apply(output, match.slice(1));
1162
+ }
1163
+ lastLength = match[0].length;
1164
+ lastLastIndex = lastIndex;
1165
+ if (output.length >= limit) {
1166
+ break;
1167
+ }
1168
+ }
1169
+ if (separator.lastIndex === match.index) {
1170
+ separator.lastIndex++; // Avoid an infinite loop
1171
+ }
1172
+ }
1173
+ if (lastLastIndex === string.length) {
1174
+ if (lastLength || !separator.test("")) {
1175
+ output.push("");
1176
+ }
1177
+ } else {
1178
+ output.push(string.slice(lastLastIndex));
1179
+ }
1180
+ return output.length > limit ? output.slice(0, limit) : output;
1181
+ };
1182
+ }());
1183
+
602
1184
  // [bugfix, chrome]
603
- // 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.
1185
+ // If separator is undefined, then the result array contains just one String,
1186
+ // which is the this value (converted to a String). If limit is not undefined,
1187
+ // then the output array is truncated so that it contains no more than limit
1188
+ // elements.
604
1189
  // "0".split(undefined, 0) -> []
605
- if("0".split(void 0, 0).length) {
606
- var oldSplit = String.prototype.split;
1190
+ } else if ("0".split(void 0, 0).length) {
607
1191
  String.prototype.split = function(separator, limit) {
608
- if(separator === void 0 && limit === 0)return [];
609
- return oldSplit.apply(this, arguments);
1192
+ if (separator === void 0 && limit === 0) return [];
1193
+ return string_split.apply(this, arguments);
610
1194
  }
611
1195
  }
612
1196
 
1197
+
613
1198
  // ECMA-262, 3rd B.2.3
614
- // Note an ECMAScript standart, although ECMAScript 3rd Edition has a non-normative section suggesting uniform semantics
615
- // and it should be normalized across all browsers
1199
+ // Note an ECMAScript standart, although ECMAScript 3rd Edition has a
1200
+ // non-normative section suggesting uniform semantics and it should be
1201
+ // normalized across all browsers
616
1202
  // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
617
1203
  if("".substr && "0b".substr(-1) !== "b") {
618
- var oldSubstr = String.prototype.substr;
1204
+ var string_substr = String.prototype.substr;
619
1205
  /**
620
- * Get the substring of a string
621
- * @param {integer} start where to start the substring
622
- * @param {integer} length how many characters to return
623
- * @return {string}
624
- */
1206
+ * Get the substring of a string
1207
+ * @param {integer} start where to start the substring
1208
+ * @param {integer} length how many characters to return
1209
+ * @return {string}
1210
+ */
625
1211
  String.prototype.substr = function(start, length) {
626
- return oldSubstr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);
1212
+ return string_substr.call(
1213
+ this,
1214
+ start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1215
+ length
1216
+ );
627
1217
  }
628
1218
  }
629
1219
 
1220
+ // ES5 15.5.4.20
1221
+ // http://es5.github.com/#x15.5.4.20
1222
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1223
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1224
+ "\u2029\uFEFF";
1225
+ if (!String.prototype.trim || ws.trim()) {
1226
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1227
+ // http://perfectionkills.com/whitespace-deviations/
1228
+ ws = "[" + ws + "]";
1229
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1230
+ trimEndRegexp = new RegExp(ws + ws + "*$");
1231
+ String.prototype.trim = function trim() {
1232
+ if (this === void 0 || this === null) {
1233
+ throw new TypeError("can't convert "+this+" to object");
1234
+ }
1235
+ return String(this)
1236
+ .replace(trimBeginRegexp, "")
1237
+ .replace(trimEndRegexp, "");
1238
+ };
1239
+ }
1240
+
630
1241
  //
631
1242
  // Util
632
1243
  // ======
633
1244
  //
634
1245
 
1246
+ // ES5 9.4
1247
+ // http://es5.github.com/#x9.4
635
1248
  // http://jsperf.com/to-integer
636
- var toInteger = function (n) {
1249
+
1250
+ function toInteger(n) {
637
1251
  n = +n;
638
- if (n !== n) // isNaN
639
- n = -1;
640
- else if (n !== 0 && n !== (1/0) && n !== -(1/0))
1252
+ if (n !== n) { // isNaN
1253
+ n = 0;
1254
+ } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
641
1255
  n = (n > 0 || -1) * Math.floor(Math.abs(n));
1256
+ }
642
1257
  return n;
643
- };
1258
+ }
644
1259
 
645
- var prepareString = "a"[0] != "a",
646
- // ES5 9.9
647
- toObject = function (o) {
648
- if (o == null) { // this matches both null and undefined
649
- throw new TypeError(); // TODO message
1260
+ function isPrimitive(input) {
1261
+ var type = typeof input;
1262
+ return (
1263
+ input === null ||
1264
+ type === "undefined" ||
1265
+ type === "boolean" ||
1266
+ type === "number" ||
1267
+ type === "string"
1268
+ );
1269
+ }
1270
+
1271
+ function toPrimitive(input) {
1272
+ var val, valueOf, toString;
1273
+ if (isPrimitive(input)) {
1274
+ return input;
1275
+ }
1276
+ valueOf = input.valueOf;
1277
+ if (typeof valueOf === "function") {
1278
+ val = valueOf.call(input);
1279
+ if (isPrimitive(val)) {
1280
+ return val;
650
1281
  }
651
- // If the implementation doesn't support by-index access of
652
- // string characters (ex. IE < 7), split the string
653
- if (prepareString && typeof o == "string" && o) {
654
- return o.split("");
1282
+ }
1283
+ toString = input.toString;
1284
+ if (typeof toString === "function") {
1285
+ val = toString.call(input);
1286
+ if (isPrimitive(val)) {
1287
+ return val;
655
1288
  }
656
- return Object(o);
657
- };
1289
+ }
1290
+ throw new TypeError();
1291
+ }
1292
+
1293
+ // ES5 9.9
1294
+ // http://es5.github.com/#x9.9
1295
+ var toObject = function (o) {
1296
+ if (o == null) { // this matches both null and undefined
1297
+ throw new TypeError("can't convert "+o+" to object");
1298
+ }
1299
+ return Object(o);
1300
+ };
658
1301
 
659
1302
  })();
660
1303
 
661
1304
 
662
1305
 
1306
+
663
1307
  (function($, shims){
664
1308
  var defineProperty = 'defineProperty';
665
1309
  var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
@@ -813,8 +1457,8 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
813
1457
  webshims.error("IE browser modes are busted in IE10+. Please test your HTML/CSS/JS with a real IE version or at least IETester or similiar tools");
814
1458
  }
815
1459
 
816
- if(!$.parseHTML){
817
- webshims.error("Webshims needs jQuery 1.8+ to work properly. Please update your jQuery version or downgrade webshims.");
1460
+ if('debug' in webshims){
1461
+ webshims.error('Use webshims.setOptions("debug", true||false||"noCombo"); to debug flag');
818
1462
  }
819
1463
 
820
1464
  if (!webshims.cfg.no$Switch) {
@@ -850,7 +1494,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
850
1494
  // '127.0.0.1': 1
851
1495
  // };
852
1496
  //
853
- // if( webshims.debug && (hostNames[location.hostname] || location.protocol == 'file:') ){
1497
+ // if( webshims.cfg.debug && (hostNames[location.hostname] || location.protocol == 'file:') ){
854
1498
  // var list = $('<ul class="webshims-debug-list" />');
855
1499
  // webshims.errorLog.push = function(message){
856
1500
  // list.appendTo('body');
@@ -1282,7 +1926,6 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1282
1926
  };
1283
1927
 
1284
1928
  $.extend(webshims, {
1285
-
1286
1929
  getID: (function(){
1287
1930
  var ID = new Date().getTime();
1288
1931
  return function(elem){
@@ -1312,6 +1955,51 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1312
1955
  }
1313
1956
  });
1314
1957
  },
1958
+ getOptions: (function(){
1959
+ var regs = {};
1960
+ var regFn = function(f, upper){
1961
+ return upper.toLowerCase();
1962
+ };
1963
+ return function(elem, name, bases){
1964
+ var data = elementData(elem, 'cfg'+name);
1965
+ var dataName;
1966
+ var cfg = {};
1967
+
1968
+ if(data){
1969
+ return data;
1970
+ }
1971
+ data = $(elem).data();
1972
+
1973
+ if(!bases){
1974
+ bases = [true, {}];
1975
+ } else if(!Array.isArray(bases)){
1976
+ bases = [true, {}, bases];
1977
+ } else {
1978
+ bases.unshift(true, {});
1979
+ }
1980
+
1981
+ if(data && data[name]){
1982
+ if(typeof data[name] == 'object'){
1983
+ bases.push(data[name]);
1984
+ } else {
1985
+ webshims.error('data-'+ name +' attribute has to be a valid JSON, was: '+ data[name]);
1986
+ }
1987
+ }
1988
+
1989
+ if(!regs[name]){
1990
+ regs[name] = new RegExp('^'+ name +'([A-Z])');
1991
+ }
1992
+
1993
+ for(dataName in data){
1994
+ if(regs[name].test(dataName)){
1995
+ cfg[dataName.replace(regs[name], regFn)] = data[dataName];
1996
+ }
1997
+ }
1998
+ bases.push(cfg);
1999
+
2000
+ return elementData(elem, 'cfg'+name, $.extend.apply($, bases));
2001
+ };
2002
+ })(),
1315
2003
  //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
1316
2004
  createPropDefault: createPropDefault,
1317
2005
  data: elementData,
@@ -1399,7 +2087,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1399
2087
  setInterval(this.test, 600);
1400
2088
  $(this.test);
1401
2089
  webshims.ready('WINDOWLOAD', this.test);
1402
- $(document).on('updatelayout', this.handler);
2090
+ $(document).on('updatelayout pageinit collapsibleexpand shown.bs.modal shown.bs.collapse slid.bs.carousel', this.handler);
1403
2091
  $(window).on('resize', this.handler);
1404
2092
  (function(){
1405
2093
  var oldAnimate = $.fn.animate;
@@ -1757,109 +2445,67 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1757
2445
  }
1758
2446
  },
1759
2447
 
1760
- // set current Lang:
1761
- // - webshims.activeLang(lang:string);
1762
- // get current lang
1763
- // - webshims.activeLang();
1764
- // get current lang
1765
- // webshims.activeLang({
1766
- // register: moduleName:string,
1767
- // callback: callback:function
1768
- // });
1769
- // get/set including remoteLang
1770
- // - webshims.activeLang({
1771
- // module: moduleName:string,
1772
- // callback: callback:function,
1773
- // langObj: languageObj:array/object
1774
- // });
1775
2448
  activeLang: (function(){
1776
- var callbacks = [];
1777
- var registeredCallbacks = {};
1778
- var currentLang;
1779
- var shortLang;
1780
- var notLocal = /:\/\/|^\.*\//;
1781
- var loadRemoteLang = function(data, lang, options){
1782
- var langSrc;
1783
- if(lang && options && $.inArray(lang, options.availableLangs || options.availabeLangs || []) !== -1){
1784
- data.loading = true;
1785
- langSrc = options.langSrc;
1786
- if(!notLocal.test(langSrc)){
1787
- langSrc = webshims.cfg.basePath+langSrc;
1788
- }
1789
- webshims.loader.loadScript(langSrc+lang+'.js', function(){
1790
- if(data.langObj[lang]){
1791
- data.loading = false;
1792
- callLang(data, true);
1793
- } else {
1794
- $(function(){
1795
- if(data.langObj[lang]){
1796
- callLang(data, true);
1797
- }
1798
- data.loading = false;
2449
+ var curLang = [];
2450
+ var langDatas = [];
2451
+ var loading = {};
2452
+ var load = function(src, obj, loadingLang){
2453
+ obj._isLoading = true;
2454
+ if(loading[src]){
2455
+ loading[src].push(obj);
2456
+ } else {
2457
+ loading[src] = [obj];
2458
+ webshims.loader.loadScript(src, function(){
2459
+ if(loadingLang == curLang.join()){
2460
+ $.each(loading[src], function(i, obj){
2461
+ select(obj);
1799
2462
  });
1800
2463
  }
2464
+ delete loading[src];
1801
2465
  });
1802
- return true;
1803
2466
  }
1804
- return false;
1805
2467
  };
1806
- var callRegister = function(module){
1807
- if(registeredCallbacks[module]){
1808
- registeredCallbacks[module].forEach(function(data){
1809
- data.callback(currentLang, shortLang, '');
1810
- });
1811
- }
1812
- };
1813
- var callLang = function(data, _noLoop){
1814
- if(data.activeLang != currentLang && data.activeLang !== shortLang){
1815
- var options = modules[data.module].options;
1816
- if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
1817
- data.activeLang = currentLang;
1818
- data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
1819
- callRegister(data.module);
1820
- } else if( !_noLoop &&
1821
- !loadRemoteLang(data, currentLang, options) &&
1822
- !loadRemoteLang(data, shortLang, options) &&
1823
- data.langObj[''] && data.activeLang !== '' ) {
1824
- data.activeLang = '';
1825
- data.callback(data.langObj[''], currentLang);
1826
- callRegister(data.module);
2468
+ var select = function(obj){
2469
+ var oldLang = obj.__active;
2470
+ var selectLang = function(i, lang){
2471
+ obj._isLoading = false;
2472
+ if(obj[lang] || obj.availableLangs.indexOf(lang) != -1){
2473
+ if(obj[lang]){
2474
+ obj.__active = obj[lang];
2475
+ } else {
2476
+ load(obj.langSrc+lang, obj, curLang.join());
2477
+ }
2478
+ return false;
1827
2479
  }
2480
+ };
2481
+ $.each(curLang, selectLang);
2482
+ if(!obj.__active){
2483
+ obj.__active = obj[''];
2484
+ }
2485
+ if(oldLang != obj.__active){
2486
+ $(obj).trigger('change');
1828
2487
  }
1829
2488
  };
1830
-
1831
-
1832
- var activeLang = function(lang){
1833
-
1834
- if(typeof lang == 'string' && lang !== currentLang){
1835
- currentLang = lang;
1836
- shortLang = currentLang.split('-')[0];
1837
- if(currentLang == shortLang){
1838
- shortLang = false;
2489
+ return function(lang){
2490
+ var shortLang;
2491
+ if(typeof lang == 'string'){
2492
+ if(curLang[0] != lang){
2493
+ curLang = [lang];
2494
+ shortLang = curLang[0].split('-')[0];
2495
+ if(shortLang && shortLang != lang){
2496
+ curLang.push(shortLang);
2497
+ }
2498
+ langDatas.forEach(select);
1839
2499
  }
1840
- $.each(callbacks, function(i, data){
1841
- callLang(data);
1842
- });
1843
2500
  } else if(typeof lang == 'object'){
1844
-
1845
- if(lang.register){
1846
- if(!registeredCallbacks[lang.register]){
1847
- registeredCallbacks[lang.register] = [];
1848
- }
1849
- registeredCallbacks[lang.register].push(lang);
1850
- lang.callback(currentLang, shortLang, '');
1851
- } else {
1852
- if(!lang.activeLang){
1853
- lang.activeLang = '';
1854
- }
1855
- callbacks.push(lang);
1856
- callLang(lang);
2501
+ if(!lang.__active){
2502
+ langDatas.push(lang);
2503
+ select(lang);
1857
2504
  }
2505
+ return lang.__active;
1858
2506
  }
1859
- return currentLang;
2507
+ return curLang[0];
1860
2508
  };
1861
-
1862
- return activeLang;
1863
2509
  })()
1864
2510
  });
1865
2511
 
@@ -1985,7 +2631,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1985
2631
  var switchOptions = function(e){
1986
2632
  var media, error, parent;
1987
2633
  if(!options.preferFlash &&
1988
- ($(e.target).is('audio, video') || ((parent = e.target.parentNode) && $('source:last', parent)[0] == e.target)) &&
2634
+ ($(e.target).is('audio, video') || ((parent = e.target.parentNode) && $('source', parent).last()[0] == e.target)) &&
1989
2635
  (media = $(e.target).closest('audio, video')) && (error = media.prop('error')) && !noSwitch[error.code]
1990
2636
  ){
1991
2637
 
@@ -2493,6 +3139,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
2493
3139
  if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
2494
3140
  supLoad.prop._supvalue.apply(this, arguments);
2495
3141
  }
3142
+ $(this).triggerHandler('wsmediareload');
2496
3143
  }
2497
3144
  }
2498
3145
  });
@@ -3089,9 +3736,9 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3089
3736
  })();
3090
3737
 
3091
3738
 
3092
- var transformDimension = (function(){
3739
+ var getComputedDimension = (function(){
3093
3740
  var dimCache = {};
3094
- var getRealDims = function(data){
3741
+ var getVideoDims = function(data){
3095
3742
  var ret, poster, img;
3096
3743
  if(dimCache[data.currentSrc]){
3097
3744
  ret = dimCache[data.currentSrc];
@@ -3116,54 +3763,102 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3116
3763
  } else {
3117
3764
  delete dimCache[poster];
3118
3765
  }
3766
+ img.onload = null;
3119
3767
  };
3120
3768
  img.src = poster;
3121
- if(img.complete){
3769
+ if(img.complete && img.onload){
3122
3770
  img.onload();
3123
3771
  }
3124
3772
  }
3125
3773
  }
3126
3774
  return ret || {width: 300, height: data._elemNodeName == 'video' ? 150 : 50};
3127
3775
  };
3128
- return function(data){
3129
- var realDims, ratio;
3130
- var ret = data.elemDimensions;
3776
+
3777
+ var getCssStyle = function(elem, style){
3778
+ return elem.style[style] || (elem.currentStyle && elem.currentStyle[style]) || (window.getComputedStyle && (window.getComputedStyle( elem, null ) || {} )[style]) || '';
3779
+ };
3780
+ var minMaxProps = ['minWidth', 'maxWidth', 'minHeight', 'maxHeight'];
3781
+
3782
+ var addMinMax = function(elem, ret){
3783
+ var i, prop;
3784
+ var hasMinMax = false;
3785
+ for (i = 0; i < 4; i++) {
3786
+ prop = getCssStyle(elem, minMaxProps[i]);
3787
+ if(parseFloat(prop, 10)){
3788
+ hasMinMax = true;
3789
+ ret[minMaxProps[i]] = prop;
3790
+ }
3791
+ }
3792
+ return hasMinMax;
3793
+ };
3794
+ var retFn = function(data){
3795
+ var videoDims, ratio, hasMinMax;
3796
+ var elem = data._elem;
3797
+ var autos = {
3798
+ width: getCssStyle(elem, 'width') == 'auto',
3799
+ height: getCssStyle(elem, 'height') == 'auto'
3800
+ };
3801
+ var ret = {
3802
+ width: !autos.width && $(elem).width(),
3803
+ height: !autos.height && $(elem).height()
3804
+ };
3131
3805
 
3132
- if(ret.width == 'auto' || ret.height == 'auto'){
3133
- ret = $.extend({}, data.elemDimensions);
3134
- realDims = getRealDims(data);
3135
- ratio = realDims.width / realDims.height;
3806
+ if(autos.width || autos.height){
3807
+ videoDims = getVideoDims(data);
3808
+ ratio = videoDims.width / videoDims.height;
3136
3809
 
3137
- if(ret.width == 'auto' && ret.height == 'auto'){
3138
- ret = realDims;
3139
- } else if(ret.width == 'auto'){
3140
- data.shadowElem.css({height: ret.height});
3141
- ret.width = data.shadowElem.height() * ratio;
3142
- } else {
3143
- data.shadowElem.css({width: ret.width});
3144
- ret.height = data.shadowElem.width() / ratio;
3810
+ if(autos.width && autos.height){
3811
+ ret.width = videoDims.width;
3812
+ ret.height = videoDims.height;
3813
+ } else if(autos.width){
3814
+ ret.width = ret.height * ratio;
3815
+ } else if(autos.height){
3816
+ ret.height = ret.width / ratio;
3817
+ }
3818
+
3819
+ if(addMinMax(elem, ret)){
3820
+ data.shadowElem.css(ret);
3821
+ if(autos.width){
3822
+ ret.width = data.shadowElem.height() * ratio;
3823
+ }
3824
+ if(autos.height){
3825
+ ret.height = ((autos.width) ? ret.width : data.shadowElem.width()) / ratio;
3826
+ }
3827
+ if(autos.width && autos.height){
3828
+ data.shadowElem.css(ret);
3829
+ ret.height = data.shadowElem.width() / ratio;
3830
+ ret.width = ret.height * ratio;
3831
+
3832
+ data.shadowElem.css(ret);
3833
+ ret.width = data.shadowElem.height() * ratio;
3834
+ ret.height = ret.width / ratio;
3835
+
3836
+ }
3837
+ if(!Modernizr.video){
3838
+ ret.width = data.shadowElem.width();
3839
+ ret.height = data.shadowElem.height();
3840
+ }
3145
3841
  }
3146
3842
  }
3147
3843
  return ret;
3148
3844
  };
3845
+
3846
+ return retFn;
3149
3847
  })();
3848
+
3150
3849
  var setElementDimension = function(data, hasControls){
3151
3850
  var dims;
3152
- var elem = data._elem;
3851
+
3153
3852
  var box = data.shadowElem;
3154
- $(elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
3853
+ $(data._elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
3155
3854
 
3156
- if(data.isActive == 'third'){
3855
+ if(data.isActive == 'third' || data.activating == 'third'){
3157
3856
  if(data._elemNodeName == 'audio' && !hasControls){
3158
3857
  box.css({width: 0, height: 0});
3159
3858
  } else {
3160
- data.elemDimensions = {
3161
- width: elem.style.width || $.attr(elem, 'width') || $(elem).width(),
3162
- height: elem.style.height || $.attr(elem, 'height') || $(elem).height()
3163
- };
3164
- dims = transformDimension(data);
3165
- dims.minWidth = elem.style.minWidth;
3166
- dims.minHeight = elem.style.minHeight;
3859
+ data._elem.style.display = '';
3860
+ dims = getComputedDimension(data);
3861
+ data._elem.style.display = 'none';
3167
3862
  box.css(dims);
3168
3863
  }
3169
3864
  }
@@ -3222,6 +3917,8 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3222
3917
  }, 1);
3223
3918
  return;
3224
3919
  }
3920
+
3921
+ var attrStyle = {};
3225
3922
 
3226
3923
  if(loadedSwf < 1){
3227
3924
  loadedSwf = 1;
@@ -3232,7 +3929,8 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3232
3929
  data = webshims.data(elem, 'mediaelement');
3233
3930
  }
3234
3931
 
3235
- if($.attr(elem, 'height') || $.attr(elem, 'width')){
3932
+ if((attrStyle.height = $.attr(elem, 'height') || '') || (attrStyle.width = $.attr(elem, 'width') || '')){
3933
+ $(elem).css(attrStyle);
3236
3934
  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.");
3237
3935
  }
3238
3936
 
@@ -3339,7 +4037,7 @@ webshims.register('mediaelement-jaris', function($, webshims, window, document,
3339
4037
  box.insertBefore(elem);
3340
4038
 
3341
4039
  if(hasNative){
3342
- $.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted'), paused: $.prop(elem, 'paused')});
4040
+ $.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted')});
3343
4041
  }
3344
4042
 
3345
4043
  webshims.addShadowDom(elem, box);