webshims-rails 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/lib/webshims-rails/version.rb +2 -2
  2. data/vendor/assets/javascripts/webshims/extras/custom-validity.js +253 -253
  3. data/vendor/assets/javascripts/webshims/extras/modernizr-custom.js +534 -534
  4. data/vendor/assets/javascripts/webshims/extras/mousepress.js +60 -60
  5. data/vendor/assets/javascripts/webshims/minified/polyfiller.js +1 -1
  6. data/vendor/assets/javascripts/webshims/minified/shims/combos/10.js +1 -1
  7. data/vendor/assets/javascripts/webshims/minified/shims/combos/12.js +1 -1
  8. data/vendor/assets/javascripts/webshims/minified/shims/combos/16.js +1 -1
  9. data/vendor/assets/javascripts/webshims/minified/shims/combos/17.js +1 -1
  10. data/vendor/assets/javascripts/webshims/minified/shims/combos/19.js +1 -1
  11. data/vendor/assets/javascripts/webshims/minified/shims/combos/2.js +1 -1
  12. data/vendor/assets/javascripts/webshims/minified/shims/combos/20.js +1 -1
  13. data/vendor/assets/javascripts/webshims/minified/shims/combos/21.js +1 -1
  14. data/vendor/assets/javascripts/webshims/minified/shims/combos/22.js +1 -1
  15. data/vendor/assets/javascripts/webshims/minified/shims/combos/23.js +1 -1
  16. data/vendor/assets/javascripts/webshims/minified/shims/combos/24.js +1 -1
  17. data/vendor/assets/javascripts/webshims/minified/shims/combos/25.js +1 -1
  18. data/vendor/assets/javascripts/webshims/minified/shims/combos/26.js +1 -1
  19. data/vendor/assets/javascripts/webshims/minified/shims/combos/27.js +1 -1
  20. data/vendor/assets/javascripts/webshims/minified/shims/combos/3.js +1 -1
  21. data/vendor/assets/javascripts/webshims/minified/shims/combos/4.js +1 -1
  22. data/vendor/assets/javascripts/webshims/minified/shims/combos/5.js +1 -1
  23. data/vendor/assets/javascripts/webshims/minified/shims/combos/59.js +1 -1
  24. data/vendor/assets/javascripts/webshims/minified/shims/combos/8.js +1 -1
  25. data/vendor/assets/javascripts/webshims/minified/shims/combos/9.js +1 -1
  26. data/vendor/assets/javascripts/webshims/minified/shims/form-core.js +1 -1
  27. data/vendor/assets/javascripts/webshims/minified/shims/form-message.js +1 -1
  28. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-de.txt +33 -33
  29. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-en.txt +34 -34
  30. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-core.js +1 -1
  31. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-jaris.js +1 -1
  32. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-swf.js +1 -1
  33. data/vendor/assets/javascripts/webshims/minified/shims/swf/JarisFLVPlayer.swf +0 -0
  34. data/vendor/assets/javascripts/webshims/polyfiller.js +1188 -1188
  35. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/README +82 -82
  36. data/vendor/assets/javascripts/webshims/shims/combos/1.js +1752 -1752
  37. data/vendor/assets/javascripts/webshims/shims/combos/10.js +3310 -3311
  38. data/vendor/assets/javascripts/webshims/shims/combos/11.js +1631 -1631
  39. data/vendor/assets/javascripts/webshims/shims/combos/12.js +1695 -1696
  40. data/vendor/assets/javascripts/webshims/shims/combos/13.js +1098 -1098
  41. data/vendor/assets/javascripts/webshims/shims/combos/14.js +477 -477
  42. data/vendor/assets/javascripts/webshims/shims/combos/15.js +317 -317
  43. data/vendor/assets/javascripts/webshims/shims/combos/16.js +2177 -2154
  44. data/vendor/assets/javascripts/webshims/shims/combos/17.js +2354 -2319
  45. data/vendor/assets/javascripts/webshims/shims/combos/18.js +1322 -1322
  46. data/vendor/assets/javascripts/webshims/shims/combos/19.js +2262 -2238
  47. data/vendor/assets/javascripts/webshims/shims/combos/2.js +2376 -2340
  48. data/vendor/assets/javascripts/webshims/shims/combos/20.js +1557 -1558
  49. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1745 -1733
  50. data/vendor/assets/javascripts/webshims/shims/combos/22.js +2360 -2361
  51. data/vendor/assets/javascripts/webshims/shims/combos/23.js +2342 -2331
  52. data/vendor/assets/javascripts/webshims/shims/combos/24.js +2859 -2836
  53. data/vendor/assets/javascripts/webshims/shims/combos/25.js +1547 -1548
  54. data/vendor/assets/javascripts/webshims/shims/combos/26.js +2178 -2155
  55. data/vendor/assets/javascripts/webshims/shims/combos/27.js +3311 -3312
  56. data/vendor/assets/javascripts/webshims/shims/combos/3.js +3058 -3022
  57. data/vendor/assets/javascripts/webshims/shims/combos/4.js +807 -771
  58. data/vendor/assets/javascripts/webshims/shims/combos/5.js +1063 -1027
  59. data/vendor/assets/javascripts/webshims/shims/combos/59.js +1745 -1709
  60. data/vendor/assets/javascripts/webshims/shims/combos/6.js +384 -384
  61. data/vendor/assets/javascripts/webshims/shims/combos/7.js +640 -640
  62. data/vendor/assets/javascripts/webshims/shims/combos/8.js +1546 -1547
  63. data/vendor/assets/javascripts/webshims/shims/combos/9.js +2507 -2508
  64. data/vendor/assets/javascripts/webshims/shims/details.js +148 -148
  65. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +949 -949
  66. data/vendor/assets/javascripts/webshims/shims/es5.js +802 -802
  67. data/vendor/assets/javascripts/webshims/shims/excanvas.js +924 -924
  68. data/vendor/assets/javascripts/webshims/shims/form-core.js +630 -606
  69. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +681 -681
  70. data/vendor/assets/javascripts/webshims/shims/form-message.js +176 -164
  71. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +255 -255
  72. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +383 -383
  73. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +1568 -1568
  74. data/vendor/assets/javascripts/webshims/shims/geolocation.js +168 -168
  75. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ar.js +32 -32
  76. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ch-ZN.js +32 -32
  77. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-de.txt +33 -33
  78. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-el.js +32 -32
  79. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-en.txt +34 -34
  80. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-es.js +31 -31
  81. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-fr.js +32 -32
  82. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-he.js +32 -32
  83. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hi.js +32 -32
  84. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hu.js +32 -32
  85. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-it.js +32 -32
  86. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ja.js +32 -32
  87. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-nl.js +32 -32
  88. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-pt-PT.js +32 -32
  89. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ru.js +31 -31
  90. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-sv.js +32 -32
  91. data/vendor/assets/javascripts/webshims/shims/json-storage.js +308 -308
  92. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +596 -597
  93. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +891 -891
  94. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +98 -98
  95. data/vendor/assets/javascripts/webshims/shims/mediaelement-swf.js +960 -960
  96. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +543 -543
  97. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +697 -697
  98. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  99. metadata +2 -4
  100. data/vendor/assets/javascripts/webshims/minified/shims/range-ui.js +0 -1
  101. data/vendor/assets/javascripts/webshims/shims/range-ui.js +0 -66
