webshims-rails 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/lib/webshims-rails/version.rb +2 -2
  2. data/vendor/assets/javascripts/webshims/extras/custom-validity.js +261 -261
  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/extras/custom-validity.js +1 -1
  6. data/vendor/assets/javascripts/webshims/minified/polyfiller.js +24 -24
  7. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/README +82 -82
  8. data/vendor/assets/javascripts/webshims/minified/shims/combos/1.js +35 -34
  9. data/vendor/assets/javascripts/webshims/minified/shims/combos/10.js +79 -82
  10. data/vendor/assets/javascripts/webshims/minified/shims/combos/11.js +45 -44
  11. data/vendor/assets/javascripts/webshims/minified/shims/combos/12.js +43 -42
  12. data/vendor/assets/javascripts/webshims/minified/shims/combos/13.js +28 -27
  13. data/vendor/assets/javascripts/webshims/minified/shims/combos/15.js +4 -4
  14. data/vendor/assets/javascripts/webshims/minified/shims/combos/16.js +57 -59
  15. data/vendor/assets/javascripts/webshims/minified/shims/combos/17.js +64 -66
  16. data/vendor/assets/javascripts/webshims/minified/shims/combos/18.js +53 -54
  17. data/vendor/assets/javascripts/webshims/minified/shims/combos/19.js +64 -66
  18. data/vendor/assets/javascripts/webshims/minified/shims/combos/2.js +72 -73
  19. data/vendor/assets/javascripts/webshims/minified/shims/combos/20.js +42 -46
  20. data/vendor/assets/javascripts/webshims/minified/shims/combos/21.js +52 -50
  21. data/vendor/assets/javascripts/webshims/minified/shims/combos/22.js +55 -59
  22. data/vendor/assets/javascripts/webshims/minified/shims/combos/23.js +66 -64
  23. data/vendor/assets/javascripts/webshims/minified/shims/combos/24.js +80 -82
  24. data/vendor/assets/javascripts/webshims/minified/shims/combos/25.js +60 -59
  25. data/vendor/assets/javascripts/webshims/minified/shims/combos/26.js +79 -81
  26. data/vendor/assets/javascripts/webshims/minified/shims/combos/27.js +101 -104
  27. data/vendor/assets/javascripts/webshims/minified/shims/combos/3.js +94 -95
  28. data/vendor/assets/javascripts/webshims/minified/shims/combos/4.js +26 -29
  29. data/vendor/assets/javascripts/webshims/minified/shims/combos/5.js +33 -36
  30. data/vendor/assets/javascripts/webshims/minified/shims/combos/59.js +51 -54
  31. data/vendor/assets/javascripts/webshims/minified/shims/combos/6.js +27 -28
  32. data/vendor/assets/javascripts/webshims/minified/shims/combos/7.js +27 -28
  33. data/vendor/assets/javascripts/webshims/minified/shims/combos/8.js +39 -38
  34. data/vendor/assets/javascripts/webshims/minified/shims/combos/9.js +65 -68
  35. data/vendor/assets/javascripts/webshims/minified/shims/details.js +4 -4
  36. data/vendor/assets/javascripts/webshims/minified/shims/dom-extend.js +23 -22
  37. data/vendor/assets/javascripts/webshims/minified/shims/form-core.js +19 -22
  38. data/vendor/assets/javascripts/webshims/minified/shims/form-datalist.js +14 -14
  39. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-api.js +9 -9
  40. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-ui.js +18 -19
  41. data/vendor/assets/javascripts/webshims/minified/shims/form-shim-extend.js +45 -43
  42. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-de.txt +33 -33
  43. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-en.txt +34 -34
  44. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-core.js +12 -12
  45. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-jaris.js +23 -0
  46. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-native-fix.js +1 -1
  47. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-swf.js +26 -30
  48. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-yt.js +3 -3
  49. data/vendor/assets/javascripts/webshims/minified/shims/styles/shim.css +689 -686
  50. data/vendor/assets/javascripts/webshims/minified/shims/swf/JarisFLVPlayer.swf +0 -0
  51. data/vendor/assets/javascripts/webshims/minified/shims/track-ui.js +9 -9
  52. data/vendor/assets/javascripts/webshims/minified/shims/track.js +21 -21
  53. data/vendor/assets/javascripts/webshims/polyfiller.js +1191 -1175
  54. data/vendor/assets/javascripts/webshims/shims/combos/1.js +1754 -1714
  55. data/vendor/assets/javascripts/webshims/shims/combos/10.js +3247 -3320
  56. data/vendor/assets/javascripts/webshims/shims/combos/11.js +1633 -1588
  57. data/vendor/assets/javascripts/webshims/shims/combos/12.js +1636 -1591
  58. data/vendor/assets/javascripts/webshims/shims/combos/13.js +1100 -1058
  59. data/vendor/assets/javascripts/webshims/shims/combos/14.js +476 -476
  60. data/vendor/assets/javascripts/webshims/shims/combos/15.js +316 -314
  61. data/vendor/assets/javascripts/webshims/shims/combos/16.js +2094 -2104
  62. data/vendor/assets/javascripts/webshims/shims/combos/17.js +2258 -2267
  63. data/vendor/assets/javascripts/webshims/shims/combos/18.js +1380 -1364
  64. data/vendor/assets/javascripts/webshims/shims/combos/19.js +2239 -2247
  65. data/vendor/assets/javascripts/webshims/shims/combos/2.js +2339 -2294
  66. data/vendor/assets/javascripts/webshims/shims/combos/20.js +1493 -1606
  67. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1733 -1635
  68. data/vendor/assets/javascripts/webshims/shims/combos/22.js +2295 -2408
  69. data/vendor/assets/javascripts/webshims/shims/combos/23.js +2269 -2168
  70. data/vendor/assets/javascripts/webshims/shims/combos/24.js +2775 -2780
  71. data/vendor/assets/javascripts/webshims/shims/combos/25.js +1505 -1456
  72. data/vendor/assets/javascripts/webshims/shims/combos/26.js +2111 -2115
  73. data/vendor/assets/javascripts/webshims/shims/combos/27.js +3264 -3331
  74. data/vendor/assets/javascripts/webshims/shims/combos/3.js +3020 -2970
  75. data/vendor/assets/javascripts/webshims/shims/combos/4.js +770 -822
  76. data/vendor/assets/javascripts/webshims/shims/combos/5.js +1025 -1077
  77. data/vendor/assets/javascripts/webshims/shims/combos/59.js +1706 -1753
  78. data/vendor/assets/javascripts/webshims/shims/combos/6.js +444 -433
  79. data/vendor/assets/javascripts/webshims/shims/combos/7.js +699 -688
  80. data/vendor/assets/javascripts/webshims/shims/combos/8.js +1488 -1445
  81. data/vendor/assets/javascripts/webshims/shims/combos/9.js +2445 -2518
  82. data/vendor/assets/javascripts/webshims/shims/details.js +148 -146
  83. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +952 -912
  84. data/vendor/assets/javascripts/webshims/shims/es5.js +802 -802
  85. data/vendor/assets/javascripts/webshims/shims/excanvas.js +924 -924
  86. data/vendor/assets/javascripts/webshims/shims/form-core.js +606 -659
  87. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +681 -676
  88. data/vendor/assets/javascripts/webshims/shims/form-message.js +164 -163
  89. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +255 -255
  90. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +383 -383
  91. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +61 -50
  92. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +1569 -1472
  93. data/vendor/assets/javascripts/webshims/shims/geolocation.js +168 -168
  94. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ar.js +32 -32
  95. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ch-ZN.js +32 -32
  96. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-de.txt +33 -33
  97. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-el.js +32 -32
  98. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-en.txt +34 -34
  99. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-es.js +31 -31
  100. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-fr.js +32 -32
  101. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-he.js +32 -32
  102. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hi.js +32 -32
  103. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hu.js +32 -32
  104. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-it.js +32 -32
  105. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ja.js +32 -32
  106. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-nl.js +32 -32
  107. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-pt-PT.js +32 -32
  108. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ru.js +31 -31
  109. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-sv.js +32 -32
  110. data/vendor/assets/javascripts/webshims/shims/json-storage.js +308 -308
  111. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +536 -533
  112. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +861 -0
  113. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +98 -98
  114. data/vendor/assets/javascripts/webshims/shims/mediaelement-swf.js +957 -1073
  115. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +543 -543
  116. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +689 -686
  117. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  118. data/vendor/assets/javascripts/webshims/shims/track-ui.js +9 -8
  119. data/vendor/assets/javascripts/webshims/shims/track.js +17 -11
  120. metadata +6 -6
  121. data/vendor/assets/javascripts/webshims/minified/shims/form-native-fix.js +0 -7
  122. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/README +0 -62
  123. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/README +0 -82
  124. data/vendor/assets/javascripts/webshims/shims/form-native-fix.js +0 -261
