webshims-rails 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/lib/webshims-rails/version.rb +2 -2
  2. data/vendor/assets/javascripts/webshims/extras/custom-validity.js +253 -253
  3. data/vendor/assets/javascripts/webshims/extras/modernizr-custom.js +534 -534
  4. data/vendor/assets/javascripts/webshims/extras/mousepress.js +60 -60
  5. data/vendor/assets/javascripts/webshims/minified/polyfiller.js +1 -1
  6. data/vendor/assets/javascripts/webshims/minified/shims/combos/10.js +1 -1
  7. data/vendor/assets/javascripts/webshims/minified/shims/combos/12.js +1 -1
  8. data/vendor/assets/javascripts/webshims/minified/shims/combos/16.js +1 -1
  9. data/vendor/assets/javascripts/webshims/minified/shims/combos/17.js +1 -1
  10. data/vendor/assets/javascripts/webshims/minified/shims/combos/19.js +1 -1
  11. data/vendor/assets/javascripts/webshims/minified/shims/combos/2.js +1 -1
  12. data/vendor/assets/javascripts/webshims/minified/shims/combos/20.js +1 -1
  13. data/vendor/assets/javascripts/webshims/minified/shims/combos/21.js +1 -1
  14. data/vendor/assets/javascripts/webshims/minified/shims/combos/22.js +1 -1
  15. data/vendor/assets/javascripts/webshims/minified/shims/combos/23.js +1 -1
  16. data/vendor/assets/javascripts/webshims/minified/shims/combos/24.js +1 -1
  17. data/vendor/assets/javascripts/webshims/minified/shims/combos/25.js +1 -1
  18. data/vendor/assets/javascripts/webshims/minified/shims/combos/26.js +1 -1
  19. data/vendor/assets/javascripts/webshims/minified/shims/combos/27.js +1 -1
  20. data/vendor/assets/javascripts/webshims/minified/shims/combos/3.js +1 -1
  21. data/vendor/assets/javascripts/webshims/minified/shims/combos/4.js +1 -1
  22. data/vendor/assets/javascripts/webshims/minified/shims/combos/5.js +1 -1
  23. data/vendor/assets/javascripts/webshims/minified/shims/combos/59.js +1 -1
  24. data/vendor/assets/javascripts/webshims/minified/shims/combos/8.js +1 -1
  25. data/vendor/assets/javascripts/webshims/minified/shims/combos/9.js +1 -1
  26. data/vendor/assets/javascripts/webshims/minified/shims/form-core.js +1 -1
  27. data/vendor/assets/javascripts/webshims/minified/shims/form-message.js +1 -1
  28. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-de.txt +33 -33
  29. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-en.txt +34 -34
  30. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-core.js +1 -1
  31. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-jaris.js +1 -1
  32. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-swf.js +1 -1
  33. data/vendor/assets/javascripts/webshims/minified/shims/swf/JarisFLVPlayer.swf +0 -0
  34. data/vendor/assets/javascripts/webshims/polyfiller.js +1188 -1188
  35. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/README +82 -82
  36. data/vendor/assets/javascripts/webshims/shims/combos/1.js +1752 -1752
  37. data/vendor/assets/javascripts/webshims/shims/combos/10.js +3310 -3311
  38. data/vendor/assets/javascripts/webshims/shims/combos/11.js +1631 -1631
  39. data/vendor/assets/javascripts/webshims/shims/combos/12.js +1695 -1696
  40. data/vendor/assets/javascripts/webshims/shims/combos/13.js +1098 -1098
  41. data/vendor/assets/javascripts/webshims/shims/combos/14.js +477 -477
  42. data/vendor/assets/javascripts/webshims/shims/combos/15.js +317 -317
  43. data/vendor/assets/javascripts/webshims/shims/combos/16.js +2177 -2154
  44. data/vendor/assets/javascripts/webshims/shims/combos/17.js +2354 -2319
  45. data/vendor/assets/javascripts/webshims/shims/combos/18.js +1322 -1322
  46. data/vendor/assets/javascripts/webshims/shims/combos/19.js +2262 -2238
  47. data/vendor/assets/javascripts/webshims/shims/combos/2.js +2376 -2340
  48. data/vendor/assets/javascripts/webshims/shims/combos/20.js +1557 -1558
  49. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1745 -1733
  50. data/vendor/assets/javascripts/webshims/shims/combos/22.js +2360 -2361
  51. data/vendor/assets/javascripts/webshims/shims/combos/23.js +2342 -2331
  52. data/vendor/assets/javascripts/webshims/shims/combos/24.js +2859 -2836
  53. data/vendor/assets/javascripts/webshims/shims/combos/25.js +1547 -1548
  54. data/vendor/assets/javascripts/webshims/shims/combos/26.js +2178 -2155
  55. data/vendor/assets/javascripts/webshims/shims/combos/27.js +3311 -3312
  56. data/vendor/assets/javascripts/webshims/shims/combos/3.js +3058 -3022
  57. data/vendor/assets/javascripts/webshims/shims/combos/4.js +807 -771
  58. data/vendor/assets/javascripts/webshims/shims/combos/5.js +1063 -1027
  59. data/vendor/assets/javascripts/webshims/shims/combos/59.js +1745 -1709
  60. data/vendor/assets/javascripts/webshims/shims/combos/6.js +384 -384
  61. data/vendor/assets/javascripts/webshims/shims/combos/7.js +640 -640
  62. data/vendor/assets/javascripts/webshims/shims/combos/8.js +1546 -1547
  63. data/vendor/assets/javascripts/webshims/shims/combos/9.js +2507 -2508
  64. data/vendor/assets/javascripts/webshims/shims/details.js +148 -148
  65. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +949 -949
  66. data/vendor/assets/javascripts/webshims/shims/es5.js +802 -802
  67. data/vendor/assets/javascripts/webshims/shims/excanvas.js +924 -924
  68. data/vendor/assets/javascripts/webshims/shims/form-core.js +630 -606
  69. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +681 -681
  70. data/vendor/assets/javascripts/webshims/shims/form-message.js +176 -164
  71. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +255 -255
  72. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +383 -383
  73. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +1568 -1568
  74. data/vendor/assets/javascripts/webshims/shims/geolocation.js +168 -168
  75. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ar.js +32 -32
  76. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ch-ZN.js +32 -32
  77. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-de.txt +33 -33
  78. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-el.js +32 -32
  79. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-en.txt +34 -34
  80. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-es.js +31 -31
  81. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-fr.js +32 -32
  82. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-he.js +32 -32
  83. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hi.js +32 -32
  84. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hu.js +32 -32
  85. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-it.js +32 -32
  86. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ja.js +32 -32
  87. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-nl.js +32 -32
  88. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-pt-PT.js +32 -32
  89. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ru.js +31 -31
  90. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-sv.js +32 -32
  91. data/vendor/assets/javascripts/webshims/shims/json-storage.js +308 -308
  92. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +596 -597
  93. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +891 -891
  94. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +98 -98
  95. data/vendor/assets/javascripts/webshims/shims/mediaelement-swf.js +960 -960
  96. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +543 -543
  97. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +697 -697
  98. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  99. metadata +2 -4
  100. data/vendor/assets/javascripts/webshims/minified/shims/range-ui.js +0 -1
  101. data/vendor/assets/javascripts/webshims/shims/range-ui.js +0 -66