@@ -1,2362 +1,2361 @@
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
-
804
- (function($, Modernizr, webshims){
805
- "use strict";
806
- var hasNative = Modernizr.audio && Modernizr.video;
807
- var supportsLoop = false;
808
- var bugs = webshims.bugs;
809
-
810
- var loadSwf = function(){
811
- webshims.ready(swfType, function(){
812
- if(!webshims.mediaelement.createSWF){
813
- webshims.mediaelement.loadSwf = true;
814
- webshims.reTest([swfType], hasNative);
815
- }
816
- });
817
- };
818
- var options = webshims.cfg.mediaelement;
819
- var swfType = options && options.player == 'jwplayer' ? 'mediaelement-swf' : 'mediaelement-jaris';
820
- var hasSwf;
821
- if(!options){
822
- webshims.error("mediaelement wasn't implemented but loaded");
823
- return;
824
- }
825
- if(hasNative){
826
- var videoElem = document.createElement('video');
827
- Modernizr.videoBuffered = ('buffered' in videoElem);
828
- supportsLoop = ('loop' in videoElem);
829
-
830
- webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
831
-
832
- if(!Modernizr.videoBuffered){
833
- webshims.addPolyfill('mediaelement-native-fix', {
834
- f: 'mediaelement',
835
- test: Modernizr.videoBuffered,
836
- d: ['dom-support']
837
- });
838
-
839
- webshims.reTest('mediaelement-native-fix');
840
- }
841
- }
842
-
843
- if(hasNative && !options.preferFlash){
844
- var switchOptions = function(e){
845
- var parent = e.target.parentNode;
846
- if(!options.preferFlash && ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) ){
847
- webshims.ready('DOM mediaelement', function(){
848
- if(hasSwf){
849
- loadSwf();
850
- }
851
- webshims.ready('WINDOWLOAD '+swfType, function(){
852
- setTimeout(function(){
853
- if(hasSwf && !options.preferFlash && webshims.mediaelement.createSWF && !$(e.target).closest('audio, video').is('.nonnative-api-active')){
854
- options.preferFlash = true;
855
- document.removeEventListener('error', switchOptions, true);
856
- $('audio, video').mediaLoad();
857
- webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src);
858
- } else if(!hasSwf){
859
- document.removeEventListener('error', switchOptions, true);
860
- }
861
- }, 20);
862
- });
863
- });
864
- }
865
- };
866
- document.addEventListener('error', switchOptions, true);
867
- $('audio, video').each(function(){
868
- if(this.error){
869
- switchOptions({target: this});
870
- }
871
- });
872
- }
873
-
874
-
875
- if(Modernizr.track && !bugs.track){
876
- (function(){
877
-
878
- if(!bugs.track){
879
- bugs.track = typeof $('<track />')[0].readyState != 'number';
880
- }
881
-
882
- if(!bugs.track){
883
- try {
884
- new TextTrackCue(2, 3, '');
885
- } catch(e){
886
- bugs.track = true;
887
- }
888
- }
889
-
890
- var trackOptions = webshims.cfg.track;
891
- var trackListener = function(e){
892
- $(e.target).filter('track').each(changeApi);
893
- };
894
- var changeApi = function(){
895
- if(bugs.track || (!trackOptions.override && $.prop(this, 'readyState') == 3)){
896
- trackOptions.override = true;
897
- webshims.reTest('track');
898
- document.removeEventListener('error', trackListener, true);
899
- if(this && $.nodeName(this, 'track')){
900
- webshims.error("track support was overwritten. Please check your vtt including your vtt mime-type");
901
- } else {
902
- webshims.info("track support was overwritten. due to bad browser support");
903
- }
904
- }
905
- };
906
- var detectTrackError = function(){
907
- document.addEventListener('error', trackListener, true);
908
-
909
- if(bugs.track){
910
- changeApi();
911
- } else {
912
- $('track').each(changeApi);
913
- }
914
- };
915
- if(!trackOptions.override){
916
- if(webshims.isReady('track')){
917
- detectTrackError();
918
- } else {
919
- $(detectTrackError);
920
- }
921
- }
922
- })();
923
-
924
- }
925
-
926
- webshims.register('mediaelement-core', function($, webshims, window, document, undefined){
927
- hasSwf = swfobject.hasFlashPlayerVersion('9.0.115');
928
- $('html').addClass(hasSwf ? 'swf' : 'no-swf');
929
- var mediaelement = webshims.mediaelement;
930
- mediaelement.parseRtmp = function(data){
931
- var src = data.src.split('://');
932
- var paths = src[1].split('/');
933
- var i, len, found;
934
- data.server = src[0]+'://'+paths[0]+'/';
935
- data.streamId = [];
936
- for(i = 1, len = paths.length; i < len; i++){
937
- if(!found && paths[i].indexOf(':') !== -1){
938
- paths[i] = paths[i].split(':')[1];
939
- found = true;
940
- }
941
- if(!found){
942
- data.server += paths[i]+'/';
943
- } else {
944
- data.streamId.push(paths[i]);
945
- }
946
- }
947
- if(!data.streamId.length){
948
- webshims.error('Could not parse rtmp url');
949
- }
950
- data.streamId = data.streamId.join('/');
951
- console.log(data)
952
- };
953
- var getSrcObj = function(elem, nodeName){
954
- elem = $(elem);
955
- var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
956
- var tmp;
957
-
958
- if(!src.src){return src;}
959
-
960
- tmp = elem.attr('data-server');
961
- if(tmp != null){
962
- src.server = tmp;
963
- }
964
-
965
- tmp = elem.attr('type');
966
- if(tmp){
967
- src.type = tmp;
968
- src.container = $.trim(tmp.split(';')[0]);
969
- } else {
970
- if(!nodeName){
971
- nodeName = elem[0].nodeName.toLowerCase();
972
- if(nodeName == 'source'){
973
- nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
974
- }
975
- }
976
- if(src.server){
977
- src.type = nodeName+'/rtmp';
978
- src.container = nodeName+'/rtmp';
979
- } else {
980
-
981
- tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
982
-
983
- if(tmp){
984
- src.type = tmp;
985
- src.container = tmp;
986
- }
987
- }
988
- }
989
- tmp = elem.attr('media');
990
- if(tmp){
991
- src.media = tmp;
992
- }
993
- if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
994
- if(src.server){
995
- src.streamId = src.src;
996
- } else {
997
- mediaelement.parseRtmp(src);
998
- }
999
- }
1000
- return src;
1001
- };
1002
-
1003
-
1004
-
1005
- var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
1006
-
1007
- var loadTrackUi = function(){
1008
- if(loadTrackUi.loaded){return;}
1009
- loadTrackUi.loaded = true;
1010
- $(function(){
1011
- webshims.loader.loadList(['track-ui']);
1012
- });
1013
- };
1014
- var loadYt = (function(){
1015
- var loaded;
1016
- return function(){
1017
- if(loaded || !hasYt){return;}
1018
- loaded = true;
1019
- webshims.loader.loadScript("https://www.youtube.com/player_api");
1020
- $(function(){
1021
- webshims.polyfill("mediaelement-yt");
1022
- });
1023
- };
1024
- })();
1025
- var loadThird = function(){
1026
- if(hasSwf){
1027
- loadSwf();
1028
- } else {
1029
- loadYt();
1030
- }
1031
- };
1032
-
1033
- webshims.addPolyfill('mediaelement-yt', {
1034
- test: !hasYt,
1035
- d: ['dom-support']
1036
- });
1037
-
1038
- mediaelement.mimeTypes = {
1039
- audio: {
1040
- //ogm shouldn´t be used!
1041
- 'audio/ogg': ['ogg','oga', 'ogm'],
1042
- 'audio/ogg;codecs="opus"': 'opus',
1043
- 'audio/mpeg': ['mp2','mp3','mpga','mpega'],
1044
- 'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
1045
- 'audio/wav': ['wav'],
1046
- 'audio/3gpp': ['3gp','3gpp'],
1047
- 'audio/webm': ['webm'],
1048
- 'audio/fla': ['flv', 'f4a', 'fla'],
1049
- 'application/x-mpegURL': ['m3u8', 'm3u']
1050
- },
1051
- video: {
1052
- //ogm shouldn´t be used!
1053
- 'video/ogg': ['ogg','ogv', 'ogm'],
1054
- 'video/mpeg': ['mpg','mpeg','mpe'],
1055
- 'video/mp4': ['mp4','mpg4', 'm4v'],
1056
- 'video/quicktime': ['mov','qt'],
1057
- 'video/x-msvideo': ['avi'],
1058
- 'video/x-ms-asf': ['asf', 'asx'],
1059
- 'video/flv': ['flv', 'f4v'],
1060
- 'video/3gpp': ['3gp','3gpp'],
1061
- 'video/webm': ['webm'],
1062
- 'application/x-mpegURL': ['m3u8', 'm3u'],
1063
- 'video/MP2T': ['ts']
1064
- }
1065
- }
1066
- ;
1067
-
1068
- mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
1069
-
1070
- mediaelement.getTypeForSrc = function(src, nodeName, data){
1071
- if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
1072
- return 'video/youtube';
1073
- }
1074
- if(src.indexOf('rtmp') === 0){
1075
- return nodeName+'/rtmp';
1076
- }
1077
- src = src.split('?')[0].split('.');
1078
- src = src[src.length - 1];
1079
- var mt;
1080
-
1081
- $.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
1082
- if(exts.indexOf(src) !== -1){
1083
- mt = mimeType;
1084
- return false;
1085
- }
1086
- });
1087
- return mt;
1088
- };
1089
-
1090
-
1091
- mediaelement.srces = function(mediaElem, srces){
1092
- mediaElem = $(mediaElem);
1093
- if(!srces){
1094
- srces = [];
1095
- var nodeName = mediaElem[0].nodeName.toLowerCase();
1096
- var src = getSrcObj(mediaElem, nodeName);
1097
-
1098
- if(!src.src){
1099
-
1100
- $('source', mediaElem).each(function(){
1101
- src = getSrcObj(this, nodeName);
1102
- if(src.src){srces.push(src);}
1103
- });
1104
- } else {
1105
- srces.push(src);
1106
- }
1107
- return srces;
1108
- } else {
1109
- mediaElem.removeAttr('src').removeAttr('type').find('source').remove();
1110
- if(!$.isArray(srces)){
1111
- srces = [srces];
1112
- }
1113
- srces.forEach(function(src){
1114
- var source = document.createElement('source');
1115
- if(typeof src == 'string'){
1116
- src = {src: src};
1117
- }
1118
- source.setAttribute('src', src.src);
1119
- if(src.type){
1120
- source.setAttribute('type', src.type);
1121
- }
1122
- if(src.media){
1123
- source.setAttribute('media', src.media);
1124
- }
1125
- mediaElem.append(source);
1126
- });
1127
-
1128
- }
1129
- };
1130
-
1131
-
1132
- $.fn.loadMediaSrc = function(srces, poster){
1133
- return this.each(function(){
1134
- if(poster !== undefined){
1135
- $(this).removeAttr('poster');
1136
- if(poster){
1137
- $.attr(this, 'poster', poster);
1138
- }
1139
- }
1140
- mediaelement.srces(this, srces);
1141
- $(this).mediaLoad();
1142
- });
1143
- };
1144
-
1145
- mediaelement.swfMimeTypes = ['video/3gpp', 'video/x-msvideo', 'video/quicktime', 'video/x-m4v', 'video/mp4', 'video/m4p', 'video/x-flv', 'video/flv', 'audio/mpeg', 'audio/aac', 'audio/mp4', 'audio/x-m4a', 'audio/m4a', 'audio/mp3', 'audio/x-fla', 'audio/fla', 'youtube/flv', 'jwplayer/jwplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
1146
-
1147
- mediaelement.canThirdPlaySrces = function(mediaElem, srces){
1148
- var ret = '';
1149
- if(hasSwf || hasYt){
1150
- mediaElem = $(mediaElem);
1151
- srces = srces || mediaelement.srces(mediaElem);
1152
- $.each(srces, function(i, src){
1153
- if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
1154
- ret = src;
1155
- return false;
1156
- }
1157
- });
1158
-
1159
- }
1160
-
1161
- return ret;
1162
- };
1163
-
1164
- var nativeCanPlayType = {};
1165
- mediaelement.canNativePlaySrces = function(mediaElem, srces){
1166
- var ret = '';
1167
- if(hasNative){
1168
- mediaElem = $(mediaElem);
1169
- var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
1170
- if(!nativeCanPlayType[nodeName]){return ret;}
1171
- srces = srces || mediaelement.srces(mediaElem);
1172
-
1173
- $.each(srces, function(i, src){
1174
- if(src.type && nativeCanPlayType[nodeName].prop._supvalue.call(mediaElem[0], src.type) ){
1175
- ret = src;
1176
- return false;
1177
- }
1178
- });
1179
- }
1180
- return ret;
1181
- };
1182
-
1183
- mediaelement.setError = function(elem, message){
1184
- if(!message){
1185
- message = "can't play sources";
1186
- }
1187
-
1188
- $(elem).pause().data('mediaerror', message);
1189
- webshims.warn('mediaelementError: '+ message);
1190
- setTimeout(function(){
1191
- if($(elem).data('mediaerror')){
1192
- $(elem).trigger('mediaerror');
1193
- }
1194
- }, 1);
1195
- };
1196
-
1197
- var handleThird = (function(){
1198
- var requested;
1199
- return function( mediaElem, ret, data ){
1200
- if(!requested){
1201
- loadTrackUi();
1202
- }
1203
- webshims.ready(hasSwf ? swfType : 'mediaelement-yt', function(){
1204
- if(mediaelement.createSWF){
1205
- mediaelement.createSWF( mediaElem, ret, data );
1206
- } else if(!requested) {
1207
- requested = true;
1208
- loadThird();
1209
- //readd to ready
1210
- handleThird( mediaElem, ret, data );
1211
- }
1212
- });
1213
- if(!requested && hasYt && !mediaelement.createSWF){
1214
- loadYt();
1215
- }
1216
- };
1217
- })();
1218
-
1219
- var stepSources = function(elem, data, useSwf, _srces, _noLoop){
1220
- var ret;
1221
- if(useSwf || (useSwf !== false && data && data.isActive == 'third')){
1222
- ret = mediaelement.canThirdPlaySrces(elem, _srces);
1223
- if(!ret){
1224
- if(_noLoop){
1225
- mediaelement.setError(elem, false);
1226
- } else {
1227
- stepSources(elem, data, false, _srces, true);
1228
- }
1229
- } else {
1230
- handleThird(elem, ret, data);
1231
- }
1232
- } else {
1233
- ret = mediaelement.canNativePlaySrces(elem, _srces);
1234
- if(!ret){
1235
- if(_noLoop){
1236
- mediaelement.setError(elem, false);
1237
- if(data && data.isActive == 'third') {
1238
- mediaelement.setActive(elem, 'html5', data);
1239
- }
1240
- } else {
1241
- stepSources(elem, data, true, _srces, true);
1242
- }
1243
- } else if(data && data.isActive == 'third') {
1244
- mediaelement.setActive(elem, 'html5', data);
1245
- }
1246
- }
1247
- };
1248
- var stopParent = /^(?:embed|object|datalist)$/i;
1249
- var selectSource = function(elem, data){
1250
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
1251
- var _srces = mediaelement.srces(elem);
1252
- var parent = elem.parentNode;
1253
-
1254
- clearTimeout(baseData.loadTimer);
1255
- $.data(elem, 'mediaerror', false);
1256
-
1257
- if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
1258
- data = data || webshims.data(elem, 'mediaelement');
1259
- stepSources(elem, data, options.preferFlash || undefined, _srces);
1260
- };
1261
-
1262
-
1263
- $(document).on('ended', function(e){
1264
- var data = webshims.data(e.target, 'mediaelement');
1265
- if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
1266
- setTimeout(function(){
1267
- if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
1268
- $(e.target).prop('currentTime', 0).play();
1269
- }, 1);
1270
-
1271
- });
1272
- if(!supportsLoop){
1273
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
1274
- }
1275
-
1276
- ['audio', 'video'].forEach(function(nodeName){
1277
- var supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
1278
- prop: {
1279
- value: function(){
1280
- var data = webshims.data(this, 'mediaelement');
1281
- selectSource(this, data);
1282
- if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
1283
- supLoad.prop._supvalue.apply(this, arguments);
1284
- }
1285
- }
1286
- }
1287
- });
1288
- nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
1289
- prop: {
1290
- value: function(type){
1291
- var ret = '';
1292
- if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
1293
- ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
1294
- if(ret == 'no'){
1295
- ret = '';
1296
- }
1297
- }
1298
- if(!ret && hasSwf){
1299
- type = $.trim((type || '').split(';')[0]);
1300
- if(mediaelement.swfMimeTypes.indexOf(type) != -1){
1301
- ret = 'maybe';
1302
- }
1303
- }
1304
- return ret;
1305
- }
1306
- }
1307
- });
1308
- });
1309
- webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
1310
- set: function(){
1311
- var elem = this;
1312
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
1313
- clearTimeout(baseData.loadTimer);
1314
- baseData.loadTimer = setTimeout(function(){
1315
- selectSource(elem);
1316
- elem = null;
1317
- }, 9);
1318
- }
1319
- });
1320
-
1321
- var initMediaElements = function(){
1322
-
1323
- webshims.addReady(function(context, insertedElement){
1324
- var media = $('video, audio', context)
1325
- .add(insertedElement.filter('video, audio'))
1326
- .each(function(){
1327
- if($.browser.msie && webshims.browserVersion > 8 && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay])')){
1328
- $(this).prop('preload', 'metadata').mediaLoad();
1329
- } else {
1330
- selectSource(this);
1331
- }
1332
-
1333
-
1334
-
1335
- if(hasNative){
1336
- var bufferTimer;
1337
- var lastBuffered;
1338
- var elem = this;
1339
- var getBufferedString = function(){
1340
- var buffered = $.prop(elem, 'buffered');
1341
- if(!buffered){return;}
1342
- var bufferString = "";
1343
- for(var i = 0, len = buffered.length; i < len;i++){
1344
- bufferString += buffered.end(i);
1345
- }
1346
- return bufferString;
1347
- };
1348
- var testBuffer = function(){
1349
- var buffered = getBufferedString();
1350
- if(buffered != lastBuffered){
1351
- lastBuffered = buffered;
1352
- $(elem).triggerHandler('progress');
1353
- }
1354
- };
1355
-
1356
- $(this)
1357
- .on({
1358
- 'play loadstart progress': function(e){
1359
- if(e.type == 'progress'){
1360
- lastBuffered = getBufferedString();
1361
- }
1362
- clearTimeout(bufferTimer);
1363
- bufferTimer = setTimeout(testBuffer, 999);
1364
- },
1365
- 'emptied stalled mediaerror abort suspend': function(e){
1366
- if(e.type == 'emptied'){
1367
- lastBuffered = false;
1368
- }
1369
- clearTimeout(bufferTimer);
1370
- }
1371
- })
1372
- ;
1373
- }
1374
-
1375
- })
1376
- ;
1377
- if(!loadTrackUi.loaded && $('track', media).length){
1378
- loadTrackUi();
1379
- }
1380
- media = null;
1381
- });
1382
- };
1383
-
1384
- if(Modernizr.track && !bugs.track){
1385
- webshims.defineProperty(TextTrack.prototype, 'shimActiveCues', {
1386
- get: function(){
1387
- return this._shimActiveCues || this.activeCues;
1388
- }
1389
- });
1390
- }
1391
- //set native implementation ready, before swf api is retested
1392
- if(hasNative){
1393
- webshims.isReady('mediaelement-core', true);
1394
- initMediaElements();
1395
- webshims.ready('WINDOWLOAD mediaelement', loadThird);
1396
- } else {
1397
- webshims.ready(swfType, initMediaElements);
1398
- }
1399
- webshims.ready('WINDOWLOAD mediaelement', loadTrackUi);
1400
- });
1401
- })(jQuery, Modernizr, jQuery.webshims);
1402
- /*
1403
- * todos:
1404
- * - decouple muted/volume (needs improvement)
1405
- * - implement video <-> flashcanvas pro API
1406
- * - improve buffered-property with youtube/rtmp
1407
- * - use jwplayer5 api instead of old flash4 api
1408
- */
1409
-
1410
- jQuery.webshims.register('mediaelement-swf', function($, webshims, window, document, undefined, options){
1411
- "use strict";
1412
- var SENDEVENT = 'sendEvent';
1413
- var mediaelement = webshims.mediaelement;
1414
- var swfobject = window.swfobject;
1415
- var hasNative = Modernizr.audio && Modernizr.video;
1416
- var hasFlash = swfobject.hasFlashPlayerVersion('9.0.115');
1417
- var loadedSwf = 0;
1418
- var getProps = {
1419
- paused: true,
1420
- ended: false,
1421
- currentSrc: '',
1422
- duration: window.NaN,
1423
-
1424
- readyState: 0,
1425
- networkState: 0,
1426
- videoHeight: 0,
1427
- videoWidth: 0,
1428
- error: null,
1429
- buffered: {
1430
- start: function(index){
1431
- if(index){
1432
- webshims.error('buffered index size error');
1433
- return;
1434
- }
1435
- return 0;
1436
- },
1437
- end: function(index){
1438
- if(index){
1439
- webshims.error('buffered index size error');
1440
- return;
1441
- }
1442
- return 0;
1443
- },
1444
- length: 0
1445
- }
1446
- };
1447
- var getPropKeys = Object.keys(getProps);
1448
-
1449
- var getSetProps = {
1450
- currentTime: 0,
1451
- volume: 1,
1452
- muted: false
1453
- };
1454
- var getSetPropKeys = Object.keys(getSetProps);
1455
-
1456
- var playerStateObj = $.extend({
1457
- isActive: 'html5',
1458
- activating: 'html5',
1459
- wasSwfReady: false,
1460
- _bufferedEnd: 0,
1461
- _bufferedStart: 0,
1462
- _metadata: false,
1463
- _durationCalcs: -1,
1464
- _callMeta: false,
1465
- currentTime: 0,
1466
- _ppFlag: undefined
1467
- }, getProps, getSetProps);
1468
-
1469
- var idRep = /^jwplayer-/;
1470
- var getSwfDataFromID = function(id){
1471
-
1472
- var elem = document.getElementById(id.replace(idRep, ''));
1473
- if(!elem){return;}
1474
- var data = webshims.data(elem, 'mediaelement');
1475
- return data.isActive == 'third' ? data : null;
1476
- };
1477
-
1478
-
1479
- var getSwfDataFromElem = function(elem){
1480
- try {
1481
- (elem.nodeName);
1482
- } catch(er){
1483
- return null;
1484
- }
1485
- var data = webshims.data(elem, 'mediaelement');
1486
- return (data && data.isActive== 'third') ? data : null;
1487
- };
1488
-
1489
- var trigger = function(elem, evt){
1490
- evt = $.Event(evt);
1491
- evt.preventDefault();
1492
- $.event.trigger(evt, undefined, elem);
1493
- };
1494
-
1495
- var playerSwfPath = options.playerPath || webshims.cfg.basePath + "jwplayer/" + (options.playerName || "player.swf");
1496
- var jwplugin = options.pluginPath || webshims.cfg.basePath +'swf/jwwebshims.swf';
1497
-
1498
- webshims.extendUNDEFProp(options.params, {
1499
- allowscriptaccess: 'always',
1500
- allowfullscreen: 'true',
1501
- wmode: 'transparent'
1502
- });
1503
- webshims.extendUNDEFProp(options.vars, {
1504
- screencolor: 'ffffffff'
1505
- });
1506
- webshims.extendUNDEFProp(options.attrs, {
1507
- bgcolor: '#000000'
1508
- });
1509
-
1510
- var getDuration = function(data, obj){
1511
- var curDuration = data.duration;
1512
- if(curDuration && data._durationCalcs > 0){return;}
1513
- try {
1514
- data.duration = data.jwapi.getPlaylist()[0].duration;
1515
- if(!data.duration || data.duration <= 0 || data.duration === data._lastDuration){
1516
- data.duration = curDuration;
1517
- }
1518
- } catch(er){}
1519
- if(data.duration && data.duration != data._lastDuration){
1520
- trigger(data._elem, 'durationchange');
1521
- if(data._elemNodeName == 'audio' || data._callMeta){
1522
- mediaelement.jwEvents.Model.META($.extend({duration: data.duration}, obj), data);
1523
- }
1524
- data._durationCalcs--;
1525
- } else {
1526
- data._durationCalcs++;
1527
- }
1528
- };
1529
- var setReadyState = function(readyState, data){
1530
- if(readyState < 3){
1531
- clearTimeout(data._canplaythroughTimer);
1532
- }
1533
- if(readyState >= 3 && data.readyState < 3){
1534
- data.readyState = readyState;
1535
- trigger(data._elem, 'canplay');
1536
- clearTimeout(data._canplaythroughTimer);
1537
- data._canplaythroughTimer = setTimeout(function(){
1538
- setReadyState(4, data);
1539
- }, 4000);
1540
- }
1541
- if(readyState >= 4 && data.readyState < 4){
1542
- data.readyState = readyState;
1543
- trigger(data._elem, 'canplaythrough');
1544
- }
1545
- data.readyState = readyState;
1546
- };
1547
-
1548
- $.extend($.event.customEvent, {
1549
- updatemediaelementdimensions: true,
1550
- flashblocker: true,
1551
- swfstageresize: true,
1552
- mediaelementapichange: true
1553
- });
1554
-
1555
- mediaelement.jwEvents = {
1556
- View: {
1557
-
1558
- PLAY: function(obj){
1559
- var data = getSwfDataFromID(obj.id);
1560
- if(!data || data.stopPlayPause){return;}
1561
- data._ppFlag = true;
1562
- if(data.paused == obj.state){
1563
- data.paused = !obj.state;
1564
- if(data.ended){
1565
- data.ended = false;
1566
- }
1567
- trigger(data._elem, obj.state ? 'play' : 'pause');
1568
- }
1569
- }
1570
- },
1571
- Model: {
1572
-
1573
- BUFFER: function(obj){
1574
- var data = getSwfDataFromID(obj.id);
1575
- if(!data || !('percentage' in obj) || data._bufferedEnd == obj.percentage){return;}
1576
- data.networkState = (obj.percentage == 100) ? 1 : 2;
1577
- if(isNaN(data.duration) || (obj.percentage > 5 && obj.percentage < 25) || (obj.percentage === 100)){
1578
- getDuration(data, obj);
1579
- }
1580
-
1581
- if(data.ended){
1582
- data.ended = false;
1583
- }
1584
- if(!data.duration){
1585
- return;
1586
- }
1587
- if(obj.percentage > 2 && obj.percentage < 20){
1588
- setReadyState(3, data);
1589
- } else if(obj.percentage > 20){
1590
- setReadyState(4, data);
1591
- }
1592
- if(data._bufferedEnd && (data._bufferedEnd > obj.percentage)){
1593
- data._bufferedStart = data.currentTime || 0;
1594
- }
1595
-
1596
- data._bufferedEnd = obj.percentage;
1597
- data.buffered.length = 1;
1598
- if(obj.percentage == 100){
1599
- data.networkState = 1;
1600
- setReadyState(4, data);
1601
- }
1602
- $.event.trigger('progress', undefined, data._elem, true);
1603
- },
1604
- META: function(obj, data){
1605
-
1606
- data = data && data.networkState ? data : getSwfDataFromID(obj.id);
1607
-
1608
- if(!data){return;}
1609
- if( !('duration' in obj) ){
1610
- data._callMeta = true;
1611
- return;
1612
- }
1613
-
1614
- if( data._metadata && (!obj.height || data.videoHeight == obj.height) && (obj.duration === data.duration) ){return;}
1615
-
1616
- data._metadata = true;
1617
-
1618
- var oldDur = data.duration;
1619
- if(obj.duration){
1620
- data.duration = obj.duration;
1621
- }
1622
- data._lastDuration = data.duration;
1623
- if(obj.height || obj.width){
1624
- data.videoHeight = obj.height || 0;
1625
- data.videoWidth = obj.width || 0;
1626
- }
1627
- if(!data.networkState){
1628
- data.networkState = 2;
1629
- }
1630
- if(data.readyState < 1){
1631
- setReadyState(1, data);
1632
- }
1633
- if(data.duration && oldDur !== data.duration){
1634
- trigger(data._elem, 'durationchange');
1635
- }
1636
-
1637
- trigger(data._elem, 'loadedmetadata');
1638
- },
1639
- TIME: function(obj){
1640
- var data = getSwfDataFromID(obj.id);
1641
- if(!data || data.currentTime === obj.position){return;}
1642
- data.currentTime = obj.position;
1643
- if(data.duration && data.duration < data.currentTime){
1644
- getDuration(data, obj);
1645
- }
1646
- if(data.readyState < 2){
1647
- setReadyState(2, data);
1648
- }
1649
- if(data.ended){
1650
- data.ended = false;
1651
- }
1652
- trigger(data._elem, 'timeupdate');
1653
-
1654
- },
1655
- STATE: function(obj){
1656
- var data = getSwfDataFromID(obj.id);
1657
- if(!data){return;}
1658
- switch(obj.newstate) {
1659
- case 'BUFFERING':
1660
-
1661
- if(data.ended){
1662
- data.ended = false;
1663
- }
1664
- setReadyState(1, data);
1665
- trigger(data._elem, 'waiting');
1666
- break;
1667
- case 'PLAYING':
1668
- data.paused = false;
1669
- data._ppFlag = true;
1670
- if(!data.duration){
1671
- getDuration(data, obj);
1672
- }
1673
- if(data.readyState < 3){
1674
- setReadyState(3, data);
1675
- }
1676
- if(data.ended){
1677
- data.ended = false;
1678
- }
1679
- trigger(data._elem, 'playing');
1680
- break;
1681
- case 'PAUSED':
1682
- if(!data.paused && !data.stopPlayPause){
1683
- data.paused = true;
1684
- data._ppFlag = true;
1685
- trigger(data._elem, 'pause');
1686
- }
1687
- break;
1688
- case 'COMPLETED':
1689
- if(data.readyState < 4){
1690
- setReadyState(4, data);
1691
- }
1692
- data.ended = true;
1693
- trigger(data._elem, 'ended');
1694
- break;
1695
- }
1696
- }
1697
- }
1698
- ,Controller: {
1699
-
1700
- ERROR: function(obj){
1701
- var data = getSwfDataFromID(obj.id);
1702
- if(!data){return;}
1703
- mediaelement.setError(data._elem, obj.message);
1704
- },
1705
- SEEK: function(obj){
1706
- var data = getSwfDataFromID(obj.id);
1707
- if(!data){return;}
1708
- if(data.ended){
1709
- data.ended = false;
1710
- }
1711
- if(data.paused){
1712
- try {
1713
- data.jwapi[SENDEVENT]('play', 'false');
1714
- } catch(er){}
1715
- }
1716
- if(data.currentTime != obj.position){
1717
- data.currentTime = obj.position;
1718
- trigger(data._elem, 'timeupdate');
1719
- }
1720
-
1721
-
1722
- },
1723
- VOLUME: function(obj){
1724
- var data = getSwfDataFromID(obj.id);
1725
- if(!data){return;}
1726
- var newVolume = obj.percentage / 100;
1727
- if(data.volume == newVolume){return;}
1728
- data.volume = newVolume;
1729
- trigger(data._elem, 'volumechange');
1730
- },
1731
- MUTE: function(obj){
1732
- if(obj.state){return;}
1733
- var data = getSwfDataFromID(obj.id);
1734
- if(!data){return;}
1735
- if(data.muted == obj.state){return;}
1736
- data.muted = obj.state;
1737
- trigger(data._elem, 'volumechange');
1738
- }
1739
- }
1740
- };
1741
-
1742
- var initEvents = function(data){
1743
- var passed = true;
1744
- $.each(mediaelement.jwEvents, function(mvcName, evts){
1745
- $.each(evts, function(evtName){
1746
- try {
1747
- data.jwapi['add'+ mvcName +'Listener'](evtName, 'jQuery.webshims.mediaelement.jwEvents.'+ mvcName +'.'+ evtName);
1748
- } catch(er){
1749
- passed = false;
1750
- return false;
1751
- }
1752
- });
1753
- });
1754
- return passed;
1755
- };
1756
-
1757
- var workActionQueue = function(data){
1758
- var actionLen = data.actionQueue.length;
1759
- var i = 0;
1760
- var operation;
1761
- if(actionLen && data.isActive == 'third'){
1762
- while(data.actionQueue.length && actionLen > i){
1763
- i++;
1764
- operation = data.actionQueue.shift();
1765
- data.jwapi[operation.fn].apply(data.jwapi, operation.args);
1766
- }
1767
- }
1768
- if(data.actionQueue.length){
1769
- data.actionQueue = [];
1770
- }
1771
- };
1772
- var startAutoPlay = function(data){
1773
- if(!data){return;}
1774
- if( (data._ppFlag === undefined && ($.prop(data._elem, 'autoplay')) || !data.paused)){
1775
- setTimeout(function(){
1776
- if(data.isActive == 'third' && (data._ppFlag === undefined || !data.paused)){
1777
- try {
1778
- $(data._elem).play();
1779
- } catch(er){}
1780
- }
1781
- }, 1);
1782
- }
1783
- };
1784
-
1785
-
1786
- mediaelement.playerResize = function(id){
1787
- if(!id){return;}
1788
- var elem = document.getElementById(id.replace(idRep, ''));
1789
-
1790
- if(elem){
1791
- $(elem).triggerHandler('swfstageresize');
1792
- }
1793
- elem = null;
1794
- };
1795
-
1796
-
1797
- $(document).on('emptied', function(e){
1798
- var data = getSwfDataFromElem(e.target);
1799
- startAutoPlay(data);
1800
- });
1801
-
1802
- var localConnectionTimer;
1803
- mediaelement.jwPlayerReady = function(jwData){
1804
- var data = getSwfDataFromID(jwData.id);
1805
- var passed = true;
1806
- var i = 0;
1807
- var doneFn = function(){
1808
- if(i > 9){return;}
1809
- i++;
1810
- if(initEvents(data)){
1811
- if(!data.wasSwfReady){
1812
- var version = parseFloat( jwData.version, 10);
1813
- if(version < 5.1 || version >= 6){
1814
- webshims.warn('mediaelement-swf is only testet with jwplayer 5.6+');
1815
- }
1816
- } else {
1817
- $(data._elem).mediaLoad();
1818
-
1819
- }
1820
- data.wasSwfReady = true;
1821
- data.tryedReframeing = 0;
1822
- workActionQueue(data);
1823
- startAutoPlay(data);
1824
- } else {
1825
- clearTimeout(data.reframeTimer);
1826
- data.reframeTimer = setTimeout(doneFn, 9 * i);
1827
- if(i > 2 && data.tryedReframeing < 9){
1828
- data.tryedReframeing++;
1829
- data.shadowElem.css({overflow: 'visible'});
1830
- setTimeout(function(){
1831
- data.shadowElem.css({overflow: 'hidden'});
1832
- }, 16);
1833
- }
1834
- }
1835
- };
1836
- if(!data || !data.jwapi){return;}
1837
- if(!data.tryedReframeing){
1838
- data.tryedReframeing = 0;
1839
- }
1840
- clearTimeout(localConnectionTimer);
1841
- data.jwData = jwData;
1842
- data.shadowElem.removeClass('flashblocker-assumed');
1843
- $.prop(data._elem, 'volume', data.volume);
1844
- $.prop(data._elem, 'muted', data.muted);
1845
- doneFn();
1846
-
1847
- };
1848
-
1849
- var addMediaToStopEvents = $.noop;
1850
- if(hasNative){
1851
- var stopEvents = {
1852
- play: 1,
1853
- playing: 1
1854
- };
1855
- var hideEvtArray = ['play', 'pause', 'playing', 'canplay', 'progress', 'waiting', 'ended', 'loadedmetadata', 'durationchange', 'emptied'];
1856
- var hidevents = hideEvtArray.map(function(evt){
1857
- return evt +'.webshimspolyfill';
1858
- }).join(' ');
1859
-
1860
- var hidePlayerEvents = function(event){
1861
- var data = webshims.data(event.target, 'mediaelement');
1862
- if(!data){return;}
1863
- var isNativeHTML5 = ( event.originalEvent && event.originalEvent.type === event.type );
1864
- if( isNativeHTML5 == (data.activating == 'third') ){
1865
- event.stopImmediatePropagation();
1866
- if(stopEvents[event.type] && data.isActive != data.activating){
1867
- $(event.target).pause();
1868
- }
1869
- }
1870
- };
1871
-
1872
- addMediaToStopEvents = function(elem){
1873
- $(elem)
1874
- .off(hidevents)
1875
- .on(hidevents, hidePlayerEvents)
1876
- ;
1877
- hideEvtArray.forEach(function(evt){
1878
- webshims.moveToFirstEvent(elem, evt);
1879
- });
1880
- };
1881
- addMediaToStopEvents(document);
1882
- }
1883
-
1884
-
1885
- mediaelement.setActive = function(elem, type, data){
1886
- if(!data){
1887
- data = webshims.data(elem, 'mediaelement');
1888
- }
1889
- if(!data || data.isActive == type){return;}
1890
- if(type != 'html5' && type != 'third'){
1891
- webshims.warn('wrong type for mediaelement activating: '+ type);
1892
- }
1893
- var shadowData = webshims.data(elem, 'shadowData');
1894
- data.activating = type;
1895
- $(elem).pause();
1896
- data.isActive = type;
1897
- if(type == 'third'){
1898
- shadowData.shadowElement = shadowData.shadowFocusElement = data.shadowElem[0];
1899
- $(elem).addClass('swf-api-active nonnative-api-active').hide().getShadowElement().show();
1900
- } else {
1901
- $(elem).removeClass('swf-api-active nonnative-api-active').show().getShadowElement().hide();
1902
- shadowData.shadowElement = shadowData.shadowFocusElement = false;
1903
- }
1904
- $(elem).trigger('mediaelementapichange');
1905
- };
1906
-
1907
-
1908
-
1909
- var resetSwfProps = (function(){
1910
- var resetProtoProps = ['_bufferedEnd', '_bufferedStart', '_metadata', '_ppFlag', 'currentSrc', 'currentTime', 'duration', 'ended', 'networkState', 'paused', 'videoHeight', 'videoWidth', '_callMeta', '_durationCalcs'];
1911
- var len = resetProtoProps.length;
1912
- return function(data){
1913
-
1914
- if(!data){return;}
1915
- var lenI = len;
1916
- var networkState = data.networkState;
1917
- setReadyState(0, data);
1918
- while(--lenI){
1919
- delete data[resetProtoProps[lenI]];
1920
- }
1921
- data.actionQueue = [];
1922
- data.buffered.length = 0;
1923
- if(networkState){
1924
- trigger(data._elem, 'emptied');
1925
- }
1926
- };
1927
- })();
1928
-
1929
- var setElementDimension = function(data, hasControls){
1930
- var elem = data._elem;
1931
- var box = data.shadowElem;
1932
- $(elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
1933
- if(data._elemNodeName == 'audio' && !hasControls){
1934
- box.css({width: 0, height: 0});
1935
- } else {
1936
- box.css({
1937
- width: elem.style.width || $(elem).width(),
1938
- height: elem.style.height || $(elem).height()
1939
- });
1940
- }
1941
- };
1942
-
1943
- mediaelement.createSWF = function( elem, canPlaySrc, data ){
1944
- if(!hasFlash){
1945
- setTimeout(function(){
1946
- $(elem).mediaLoad(); //<- this should produce a mediaerror
1947
- }, 1);
1948
- return;
1949
- }
1950
-
1951
- if(loadedSwf < 1){
1952
- loadedSwf = 1;
1953
- } else {
1954
- loadedSwf++;
1955
- }
1956
- var vars = $.extend({}, options.vars, {
1957
- image: $.prop(elem, 'poster') || '',
1958
- file: canPlaySrc.streamId || canPlaySrc.srcProp
1959
- });
1960
- var elemVars = $(elem).data('vars') || {};
1961
-
1962
- if(canPlaySrc.server){
1963
- vars.streamer = canPlaySrc.server;
1964
- }
1965
- if(!data){
1966
- data = webshims.data(elem, 'mediaelement');
1967
- }
1968
-
1969
- if(data && data.swfCreated){
1970
- mediaelement.setActive(elem, 'third', data);
1971
- resetSwfProps(data);
1972
- data.currentSrc = canPlaySrc.srcProp;
1973
- $.extend(vars, elemVars);
1974
- options.changeSWF(vars, elem, canPlaySrc, data, 'load');
1975
- queueSwfMethod(elem, SENDEVENT, ['LOAD', vars]);
1976
- return;
1977
- }
1978
-
1979
-
1980
- var hasControls = $.prop(elem, 'controls');
1981
- var elemId = 'jwplayer-'+ webshims.getID(elem);
1982
- var params = $.extend(
1983
- {},
1984
- options.params,
1985
- $(elem).data('params')
1986
- );
1987
- var elemNodeName = elem.nodeName.toLowerCase();
1988
- var attrs = $.extend(
1989
- {},
1990
- options.attrs,
1991
- {
1992
- name: elemId,
1993
- id: elemId
1994
- },
1995
- $(elem).data('attrs')
1996
- );
1997
- var box = $('<div class="polyfill-'+ (elemNodeName) +' polyfill-mediaelement" id="wrapper-'+ elemId +'"><div id="'+ elemId +'"></div>')
1998
- .css({
1999
- position: 'relative',
2000
- overflow: 'hidden'
2001
- })
2002
- ;
2003
- data = webshims.data(elem, 'mediaelement', webshims.objectCreate(playerStateObj, {
2004
- actionQueue: {
2005
- value: []
2006
- },
2007
- shadowElem: {
2008
- value: box
2009
- },
2010
- _elemNodeName: {
2011
- value: elemNodeName
2012
- },
2013
- _elem: {
2014
- value: elem
2015
- },
2016
- currentSrc: {
2017
- value: canPlaySrc.srcProp
2018
- },
2019
- swfCreated: {
2020
- value: true
2021
- },
2022
- buffered: {
2023
- value: {
2024
- start: function(index){
2025
- if(index >= data.buffered.length){
2026
- webshims.error('buffered index size error');
2027
- return;
2028
- }
2029
- return 0;
2030
- },
2031
- end: function(index){
2032
- if(index >= data.buffered.length){
2033
- webshims.error('buffered index size error');
2034
- return;
2035
- }
2036
- return ( (data.duration - data._bufferedStart) * data._bufferedEnd / 100) + data._bufferedStart;
2037
- },
2038
- length: 0
2039
- }
2040
- }
2041
- }));
2042
-
2043
- setElementDimension(data, hasControls);
2044
-
2045
- box.insertBefore(elem);
2046
-
2047
- if(hasNative){
2048
- $.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted')});
2049
- }
2050
-
2051
- $.extend(vars,
2052
- {
2053
- id: elemId,
2054
- controlbar: hasControls ? options.vars.controlbar || (elemNodeName == 'video' ? 'over' : 'bottom') : (elemNodeName == 'video') ? 'none' : 'bottom',
2055
- icons: ''+ (hasControls && elemNodeName == 'video')
2056
- },
2057
- elemVars,
2058
- {playerready: 'jQuery.webshims.mediaelement.jwPlayerReady'}
2059
- );
2060
- if(vars.plugins){
2061
- vars.plugins += ','+jwplugin;
2062
- } else {
2063
- vars.plugins = jwplugin;
2064
- }
2065
-
2066
-
2067
- webshims.addShadowDom(elem, box);
2068
-
2069
- addMediaToStopEvents(elem);
2070
-
2071
- mediaelement.setActive(elem, 'third', data);
2072
-
2073
- options.changeSWF(vars, elem, canPlaySrc, data, 'embed');
2074
-
2075
- $(elem).on('updatemediaelementdimensions updateshadowdom', function(){
2076
- setElementDimension(data, $.prop(elem, 'controls'));
2077
- });
2078
-
2079
-
2080
- swfobject.embedSWF(playerSwfPath, elemId, "100%", "100%", "9.0.0", false, vars, params, attrs, function(swfData){
2081
-
2082
- if(swfData.success){
2083
- data.jwapi = swfData.ref;
2084
-
2085
- if(!hasControls){
2086
- $(swfData.ref).attr('tabindex', '-1').css('outline', 'none');
2087
- }
2088
- setTimeout(function(){
2089
- if((!swfData.ref.parentNode && box[0].parentNode) || swfData.ref.style.display == "none"){
2090
- box.addClass('flashblocker-assumed');
2091
- $(elem).trigger('flashblocker');
2092
- webshims.warn("flashblocker assumed");
2093
- }
2094
- $(swfData.ref).css({'minHeight': '2px', 'minWidth': '2px', display: 'block'});
2095
- }, 9);
2096
- if(!localConnectionTimer){
2097
- clearTimeout(localConnectionTimer);
2098
- localConnectionTimer = setTimeout(function(){
2099
- var flash = $(swfData.ref);
2100
- if(flash[0].offsetWidth > 1 && flash[0].offsetHeight > 1 && location.protocol.indexOf('file:') === 0){
2101
- webshims.error("Add your local development-directory to the local-trusted security sandbox: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html");
2102
- } else if(flash[0].offsetWidth < 2 || flash[0].offsetHeight < 2) {
2103
- webshims.warn("JS-SWF connection can't be established on hidden or unconnected flash objects");
2104
- }
2105
- flash = null;
2106
- }, 8000);
2107
- }
2108
- }
2109
- });
2110
- };
2111
-
2112
-
2113
- var queueSwfMethod = function(elem, fn, args, data){
2114
- data = data || getSwfDataFromElem(elem);
2115
- if(data){
2116
- if(data.jwapi && data.jwapi[fn]){
2117
- data.jwapi[fn].apply(data.jwapi, args || []);
2118
- } else {
2119
- //todo add to queue
2120
- data.actionQueue.push({fn: fn, args: args});
2121
- if(data.actionQueue.length > 10){
2122
- setTimeout(function(){
2123
- if(data.actionQueue.length > 5){
2124
- data.actionQueue.shift();
2125
- }
2126
- }, 99);
2127
- }
2128
- }
2129
- return data;
2130
- }
2131
- return false;
2132
- };
2133
-
2134
- ['audio', 'video'].forEach(function(nodeName){
2135
- var descs = {};
2136
- var mediaSup;
2137
- var createGetProp = function(key){
2138
- if(nodeName == 'audio' && (key == 'videoHeight' || key == 'videoWidth')){return;}
2139
-
2140
- descs[key] = {
2141
- get: function(){
2142
- var data = getSwfDataFromElem(this);
2143
- if(data){
2144
- return data[key];
2145
- } else if(hasNative && mediaSup[key].prop._supget) {
2146
- return mediaSup[key].prop._supget.apply(this);
2147
- } else {
2148
- return playerStateObj[key];
2149
- }
2150
- },
2151
- writeable: false
2152
- };
2153
- };
2154
- var createGetSetProp = function(key, setFn){
2155
- createGetProp(key);
2156
- delete descs[key].writeable;
2157
- descs[key].set = setFn;
2158
- };
2159
-
2160
- createGetSetProp('volume', function(v){
2161
- var data = getSwfDataFromElem(this);
2162
- if(data){
2163
- v *= 100;
2164
- if(!isNaN(v)){
2165
- var muted = data.muted;
2166
- if(v < 0 || v > 100){
2167
- webshims.error('volume greater or less than allowed '+ (v / 100));
2168
- }
2169
-
2170
- queueSwfMethod(this, SENDEVENT, ['VOLUME', v], data);
2171
- if(muted){
2172
- try {
2173
- data.jwapi.sendEvent('mute', 'true');
2174
- } catch(er){}
2175
- }
2176
- v /= 100;
2177
- if(data.volume == v || data.isActive != 'third'){return;}
2178
- data.volume = v;
2179
- trigger(data._elem, 'volumechange');
2180
- data = null;
2181
- }
2182
- } else if(mediaSup.volume.prop._supset) {
2183
- return mediaSup.volume.prop._supset.apply(this, arguments);
2184
- }
2185
- });
2186
-
2187
- createGetSetProp('muted', function(m){
2188
- var data = getSwfDataFromElem(this);
2189
- if(data){
2190
- m = !!m;
2191
- queueSwfMethod(this, SENDEVENT, ['mute', ''+m], data);
2192
- if(data.muted == m || data.isActive != 'third'){return;}
2193
- data.muted = m;
2194
- trigger(data._elem, 'volumechange');
2195
- data = null;
2196
- } else if(mediaSup.muted.prop._supset) {
2197
- return mediaSup.muted.prop._supset.apply(this, arguments);
2198
- }
2199
- });
2200
-
2201
-
2202
- createGetSetProp('currentTime', function(t){
2203
- var data = getSwfDataFromElem(this);
2204
- if(data){
2205
- t *= 1;
2206
- if (!isNaN(t)) {
2207
- if(data.paused){
2208
- clearTimeout(data.stopPlayPause);
2209
- data.stopPlayPause = setTimeout(function(){
2210
- data.paused = true;
2211
- data.stopPlayPause = false;
2212
- }, 50);
2213
- }
2214
- queueSwfMethod(this, SENDEVENT, ['SEEK', '' + t], data);
2215
-
2216
- if(data.paused){
2217
- if(data.readyState > 0){
2218
- data.currentTime = t;
2219
- trigger(data._elem, 'timeupdate');
2220
- }
2221
- try {
2222
- data.jwapi[SENDEVENT]('play', 'false');
2223
- } catch(er){}
2224
-
2225
- }
2226
- }
2227
-
2228
- } else if(mediaSup.currentTime.prop._supset) {
2229
- return mediaSup.currentTime.prop._supset.apply(this, arguments);
2230
- }
2231
- });
2232
-
2233
- ['play', 'pause'].forEach(function(fn){
2234
- descs[fn] = {
2235
- value: function(){
2236
- var data = getSwfDataFromElem(this);
2237
- if(data){
2238
- if(data.stopPlayPause){
2239
- clearTimeout(data.stopPlayPause);
2240
- }
2241
- queueSwfMethod(this, SENDEVENT, ['play', fn == 'play'], data);
2242
- setTimeout(function(){
2243
- if(data.isActive == 'third'){
2244
- data._ppFlag = true;
2245
- if(data.paused != (fn != 'play')){
2246
- data.paused = fn != 'play';
2247
- trigger(data._elem, fn);
2248
- }
2249
- }
2250
- }, 1);
2251
- } else if(mediaSup[fn].prop._supvalue) {
2252
- return mediaSup[fn].prop._supvalue.apply(this, arguments);
2253
- }
2254
- }
2255
- };
2256
- });
2257
-
2258
- getPropKeys.forEach(createGetProp);
2259
-
2260
- webshims.onNodeNamesPropertyModify(nodeName, 'controls', function(val, boolProp){
2261
- var data = getSwfDataFromElem(this);
2262
- $(this)[boolProp ? 'addClass' : 'removeClass']('webshims-controls');
2263
-
2264
- if(data){
2265
- try {
2266
- queueSwfMethod(this, boolProp ? 'showControls' : 'hideControls', [nodeName], data);
2267
- } catch(er){
2268
- webshims.warn("you need to generate a crossdomain.xml");
2269
- }
2270
- if(nodeName == 'audio'){
2271
- setElementDimension(data, boolProp);
2272
- }
2273
- $(data.jwapi).attr('tabindex', boolProp ? '0' : '-1');
2274
- }
2275
- });
2276
-
2277
- mediaSup = webshims.defineNodeNameProperties(nodeName, descs, 'prop');
2278
- });
2279
-
2280
- if(hasFlash){
2281
- var oldClean = $.cleanData;
2282
- var gcBrowser = $.browser.msie && webshims.browserVersion < 9;
2283
- var flashNames = {
2284
- object: 1,
2285
- OBJECT: 1
2286
- };
2287
- $.cleanData = function(elems){
2288
- var i, len, prop;
2289
- if(elems && (len = elems.length) && loadedSwf){
2290
-
2291
- for(i = 0; i < len; i++){
2292
- if(flashNames[elems[i].nodeName]){
2293
- if(SENDEVENT in elems[i]){
2294
- loadedSwf--;
2295
- try {
2296
- elems[i][SENDEVENT]('play', false);
2297
- } catch(er){}
2298
- }
2299
- if(gcBrowser){
2300
- try {
2301
- for (prop in elems[i]) {
2302
- if (typeof elems[i][prop] == "function") {
2303
- elems[i][prop] = null;
2304
- }
2305
- }
2306
- } catch(er){}
2307
- }
2308
- }
2309
- }
2310
-
2311
- }
2312
- return oldClean.apply(this, arguments);
2313
- };
2314
- }
2315
-
2316
- if(!hasNative){
2317
-
2318
- ['poster', 'src'].forEach(function(prop){
2319
- webshims.defineNodeNamesProperty(prop == 'src' ? ['audio', 'video', 'source'] : ['video'], prop, {
2320
- //attr: {},
2321
- reflect: true,
2322
- propType: 'src'
2323
- });
2324
- });
2325
-
2326
-
2327
- ['autoplay', 'controls'].forEach(function(name){
2328
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], name);
2329
- });
2330
-
2331
- webshims.defineNodeNamesProperties(['audio', 'video'], {
2332
- HAVE_CURRENT_DATA: {
2333
- value: 2
2334
- },
2335
- HAVE_ENOUGH_DATA: {
2336
- value: 4
2337
- },
2338
- HAVE_FUTURE_DATA: {
2339
- value: 3
2340
- },
2341
- HAVE_METADATA: {
2342
- value: 1
2343
- },
2344
- HAVE_NOTHING: {
2345
- value: 0
2346
- },
2347
- NETWORK_EMPTY: {
2348
- value: 0
2349
- },
2350
- NETWORK_IDLE: {
2351
- value: 1
2352
- },
2353
- NETWORK_LOADING: {
2354
- value: 2
2355
- },
2356
- NETWORK_NO_SOURCE: {
2357
- value: 3
2358
- }
2359
-
2360
- }, 'prop');
2361
- }
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
+
804
+ (function($, Modernizr, webshims){
805
+ "use strict";
806
+ var hasNative = Modernizr.audio && Modernizr.video;
807
+ var supportsLoop = false;
808
+ var bugs = webshims.bugs;
809
+
810
+ var loadSwf = function(){
811
+ webshims.ready(swfType, function(){
812
+ if(!webshims.mediaelement.createSWF){
813
+ webshims.mediaelement.loadSwf = true;
814
+ webshims.reTest([swfType], hasNative);
815
+ }
816
+ });
817
+ };
818
+ var options = webshims.cfg.mediaelement;
819
+ var swfType = options && options.player == 'jwplayer' ? 'mediaelement-swf' : 'mediaelement-jaris';
820
+ var hasSwf;
821
+ if(!options){
822
+ webshims.error("mediaelement wasn't implemented but loaded");
823
+ return;
824
+ }
825
+ if(hasNative){
826
+ var videoElem = document.createElement('video');
827
+ Modernizr.videoBuffered = ('buffered' in videoElem);
828
+ supportsLoop = ('loop' in videoElem);
829
+
830
+ webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
831
+
832
+ if(!Modernizr.videoBuffered){
833
+ webshims.addPolyfill('mediaelement-native-fix', {
834
+ f: 'mediaelement',
835
+ test: Modernizr.videoBuffered,
836
+ d: ['dom-support']
837
+ });
838
+
839
+ webshims.reTest('mediaelement-native-fix');
840
+ }
841
+ }
842
+
843
+ if(hasNative && !options.preferFlash){
844
+ var switchOptions = function(e){
845
+ var parent = e.target.parentNode;
846
+ if(!options.preferFlash && ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) ){
847
+ webshims.ready('DOM mediaelement', function(){
848
+ if(hasSwf){
849
+ loadSwf();
850
+ }
851
+ webshims.ready('WINDOWLOAD '+swfType, function(){
852
+ setTimeout(function(){
853
+ if(hasSwf && !options.preferFlash && webshims.mediaelement.createSWF && !$(e.target).closest('audio, video').is('.nonnative-api-active')){
854
+ options.preferFlash = true;
855
+ document.removeEventListener('error', switchOptions, true);
856
+ $('audio, video').mediaLoad();
857
+ webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src);
858
+ } else if(!hasSwf){
859
+ document.removeEventListener('error', switchOptions, true);
860
+ }
861
+ }, 20);
862
+ });
863
+ });
864
+ }
865
+ };
866
+ document.addEventListener('error', switchOptions, true);
867
+ $('audio, video').each(function(){
868
+ if(this.error){
869
+ switchOptions({target: this});
870
+ }
871
+ });
872
+ }
873
+
874
+
875
+ if(Modernizr.track && !bugs.track){
876
+ (function(){
877
+
878
+ if(!bugs.track){
879
+ bugs.track = typeof $('<track />')[0].readyState != 'number';
880
+ }
881
+
882
+ if(!bugs.track){
883
+ try {
884
+ new TextTrackCue(2, 3, '');
885
+ } catch(e){
886
+ bugs.track = true;
887
+ }
888
+ }
889
+
890
+ var trackOptions = webshims.cfg.track;
891
+ var trackListener = function(e){
892
+ $(e.target).filter('track').each(changeApi);
893
+ };
894
+ var changeApi = function(){
895
+ if(bugs.track || (!trackOptions.override && $.prop(this, 'readyState') == 3)){
896
+ trackOptions.override = true;
897
+ webshims.reTest('track');
898
+ document.removeEventListener('error', trackListener, true);
899
+ if(this && $.nodeName(this, 'track')){
900
+ webshims.error("track support was overwritten. Please check your vtt including your vtt mime-type");
901
+ } else {
902
+ webshims.info("track support was overwritten. due to bad browser support");
903
+ }
904
+ }
905
+ };
906
+ var detectTrackError = function(){
907
+ document.addEventListener('error', trackListener, true);
908
+
909
+ if(bugs.track){
910
+ changeApi();
911
+ } else {
912
+ $('track').each(changeApi);
913
+ }
914
+ };
915
+ if(!trackOptions.override){
916
+ if(webshims.isReady('track')){
917
+ detectTrackError();
918
+ } else {
919
+ $(detectTrackError);
920
+ }
921
+ }
922
+ })();
923
+
924
+ }
925
+
926
+ webshims.register('mediaelement-core', function($, webshims, window, document, undefined){
927
+ hasSwf = swfobject.hasFlashPlayerVersion('9.0.115');
928
+ $('html').addClass(hasSwf ? 'swf' : 'no-swf');
929
+ var mediaelement = webshims.mediaelement;
930
+ mediaelement.parseRtmp = function(data){
931
+ var src = data.src.split('://');
932
+ var paths = src[1].split('/');
933
+ var i, len, found;
934
+ data.server = src[0]+'://'+paths[0]+'/';
935
+ data.streamId = [];
936
+ for(i = 1, len = paths.length; i < len; i++){
937
+ if(!found && paths[i].indexOf(':') !== -1){
938
+ paths[i] = paths[i].split(':')[1];
939
+ found = true;
940
+ }
941
+ if(!found){
942
+ data.server += paths[i]+'/';
943
+ } else {
944
+ data.streamId.push(paths[i]);
945
+ }
946
+ }
947
+ if(!data.streamId.length){
948
+ webshims.error('Could not parse rtmp url');
949
+ }
950
+ data.streamId = data.streamId.join('/');
951
+ };
952
+ var getSrcObj = function(elem, nodeName){
953
+ elem = $(elem);
954
+ var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
955
+ var tmp;
956
+
957
+ if(!src.src){return src;}
958
+
959
+ tmp = elem.attr('data-server');
960
+ if(tmp != null){
961
+ src.server = tmp;
962
+ }
963
+
964
+ tmp = elem.attr('type');
965
+ if(tmp){
966
+ src.type = tmp;
967
+ src.container = $.trim(tmp.split(';')[0]);
968
+ } else {
969
+ if(!nodeName){
970
+ nodeName = elem[0].nodeName.toLowerCase();
971
+ if(nodeName == 'source'){
972
+ nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
973
+ }
974
+ }
975
+ if(src.server){
976
+ src.type = nodeName+'/rtmp';
977
+ src.container = nodeName+'/rtmp';
978
+ } else {
979
+
980
+ tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
981
+
982
+ if(tmp){
983
+ src.type = tmp;
984
+ src.container = tmp;
985
+ }
986
+ }
987
+ }
988
+ tmp = elem.attr('media');
989
+ if(tmp){
990
+ src.media = tmp;
991
+ }
992
+ if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
993
+ if(src.server){
994
+ src.streamId = src.src;
995
+ } else {
996
+ mediaelement.parseRtmp(src);
997
+ }
998
+ }
999
+ return src;
1000
+ };
1001
+
1002
+
1003
+
1004
+ var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
1005
+
1006
+ var loadTrackUi = function(){
1007
+ if(loadTrackUi.loaded){return;}
1008
+ loadTrackUi.loaded = true;
1009
+ $(function(){
1010
+ webshims.loader.loadList(['track-ui']);
1011
+ });
1012
+ };
1013
+ var loadYt = (function(){
1014
+ var loaded;
1015
+ return function(){
1016
+ if(loaded || !hasYt){return;}
1017
+ loaded = true;
1018
+ webshims.loader.loadScript("https://www.youtube.com/player_api");
1019
+ $(function(){
1020
+ webshims.polyfill("mediaelement-yt");
1021
+ });
1022
+ };
1023
+ })();
1024
+ var loadThird = function(){
1025
+ if(hasSwf){
1026
+ loadSwf();
1027
+ } else {
1028
+ loadYt();
1029
+ }
1030
+ };
1031
+
1032
+ webshims.addPolyfill('mediaelement-yt', {
1033
+ test: !hasYt,
1034
+ d: ['dom-support']
1035
+ });
1036
+
1037
+ mediaelement.mimeTypes = {
1038
+ audio: {
1039
+ //ogm shouldn´t be used!
1040
+ 'audio/ogg': ['ogg','oga', 'ogm'],
1041
+ 'audio/ogg;codecs="opus"': 'opus',
1042
+ 'audio/mpeg': ['mp2','mp3','mpga','mpega'],
1043
+ 'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
1044
+ 'audio/wav': ['wav'],
1045
+ 'audio/3gpp': ['3gp','3gpp'],
1046
+ 'audio/webm': ['webm'],
1047
+ 'audio/fla': ['flv', 'f4a', 'fla'],
1048
+ 'application/x-mpegURL': ['m3u8', 'm3u']
1049
+ },
1050
+ video: {
1051
+ //ogm shouldn´t be used!
1052
+ 'video/ogg': ['ogg','ogv', 'ogm'],
1053
+ 'video/mpeg': ['mpg','mpeg','mpe'],
1054
+ 'video/mp4': ['mp4','mpg4', 'm4v'],
1055
+ 'video/quicktime': ['mov','qt'],
1056
+ 'video/x-msvideo': ['avi'],
1057
+ 'video/x-ms-asf': ['asf', 'asx'],
1058
+ 'video/flv': ['flv', 'f4v'],
1059
+ 'video/3gpp': ['3gp','3gpp'],
1060
+ 'video/webm': ['webm'],
1061
+ 'application/x-mpegURL': ['m3u8', 'm3u'],
1062
+ 'video/MP2T': ['ts']
1063
+ }
1064
+ }
1065
+ ;
1066
+
1067
+ mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
1068
+
1069
+ mediaelement.getTypeForSrc = function(src, nodeName, data){
1070
+ if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
1071
+ return 'video/youtube';
1072
+ }
1073
+ if(src.indexOf('rtmp') === 0){
1074
+ return nodeName+'/rtmp';
1075
+ }
1076
+ src = src.split('?')[0].split('.');
1077
+ src = src[src.length - 1];
1078
+ var mt;
1079
+
1080
+ $.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
1081
+ if(exts.indexOf(src) !== -1){
1082
+ mt = mimeType;
1083
+ return false;
1084
+ }
1085
+ });
1086
+ return mt;
1087
+ };
1088
+
1089
+
1090
+ mediaelement.srces = function(mediaElem, srces){
1091
+ mediaElem = $(mediaElem);
1092
+ if(!srces){
1093
+ srces = [];
1094
+ var nodeName = mediaElem[0].nodeName.toLowerCase();
1095
+ var src = getSrcObj(mediaElem, nodeName);
1096
+
1097
+ if(!src.src){
1098
+
1099
+ $('source', mediaElem).each(function(){
1100
+ src = getSrcObj(this, nodeName);
1101
+ if(src.src){srces.push(src);}
1102
+ });
1103
+ } else {
1104
+ srces.push(src);
1105
+ }
1106
+ return srces;
1107
+ } else {
1108
+ mediaElem.removeAttr('src').removeAttr('type').find('source').remove();
1109
+ if(!$.isArray(srces)){
1110
+ srces = [srces];
1111
+ }
1112
+ srces.forEach(function(src){
1113
+ var source = document.createElement('source');
1114
+ if(typeof src == 'string'){
1115
+ src = {src: src};
1116
+ }
1117
+ source.setAttribute('src', src.src);
1118
+ if(src.type){
1119
+ source.setAttribute('type', src.type);
1120
+ }
1121
+ if(src.media){
1122
+ source.setAttribute('media', src.media);
1123
+ }
1124
+ mediaElem.append(source);
1125
+ });
1126
+
1127
+ }
1128
+ };
1129
+
1130
+
1131
+ $.fn.loadMediaSrc = function(srces, poster){
1132
+ return this.each(function(){
1133
+ if(poster !== undefined){
1134
+ $(this).removeAttr('poster');
1135
+ if(poster){
1136
+ $.attr(this, 'poster', poster);
1137
+ }
1138
+ }
1139
+ mediaelement.srces(this, srces);
1140
+ $(this).mediaLoad();
1141
+ });
1142
+ };
1143
+
1144
+ mediaelement.swfMimeTypes = ['video/3gpp', 'video/x-msvideo', 'video/quicktime', 'video/x-m4v', 'video/mp4', 'video/m4p', 'video/x-flv', 'video/flv', 'audio/mpeg', 'audio/aac', 'audio/mp4', 'audio/x-m4a', 'audio/m4a', 'audio/mp3', 'audio/x-fla', 'audio/fla', 'youtube/flv', 'jwplayer/jwplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
1145
+
1146
+ mediaelement.canThirdPlaySrces = function(mediaElem, srces){
1147
+ var ret = '';
1148
+ if(hasSwf || hasYt){
1149
+ mediaElem = $(mediaElem);
1150
+ srces = srces || mediaelement.srces(mediaElem);
1151
+ $.each(srces, function(i, src){
1152
+ if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
1153
+ ret = src;
1154
+ return false;
1155
+ }
1156
+ });
1157
+
1158
+ }
1159
+
1160
+ return ret;
1161
+ };
1162
+
1163
+ var nativeCanPlayType = {};
1164
+ mediaelement.canNativePlaySrces = function(mediaElem, srces){
1165
+ var ret = '';
1166
+ if(hasNative){
1167
+ mediaElem = $(mediaElem);
1168
+ var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
1169
+ if(!nativeCanPlayType[nodeName]){return ret;}
1170
+ srces = srces || mediaelement.srces(mediaElem);
1171
+
1172
+ $.each(srces, function(i, src){
1173
+ if(src.type && nativeCanPlayType[nodeName].prop._supvalue.call(mediaElem[0], src.type) ){
1174
+ ret = src;
1175
+ return false;
1176
+ }
1177
+ });
1178
+ }
1179
+ return ret;
1180
+ };
1181
+
1182
+ mediaelement.setError = function(elem, message){
1183
+ if(!message){
1184
+ message = "can't play sources";
1185
+ }
1186
+
1187
+ $(elem).pause().data('mediaerror', message);
1188
+ webshims.warn('mediaelementError: '+ message);
1189
+ setTimeout(function(){
1190
+ if($(elem).data('mediaerror')){
1191
+ $(elem).trigger('mediaerror');
1192
+ }
1193
+ }, 1);
1194
+ };
1195
+
1196
+ var handleThird = (function(){
1197
+ var requested;
1198
+ return function( mediaElem, ret, data ){
1199
+ if(!requested){
1200
+ loadTrackUi();
1201
+ }
1202
+ webshims.ready(hasSwf ? swfType : 'mediaelement-yt', function(){
1203
+ if(mediaelement.createSWF){
1204
+ mediaelement.createSWF( mediaElem, ret, data );
1205
+ } else if(!requested) {
1206
+ requested = true;
1207
+ loadThird();
1208
+ //readd to ready
1209
+ handleThird( mediaElem, ret, data );
1210
+ }
1211
+ });
1212
+ if(!requested && hasYt && !mediaelement.createSWF){
1213
+ loadYt();
1214
+ }
1215
+ };
1216
+ })();
1217
+
1218
+ var stepSources = function(elem, data, useSwf, _srces, _noLoop){
1219
+ var ret;
1220
+ if(useSwf || (useSwf !== false && data && data.isActive == 'third')){
1221
+ ret = mediaelement.canThirdPlaySrces(elem, _srces);
1222
+ if(!ret){
1223
+ if(_noLoop){
1224
+ mediaelement.setError(elem, false);
1225
+ } else {
1226
+ stepSources(elem, data, false, _srces, true);
1227
+ }
1228
+ } else {
1229
+ handleThird(elem, ret, data);
1230
+ }
1231
+ } else {
1232
+ ret = mediaelement.canNativePlaySrces(elem, _srces);
1233
+ if(!ret){
1234
+ if(_noLoop){
1235
+ mediaelement.setError(elem, false);
1236
+ if(data && data.isActive == 'third') {
1237
+ mediaelement.setActive(elem, 'html5', data);
1238
+ }
1239
+ } else {
1240
+ stepSources(elem, data, true, _srces, true);
1241
+ }
1242
+ } else if(data && data.isActive == 'third') {
1243
+ mediaelement.setActive(elem, 'html5', data);
1244
+ }
1245
+ }
1246
+ };
1247
+ var stopParent = /^(?:embed|object|datalist)$/i;
1248
+ var selectSource = function(elem, data){
1249
+ var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
1250
+ var _srces = mediaelement.srces(elem);
1251
+ var parent = elem.parentNode;
1252
+
1253
+ clearTimeout(baseData.loadTimer);
1254
+ $.data(elem, 'mediaerror', false);
1255
+
1256
+ if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
1257
+ data = data || webshims.data(elem, 'mediaelement');
1258
+ stepSources(elem, data, options.preferFlash || undefined, _srces);
1259
+ };
1260
+
1261
+
1262
+ $(document).on('ended', function(e){
1263
+ var data = webshims.data(e.target, 'mediaelement');
1264
+ if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
1265
+ setTimeout(function(){
1266
+ if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
1267
+ $(e.target).prop('currentTime', 0).play();
1268
+ }, 1);
1269
+
1270
+ });
1271
+ if(!supportsLoop){
1272
+ webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
1273
+ }
1274
+
1275
+ ['audio', 'video'].forEach(function(nodeName){
1276
+ var supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
1277
+ prop: {
1278
+ value: function(){
1279
+ var data = webshims.data(this, 'mediaelement');
1280
+ selectSource(this, data);
1281
+ if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
1282
+ supLoad.prop._supvalue.apply(this, arguments);
1283
+ }
1284
+ }
1285
+ }
1286
+ });
1287
+ nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
1288
+ prop: {
1289
+ value: function(type){
1290
+ var ret = '';
1291
+ if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
1292
+ ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
1293
+ if(ret == 'no'){
1294
+ ret = '';
1295
+ }
1296
+ }
1297
+ if(!ret && hasSwf){
1298
+ type = $.trim((type || '').split(';')[0]);
1299
+ if(mediaelement.swfMimeTypes.indexOf(type) != -1){
1300
+ ret = 'maybe';
1301
+ }
1302
+ }
1303
+ return ret;
1304
+ }
1305
+ }
1306
+ });
1307
+ });
1308
+ webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
1309
+ set: function(){
1310
+ var elem = this;
1311
+ var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
1312
+ clearTimeout(baseData.loadTimer);
1313
+ baseData.loadTimer = setTimeout(function(){
1314
+ selectSource(elem);
1315
+ elem = null;
1316
+ }, 9);
1317
+ }
1318
+ });
1319
+
1320
+ var initMediaElements = function(){
1321
+
1322
+ webshims.addReady(function(context, insertedElement){
1323
+ var media = $('video, audio', context)
1324
+ .add(insertedElement.filter('video, audio'))
1325
+ .each(function(){
1326
+ if($.browser.msie && webshims.browserVersion > 8 && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay])')){
1327
+ $(this).prop('preload', 'metadata').mediaLoad();
1328
+ } else {
1329
+ selectSource(this);
1330
+ }
1331
+
1332
+
1333
+
1334
+ if(hasNative){
1335
+ var bufferTimer;
1336
+ var lastBuffered;
1337
+ var elem = this;
1338
+ var getBufferedString = function(){
1339
+ var buffered = $.prop(elem, 'buffered');
1340
+ if(!buffered){return;}
1341
+ var bufferString = "";
1342
+ for(var i = 0, len = buffered.length; i < len;i++){
1343
+ bufferString += buffered.end(i);
1344
+ }
1345
+ return bufferString;
1346
+ };
1347
+ var testBuffer = function(){
1348
+ var buffered = getBufferedString();
1349
+ if(buffered != lastBuffered){
1350
+ lastBuffered = buffered;
1351
+ $(elem).triggerHandler('progress');
1352
+ }
1353
+ };
1354
+
1355
+ $(this)
1356
+ .on({
1357
+ 'play loadstart progress': function(e){
1358
+ if(e.type == 'progress'){
1359
+ lastBuffered = getBufferedString();
1360
+ }
1361
+ clearTimeout(bufferTimer);
1362
+ bufferTimer = setTimeout(testBuffer, 999);
1363
+ },
1364
+ 'emptied stalled mediaerror abort suspend': function(e){
1365
+ if(e.type == 'emptied'){
1366
+ lastBuffered = false;
1367
+ }
1368
+ clearTimeout(bufferTimer);
1369
+ }
1370
+ })
1371
+ ;
1372
+ }
1373
+
1374
+ })
1375
+ ;
1376
+ if(!loadTrackUi.loaded && $('track', media).length){
1377
+ loadTrackUi();
1378
+ }
1379
+ media = null;
1380
+ });
1381
+ };
1382
+
1383
+ if(Modernizr.track && !bugs.track){
1384
+ webshims.defineProperty(TextTrack.prototype, 'shimActiveCues', {
1385
+ get: function(){
1386
+ return this._shimActiveCues || this.activeCues;
1387
+ }
1388
+ });
1389
+ }
1390
+ //set native implementation ready, before swf api is retested
1391
+ if(hasNative){
1392
+ webshims.isReady('mediaelement-core', true);
1393
+ initMediaElements();
1394
+ webshims.ready('WINDOWLOAD mediaelement', loadThird);
1395
+ } else {
1396
+ webshims.ready(swfType, initMediaElements);
1397
+ }
1398
+ webshims.ready('WINDOWLOAD mediaelement', loadTrackUi);
1399
+ });
1400
+ })(jQuery, Modernizr, jQuery.webshims);
1401
+ /*
1402
+ * todos:
1403
+ * - decouple muted/volume (needs improvement)
1404
+ * - implement video <-> flashcanvas pro API
1405
+ * - improve buffered-property with youtube/rtmp
1406
+ * - use jwplayer5 api instead of old flash4 api
1407
+ */
1408
+
1409
+ jQuery.webshims.register('mediaelement-swf', function($, webshims, window, document, undefined, options){
1410
+ "use strict";
1411
+ var SENDEVENT = 'sendEvent';
1412
+ var mediaelement = webshims.mediaelement;
1413
+ var swfobject = window.swfobject;
1414
+ var hasNative = Modernizr.audio && Modernizr.video;
1415
+ var hasFlash = swfobject.hasFlashPlayerVersion('9.0.115');
1416
+ var loadedSwf = 0;
1417
+ var getProps = {
1418
+ paused: true,
1419
+ ended: false,
1420
+ currentSrc: '',
1421
+ duration: window.NaN,
1422
+
1423
+ readyState: 0,
1424
+ networkState: 0,
1425
+ videoHeight: 0,
1426
+ videoWidth: 0,
1427
+ error: null,
1428
+ buffered: {
1429
+ start: function(index){
1430
+ if(index){
1431
+ webshims.error('buffered index size error');
1432
+ return;
1433
+ }
1434
+ return 0;
1435
+ },
1436
+ end: function(index){
1437
+ if(index){
1438
+ webshims.error('buffered index size error');
1439
+ return;
1440
+ }
1441
+ return 0;
1442
+ },
1443
+ length: 0
1444
+ }
1445
+ };
1446
+ var getPropKeys = Object.keys(getProps);
1447
+
1448
+ var getSetProps = {
1449
+ currentTime: 0,
1450
+ volume: 1,
1451
+ muted: false
1452
+ };
1453
+ var getSetPropKeys = Object.keys(getSetProps);
1454
+
1455
+ var playerStateObj = $.extend({
1456
+ isActive: 'html5',
1457
+ activating: 'html5',
1458
+ wasSwfReady: false,
1459
+ _bufferedEnd: 0,
1460
+ _bufferedStart: 0,
1461
+ _metadata: false,
1462
+ _durationCalcs: -1,
1463
+ _callMeta: false,
1464
+ currentTime: 0,
1465
+ _ppFlag: undefined
1466
+ }, getProps, getSetProps);
1467
+
1468
+ var idRep = /^jwplayer-/;
1469
+ var getSwfDataFromID = function(id){
1470
+
1471
+ var elem = document.getElementById(id.replace(idRep, ''));
1472
+ if(!elem){return;}
1473
+ var data = webshims.data(elem, 'mediaelement');
1474
+ return data.isActive == 'third' ? data : null;
1475
+ };
1476
+
1477
+
1478
+ var getSwfDataFromElem = function(elem){
1479
+ try {
1480
+ (elem.nodeName);
1481
+ } catch(er){
1482
+ return null;
1483
+ }
1484
+ var data = webshims.data(elem, 'mediaelement');
1485
+ return (data && data.isActive== 'third') ? data : null;
1486
+ };
1487
+
1488
+ var trigger = function(elem, evt){
1489
+ evt = $.Event(evt);
1490
+ evt.preventDefault();
1491
+ $.event.trigger(evt, undefined, elem);
1492
+ };
1493
+
1494
+ var playerSwfPath = options.playerPath || webshims.cfg.basePath + "jwplayer/" + (options.playerName || "player.swf");
1495
+ var jwplugin = options.pluginPath || webshims.cfg.basePath +'swf/jwwebshims.swf';
1496
+
1497
+ webshims.extendUNDEFProp(options.params, {
1498
+ allowscriptaccess: 'always',
1499
+ allowfullscreen: 'true',
1500
+ wmode: 'transparent'
1501
+ });
1502
+ webshims.extendUNDEFProp(options.vars, {
1503
+ screencolor: 'ffffffff'
1504
+ });
1505
+ webshims.extendUNDEFProp(options.attrs, {
1506
+ bgcolor: '#000000'
1507
+ });
1508
+
1509
+ var getDuration = function(data, obj){
1510
+ var curDuration = data.duration;
1511
+ if(curDuration && data._durationCalcs > 0){return;}
1512
+ try {
1513
+ data.duration = data.jwapi.getPlaylist()[0].duration;
1514
+ if(!data.duration || data.duration <= 0 || data.duration === data._lastDuration){
1515
+ data.duration = curDuration;
1516
+ }
1517
+ } catch(er){}
1518
+ if(data.duration && data.duration != data._lastDuration){
1519
+ trigger(data._elem, 'durationchange');
1520
+ if(data._elemNodeName == 'audio' || data._callMeta){
1521
+ mediaelement.jwEvents.Model.META($.extend({duration: data.duration}, obj), data);
1522
+ }
1523
+ data._durationCalcs--;
1524
+ } else {
1525
+ data._durationCalcs++;
1526
+ }
1527
+ };
1528
+ var setReadyState = function(readyState, data){
1529
+ if(readyState < 3){
1530
+ clearTimeout(data._canplaythroughTimer);
1531
+ }
1532
+ if(readyState >= 3 && data.readyState < 3){
1533
+ data.readyState = readyState;
1534
+ trigger(data._elem, 'canplay');
1535
+ clearTimeout(data._canplaythroughTimer);
1536
+ data._canplaythroughTimer = setTimeout(function(){
1537
+ setReadyState(4, data);
1538
+ }, 4000);
1539
+ }
1540
+ if(readyState >= 4 && data.readyState < 4){
1541
+ data.readyState = readyState;
1542
+ trigger(data._elem, 'canplaythrough');
1543
+ }
1544
+ data.readyState = readyState;
1545
+ };
1546
+
1547
+ $.extend($.event.customEvent, {
1548
+ updatemediaelementdimensions: true,
1549
+ flashblocker: true,
1550
+ swfstageresize: true,
1551
+ mediaelementapichange: true
1552
+ });
1553
+
1554
+ mediaelement.jwEvents = {
1555
+ View: {
1556
+
1557
+ PLAY: function(obj){
1558
+ var data = getSwfDataFromID(obj.id);
1559
+ if(!data || data.stopPlayPause){return;}
1560
+ data._ppFlag = true;
1561
+ if(data.paused == obj.state){
1562
+ data.paused = !obj.state;
1563
+ if(data.ended){
1564
+ data.ended = false;
1565
+ }
1566
+ trigger(data._elem, obj.state ? 'play' : 'pause');
1567
+ }
1568
+ }
1569
+ },
1570
+ Model: {
1571
+
1572
+ BUFFER: function(obj){
1573
+ var data = getSwfDataFromID(obj.id);
1574
+ if(!data || !('percentage' in obj) || data._bufferedEnd == obj.percentage){return;}
1575
+ data.networkState = (obj.percentage == 100) ? 1 : 2;
1576
+ if(isNaN(data.duration) || (obj.percentage > 5 && obj.percentage < 25) || (obj.percentage === 100)){
1577
+ getDuration(data, obj);
1578
+ }
1579
+
1580
+ if(data.ended){
1581
+ data.ended = false;
1582
+ }
1583
+ if(!data.duration){
1584
+ return;
1585
+ }
1586
+ if(obj.percentage > 2 && obj.percentage < 20){
1587
+ setReadyState(3, data);
1588
+ } else if(obj.percentage > 20){
1589
+ setReadyState(4, data);
1590
+ }
1591
+ if(data._bufferedEnd && (data._bufferedEnd > obj.percentage)){
1592
+ data._bufferedStart = data.currentTime || 0;
1593
+ }
1594
+
1595
+ data._bufferedEnd = obj.percentage;
1596
+ data.buffered.length = 1;
1597
+ if(obj.percentage == 100){
1598
+ data.networkState = 1;
1599
+ setReadyState(4, data);
1600
+ }
1601
+ $.event.trigger('progress', undefined, data._elem, true);
1602
+ },
1603
+ META: function(obj, data){
1604
+
1605
+ data = data && data.networkState ? data : getSwfDataFromID(obj.id);
1606
+
1607
+ if(!data){return;}
1608
+ if( !('duration' in obj) ){
1609
+ data._callMeta = true;
1610
+ return;
1611
+ }
1612
+
1613
+ if( data._metadata && (!obj.height || data.videoHeight == obj.height) && (obj.duration === data.duration) ){return;}
1614
+
1615
+ data._metadata = true;
1616
+
1617
+ var oldDur = data.duration;
1618
+ if(obj.duration){
1619
+ data.duration = obj.duration;
1620
+ }
1621
+ data._lastDuration = data.duration;
1622
+ if(obj.height || obj.width){
1623
+ data.videoHeight = obj.height || 0;
1624
+ data.videoWidth = obj.width || 0;
1625
+ }
1626
+ if(!data.networkState){
1627
+ data.networkState = 2;
1628
+ }
1629
+ if(data.readyState < 1){
1630
+ setReadyState(1, data);
1631
+ }
1632
+ if(data.duration && oldDur !== data.duration){
1633
+ trigger(data._elem, 'durationchange');
1634
+ }
1635
+
1636
+ trigger(data._elem, 'loadedmetadata');
1637
+ },
1638
+ TIME: function(obj){
1639
+ var data = getSwfDataFromID(obj.id);
1640
+ if(!data || data.currentTime === obj.position){return;}
1641
+ data.currentTime = obj.position;
1642
+ if(data.duration && data.duration < data.currentTime){
1643
+ getDuration(data, obj);
1644
+ }
1645
+ if(data.readyState < 2){
1646
+ setReadyState(2, data);
1647
+ }
1648
+ if(data.ended){
1649
+ data.ended = false;
1650
+ }
1651
+ trigger(data._elem, 'timeupdate');
1652
+
1653
+ },
1654
+ STATE: function(obj){
1655
+ var data = getSwfDataFromID(obj.id);
1656
+ if(!data){return;}
1657
+ switch(obj.newstate) {
1658
+ case 'BUFFERING':
1659
+
1660
+ if(data.ended){
1661
+ data.ended = false;
1662
+ }
1663
+ setReadyState(1, data);
1664
+ trigger(data._elem, 'waiting');
1665
+ break;
1666
+ case 'PLAYING':
1667
+ data.paused = false;
1668
+ data._ppFlag = true;
1669
+ if(!data.duration){
1670
+ getDuration(data, obj);
1671
+ }
1672
+ if(data.readyState < 3){
1673
+ setReadyState(3, data);
1674
+ }
1675
+ if(data.ended){
1676
+ data.ended = false;
1677
+ }
1678
+ trigger(data._elem, 'playing');
1679
+ break;
1680
+ case 'PAUSED':
1681
+ if(!data.paused && !data.stopPlayPause){
1682
+ data.paused = true;
1683
+ data._ppFlag = true;
1684
+ trigger(data._elem, 'pause');
1685
+ }
1686
+ break;
1687
+ case 'COMPLETED':
1688
+ if(data.readyState < 4){
1689
+ setReadyState(4, data);
1690
+ }
1691
+ data.ended = true;
1692
+ trigger(data._elem, 'ended');
1693
+ break;
1694
+ }
1695
+ }
1696
+ }
1697
+ ,Controller: {
1698
+
1699
+ ERROR: function(obj){
1700
+ var data = getSwfDataFromID(obj.id);
1701
+ if(!data){return;}
1702
+ mediaelement.setError(data._elem, obj.message);
1703
+ },
1704
+ SEEK: function(obj){
1705
+ var data = getSwfDataFromID(obj.id);
1706
+ if(!data){return;}
1707
+ if(data.ended){
1708
+ data.ended = false;
1709
+ }
1710
+ if(data.paused){
1711
+ try {
1712
+ data.jwapi[SENDEVENT]('play', 'false');
1713
+ } catch(er){}
1714
+ }
1715
+ if(data.currentTime != obj.position){
1716
+ data.currentTime = obj.position;
1717
+ trigger(data._elem, 'timeupdate');
1718
+ }
1719
+
1720
+
1721
+ },
1722
+ VOLUME: function(obj){
1723
+ var data = getSwfDataFromID(obj.id);
1724
+ if(!data){return;}
1725
+ var newVolume = obj.percentage / 100;
1726
+ if(data.volume == newVolume){return;}
1727
+ data.volume = newVolume;
1728
+ trigger(data._elem, 'volumechange');
1729
+ },
1730
+ MUTE: function(obj){
1731
+ if(obj.state){return;}
1732
+ var data = getSwfDataFromID(obj.id);
1733
+ if(!data){return;}
1734
+ if(data.muted == obj.state){return;}
1735
+ data.muted = obj.state;
1736
+ trigger(data._elem, 'volumechange');
1737
+ }
1738
+ }
1739
+ };
1740
+
1741
+ var initEvents = function(data){
1742
+ var passed = true;
1743
+ $.each(mediaelement.jwEvents, function(mvcName, evts){
1744
+ $.each(evts, function(evtName){
1745
+ try {
1746
+ data.jwapi['add'+ mvcName +'Listener'](evtName, 'jQuery.webshims.mediaelement.jwEvents.'+ mvcName +'.'+ evtName);
1747
+ } catch(er){
1748
+ passed = false;
1749
+ return false;
1750
+ }
1751
+ });
1752
+ });
1753
+ return passed;
1754
+ };
1755
+
1756
+ var workActionQueue = function(data){
1757
+ var actionLen = data.actionQueue.length;
1758
+ var i = 0;
1759
+ var operation;
1760
+ if(actionLen && data.isActive == 'third'){
1761
+ while(data.actionQueue.length && actionLen > i){
1762
+ i++;
1763
+ operation = data.actionQueue.shift();
1764
+ data.jwapi[operation.fn].apply(data.jwapi, operation.args);
1765
+ }
1766
+ }
1767
+ if(data.actionQueue.length){
1768
+ data.actionQueue = [];
1769
+ }
1770
+ };
1771
+ var startAutoPlay = function(data){
1772
+ if(!data){return;}
1773
+ if( (data._ppFlag === undefined && ($.prop(data._elem, 'autoplay')) || !data.paused)){
1774
+ setTimeout(function(){
1775
+ if(data.isActive == 'third' && (data._ppFlag === undefined || !data.paused)){
1776
+ try {
1777
+ $(data._elem).play();
1778
+ } catch(er){}
1779
+ }
1780
+ }, 1);
1781
+ }
1782
+ };
1783
+
1784
+
1785
+ mediaelement.playerResize = function(id){
1786
+ if(!id){return;}
1787
+ var elem = document.getElementById(id.replace(idRep, ''));
1788
+
1789
+ if(elem){
1790
+ $(elem).triggerHandler('swfstageresize');
1791
+ }
1792
+ elem = null;
1793
+ };
1794
+
1795
+
1796
+ $(document).on('emptied', function(e){
1797
+ var data = getSwfDataFromElem(e.target);
1798
+ startAutoPlay(data);
1799
+ });
1800
+
1801
+ var localConnectionTimer;
1802
+ mediaelement.jwPlayerReady = function(jwData){
1803
+ var data = getSwfDataFromID(jwData.id);
1804
+ var passed = true;
1805
+ var i = 0;
1806
+ var doneFn = function(){
1807
+ if(i > 9){return;}
1808
+ i++;
1809
+ if(initEvents(data)){
1810
+ if(!data.wasSwfReady){
1811
+ var version = parseFloat( jwData.version, 10);
1812
+ if(version < 5.1 || version >= 6){
1813
+ webshims.warn('mediaelement-swf is only testet with jwplayer 5.6+');
1814
+ }
1815
+ } else {
1816
+ $(data._elem).mediaLoad();
1817
+
1818
+ }
1819
+ data.wasSwfReady = true;
1820
+ data.tryedReframeing = 0;
1821
+ workActionQueue(data);
1822
+ startAutoPlay(data);
1823
+ } else {
1824
+ clearTimeout(data.reframeTimer);
1825
+ data.reframeTimer = setTimeout(doneFn, 9 * i);
1826
+ if(i > 2 && data.tryedReframeing < 9){
1827
+ data.tryedReframeing++;
1828
+ data.shadowElem.css({overflow: 'visible'});
1829
+ setTimeout(function(){
1830
+ data.shadowElem.css({overflow: 'hidden'});
1831
+ }, 16);
1832
+ }
1833
+ }
1834
+ };
1835
+ if(!data || !data.jwapi){return;}
1836
+ if(!data.tryedReframeing){
1837
+ data.tryedReframeing = 0;
1838
+ }
1839
+ clearTimeout(localConnectionTimer);
1840
+ data.jwData = jwData;
1841
+ data.shadowElem.removeClass('flashblocker-assumed');
1842
+ $.prop(data._elem, 'volume', data.volume);
1843
+ $.prop(data._elem, 'muted', data.muted);
1844
+ doneFn();
1845
+
1846
+ };
1847
+
1848
+ var addMediaToStopEvents = $.noop;
1849
+ if(hasNative){
1850
+ var stopEvents = {
1851
+ play: 1,
1852
+ playing: 1
1853
+ };
1854
+ var hideEvtArray = ['play', 'pause', 'playing', 'canplay', 'progress', 'waiting', 'ended', 'loadedmetadata', 'durationchange', 'emptied'];
1855
+ var hidevents = hideEvtArray.map(function(evt){
1856
+ return evt +'.webshimspolyfill';
1857
+ }).join(' ');
1858
+
1859
+ var hidePlayerEvents = function(event){
1860
+ var data = webshims.data(event.target, 'mediaelement');
1861
+ if(!data){return;}
1862
+ var isNativeHTML5 = ( event.originalEvent && event.originalEvent.type === event.type );
1863
+ if( isNativeHTML5 == (data.activating == 'third') ){
1864
+ event.stopImmediatePropagation();
1865
+ if(stopEvents[event.type] && data.isActive != data.activating){
1866
+ $(event.target).pause();
1867
+ }
1868
+ }
1869
+ };
1870
+
1871
+ addMediaToStopEvents = function(elem){
1872
+ $(elem)
1873
+ .off(hidevents)
1874
+ .on(hidevents, hidePlayerEvents)
1875
+ ;
1876
+ hideEvtArray.forEach(function(evt){
1877
+ webshims.moveToFirstEvent(elem, evt);
1878
+ });
1879
+ };
1880
+ addMediaToStopEvents(document);
1881
+ }
1882
+
1883
+
1884
+ mediaelement.setActive = function(elem, type, data){
1885
+ if(!data){
1886
+ data = webshims.data(elem, 'mediaelement');
1887
+ }
1888
+ if(!data || data.isActive == type){return;}
1889
+ if(type != 'html5' && type != 'third'){
1890
+ webshims.warn('wrong type for mediaelement activating: '+ type);
1891
+ }
1892
+ var shadowData = webshims.data(elem, 'shadowData');
1893
+ data.activating = type;
1894
+ $(elem).pause();
1895
+ data.isActive = type;
1896
+ if(type == 'third'){
1897
+ shadowData.shadowElement = shadowData.shadowFocusElement = data.shadowElem[0];
1898
+ $(elem).addClass('swf-api-active nonnative-api-active').hide().getShadowElement().show();
1899
+ } else {
1900
+ $(elem).removeClass('swf-api-active nonnative-api-active').show().getShadowElement().hide();
1901
+ shadowData.shadowElement = shadowData.shadowFocusElement = false;
1902
+ }
1903
+ $(elem).trigger('mediaelementapichange');
1904
+ };
1905
+
1906
+
1907
+
1908
+ var resetSwfProps = (function(){
1909
+ var resetProtoProps = ['_bufferedEnd', '_bufferedStart', '_metadata', '_ppFlag', 'currentSrc', 'currentTime', 'duration', 'ended', 'networkState', 'paused', 'videoHeight', 'videoWidth', '_callMeta', '_durationCalcs'];
1910
+ var len = resetProtoProps.length;
1911
+ return function(data){
1912
+
1913
+ if(!data){return;}
1914
+ var lenI = len;
1915
+ var networkState = data.networkState;
1916
+ setReadyState(0, data);
1917
+ while(--lenI){
1918
+ delete data[resetProtoProps[lenI]];
1919
+ }
1920
+ data.actionQueue = [];
1921
+ data.buffered.length = 0;
1922
+ if(networkState){
1923
+ trigger(data._elem, 'emptied');
1924
+ }
1925
+ };
1926
+ })();
1927
+
1928
+ var setElementDimension = function(data, hasControls){
1929
+ var elem = data._elem;
1930
+ var box = data.shadowElem;
1931
+ $(elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
1932
+ if(data._elemNodeName == 'audio' && !hasControls){
1933
+ box.css({width: 0, height: 0});
1934
+ } else {
1935
+ box.css({
1936
+ width: elem.style.width || $(elem).width(),
1937
+ height: elem.style.height || $(elem).height()
1938
+ });
1939
+ }
1940
+ };
1941
+
1942
+ mediaelement.createSWF = function( elem, canPlaySrc, data ){
1943
+ if(!hasFlash){
1944
+ setTimeout(function(){
1945
+ $(elem).mediaLoad(); //<- this should produce a mediaerror
1946
+ }, 1);
1947
+ return;
1948
+ }
1949
+
1950
+ if(loadedSwf < 1){
1951
+ loadedSwf = 1;
1952
+ } else {
1953
+ loadedSwf++;
1954
+ }
1955
+ var vars = $.extend({}, options.vars, {
1956
+ image: $.attr(elem, 'poster') && $.prop(elem, 'poster') || '',
1957
+ file: canPlaySrc.streamId || canPlaySrc.srcProp
1958
+ });
1959
+ var elemVars = $(elem).data('vars') || {};
1960
+
1961
+ if(canPlaySrc.server){
1962
+ vars.streamer = canPlaySrc.server;
1963
+ }
1964
+ if(!data){
1965
+ data = webshims.data(elem, 'mediaelement');
1966
+ }
1967
+
1968
+ if(data && data.swfCreated){
1969
+ mediaelement.setActive(elem, 'third', data);
1970
+ resetSwfProps(data);
1971
+ data.currentSrc = canPlaySrc.srcProp;
1972
+ $.extend(vars, elemVars);
1973
+ options.changeSWF(vars, elem, canPlaySrc, data, 'load');
1974
+ queueSwfMethod(elem, SENDEVENT, ['LOAD', vars]);
1975
+ return;
1976
+ }
1977
+
1978
+
1979
+ var hasControls = $.prop(elem, 'controls');
1980
+ var elemId = 'jwplayer-'+ webshims.getID(elem);
1981
+ var params = $.extend(
1982
+ {},
1983
+ options.params,
1984
+ $(elem).data('params')
1985
+ );
1986
+ var elemNodeName = elem.nodeName.toLowerCase();
1987
+ var attrs = $.extend(
1988
+ {},
1989
+ options.attrs,
1990
+ {
1991
+ name: elemId,
1992
+ id: elemId
1993
+ },
1994
+ $(elem).data('attrs')
1995
+ );
1996
+ var box = $('<div class="polyfill-'+ (elemNodeName) +' polyfill-mediaelement" id="wrapper-'+ elemId +'"><div id="'+ elemId +'"></div>')
1997
+ .css({
1998
+ position: 'relative',
1999
+ overflow: 'hidden'
2000
+ })
2001
+ ;
2002
+ data = webshims.data(elem, 'mediaelement', webshims.objectCreate(playerStateObj, {
2003
+ actionQueue: {
2004
+ value: []
2005
+ },
2006
+ shadowElem: {
2007
+ value: box
2008
+ },
2009
+ _elemNodeName: {
2010
+ value: elemNodeName
2011
+ },
2012
+ _elem: {
2013
+ value: elem
2014
+ },
2015
+ currentSrc: {
2016
+ value: canPlaySrc.srcProp
2017
+ },
2018
+ swfCreated: {
2019
+ value: true
2020
+ },
2021
+ buffered: {
2022
+ value: {
2023
+ start: function(index){
2024
+ if(index >= data.buffered.length){
2025
+ webshims.error('buffered index size error');
2026
+ return;
2027
+ }
2028
+ return 0;
2029
+ },
2030
+ end: function(index){
2031
+ if(index >= data.buffered.length){
2032
+ webshims.error('buffered index size error');
2033
+ return;
2034
+ }
2035
+ return ( (data.duration - data._bufferedStart) * data._bufferedEnd / 100) + data._bufferedStart;
2036
+ },
2037
+ length: 0
2038
+ }
2039
+ }
2040
+ }));
2041
+
2042
+ setElementDimension(data, hasControls);
2043
+
2044
+ box.insertBefore(elem);
2045
+
2046
+ if(hasNative){
2047
+ $.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted')});
2048
+ }
2049
+
2050
+ $.extend(vars,
2051
+ {
2052
+ id: elemId,
2053
+ controlbar: hasControls ? options.vars.controlbar || (elemNodeName == 'video' ? 'over' : 'bottom') : (elemNodeName == 'video') ? 'none' : 'bottom',
2054
+ icons: ''+ (hasControls && elemNodeName == 'video')
2055
+ },
2056
+ elemVars,
2057
+ {playerready: 'jQuery.webshims.mediaelement.jwPlayerReady'}
2058
+ );
2059
+ if(vars.plugins){
2060
+ vars.plugins += ','+jwplugin;
2061
+ } else {
2062
+ vars.plugins = jwplugin;
2063
+ }
2064
+
2065
+
2066
+ webshims.addShadowDom(elem, box);
2067
+
2068
+ addMediaToStopEvents(elem);
2069
+
2070
+ mediaelement.setActive(elem, 'third', data);
2071
+
2072
+ options.changeSWF(vars, elem, canPlaySrc, data, 'embed');
2073
+
2074
+ $(elem).on('updatemediaelementdimensions updateshadowdom', function(){
2075
+ setElementDimension(data, $.prop(elem, 'controls'));
2076
+ });
2077
+
2078
+
2079
+ swfobject.embedSWF(playerSwfPath, elemId, "100%", "100%", "9.0.0", false, vars, params, attrs, function(swfData){
2080
+
2081
+ if(swfData.success){
2082
+ data.jwapi = swfData.ref;
2083
+
2084
+ if(!hasControls){
2085
+ $(swfData.ref).attr('tabindex', '-1').css('outline', 'none');
2086
+ }
2087
+ setTimeout(function(){
2088
+ if((!swfData.ref.parentNode && box[0].parentNode) || swfData.ref.style.display == "none"){
2089
+ box.addClass('flashblocker-assumed');
2090
+ $(elem).trigger('flashblocker');
2091
+ webshims.warn("flashblocker assumed");
2092
+ }
2093
+ $(swfData.ref).css({'minHeight': '2px', 'minWidth': '2px', display: 'block'});
2094
+ }, 9);
2095
+ if(!localConnectionTimer){
2096
+ clearTimeout(localConnectionTimer);
2097
+ localConnectionTimer = setTimeout(function(){
2098
+ var flash = $(swfData.ref);
2099
+ if(flash[0].offsetWidth > 1 && flash[0].offsetHeight > 1 && location.protocol.indexOf('file:') === 0){
2100
+ webshims.error("Add your local development-directory to the local-trusted security sandbox: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html");
2101
+ } else if(flash[0].offsetWidth < 2 || flash[0].offsetHeight < 2) {
2102
+ webshims.warn("JS-SWF connection can't be established on hidden or unconnected flash objects");
2103
+ }
2104
+ flash = null;
2105
+ }, 8000);
2106
+ }
2107
+ }
2108
+ });
2109
+ };
2110
+
2111
+
2112
+ var queueSwfMethod = function(elem, fn, args, data){
2113
+ data = data || getSwfDataFromElem(elem);
2114
+ if(data){
2115
+ if(data.jwapi && data.jwapi[fn]){
2116
+ data.jwapi[fn].apply(data.jwapi, args || []);
2117
+ } else {
2118
+ //todo add to queue
2119
+ data.actionQueue.push({fn: fn, args: args});
2120
+ if(data.actionQueue.length > 10){
2121
+ setTimeout(function(){
2122
+ if(data.actionQueue.length > 5){
2123
+ data.actionQueue.shift();
2124
+ }
2125
+ }, 99);
2126
+ }
2127
+ }
2128
+ return data;
2129
+ }
2130
+ return false;
2131
+ };
2132
+
2133
+ ['audio', 'video'].forEach(function(nodeName){
2134
+ var descs = {};
2135
+ var mediaSup;
2136
+ var createGetProp = function(key){
2137
+ if(nodeName == 'audio' && (key == 'videoHeight' || key == 'videoWidth')){return;}
2138
+
2139
+ descs[key] = {
2140
+ get: function(){
2141
+ var data = getSwfDataFromElem(this);
2142
+ if(data){
2143
+ return data[key];
2144
+ } else if(hasNative && mediaSup[key].prop._supget) {
2145
+ return mediaSup[key].prop._supget.apply(this);
2146
+ } else {
2147
+ return playerStateObj[key];
2148
+ }
2149
+ },
2150
+ writeable: false
2151
+ };
2152
+ };
2153
+ var createGetSetProp = function(key, setFn){
2154
+ createGetProp(key);
2155
+ delete descs[key].writeable;
2156
+ descs[key].set = setFn;
2157
+ };
2158
+
2159
+ createGetSetProp('volume', function(v){
2160
+ var data = getSwfDataFromElem(this);
2161
+ if(data){
2162
+ v *= 100;
2163
+ if(!isNaN(v)){
2164
+ var muted = data.muted;
2165
+ if(v < 0 || v > 100){
2166
+ webshims.error('volume greater or less than allowed '+ (v / 100));
2167
+ }
2168
+
2169
+ queueSwfMethod(this, SENDEVENT, ['VOLUME', v], data);
2170
+ if(muted){
2171
+ try {
2172
+ data.jwapi.sendEvent('mute', 'true');
2173
+ } catch(er){}
2174
+ }
2175
+ v /= 100;
2176
+ if(data.volume == v || data.isActive != 'third'){return;}
2177
+ data.volume = v;
2178
+ trigger(data._elem, 'volumechange');
2179
+ data = null;
2180
+ }
2181
+ } else if(mediaSup.volume.prop._supset) {
2182
+ return mediaSup.volume.prop._supset.apply(this, arguments);
2183
+ }
2184
+ });
2185
+
2186
+ createGetSetProp('muted', function(m){
2187
+ var data = getSwfDataFromElem(this);
2188
+ if(data){
2189
+ m = !!m;
2190
+ queueSwfMethod(this, SENDEVENT, ['mute', ''+m], data);
2191
+ if(data.muted == m || data.isActive != 'third'){return;}
2192
+ data.muted = m;
2193
+ trigger(data._elem, 'volumechange');
2194
+ data = null;
2195
+ } else if(mediaSup.muted.prop._supset) {
2196
+ return mediaSup.muted.prop._supset.apply(this, arguments);
2197
+ }
2198
+ });
2199
+
2200
+
2201
+ createGetSetProp('currentTime', function(t){
2202
+ var data = getSwfDataFromElem(this);
2203
+ if(data){
2204
+ t *= 1;
2205
+ if (!isNaN(t)) {
2206
+ if(data.paused){
2207
+ clearTimeout(data.stopPlayPause);
2208
+ data.stopPlayPause = setTimeout(function(){
2209
+ data.paused = true;
2210
+ data.stopPlayPause = false;
2211
+ }, 50);
2212
+ }
2213
+ queueSwfMethod(this, SENDEVENT, ['SEEK', '' + t], data);
2214
+
2215
+ if(data.paused){
2216
+ if(data.readyState > 0){
2217
+ data.currentTime = t;
2218
+ trigger(data._elem, 'timeupdate');
2219
+ }
2220
+ try {
2221
+ data.jwapi[SENDEVENT]('play', 'false');
2222
+ } catch(er){}
2223
+
2224
+ }
2225
+ }
2226
+
2227
+ } else if(mediaSup.currentTime.prop._supset) {
2228
+ return mediaSup.currentTime.prop._supset.apply(this, arguments);
2229
+ }
2230
+ });
2231
+
2232
+ ['play', 'pause'].forEach(function(fn){
2233
+ descs[fn] = {
2234
+ value: function(){
2235
+ var data = getSwfDataFromElem(this);
2236
+ if(data){
2237
+ if(data.stopPlayPause){
2238
+ clearTimeout(data.stopPlayPause);
2239
+ }
2240
+ queueSwfMethod(this, SENDEVENT, ['play', fn == 'play'], data);
2241
+ setTimeout(function(){
2242
+ if(data.isActive == 'third'){
2243
+ data._ppFlag = true;
2244
+ if(data.paused != (fn != 'play')){
2245
+ data.paused = fn != 'play';
2246
+ trigger(data._elem, fn);
2247
+ }
2248
+ }
2249
+ }, 1);
2250
+ } else if(mediaSup[fn].prop._supvalue) {
2251
+ return mediaSup[fn].prop._supvalue.apply(this, arguments);
2252
+ }
2253
+ }
2254
+ };
2255
+ });
2256
+
2257
+ getPropKeys.forEach(createGetProp);
2258
+
2259
+ webshims.onNodeNamesPropertyModify(nodeName, 'controls', function(val, boolProp){
2260
+ var data = getSwfDataFromElem(this);
2261
+ $(this)[boolProp ? 'addClass' : 'removeClass']('webshims-controls');
2262
+
2263
+ if(data){
2264
+ try {
2265
+ queueSwfMethod(this, boolProp ? 'showControls' : 'hideControls', [nodeName], data);
2266
+ } catch(er){
2267
+ webshims.warn("you need to generate a crossdomain.xml");
2268
+ }
2269
+ if(nodeName == 'audio'){
2270
+ setElementDimension(data, boolProp);
2271
+ }
2272
+ $(data.jwapi).attr('tabindex', boolProp ? '0' : '-1');
2273
+ }
2274
+ });
2275
+
2276
+ mediaSup = webshims.defineNodeNameProperties(nodeName, descs, 'prop');
2277
+ });
2278
+
2279
+ if(hasFlash){
2280
+ var oldClean = $.cleanData;
2281
+ var gcBrowser = $.browser.msie && webshims.browserVersion < 9;
2282
+ var flashNames = {
2283
+ object: 1,
2284
+ OBJECT: 1
2285
+ };
2286
+ $.cleanData = function(elems){
2287
+ var i, len, prop;
2288
+ if(elems && (len = elems.length) && loadedSwf){
2289
+
2290
+ for(i = 0; i < len; i++){
2291
+ if(flashNames[elems[i].nodeName]){
2292
+ if(SENDEVENT in elems[i]){
2293
+ loadedSwf--;
2294
+ try {
2295
+ elems[i][SENDEVENT]('play', false);
2296
+ } catch(er){}
2297
+ }
2298
+ if(gcBrowser){
2299
+ try {
2300
+ for (prop in elems[i]) {
2301
+ if (typeof elems[i][prop] == "function") {
2302
+ elems[i][prop] = null;
2303
+ }
2304
+ }
2305
+ } catch(er){}
2306
+ }
2307
+ }
2308
+ }
2309
+
2310
+ }
2311
+ return oldClean.apply(this, arguments);
2312
+ };
2313
+ }
2314
+
2315
+ if(!hasNative){
2316
+
2317
+ ['poster', 'src'].forEach(function(prop){
2318
+ webshims.defineNodeNamesProperty(prop == 'src' ? ['audio', 'video', 'source'] : ['video'], prop, {
2319
+ //attr: {},
2320
+ reflect: true,
2321
+ propType: 'src'
2322
+ });
2323
+ });
2324
+
2325
+
2326
+ ['autoplay', 'controls'].forEach(function(name){
2327
+ webshims.defineNodeNamesBooleanProperty(['audio', 'video'], name);
2328
+ });
2329
+
2330
+ webshims.defineNodeNamesProperties(['audio', 'video'], {
2331
+ HAVE_CURRENT_DATA: {
2332
+ value: 2
2333
+ },
2334
+ HAVE_ENOUGH_DATA: {
2335
+ value: 4
2336
+ },
2337
+ HAVE_FUTURE_DATA: {
2338
+ value: 3
2339
+ },
2340
+ HAVE_METADATA: {
2341
+ value: 1
2342
+ },
2343
+ HAVE_NOTHING: {
2344
+ value: 0
2345
+ },
2346
+ NETWORK_EMPTY: {
2347
+ value: 0
2348
+ },
2349
+ NETWORK_IDLE: {
2350
+ value: 1
2351
+ },
2352
+ NETWORK_LOADING: {
2353
+ value: 2
2354
+ },
2355
+ NETWORK_NO_SOURCE: {
2356
+ value: 3
2357
+ }
2358
+
2359
+ }, 'prop');
2360
+ }
2362
2361
  });