@@ -1,1714 +1,1754 @@
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
-
803
- //DOM-Extension helper
804
- jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
805
- "use strict";
806
- //shortcus
807
- var modules = webshims.modules;
808
- var listReg = /\s*,\s*/;
809
-
810
- //proxying attribute
811
- var olds = {};
812
- var havePolyfill = {};
813
- var extendedProps = {};
814
- var extendQ = {};
815
- var modifyProps = {};
816
-
817
- var oldVal = $.fn.val;
818
- var singleVal = function(elem, name, val, pass, _argless){
819
- return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
820
- };
821
- $.fn.val = function(val){
822
- var elem = this[0];
823
- if(arguments.length && val == null){
824
- val = '';
825
- }
826
- if(!arguments.length){
827
- if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
828
- return $.prop(elem, 'value', val, 'val', true);
829
- }
830
- if($.isArray(val)){
831
- return oldVal.apply(this, arguments);
832
- }
833
- var isFunction = $.isFunction(val);
834
- return this.each(function(i){
835
- elem = this;
836
- if(elem.nodeType === 1){
837
- if(isFunction){
838
- var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
839
- if(genVal == null){
840
- genVal = '';
841
- }
842
- $.prop(elem, 'value', genVal, 'val') ;
843
- } else {
844
- $.prop(elem, 'value', val, 'val');
845
- }
846
- }
847
- });
848
- };
849
-
850
- var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
851
- var elementData = function(elem, key, val){
852
- elem = elem.jquery ? elem[0] : elem;
853
- if(!elem){return val || {};}
854
- var data = $.data(elem, dataID);
855
- if(val !== undefined){
856
- if(!data){
857
- data = $.data(elem, dataID, {});
858
- }
859
- if(key){
860
- data[key] = val;
861
- }
862
- }
863
-
864
- return key ? data && data[key] : data;
865
- };
866
-
867
-
868
- [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
869
- $.fn[data.name] = function(){
870
- return this.map(function(){
871
- var shadowData = elementData(this, 'shadowData');
872
- return shadowData && shadowData[data.prop] || this;
873
- });
874
- };
875
- });
876
-
877
-
878
- ['removeAttr', 'prop', 'attr'].forEach(function(type){
879
- olds[type] = $[type];
880
- $[type] = function(elem, name, value, pass, _argless){
881
- var isVal = (pass == 'val');
882
- var oldMethod = !isVal ? olds[type] : singleVal;
883
- if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
884
- return oldMethod(elem, name, value, pass, _argless);
885
- }
886
-
887
- var nodeName = (elem.nodeName || '').toLowerCase();
888
- var desc = extendedProps[nodeName];
889
- var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
890
- var propMethod;
891
- var oldValMethod;
892
- var ret;
893
-
894
-
895
- if(!desc){
896
- desc = extendedProps['*'];
897
- }
898
- if(desc){
899
- desc = desc[name];
900
- }
901
-
902
- if(desc){
903
- propMethod = desc[curType];
904
- }
905
-
906
- if(propMethod){
907
- if(name == 'value'){
908
- oldValMethod = propMethod.isVal;
909
- propMethod.isVal = isVal;
910
- }
911
- if(curType === 'removeAttr'){
912
- return propMethod.value.call(elem);
913
- } else if(value === undefined){
914
- return (propMethod.get) ?
915
- propMethod.get.call(elem) :
916
- propMethod.value
917
- ;
918
- } else if(propMethod.set) {
919
- if(type == 'attr' && value === true){
920
- value = name;
921
- }
922
-
923
- ret = propMethod.set.call(elem, value);
924
- }
925
- if(name == 'value'){
926
- propMethod.isVal = oldValMethod;
927
- }
928
- } else {
929
- ret = oldMethod(elem, name, value, pass, _argless);
930
- }
931
- if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
932
-
933
- var boolValue;
934
- if(curType == 'removeAttr'){
935
- boolValue = false;
936
- } else if(curType == 'prop'){
937
- boolValue = !!(value);
938
- } else {
939
- boolValue = true;
940
- }
941
-
942
- modifyProps[nodeName][name].forEach(function(fn){
943
- if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
944
- fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
945
- }
946
- });
947
- }
948
- return ret;
949
- };
950
-
951
- extendQ[type] = function(nodeName, prop, desc){
952
-
953
- if(!extendedProps[nodeName]){
954
- extendedProps[nodeName] = {};
955
- }
956
- if(!extendedProps[nodeName][prop]){
957
- extendedProps[nodeName][prop] = {};
958
- }
959
- var oldDesc = extendedProps[nodeName][prop][type];
960
- var getSup = function(propType, descriptor, oDesc){
961
- if(descriptor && descriptor[propType]){
962
- return descriptor[propType];
963
- }
964
- if(oDesc && oDesc[propType]){
965
- return oDesc[propType];
966
- }
967
- if(type == 'prop' && prop == 'value'){
968
- return function(value){
969
- var elem = this;
970
- return (desc.isVal) ?
971
- singleVal(elem, prop, value, false, (arguments.length === 0)) :
972
- olds[type](elem, prop, value)
973
- ;
974
- };
975
- }
976
- if(type == 'prop' && propType == 'value' && desc.value.apply){
977
- return function(value){
978
- var sup = olds[type](this, prop);
979
- if(sup && sup.apply){
980
- sup = sup.apply(this, arguments);
981
- }
982
- return sup;
983
- };
984
- }
985
- return function(value){
986
- return olds[type](this, prop, value);
987
- };
988
- };
989
- extendedProps[nodeName][prop][type] = desc;
990
- if(desc.value === undefined){
991
- if(!desc.set){
992
- desc.set = desc.writeable ?
993
- getSup('set', desc, oldDesc) :
994
- (webshims.cfg.useStrict && prop == 'prop') ?
995
- function(){throw(prop +' is readonly on '+ nodeName);} :
996
- $.noop
997
- ;
998
- }
999
- if(!desc.get){
1000
- desc.get = getSup('get', desc, oldDesc);
1001
- }
1002
-
1003
- }
1004
-
1005
- ['value', 'get', 'set'].forEach(function(descProp){
1006
- if(desc[descProp]){
1007
- desc['_sup'+descProp] = getSup(descProp, oldDesc);
1008
- }
1009
- });
1010
- };
1011
-
1012
- });
1013
-
1014
- //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
1015
- var isExtendNativeSave = (!$.browser.msie || parseInt($.browser.version, 10) > 8);
1016
- var extendNativeValue = (function(){
1017
- var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
1018
- var has = Object.prototype.hasOwnProperty;
1019
- return function(nodeName, prop, desc){
1020
- var elem = document.createElement(nodeName);
1021
- var elemProto = webshims.getPrototypeOf(elem);
1022
- if( isExtendNativeSave && elemProto && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
1023
- var sup = elem[prop];
1024
- desc._supvalue = function(){
1025
- if(sup && sup.apply){
1026
- return sup.apply(this, arguments);
1027
- }
1028
- return sup;
1029
- };
1030
- elemProto[prop] = desc.value;
1031
- } else {
1032
- desc._supvalue = function(){
1033
- var data = elementData(this, 'propValue');
1034
- if(data && data[prop] && data[prop].apply){
1035
- return data[prop].apply(this, arguments);
1036
- }
1037
- return data && data[prop];
1038
- };
1039
- initProp.extendValue(nodeName, prop, desc.value);
1040
- }
1041
- desc.value._supvalue = desc._supvalue;
1042
- };
1043
- })();
1044
-
1045
- var initProp = (function(){
1046
-
1047
- var initProps = {};
1048
-
1049
- webshims.addReady(function(context, contextElem){
1050
- var nodeNameCache = {};
1051
- var getElementsByName = function(name){
1052
- if(!nodeNameCache[name]){
1053
- nodeNameCache[name] = $(context.getElementsByTagName(name));
1054
- if(contextElem[0] && $.nodeName(contextElem[0], name)){
1055
- nodeNameCache[name] = nodeNameCache[name].add(contextElem);
1056
- }
1057
- }
1058
- };
1059
-
1060
-
1061
- $.each(initProps, function(name, fns){
1062
- getElementsByName(name);
1063
- if(!fns || !fns.forEach){
1064
- webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
1065
- return;
1066
- }
1067
- fns.forEach(function(fn){
1068
- nodeNameCache[name].each(fn);
1069
- });
1070
- });
1071
- nodeNameCache = null;
1072
- });
1073
-
1074
- var tempCache;
1075
- var emptyQ = $([]);
1076
- var createNodeNameInit = function(nodeName, fn){
1077
- if(!initProps[nodeName]){
1078
- initProps[nodeName] = [fn];
1079
- } else {
1080
- initProps[nodeName].push(fn);
1081
- }
1082
- if($.isDOMReady){
1083
- (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
1084
- }
1085
- };
1086
-
1087
- var elementExtends = {};
1088
- return {
1089
- createTmpCache: function(nodeName){
1090
- if($.isDOMReady){
1091
- tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
1092
- }
1093
- return tempCache || emptyQ;
1094
- },
1095
- flushTmpCache: function(){
1096
- tempCache = null;
1097
- },
1098
- content: function(nodeName, prop){
1099
- createNodeNameInit(nodeName, function(){
1100
- var val = $.attr(this, prop);
1101
- if(val != null){
1102
- $.attr(this, prop, val);
1103
- }
1104
- });
1105
- },
1106
- createElement: function(nodeName, fn){
1107
- createNodeNameInit(nodeName, fn);
1108
- },
1109
- extendValue: function(nodeName, prop, value){
1110
- createNodeNameInit(nodeName, function(){
1111
- $(this).each(function(){
1112
- var data = elementData(this, 'propValue', {});
1113
- data[prop] = this[prop];
1114
- this[prop] = value;
1115
- });
1116
- });
1117
- }
1118
- };
1119
- })();
1120
-
1121
- var createPropDefault = function(descs, removeType){
1122
- if(descs.defaultValue === undefined){
1123
- descs.defaultValue = '';
1124
- }
1125
- if(!descs.removeAttr){
1126
- descs.removeAttr = {
1127
- value: function(){
1128
- descs[removeType || 'prop'].set.call(this, descs.defaultValue);
1129
- descs.removeAttr._supvalue.call(this);
1130
- }
1131
- };
1132
- }
1133
- if(!descs.attr){
1134
- descs.attr = {};
1135
- }
1136
- };
1137
-
1138
- $.extend(webshims, {
1139
-
1140
- getID: (function(){
1141
- var ID = new Date().getTime();
1142
- return function(elem){
1143
- elem = $(elem);
1144
- var id = elem.attr('id');
1145
- if(!id){
1146
- ID++;
1147
- id = 'ID-'+ ID;
1148
- elem.attr('id', id);
1149
- }
1150
- return id;
1151
- };
1152
- })(),
1153
- extendUNDEFProp: function(obj, props){
1154
- $.each(props, function(name, prop){
1155
- if( !(name in obj) ){
1156
- obj[name] = prop;
1157
- }
1158
- });
1159
- },
1160
- //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
1161
- createPropDefault: createPropDefault,
1162
- data: elementData,
1163
- moveToFirstEvent: (function(){
1164
- var getData = $._data ? '_data' : 'data';
1165
- return function(elem, eventType, bindType){
1166
- var events = ($[getData](elem, 'events') || {})[eventType];
1167
- var fn;
1168
-
1169
- if(events && events.length > 1){
1170
- fn = events.pop();
1171
- if(!bindType){
1172
- bindType = 'bind';
1173
- }
1174
- if(bindType == 'bind' && events.delegateCount){
1175
- events.splice( events.delegateCount, 0, fn);
1176
- } else {
1177
- events.unshift( fn );
1178
- }
1179
-
1180
-
1181
- }
1182
- elem = null;
1183
- };
1184
- })(),
1185
- addShadowDom: (function(){
1186
- var resizeTimer;
1187
- var lastHeight;
1188
- var lastWidth;
1189
- var handler;
1190
- var docObserve = {
1191
- init: false,
1192
- start: function(){
1193
- if(!this.init && document.body){
1194
- this.init = true;
1195
- this.height = $(document).height();
1196
- this.width = $(document).width();
1197
- setInterval(function(){
1198
- var height = $(document).height();
1199
- var width = $(document).width();
1200
- if(height != docObserve.height || width != docObserve.width){
1201
- docObserve.height = height;
1202
- docObserve.width = width;
1203
- handler({type: 'docresize'});
1204
- }
1205
- }, 600);
1206
- }
1207
- }
1208
- };
1209
-
1210
- handler = function(e){
1211
- clearTimeout(resizeTimer);
1212
- resizeTimer = setTimeout(function(){
1213
- if(e.type == 'resize'){
1214
- var width = $(window).width();
1215
- var height = $(window).width();
1216
- if(height == lastHeight && width == lastWidth){
1217
- return;
1218
- }
1219
- lastHeight = height;
1220
- lastWidth = width;
1221
- if(document.body){
1222
- docObserve.height = $(document).height();
1223
- docObserve.width = $(document).width();
1224
- }
1225
- }
1226
- $.event.trigger('updateshadowdom');
1227
- }, 40);
1228
- };
1229
- $(window).bind('resize', handler);
1230
-
1231
- $.event.customEvent.updateshadowdom = true;
1232
-
1233
- return function(nativeElem, shadowElem, opts){
1234
- opts = opts || {};
1235
- if(nativeElem.jquery){
1236
- nativeElem = nativeElem[0];
1237
- }
1238
- if(shadowElem.jquery){
1239
- shadowElem = shadowElem[0];
1240
- }
1241
- var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
1242
- var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
1243
- var shadowFocusElementData = {};
1244
- if(!opts.shadowFocusElement){
1245
- opts.shadowFocusElement = shadowElem;
1246
- } else if(opts.shadowFocusElement){
1247
- if(opts.shadowFocusElement.jquery){
1248
- opts.shadowFocusElement = opts.shadowFocusElement[0];
1249
- }
1250
- shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
1251
- }
1252
-
1253
- nativeData.hasShadow = shadowElem;
1254
- shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
1255
- shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
1256
- nativeElement: nativeElem,
1257
- shadowElement: shadowElem,
1258
- shadowFocusElement: opts.shadowFocusElement
1259
- };
1260
- if(opts.shadowChilds){
1261
- opts.shadowChilds.each(function(){
1262
- elementData(this, 'shadowData', shadowData.shadowData);
1263
- });
1264
- }
1265
-
1266
- if(opts.data){
1267
- shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
1268
- }
1269
- opts = null;
1270
- webshims.ready('DOM', function(){
1271
- docObserve.start();
1272
- });
1273
- }
1274
- })(),
1275
- propTypes: {
1276
- standard: function(descs, name){
1277
- createPropDefault(descs);
1278
- if(descs.prop){return;}
1279
- descs.prop = {
1280
- set: function(val){
1281
- descs.attr.set.call(this, ''+val);
1282
- },
1283
- get: function(){
1284
- return descs.attr.get.call(this) || descs.defaultValue;
1285
- }
1286
- };
1287
-
1288
- },
1289
- "boolean": function(descs, name){
1290
-
1291
- createPropDefault(descs);
1292
- if(descs.prop){return;}
1293
- descs.prop = {
1294
- set: function(val){
1295
- if(val){
1296
- descs.attr.set.call(this, "");
1297
- } else {
1298
- descs.removeAttr.value.call(this);
1299
- }
1300
- },
1301
- get: function(){
1302
- return descs.attr.get.call(this) != null;
1303
- }
1304
- };
1305
- },
1306
- "src": (function(){
1307
- var anchor = document.createElement('a');
1308
- anchor.style.display = "none";
1309
- return function(descs, name){
1310
-
1311
- createPropDefault(descs);
1312
- if(descs.prop){return;}
1313
- descs.prop = {
1314
- set: function(val){
1315
- descs.attr.set.call(this, val);
1316
- },
1317
- get: function(){
1318
- var href = this.getAttribute(name);
1319
- var ret;
1320
- if(href == null){return '';}
1321
-
1322
- anchor.setAttribute('href', href+'' );
1323
-
1324
- if(!$.support.hrefNormalized){
1325
- try {
1326
- $(anchor).insertAfter(this);
1327
- ret = anchor.getAttribute('href', 4);
1328
- } catch(er){
1329
- ret = anchor.getAttribute('href', 4);
1330
- }
1331
- $(anchor).detach();
1332
- }
1333
- return ret || anchor.href;
1334
- }
1335
- };
1336
- };
1337
- })(),
1338
- enumarated: function(descs, name){
1339
-
1340
- createPropDefault(descs);
1341
- if(descs.prop){return;}
1342
- descs.prop = {
1343
- set: function(val){
1344
- descs.attr.set.call(this, val);
1345
- },
1346
- get: function(){
1347
- var val = (descs.attr.get.call(this) || '').toLowerCase();
1348
- if(!val || descs.limitedTo.indexOf(val) == -1){
1349
- val = descs.defaultValue;
1350
- }
1351
- return val;
1352
- }
1353
- };
1354
- }
1355
-
1356
- // ,unsignedLong: $.noop
1357
- // ,"doubble": $.noop
1358
- // ,"long": $.noop
1359
- // ,tokenlist: $.noop
1360
- // ,settableTokenlist: $.noop
1361
- },
1362
- reflectProperties: function(nodeNames, props){
1363
- if(typeof props == 'string'){
1364
- props = props.split(listReg);
1365
- }
1366
- props.forEach(function(prop){
1367
- webshims.defineNodeNamesProperty(nodeNames, prop, {
1368
- prop: {
1369
- set: function(val){
1370
- $.attr(this, prop, val);
1371
- },
1372
- get: function(){
1373
- return $.attr(this, prop) || '';
1374
- }
1375
- }
1376
- });
1377
- });
1378
- },
1379
- defineNodeNameProperty: function(nodeName, prop, descs){
1380
- havePolyfill[prop] = true;
1381
-
1382
- if(descs.reflect){
1383
- webshims.propTypes[descs.propType || 'standard'](descs, prop);
1384
- }
1385
-
1386
- ['prop', 'attr', 'removeAttr'].forEach(function(type){
1387
- var desc = descs[type];
1388
- if(desc){
1389
- if(type === 'prop'){
1390
- desc = $.extend({writeable: true}, desc);
1391
- } else {
1392
- desc = $.extend({}, desc, {writeable: true});
1393
- }
1394
-
1395
- extendQ[type](nodeName, prop, desc);
1396
- if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
1397
- extendNativeValue(nodeName, prop, desc);
1398
- }
1399
- descs[type] = desc;
1400
- }
1401
- });
1402
- if(descs.initAttr){
1403
- initProp.content(nodeName, prop);
1404
- }
1405
- return descs;
1406
- },
1407
-
1408
- defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
1409
- var olddesc;
1410
- for(var prop in descs){
1411
- if(!_noTmpCache && descs[prop].initAttr){
1412
- initProp.createTmpCache(name);
1413
- }
1414
- if(propType){
1415
- if(descs[prop][propType]){
1416
- //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
1417
- } else {
1418
- descs[prop][propType] = {};
1419
- ['value', 'set', 'get'].forEach(function(copyProp){
1420
- if(copyProp in descs[prop]){
1421
- descs[prop][propType][copyProp] = descs[prop][copyProp];
1422
- delete descs[prop][copyProp];
1423
- }
1424
- });
1425
- }
1426
- }
1427
- descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
1428
- }
1429
- if(!_noTmpCache){
1430
- initProp.flushTmpCache();
1431
- }
1432
- return descs;
1433
- },
1434
-
1435
- createElement: function(nodeName, create, descs){
1436
- var ret;
1437
- if($.isFunction(create)){
1438
- create = {
1439
- after: create
1440
- };
1441
- }
1442
- initProp.createTmpCache(nodeName);
1443
- if(create.before){
1444
- initProp.createElement(nodeName, create.before);
1445
- }
1446
- if(descs){
1447
- ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
1448
- }
1449
- if(create.after){
1450
- initProp.createElement(nodeName, create.after);
1451
- }
1452
- initProp.flushTmpCache();
1453
- return ret;
1454
- },
1455
- onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
1456
- if(typeof nodeNames == 'string'){
1457
- nodeNames = nodeNames.split(listReg);
1458
- }
1459
- if($.isFunction(desc)){
1460
- desc = {set: desc};
1461
- }
1462
-
1463
- nodeNames.forEach(function(name){
1464
- if(!modifyProps[name]){
1465
- modifyProps[name] = {};
1466
- }
1467
- if(typeof props == 'string'){
1468
- props = props.split(listReg);
1469
- }
1470
- if(desc.initAttr){
1471
- initProp.createTmpCache(name);
1472
- }
1473
- props.forEach(function(prop){
1474
- if(!modifyProps[name][prop]){
1475
- modifyProps[name][prop] = [];
1476
- havePolyfill[prop] = true;
1477
- }
1478
- if(desc.set){
1479
- if(only){
1480
- desc.set.only = only;
1481
- }
1482
- modifyProps[name][prop].push(desc.set);
1483
- }
1484
-
1485
- if(desc.initAttr){
1486
- initProp.content(name, prop);
1487
- }
1488
- });
1489
- initProp.flushTmpCache();
1490
-
1491
- });
1492
- },
1493
- defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
1494
- if(!descs){
1495
- descs = {};
1496
- }
1497
- if($.isFunction(descs)){
1498
- descs.set = descs;
1499
- }
1500
- webshims.defineNodeNamesProperty(elementNames, prop, {
1501
- attr: {
1502
- set: function(val){
1503
- this.setAttribute(prop, val);
1504
- if(descs.set){
1505
- descs.set.call(this, true);
1506
- }
1507
- },
1508
- get: function(){
1509
- var ret = this.getAttribute(prop);
1510
- return (ret == null) ? undefined : prop;
1511
- }
1512
- },
1513
- removeAttr: {
1514
- value: function(){
1515
- this.removeAttribute(prop);
1516
- if(descs.set){
1517
- descs.set.call(this, false);
1518
- }
1519
- }
1520
- },
1521
- reflect: true,
1522
- propType: 'boolean',
1523
- initAttr: descs.initAttr || false
1524
- });
1525
- },
1526
- contentAttr: function(elem, name, val){
1527
- if(!elem.nodeName){return;}
1528
- var attr;
1529
- if(val === undefined){
1530
- attr = (elem.attributes[name] || {});
1531
- val = attr.specified ? attr.value : null;
1532
- return (val == null) ? undefined : val;
1533
- }
1534
-
1535
- if(typeof val == 'boolean'){
1536
- if(!val){
1537
- elem.removeAttribute(name);
1538
- } else {
1539
- elem.setAttribute(name, name);
1540
- }
1541
- } else {
1542
- elem.setAttribute(name, val);
1543
- }
1544
- },
1545
-
1546
- // set current Lang:
1547
- // - webshims.activeLang(lang:string);
1548
- // get current lang
1549
- // - webshims.activeLang();
1550
- // get current lang
1551
- // webshims.activeLang({
1552
- // register: moduleName:string,
1553
- // callback: callback:function
1554
- // });
1555
- // get/set including removeLang
1556
- // - webshims.activeLang({
1557
- // module: moduleName:string,
1558
- // callback: callback:function,
1559
- // langObj: languageObj:array/object
1560
- // });
1561
- activeLang: (function(){
1562
- var callbacks = [];
1563
- var registeredCallbacks = {};
1564
- var currentLang;
1565
- var shortLang;
1566
- var notLocal = /:\/\/|^\.*\//;
1567
- var loadRemoteLang = function(data, lang, options){
1568
- var langSrc;
1569
- if(lang && options && $.inArray(lang, options.availabeLangs || []) !== -1){
1570
- data.loading = true;
1571
- langSrc = options.langSrc;
1572
- if(!notLocal.test(langSrc)){
1573
- langSrc = webshims.cfg.basePath+langSrc;
1574
- }
1575
- webshims.loader.loadScript(langSrc+lang+'.js', function(){
1576
- if(data.langObj[lang]){
1577
- data.loading = false;
1578
- callLang(data, true);
1579
- } else {
1580
- $(function(){
1581
- if(data.langObj[lang]){
1582
- callLang(data, true);
1583
- }
1584
- data.loading = false;
1585
- });
1586
- }
1587
- });
1588
- return true;
1589
- }
1590
- return false;
1591
- };
1592
- var callRegister = function(module){
1593
- if(registeredCallbacks[module]){
1594
- registeredCallbacks[module].forEach(function(data){
1595
- data.callback();
1596
- });
1597
- }
1598
- };
1599
- var callLang = function(data, _noLoop){
1600
- if(data.activeLang != currentLang && data.activeLang !== shortLang){
1601
- var options = modules[data.module].options;
1602
- if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
1603
- data.activeLang = currentLang;
1604
- data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
1605
- callRegister(data.module);
1606
- } else if( !_noLoop &&
1607
- !loadRemoteLang(data, currentLang, options) &&
1608
- !loadRemoteLang(data, shortLang, options) &&
1609
- data.langObj[''] && data.activeLang !== '' ) {
1610
- data.activeLang = '';
1611
- data.callback(data.langObj[''], currentLang);
1612
- callRegister(data.module);
1613
- }
1614
- }
1615
- };
1616
-
1617
-
1618
- var activeLang = function(lang){
1619
-
1620
- if(typeof lang == 'string' && lang !== currentLang){
1621
- currentLang = lang;
1622
- shortLang = currentLang.split('-')[0];
1623
- if(currentLang == shortLang){
1624
- shortLang = false;
1625
- }
1626
- $.each(callbacks, function(i, data){
1627
- callLang(data);
1628
- });
1629
- } else if(typeof lang == 'object'){
1630
-
1631
- if(lang.register){
1632
- if(!registeredCallbacks[lang.register]){
1633
- registeredCallbacks[lang.register] = [];
1634
- }
1635
- registeredCallbacks[lang.register].push(lang);
1636
- lang.callback();
1637
- } else {
1638
- if(!lang.activeLang){
1639
- lang.activeLang = '';
1640
- }
1641
- callbacks.push(lang);
1642
- callLang(lang);
1643
- }
1644
- }
1645
- return currentLang;
1646
- };
1647
-
1648
- return activeLang;
1649
- })()
1650
- });
1651
-
1652
- $.each({
1653
- defineNodeNamesProperty: 'defineNodeNameProperty',
1654
- defineNodeNamesProperties: 'defineNodeNameProperties',
1655
- createElements: 'createElement'
1656
- }, function(name, baseMethod){
1657
- webshims[name] = function(names, a, b, c){
1658
- if(typeof names == 'string'){
1659
- names = names.split(listReg);
1660
- }
1661
- var retDesc = {};
1662
- names.forEach(function(nodeName){
1663
- retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
1664
- });
1665
- return retDesc;
1666
- };
1667
- });
1668
-
1669
- webshims.isReady('webshimLocalization', true);
1670
- });
1671
- //html5a11y
1672
- (function($, document){
1673
- var browserVersion = $.webshims.browserVersion;
1674
- if($.browser.mozilla && browserVersion > 5){return;}
1675
- if (!$.browser.msie || (browserVersion < 12 && browserVersion > 7)) {
1676
- var elemMappings = {
1677
- article: "article",
1678
- aside: "complementary",
1679
- section: "region",
1680
- nav: "navigation",
1681
- address: "contentinfo"
1682
- };
1683
- var addRole = function(elem, role){
1684
- var hasRole = elem.getAttribute('role');
1685
- if (!hasRole) {
1686
- elem.setAttribute('role', role);
1687
- }
1688
- };
1689
-
1690
- $.webshims.addReady(function(context, contextElem){
1691
- $.each(elemMappings, function(name, role){
1692
- var elems = $(name, context).add(contextElem.filter(name));
1693
- for (var i = 0, len = elems.length; i < len; i++) {
1694
- addRole(elems[i], role);
1695
- }
1696
- });
1697
- if (context === document) {
1698
- var header = document.getElementsByTagName('header')[0];
1699
- var footers = document.getElementsByTagName('footer');
1700
- var footerLen = footers.length;
1701
- if (header && !$(header).closest('section, article')[0]) {
1702
- addRole(header, 'banner');
1703
- }
1704
- if (!footerLen) {
1705
- return;
1706
- }
1707
- var footer = footers[footerLen - 1];
1708
- if (!$(footer).closest('section, article')[0]) {
1709
- addRole(footer, 'contentinfo');
1710
- }
1711
- }
1712
- });
1713
- }
1714
- })(jQuery, document);
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
+
803
+ //DOM-Extension helper
804
+ jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
805
+ "use strict";
806
+ //shortcus
807
+ var modules = webshims.modules;
808
+ var listReg = /\s*,\s*/;
809
+
810
+ //proxying attribute
811
+ var olds = {};
812
+ var havePolyfill = {};
813
+ var extendedProps = {};
814
+ var extendQ = {};
815
+ var modifyProps = {};
816
+
817
+ var oldVal = $.fn.val;
818
+ var singleVal = function(elem, name, val, pass, _argless){
819
+ return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
820
+ };
821
+ $.fn.val = function(val){
822
+ var elem = this[0];
823
+ if(arguments.length && val == null){
824
+ val = '';
825
+ }
826
+ if(!arguments.length){
827
+ if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
828
+ return $.prop(elem, 'value', val, 'val', true);
829
+ }
830
+ if($.isArray(val)){
831
+ return oldVal.apply(this, arguments);
832
+ }
833
+ var isFunction = $.isFunction(val);
834
+ return this.each(function(i){
835
+ elem = this;
836
+ if(elem.nodeType === 1){
837
+ if(isFunction){
838
+ var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
839
+ if(genVal == null){
840
+ genVal = '';
841
+ }
842
+ $.prop(elem, 'value', genVal, 'val') ;
843
+ } else {
844
+ $.prop(elem, 'value', val, 'val');
845
+ }
846
+ }
847
+ });
848
+ };
849
+
850
+ var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
851
+ var elementData = function(elem, key, val){
852
+ elem = elem.jquery ? elem[0] : elem;
853
+ if(!elem){return val || {};}
854
+ var data = $.data(elem, dataID);
855
+ if(val !== undefined){
856
+ if(!data){
857
+ data = $.data(elem, dataID, {});
858
+ }
859
+ if(key){
860
+ data[key] = val;
861
+ }
862
+ }
863
+
864
+ return key ? data && data[key] : data;
865
+ };
866
+
867
+
868
+ [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
869
+ $.fn[data.name] = function(){
870
+ return this.map(function(){
871
+ var shadowData = elementData(this, 'shadowData');
872
+ return shadowData && shadowData[data.prop] || this;
873
+ });
874
+ };
875
+ });
876
+
877
+
878
+ ['removeAttr', 'prop', 'attr'].forEach(function(type){
879
+ olds[type] = $[type];
880
+ $[type] = function(elem, name, value, pass, _argless){
881
+ var isVal = (pass == 'val');
882
+ var oldMethod = !isVal ? olds[type] : singleVal;
883
+ if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
884
+ return oldMethod(elem, name, value, pass, _argless);
885
+ }
886
+
887
+ var nodeName = (elem.nodeName || '').toLowerCase();
888
+ var desc = extendedProps[nodeName];
889
+ var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
890
+ var propMethod;
891
+ var oldValMethod;
892
+ var ret;
893
+
894
+
895
+ if(!desc){
896
+ desc = extendedProps['*'];
897
+ }
898
+ if(desc){
899
+ desc = desc[name];
900
+ }
901
+
902
+ if(desc){
903
+ propMethod = desc[curType];
904
+ }
905
+
906
+ if(propMethod){
907
+ if(name == 'value'){
908
+ oldValMethod = propMethod.isVal;
909
+ propMethod.isVal = isVal;
910
+ }
911
+ if(curType === 'removeAttr'){
912
+ return propMethod.value.call(elem);
913
+ } else if(value === undefined){
914
+ return (propMethod.get) ?
915
+ propMethod.get.call(elem) :
916
+ propMethod.value
917
+ ;
918
+ } else if(propMethod.set) {
919
+ if(type == 'attr' && value === true){
920
+ value = name;
921
+ }
922
+
923
+ ret = propMethod.set.call(elem, value);
924
+ }
925
+ if(name == 'value'){
926
+ propMethod.isVal = oldValMethod;
927
+ }
928
+ } else {
929
+ ret = oldMethod(elem, name, value, pass, _argless);
930
+ }
931
+ if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
932
+
933
+ var boolValue;
934
+ if(curType == 'removeAttr'){
935
+ boolValue = false;
936
+ } else if(curType == 'prop'){
937
+ boolValue = !!(value);
938
+ } else {
939
+ boolValue = true;
940
+ }
941
+
942
+ modifyProps[nodeName][name].forEach(function(fn){
943
+ if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
944
+ fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
945
+ }
946
+ });
947
+ }
948
+ return ret;
949
+ };
950
+
951
+ extendQ[type] = function(nodeName, prop, desc){
952
+
953
+ if(!extendedProps[nodeName]){
954
+ extendedProps[nodeName] = {};
955
+ }
956
+ if(!extendedProps[nodeName][prop]){
957
+ extendedProps[nodeName][prop] = {};
958
+ }
959
+ var oldDesc = extendedProps[nodeName][prop][type];
960
+ var getSup = function(propType, descriptor, oDesc){
961
+ if(descriptor && descriptor[propType]){
962
+ return descriptor[propType];
963
+ }
964
+ if(oDesc && oDesc[propType]){
965
+ return oDesc[propType];
966
+ }
967
+ if(type == 'prop' && prop == 'value'){
968
+ return function(value){
969
+ var elem = this;
970
+ return (desc.isVal) ?
971
+ singleVal(elem, prop, value, false, (arguments.length === 0)) :
972
+ olds[type](elem, prop, value)
973
+ ;
974
+ };
975
+ }
976
+ if(type == 'prop' && propType == 'value' && desc.value.apply){
977
+ return function(value){
978
+ var sup = olds[type](this, prop);
979
+ if(sup && sup.apply){
980
+ sup = sup.apply(this, arguments);
981
+ }
982
+ return sup;
983
+ };
984
+ }
985
+ return function(value){
986
+ return olds[type](this, prop, value);
987
+ };
988
+ };
989
+ extendedProps[nodeName][prop][type] = desc;
990
+ if(desc.value === undefined){
991
+ if(!desc.set){
992
+ desc.set = desc.writeable ?
993
+ getSup('set', desc, oldDesc) :
994
+ (webshims.cfg.useStrict && prop == 'prop') ?
995
+ function(){throw(prop +' is readonly on '+ nodeName);} :
996
+ $.noop
997
+ ;
998
+ }
999
+ if(!desc.get){
1000
+ desc.get = getSup('get', desc, oldDesc);
1001
+ }
1002
+
1003
+ }
1004
+
1005
+ ['value', 'get', 'set'].forEach(function(descProp){
1006
+ if(desc[descProp]){
1007
+ desc['_sup'+descProp] = getSup(descProp, oldDesc);
1008
+ }
1009
+ });
1010
+ };
1011
+
1012
+ });
1013
+
1014
+ //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
1015
+ var isExtendNativeSave = (!$.browser.msie || parseInt($.browser.version, 10) > 8);
1016
+ var extendNativeValue = (function(){
1017
+ var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
1018
+ var has = Object.prototype.hasOwnProperty;
1019
+ return function(nodeName, prop, desc){
1020
+ var elem = document.createElement(nodeName);
1021
+ var elemProto = webshims.getPrototypeOf(elem);
1022
+ if( isExtendNativeSave && elemProto && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
1023
+ var sup = elem[prop];
1024
+ desc._supvalue = function(){
1025
+ if(sup && sup.apply){
1026
+ return sup.apply(this, arguments);
1027
+ }
1028
+ return sup;
1029
+ };
1030
+ elemProto[prop] = desc.value;
1031
+ } else {
1032
+ desc._supvalue = function(){
1033
+ var data = elementData(this, 'propValue');
1034
+ if(data && data[prop] && data[prop].apply){
1035
+ return data[prop].apply(this, arguments);
1036
+ }
1037
+ return data && data[prop];
1038
+ };
1039
+ initProp.extendValue(nodeName, prop, desc.value);
1040
+ }
1041
+ desc.value._supvalue = desc._supvalue;
1042
+ };
1043
+ })();
1044
+
1045
+ var initProp = (function(){
1046
+
1047
+ var initProps = {};
1048
+
1049
+ webshims.addReady(function(context, contextElem){
1050
+ var nodeNameCache = {};
1051
+ var getElementsByName = function(name){
1052
+ if(!nodeNameCache[name]){
1053
+ nodeNameCache[name] = $(context.getElementsByTagName(name));
1054
+ if(contextElem[0] && $.nodeName(contextElem[0], name)){
1055
+ nodeNameCache[name] = nodeNameCache[name].add(contextElem);
1056
+ }
1057
+ }
1058
+ };
1059
+
1060
+
1061
+ $.each(initProps, function(name, fns){
1062
+ getElementsByName(name);
1063
+ if(!fns || !fns.forEach){
1064
+ webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
1065
+ return;
1066
+ }
1067
+ fns.forEach(function(fn){
1068
+ nodeNameCache[name].each(fn);
1069
+ });
1070
+ });
1071
+ nodeNameCache = null;
1072
+ });
1073
+
1074
+ var tempCache;
1075
+ var emptyQ = $([]);
1076
+ var createNodeNameInit = function(nodeName, fn){
1077
+ if(!initProps[nodeName]){
1078
+ initProps[nodeName] = [fn];
1079
+ } else {
1080
+ initProps[nodeName].push(fn);
1081
+ }
1082
+ if($.isDOMReady){
1083
+ (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
1084
+ }
1085
+ };
1086
+
1087
+ var elementExtends = {};
1088
+ return {
1089
+ createTmpCache: function(nodeName){
1090
+ if($.isDOMReady){
1091
+ tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
1092
+ }
1093
+ return tempCache || emptyQ;
1094
+ },
1095
+ flushTmpCache: function(){
1096
+ tempCache = null;
1097
+ },
1098
+ content: function(nodeName, prop){
1099
+ createNodeNameInit(nodeName, function(){
1100
+ var val = $.attr(this, prop);
1101
+ if(val != null){
1102
+ $.attr(this, prop, val);
1103
+ }
1104
+ });
1105
+ },
1106
+ createElement: function(nodeName, fn){
1107
+ createNodeNameInit(nodeName, fn);
1108
+ },
1109
+ extendValue: function(nodeName, prop, value){
1110
+ createNodeNameInit(nodeName, function(){
1111
+ $(this).each(function(){
1112
+ var data = elementData(this, 'propValue', {});
1113
+ data[prop] = this[prop];
1114
+ this[prop] = value;
1115
+ });
1116
+ });
1117
+ }
1118
+ };
1119
+ })();
1120
+
1121
+ var createPropDefault = function(descs, removeType){
1122
+ if(descs.defaultValue === undefined){
1123
+ descs.defaultValue = '';
1124
+ }
1125
+ if(!descs.removeAttr){
1126
+ descs.removeAttr = {
1127
+ value: function(){
1128
+ descs[removeType || 'prop'].set.call(this, descs.defaultValue);
1129
+ descs.removeAttr._supvalue.call(this);
1130
+ }
1131
+ };
1132
+ }
1133
+ if(!descs.attr){
1134
+ descs.attr = {};
1135
+ }
1136
+ };
1137
+
1138
+ $.extend(webshims, {
1139
+
1140
+ getID: (function(){
1141
+ var ID = new Date().getTime();
1142
+ return function(elem){
1143
+ elem = $(elem);
1144
+ var id = elem.attr('id');
1145
+ if(!id){
1146
+ ID++;
1147
+ id = 'ID-'+ ID;
1148
+ elem.attr('id', id);
1149
+ }
1150
+ return id;
1151
+ };
1152
+ })(),
1153
+ extendUNDEFProp: function(obj, props){
1154
+ $.each(props, function(name, prop){
1155
+ if( !(name in obj) ){
1156
+ obj[name] = prop;
1157
+ }
1158
+ });
1159
+ },
1160
+ //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
1161
+ createPropDefault: createPropDefault,
1162
+ data: elementData,
1163
+ moveToFirstEvent: (function(){
1164
+ var getData = $._data ? '_data' : 'data';
1165
+ return function(elem, eventType, bindType){
1166
+ var events = ($[getData](elem, 'events') || {})[eventType];
1167
+ var fn;
1168
+
1169
+ if(events && events.length > 1){
1170
+ fn = events.pop();
1171
+ if(!bindType){
1172
+ bindType = 'bind';
1173
+ }
1174
+ if(bindType == 'bind' && events.delegateCount){
1175
+ events.splice( events.delegateCount, 0, fn);
1176
+ } else {
1177
+ events.unshift( fn );
1178
+ }
1179
+
1180
+
1181
+ }
1182
+ elem = null;
1183
+ };
1184
+ })(),
1185
+ addShadowDom: (function(){
1186
+ var resizeTimer;
1187
+ var lastHeight;
1188
+ var lastWidth;
1189
+
1190
+ var docObserve = {
1191
+ init: false,
1192
+ runs: 0,
1193
+ test: function(){
1194
+ var height = docObserve.getHeight();
1195
+ var width = docObserve.getWidth();
1196
+ if(height != docObserve.height || width != docObserve.width){
1197
+ docObserve.height = height;
1198
+ docObserve.width = width;
1199
+ docObserve.handler({type: 'docresize'});
1200
+ docObserve.runs++;
1201
+ if(docObserve.runs < 30){
1202
+ setTimeout(docObserve.test, 30);
1203
+ }
1204
+ } else {
1205
+ docObserve.runs = 0;
1206
+ }
1207
+ },
1208
+ handler: function(e){
1209
+ clearTimeout(resizeTimer);
1210
+ resizeTimer = setTimeout(function(){
1211
+ if(e.type == 'resize'){
1212
+ var width = $(window).width();
1213
+ var height = $(window).width();
1214
+ if(height == lastHeight && width == lastWidth){
1215
+ return;
1216
+ }
1217
+ lastHeight = height;
1218
+ lastWidth = width;
1219
+
1220
+ docObserve.height = docObserve.getHeight();
1221
+ docObserve.width = docObserve.getWidth();
1222
+
1223
+ }
1224
+ $.event.trigger('updateshadowdom');
1225
+ }, (e.type == 'resize') ? 50 : 9);
1226
+ },
1227
+ _create: function(){
1228
+ $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
1229
+ var body = document.body;
1230
+ var doc = document.documentElement;
1231
+ docObserve[type] = function(){
1232
+ return Math.max(
1233
+ body[ "scroll" + name ], doc[ "scroll" + name ],
1234
+ body[ "offset" + name ], doc[ "offset" + name ],
1235
+ doc[ "client" + name ]
1236
+ );
1237
+ };
1238
+ });
1239
+ },
1240
+ start: function(){
1241
+ if(!this.init && document.body){
1242
+ this.init = true;
1243
+ this._create();
1244
+ this.height = docObserve.getHeight();
1245
+ this.width = docObserve.getWidth();
1246
+ setInterval(this.test, 400);
1247
+ $(this.test);
1248
+ $(window).bind('load', this.test);
1249
+ $(window).bind('resize', this.handler);
1250
+ (function(){
1251
+ var oldAnimate = $.fn.animate;
1252
+ var animationTimer;
1253
+
1254
+ $.fn.animate = function(){
1255
+ clearTimeout(animationTimer);
1256
+ animationTimer = setTimeout(function(){
1257
+ docObserve.test();
1258
+ docObserve.handler({type: 'animationstart'});
1259
+ }, 19);
1260
+
1261
+ return oldAnimate.apply(this, arguments);
1262
+ };
1263
+ })();
1264
+ }
1265
+ }
1266
+ };
1267
+
1268
+
1269
+ $.event.customEvent.updateshadowdom = true;
1270
+ webshims.docObserve = function(){
1271
+ webshims.ready('DOM', function(){
1272
+ docObserve.start();
1273
+ });
1274
+ };
1275
+ return function(nativeElem, shadowElem, opts){
1276
+ opts = opts || {};
1277
+ if(nativeElem.jquery){
1278
+ nativeElem = nativeElem[0];
1279
+ }
1280
+ if(shadowElem.jquery){
1281
+ shadowElem = shadowElem[0];
1282
+ }
1283
+ var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
1284
+ var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
1285
+ var shadowFocusElementData = {};
1286
+ if(!opts.shadowFocusElement){
1287
+ opts.shadowFocusElement = shadowElem;
1288
+ } else if(opts.shadowFocusElement){
1289
+ if(opts.shadowFocusElement.jquery){
1290
+ opts.shadowFocusElement = opts.shadowFocusElement[0];
1291
+ }
1292
+ shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
1293
+ }
1294
+
1295
+ nativeData.hasShadow = shadowElem;
1296
+ shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
1297
+ shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
1298
+ nativeElement: nativeElem,
1299
+ shadowElement: shadowElem,
1300
+ shadowFocusElement: opts.shadowFocusElement
1301
+ };
1302
+ if(opts.shadowChilds){
1303
+ opts.shadowChilds.each(function(){
1304
+ elementData(this, 'shadowData', shadowData.shadowData);
1305
+ });
1306
+ }
1307
+
1308
+ if(opts.data){
1309
+ shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
1310
+ }
1311
+ opts = null;
1312
+ webshims.docObserve();
1313
+ };
1314
+ })(),
1315
+ propTypes: {
1316
+ standard: function(descs, name){
1317
+ createPropDefault(descs);
1318
+ if(descs.prop){return;}
1319
+ descs.prop = {
1320
+ set: function(val){
1321
+ descs.attr.set.call(this, ''+val);
1322
+ },
1323
+ get: function(){
1324
+ return descs.attr.get.call(this) || descs.defaultValue;
1325
+ }
1326
+ };
1327
+
1328
+ },
1329
+ "boolean": function(descs, name){
1330
+
1331
+ createPropDefault(descs);
1332
+ if(descs.prop){return;}
1333
+ descs.prop = {
1334
+ set: function(val){
1335
+ if(val){
1336
+ descs.attr.set.call(this, "");
1337
+ } else {
1338
+ descs.removeAttr.value.call(this);
1339
+ }
1340
+ },
1341
+ get: function(){
1342
+ return descs.attr.get.call(this) != null;
1343
+ }
1344
+ };
1345
+ },
1346
+ "src": (function(){
1347
+ var anchor = document.createElement('a');
1348
+ anchor.style.display = "none";
1349
+ return function(descs, name){
1350
+
1351
+ createPropDefault(descs);
1352
+ if(descs.prop){return;}
1353
+ descs.prop = {
1354
+ set: function(val){
1355
+ descs.attr.set.call(this, val);
1356
+ },
1357
+ get: function(){
1358
+ var href = this.getAttribute(name);
1359
+ var ret;
1360
+ if(href == null){return '';}
1361
+
1362
+ anchor.setAttribute('href', href+'' );
1363
+
1364
+ if(!$.support.hrefNormalized){
1365
+ try {
1366
+ $(anchor).insertAfter(this);
1367
+ ret = anchor.getAttribute('href', 4);
1368
+ } catch(er){
1369
+ ret = anchor.getAttribute('href', 4);
1370
+ }
1371
+ $(anchor).detach();
1372
+ }
1373
+ return ret || anchor.href;
1374
+ }
1375
+ };
1376
+ };
1377
+ })(),
1378
+ enumarated: function(descs, name){
1379
+
1380
+ createPropDefault(descs);
1381
+ if(descs.prop){return;}
1382
+ descs.prop = {
1383
+ set: function(val){
1384
+ descs.attr.set.call(this, val);
1385
+ },
1386
+ get: function(){
1387
+ var val = (descs.attr.get.call(this) || '').toLowerCase();
1388
+ if(!val || descs.limitedTo.indexOf(val) == -1){
1389
+ val = descs.defaultValue;
1390
+ }
1391
+ return val;
1392
+ }
1393
+ };
1394
+ }
1395
+
1396
+ // ,unsignedLong: $.noop
1397
+ // ,"doubble": $.noop
1398
+ // ,"long": $.noop
1399
+ // ,tokenlist: $.noop
1400
+ // ,settableTokenlist: $.noop
1401
+ },
1402
+ reflectProperties: function(nodeNames, props){
1403
+ if(typeof props == 'string'){
1404
+ props = props.split(listReg);
1405
+ }
1406
+ props.forEach(function(prop){
1407
+ webshims.defineNodeNamesProperty(nodeNames, prop, {
1408
+ prop: {
1409
+ set: function(val){
1410
+ $.attr(this, prop, val);
1411
+ },
1412
+ get: function(){
1413
+ return $.attr(this, prop) || '';
1414
+ }
1415
+ }
1416
+ });
1417
+ });
1418
+ },
1419
+ defineNodeNameProperty: function(nodeName, prop, descs){
1420
+ havePolyfill[prop] = true;
1421
+
1422
+ if(descs.reflect){
1423
+ webshims.propTypes[descs.propType || 'standard'](descs, prop);
1424
+ }
1425
+
1426
+ ['prop', 'attr', 'removeAttr'].forEach(function(type){
1427
+ var desc = descs[type];
1428
+ if(desc){
1429
+ if(type === 'prop'){
1430
+ desc = $.extend({writeable: true}, desc);
1431
+ } else {
1432
+ desc = $.extend({}, desc, {writeable: true});
1433
+ }
1434
+
1435
+ extendQ[type](nodeName, prop, desc);
1436
+ if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
1437
+ extendNativeValue(nodeName, prop, desc);
1438
+ }
1439
+ descs[type] = desc;
1440
+ }
1441
+ });
1442
+ if(descs.initAttr){
1443
+ initProp.content(nodeName, prop);
1444
+ }
1445
+ return descs;
1446
+ },
1447
+
1448
+ defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
1449
+ var olddesc;
1450
+ for(var prop in descs){
1451
+ if(!_noTmpCache && descs[prop].initAttr){
1452
+ initProp.createTmpCache(name);
1453
+ }
1454
+ if(propType){
1455
+ if(descs[prop][propType]){
1456
+ //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
1457
+ } else {
1458
+ descs[prop][propType] = {};
1459
+ ['value', 'set', 'get'].forEach(function(copyProp){
1460
+ if(copyProp in descs[prop]){
1461
+ descs[prop][propType][copyProp] = descs[prop][copyProp];
1462
+ delete descs[prop][copyProp];
1463
+ }
1464
+ });
1465
+ }
1466
+ }
1467
+ descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
1468
+ }
1469
+ if(!_noTmpCache){
1470
+ initProp.flushTmpCache();
1471
+ }
1472
+ return descs;
1473
+ },
1474
+
1475
+ createElement: function(nodeName, create, descs){
1476
+ var ret;
1477
+ if($.isFunction(create)){
1478
+ create = {
1479
+ after: create
1480
+ };
1481
+ }
1482
+ initProp.createTmpCache(nodeName);
1483
+ if(create.before){
1484
+ initProp.createElement(nodeName, create.before);
1485
+ }
1486
+ if(descs){
1487
+ ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
1488
+ }
1489
+ if(create.after){
1490
+ initProp.createElement(nodeName, create.after);
1491
+ }
1492
+ initProp.flushTmpCache();
1493
+ return ret;
1494
+ },
1495
+ onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
1496
+ if(typeof nodeNames == 'string'){
1497
+ nodeNames = nodeNames.split(listReg);
1498
+ }
1499
+ if($.isFunction(desc)){
1500
+ desc = {set: desc};
1501
+ }
1502
+
1503
+ nodeNames.forEach(function(name){
1504
+ if(!modifyProps[name]){
1505
+ modifyProps[name] = {};
1506
+ }
1507
+ if(typeof props == 'string'){
1508
+ props = props.split(listReg);
1509
+ }
1510
+ if(desc.initAttr){
1511
+ initProp.createTmpCache(name);
1512
+ }
1513
+ props.forEach(function(prop){
1514
+ if(!modifyProps[name][prop]){
1515
+ modifyProps[name][prop] = [];
1516
+ havePolyfill[prop] = true;
1517
+ }
1518
+ if(desc.set){
1519
+ if(only){
1520
+ desc.set.only = only;
1521
+ }
1522
+ modifyProps[name][prop].push(desc.set);
1523
+ }
1524
+
1525
+ if(desc.initAttr){
1526
+ initProp.content(name, prop);
1527
+ }
1528
+ });
1529
+ initProp.flushTmpCache();
1530
+
1531
+ });
1532
+ },
1533
+ defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
1534
+ if(!descs){
1535
+ descs = {};
1536
+ }
1537
+ if($.isFunction(descs)){
1538
+ descs.set = descs;
1539
+ }
1540
+ webshims.defineNodeNamesProperty(elementNames, prop, {
1541
+ attr: {
1542
+ set: function(val){
1543
+ this.setAttribute(prop, val);
1544
+ if(descs.set){
1545
+ descs.set.call(this, true);
1546
+ }
1547
+ },
1548
+ get: function(){
1549
+ var ret = this.getAttribute(prop);
1550
+ return (ret == null) ? undefined : prop;
1551
+ }
1552
+ },
1553
+ removeAttr: {
1554
+ value: function(){
1555
+ this.removeAttribute(prop);
1556
+ if(descs.set){
1557
+ descs.set.call(this, false);
1558
+ }
1559
+ }
1560
+ },
1561
+ reflect: true,
1562
+ propType: 'boolean',
1563
+ initAttr: descs.initAttr || false
1564
+ });
1565
+ },
1566
+ contentAttr: function(elem, name, val){
1567
+ if(!elem.nodeName){return;}
1568
+ var attr;
1569
+ if(val === undefined){
1570
+ attr = (elem.attributes[name] || {});
1571
+ val = attr.specified ? attr.value : null;
1572
+ return (val == null) ? undefined : val;
1573
+ }
1574
+
1575
+ if(typeof val == 'boolean'){
1576
+ if(!val){
1577
+ elem.removeAttribute(name);
1578
+ } else {
1579
+ elem.setAttribute(name, name);
1580
+ }
1581
+ } else {
1582
+ elem.setAttribute(name, val);
1583
+ }
1584
+ },
1585
+
1586
+ // set current Lang:
1587
+ // - webshims.activeLang(lang:string);
1588
+ // get current lang
1589
+ // - webshims.activeLang();
1590
+ // get current lang
1591
+ // webshims.activeLang({
1592
+ // register: moduleName:string,
1593
+ // callback: callback:function
1594
+ // });
1595
+ // get/set including removeLang
1596
+ // - webshims.activeLang({
1597
+ // module: moduleName:string,
1598
+ // callback: callback:function,
1599
+ // langObj: languageObj:array/object
1600
+ // });
1601
+ activeLang: (function(){
1602
+ var callbacks = [];
1603
+ var registeredCallbacks = {};
1604
+ var currentLang;
1605
+ var shortLang;
1606
+ var notLocal = /:\/\/|^\.*\//;
1607
+ var loadRemoteLang = function(data, lang, options){
1608
+ var langSrc;
1609
+ if(lang && options && $.inArray(lang, options.availabeLangs || []) !== -1){
1610
+ data.loading = true;
1611
+ langSrc = options.langSrc;
1612
+ if(!notLocal.test(langSrc)){
1613
+ langSrc = webshims.cfg.basePath+langSrc;
1614
+ }
1615
+ webshims.loader.loadScript(langSrc+lang+'.js', function(){
1616
+ if(data.langObj[lang]){
1617
+ data.loading = false;
1618
+ callLang(data, true);
1619
+ } else {
1620
+ $(function(){
1621
+ if(data.langObj[lang]){
1622
+ callLang(data, true);
1623
+ }
1624
+ data.loading = false;
1625
+ });
1626
+ }
1627
+ });
1628
+ return true;
1629
+ }
1630
+ return false;
1631
+ };
1632
+ var callRegister = function(module){
1633
+ if(registeredCallbacks[module]){
1634
+ registeredCallbacks[module].forEach(function(data){
1635
+ data.callback();
1636
+ });
1637
+ }
1638
+ };
1639
+ var callLang = function(data, _noLoop){
1640
+ if(data.activeLang != currentLang && data.activeLang !== shortLang){
1641
+ var options = modules[data.module].options;
1642
+ if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
1643
+ data.activeLang = currentLang;
1644
+ data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
1645
+ callRegister(data.module);
1646
+ } else if( !_noLoop &&
1647
+ !loadRemoteLang(data, currentLang, options) &&
1648
+ !loadRemoteLang(data, shortLang, options) &&
1649
+ data.langObj[''] && data.activeLang !== '' ) {
1650
+ data.activeLang = '';
1651
+ data.callback(data.langObj[''], currentLang);
1652
+ callRegister(data.module);
1653
+ }
1654
+ }
1655
+ };
1656
+
1657
+
1658
+ var activeLang = function(lang){
1659
+
1660
+ if(typeof lang == 'string' && lang !== currentLang){
1661
+ currentLang = lang;
1662
+ shortLang = currentLang.split('-')[0];
1663
+ if(currentLang == shortLang){
1664
+ shortLang = false;
1665
+ }
1666
+ $.each(callbacks, function(i, data){
1667
+ callLang(data);
1668
+ });
1669
+ } else if(typeof lang == 'object'){
1670
+
1671
+ if(lang.register){
1672
+ if(!registeredCallbacks[lang.register]){
1673
+ registeredCallbacks[lang.register] = [];
1674
+ }
1675
+ registeredCallbacks[lang.register].push(lang);
1676
+ lang.callback();
1677
+ } else {
1678
+ if(!lang.activeLang){
1679
+ lang.activeLang = '';
1680
+ }
1681
+ callbacks.push(lang);
1682
+ callLang(lang);
1683
+ }
1684
+ }
1685
+ return currentLang;
1686
+ };
1687
+
1688
+ return activeLang;
1689
+ })()
1690
+ });
1691
+
1692
+ $.each({
1693
+ defineNodeNamesProperty: 'defineNodeNameProperty',
1694
+ defineNodeNamesProperties: 'defineNodeNameProperties',
1695
+ createElements: 'createElement'
1696
+ }, function(name, baseMethod){
1697
+ webshims[name] = function(names, a, b, c){
1698
+ if(typeof names == 'string'){
1699
+ names = names.split(listReg);
1700
+ }
1701
+ var retDesc = {};
1702
+ names.forEach(function(nodeName){
1703
+ retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
1704
+ });
1705
+ return retDesc;
1706
+ };
1707
+ });
1708
+
1709
+ webshims.isReady('webshimLocalization', true);
1710
+ });
1711
+ //html5a11y
1712
+ (function($, document){
1713
+ var browserVersion = $.webshims.browserVersion;
1714
+ if($.browser.mozilla && browserVersion > 5){return;}
1715
+ if (!$.browser.msie || (browserVersion < 12 && browserVersion > 7)) {
1716
+ var elemMappings = {
1717
+ article: "article",
1718
+ aside: "complementary",
1719
+ section: "region",
1720
+ nav: "navigation",
1721
+ address: "contentinfo"
1722
+ };
1723
+ var addRole = function(elem, role){
1724
+ var hasRole = elem.getAttribute('role');
1725
+ if (!hasRole) {
1726
+ elem.setAttribute('role', role);
1727
+ }
1728
+ };
1729
+
1730
+ $.webshims.addReady(function(context, contextElem){
1731
+ $.each(elemMappings, function(name, role){
1732
+ var elems = $(name, context).add(contextElem.filter(name));
1733
+ for (var i = 0, len = elems.length; i < len; i++) {
1734
+ addRole(elems[i], role);
1735
+ }
1736
+ });
1737
+ if (context === document) {
1738
+ var header = document.getElementsByTagName('header')[0];
1739
+ var footers = document.getElementsByTagName('footer');
1740
+ var footerLen = footers.length;
1741
+ if (header && !$(header).closest('section, article')[0]) {
1742
+ addRole(header, 'banner');
1743
+ }
1744
+ if (!footerLen) {
1745
+ return;
1746
+ }
1747
+ var footer = footers[footerLen - 1];
1748
+ if (!$(footer).closest('section, article')[0]) {
1749
+ addRole(footer, 'contentinfo');
1750
+ }
1751
+ }
1752
+ });
1753
+ }
1754
+ })(jQuery, document);