@@ -1,802 +1,802 @@
1
- // 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) {
28
-
29
- /**
30
- * Brings an environment as close to ECMAScript 5 compliance
31
- * as is possible with the facilities of erstwhile engines.
32
- *
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
48
- */
49
-
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;
62
-
63
- // ES-5 15.3.4.5
64
- // http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
65
-
66
- if (!Function.prototype.bind) {
67
- Function.prototype.bind = function (that) { // .length is 1
68
- // 1. Let Target be the this value.
69
- var target = this;
70
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
71
- if (typeof target != "function")
72
- throw new TypeError(); // TODO message
73
- // 3. Let A be a new (possibly empty) internal list of all of the
74
- // argument values provided after thisArg (arg1, arg2 etc), in order.
75
- // XXX slicedArgs will stand in for "A" if used
76
- var args = slice.call(arguments, 1); // for normal call
77
- // 4. Let F be a new native ECMAScript object.
78
- // 9. Set the [[Prototype]] internal property of F to the standard
79
- // built-in Function prototype object as specified in 15.3.3.1.
80
- // 10. Set the [[Call]] internal property of F as described in
81
- // 15.3.4.5.1.
82
- // 11. Set the [[Construct]] internal property of F as described in
83
- // 15.3.4.5.2.
84
- // 12. Set the [[HasInstance]] internal property of F as described in
85
- // 15.3.4.5.3.
86
- // 13. The [[Scope]] internal property of F is unused and need not
87
- // exist.
88
- var bound = function () {
89
-
90
- if (this instanceof bound) {
91
- // 15.3.4.5.2 [[Construct]]
92
- // When the [[Construct]] internal method of a function object,
93
- // F that was created using the bind function is called with a
94
- // list of arguments ExtraArgs the following steps are taken:
95
- // 1. Let target be the value of F's [[TargetFunction]]
96
- // internal property.
97
- // 2. If target has no [[Construct]] internal method, a
98
- // TypeError exception is thrown.
99
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
100
- // property.
101
- // 4. Let args be a new list containing the same values as the
102
- // list boundArgs in the same order followed by the same
103
- // values as the list ExtraArgs in the same order.
104
-
105
- var F = function(){};
106
- F.prototype = target.prototype;
107
- var self = new F;
108
-
109
- var result = target.apply(
110
- self,
111
- args.concat(slice.call(arguments))
112
- );
113
- if (result !== null && Object(result) === result)
114
- return result;
115
- return self;
116
-
117
- } else {
118
- // 15.3.4.5.1 [[Call]]
119
- // When the [[Call]] internal method of a function object, F,
120
- // which was created using the bind function is called with a
121
- // this value and a list of arguments ExtraArgs the following
122
- // steps are taken:
123
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
124
- // property.
125
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
126
- // property.
127
- // 3. Let target be the value of F's [[TargetFunction]] internal
128
- // 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.
135
-
136
- // equiv: target.call(this, ...boundArgs, ...args)
137
- return target.apply(
138
- that,
139
- args.concat(slice.call(arguments))
140
- );
141
-
142
- }
143
-
144
- };
145
- // XXX bound.length is never writable, so don't even try
146
- //
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.
151
- // 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.
156
- // 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.
161
- // TODO
162
- // NOTE Function objects created using Function.prototype.bind do not
163
- // have a prototype property.
164
- // XXX can't delete it in pure-js.
165
- return bound;
166
- };
167
- }
168
-
169
- toString = call.bind(prototypeOfObject.toString);
170
- owns = call.bind(prototypeOfObject.hasOwnProperty);
171
-
172
-
173
- //
174
- // Array
175
- // =====
176
- //
177
-
178
- // ES5 15.4.3.2
179
- if (!Array.isArray) {
180
- Array.isArray = function (obj) {
181
- return toString(obj) == "[object Array]";
182
- };
183
- }
184
-
185
- // The IsCallable() check in the Array functions
186
- // has been replaced with a strict check on the
187
- // internal class of the object to trap cases where
188
- // the provided function was actually a regular
189
- // expression literal, which in V8 and
190
- // JavaScriptCore is a typeof "function". Only in
191
- // V8 are regular expression literals permitted as
192
- // reduce parameters, so it is desirable in the
193
- // general case for the shim to match the more
194
- // strict and common behavior of rejecting regular
195
- // expressions.
196
-
197
- // ES5 15.4.4.18
198
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
199
- if (!Array.prototype.forEach) {
200
- Array.prototype.forEach = function (fun /*, thisp*/) {
201
- var self = toObject(this),
202
- thisp = arguments[1],
203
- i = 0,
204
- length = self.length >>> 0;
205
-
206
- // If no callback function or if callback is not a callable function
207
- if (toString(fun) != "[object Function]") {
208
- throw new TypeError(); // TODO message
209
- }
210
-
211
- while (i < length) {
212
- if (i in self) {
213
- // 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);
216
- }
217
- i++;
218
- }
219
- };
220
- }
221
-
222
- // ES5 15.4.4.19
223
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
224
- if (!Array.prototype.map) {
225
- Array.prototype.map = function (fun /*, thisp*/) {
226
- var self = toObject(this),
227
- length = self.length >>> 0,
228
- result = Array(length),
229
- thisp = arguments[1];
230
-
231
- // If no callback function or if callback is not a callable function
232
- if (toString(fun) != "[object Function]") {
233
- throw new TypeError(); // TODO message
234
- }
235
-
236
- for (var i = 0; i < length; i++) {
237
- if (i in self)
238
- result[i] = fun.call(thisp, self[i], i, self);
239
- }
240
- return result;
241
- };
242
- }
243
-
244
- // ES5 15.4.4.20
245
- if (!Array.prototype.filter) {
246
- Array.prototype.filter = function (fun /*, thisp */) {
247
- var self = toObject(this),
248
- length = self.length >>> 0,
249
- result = [],
250
- thisp = arguments[1];
251
-
252
- // If no callback function or if callback is not a callable function
253
- if (toString(fun) != "[object Function]") {
254
- throw new TypeError(); // TODO message
255
- }
256
-
257
- for (var i = 0; i < length; i++) {
258
- if (i in self && fun.call(thisp, self[i], i, self))
259
- result.push(self[i]);
260
- }
261
- return result;
262
- };
263
- }
264
-
265
- // ES5 15.4.4.16
266
- if (!Array.prototype.every) {
267
- Array.prototype.every = function (fun /*, thisp */) {
268
- var self = toObject(this),
269
- length = self.length >>> 0,
270
- thisp = arguments[1];
271
-
272
- // If no callback function or if callback is not a callable function
273
- if (toString(fun) != "[object Function]") {
274
- throw new TypeError(); // TODO message
275
- }
276
-
277
- for (var i = 0; i < length; i++) {
278
- if (i in self && !fun.call(thisp, self[i], i, self))
279
- return false;
280
- }
281
- return true;
282
- };
283
- }
284
-
285
- // ES5 15.4.4.17
286
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
287
- if (!Array.prototype.some) {
288
- Array.prototype.some = function (fun /*, thisp */) {
289
- var self = toObject(this),
290
- length = self.length >>> 0,
291
- thisp = arguments[1];
292
-
293
- // If no callback function or if callback is not a callable function
294
- if (toString(fun) != "[object Function]") {
295
- throw new TypeError(); // TODO message
296
- }
297
-
298
- for (var i = 0; i < length; i++) {
299
- if (i in self && fun.call(thisp, self[i], i, self))
300
- return true;
301
- }
302
- return false;
303
- };
304
- }
305
-
306
- // ES5 15.4.4.21
307
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
308
- if (!Array.prototype.reduce) {
309
- Array.prototype.reduce = function (fun /*, initial*/) {
310
- var self = toObject(this),
311
- length = self.length >>> 0;
312
-
313
- // If no callback function or if callback is not a callable function
314
- if (toString(fun) != "[object Function]") {
315
- throw new TypeError(); // TODO message
316
- }
317
-
318
- // no value to return if no initial value and an empty array
319
- if (!length && arguments.length == 1)
320
- throw new TypeError(); // TODO message
321
-
322
- var i = 0;
323
- var result;
324
- if (arguments.length >= 2) {
325
- result = arguments[1];
326
- } else {
327
- do {
328
- if (i in self) {
329
- result = self[i++];
330
- break;
331
- }
332
-
333
- // if array contains no values, no initial value to return
334
- if (++i >= length)
335
- throw new TypeError(); // TODO message
336
- } while (true);
337
- }
338
-
339
- for (; i < length; i++) {
340
- if (i in self)
341
- result = fun.call(void 0, result, self[i], i, self);
342
- }
343
-
344
- return result;
345
- };
346
- }
347
-
348
- // ES5 15.4.4.22
349
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
350
- if (!Array.prototype.reduceRight) {
351
- Array.prototype.reduceRight = function (fun /*, initial*/) {
352
- var self = toObject(this),
353
- length = self.length >>> 0;
354
-
355
- // If no callback function or if callback is not a callable function
356
- if (toString(fun) != "[object Function]") {
357
- throw new TypeError(); // TODO message
358
- }
359
-
360
- // no value to return if no initial value, empty array
361
- if (!length && arguments.length == 1)
362
- throw new TypeError(); // TODO message
363
-
364
- var result, i = length - 1;
365
- if (arguments.length >= 2) {
366
- result = arguments[1];
367
- } else {
368
- do {
369
- if (i in self) {
370
- result = self[i--];
371
- break;
372
- }
373
-
374
- // if array contains no values, no initial value to return
375
- if (--i < 0)
376
- throw new TypeError(); // TODO message
377
- } while (true);
378
- }
379
-
380
- do {
381
- if (i in this)
382
- result = fun.call(void 0, result, self[i], i, self);
383
- } while (i--);
384
-
385
- return result;
386
- };
387
- }
388
-
389
- // ES5 15.4.4.14
390
- // 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),
394
- length = self.length >>> 0;
395
-
396
- if (!length)
397
- return -1;
398
-
399
- var i = 0;
400
- if (arguments.length > 1)
401
- i = toInteger(arguments[1]);
402
-
403
- // handle negative indices
404
- i = i >= 0 ? i : length - Math.abs(i);
405
- for (; i < length; i++) {
406
- if (i in self && self[i] === sought) {
407
- return i;
408
- }
409
- }
410
- return -1;
411
- };
412
- }
413
-
414
- // ES5 15.4.4.15
415
- if (!Array.prototype.lastIndexOf) {
416
- Array.prototype.lastIndexOf = function (sought /*, fromIndex */) {
417
- var self = toObject(this),
418
- length = self.length >>> 0;
419
-
420
- if (!length)
421
- return -1;
422
- var i = length - 1;
423
- if (arguments.length > 1)
424
- i = toInteger(arguments[1]);
425
- // handle negative indices
426
- i = i >= 0 ? i : length - Math.abs(i);
427
- for (; i >= 0; i--) {
428
- if (i in self && sought === self[i])
429
- return i;
430
- }
431
- return -1;
432
- };
433
- }
434
-
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
- //
459
- // Object
460
- // ======
461
- //
462
-
463
-
464
- // ES5 15.2.3.14
465
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
466
- if (!Object.keys) {
467
-
468
- var hasDontEnumBug = true,
469
- dontEnums = [
470
- "toString",
471
- "toLocaleString",
472
- "valueOf",
473
- "hasOwnProperty",
474
- "isPrototypeOf",
475
- "propertyIsEnumerable",
476
- "constructor"
477
- ],
478
- dontEnumsLength = dontEnums.length;
479
-
480
- for (var key in {"toString": null})
481
- hasDontEnumBug = false;
482
-
483
- Object.keys = function keys(object) {
484
-
485
- if ((typeof object != "object" && typeof object != "function") || object === null)
486
- throw new TypeError("Object.keys called on a non-object");
487
-
488
- var keys = [];
489
- for (var name in object) {
490
- if (owns(object, name)) {
491
- keys.push(name);
492
- }
493
- }
494
-
495
- if (hasDontEnumBug) {
496
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
497
- var dontEnum = dontEnums[i];
498
- if (owns(object, dontEnum)) {
499
- keys.push(dontEnum);
500
- }
501
- }
502
- }
503
-
504
- return keys;
505
- };
506
-
507
- }
508
-
509
- //
510
- // Date
511
- // ====
512
- //
513
-
514
- // 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) {
518
- Date.prototype.toISOString = function toISOString() {
519
- var result, length, value;
520
- if (!isFinite(this))
521
- throw new RangeError;
522
-
523
- // the date time string format is specified in 15.9.1.15.
524
- result = [this.getUTCFullYear(), this.getUTCMonth() + 1, this.getUTCDate(),
525
- this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
526
-
527
- length = result.length;
528
- while (length--) {
529
- value = result[length];
530
- // pad months, days, hours, minutes, and seconds to have two digits.
531
- if (value < 10)
532
- result[length] = "0" + value;
533
- }
534
- // 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();
544
- };
545
- }
546
-
547
- // ES5 15.9.5.44
548
- if (!Date.prototype.toJSON) {
549
- 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:
553
-
554
- // 1. Let O be the result of calling ToObject, giving it the this
555
- // value as its argument.
556
- // 2. Let tv be ToPrimitive(O, hint Number).
557
- // 3. If tv is a Number and is not finite, return null.
558
- // XXX
559
- // 4. Let toISO be the result of calling the [[Get]] internal method of
560
- // O with argument "toISOString".
561
- // 5. If IsCallable(toISO) is false, throw a TypeError exception.
562
- if (typeof this.toISOString != "function")
563
- throw new TypeError(); // TODO message
564
- // 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();
567
-
568
- // NOTE 1 The argument is ignored.
569
-
570
- // NOTE 2 The toJSON function is intentionally generic; it does not
571
- // require that its this value be a Date object. Therefore, it can be
572
- // transferred to other kinds of objects for use as a method. However,
573
- // it does require that any such object have a toISOString method. An
574
- // object is free to use the argument key to filter its
575
- // stringification.
576
- };
577
- }
578
-
579
-
580
- //
581
- // String
582
- // ======
583
- //
584
-
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
- };
598
- }
599
-
600
- // ES5 15.5.4.14
601
- // http://es5.github.com/#x15.5.4.14
602
- // [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.
604
- // "0".split(undefined, 0) -> []
605
- if("0".split(void 0, 0).length) {
606
- var oldSplit = String.prototype.split;
607
- String.prototype.split = function(separator, limit) {
608
- if(separator === void 0 && limit === 0)return [];
609
- return oldSplit.apply(this, arguments);
610
- }
611
- }
612
-
613
- // 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
616
- // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
617
- if("".substr && "0b".substr(-1) !== "b") {
618
- var oldSubstr = String.prototype.substr;
619
- /**
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
- */
625
- String.prototype.substr = function(start, length) {
626
- return oldSubstr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);
627
- }
628
- }
629
-
630
- //
631
- // Util
632
- // ======
633
- //
634
-
635
- // http://jsperf.com/to-integer
636
- var toInteger = function (n) {
637
- n = +n;
638
- if (n !== n) // isNaN
639
- n = -1;
640
- else if (n !== 0 && n !== (1/0) && n !== -(1/0))
641
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
642
- return n;
643
- };
644
-
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
650
- }
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("");
655
- }
656
- return Object(o);
657
- };
658
-
659
- })();
660
-
661
-
662
-
663
- (function($, shims){
664
- var defineProperty = 'defineProperty';
665
- var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
666
- //safari5 has defineProperty-interface, but it can't be used on dom-object
667
- //only do this test in non-IE browsers, because this hurts dhtml-behavior in some IE8 versions
668
- if (advancedObjectProperties && !$.browser.msie && Object[defineProperty] && Object.prototype.__defineGetter__) {
669
- (function(){
670
- try {
671
- var foo = document.createElement('foo');
672
- Object[defineProperty](foo, 'bar', {
673
- get: function(){
674
- return true;
675
- }
676
- });
677
- advancedObjectProperties = !!foo.bar;
678
- }
679
- catch (e) {
680
- advancedObjectProperties = false;
681
- }
682
- foo = null;
683
- })();
684
- }
685
-
686
- Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)) && (!$.browser.opera || shims.browserVersion >= 11));
687
- Modernizr.advancedObjectProperties = advancedObjectProperties;
688
-
689
- if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
690
- var call = Function.prototype.call;
691
- var prototypeOfObject = Object.prototype;
692
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
693
-
694
- shims.objectCreate = function(proto, props, opts, no__proto__){
695
- var o;
696
- var f = function(){};
697
-
698
- f.prototype = proto;
699
- o = new f();
700
-
701
- if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
702
- o.__proto__ = proto;
703
- }
704
-
705
- if(props){
706
- shims.defineProperties(o, props);
707
- }
708
-
709
- if(opts){
710
- o.options = jQuery.extend(true, {}, o.options || {}, opts);
711
- opts = o.options;
712
- }
713
-
714
- if(o._create && jQuery.isFunction(o._create)){
715
- o._create(opts);
716
- }
717
- return o;
718
- };
719
-
720
- shims.defineProperties = function(object, props){
721
- for (var name in props) {
722
- if (owns(props, name)) {
723
- shims.defineProperty(object, name, props[name]);
724
- }
725
- }
726
- return object;
727
- };
728
-
729
- var descProps = ['configurable', 'enumerable', 'writable'];
730
- shims.defineProperty = function(proto, property, descriptor){
731
- if(typeof descriptor != "object" || descriptor === null){return proto;}
732
-
733
- if(owns(descriptor, "value")){
734
- proto[property] = descriptor.value;
735
- return proto;
736
- }
737
-
738
- if(proto.__defineGetter__){
739
- if (typeof descriptor.get == "function") {
740
- proto.__defineGetter__(property, descriptor.get);
741
- }
742
- if (typeof descriptor.set == "function"){
743
- proto.__defineSetter__(property, descriptor.set);
744
- }
745
- }
746
- return proto;
747
- };
748
-
749
- shims.getPrototypeOf = function (object) {
750
- return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
751
- };
752
-
753
- //based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
754
- shims.getOwnPropertyDescriptor = function(obj, prop){
755
- if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
756
- throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
757
- }
758
- var descriptor;
759
- if(Object.defineProperty && Object.getOwnPropertyDescriptor){
760
- try{
761
- descriptor = Object.getOwnPropertyDescriptor(obj, prop);
762
- return descriptor;
763
- } catch(e){}
764
- }
765
- descriptor = {
766
- configurable: true,
767
- enumerable: true,
768
- writable: true,
769
- value: undefined
770
- };
771
- var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
772
- setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
773
- ;
774
-
775
- if (!getter && !setter) { // not an accessor so return prop
776
- if(!owns(obj, prop)){
777
- return;
778
- }
779
- descriptor.value = obj[prop];
780
- return descriptor;
781
- }
782
-
783
- // there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
784
- delete descriptor.writable;
785
- delete descriptor.value;
786
- descriptor.get = descriptor.set = undefined;
787
-
788
- if(getter){
789
- descriptor.get = getter;
790
- }
791
-
792
- if(setter){
793
- descriptor.set = setter;
794
- }
795
-
796
- return descriptor;
797
- };
798
-
799
- }
800
- })(jQuery, jQuery.webshims);
801
-
802
-
1
+ // 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) {
28
+
29
+ /**
30
+ * Brings an environment as close to ECMAScript 5 compliance
31
+ * as is possible with the facilities of erstwhile engines.
32
+ *
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
48
+ */
49
+
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;
62
+
63
+ // ES-5 15.3.4.5
64
+ // http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
65
+
66
+ if (!Function.prototype.bind) {
67
+ Function.prototype.bind = function (that) { // .length is 1
68
+ // 1. Let Target be the this value.
69
+ var target = this;
70
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
71
+ if (typeof target != "function")
72
+ throw new TypeError(); // TODO message
73
+ // 3. Let A be a new (possibly empty) internal list of all of the
74
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
75
+ // XXX slicedArgs will stand in for "A" if used
76
+ var args = slice.call(arguments, 1); // for normal call
77
+ // 4. Let F be a new native ECMAScript object.
78
+ // 9. Set the [[Prototype]] internal property of F to the standard
79
+ // built-in Function prototype object as specified in 15.3.3.1.
80
+ // 10. Set the [[Call]] internal property of F as described in
81
+ // 15.3.4.5.1.
82
+ // 11. Set the [[Construct]] internal property of F as described in
83
+ // 15.3.4.5.2.
84
+ // 12. Set the [[HasInstance]] internal property of F as described in
85
+ // 15.3.4.5.3.
86
+ // 13. The [[Scope]] internal property of F is unused and need not
87
+ // exist.
88
+ var bound = function () {
89
+
90
+ if (this instanceof bound) {
91
+ // 15.3.4.5.2 [[Construct]]
92
+ // When the [[Construct]] internal method of a function object,
93
+ // F that was created using the bind function is called with a
94
+ // list of arguments ExtraArgs the following steps are taken:
95
+ // 1. Let target be the value of F's [[TargetFunction]]
96
+ // internal property.
97
+ // 2. If target has no [[Construct]] internal method, a
98
+ // TypeError exception is thrown.
99
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
100
+ // property.
101
+ // 4. Let args be a new list containing the same values as the
102
+ // list boundArgs in the same order followed by the same
103
+ // values as the list ExtraArgs in the same order.
104
+
105
+ var F = function(){};
106
+ F.prototype = target.prototype;
107
+ var self = new F;
108
+
109
+ var result = target.apply(
110
+ self,
111
+ args.concat(slice.call(arguments))
112
+ );
113
+ if (result !== null && Object(result) === result)
114
+ return result;
115
+ return self;
116
+
117
+ } else {
118
+ // 15.3.4.5.1 [[Call]]
119
+ // When the [[Call]] internal method of a function object, F,
120
+ // which was created using the bind function is called with a
121
+ // this value and a list of arguments ExtraArgs the following
122
+ // steps are taken:
123
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
124
+ // property.
125
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
126
+ // property.
127
+ // 3. Let target be the value of F's [[TargetFunction]] internal
128
+ // 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.
135
+
136
+ // equiv: target.call(this, ...boundArgs, ...args)
137
+ return target.apply(
138
+ that,
139
+ args.concat(slice.call(arguments))
140
+ );
141
+
142
+ }
143
+
144
+ };
145
+ // XXX bound.length is never writable, so don't even try
146
+ //
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.
151
+ // 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.
156
+ // 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.
161
+ // TODO
162
+ // NOTE Function objects created using Function.prototype.bind do not
163
+ // have a prototype property.
164
+ // XXX can't delete it in pure-js.
165
+ return bound;
166
+ };
167
+ }
168
+
169
+ toString = call.bind(prototypeOfObject.toString);
170
+ owns = call.bind(prototypeOfObject.hasOwnProperty);
171
+
172
+
173
+ //
174
+ // Array
175
+ // =====
176
+ //
177
+
178
+ // ES5 15.4.3.2
179
+ if (!Array.isArray) {
180
+ Array.isArray = function (obj) {
181
+ return toString(obj) == "[object Array]";
182
+ };
183
+ }
184
+
185
+ // The IsCallable() check in the Array functions
186
+ // has been replaced with a strict check on the
187
+ // internal class of the object to trap cases where
188
+ // the provided function was actually a regular
189
+ // expression literal, which in V8 and
190
+ // JavaScriptCore is a typeof "function". Only in
191
+ // V8 are regular expression literals permitted as
192
+ // reduce parameters, so it is desirable in the
193
+ // general case for the shim to match the more
194
+ // strict and common behavior of rejecting regular
195
+ // expressions.
196
+
197
+ // ES5 15.4.4.18
198
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
199
+ if (!Array.prototype.forEach) {
200
+ Array.prototype.forEach = function (fun /*, thisp*/) {
201
+ var self = toObject(this),
202
+ thisp = arguments[1],
203
+ i = 0,
204
+ length = self.length >>> 0;
205
+
206
+ // If no callback function or if callback is not a callable function
207
+ if (toString(fun) != "[object Function]") {
208
+ throw new TypeError(); // TODO message
209
+ }
210
+
211
+ while (i < length) {
212
+ if (i in self) {
213
+ // 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);
216
+ }
217
+ i++;
218
+ }
219
+ };
220
+ }
221
+
222
+ // ES5 15.4.4.19
223
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
224
+ if (!Array.prototype.map) {
225
+ Array.prototype.map = function (fun /*, thisp*/) {
226
+ var self = toObject(this),
227
+ length = self.length >>> 0,
228
+ result = Array(length),
229
+ thisp = arguments[1];
230
+
231
+ // If no callback function or if callback is not a callable function
232
+ if (toString(fun) != "[object Function]") {
233
+ throw new TypeError(); // TODO message
234
+ }
235
+
236
+ for (var i = 0; i < length; i++) {
237
+ if (i in self)
238
+ result[i] = fun.call(thisp, self[i], i, self);
239
+ }
240
+ return result;
241
+ };
242
+ }
243
+
244
+ // ES5 15.4.4.20
245
+ if (!Array.prototype.filter) {
246
+ Array.prototype.filter = function (fun /*, thisp */) {
247
+ var self = toObject(this),
248
+ length = self.length >>> 0,
249
+ result = [],
250
+ thisp = arguments[1];
251
+
252
+ // If no callback function or if callback is not a callable function
253
+ if (toString(fun) != "[object Function]") {
254
+ throw new TypeError(); // TODO message
255
+ }
256
+
257
+ for (var i = 0; i < length; i++) {
258
+ if (i in self && fun.call(thisp, self[i], i, self))
259
+ result.push(self[i]);
260
+ }
261
+ return result;
262
+ };
263
+ }
264
+
265
+ // ES5 15.4.4.16
266
+ if (!Array.prototype.every) {
267
+ Array.prototype.every = function (fun /*, thisp */) {
268
+ var self = toObject(this),
269
+ length = self.length >>> 0,
270
+ thisp = arguments[1];
271
+
272
+ // If no callback function or if callback is not a callable function
273
+ if (toString(fun) != "[object Function]") {
274
+ throw new TypeError(); // TODO message
275
+ }
276
+
277
+ for (var i = 0; i < length; i++) {
278
+ if (i in self && !fun.call(thisp, self[i], i, self))
279
+ return false;
280
+ }
281
+ return true;
282
+ };
283
+ }
284
+
285
+ // ES5 15.4.4.17
286
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
287
+ if (!Array.prototype.some) {
288
+ Array.prototype.some = function (fun /*, thisp */) {
289
+ var self = toObject(this),
290
+ length = self.length >>> 0,
291
+ thisp = arguments[1];
292
+
293
+ // If no callback function or if callback is not a callable function
294
+ if (toString(fun) != "[object Function]") {
295
+ throw new TypeError(); // TODO message
296
+ }
297
+
298
+ for (var i = 0; i < length; i++) {
299
+ if (i in self && fun.call(thisp, self[i], i, self))
300
+ return true;
301
+ }
302
+ return false;
303
+ };
304
+ }
305
+
306
+ // ES5 15.4.4.21
307
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
308
+ if (!Array.prototype.reduce) {
309
+ Array.prototype.reduce = function (fun /*, initial*/) {
310
+ var self = toObject(this),
311
+ length = self.length >>> 0;
312
+
313
+ // If no callback function or if callback is not a callable function
314
+ if (toString(fun) != "[object Function]") {
315
+ throw new TypeError(); // TODO message
316
+ }
317
+
318
+ // no value to return if no initial value and an empty array
319
+ if (!length && arguments.length == 1)
320
+ throw new TypeError(); // TODO message
321
+
322
+ var i = 0;
323
+ var result;
324
+ if (arguments.length >= 2) {
325
+ result = arguments[1];
326
+ } else {
327
+ do {
328
+ if (i in self) {
329
+ result = self[i++];
330
+ break;
331
+ }
332
+
333
+ // if array contains no values, no initial value to return
334
+ if (++i >= length)
335
+ throw new TypeError(); // TODO message
336
+ } while (true);
337
+ }
338
+
339
+ for (; i < length; i++) {
340
+ if (i in self)
341
+ result = fun.call(void 0, result, self[i], i, self);
342
+ }
343
+
344
+ return result;
345
+ };
346
+ }
347
+
348
+ // ES5 15.4.4.22
349
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
350
+ if (!Array.prototype.reduceRight) {
351
+ Array.prototype.reduceRight = function (fun /*, initial*/) {
352
+ var self = toObject(this),
353
+ length = self.length >>> 0;
354
+
355
+ // If no callback function or if callback is not a callable function
356
+ if (toString(fun) != "[object Function]") {
357
+ throw new TypeError(); // TODO message
358
+ }
359
+
360
+ // no value to return if no initial value, empty array
361
+ if (!length && arguments.length == 1)
362
+ throw new TypeError(); // TODO message
363
+
364
+ var result, i = length - 1;
365
+ if (arguments.length >= 2) {
366
+ result = arguments[1];
367
+ } else {
368
+ do {
369
+ if (i in self) {
370
+ result = self[i--];
371
+ break;
372
+ }
373
+
374
+ // if array contains no values, no initial value to return
375
+ if (--i < 0)
376
+ throw new TypeError(); // TODO message
377
+ } while (true);
378
+ }
379
+
380
+ do {
381
+ if (i in this)
382
+ result = fun.call(void 0, result, self[i], i, self);
383
+ } while (i--);
384
+
385
+ return result;
386
+ };
387
+ }
388
+
389
+ // ES5 15.4.4.14
390
+ // 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),
394
+ length = self.length >>> 0;
395
+
396
+ if (!length)
397
+ return -1;
398
+
399
+ var i = 0;
400
+ if (arguments.length > 1)
401
+ i = toInteger(arguments[1]);
402
+
403
+ // handle negative indices
404
+ i = i >= 0 ? i : length - Math.abs(i);
405
+ for (; i < length; i++) {
406
+ if (i in self && self[i] === sought) {
407
+ return i;
408
+ }
409
+ }
410
+ return -1;
411
+ };
412
+ }
413
+
414
+ // ES5 15.4.4.15
415
+ if (!Array.prototype.lastIndexOf) {
416
+ Array.prototype.lastIndexOf = function (sought /*, fromIndex */) {
417
+ var self = toObject(this),
418
+ length = self.length >>> 0;
419
+
420
+ if (!length)
421
+ return -1;
422
+ var i = length - 1;
423
+ if (arguments.length > 1)
424
+ i = toInteger(arguments[1]);
425
+ // handle negative indices
426
+ i = i >= 0 ? i : length - Math.abs(i);
427
+ for (; i >= 0; i--) {
428
+ if (i in self && sought === self[i])
429
+ return i;
430
+ }
431
+ return -1;
432
+ };
433
+ }
434
+
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
+ //
459
+ // Object
460
+ // ======
461
+ //
462
+
463
+
464
+ // ES5 15.2.3.14
465
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
466
+ if (!Object.keys) {
467
+
468
+ var hasDontEnumBug = true,
469
+ dontEnums = [
470
+ "toString",
471
+ "toLocaleString",
472
+ "valueOf",
473
+ "hasOwnProperty",
474
+ "isPrototypeOf",
475
+ "propertyIsEnumerable",
476
+ "constructor"
477
+ ],
478
+ dontEnumsLength = dontEnums.length;
479
+
480
+ for (var key in {"toString": null})
481
+ hasDontEnumBug = false;
482
+
483
+ Object.keys = function keys(object) {
484
+
485
+ if ((typeof object != "object" && typeof object != "function") || object === null)
486
+ throw new TypeError("Object.keys called on a non-object");
487
+
488
+ var keys = [];
489
+ for (var name in object) {
490
+ if (owns(object, name)) {
491
+ keys.push(name);
492
+ }
493
+ }
494
+
495
+ if (hasDontEnumBug) {
496
+ for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
497
+ var dontEnum = dontEnums[i];
498
+ if (owns(object, dontEnum)) {
499
+ keys.push(dontEnum);
500
+ }
501
+ }
502
+ }
503
+
504
+ return keys;
505
+ };
506
+
507
+ }
508
+
509
+ //
510
+ // Date
511
+ // ====
512
+ //
513
+
514
+ // 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) {
518
+ Date.prototype.toISOString = function toISOString() {
519
+ var result, length, value;
520
+ if (!isFinite(this))
521
+ throw new RangeError;
522
+
523
+ // the date time string format is specified in 15.9.1.15.
524
+ result = [this.getUTCFullYear(), this.getUTCMonth() + 1, this.getUTCDate(),
525
+ this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
526
+
527
+ length = result.length;
528
+ while (length--) {
529
+ value = result[length];
530
+ // pad months, days, hours, minutes, and seconds to have two digits.
531
+ if (value < 10)
532
+ result[length] = "0" + value;
533
+ }
534
+ // 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();
544
+ };
545
+ }
546
+
547
+ // ES5 15.9.5.44
548
+ if (!Date.prototype.toJSON) {
549
+ 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:
553
+
554
+ // 1. Let O be the result of calling ToObject, giving it the this
555
+ // value as its argument.
556
+ // 2. Let tv be ToPrimitive(O, hint Number).
557
+ // 3. If tv is a Number and is not finite, return null.
558
+ // XXX
559
+ // 4. Let toISO be the result of calling the [[Get]] internal method of
560
+ // O with argument "toISOString".
561
+ // 5. If IsCallable(toISO) is false, throw a TypeError exception.
562
+ if (typeof this.toISOString != "function")
563
+ throw new TypeError(); // TODO message
564
+ // 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();
567
+
568
+ // NOTE 1 The argument is ignored.
569
+
570
+ // NOTE 2 The toJSON function is intentionally generic; it does not
571
+ // require that its this value be a Date object. Therefore, it can be
572
+ // transferred to other kinds of objects for use as a method. However,
573
+ // it does require that any such object have a toISOString method. An
574
+ // object is free to use the argument key to filter its
575
+ // stringification.
576
+ };
577
+ }
578
+
579
+
580
+ //
581
+ // String
582
+ // ======
583
+ //
584
+
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
+ };
598
+ }
599
+
600
+ // ES5 15.5.4.14
601
+ // http://es5.github.com/#x15.5.4.14
602
+ // [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.
604
+ // "0".split(undefined, 0) -> []
605
+ if("0".split(void 0, 0).length) {
606
+ var oldSplit = String.prototype.split;
607
+ String.prototype.split = function(separator, limit) {
608
+ if(separator === void 0 && limit === 0)return [];
609
+ return oldSplit.apply(this, arguments);
610
+ }
611
+ }
612
+
613
+ // 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
616
+ // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
617
+ if("".substr && "0b".substr(-1) !== "b") {
618
+ var oldSubstr = String.prototype.substr;
619
+ /**
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
+ */
625
+ String.prototype.substr = function(start, length) {
626
+ return oldSubstr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);
627
+ }
628
+ }
629
+
630
+ //
631
+ // Util
632
+ // ======
633
+ //
634
+
635
+ // http://jsperf.com/to-integer
636
+ var toInteger = function (n) {
637
+ n = +n;
638
+ if (n !== n) // isNaN
639
+ n = -1;
640
+ else if (n !== 0 && n !== (1/0) && n !== -(1/0))
641
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
642
+ return n;
643
+ };
644
+
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
650
+ }
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("");
655
+ }
656
+ return Object(o);
657
+ };
658
+
659
+ })();
660
+
661
+
662
+
663
+ (function($, shims){
664
+ var defineProperty = 'defineProperty';
665
+ var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
666
+ //safari5 has defineProperty-interface, but it can't be used on dom-object
667
+ //only do this test in non-IE browsers, because this hurts dhtml-behavior in some IE8 versions
668
+ if (advancedObjectProperties && !$.browser.msie && Object[defineProperty] && Object.prototype.__defineGetter__) {
669
+ (function(){
670
+ try {
671
+ var foo = document.createElement('foo');
672
+ Object[defineProperty](foo, 'bar', {
673
+ get: function(){
674
+ return true;
675
+ }
676
+ });
677
+ advancedObjectProperties = !!foo.bar;
678
+ }
679
+ catch (e) {
680
+ advancedObjectProperties = false;
681
+ }
682
+ foo = null;
683
+ })();
684
+ }
685
+
686
+ Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)) && (!$.browser.opera || shims.browserVersion >= 11));
687
+ Modernizr.advancedObjectProperties = advancedObjectProperties;
688
+
689
+ if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
690
+ var call = Function.prototype.call;
691
+ var prototypeOfObject = Object.prototype;
692
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
693
+
694
+ shims.objectCreate = function(proto, props, opts, no__proto__){
695
+ var o;
696
+ var f = function(){};
697
+
698
+ f.prototype = proto;
699
+ o = new f();
700
+
701
+ if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
702
+ o.__proto__ = proto;
703
+ }
704
+
705
+ if(props){
706
+ shims.defineProperties(o, props);
707
+ }
708
+
709
+ if(opts){
710
+ o.options = jQuery.extend(true, {}, o.options || {}, opts);
711
+ opts = o.options;
712
+ }
713
+
714
+ if(o._create && jQuery.isFunction(o._create)){
715
+ o._create(opts);
716
+ }
717
+ return o;
718
+ };
719
+
720
+ shims.defineProperties = function(object, props){
721
+ for (var name in props) {
722
+ if (owns(props, name)) {
723
+ shims.defineProperty(object, name, props[name]);
724
+ }
725
+ }
726
+ return object;
727
+ };
728
+
729
+ var descProps = ['configurable', 'enumerable', 'writable'];
730
+ shims.defineProperty = function(proto, property, descriptor){
731
+ if(typeof descriptor != "object" || descriptor === null){return proto;}
732
+
733
+ if(owns(descriptor, "value")){
734
+ proto[property] = descriptor.value;
735
+ return proto;
736
+ }
737
+
738
+ if(proto.__defineGetter__){
739
+ if (typeof descriptor.get == "function") {
740
+ proto.__defineGetter__(property, descriptor.get);
741
+ }
742
+ if (typeof descriptor.set == "function"){
743
+ proto.__defineSetter__(property, descriptor.set);
744
+ }
745
+ }
746
+ return proto;
747
+ };
748
+
749
+ shims.getPrototypeOf = function (object) {
750
+ return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
751
+ };
752
+
753
+ //based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
754
+ shims.getOwnPropertyDescriptor = function(obj, prop){
755
+ if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
756
+ throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
757
+ }
758
+ var descriptor;
759
+ if(Object.defineProperty && Object.getOwnPropertyDescriptor){
760
+ try{
761
+ descriptor = Object.getOwnPropertyDescriptor(obj, prop);
762
+ return descriptor;
763
+ } catch(e){}
764
+ }
765
+ descriptor = {
766
+ configurable: true,
767
+ enumerable: true,
768
+ writable: true,
769
+ value: undefined
770
+ };
771
+ var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
772
+ setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
773
+ ;
774
+
775
+ if (!getter && !setter) { // not an accessor so return prop
776
+ if(!owns(obj, prop)){
777
+ return;
778
+ }
779
+ descriptor.value = obj[prop];
780
+ return descriptor;
781
+ }
782
+
783
+ // there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
784
+ delete descriptor.writable;
785
+ delete descriptor.value;
786
+ descriptor.get = descriptor.set = undefined;
787
+
788
+ if(getter){
789
+ descriptor.get = getter;
790
+ }
791
+
792
+ if(setter){
793
+ descriptor.set = setter;
794
+ }
795
+
796
+ return descriptor;
797
+ };
798
+
799
+ }
800
+ })(jQuery, jQuery.webshims);
801
+
802
+