webshims-rails 1.14.3 → 1.14.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/extras/modernizr-custom.js +4 -0
  4. data/vendor/assets/javascripts/webshims/polyfiller.js +141 -139
  5. data/vendor/assets/javascripts/webshims/shims/color-picker.js +1 -3
  6. data/vendor/assets/javascripts/webshims/shims/combos/1.js +22 -33
  7. data/vendor/assets/javascripts/webshims/shims/combos/10.js +76 -73
  8. data/vendor/assets/javascripts/webshims/shims/combos/11.js +73 -61
  9. data/vendor/assets/javascripts/webshims/shims/combos/12.js +37 -41
  10. data/vendor/assets/javascripts/webshims/shims/combos/13.js +36 -40
  11. data/vendor/assets/javascripts/webshims/shims/combos/14.js +7 -7
  12. data/vendor/assets/javascripts/webshims/shims/combos/15.js +23 -32
  13. data/vendor/assets/javascripts/webshims/shims/combos/16.js +36 -57
  14. data/vendor/assets/javascripts/webshims/shims/combos/17.js +73 -61
  15. data/vendor/assets/javascripts/webshims/shims/combos/18.js +611 -4604
  16. data/vendor/assets/javascripts/webshims/shims/combos/2.js +27 -47
  17. data/vendor/assets/javascripts/webshims/shims/combos/21.js +61 -31
  18. data/vendor/assets/javascripts/webshims/shims/combos/22.js +24 -16
  19. data/vendor/assets/javascripts/webshims/shims/combos/23.js +13 -25
  20. data/vendor/assets/javascripts/webshims/shims/combos/25.js +40 -27
  21. data/vendor/assets/javascripts/webshims/shims/combos/27.js +167 -166
  22. data/vendor/assets/javascripts/webshims/shims/combos/28.js +11 -12
  23. data/vendor/assets/javascripts/webshims/shims/combos/29.js +5 -5
  24. data/vendor/assets/javascripts/webshims/shims/combos/3.js +14 -22
  25. data/vendor/assets/javascripts/webshims/shims/combos/30.js +16 -24
  26. data/vendor/assets/javascripts/webshims/shims/combos/31.js +14 -22
  27. data/vendor/assets/javascripts/webshims/shims/combos/33.js +2 -2
  28. data/vendor/assets/javascripts/webshims/shims/combos/34.js +27 -28
  29. data/vendor/assets/javascripts/webshims/shims/combos/4.js +5 -14
  30. data/vendor/assets/javascripts/webshims/shims/combos/5.js +78 -66
  31. data/vendor/assets/javascripts/webshims/shims/combos/6.js +80 -68
  32. data/vendor/assets/javascripts/webshims/shims/combos/7.js +29 -49
  33. data/vendor/assets/javascripts/webshims/shims/combos/8.js +27 -47
  34. data/vendor/assets/javascripts/webshims/shims/combos/9.js +78 -75
  35. data/vendor/assets/javascripts/webshims/shims/combos/97.js +42 -29
  36. data/vendor/assets/javascripts/webshims/shims/combos/98.js +116 -40
  37. data/vendor/assets/javascripts/webshims/shims/combos/99.js +112 -38
  38. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +3 -12
  39. data/vendor/assets/javascripts/webshims/shims/es5.js +4 -4
  40. data/vendor/assets/javascripts/webshims/shims/es6.js +1887 -0
  41. data/vendor/assets/javascripts/webshims/shims/form-core.js +9 -8
  42. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +2 -2
  43. data/vendor/assets/javascripts/webshims/shims/form-inputmode.js +52 -0
  44. data/vendor/assets/javascripts/webshims/shims/form-message.js +2 -2
  45. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +4 -5
  46. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +73 -61
  47. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +7 -8
  48. data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +164 -163
  49. data/vendor/assets/javascripts/webshims/shims/form-validation.js +121 -144
  50. data/vendor/assets/javascripts/webshims/shims/jme/_icons.scss +3 -0
  51. data/vendor/assets/javascripts/webshims/shims/jme/alternate-media.js +184 -0
  52. data/vendor/assets/javascripts/webshims/shims/jme/{b.js → base.js} +38 -27
  53. data/vendor/assets/javascripts/webshims/shims/jme/controls.css +129 -39
  54. data/vendor/assets/javascripts/webshims/shims/jme/controls.scss +145 -44
  55. data/vendor/assets/javascripts/webshims/shims/jme/jme.eot +0 -0
  56. data/vendor/assets/javascripts/webshims/shims/jme/jme.svg +0 -0
  57. data/vendor/assets/javascripts/webshims/shims/jme/jme.ttf +0 -0
  58. data/vendor/assets/javascripts/webshims/shims/jme/jme.woff +0 -0
  59. data/vendor/assets/javascripts/webshims/shims/jme/mediacontrols-lazy.js +448 -90
  60. data/vendor/assets/javascripts/webshims/shims/jme/{c.js → mediacontrols.js} +74 -11
  61. data/vendor/assets/javascripts/webshims/shims/jme/{p.js → playlist.js} +4 -2
  62. data/vendor/assets/javascripts/webshims/shims/matchMedia.js +122 -0
  63. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +12 -24
  64. data/vendor/assets/javascripts/webshims/shims/mediaelement-debug.js +1 -1
  65. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +37 -15
  66. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +3 -3
  67. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +4 -5
  68. data/vendor/assets/javascripts/webshims/shims/picture.js +13 -54
  69. data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +13 -20
  70. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +24 -18
  71. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +32 -10
  72. data/vendor/assets/javascripts/webshims/shims/styles/shim-ext.css +43 -47
  73. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +30 -18
  74. data/vendor/assets/javascripts/webshims/shims/styles/transparent.png +0 -0
  75. data/vendor/assets/javascripts/webshims/shims/styles/widget.eot +0 -0
  76. data/vendor/assets/javascripts/webshims/shims/styles/widget.svg +0 -0
  77. data/vendor/assets/javascripts/webshims/shims/styles/widget.ttf +0 -0
  78. data/vendor/assets/javascripts/webshims/shims/styles/widget.woff +0 -0
  79. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  80. data/vendor/assets/javascripts/webshims/shims/swfmini.js +1 -1
  81. data/vendor/assets/javascripts/webshims/shims/track-ui.js +4 -5
  82. data/vendor/assets/javascripts/webshims/shims/track.js +24 -16
  83. metadata +9 -8
  84. data/vendor/assets/javascripts/webshims/shims/combos/19.js +0 -4745
  85. data/vendor/assets/javascripts/webshims/shims/combos/20.js +0 -4522
  86. data/vendor/assets/javascripts/webshims/shims/combos/32.js +0 -2443
  87. data/vendor/assets/javascripts/webshims/shims/combos/comboinfo.json +0 -1
@@ -1,4745 +0,0 @@
1
- /*! SWFMini - a SWFObject 2.2 cut down version for webshims
2
- *
3
- * based on SWFObject v2.2 <http://code.google.com/p/swfobject/>
4
- is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
5
- */
6
-
7
- var swfmini = function() {
8
- var wasRemoved = function(){webshims.error('This method was removed from swfmini');};
9
- var UNDEF = "undefined",
10
- OBJECT = "object",
11
- webshims = window.webshims,
12
- SHOCKWAVE_FLASH = "Shockwave Flash",
13
- SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
14
- FLASH_MIME_TYPE = "application/x-shockwave-flash",
15
-
16
- win = window,
17
- doc = document,
18
- nav = navigator,
19
-
20
- plugin = false,
21
- domLoadFnArr = [main],
22
-
23
- isDomLoaded = false,
24
- autoHideShow = true,
25
-
26
- /* Centralized function for browser feature detection
27
- - User agent string detection is only used when no good alternative is possible
28
- - Is executed directly for optimal performance
29
- */
30
- ua = function() {
31
- var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
32
- u = nav.userAgent.toLowerCase(),
33
- p = nav.platform.toLowerCase(),
34
- windows = p ? /win/.test(p) : /win/.test(u),
35
- mac = p ? /mac/.test(p) : /mac/.test(u),
36
- webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
37
- ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
38
- playerVersion = [0,0,0],
39
- d = null;
40
- if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
41
- d = nav.plugins[SHOCKWAVE_FLASH].description;
42
- if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
43
- plugin = true;
44
- ie = false; // cascaded feature detection for Internet Explorer
45
- d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
46
- playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
47
- playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
48
- playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
49
- }
50
- }
51
- else if (typeof win.ActiveXObject != UNDEF) {
52
- try {
53
- var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
54
- if (a) { // a will return null when ActiveX is disabled
55
- d = a.GetVariable("$version");
56
- if (d) {
57
- ie = true; // cascaded feature detection for Internet Explorer
58
- d = d.split(" ")[1].split(",");
59
- playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
60
- }
61
- }
62
- }
63
- catch(e) {}
64
- }
65
- return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
66
- }();
67
-
68
-
69
- function callDomLoadFunctions() {
70
- if (isDomLoaded) { return; }
71
- isDomLoaded = true;
72
- var dl = domLoadFnArr.length;
73
- for (var i = 0; i < dl; i++) {
74
- domLoadFnArr[i]();
75
- }
76
- }
77
-
78
- function addDomLoadEvent(fn) {
79
- if (isDomLoaded) {
80
- fn();
81
- }
82
- else {
83
- domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
84
- }
85
- }
86
-
87
-
88
- /* Main function
89
- - Will preferably execute onDomLoad, otherwise onload (as a fallback)
90
- */
91
- function main() {
92
- if (plugin) {
93
- testPlayerVersion();
94
- }
95
- }
96
-
97
- /* Detect the Flash Player version for non-Internet Explorer browsers
98
- - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
99
- a. Both release and build numbers can be detected
100
- b. Avoid wrong descriptions by corrupt installers provided by Adobe
101
- c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
102
- - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
103
- */
104
- function testPlayerVersion() {
105
- var b = doc.getElementsByTagName("body")[0];
106
- var o = createElement(OBJECT);
107
- o.setAttribute("type", FLASH_MIME_TYPE);
108
- var t = b.appendChild(o);
109
- if (t) {
110
- var counter = 0;
111
- (function(){
112
- if (typeof t.GetVariable != UNDEF) {
113
- var d = t.GetVariable("$version");
114
- if (d) {
115
- d = d.split(" ")[1].split(",");
116
- ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
117
- }
118
- }
119
- else if (counter < 10) {
120
- counter++;
121
- setTimeout(arguments.callee, 10);
122
- return;
123
- }
124
- b.removeChild(o);
125
- t = null;
126
- })();
127
- }
128
- }
129
-
130
-
131
- function createElement(el) {
132
- return doc.createElement(el);
133
- }
134
-
135
-
136
- /* Flash Player and SWF content version matching
137
- */
138
- function hasPlayerVersion(rv) {
139
- var pv = ua.pv, v = rv.split(".");
140
- v[0] = parseInt(v[0], 10);
141
- v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
142
- v[2] = parseInt(v[2], 10) || 0;
143
- return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
144
- }
145
-
146
-
147
-
148
-
149
-
150
- webshims.ready('DOM', callDomLoadFunctions);
151
-
152
- webshims.loader.addModule('swfmini-embed', {d: ['swfmini']});
153
- var loadEmbed = hasPlayerVersion('9.0.0') ?
154
- function(){
155
- webshims.loader.loadList(['swfmini-embed']);
156
- return true;
157
- } :
158
- webshims.$.noop
159
- ;
160
-
161
- if(!Modernizr.video){
162
- loadEmbed();
163
- } else {
164
- webshims.ready('WINDOWLOAD', loadEmbed);
165
- }
166
-
167
- return {
168
- /* Public API
169
- - Reference: http://code.google.com/p/swfobject/wiki/documentation
170
- */
171
- registerObject: wasRemoved,
172
-
173
- getObjectById: wasRemoved,
174
-
175
- embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
176
- var args = arguments;
177
- if(loadEmbed()){
178
- webshims.ready('swfmini-embed', function(){
179
- swfmini.embedSWF.apply(swfmini, args);
180
- });
181
- } else if(callbackFn) {
182
- callbackFn({success:false, id:replaceElemIdStr});
183
- }
184
- },
185
-
186
- switchOffAutoHideShow: function() {
187
- autoHideShow = false;
188
- },
189
-
190
- ua: ua,
191
-
192
- getFlashPlayerVersion: function() {
193
- return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
194
- },
195
-
196
- hasFlashPlayerVersion: hasPlayerVersion,
197
-
198
- createSWF: function(attObj, parObj, replaceElemIdStr) {
199
- if (ua.w3) {
200
- return createSWF(attObj, parObj, replaceElemIdStr);
201
- }
202
- else {
203
- return undefined;
204
- }
205
- },
206
-
207
- showExpressInstall: wasRemoved,
208
-
209
- removeSWF: wasRemoved,
210
-
211
- createCSS: wasRemoved,
212
-
213
- addDomLoadEvent: addDomLoadEvent,
214
-
215
- addLoadEvent: wasRemoved,
216
-
217
-
218
- // For internal usage only
219
- expressInstallCallback: wasRemoved
220
- };
221
- }();
222
-
223
- webshims.isReady('swfmini', true);
224
- ;// Copyright 2009-2012 by contributors, MIT License
225
- // vim: ts=4 sts=4 sw=4 expandtab
226
-
227
- (function () {
228
- setTimeout(function(){
229
- webshims.isReady('es5', true);
230
- });
231
- /**
232
- * Brings an environment as close to ECMAScript 5 compliance
233
- * as is possible with the facilities of erstwhile engines.
234
- *
235
- * Annotated ES5: http://es5.github.com/ (specific links below)
236
- * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
237
- * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
238
- */
239
-
240
- // Shortcut to an often accessed properties, in order to avoid multiple
241
- // dereference that costs universally.
242
- var call = Function.prototype.call;
243
- var prototypeOfArray = Array.prototype;
244
- var prototypeOfObject = Object.prototype;
245
- var _Array_slice_ = prototypeOfArray.slice;
246
- var array_splice = Array.prototype.splice;
247
- var array_push = Array.prototype.push;
248
- var array_unshift = Array.prototype.unshift;
249
-
250
- // Having a toString local variable name breaks in Opera so use _toString.
251
- var _toString = prototypeOfObject.toString;
252
-
253
- var isFunction = function (val) {
254
- return prototypeOfObject.toString.call(val) === '[object Function]';
255
- };
256
- var isRegex = function (val) {
257
- return prototypeOfObject.toString.call(val) === '[object RegExp]';
258
- };
259
- var isArray = function isArray(obj) {
260
- return _toString.call(obj) === "[object Array]";
261
- };
262
- var isArguments = function isArguments(value) {
263
- var str = _toString.call(value);
264
- var isArgs = str === '[object Arguments]';
265
- if (!isArgs) {
266
- isArgs = !isArray(str)
267
- && value !== null
268
- && typeof value === 'object'
269
- && typeof value.length === 'number'
270
- && value.length >= 0
271
- && isFunction(value.callee);
272
- }
273
- return isArgs;
274
- };
275
-
276
- //
277
- // Function
278
- // ========
279
- //
280
-
281
- // ES-5 15.3.4.5
282
- // http://es5.github.com/#x15.3.4.5
283
-
284
- function Empty() {}
285
-
286
- if (!Function.prototype.bind) {
287
- Function.prototype.bind = function bind(that) { // .length is 1
288
- // 1. Let Target be the this value.
289
- var target = this;
290
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
291
- if (!isFunction(target)) {
292
- throw new TypeError("Function.prototype.bind called on incompatible " + target);
293
- }
294
- // 3. Let A be a new (possibly empty) internal list of all of the
295
- // argument values provided after thisArg (arg1, arg2 etc), in order.
296
- // XXX slicedArgs will stand in for "A" if used
297
- var args = _Array_slice_.call(arguments, 1); // for normal call
298
- // 4. Let F be a new native ECMAScript object.
299
- // 11. Set the [[Prototype]] internal property of F to the standard
300
- // built-in Function prototype object as specified in 15.3.3.1.
301
- // 12. Set the [[Call]] internal property of F as described in
302
- // 15.3.4.5.1.
303
- // 13. Set the [[Construct]] internal property of F as described in
304
- // 15.3.4.5.2.
305
- // 14. Set the [[HasInstance]] internal property of F as described in
306
- // 15.3.4.5.3.
307
- var binder = function () {
308
-
309
- if (this instanceof bound) {
310
- // 15.3.4.5.2 [[Construct]]
311
- // When the [[Construct]] internal method of a function object,
312
- // F that was created using the bind function is called with a
313
- // list of arguments ExtraArgs, the following steps are taken:
314
- // 1. Let target be the value of F's [[TargetFunction]]
315
- // internal property.
316
- // 2. If target has no [[Construct]] internal method, a
317
- // TypeError exception is thrown.
318
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
319
- // property.
320
- // 4. Let args be a new list containing the same values as the
321
- // list boundArgs in the same order followed by the same
322
- // values as the list ExtraArgs in the same order.
323
- // 5. Return the result of calling the [[Construct]] internal
324
- // method of target providing args as the arguments.
325
-
326
- var result = target.apply(
327
- this,
328
- args.concat(_Array_slice_.call(arguments))
329
- );
330
- if (Object(result) === result) {
331
- return result;
332
- }
333
- return this;
334
-
335
- } else {
336
- // 15.3.4.5.1 [[Call]]
337
- // When the [[Call]] internal method of a function object, F,
338
- // which was created using the bind function is called with a
339
- // this value and a list of arguments ExtraArgs, the following
340
- // steps are taken:
341
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
342
- // property.
343
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
344
- // property.
345
- // 3. Let target be the value of F's [[TargetFunction]] internal
346
- // property.
347
- // 4. Let args be a new list containing the same values as the
348
- // list boundArgs in the same order followed by the same
349
- // values as the list ExtraArgs in the same order.
350
- // 5. Return the result of calling the [[Call]] internal method
351
- // of target providing boundThis as the this value and
352
- // providing args as the arguments.
353
-
354
- // equiv: target.call(this, ...boundArgs, ...args)
355
- return target.apply(
356
- that,
357
- args.concat(_Array_slice_.call(arguments))
358
- );
359
-
360
- }
361
-
362
- };
363
-
364
- // 15. If the [[Class]] internal property of Target is "Function", then
365
- // a. Let L be the length property of Target minus the length of A.
366
- // b. Set the length own property of F to either 0 or L, whichever is
367
- // larger.
368
- // 16. Else set the length own property of F to 0.
369
-
370
- var boundLength = Math.max(0, target.length - args.length);
371
-
372
- // 17. Set the attributes of the length own property of F to the values
373
- // specified in 15.3.5.1.
374
- var boundArgs = [];
375
- for (var i = 0; i < boundLength; i++) {
376
- boundArgs.push("$" + i);
377
- }
378
-
379
- // XXX Build a dynamic function with desired amount of arguments is the only
380
- // way to set the length property of a function.
381
- // In environments where Content Security Policies enabled (Chrome extensions,
382
- // for ex.) all use of eval or Function costructor throws an exception.
383
- // However in all of these environments Function.prototype.bind exists
384
- // and so this code will never be executed.
385
- var bound = Function("binder", "return function (" + boundArgs.join(",") + "){return binder.apply(this,arguments)}")(binder);
386
-
387
- if (target.prototype) {
388
- Empty.prototype = target.prototype;
389
- bound.prototype = new Empty();
390
- // Clean up dangling references.
391
- Empty.prototype = null;
392
- }
393
-
394
- // TODO
395
- // 18. Set the [[Extensible]] internal property of F to true.
396
-
397
- // TODO
398
- // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
399
- // 20. Call the [[DefineOwnProperty]] internal method of F with
400
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
401
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
402
- // false.
403
- // 21. Call the [[DefineOwnProperty]] internal method of F with
404
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
405
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
406
- // and false.
407
-
408
- // TODO
409
- // NOTE Function objects created using Function.prototype.bind do not
410
- // have a prototype property or the [[Code]], [[FormalParameters]], and
411
- // [[Scope]] internal properties.
412
- // XXX can't delete prototype in pure-js.
413
-
414
- // 22. Return F.
415
- return bound;
416
- };
417
- }
418
-
419
- // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
420
- // us it in defining shortcuts.
421
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
422
-
423
- // If JS engine supports accessors creating shortcuts.
424
- var defineGetter;
425
- var defineSetter;
426
- var lookupGetter;
427
- var lookupSetter;
428
- var supportsAccessors;
429
- if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
430
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
431
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
432
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
433
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
434
- }
435
-
436
- //
437
- // Array
438
- // =====
439
- //
440
-
441
- // ES5 15.4.4.12
442
- // http://es5.github.com/#x15.4.4.12
443
- var spliceWorksWithEmptyObject = (function () {
444
- var obj = {};
445
- Array.prototype.splice.call(obj, 0, 0, 1);
446
- return obj.length === 1;
447
- }());
448
- var omittingSecondSpliceArgIsNoop = [1].splice(0).length === 0;
449
- var spliceNoopReturnsEmptyArray = (function () {
450
- var a = [1, 2];
451
- var result = a.splice();
452
- return a.length === 2 && isArray(result) && result.length === 0;
453
- }());
454
- if (spliceNoopReturnsEmptyArray) {
455
- // Safari 5.0 bug where .split() returns undefined
456
- Array.prototype.splice = function splice(start, deleteCount) {
457
- if (arguments.length === 0) { return []; }
458
- else { return array_splice.apply(this, arguments); }
459
- };
460
- }
461
- if (!omittingSecondSpliceArgIsNoop || !spliceWorksWithEmptyObject) {
462
- Array.prototype.splice = function splice(start, deleteCount) {
463
- if (arguments.length === 0) { return []; }
464
- var args = arguments;
465
- this.length = Math.max(toInteger(this.length), 0);
466
- if (arguments.length > 0 && typeof deleteCount !== 'number') {
467
- args = _Array_slice_.call(arguments);
468
- if (args.length < 2) { args.push(toInteger(deleteCount)); }
469
- else { args[1] = toInteger(deleteCount); }
470
- }
471
- return array_splice.apply(this, args);
472
- };
473
- }
474
-
475
- // ES5 15.4.4.12
476
- // http://es5.github.com/#x15.4.4.13
477
- // Return len+argCount.
478
- // [bugfix, ielt8]
479
- // IE < 8 bug: [].unshift(0) === undefined but should be "1"
480
- if ([].unshift(0) !== 1) {
481
- Array.prototype.unshift = function () {
482
- array_unshift.apply(this, arguments);
483
- return this.length;
484
- };
485
- }
486
-
487
- // ES5 15.4.3.2
488
- // http://es5.github.com/#x15.4.3.2
489
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
490
- if (!Array.isArray) {
491
- Array.isArray = isArray;
492
- }
493
-
494
- // The IsCallable() check in the Array functions
495
- // has been replaced with a strict check on the
496
- // internal class of the object to trap cases where
497
- // the provided function was actually a regular
498
- // expression literal, which in V8 and
499
- // JavaScriptCore is a typeof "function". Only in
500
- // V8 are regular expression literals permitted as
501
- // reduce parameters, so it is desirable in the
502
- // general case for the shim to match the more
503
- // strict and common behavior of rejecting regular
504
- // expressions.
505
-
506
- // ES5 15.4.4.18
507
- // http://es5.github.com/#x15.4.4.18
508
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
509
-
510
- // Check failure of by-index access of string characters (IE < 9)
511
- // and failure of `0 in boxedString` (Rhino)
512
- var boxedString = Object("a");
513
- var splitString = boxedString[0] !== "a" || !(0 in boxedString);
514
-
515
- var properlyBoxesContext = function properlyBoxed(method) {
516
- // Check node 0.6.21 bug where third parameter is not boxed
517
- var properlyBoxesNonStrict = true;
518
- var properlyBoxesStrict = true;
519
- if (method) {
520
- method.call('foo', function (_, __, context) {
521
- if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
522
- });
523
-
524
- method.call([1], function () {
525
- 'use strict';
526
- properlyBoxesStrict = typeof this === 'string';
527
- }, 'x');
528
- }
529
- return !!method && properlyBoxesNonStrict && properlyBoxesStrict;
530
- };
531
-
532
- if (!Array.prototype.forEach || !properlyBoxesContext(Array.prototype.forEach)) {
533
- Array.prototype.forEach = function forEach(fun /*, thisp*/) {
534
- var object = toObject(this),
535
- self = splitString && _toString.call(this) === "[object String]" ?
536
- this.split("") :
537
- object,
538
- thisp = arguments[1],
539
- i = -1,
540
- length = self.length >>> 0;
541
-
542
- // If no callback function or if callback is not a callable function
543
- if (!isFunction(fun)) {
544
- throw new TypeError(); // TODO message
545
- }
546
-
547
- while (++i < length) {
548
- if (i in self) {
549
- // Invoke the callback function with call, passing arguments:
550
- // context, property value, property key, thisArg object
551
- // context
552
- fun.call(thisp, self[i], i, object);
553
- }
554
- }
555
- };
556
- }
557
-
558
- // ES5 15.4.4.19
559
- // http://es5.github.com/#x15.4.4.19
560
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
561
- if (!Array.prototype.map || !properlyBoxesContext(Array.prototype.map)) {
562
- Array.prototype.map = function map(fun /*, thisp*/) {
563
- var object = toObject(this),
564
- self = splitString && _toString.call(this) === "[object String]" ?
565
- this.split("") :
566
- object,
567
- length = self.length >>> 0,
568
- result = Array(length),
569
- thisp = arguments[1];
570
-
571
- // If no callback function or if callback is not a callable function
572
- if (!isFunction(fun)) {
573
- throw new TypeError(fun + " is not a function");
574
- }
575
-
576
- for (var i = 0; i < length; i++) {
577
- if (i in self) {
578
- result[i] = fun.call(thisp, self[i], i, object);
579
- }
580
- }
581
- return result;
582
- };
583
- }
584
-
585
- // ES5 15.4.4.20
586
- // http://es5.github.com/#x15.4.4.20
587
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
588
- if (!Array.prototype.filter || !properlyBoxesContext(Array.prototype.filter)) {
589
- Array.prototype.filter = function filter(fun /*, thisp */) {
590
- var object = toObject(this),
591
- self = splitString && _toString.call(this) === "[object String]" ?
592
- this.split("") :
593
- object,
594
- length = self.length >>> 0,
595
- result = [],
596
- value,
597
- thisp = arguments[1];
598
-
599
- // If no callback function or if callback is not a callable function
600
- if (!isFunction(fun)) {
601
- throw new TypeError(fun + " is not a function");
602
- }
603
-
604
- for (var i = 0; i < length; i++) {
605
- if (i in self) {
606
- value = self[i];
607
- if (fun.call(thisp, value, i, object)) {
608
- result.push(value);
609
- }
610
- }
611
- }
612
- return result;
613
- };
614
- }
615
-
616
- // ES5 15.4.4.16
617
- // http://es5.github.com/#x15.4.4.16
618
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
619
- if (!Array.prototype.every || !properlyBoxesContext(Array.prototype.every)) {
620
- Array.prototype.every = function every(fun /*, thisp */) {
621
- var object = toObject(this),
622
- self = splitString && _toString.call(this) === "[object String]" ?
623
- this.split("") :
624
- object,
625
- length = self.length >>> 0,
626
- thisp = arguments[1];
627
-
628
- // If no callback function or if callback is not a callable function
629
- if (!isFunction(fun)) {
630
- throw new TypeError(fun + " is not a function");
631
- }
632
-
633
- for (var i = 0; i < length; i++) {
634
- if (i in self && !fun.call(thisp, self[i], i, object)) {
635
- return false;
636
- }
637
- }
638
- return true;
639
- };
640
- }
641
-
642
- // ES5 15.4.4.17
643
- // http://es5.github.com/#x15.4.4.17
644
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
645
- if (!Array.prototype.some || !properlyBoxesContext(Array.prototype.some)) {
646
- Array.prototype.some = function some(fun /*, thisp */) {
647
- var object = toObject(this),
648
- self = splitString && _toString.call(this) === "[object String]" ?
649
- this.split("") :
650
- object,
651
- length = self.length >>> 0,
652
- thisp = arguments[1];
653
-
654
- // If no callback function or if callback is not a callable function
655
- if (!isFunction(fun)) {
656
- throw new TypeError(fun + " is not a function");
657
- }
658
-
659
- for (var i = 0; i < length; i++) {
660
- if (i in self && fun.call(thisp, self[i], i, object)) {
661
- return true;
662
- }
663
- }
664
- return false;
665
- };
666
- }
667
-
668
- // ES5 15.4.4.21
669
- // http://es5.github.com/#x15.4.4.21
670
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
671
- var reduceCoercesToObject = false;
672
- if (Array.prototype.reduce) {
673
- reduceCoercesToObject = typeof Array.prototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
674
- }
675
- if (!Array.prototype.reduce || !reduceCoercesToObject) {
676
- Array.prototype.reduce = function reduce(fun /*, initial*/) {
677
- var object = toObject(this),
678
- self = splitString && _toString.call(this) === "[object String]" ?
679
- this.split("") :
680
- object,
681
- length = self.length >>> 0;
682
-
683
- // If no callback function or if callback is not a callable function
684
- if (!isFunction(fun)) {
685
- throw new TypeError(fun + " is not a function");
686
- }
687
-
688
- // no value to return if no initial value and an empty array
689
- if (!length && arguments.length === 1) {
690
- throw new TypeError("reduce of empty array with no initial value");
691
- }
692
-
693
- var i = 0;
694
- var result;
695
- if (arguments.length >= 2) {
696
- result = arguments[1];
697
- } else {
698
- do {
699
- if (i in self) {
700
- result = self[i++];
701
- break;
702
- }
703
-
704
- // if array contains no values, no initial value to return
705
- if (++i >= length) {
706
- throw new TypeError("reduce of empty array with no initial value");
707
- }
708
- } while (true);
709
- }
710
-
711
- for (; i < length; i++) {
712
- if (i in self) {
713
- result = fun.call(void 0, result, self[i], i, object);
714
- }
715
- }
716
-
717
- return result;
718
- };
719
- }
720
-
721
- // ES5 15.4.4.22
722
- // http://es5.github.com/#x15.4.4.22
723
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
724
- var reduceRightCoercesToObject = false;
725
- if (Array.prototype.reduceRight) {
726
- reduceRightCoercesToObject = typeof Array.prototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
727
- }
728
- if (!Array.prototype.reduceRight || !reduceRightCoercesToObject) {
729
- Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
730
- var object = toObject(this),
731
- self = splitString && _toString.call(this) === "[object String]" ?
732
- this.split("") :
733
- object,
734
- length = self.length >>> 0;
735
-
736
- // If no callback function or if callback is not a callable function
737
- if (!isFunction(fun)) {
738
- throw new TypeError(fun + " is not a function");
739
- }
740
-
741
- // no value to return if no initial value, empty array
742
- if (!length && arguments.length === 1) {
743
- throw new TypeError("reduceRight of empty array with no initial value");
744
- }
745
-
746
- var result, i = length - 1;
747
- if (arguments.length >= 2) {
748
- result = arguments[1];
749
- } else {
750
- do {
751
- if (i in self) {
752
- result = self[i--];
753
- break;
754
- }
755
-
756
- // if array contains no values, no initial value to return
757
- if (--i < 0) {
758
- throw new TypeError("reduceRight of empty array with no initial value");
759
- }
760
- } while (true);
761
- }
762
-
763
- if (i < 0) {
764
- return result;
765
- }
766
-
767
- do {
768
- if (i in self) {
769
- result = fun.call(void 0, result, self[i], i, object);
770
- }
771
- } while (i--);
772
-
773
- return result;
774
- };
775
- }
776
-
777
- // ES5 15.4.4.14
778
- // http://es5.github.com/#x15.4.4.14
779
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
780
- if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) !== -1)) {
781
- Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
782
- var self = splitString && _toString.call(this) === "[object String]" ?
783
- this.split("") :
784
- toObject(this),
785
- length = self.length >>> 0;
786
-
787
- if (!length) {
788
- return -1;
789
- }
790
-
791
- var i = 0;
792
- if (arguments.length > 1) {
793
- i = toInteger(arguments[1]);
794
- }
795
-
796
- // handle negative indices
797
- i = i >= 0 ? i : Math.max(0, length + i);
798
- for (; i < length; i++) {
799
- if (i in self && self[i] === sought) {
800
- return i;
801
- }
802
- }
803
- return -1;
804
- };
805
- }
806
-
807
- // ES5 15.4.4.15
808
- // http://es5.github.com/#x15.4.4.15
809
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
810
- if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) !== -1)) {
811
- Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
812
- var self = splitString && _toString.call(this) === "[object String]" ?
813
- this.split("") :
814
- toObject(this),
815
- length = self.length >>> 0;
816
-
817
- if (!length) {
818
- return -1;
819
- }
820
- var i = length - 1;
821
- if (arguments.length > 1) {
822
- i = Math.min(i, toInteger(arguments[1]));
823
- }
824
- // handle negative indices
825
- i = i >= 0 ? i : length - Math.abs(i);
826
- for (; i >= 0; i--) {
827
- if (i in self && sought === self[i]) {
828
- return i;
829
- }
830
- }
831
- return -1;
832
- };
833
- }
834
-
835
- //
836
- // Object
837
- // ======
838
- //
839
-
840
- // ES5 15.2.3.14
841
- // http://es5.github.com/#x15.2.3.14
842
- var keysWorksWithArguments = Object.keys && (function () {
843
- return Object.keys(arguments).length === 2;
844
- }(1, 2));
845
- if (!Object.keys) {
846
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
847
- var hasDontEnumBug = !({'toString': null}).propertyIsEnumerable('toString'),
848
- hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
849
- dontEnums = [
850
- "toString",
851
- "toLocaleString",
852
- "valueOf",
853
- "hasOwnProperty",
854
- "isPrototypeOf",
855
- "propertyIsEnumerable",
856
- "constructor"
857
- ],
858
- dontEnumsLength = dontEnums.length;
859
-
860
- Object.keys = function keys(object) {
861
- var isFn = isFunction(object),
862
- isArgs = isArguments(object),
863
- isObject = object !== null && typeof object === 'object',
864
- isString = isObject && _toString.call(object) === '[object String]';
865
-
866
- if (!isObject && !isFn && !isArgs) {
867
- throw new TypeError("Object.keys called on a non-object");
868
- }
869
-
870
- var theKeys = [];
871
- var skipProto = hasProtoEnumBug && isFn;
872
- if (isString || isArgs) {
873
- for (var i = 0; i < object.length; ++i) {
874
- theKeys.push(String(i));
875
- }
876
- } else {
877
- for (var name in object) {
878
- if (!(skipProto && name === 'prototype') && owns(object, name)) {
879
- theKeys.push(String(name));
880
- }
881
- }
882
- }
883
-
884
- if (hasDontEnumBug) {
885
- var ctor = object.constructor,
886
- skipConstructor = ctor && ctor.prototype === object;
887
- for (var j = 0; j < dontEnumsLength; j++) {
888
- var dontEnum = dontEnums[j];
889
- if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
890
- theKeys.push(dontEnum);
891
- }
892
- }
893
- }
894
- return theKeys;
895
- };
896
- } else if (!keysWorksWithArguments) {
897
- // Safari 5.0 bug
898
- var originalKeys = Object.keys;
899
- Object.keys = function keys(object) {
900
- if (isArguments(object)) {
901
- return originalKeys(Array.prototype.slice.call(object));
902
- } else {
903
- return originalKeys(object);
904
- }
905
- };
906
- }
907
-
908
- //
909
- // Date
910
- // ====
911
- //
912
-
913
- // ES5 15.9.5.43
914
- // http://es5.github.com/#x15.9.5.43
915
- // This function returns a String value represent the instance in time
916
- // represented by this Date object. The format of the String is the Date Time
917
- // string format defined in 15.9.1.15. All fields are present in the String.
918
- // The time zone is always UTC, denoted by the suffix Z. If the time value of
919
- // this object is not a finite Number a RangeError exception is thrown.
920
- var negativeDate = -62198755200000,
921
- negativeYearString = "-000001";
922
- if (
923
- !Date.prototype.toISOString ||
924
- (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
925
- ) {
926
- Date.prototype.toISOString = function toISOString() {
927
- var result, length, value, year, month;
928
- if (!isFinite(this)) {
929
- throw new RangeError("Date.prototype.toISOString called on non-finite value.");
930
- }
931
-
932
- year = this.getUTCFullYear();
933
-
934
- month = this.getUTCMonth();
935
- // see https://github.com/es-shims/es5-shim/issues/111
936
- year += Math.floor(month / 12);
937
- month = (month % 12 + 12) % 12;
938
-
939
- // the date time string format is specified in 15.9.1.15.
940
- result = [month + 1, this.getUTCDate(), this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
941
- year = (
942
- (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
943
- ("00000" + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6)
944
- );
945
-
946
- length = result.length;
947
- while (length--) {
948
- value = result[length];
949
- // pad months, days, hours, minutes, and seconds to have two
950
- // digits.
951
- if (value < 10) {
952
- result[length] = "0" + value;
953
- }
954
- }
955
- // pad milliseconds to have three digits.
956
- return (
957
- year + "-" + result.slice(0, 2).join("-") +
958
- "T" + result.slice(2).join(":") + "." +
959
- ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
960
- );
961
- };
962
- }
963
-
964
-
965
- // ES5 15.9.5.44
966
- // http://es5.github.com/#x15.9.5.44
967
- // This function provides a String representation of a Date object for use by
968
- // JSON.stringify (15.12.3).
969
- var dateToJSONIsSupported = false;
970
- try {
971
- dateToJSONIsSupported = (
972
- Date.prototype.toJSON &&
973
- new Date(NaN).toJSON() === null &&
974
- new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
975
- Date.prototype.toJSON.call({ // generic
976
- toISOString: function () {
977
- return true;
978
- }
979
- })
980
- );
981
- } catch (e) {
982
- }
983
- if (!dateToJSONIsSupported) {
984
- Date.prototype.toJSON = function toJSON(key) {
985
- // When the toJSON method is called with argument key, the following
986
- // steps are taken:
987
-
988
- // 1. Let O be the result of calling ToObject, giving it the this
989
- // value as its argument.
990
- // 2. Let tv be toPrimitive(O, hint Number).
991
- var o = Object(this),
992
- tv = toPrimitive(o),
993
- toISO;
994
- // 3. If tv is a Number and is not finite, return null.
995
- if (typeof tv === "number" && !isFinite(tv)) {
996
- return null;
997
- }
998
- // 4. Let toISO be the result of calling the [[Get]] internal method of
999
- // O with argument "toISOString".
1000
- toISO = o.toISOString;
1001
- // 5. If IsCallable(toISO) is false, throw a TypeError exception.
1002
- if (typeof toISO !== "function") {
1003
- throw new TypeError("toISOString property is not callable");
1004
- }
1005
- // 6. Return the result of calling the [[Call]] internal method of
1006
- // toISO with O as the this value and an empty argument list.
1007
- return toISO.call(o);
1008
-
1009
- // NOTE 1 The argument is ignored.
1010
-
1011
- // NOTE 2 The toJSON function is intentionally generic; it does not
1012
- // require that its this value be a Date object. Therefore, it can be
1013
- // transferred to other kinds of objects for use as a method. However,
1014
- // it does require that any such object have a toISOString method. An
1015
- // object is free to use the argument key to filter its
1016
- // stringification.
1017
- };
1018
- }
1019
-
1020
- // ES5 15.9.4.2
1021
- // http://es5.github.com/#x15.9.4.2
1022
- // based on work shared by Daniel Friesen (dantman)
1023
- // http://gist.github.com/303249
1024
- var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
1025
- var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z'));
1026
- var doesNotParseY2KNewYear = isNaN(Date.parse("2000-01-01T00:00:00.000Z"));
1027
- if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
1028
- // XXX global assignment won't work in embeddings that use
1029
- // an alternate object for the context.
1030
- Date = (function (NativeDate) {
1031
-
1032
- // Date.length === 7
1033
- function Date(Y, M, D, h, m, s, ms) {
1034
- var length = arguments.length;
1035
- if (this instanceof NativeDate) {
1036
- var date = length === 1 && String(Y) === Y ? // isString(Y)
1037
- // We explicitly pass it through parse:
1038
- new NativeDate(Date.parse(Y)) :
1039
- // We have to manually make calls depending on argument
1040
- // length here
1041
- length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
1042
- length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
1043
- length >= 5 ? new NativeDate(Y, M, D, h, m) :
1044
- length >= 4 ? new NativeDate(Y, M, D, h) :
1045
- length >= 3 ? new NativeDate(Y, M, D) :
1046
- length >= 2 ? new NativeDate(Y, M) :
1047
- length >= 1 ? new NativeDate(Y) :
1048
- new NativeDate();
1049
- // Prevent mixups with unfixed Date object
1050
- date.constructor = Date;
1051
- return date;
1052
- }
1053
- return NativeDate.apply(this, arguments);
1054
- }
1055
-
1056
- // 15.9.1.15 Date Time String Format.
1057
- var isoDateExpression = new RegExp("^" +
1058
- "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
1059
- // 6-digit extended year
1060
- "(?:-(\\d{2})" + // optional month capture
1061
- "(?:-(\\d{2})" + // optional day capture
1062
- "(?:" + // capture hours:minutes:seconds.milliseconds
1063
- "T(\\d{2})" + // hours capture
1064
- ":(\\d{2})" + // minutes capture
1065
- "(?:" + // optional :seconds.milliseconds
1066
- ":(\\d{2})" + // seconds capture
1067
- "(?:(\\.\\d{1,}))?" + // milliseconds capture
1068
- ")?" +
1069
- "(" + // capture UTC offset component
1070
- "Z|" + // UTC capture
1071
- "(?:" + // offset specifier +/-hours:minutes
1072
- "([-+])" + // sign capture
1073
- "(\\d{2})" + // hours offset capture
1074
- ":(\\d{2})" + // minutes offset capture
1075
- ")" +
1076
- ")?)?)?)?" +
1077
- "$");
1078
-
1079
- var months = [
1080
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
1081
- ];
1082
-
1083
- function dayFromMonth(year, month) {
1084
- var t = month > 1 ? 1 : 0;
1085
- return (
1086
- months[month] +
1087
- Math.floor((year - 1969 + t) / 4) -
1088
- Math.floor((year - 1901 + t) / 100) +
1089
- Math.floor((year - 1601 + t) / 400) +
1090
- 365 * (year - 1970)
1091
- );
1092
- }
1093
-
1094
- function toUTC(t) {
1095
- return Number(new NativeDate(1970, 0, 1, 0, 0, 0, t));
1096
- }
1097
-
1098
- // Copy any custom methods a 3rd party library may have added
1099
- for (var key in NativeDate) {
1100
- Date[key] = NativeDate[key];
1101
- }
1102
-
1103
- // Copy "native" methods explicitly; they may be non-enumerable
1104
- Date.now = NativeDate.now;
1105
- Date.UTC = NativeDate.UTC;
1106
- Date.prototype = NativeDate.prototype;
1107
- Date.prototype.constructor = Date;
1108
-
1109
- // Upgrade Date.parse to handle simplified ISO 8601 strings
1110
- Date.parse = function parse(string) {
1111
- var match = isoDateExpression.exec(string);
1112
- if (match) {
1113
- // parse months, days, hours, minutes, seconds, and milliseconds
1114
- // provide default values if necessary
1115
- // parse the UTC offset component
1116
- var year = Number(match[1]),
1117
- month = Number(match[2] || 1) - 1,
1118
- day = Number(match[3] || 1) - 1,
1119
- hour = Number(match[4] || 0),
1120
- minute = Number(match[5] || 0),
1121
- second = Number(match[6] || 0),
1122
- millisecond = Math.floor(Number(match[7] || 0) * 1000),
1123
- // When time zone is missed, local offset should be used
1124
- // (ES 5.1 bug)
1125
- // see https://bugs.ecmascript.org/show_bug.cgi?id=112
1126
- isLocalTime = Boolean(match[4] && !match[8]),
1127
- signOffset = match[9] === "-" ? 1 : -1,
1128
- hourOffset = Number(match[10] || 0),
1129
- minuteOffset = Number(match[11] || 0),
1130
- result;
1131
- if (
1132
- hour < (
1133
- minute > 0 || second > 0 || millisecond > 0 ?
1134
- 24 : 25
1135
- ) &&
1136
- minute < 60 && second < 60 && millisecond < 1000 &&
1137
- month > -1 && month < 12 && hourOffset < 24 &&
1138
- minuteOffset < 60 && // detect invalid offsets
1139
- day > -1 &&
1140
- day < (
1141
- dayFromMonth(year, month + 1) -
1142
- dayFromMonth(year, month)
1143
- )
1144
- ) {
1145
- result = (
1146
- (dayFromMonth(year, month) + day) * 24 +
1147
- hour +
1148
- hourOffset * signOffset
1149
- ) * 60;
1150
- result = (
1151
- (result + minute + minuteOffset * signOffset) * 60 +
1152
- second
1153
- ) * 1000 + millisecond;
1154
- if (isLocalTime) {
1155
- result = toUTC(result);
1156
- }
1157
- if (-8.64e15 <= result && result <= 8.64e15) {
1158
- return result;
1159
- }
1160
- }
1161
- return NaN;
1162
- }
1163
- return NativeDate.parse.apply(this, arguments);
1164
- };
1165
-
1166
- return Date;
1167
- })(Date);
1168
- }
1169
-
1170
- // ES5 15.9.4.4
1171
- // http://es5.github.com/#x15.9.4.4
1172
- if (!Date.now) {
1173
- Date.now = function now() {
1174
- return new Date().getTime();
1175
- };
1176
- }
1177
-
1178
-
1179
- //
1180
- // Number
1181
- // ======
1182
- //
1183
-
1184
- // ES5.1 15.7.4.5
1185
- // http://es5.github.com/#x15.7.4.5
1186
- if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' || (1000000000000000128).toFixed(0) !== "1000000000000000128") {
1187
- // Hide these variables and functions
1188
- (function () {
1189
- var base, size, data, i;
1190
-
1191
- base = 1e7;
1192
- size = 6;
1193
- data = [0, 0, 0, 0, 0, 0];
1194
-
1195
- function multiply(n, c) {
1196
- var i = -1;
1197
- while (++i < size) {
1198
- c += n * data[i];
1199
- data[i] = c % base;
1200
- c = Math.floor(c / base);
1201
- }
1202
- }
1203
-
1204
- function divide(n) {
1205
- var i = size, c = 0;
1206
- while (--i >= 0) {
1207
- c += data[i];
1208
- data[i] = Math.floor(c / n);
1209
- c = (c % n) * base;
1210
- }
1211
- }
1212
-
1213
- function numToString() {
1214
- var i = size;
1215
- var s = '';
1216
- while (--i >= 0) {
1217
- if (s !== '' || i === 0 || data[i] !== 0) {
1218
- var t = String(data[i]);
1219
- if (s === '') {
1220
- s = t;
1221
- } else {
1222
- s += '0000000'.slice(0, 7 - t.length) + t;
1223
- }
1224
- }
1225
- }
1226
- return s;
1227
- }
1228
-
1229
- function pow(x, n, acc) {
1230
- return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
1231
- }
1232
-
1233
- function log(x) {
1234
- var n = 0;
1235
- while (x >= 4096) {
1236
- n += 12;
1237
- x /= 4096;
1238
- }
1239
- while (x >= 2) {
1240
- n += 1;
1241
- x /= 2;
1242
- }
1243
- return n;
1244
- }
1245
-
1246
- Number.prototype.toFixed = function toFixed(fractionDigits) {
1247
- var f, x, s, m, e, z, j, k;
1248
-
1249
- // Test for NaN and round fractionDigits down
1250
- f = Number(fractionDigits);
1251
- f = f !== f ? 0 : Math.floor(f);
1252
-
1253
- if (f < 0 || f > 20) {
1254
- throw new RangeError("Number.toFixed called with invalid number of decimals");
1255
- }
1256
-
1257
- x = Number(this);
1258
-
1259
- // Test for NaN
1260
- if (x !== x) {
1261
- return "NaN";
1262
- }
1263
-
1264
- // If it is too big or small, return the string value of the number
1265
- if (x <= -1e21 || x >= 1e21) {
1266
- return String(x);
1267
- }
1268
-
1269
- s = "";
1270
-
1271
- if (x < 0) {
1272
- s = "-";
1273
- x = -x;
1274
- }
1275
-
1276
- m = "0";
1277
-
1278
- if (x > 1e-21) {
1279
- // 1e-21 < x < 1e21
1280
- // -70 < log2(x) < 70
1281
- e = log(x * pow(2, 69, 1)) - 69;
1282
- z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1283
- z *= 0x10000000000000; // Math.pow(2, 52);
1284
- e = 52 - e;
1285
-
1286
- // -18 < e < 122
1287
- // x = z / 2 ^ e
1288
- if (e > 0) {
1289
- multiply(0, z);
1290
- j = f;
1291
-
1292
- while (j >= 7) {
1293
- multiply(1e7, 0);
1294
- j -= 7;
1295
- }
1296
-
1297
- multiply(pow(10, j, 1), 0);
1298
- j = e - 1;
1299
-
1300
- while (j >= 23) {
1301
- divide(1 << 23);
1302
- j -= 23;
1303
- }
1304
-
1305
- divide(1 << j);
1306
- multiply(1, 1);
1307
- divide(2);
1308
- m = numToString();
1309
- } else {
1310
- multiply(0, z);
1311
- multiply(1 << (-e), 0);
1312
- m = numToString() + '0.00000000000000000000'.slice(2, 2 + f);
1313
- }
1314
- }
1315
-
1316
- if (f > 0) {
1317
- k = m.length;
1318
-
1319
- if (k <= f) {
1320
- m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1321
- } else {
1322
- m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1323
- }
1324
- } else {
1325
- m = s + m;
1326
- }
1327
-
1328
- return m;
1329
- };
1330
- }());
1331
- }
1332
-
1333
-
1334
- //
1335
- // String
1336
- // ======
1337
- //
1338
-
1339
- // ES5 15.5.4.14
1340
- // http://es5.github.com/#x15.5.4.14
1341
-
1342
- // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
1343
- // Many browsers do not split properly with regular expressions or they
1344
- // do not perform the split correctly under obscure conditions.
1345
- // See http://blog.stevenlevithan.com/archives/cross-browser-split
1346
- // I've tested in many browsers and this seems to cover the deviant ones:
1347
- // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1348
- // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1349
- // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1350
- // [undefined, "t", undefined, "e", ...]
1351
- // ''.split(/.?/) should be [], not [""]
1352
- // '.'.split(/()()/) should be ["."], not ["", "", "."]
1353
-
1354
- var string_split = String.prototype.split;
1355
- if (
1356
- 'ab'.split(/(?:ab)*/).length !== 2 ||
1357
- '.'.split(/(.?)(.?)/).length !== 4 ||
1358
- 'tesst'.split(/(s)*/)[1] === "t" ||
1359
- 'test'.split(/(?:)/, -1).length !== 4 ||
1360
- ''.split(/.?/).length ||
1361
- '.'.split(/()()/).length > 1
1362
- ) {
1363
- (function () {
1364
- var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1365
-
1366
- String.prototype.split = function (separator, limit) {
1367
- var string = this;
1368
- if (separator === void 0 && limit === 0) {
1369
- return [];
1370
- }
1371
-
1372
- // If `separator` is not a regex, use native split
1373
- if (_toString.call(separator) !== "[object RegExp]") {
1374
- return string_split.call(this, separator, limit);
1375
- }
1376
-
1377
- var output = [],
1378
- flags = (separator.ignoreCase ? "i" : "") +
1379
- (separator.multiline ? "m" : "") +
1380
- (separator.extended ? "x" : "") + // Proposed for ES6
1381
- (separator.sticky ? "y" : ""), // Firefox 3+
1382
- lastLastIndex = 0,
1383
- // Make `global` and avoid `lastIndex` issues by working with a copy
1384
- separator2, match, lastIndex, lastLength;
1385
- separator = new RegExp(separator.source, flags + "g");
1386
- string += ""; // Type-convert
1387
- if (!compliantExecNpcg) {
1388
- // Doesn't need flags gy, but they don't hurt
1389
- separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1390
- }
1391
- /* Values for `limit`, per the spec:
1392
- * If undefined: 4294967295 // Math.pow(2, 32) - 1
1393
- * If 0, Infinity, or NaN: 0
1394
- * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1395
- * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1396
- * If other: Type-convert, then use the above rules
1397
- */
1398
- limit = limit === void 0 ?
1399
- -1 >>> 0 : // Math.pow(2, 32) - 1
1400
- ToUint32(limit);
1401
- while (match = separator.exec(string)) {
1402
- // `separator.lastIndex` is not reliable cross-browser
1403
- lastIndex = match.index + match[0].length;
1404
- if (lastIndex > lastLastIndex) {
1405
- output.push(string.slice(lastLastIndex, match.index));
1406
- // Fix browsers whose `exec` methods don't consistently return `undefined` for
1407
- // nonparticipating capturing groups
1408
- if (!compliantExecNpcg && match.length > 1) {
1409
- match[0].replace(separator2, function () {
1410
- for (var i = 1; i < arguments.length - 2; i++) {
1411
- if (arguments[i] === void 0) {
1412
- match[i] = void 0;
1413
- }
1414
- }
1415
- });
1416
- }
1417
- if (match.length > 1 && match.index < string.length) {
1418
- Array.prototype.push.apply(output, match.slice(1));
1419
- }
1420
- lastLength = match[0].length;
1421
- lastLastIndex = lastIndex;
1422
- if (output.length >= limit) {
1423
- break;
1424
- }
1425
- }
1426
- if (separator.lastIndex === match.index) {
1427
- separator.lastIndex++; // Avoid an infinite loop
1428
- }
1429
- }
1430
- if (lastLastIndex === string.length) {
1431
- if (lastLength || !separator.test("")) {
1432
- output.push("");
1433
- }
1434
- } else {
1435
- output.push(string.slice(lastLastIndex));
1436
- }
1437
- return output.length > limit ? output.slice(0, limit) : output;
1438
- };
1439
- }());
1440
-
1441
- // [bugfix, chrome]
1442
- // If separator is undefined, then the result array contains just one String,
1443
- // which is the this value (converted to a String). If limit is not undefined,
1444
- // then the output array is truncated so that it contains no more than limit
1445
- // elements.
1446
- // "0".split(undefined, 0) -> []
1447
- } else if ("0".split(void 0, 0).length) {
1448
- String.prototype.split = function split(separator, limit) {
1449
- if (separator === void 0 && limit === 0) { return []; }
1450
- return string_split.call(this, separator, limit);
1451
- };
1452
- }
1453
-
1454
- var str_replace = String.prototype.replace;
1455
- var replaceReportsGroupsCorrectly = (function () {
1456
- var groups = [];
1457
- 'x'.replace(/x(.)?/g, function (match, group) {
1458
- groups.push(group);
1459
- });
1460
- return groups.length === 1 && typeof groups[0] === 'undefined';
1461
- }());
1462
-
1463
- if (!replaceReportsGroupsCorrectly) {
1464
- String.prototype.replace = function replace(searchValue, replaceValue) {
1465
- var isFn = isFunction(replaceValue);
1466
- var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source);
1467
- if (!isFn || !hasCapturingGroups) {
1468
- return str_replace.call(this, searchValue, replaceValue);
1469
- } else {
1470
- var wrappedReplaceValue = function (match) {
1471
- var length = arguments.length;
1472
- var originalLastIndex = searchValue.lastIndex;
1473
- searchValue.lastIndex = 0;
1474
- var args = searchValue.exec(match);
1475
- searchValue.lastIndex = originalLastIndex;
1476
- args.push(arguments[length - 2], arguments[length - 1]);
1477
- return replaceValue.apply(this, args);
1478
- };
1479
- return str_replace.call(this, searchValue, wrappedReplaceValue);
1480
- }
1481
- };
1482
- }
1483
-
1484
- // ECMA-262, 3rd B.2.3
1485
- // Not an ECMAScript standard, although ECMAScript 3rd Edition has a
1486
- // non-normative section suggesting uniform semantics and it should be
1487
- // normalized across all browsers
1488
- // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1489
- if ("".substr && "0b".substr(-1) !== "b") {
1490
- var string_substr = String.prototype.substr;
1491
- /**
1492
- * Get the substring of a string
1493
- * @param {integer} start where to start the substring
1494
- * @param {integer} length how many characters to return
1495
- * @return {string}
1496
- */
1497
- String.prototype.substr = function substr(start, length) {
1498
- return string_substr.call(
1499
- this,
1500
- start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1501
- length
1502
- );
1503
- };
1504
- }
1505
-
1506
- // ES5 15.5.4.20
1507
- // whitespace from: http://es5.github.io/#x15.5.4.20
1508
- var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1509
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1510
- "\u2029\uFEFF";
1511
- var zeroWidth = '\u200b';
1512
- if (!String.prototype.trim || ws.trim() || !zeroWidth.trim()) {
1513
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1514
- // http://perfectionkills.com/whitespace-deviations/
1515
- ws = "[" + ws + "]";
1516
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1517
- trimEndRegexp = new RegExp(ws + ws + "*$");
1518
- String.prototype.trim = function trim() {
1519
- if (this === void 0 || this === null) {
1520
- throw new TypeError("can't convert " + this + " to object");
1521
- }
1522
- return String(this)
1523
- .replace(trimBeginRegexp, "")
1524
- .replace(trimEndRegexp, "");
1525
- };
1526
- }
1527
-
1528
- // ES-5 15.1.2.2
1529
- if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
1530
- parseInt = (function (origParseInt) {
1531
- var hexRegex = /^0[xX]/;
1532
- return function parseIntES5(str, radix) {
1533
- str = String(str).trim();
1534
- if (!Number(radix)) {
1535
- radix = hexRegex.test(str) ? 16 : 10;
1536
- }
1537
- return origParseInt(str, radix);
1538
- };
1539
- }(parseInt));
1540
- }
1541
-
1542
- //
1543
- // Util
1544
- // ======
1545
- //
1546
-
1547
- // ES5 9.4
1548
- // http://es5.github.com/#x9.4
1549
- // http://jsperf.com/to-integer
1550
-
1551
- function toInteger(n) {
1552
- n = +n;
1553
- if (n !== n) { // isNaN
1554
- n = 0;
1555
- } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
1556
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
1557
- }
1558
- return n;
1559
- }
1560
-
1561
- function isPrimitive(input) {
1562
- var type = typeof input;
1563
- return (
1564
- input === null ||
1565
- type === "undefined" ||
1566
- type === "boolean" ||
1567
- type === "number" ||
1568
- type === "string"
1569
- );
1570
- }
1571
-
1572
- function toPrimitive(input) {
1573
- var val, valueOf, toStr;
1574
- if (isPrimitive(input)) {
1575
- return input;
1576
- }
1577
- valueOf = input.valueOf;
1578
- if (isFunction(valueOf)) {
1579
- val = valueOf.call(input);
1580
- if (isPrimitive(val)) {
1581
- return val;
1582
- }
1583
- }
1584
- toStr = input.toString;
1585
- if (isFunction(toStr)) {
1586
- val = toStr.call(input);
1587
- if (isPrimitive(val)) {
1588
- return val;
1589
- }
1590
- }
1591
- throw new TypeError();
1592
- }
1593
-
1594
- // ES5 9.9
1595
- // http://es5.github.com/#x9.9
1596
- var toObject = function (o) {
1597
- if (o == null) { // this matches both null and undefined
1598
- throw new TypeError("can't convert " + o + " to object");
1599
- }
1600
- return Object(o);
1601
- };
1602
-
1603
- var ToUint32 = function ToUint32(x) {
1604
- return x >>> 0;
1605
- };
1606
-
1607
- })();
1608
-
1609
-
1610
-
1611
-
1612
- (function($, shims){
1613
- var defineProperty = 'defineProperty';
1614
- var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
1615
- //safari5 has defineProperty-interface, but it can't be used on dom-object
1616
- //only do this test in non-IE browsers, because this hurts dhtml-behavior in some IE8 versions
1617
- if (advancedObjectProperties && Object[defineProperty] && Object.prototype.__defineGetter__) {
1618
- (function(){
1619
- try {
1620
- var foo = document.createElement('foo');
1621
- Object[defineProperty](foo, 'bar', {
1622
- get: function(){
1623
- return true;
1624
- }
1625
- });
1626
- advancedObjectProperties = !!foo.bar;
1627
- }
1628
- catch (e) {
1629
- advancedObjectProperties = false;
1630
- }
1631
- foo = null;
1632
- })();
1633
- }
1634
-
1635
- Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)));
1636
- Modernizr.advancedObjectProperties = advancedObjectProperties;
1637
-
1638
- if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
1639
- var call = Function.prototype.call;
1640
- var prototypeOfObject = Object.prototype;
1641
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
1642
-
1643
- shims.objectCreate = function(proto, props, opts, no__proto__){
1644
- var o;
1645
- var f = function(){};
1646
-
1647
- f.prototype = proto;
1648
- o = new f();
1649
-
1650
- if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
1651
- o.__proto__ = proto;
1652
- }
1653
-
1654
- if(props){
1655
- shims.defineProperties(o, props);
1656
- }
1657
-
1658
- if(opts){
1659
- o.options = $.extend(true, {}, o.options || {}, opts);
1660
- opts = o.options;
1661
- }
1662
-
1663
- if(o._create && $.isFunction(o._create)){
1664
- o._create(opts);
1665
- }
1666
- return o;
1667
- };
1668
-
1669
- shims.defineProperties = function(object, props){
1670
- for (var name in props) {
1671
- if (owns(props, name)) {
1672
- shims.defineProperty(object, name, props[name]);
1673
- }
1674
- }
1675
- return object;
1676
- };
1677
-
1678
- var descProps = ['configurable', 'enumerable', 'writable'];
1679
- shims.defineProperty = function(proto, property, descriptor){
1680
- if(typeof descriptor != "object" || descriptor === null){return proto;}
1681
-
1682
- if(owns(descriptor, "value")){
1683
- proto[property] = descriptor.value;
1684
- return proto;
1685
- }
1686
-
1687
- if(proto.__defineGetter__){
1688
- if (typeof descriptor.get == "function") {
1689
- proto.__defineGetter__(property, descriptor.get);
1690
- }
1691
- if (typeof descriptor.set == "function"){
1692
- proto.__defineSetter__(property, descriptor.set);
1693
- }
1694
- }
1695
- return proto;
1696
- };
1697
-
1698
- shims.getPrototypeOf = function (object) {
1699
- return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
1700
- };
1701
-
1702
- //based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
1703
- shims.getOwnPropertyDescriptor = function(obj, prop){
1704
- if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
1705
- throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
1706
- }
1707
- var descriptor;
1708
- if(Object.defineProperty && Object.getOwnPropertyDescriptor){
1709
- try{
1710
- descriptor = Object.getOwnPropertyDescriptor(obj, prop);
1711
- return descriptor;
1712
- } catch(e){}
1713
- }
1714
- descriptor = {
1715
- configurable: true,
1716
- enumerable: true,
1717
- writable: true,
1718
- value: undefined
1719
- };
1720
- var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
1721
- setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
1722
- ;
1723
-
1724
- if (!getter && !setter) { // not an accessor so return prop
1725
- if(!owns(obj, prop)){
1726
- return;
1727
- }
1728
- descriptor.value = obj[prop];
1729
- return descriptor;
1730
- }
1731
-
1732
- // there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
1733
- delete descriptor.writable;
1734
- delete descriptor.value;
1735
- descriptor.get = descriptor.set = undefined;
1736
-
1737
- if(getter){
1738
- descriptor.get = getter;
1739
- }
1740
-
1741
- if(setter){
1742
- descriptor.set = setter;
1743
- }
1744
-
1745
- return descriptor;
1746
- };
1747
-
1748
- }
1749
- webshims.isReady('es5', true);
1750
- })(webshims.$, webshims);
1751
-
1752
-
1753
- ;
1754
- //this might was already extended by ES5 shim feature
1755
- (function($){
1756
- "use strict";
1757
- var webshims = window.webshims;
1758
- if(webshims.defineProperties){return;}
1759
- var defineProperty = 'defineProperty';
1760
- var has = Object.prototype.hasOwnProperty;
1761
- var descProps = ['configurable', 'enumerable', 'writable'];
1762
- var extendUndefined = function(prop){
1763
- for(var i = 0; i < 3; i++){
1764
- if(prop[descProps[i]] === undefined && (descProps[i] !== 'writable' || prop.value !== undefined)){
1765
- prop[descProps[i]] = true;
1766
- }
1767
- }
1768
- };
1769
-
1770
- var extendProps = function(props){
1771
- if(props){
1772
- for(var i in props){
1773
- if(has.call(props, i)){
1774
- extendUndefined(props[i]);
1775
- }
1776
- }
1777
- }
1778
- };
1779
-
1780
- if(Object.create){
1781
- webshims.objectCreate = function(proto, props, opts){
1782
- extendProps(props);
1783
- var o = Object.create(proto, props);
1784
- if(opts){
1785
- o.options = $.extend(true, {}, o.options || {}, opts);
1786
- opts = o.options;
1787
- }
1788
- if(o._create && $.isFunction(o._create)){
1789
- o._create(opts);
1790
- }
1791
- return o;
1792
- };
1793
- }
1794
-
1795
- if(Object[defineProperty]){
1796
- webshims[defineProperty] = function(obj, prop, desc){
1797
- extendUndefined(desc);
1798
- return Object[defineProperty](obj, prop, desc);
1799
- };
1800
- }
1801
- if(Object.defineProperties){
1802
- webshims.defineProperties = function(obj, props){
1803
- extendProps(props);
1804
- return Object.defineProperties(obj, props);
1805
- };
1806
- }
1807
- webshims.getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1808
-
1809
- webshims.getPrototypeOf = Object.getPrototypeOf;
1810
- })(window.webshims.$);
1811
- //DOM-Extension helper
1812
- webshims.register('dom-extend', function($, webshims, window, document, undefined){
1813
- "use strict";
1814
- var supportHrefNormalized = !('hrefNormalized' in $.support) || $.support.hrefNormalized;
1815
- var supportGetSetAttribute = !('getSetAttribute' in $.support) || $.support.getSetAttribute;
1816
- var has = Object.prototype.hasOwnProperty;
1817
- webshims.assumeARIA = supportGetSetAttribute || Modernizr.canvas || Modernizr.video || Modernizr.boxsizing;
1818
-
1819
- if($('<input type="email" />').attr('type') == 'text' || $('<form />').attr('novalidate') === "" || ('required' in $('<input />')[0].attributes)){
1820
- webshims.error("IE browser modes are busted in IE10+. Please test your HTML/CSS/JS with a real IE version or at least IETester or similiar tools");
1821
- }
1822
-
1823
- if('debug' in webshims){
1824
- webshims.error('Use webshims.setOptions("debug", true||false||"noCombo"); to debug flag');
1825
- }
1826
-
1827
- if (!webshims.cfg.no$Switch) {
1828
- var switch$ = function(){
1829
- if (window.jQuery && (!window.$ || window.jQuery == window.$) && !window.jQuery.webshims) {
1830
- webshims.error("jQuery was included more than once. Make sure to include it only once or try the $.noConflict(extreme) feature! Webshims and other Plugins might not work properly. Or set webshims.cfg.no$Switch to 'true'.");
1831
- if (window.$) {
1832
- window.$ = webshims.$;
1833
- }
1834
- window.jQuery = webshims.$;
1835
- }
1836
- if(webshims.M != Modernizr){
1837
- webshims.error("Modernizr was included more than once. Make sure to include it only once! Webshims and other scripts might not work properly.");
1838
- for(var i in Modernizr){
1839
- if(!(i in webshims.M)){
1840
- webshims.M[i] = Modernizr[i];
1841
- }
1842
- }
1843
- Modernizr = webshims.M;
1844
- }
1845
- };
1846
- switch$();
1847
- setTimeout(switch$, 90);
1848
- webshims.ready('DOM', switch$);
1849
- $(switch$);
1850
- webshims.ready('WINDOWLOAD', switch$);
1851
-
1852
- }
1853
-
1854
- //shortcus
1855
- var modules = webshims.modules;
1856
- var listReg = /\s*,\s*/;
1857
-
1858
- //proxying attribute
1859
- var olds = {};
1860
- var havePolyfill = {};
1861
- var hasPolyfillMethod = {};
1862
- var extendedProps = {};
1863
- var extendQ = {};
1864
- var modifyProps = {};
1865
-
1866
- var oldVal = $.fn.val;
1867
- var singleVal = function(elem, name, val, pass, _argless){
1868
- return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
1869
- };
1870
-
1871
- //jquery mobile and jquery ui
1872
- if(!$.widget){
1873
- (function(){
1874
- var _cleanData = $.cleanData;
1875
- $.cleanData = function( elems ) {
1876
- if(!$.widget){
1877
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
1878
- try {
1879
- $( elem ).triggerHandler( "remove" );
1880
- // http://bugs.jquery.com/ticket/8235
1881
- } catch( e ) {}
1882
- }
1883
- }
1884
- _cleanData( elems );
1885
- };
1886
- })();
1887
- }
1888
-
1889
-
1890
- $.fn.val = function(val){
1891
- var elem = this[0];
1892
- if(arguments.length && val == null){
1893
- val = '';
1894
- }
1895
- if(!arguments.length){
1896
- if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
1897
- return $.prop(elem, 'value', val, 'val', true);
1898
- }
1899
- if($.isArray(val)){
1900
- return oldVal.apply(this, arguments);
1901
- }
1902
- var isFunction = $.isFunction(val);
1903
- return this.each(function(i){
1904
- elem = this;
1905
- if(elem.nodeType === 1){
1906
- if(isFunction){
1907
- var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
1908
- if(genVal == null){
1909
- genVal = '';
1910
- }
1911
- $.prop(elem, 'value', genVal, 'val') ;
1912
- } else {
1913
- $.prop(elem, 'value', val, 'val');
1914
- }
1915
- }
1916
- });
1917
- };
1918
- $.fn.onTrigger = function(evt, fn){
1919
- return this.on(evt, fn).each(fn);
1920
- };
1921
-
1922
- $.fn.onWSOff = function(evt, fn, trigger, evtDel){
1923
- if(!evtDel){
1924
- evtDel = document;
1925
- }
1926
- $(evtDel)[trigger ? 'onTrigger' : 'on'](evt, fn);
1927
- this.on('remove', function(e){
1928
- if(!e.originalEvent){
1929
- $(evtDel).off(evt, fn);
1930
- }
1931
- });
1932
- return this;
1933
- };
1934
- var idCount = 0;
1935
- var dataID = '_webshims'+ (Math.round(Math.random() * 1000));
1936
- var elementData = function(elem, key, val){
1937
- elem = elem.jquery ? elem[0] : elem;
1938
- if(!elem){return val || {};}
1939
- var data = $.data(elem, dataID);
1940
- if(val !== undefined){
1941
- if(!data){
1942
- data = $.data(elem, dataID, {});
1943
- }
1944
- if(key){
1945
- data[key] = val;
1946
- }
1947
- }
1948
-
1949
- return key ? data && data[key] : data;
1950
- };
1951
-
1952
-
1953
- [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
1954
- $.fn[data.name] = function(){
1955
- var elems = [];
1956
- this.each(function(){
1957
- var shadowData = elementData(this, 'shadowData');
1958
- var elem = shadowData && shadowData[data.prop] || this;
1959
- if($.inArray(elem, elems) == -1){
1960
- elems.push(elem);
1961
- }
1962
- });
1963
- return this.pushStack(elems);
1964
- };
1965
- });
1966
-
1967
- function clone(elem, dataAndEvents, uniqueIds){
1968
- var cloned = $.clone( elem, dataAndEvents, false );
1969
- $(cloned.querySelectorAll('.'+webshims.shadowClass)).detach();
1970
- if(uniqueIds){
1971
- idCount++;
1972
- $(cloned.querySelectorAll('[id]')).prop('id', function(i, id){
1973
- return id +idCount;
1974
- });
1975
- } else {
1976
- $(cloned.querySelectorAll('audio[id^="ID-"], video[id^="ID-"], label[id^="ID-"]')).removeAttr('id');
1977
- }
1978
- return cloned;
1979
- }
1980
-
1981
- $.fn.clonePolyfill = function(dataAndEvents, uniqueIds){
1982
- dataAndEvents = dataAndEvents || false;
1983
- return this
1984
- .map(function() {
1985
- var cloned = clone( this, dataAndEvents, uniqueIds );
1986
- setTimeout(function(){
1987
- if($.contains(document.body, cloned)){
1988
- $(cloned).updatePolyfill();
1989
- }
1990
- });
1991
- return cloned;
1992
- })
1993
- ;
1994
- };
1995
-
1996
- //add support for $('video').trigger('play') in case extendNative is set to false
1997
- if(!webshims.cfg.extendNative && !webshims.cfg.noTriggerOverride){
1998
- (function(oldTrigger){
1999
- $.event.trigger = function(event, data, elem, onlyHandlers){
2000
-
2001
- if(!hasPolyfillMethod[event] || onlyHandlers || !elem || elem.nodeType !== 1){
2002
- return oldTrigger.apply(this, arguments);
2003
- }
2004
- var ret, isOrig, origName;
2005
- var origFn = elem[event];
2006
- var polyfilledFn = $.prop(elem, event);
2007
- var changeFn = polyfilledFn && origFn != polyfilledFn;
2008
- if(changeFn){
2009
- origName = '__ws'+event;
2010
- isOrig = (event in elem) && has.call(elem, event);
2011
- elem[event] = polyfilledFn;
2012
- elem[origName] = origFn;
2013
- }
2014
-
2015
- ret = oldTrigger.apply(this, arguments);
2016
- if (changeFn) {
2017
- if(isOrig){
2018
- elem[event] = origFn;
2019
- } else {
2020
- delete elem[event];
2021
- }
2022
- delete elem[origName];
2023
- }
2024
-
2025
- return ret;
2026
- };
2027
- })($.event.trigger);
2028
- }
2029
-
2030
- ['removeAttr', 'prop', 'attr'].forEach(function(type){
2031
- olds[type] = $[type];
2032
- $[type] = function(elem, name, value, pass, _argless){
2033
- var isVal = (pass == 'val');
2034
- var oldMethod = !isVal ? olds[type] : singleVal;
2035
- if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
2036
- return oldMethod(elem, name, value, pass, _argless);
2037
- }
2038
-
2039
- var nodeName = (elem.nodeName || '').toLowerCase();
2040
- var desc = extendedProps[nodeName];
2041
- var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
2042
- var propMethod;
2043
- var oldValMethod;
2044
- var ret;
2045
-
2046
-
2047
- if(!desc){
2048
- desc = extendedProps['*'];
2049
- }
2050
- if(desc){
2051
- desc = desc[name];
2052
- }
2053
-
2054
- if(desc){
2055
- propMethod = desc[curType];
2056
- }
2057
-
2058
- if(propMethod){
2059
- if(name == 'value'){
2060
- oldValMethod = propMethod.isVal;
2061
- propMethod.isVal = isVal;
2062
- }
2063
- if(curType === 'removeAttr'){
2064
- return propMethod.value.call(elem);
2065
- } else if(value === undefined){
2066
- return (propMethod.get) ?
2067
- propMethod.get.call(elem) :
2068
- propMethod.value
2069
- ;
2070
- } else if(propMethod.set) {
2071
- if(type == 'attr' && value === true){
2072
- value = name;
2073
- }
2074
-
2075
- ret = propMethod.set.call(elem, value);
2076
- }
2077
- if(name == 'value'){
2078
- propMethod.isVal = oldValMethod;
2079
- }
2080
- } else {
2081
- ret = oldMethod(elem, name, value, pass, _argless);
2082
- }
2083
- if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
2084
-
2085
- var boolValue;
2086
- if(curType == 'removeAttr'){
2087
- boolValue = false;
2088
- } else if(curType == 'prop'){
2089
- boolValue = !!(value);
2090
- } else {
2091
- boolValue = true;
2092
- }
2093
-
2094
- modifyProps[nodeName][name].forEach(function(fn){
2095
- if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
2096
- fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
2097
- }
2098
- });
2099
- }
2100
- return ret;
2101
- };
2102
-
2103
- extendQ[type] = function(nodeName, prop, desc){
2104
-
2105
- if(!extendedProps[nodeName]){
2106
- extendedProps[nodeName] = {};
2107
- }
2108
- if(!extendedProps[nodeName][prop]){
2109
- extendedProps[nodeName][prop] = {};
2110
- }
2111
- var oldDesc = extendedProps[nodeName][prop][type];
2112
- var getSup = function(propType, descriptor, oDesc){
2113
- var origProp;
2114
- if(descriptor && descriptor[propType]){
2115
- return descriptor[propType];
2116
- }
2117
- if(oDesc && oDesc[propType]){
2118
- return oDesc[propType];
2119
- }
2120
- if(type == 'prop' && prop == 'value'){
2121
- return function(value){
2122
- var elem = this;
2123
- return (desc.isVal) ?
2124
- singleVal(elem, prop, value, false, (arguments.length === 0)) :
2125
- olds[type](elem, prop, value)
2126
- ;
2127
- };
2128
- }
2129
- if(type == 'prop' && propType == 'value' && desc.value.apply){
2130
- origProp = '__ws'+prop;
2131
- hasPolyfillMethod[prop] = true;
2132
- return function(value){
2133
- var sup = this[origProp] || olds[type](this, prop);
2134
- if(sup && sup.apply){
2135
- sup = sup.apply(this, arguments);
2136
- }
2137
- return sup;
2138
- };
2139
- }
2140
- return function(value){
2141
- return olds[type](this, prop, value);
2142
- };
2143
- };
2144
- extendedProps[nodeName][prop][type] = desc;
2145
- if(desc.value === undefined){
2146
- if(!desc.set){
2147
- desc.set = desc.writeable ?
2148
- getSup('set', desc, oldDesc) :
2149
- (webshims.cfg.useStrict && prop == 'prop') ?
2150
- function(){throw(prop +' is readonly on '+ nodeName);} :
2151
- function(){webshims.info(prop +' is readonly on '+ nodeName);}
2152
- ;
2153
- }
2154
- if(!desc.get){
2155
- desc.get = getSup('get', desc, oldDesc);
2156
- }
2157
-
2158
- }
2159
-
2160
- ['value', 'get', 'set'].forEach(function(descProp){
2161
- if(desc[descProp]){
2162
- desc['_sup'+descProp] = getSup(descProp, oldDesc);
2163
- }
2164
- });
2165
- };
2166
-
2167
- });
2168
-
2169
- var extendNativeValue = (function(){
2170
- var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
2171
-
2172
- //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
2173
- var isExtendNativeSave = Modernizr.advancedObjectProperties && Modernizr.objectAccessor;
2174
- return function(nodeName, prop, desc){
2175
- var elem , elemProto;
2176
- if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
2177
- var sup = elem[prop];
2178
- desc._supvalue = function(){
2179
- if(sup && sup.apply){
2180
- return sup.apply(this, arguments);
2181
- }
2182
- return sup;
2183
- };
2184
- elemProto[prop] = desc.value;
2185
- } else {
2186
- desc._supvalue = function(){
2187
- var data = elementData(this, 'propValue');
2188
- if(data && data[prop] && data[prop].apply){
2189
- return data[prop].apply(this, arguments);
2190
- }
2191
- return data && data[prop];
2192
- };
2193
- initProp.extendValue(nodeName, prop, desc.value);
2194
- }
2195
- desc.value._supvalue = desc._supvalue;
2196
- };
2197
- })();
2198
-
2199
- var initProp = (function(){
2200
-
2201
- var initProps = {};
2202
-
2203
- webshims.addReady(function(context, contextElem){
2204
- var nodeNameCache = {};
2205
- var getElementsByName = function(name){
2206
- if(!nodeNameCache[name]){
2207
- nodeNameCache[name] = $(context.getElementsByTagName(name));
2208
- if(contextElem[0] && $.nodeName(contextElem[0], name)){
2209
- nodeNameCache[name] = nodeNameCache[name].add(contextElem);
2210
- }
2211
- }
2212
- };
2213
-
2214
-
2215
- $.each(initProps, function(name, fns){
2216
- getElementsByName(name);
2217
- if(!fns || !fns.forEach){
2218
- webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
2219
- return;
2220
- }
2221
- fns.forEach(function(fn){
2222
- nodeNameCache[name].each(fn);
2223
- });
2224
- });
2225
- nodeNameCache = null;
2226
- });
2227
-
2228
- var tempCache;
2229
- var emptyQ = $([]);
2230
- var createNodeNameInit = function(nodeName, fn){
2231
- if(!initProps[nodeName]){
2232
- initProps[nodeName] = [fn];
2233
- } else {
2234
- initProps[nodeName].push(fn);
2235
- }
2236
- if($.isDOMReady){
2237
- (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
2238
- }
2239
- };
2240
-
2241
- var elementExtends = {};
2242
- return {
2243
- createTmpCache: function(nodeName){
2244
- if($.isDOMReady){
2245
- tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
2246
- }
2247
- return tempCache || emptyQ;
2248
- },
2249
- flushTmpCache: function(){
2250
- tempCache = null;
2251
- },
2252
- content: function(nodeName, prop){
2253
- createNodeNameInit(nodeName, function(){
2254
- var val = $.attr(this, prop);
2255
- if(val != null){
2256
- $.attr(this, prop, val);
2257
- }
2258
- });
2259
- },
2260
- createElement: function(nodeName, fn){
2261
- createNodeNameInit(nodeName, fn);
2262
- },
2263
- extendValue: function(nodeName, prop, value){
2264
- createNodeNameInit(nodeName, function(){
2265
- $(this).each(function(){
2266
- var data = elementData(this, 'propValue', {});
2267
- data[prop] = this[prop];
2268
- this[prop] = value;
2269
- });
2270
- });
2271
- }
2272
- };
2273
- })();
2274
-
2275
- var createPropDefault = function(descs, removeType){
2276
- if(descs.defaultValue === undefined){
2277
- descs.defaultValue = '';
2278
- }
2279
- if(!descs.removeAttr){
2280
- descs.removeAttr = {
2281
- value: function(){
2282
- descs[removeType || 'prop'].set.call(this, descs.defaultValue);
2283
- descs.removeAttr._supvalue.call(this);
2284
- }
2285
- };
2286
- }
2287
- if(!descs.attr){
2288
- descs.attr = {};
2289
- }
2290
- };
2291
-
2292
- $.extend(webshims, {
2293
- getID: (function(){
2294
- var ID = new Date().getTime();
2295
- return function(elem){
2296
- elem = $(elem);
2297
- var id = elem.prop('id');
2298
- if(!id){
2299
- ID++;
2300
- id = 'ID-'+ ID;
2301
- elem.eq(0).prop('id', id);
2302
- }
2303
- return id;
2304
- };
2305
- })(),
2306
- shadowClass: 'wsshadow-'+(Date.now()),
2307
- implement: function(elem, type){
2308
- var data = elementData(elem, 'implemented') || elementData(elem, 'implemented', {});
2309
- if(data[type]){
2310
- webshims.warn(type +' already implemented for element #'+elem.id);
2311
- return false;
2312
- }
2313
- data[type] = true;
2314
- return true;
2315
- },
2316
- extendUNDEFProp: function(obj, props){
2317
- $.each(props, function(name, prop){
2318
- if( !(name in obj) ){
2319
- obj[name] = prop;
2320
- }
2321
- });
2322
- },
2323
- getOptions: (function(){
2324
- var normalName = /\-([a-z])/g;
2325
- var regs = {};
2326
- var nameRegs = {};
2327
- var regFn = function(f, upper){
2328
- return upper.toLowerCase();
2329
- };
2330
- var nameFn = function(f, dashed){
2331
- return dashed.toUpperCase();
2332
- };
2333
- return function(elem, name, bases, stringAllowed){
2334
- if(nameRegs[name]){
2335
- name = nameRegs[name];
2336
- } else {
2337
- nameRegs[name] = name.replace(normalName, nameFn);
2338
- name = nameRegs[name];
2339
- }
2340
- var data = elementData(elem, 'cfg'+name);
2341
- var dataName;
2342
- var cfg = {};
2343
-
2344
- if(data){
2345
- return data;
2346
- }
2347
- data = $(elem).data();
2348
- if(data && typeof data[name] == 'string'){
2349
- if(stringAllowed){
2350
- return elementData(elem, 'cfg'+name, data[name]);
2351
- }
2352
- webshims.error('data-'+ name +' attribute has to be a valid JSON, was: '+ data[name]);
2353
- }
2354
- if(!bases){
2355
- bases = [true, {}];
2356
- } else if(!Array.isArray(bases)){
2357
- bases = [true, {}, bases];
2358
- } else {
2359
- bases.unshift(true, {});
2360
- }
2361
-
2362
- if(data && typeof data[name] == 'object'){
2363
- bases.push(data[name]);
2364
- }
2365
-
2366
- if(!regs[name]){
2367
- regs[name] = new RegExp('^'+ name +'([A-Z])');
2368
- }
2369
-
2370
- for(dataName in data){
2371
- if(regs[name].test(dataName)){
2372
- cfg[dataName.replace(regs[name], regFn)] = data[dataName];
2373
- }
2374
- }
2375
- bases.push(cfg);
2376
- return elementData(elem, 'cfg'+name, $.extend.apply($, bases));
2377
- };
2378
- })(),
2379
- //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
2380
- createPropDefault: createPropDefault,
2381
- data: elementData,
2382
- moveToFirstEvent: function(elem, eventType, bindType){
2383
- var events = ($._data(elem, 'events') || {})[eventType];
2384
- var fn;
2385
-
2386
- if(events && events.length > 1){
2387
- fn = events.pop();
2388
- if(!bindType){
2389
- bindType = 'bind';
2390
- }
2391
- if(bindType == 'bind' && events.delegateCount){
2392
- events.splice( events.delegateCount, 0, fn);
2393
- } else {
2394
- events.unshift( fn );
2395
- }
2396
-
2397
-
2398
- }
2399
- elem = null;
2400
- },
2401
- addShadowDom: (function(){
2402
- var resizeTimer;
2403
- var lastHeight;
2404
- var lastWidth;
2405
- var $window = $(window);
2406
- var docObserve = {
2407
- init: false,
2408
- runs: 0,
2409
- test: function(){
2410
- var height = docObserve.getHeight();
2411
- var width = docObserve.getWidth();
2412
-
2413
- if(height != docObserve.height || width != docObserve.width){
2414
- docObserve.height = height;
2415
- docObserve.width = width;
2416
- docObserve.handler({type: 'docresize'});
2417
- docObserve.runs++;
2418
- if(docObserve.runs < 9){
2419
- setTimeout(docObserve.test, 90);
2420
- }
2421
- } else {
2422
- docObserve.runs = 0;
2423
- }
2424
- },
2425
- handler: (function(){
2426
- var trigger = function(){
2427
- $(document).triggerHandler('updateshadowdom');
2428
- };
2429
- return function(e){
2430
- clearTimeout(resizeTimer);
2431
- resizeTimer = setTimeout(function(){
2432
- if(e.type == 'resize'){
2433
- var width = $window.width();
2434
- var height = $window.width();
2435
-
2436
- if(height == lastHeight && width == lastWidth){
2437
- return;
2438
- }
2439
- lastHeight = height;
2440
- lastWidth = width;
2441
-
2442
- docObserve.height = docObserve.getHeight();
2443
- docObserve.width = docObserve.getWidth();
2444
- }
2445
-
2446
- if(window.requestAnimationFrame){
2447
- requestAnimationFrame(trigger);
2448
- } else {
2449
- setTimeout(trigger, 0);
2450
- }
2451
-
2452
- }, (e.type == 'resize' && !window.requestAnimationFrame) ? 50 : 9);
2453
- };
2454
- })(),
2455
- _create: function(){
2456
- $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
2457
- var body = document.body;
2458
- var doc = document.documentElement;
2459
- docObserve[type] = function (){
2460
- return Math.max(
2461
- body[ "scroll" + name ], doc[ "scroll" + name ],
2462
- body[ "offset" + name ], doc[ "offset" + name ],
2463
- doc[ "client" + name ]
2464
- );
2465
- };
2466
- });
2467
- },
2468
- start: function(){
2469
- if(!this.init && document.body){
2470
- this.init = true;
2471
- this._create();
2472
- this.height = docObserve.getHeight();
2473
- this.width = docObserve.getWidth();
2474
- setInterval(this.test, 999);
2475
- $(this.test);
2476
- if($.support.boxSizing == null){
2477
- $(function(){
2478
- if($.support.boxSizing){
2479
- docObserve.handler({type: 'boxsizing'});
2480
- }
2481
- });
2482
- }
2483
- webshims.ready('WINDOWLOAD', this.test);
2484
- $(document).on('updatelayout.webshim pageinit popupafteropen panelbeforeopen tabsactivate collapsibleexpand shown.bs.modal shown.bs.collapse slid.bs.carousel', this.handler);
2485
- $(window).on('resize', this.handler);
2486
- }
2487
- }
2488
- };
2489
-
2490
-
2491
- webshims.docObserve = function(){
2492
- webshims.ready('DOM', function(){
2493
- docObserve.start();
2494
-
2495
- });
2496
- };
2497
- return function(nativeElem, shadowElem, opts){
2498
- if(nativeElem && shadowElem){
2499
- opts = opts || {};
2500
- if(nativeElem.jquery){
2501
- nativeElem = nativeElem[0];
2502
- }
2503
- if(shadowElem.jquery){
2504
- shadowElem = shadowElem[0];
2505
- }
2506
- var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
2507
- var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
2508
- var shadowFocusElementData = {};
2509
- if(!opts.shadowFocusElement){
2510
- opts.shadowFocusElement = shadowElem;
2511
- } else if(opts.shadowFocusElement){
2512
- if(opts.shadowFocusElement.jquery){
2513
- opts.shadowFocusElement = opts.shadowFocusElement[0];
2514
- }
2515
- shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
2516
- }
2517
-
2518
- $(nativeElem).on('remove', function(e){
2519
- if (!e.originalEvent) {
2520
- setTimeout(function(){
2521
- $(shadowElem).remove();
2522
- }, 4);
2523
- }
2524
- });
2525
-
2526
- nativeData.hasShadow = shadowElem;
2527
- shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
2528
- shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
2529
- nativeElement: nativeElem,
2530
- shadowElement: shadowElem,
2531
- shadowFocusElement: opts.shadowFocusElement
2532
- };
2533
- if(opts.shadowChilds){
2534
- opts.shadowChilds.each(function(){
2535
- elementData(this, 'shadowData', shadowData.shadowData);
2536
- });
2537
- }
2538
-
2539
- if(opts.data){
2540
- shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
2541
- }
2542
- opts = null;
2543
- }
2544
- webshims.docObserve();
2545
- };
2546
- })(),
2547
- propTypes: {
2548
- standard: function(descs, name){
2549
- createPropDefault(descs);
2550
- if(descs.prop){return;}
2551
- descs.prop = {
2552
- set: function(val){
2553
- descs.attr.set.call(this, ''+val);
2554
- },
2555
- get: function(){
2556
- return descs.attr.get.call(this) || descs.defaultValue;
2557
- }
2558
- };
2559
-
2560
- },
2561
- "boolean": function(descs, name){
2562
-
2563
- createPropDefault(descs);
2564
- if(descs.prop){return;}
2565
- descs.prop = {
2566
- set: function(val){
2567
- if(val){
2568
- descs.attr.set.call(this, "");
2569
- } else {
2570
- descs.removeAttr.value.call(this);
2571
- }
2572
- },
2573
- get: function(){
2574
- return descs.attr.get.call(this) != null;
2575
- }
2576
- };
2577
- },
2578
- "src": (function(){
2579
- var anchor = document.createElement('a');
2580
- anchor.style.display = "none";
2581
- return function(descs, name){
2582
-
2583
- createPropDefault(descs);
2584
- if(descs.prop){return;}
2585
- descs.prop = {
2586
- set: function(val){
2587
- descs.attr.set.call(this, val);
2588
- },
2589
- get: function(){
2590
- var href = this.getAttribute(name);
2591
- var ret;
2592
- if(href == null){return '';}
2593
-
2594
- anchor.setAttribute('href', href+'' );
2595
-
2596
- if(!supportHrefNormalized){
2597
- try {
2598
- $(anchor).insertAfter(this);
2599
- ret = anchor.getAttribute('href', 4);
2600
- } catch(er){
2601
- ret = anchor.getAttribute('href', 4);
2602
- }
2603
- $(anchor).detach();
2604
- }
2605
- return ret || anchor.href;
2606
- }
2607
- };
2608
- };
2609
- })(),
2610
- enumarated: function(descs, name){
2611
-
2612
- createPropDefault(descs);
2613
- if(descs.prop){return;}
2614
- descs.prop = {
2615
- set: function(val){
2616
- descs.attr.set.call(this, val);
2617
- },
2618
- get: function(){
2619
- var val = (descs.attr.get.call(this) || '').toLowerCase();
2620
- if(!val || descs.limitedTo.indexOf(val) == -1){
2621
- val = descs.defaultValue;
2622
- }
2623
- return val;
2624
- }
2625
- };
2626
- }
2627
-
2628
- // ,unsignedLong: $.noop
2629
- // ,"doubble": $.noop
2630
- // ,"long": $.noop
2631
- // ,tokenlist: $.noop
2632
- // ,settableTokenlist: $.noop
2633
- },
2634
- reflectProperties: function(nodeNames, props){
2635
- if(typeof props == 'string'){
2636
- props = props.split(listReg);
2637
- }
2638
- props.forEach(function(prop){
2639
- webshims.defineNodeNamesProperty(nodeNames, prop, {
2640
- prop: {
2641
- set: function(val){
2642
- $.attr(this, prop, val);
2643
- },
2644
- get: function(){
2645
- return $.attr(this, prop) || '';
2646
- }
2647
- }
2648
- });
2649
- });
2650
- },
2651
- defineNodeNameProperty: function(nodeName, prop, descs){
2652
- havePolyfill[prop] = true;
2653
-
2654
- if(descs.reflect){
2655
- if(descs.propType && !webshims.propTypes[descs.propType]){
2656
- webshims.error('could not finde propType '+ descs.propType);
2657
- } else {
2658
- webshims.propTypes[descs.propType || 'standard'](descs, prop);
2659
- }
2660
-
2661
- }
2662
-
2663
- ['prop', 'attr', 'removeAttr'].forEach(function(type){
2664
- var desc = descs[type];
2665
- if(desc){
2666
- if(type === 'prop'){
2667
- desc = $.extend({writeable: true}, desc);
2668
- } else {
2669
- desc = $.extend({}, desc, {writeable: true});
2670
- }
2671
-
2672
- extendQ[type](nodeName, prop, desc);
2673
- if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
2674
- extendNativeValue(nodeName, prop, desc);
2675
- }
2676
- descs[type] = desc;
2677
- }
2678
- });
2679
- if(descs.initAttr){
2680
- initProp.content(nodeName, prop);
2681
- }
2682
- return descs;
2683
- },
2684
-
2685
- defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
2686
- var olddesc;
2687
- for(var prop in descs){
2688
- if(!_noTmpCache && descs[prop].initAttr){
2689
- initProp.createTmpCache(name);
2690
- }
2691
- if(propType){
2692
- if(descs[prop][propType]){
2693
- //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
2694
- } else {
2695
- descs[prop][propType] = {};
2696
- ['value', 'set', 'get'].forEach(function(copyProp){
2697
- if(copyProp in descs[prop]){
2698
- descs[prop][propType][copyProp] = descs[prop][copyProp];
2699
- delete descs[prop][copyProp];
2700
- }
2701
- });
2702
- }
2703
- }
2704
- descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
2705
- }
2706
- if(!_noTmpCache){
2707
- initProp.flushTmpCache();
2708
- }
2709
- return descs;
2710
- },
2711
-
2712
- createElement: function(nodeName, create, descs){
2713
- var ret;
2714
- if($.isFunction(create)){
2715
- create = {
2716
- after: create
2717
- };
2718
- }
2719
- initProp.createTmpCache(nodeName);
2720
- if(create.before){
2721
- initProp.createElement(nodeName, create.before);
2722
- }
2723
- if(descs){
2724
- ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
2725
- }
2726
- if(create.after){
2727
- initProp.createElement(nodeName, create.after);
2728
- }
2729
- initProp.flushTmpCache();
2730
- return ret;
2731
- },
2732
- onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
2733
- if(typeof nodeNames == 'string'){
2734
- nodeNames = nodeNames.split(listReg);
2735
- }
2736
- if($.isFunction(desc)){
2737
- desc = {set: desc};
2738
- }
2739
-
2740
- nodeNames.forEach(function(name){
2741
- if(!modifyProps[name]){
2742
- modifyProps[name] = {};
2743
- }
2744
- if(typeof props == 'string'){
2745
- props = props.split(listReg);
2746
- }
2747
- if(desc.initAttr){
2748
- initProp.createTmpCache(name);
2749
- }
2750
- props.forEach(function(prop){
2751
- if(!modifyProps[name][prop]){
2752
- modifyProps[name][prop] = [];
2753
- havePolyfill[prop] = true;
2754
- }
2755
- if(desc.set){
2756
- if(only){
2757
- desc.set.only = only;
2758
- }
2759
- modifyProps[name][prop].push(desc.set);
2760
- }
2761
-
2762
- if(desc.initAttr){
2763
- initProp.content(name, prop);
2764
- }
2765
- });
2766
- initProp.flushTmpCache();
2767
-
2768
- });
2769
- },
2770
- defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
2771
- if(!descs){
2772
- descs = {};
2773
- }
2774
- if($.isFunction(descs)){
2775
- descs.set = descs;
2776
- }
2777
- webshims.defineNodeNamesProperty(elementNames, prop, {
2778
- attr: {
2779
- set: function(val){
2780
- if(descs.useContentAttribute){
2781
- webshims.contentAttr(this, prop, val);
2782
- } else {
2783
- this.setAttribute(prop, val);
2784
- }
2785
- if(descs.set){
2786
- descs.set.call(this, true);
2787
- }
2788
- },
2789
- get: function(){
2790
- var ret = (descs.useContentAttribute) ? webshims.contentAttr(this, prop) : this.getAttribute(prop);
2791
- return (ret == null) ? undefined : prop;
2792
- }
2793
- },
2794
- removeAttr: {
2795
- value: function(){
2796
- this.removeAttribute(prop);
2797
- if(descs.set){
2798
- descs.set.call(this, false);
2799
- }
2800
- }
2801
- },
2802
- reflect: true,
2803
- propType: 'boolean',
2804
- initAttr: descs.initAttr || false
2805
- });
2806
- },
2807
- contentAttr: function(elem, name, val){
2808
- if(!elem.nodeName){return;}
2809
- var attr;
2810
- if(val === undefined){
2811
- attr = (elem.attributes[name] || {});
2812
- val = attr.specified ? attr.value : null;
2813
- return (val == null) ? undefined : val;
2814
- }
2815
-
2816
- if(typeof val == 'boolean'){
2817
- if(!val){
2818
- elem.removeAttribute(name);
2819
- } else {
2820
- elem.setAttribute(name, name);
2821
- }
2822
- } else {
2823
- elem.setAttribute(name, val);
2824
- }
2825
- },
2826
-
2827
- activeLang: (function(){
2828
- var curLang = [];
2829
- var langDatas = [];
2830
- var loading = {};
2831
- var load = function(src, obj, loadingLang){
2832
- obj._isLoading = true;
2833
- if(loading[src]){
2834
- loading[src].push(obj);
2835
- } else {
2836
- loading[src] = [obj];
2837
- webshims.loader.loadScript(src, function(){
2838
- if(loadingLang == curLang.join()){
2839
- $.each(loading[src], function(i, obj){
2840
- select(obj);
2841
- });
2842
- }
2843
- delete loading[src];
2844
- });
2845
- }
2846
- };
2847
-
2848
- var select = function(obj){
2849
- var oldLang = obj.__active;
2850
- var selectLang = function(i, lang){
2851
- obj._isLoading = false;
2852
- if(obj[lang] || obj.availableLangs.indexOf(lang) != -1){
2853
- if(obj[lang]){
2854
- obj.__active = obj[lang];
2855
- obj.__activeName = lang;
2856
- } else {
2857
- load(obj.langSrc+lang, obj, curLang.join());
2858
- }
2859
- return false;
2860
- }
2861
- };
2862
- $.each(curLang, selectLang);
2863
- if(!obj.__active){
2864
- obj.__active = obj[''];
2865
- obj.__activeName = '';
2866
- }
2867
- if(oldLang != obj.__active){
2868
- $(obj).trigger('change');
2869
- }
2870
- };
2871
- return function(lang){
2872
- var shortLang;
2873
- if(typeof lang == 'string'){
2874
- if(curLang[0] != lang){
2875
- curLang = [lang];
2876
- shortLang = curLang[0].split('-')[0];
2877
- if(shortLang && shortLang != lang){
2878
- curLang.push(shortLang);
2879
- }
2880
- langDatas.forEach(select);
2881
- }
2882
- } else if(typeof lang == 'object'){
2883
- if(!lang.__active){
2884
- langDatas.push(lang);
2885
- select(lang);
2886
- }
2887
- return lang.__active;
2888
- }
2889
- return curLang[0];
2890
- };
2891
- })()
2892
- });
2893
-
2894
- $.each({
2895
- defineNodeNamesProperty: 'defineNodeNameProperty',
2896
- defineNodeNamesProperties: 'defineNodeNameProperties',
2897
- createElements: 'createElement'
2898
- }, function(name, baseMethod){
2899
- webshims[name] = function(names, a, b, c){
2900
- if(typeof names == 'string'){
2901
- names = names.split(listReg);
2902
- }
2903
- var retDesc = {};
2904
- names.forEach(function(nodeName){
2905
- retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
2906
- });
2907
- return retDesc;
2908
- };
2909
- });
2910
-
2911
- webshims.isReady('webshimLocalization', true);
2912
-
2913
- //html5a11y + hidden attribute
2914
- (function(){
2915
- if(('content' in document.createElement('template'))){return;}
2916
-
2917
- $(function(){
2918
- var main = $('main').attr({role: 'main'});
2919
- if(main.length > 1){
2920
- webshims.error('only one main element allowed in document');
2921
- } else if(main.is('article *, section *')) {
2922
- webshims.error('main not allowed inside of article/section elements');
2923
- }
2924
- });
2925
-
2926
- if(('hidden' in document.createElement('a'))){
2927
- return;
2928
- }
2929
-
2930
- webshims.defineNodeNamesBooleanProperty(['*'], 'hidden');
2931
-
2932
- var elemMappings = {
2933
- article: "article",
2934
- aside: "complementary",
2935
- section: "region",
2936
- nav: "navigation",
2937
- address: "contentinfo"
2938
- };
2939
- var addRole = function(elem, role){
2940
- var hasRole = elem.getAttribute('role');
2941
- if (!hasRole) {
2942
- elem.setAttribute('role', role);
2943
- }
2944
- };
2945
-
2946
-
2947
- $.webshims.addReady(function(context, contextElem){
2948
- $.each(elemMappings, function(name, role){
2949
- var elems = $(name, context).add(contextElem.filter(name));
2950
- for (var i = 0, len = elems.length; i < len; i++) {
2951
- addRole(elems[i], role);
2952
- }
2953
- });
2954
- if (context === document) {
2955
- var header = document.getElementsByTagName('header')[0];
2956
- var footers = document.getElementsByTagName('footer');
2957
- var footerLen = footers.length;
2958
-
2959
- if (header && !$(header).closest('section, article')[0]) {
2960
- addRole(header, 'banner');
2961
- }
2962
- if (!footerLen) {
2963
- return;
2964
- }
2965
- var footer = footers[footerLen - 1];
2966
- if (!$(footer).closest('section, article')[0]) {
2967
- addRole(footer, 'contentinfo');
2968
- }
2969
- }
2970
- });
2971
-
2972
- })();
2973
- });
2974
- ;(function(Modernizr, webshims){
2975
- "use strict";
2976
- var hasNative = Modernizr.audio && Modernizr.video;
2977
- var supportsLoop = false;
2978
- var bugs = webshims.bugs;
2979
- var swfType = 'mediaelement-jaris';
2980
- var loadSwf = function(){
2981
- webshims.ready(swfType, function(){
2982
- if(!webshims.mediaelement.createSWF){
2983
- webshims.mediaelement.loadSwf = true;
2984
- webshims.reTest([swfType], hasNative);
2985
- }
2986
- });
2987
- };
2988
-
2989
- var wsCfg = webshims.cfg;
2990
- var options = wsCfg.mediaelement;
2991
- var isIE = navigator.userAgent.indexOf('MSIE') != -1;
2992
- if(!options){
2993
- webshims.error("mediaelement wasn't implemented but loaded");
2994
- return;
2995
- }
2996
-
2997
- if(hasNative){
2998
- var videoElem = document.createElement('video');
2999
- Modernizr.videoBuffered = ('buffered' in videoElem);
3000
- Modernizr.mediaDefaultMuted = ('defaultMuted' in videoElem);
3001
- supportsLoop = ('loop' in videoElem);
3002
- Modernizr.mediaLoop = supportsLoop;
3003
-
3004
- webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
3005
-
3006
- if( !Modernizr.videoBuffered || !supportsLoop || (!Modernizr.mediaDefaultMuted && isIE && 'ActiveXObject' in window) ){
3007
- webshims.addPolyfill('mediaelement-native-fix', {
3008
- d: ['dom-support']
3009
- });
3010
- webshims.loader.loadList(['mediaelement-native-fix']);
3011
- }
3012
- }
3013
-
3014
- if(Modernizr.track && !bugs.track){
3015
- (function(){
3016
- if(!bugs.track){
3017
-
3018
- if(window.VTTCue && !window.TextTrackCue){
3019
- window.TextTrackCue = window.VTTCue;
3020
- } else if(!window.VTTCue){
3021
- window.VTTCue = window.TextTrackCue;
3022
- }
3023
-
3024
- try {
3025
- new VTTCue(2, 3, '');
3026
- } catch(e){
3027
- bugs.track = true;
3028
- }
3029
- }
3030
- })();
3031
- }
3032
-
3033
- webshims.register('mediaelement-core', function($, webshims, window, document, undefined, options){
3034
- var hasSwf = swfmini.hasFlashPlayerVersion('10.0.3');
3035
- var mediaelement = webshims.mediaelement;
3036
-
3037
- mediaelement.parseRtmp = function(data){
3038
- var src = data.src.split('://');
3039
- var paths = src[1].split('/');
3040
- var i, len, found;
3041
- data.server = src[0]+'://'+paths[0]+'/';
3042
- data.streamId = [];
3043
- for(i = 1, len = paths.length; i < len; i++){
3044
- if(!found && paths[i].indexOf(':') !== -1){
3045
- paths[i] = paths[i].split(':')[1];
3046
- found = true;
3047
- }
3048
- if(!found){
3049
- data.server += paths[i]+'/';
3050
- } else {
3051
- data.streamId.push(paths[i]);
3052
- }
3053
- }
3054
- if(!data.streamId.length){
3055
- webshims.error('Could not parse rtmp url');
3056
- }
3057
- data.streamId = data.streamId.join('/');
3058
- };
3059
-
3060
- var getSrcObj = function(elem, nodeName){
3061
- elem = $(elem);
3062
- var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
3063
- var tmp;
3064
-
3065
- if(!src.src){return src;}
3066
-
3067
- tmp = elem.attr('data-server');
3068
- if(tmp != null){
3069
- src.server = tmp;
3070
- }
3071
-
3072
- tmp = elem.attr('type') || elem.attr('data-type');
3073
- if(tmp){
3074
- src.type = tmp;
3075
- src.container = $.trim(tmp.split(';')[0]);
3076
- } else {
3077
- if(!nodeName){
3078
- nodeName = elem[0].nodeName.toLowerCase();
3079
- if(nodeName == 'source'){
3080
- nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
3081
- }
3082
- }
3083
- if(src.server){
3084
- src.type = nodeName+'/rtmp';
3085
- src.container = nodeName+'/rtmp';
3086
- } else {
3087
-
3088
- tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
3089
-
3090
- if(tmp){
3091
- src.type = tmp;
3092
- src.container = tmp;
3093
- }
3094
- }
3095
- }
3096
-
3097
- tmp = elem.attr('media');
3098
- if(tmp){
3099
- src.media = tmp;
3100
- }
3101
- if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
3102
- if(src.server){
3103
- src.streamId = src.src;
3104
- } else {
3105
- mediaelement.parseRtmp(src);
3106
- }
3107
- }
3108
- return src;
3109
- };
3110
-
3111
-
3112
-
3113
- var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
3114
-
3115
- var loadTrackUi = function(){
3116
- if(loadTrackUi.loaded){return;}
3117
- loadTrackUi.loaded = true;
3118
- if(!options.noAutoTrack){
3119
- webshims.ready('WINDOWLOAD', function(){
3120
- loadThird();
3121
- webshims.loader.loadList(['track-ui']);
3122
- });
3123
- }
3124
- };
3125
-
3126
- var loadYt = (function(){
3127
- var loaded;
3128
- return function(){
3129
- if(loaded || !hasYt){return;}
3130
- loaded = true;
3131
- webshims.loader.loadScript("https://www.youtube.com/player_api");
3132
- $(function(){
3133
- webshims._polyfill(["mediaelement-yt"]);
3134
- });
3135
- };
3136
- })();
3137
- var loadThird = function(){
3138
- if(hasSwf){
3139
- loadSwf();
3140
- } else {
3141
- loadYt();
3142
- }
3143
- };
3144
-
3145
- webshims.addPolyfill('mediaelement-yt', {
3146
- test: !hasYt,
3147
- d: ['dom-support']
3148
- });
3149
-
3150
-
3151
-
3152
- mediaelement.mimeTypes = {
3153
- audio: {
3154
- //ogm shouldn´t be used!
3155
- 'audio/ogg': ['ogg','oga', 'ogm'],
3156
- 'audio/ogg;codecs="opus"': 'opus',
3157
- 'audio/mpeg': ['mp2','mp3','mpga','mpega'],
3158
- 'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
3159
- 'audio/wav': ['wav'],
3160
- 'audio/3gpp': ['3gp','3gpp'],
3161
- 'audio/webm': ['webm'],
3162
- 'audio/fla': ['flv', 'f4a', 'fla'],
3163
- 'application/x-mpegURL': ['m3u8', 'm3u']
3164
- },
3165
- video: {
3166
- //ogm shouldn´t be used!
3167
- 'video/ogg': ['ogg','ogv', 'ogm'],
3168
- 'video/mpeg': ['mpg','mpeg','mpe'],
3169
- 'video/mp4': ['mp4','mpg4', 'm4v'],
3170
- 'video/quicktime': ['mov','qt'],
3171
- 'video/x-msvideo': ['avi'],
3172
- 'video/x-ms-asf': ['asf', 'asx'],
3173
- 'video/flv': ['flv', 'f4v'],
3174
- 'video/3gpp': ['3gp','3gpp'],
3175
- 'video/webm': ['webm'],
3176
- 'application/x-mpegURL': ['m3u8', 'm3u'],
3177
- 'video/MP2T': ['ts']
3178
- }
3179
- }
3180
- ;
3181
-
3182
- mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
3183
-
3184
- mediaelement.getTypeForSrc = function(src, nodeName){
3185
- if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
3186
- return 'video/youtube';
3187
- }
3188
- if(src.indexOf('rtmp') === 0){
3189
- return nodeName+'/rtmp';
3190
- }
3191
- src = src.split('?')[0].split('#')[0].split('.');
3192
- src = src[src.length - 1];
3193
- var mt;
3194
-
3195
- $.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
3196
- if(exts.indexOf(src) !== -1){
3197
- mt = mimeType;
3198
- return false;
3199
- }
3200
- });
3201
- return mt;
3202
- };
3203
-
3204
-
3205
- mediaelement.srces = function(mediaElem, srces){
3206
- mediaElem = $(mediaElem);
3207
- if(!srces){
3208
- srces = [];
3209
- var nodeName = mediaElem[0].nodeName.toLowerCase();
3210
- var src = getSrcObj(mediaElem, nodeName);
3211
-
3212
- if(!src.src){
3213
- $('source', mediaElem).each(function(){
3214
- src = getSrcObj(this, nodeName);
3215
- if(src.src){srces.push(src);}
3216
- });
3217
- } else {
3218
- srces.push(src);
3219
- }
3220
- return srces;
3221
- } else {
3222
- webshims.error('setting sources was removed.');
3223
- }
3224
- };
3225
-
3226
- 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', 'video/jarisplayer', 'jarisplayer/jarisplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
3227
-
3228
- mediaelement.canThirdPlaySrces = function(mediaElem, srces){
3229
- var ret = '';
3230
- if(hasSwf || hasYt){
3231
- mediaElem = $(mediaElem);
3232
- srces = srces || mediaelement.srces(mediaElem);
3233
- $.each(srces, function(i, src){
3234
- if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
3235
- ret = src;
3236
- return false;
3237
- }
3238
- });
3239
-
3240
- }
3241
-
3242
- return ret;
3243
- };
3244
-
3245
- var nativeCanPlayType = {};
3246
- mediaelement.canNativePlaySrces = function(mediaElem, srces){
3247
- var ret = '';
3248
- if(hasNative){
3249
- mediaElem = $(mediaElem);
3250
- var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
3251
- var nativeCanPlay = (nativeCanPlayType[nodeName] || {prop: {_supvalue: false}}).prop._supvalue || mediaElem[0].canPlayType;
3252
- if(!nativeCanPlay){return ret;}
3253
- srces = srces || mediaelement.srces(mediaElem);
3254
-
3255
- $.each(srces, function(i, src){
3256
- if(src.type && nativeCanPlay.call(mediaElem[0], src.type) ){
3257
- ret = src;
3258
- return false;
3259
- }
3260
- });
3261
- }
3262
- return ret;
3263
- };
3264
- var emptyType = (/^\s*application\/octet\-stream\s*$/i);
3265
- var getRemoveEmptyType = function(){
3266
- var ret = emptyType.test($.attr(this, 'type') || '');
3267
- if(ret){
3268
- $(this).removeAttr('type');
3269
- }
3270
- return ret;
3271
- };
3272
- mediaelement.setError = function(elem, message){
3273
- if($('source', elem).filter(getRemoveEmptyType).length){
3274
- webshims.error('"application/octet-stream" is a useless mimetype for audio/video. Please change this attribute.');
3275
- try {
3276
- $(elem).mediaLoad();
3277
- } catch(er){}
3278
- } else {
3279
- if(!message){
3280
- message = "can't play sources";
3281
- }
3282
- $(elem).pause().data('mediaerror', message);
3283
- webshims.error('mediaelementError: '+ message +'. Run the following line in your console to get more info: webshim.mediaelement.loadDebugger();');
3284
- setTimeout(function(){
3285
- if($(elem).data('mediaerror')){
3286
- $(elem).addClass('media-error').trigger('mediaerror');
3287
- }
3288
- }, 1);
3289
- }
3290
-
3291
-
3292
- };
3293
-
3294
- var handleThird = (function(){
3295
- var requested;
3296
- var readyType = hasSwf ? swfType : 'mediaelement-yt';
3297
- return function( mediaElem, ret, data ){
3298
- //readd to ready
3299
-
3300
- webshims.ready(readyType, function(){
3301
- if(mediaelement.createSWF && $(mediaElem).parent()[0]){
3302
- mediaelement.createSWF( mediaElem, ret, data );
3303
- } else if(!requested) {
3304
- requested = true;
3305
- loadThird();
3306
-
3307
- handleThird( mediaElem, ret, data );
3308
- }
3309
- });
3310
- if(!requested && hasYt && !mediaelement.createSWF){
3311
- loadYt();
3312
- }
3313
- };
3314
- })();
3315
-
3316
- var activate = {
3317
- native: function(elem, src, data){
3318
- if(data && data.isActive == 'third') {
3319
- mediaelement.setActive(elem, 'html5', data);
3320
- }
3321
- },
3322
- third: handleThird
3323
- };
3324
-
3325
- var stepSources = function(elem, data, srces){
3326
- var i, src;
3327
- var testOrder = [{test: 'canNativePlaySrces', activate: 'native'}, {test: 'canThirdPlaySrces', activate: 'third'}];
3328
- if(options.preferFlash || (data && data.isActive == 'third') ){
3329
- testOrder.reverse();
3330
- }
3331
- for(i = 0; i < 2; i++){
3332
- src = mediaelement[testOrder[i].test](elem, srces);
3333
- if(src){
3334
- activate[testOrder[i].activate](elem, src, data);
3335
- break;
3336
- }
3337
- }
3338
-
3339
- if(!src){
3340
- mediaelement.setError(elem, false);
3341
- if(data && data.isActive == 'third') {
3342
- mediaelement.setActive(elem, 'html5', data);
3343
- }
3344
- }
3345
- };
3346
- var allowedPreload = {'metadata': 1, 'auto': 1, '': 1};
3347
- var fixPreload = function(elem){
3348
- var preload, img;
3349
- if(elem.getAttribute('preload') == 'none'){
3350
- if(allowedPreload[(preload = $.attr(elem, 'data-preload'))]){
3351
- $.attr(elem, 'preload', preload);
3352
- } else if(hasNative && (preload = elem.getAttribute('poster'))){
3353
- img = document.createElement('img');
3354
- img.src = preload;
3355
- }
3356
- }
3357
- };
3358
- var stopParent = /^(?:embed|object|datalist)$/i;
3359
- var selectSource = function(elem, data){
3360
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
3361
- var _srces = mediaelement.srces(elem);
3362
- var parent = elem.parentNode;
3363
-
3364
- clearTimeout(baseData.loadTimer);
3365
- $(elem).removeClass('media-error');
3366
- $.data(elem, 'mediaerror', false);
3367
-
3368
- if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
3369
- data = data || webshims.data(elem, 'mediaelement');
3370
- if(mediaelement.sortMedia){
3371
- _srces.sort(mediaelement.sortMedia);
3372
- }
3373
- fixPreload(elem);
3374
- stepSources(elem, data, _srces);
3375
-
3376
- };
3377
- mediaelement.selectSource = selectSource;
3378
-
3379
-
3380
- $(document).on('ended', function(e){
3381
- var data = webshims.data(e.target, 'mediaelement');
3382
- if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
3383
- setTimeout(function(){
3384
- if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
3385
- $(e.target).prop('currentTime', 0).play();
3386
- });
3387
-
3388
- });
3389
-
3390
- var handleMedia = false;
3391
-
3392
- var initMediaElements = function(){
3393
- var testFixMedia = function(){
3394
-
3395
- if(webshims.implement(this, 'mediaelement')){
3396
- selectSource(this);
3397
- if(!Modernizr.mediaDefaultMuted && $.attr(this, 'muted') != null){
3398
- $.prop(this, 'muted', true);
3399
- }
3400
-
3401
- }
3402
- };
3403
-
3404
- webshims.ready('dom-support', function(){
3405
- handleMedia = true;
3406
-
3407
- if(!supportsLoop){
3408
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
3409
- }
3410
-
3411
- ['audio', 'video'].forEach(function(nodeName){
3412
- var supLoad;
3413
- supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
3414
- prop: {
3415
- value: function(){
3416
- var data = webshims.data(this, 'mediaelement');
3417
-
3418
- selectSource(this, data);
3419
- if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
3420
- supLoad.prop._supvalue.apply(this, arguments);
3421
- }
3422
- if(!loadTrackUi.loaded && $('track', this).length){
3423
- loadTrackUi();
3424
- }
3425
- $(this).triggerHandler('wsmediareload');
3426
- }
3427
- }
3428
- });
3429
-
3430
- nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
3431
- prop: {
3432
- value: function(type){
3433
- var ret = '';
3434
- if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
3435
- ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
3436
- if(ret == 'no'){
3437
- ret = '';
3438
- }
3439
- }
3440
- if(!ret && hasSwf){
3441
- type = $.trim((type || '').split(';')[0]);
3442
- if(mediaelement.swfMimeTypes.indexOf(type) != -1){
3443
- ret = 'maybe';
3444
- }
3445
- }
3446
- if(!ret && hasYt && type == 'video/youtube'){
3447
- ret = 'maybe';
3448
- }
3449
- return ret;
3450
- }
3451
- }
3452
- });
3453
- });
3454
-
3455
-
3456
- webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
3457
- set: function(){
3458
- var elem = this;
3459
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
3460
- clearTimeout(baseData.loadTimer);
3461
- baseData.loadTimer = setTimeout(function(){
3462
- selectSource(elem);
3463
- elem = null;
3464
- }, 9);
3465
- }
3466
- });
3467
-
3468
-
3469
- webshims.addReady(function(context, insertedElement){
3470
- var media = $('video, audio', context)
3471
- .add(insertedElement.filter('video, audio'))
3472
- .each(testFixMedia)
3473
- ;
3474
- if(!loadTrackUi.loaded && $('track', media).length){
3475
- loadTrackUi();
3476
- }
3477
- media = null;
3478
- });
3479
- });
3480
-
3481
- if(hasNative && !handleMedia){
3482
- webshims.addReady(function(context, insertedElement){
3483
- if(!handleMedia){
3484
- $('video, audio', context)
3485
- .add(insertedElement.filter('video, audio'))
3486
- .each(function(){
3487
- if(!mediaelement.canNativePlaySrces(this)){
3488
- loadThird();
3489
- handleMedia = true;
3490
- return false;
3491
- }
3492
- })
3493
- ;
3494
- }
3495
- });
3496
- }
3497
- };
3498
-
3499
- mediaelement.loadDebugger = function(){
3500
- webshims.ready('dom-support', function(){
3501
- webshims.loader.loadScript('mediaelement-debug');
3502
- });
3503
- };
3504
-
3505
- if(({noCombo: 1, media: 1})[webshims.cfg.debug]){
3506
- $(document).on('mediaerror', function(e){
3507
- mediaelement.loadDebugger();
3508
- });
3509
- }
3510
- //set native implementation ready, before swf api is retested
3511
- if(hasNative){
3512
- webshims.isReady('mediaelement-core', true);
3513
- initMediaElements();
3514
- webshims.ready('WINDOWLOAD mediaelement', loadThird);
3515
- } else {
3516
- webshims.ready(swfType, initMediaElements);
3517
- }
3518
- webshims.ready('track', loadTrackUi);
3519
- });
3520
-
3521
- })(Modernizr, webshims);
3522
- ;webshims.register('mediaelement-jaris', function($, webshims, window, document, undefined, options){
3523
- "use strict";
3524
-
3525
- var mediaelement = webshims.mediaelement;
3526
- var swfmini = window.swfmini;
3527
- var hasNative = Modernizr.audio && Modernizr.video;
3528
- var hasFlash = swfmini.hasFlashPlayerVersion('9.0.115');
3529
- var loadedSwf = 0;
3530
- var needsLoadPreload = 'ActiveXObject' in window && hasNative;
3531
- var getProps = {
3532
- paused: true,
3533
- ended: false,
3534
- currentSrc: '',
3535
- duration: window.NaN,
3536
- readyState: 0,
3537
- networkState: 0,
3538
- videoHeight: 0,
3539
- videoWidth: 0,
3540
- seeking: false,
3541
- error: null,
3542
- buffered: {
3543
- start: function(index){
3544
- if(index){
3545
- webshims.error('buffered index size error');
3546
- return;
3547
- }
3548
- return 0;
3549
- },
3550
- end: function(index){
3551
- if(index){
3552
- webshims.error('buffered index size error');
3553
- return;
3554
- }
3555
- return 0;
3556
- },
3557
- length: 0
3558
- }
3559
- };
3560
- var getPropKeys = Object.keys(getProps);
3561
-
3562
- var getSetProps = {
3563
- currentTime: 0,
3564
- volume: 1,
3565
- muted: false
3566
- };
3567
- var getSetPropKeys = Object.keys(getSetProps);
3568
-
3569
- var playerStateObj = $.extend({
3570
- isActive: 'html5',
3571
- activating: 'html5',
3572
- wasSwfReady: false,
3573
- _bufferedEnd: 0,
3574
- _bufferedStart: 0,
3575
- currentTime: 0,
3576
- _ppFlag: undefined,
3577
- _calledMeta: false,
3578
- lastDuration: 0
3579
- }, getProps, getSetProps);
3580
-
3581
-
3582
- var getSwfDataFromElem = function(elem){
3583
- try {
3584
- (elem.nodeName);
3585
- } catch(er){
3586
- return null;
3587
- }
3588
- var data = webshims.data(elem, 'mediaelement');
3589
- return (data && data.isActive== 'third') ? data : null;
3590
- };
3591
-
3592
- var trigger = function(elem, evt){
3593
- evt = $.Event(evt);
3594
- evt.preventDefault();
3595
- $.event.trigger(evt, undefined, elem);
3596
- };
3597
-
3598
- var playerSwfPath = options.playerPath || webshims.cfg.basePath + "swf/" + (options.playerName || 'JarisFLVPlayer.swf');
3599
-
3600
- webshims.extendUNDEFProp(options.params, {
3601
- allowscriptaccess: 'always',
3602
- allowfullscreen: 'true',
3603
- wmode: 'transparent',
3604
- allowNetworking: 'all'
3605
- });
3606
- webshims.extendUNDEFProp(options.vars, {
3607
- controltype: '1',
3608
- jsapi: '1'
3609
- });
3610
- webshims.extendUNDEFProp(options.attrs, {
3611
- bgcolor: '#000000'
3612
- });
3613
-
3614
- var setReadyState = function(readyState, data){
3615
- if(readyState < 3){
3616
- clearTimeout(data._canplaythroughTimer);
3617
- }
3618
- if(readyState >= 3 && data.readyState < 3){
3619
- data.readyState = readyState;
3620
- trigger(data._elem, 'canplay');
3621
- if(!data.paused){
3622
- trigger(data._elem, 'playing');
3623
- }
3624
- clearTimeout(data._canplaythroughTimer);
3625
- data._canplaythroughTimer = setTimeout(function(){
3626
- setReadyState(4, data);
3627
- }, 4000);
3628
- }
3629
- if(readyState >= 4 && data.readyState < 4){
3630
- data.readyState = readyState;
3631
- trigger(data._elem, 'canplaythrough');
3632
- }
3633
- data.readyState = readyState;
3634
- };
3635
- var callSeeked = function(data){
3636
- if(data.seeking && Math.abs(data.currentTime - data._lastSeektime) < 2){
3637
- data.seeking = false;
3638
- $(data._elem).triggerHandler('seeked');
3639
- }
3640
- };
3641
-
3642
-
3643
- mediaelement.jarisEvent = {};
3644
- var localConnectionTimer;
3645
- var onEvent = {
3646
- onPlayPause: function(jaris, data, override){
3647
- var playing, type;
3648
- if(override == null){
3649
- try {
3650
- playing = data.api.api_get("isPlaying");
3651
- } catch(e){}
3652
- } else {
3653
- playing = override;
3654
- }
3655
- if(playing == data.paused){
3656
-
3657
- data.paused = !playing;
3658
- type = data.paused ? 'pause' : 'play';
3659
- data._ppFlag = true;
3660
- trigger(data._elem, type);
3661
- if(data.readyState < 3){
3662
- setReadyState(3, data);
3663
- }
3664
- if(!data.paused){
3665
- trigger(data._elem, 'playing');
3666
- }
3667
- }
3668
- },
3669
- onSeek: function(jaris, data){
3670
- data._lastSeektime = jaris.seekTime;
3671
-
3672
- data.seeking = true;
3673
- $(data._elem).triggerHandler('seeking');
3674
- clearTimeout(data._seekedTimer);
3675
- data._seekedTimer = setTimeout(function(){
3676
- callSeeked(data);
3677
- data.seeking = false;
3678
- }, 300);
3679
- },
3680
- onConnectionFailed: function(jaris, data){
3681
- mediaelement.setError(data._elem, 'flash connection error');
3682
- },
3683
- onNotBuffering: function(jaris, data){
3684
- setReadyState(3, data);
3685
- },
3686
- onDataInitialized: function(jaris, data){
3687
-
3688
- var oldDur = data.duration;
3689
- var durDelta;
3690
- data.duration = jaris.duration;
3691
- if(oldDur == data.duration || isNaN(data.duration)){return;}
3692
-
3693
- if(data._calledMeta && ((durDelta = Math.abs(data.lastDuration - data.duration)) < 2)){return;}
3694
-
3695
-
3696
-
3697
- data.videoHeight = jaris.height;
3698
- data.videoWidth = jaris.width;
3699
-
3700
- if(!data.networkState){
3701
- data.networkState = 2;
3702
- }
3703
- if(data.readyState < 1){
3704
- setReadyState(1, data);
3705
- }
3706
- clearTimeout(data._durationChangeTimer);
3707
- if(data._calledMeta && data.duration){
3708
- data._durationChangeTimer = setTimeout(function(){
3709
- data.lastDuration = data.duration;
3710
- trigger(data._elem, 'durationchange');
3711
- }, durDelta > 50 ? 0 : durDelta > 9 ? 9 : 99);
3712
- } else {
3713
- data.lastDuration = data.duration;
3714
- if(data.duration){
3715
- trigger(data._elem, 'durationchange');
3716
- }
3717
- if(!data._calledMeta){
3718
- trigger(data._elem, 'loadedmetadata');
3719
- }
3720
- }
3721
- data._calledMeta = true;
3722
- },
3723
- onBuffering: function(jaris, data){
3724
- if(data.ended){
3725
- data.ended = false;
3726
- }
3727
- setReadyState(1, data);
3728
- trigger(data._elem, 'waiting');
3729
- },
3730
- onTimeUpdate: function(jaris, data){
3731
- if(data.ended){
3732
- data.ended = false;
3733
- }
3734
- if(data.readyState < 3){
3735
- setReadyState(3, data);
3736
- trigger(data._elem, 'playing');
3737
- }
3738
- if(data.seeking){
3739
- callSeeked(data);
3740
- }
3741
- trigger(data._elem, 'timeupdate');
3742
- },
3743
- onProgress: function(jaris, data){
3744
- if(data.ended){
3745
- data.ended = false;
3746
- }
3747
- if(!data.duration || isNaN(data.duration)){
3748
- return;
3749
- }
3750
- var percentage = jaris.loaded / jaris.total;
3751
- if(percentage > 0.02 && percentage < 0.2){
3752
- setReadyState(3, data);
3753
- } else if(percentage > 0.2){
3754
- if(percentage > 0.99){
3755
- data.networkState = 1;
3756
- }
3757
- setReadyState(4, data);
3758
- }
3759
- if(data._bufferedEnd && (data._bufferedEnd > percentage)){
3760
- data._bufferedStart = data.currentTime || 0;
3761
- }
3762
-
3763
- data._bufferedEnd = percentage;
3764
- data.buffered.length = 1;
3765
-
3766
- $.event.trigger('progress', undefined, data._elem, true);
3767
- },
3768
- onPlaybackFinished: function(jaris, data){
3769
- if(data.readyState < 4){
3770
- setReadyState(4, data);
3771
- }
3772
- data.ended = true;
3773
- trigger(data._elem, 'ended');
3774
- },
3775
- onVolumeChange: function(jaris, data){
3776
- if(data.volume != jaris.volume || data.muted != jaris.mute){
3777
- data.volume = jaris.volume;
3778
- data.muted = jaris.mute;
3779
- trigger(data._elem, 'volumechange');
3780
- }
3781
- },
3782
- ready: (function(){
3783
- var testAPI = function(data){
3784
- var passed = true;
3785
-
3786
- try {
3787
- data.api.api_get('volume');
3788
- } catch(er){
3789
- passed = false;
3790
- }
3791
- return passed;
3792
- };
3793
-
3794
- return function(jaris, data){
3795
- var i = 0;
3796
-
3797
- var doneFn = function(){
3798
- if(i > 9){
3799
- data.tryedReframeing = 0;
3800
- return;
3801
- }
3802
- i++;
3803
-
3804
- data.tryedReframeing++;
3805
- if(testAPI(data)){
3806
- data.wasSwfReady = true;
3807
- data.tryedReframeing = 0;
3808
- startAutoPlay(data);
3809
- workActionQueue(data);
3810
- } else if(data.tryedReframeing < 6) {
3811
- if(data.tryedReframeing < 3){
3812
- data.reframeTimer = setTimeout(doneFn, 9);
3813
- data.shadowElem.css({overflow: 'visible'});
3814
- setTimeout(function(){
3815
- data.shadowElem.css({overflow: 'hidden'});
3816
- }, 1);
3817
- } else {
3818
- data.shadowElem.css({overflow: 'hidden'});
3819
- $(data._elem).mediaLoad();
3820
- }
3821
- } else {
3822
- clearTimeout(data.reframeTimer);
3823
- webshims.error("reframing error");
3824
- }
3825
- };
3826
- if(!data || !data.api){return;}
3827
- if(!data.tryedReframeing){
3828
- data.tryedReframeing = 0;
3829
- }
3830
- clearTimeout(localConnectionTimer);
3831
- clearTimeout(data.reframeTimer);
3832
- data.shadowElem.removeClass('flashblocker-assumed');
3833
-
3834
- if(!i){
3835
- doneFn();
3836
- } else {
3837
- data.reframeTimer = setTimeout(doneFn, 9);
3838
- }
3839
-
3840
- };
3841
- })()
3842
- };
3843
-
3844
- onEvent.onMute = onEvent.onVolumeChange;
3845
-
3846
-
3847
- var workActionQueue = function(data){
3848
- var actionLen = data.actionQueue.length;
3849
- var i = 0;
3850
- var operation;
3851
-
3852
- if(actionLen && data.isActive == 'third'){
3853
- while(data.actionQueue.length && actionLen > i){
3854
- i++;
3855
- operation = data.actionQueue.shift();
3856
- try{
3857
- data.api[operation.fn].apply(data.api, operation.args);
3858
- } catch(er){
3859
- webshims.warn(er);
3860
- }
3861
- }
3862
- }
3863
- if(data.actionQueue.length){
3864
- data.actionQueue = [];
3865
- }
3866
- };
3867
- var startAutoPlay = function(data){
3868
- if(!data){return;}
3869
- if( (data._ppFlag === undefined && ($.prop(data._elem, 'autoplay')) || !data.paused)){
3870
- setTimeout(function(){
3871
- if(data.isActive == 'third' && (data._ppFlag === undefined || !data.paused)){
3872
-
3873
- try {
3874
- $(data._elem).play();
3875
- data._ppFlag = true;
3876
- } catch(er){}
3877
- }
3878
- }, 1);
3879
- }
3880
-
3881
- if(data.muted){
3882
- $.prop(data._elem, 'muted', true);
3883
- }
3884
- if(data.volume != 1){
3885
- $.prop(data._elem, 'volume', data.volume);
3886
- }
3887
- };
3888
-
3889
-
3890
- var addMediaToStopEvents = $.noop;
3891
- if(hasNative){
3892
- var stopEvents = {
3893
- play: 1,
3894
- playing: 1
3895
- };
3896
- var hideEvtArray = ['play', 'pause', 'playing', 'canplay', 'progress', 'waiting', 'ended', 'loadedmetadata', 'durationchange', 'emptied'];
3897
- var hidevents = hideEvtArray.map(function(evt){
3898
- return evt +'.webshimspolyfill';
3899
- }).join(' ');
3900
-
3901
- var hidePlayerEvents = function(event){
3902
- var data = webshims.data(event.target, 'mediaelement');
3903
- if(!data){return;}
3904
- var isNativeHTML5 = ( event.originalEvent && event.originalEvent.type === event.type );
3905
- if( isNativeHTML5 == (data.activating == 'third') ){
3906
- event.stopImmediatePropagation();
3907
-
3908
- if(stopEvents[event.type]){
3909
- if(data.isActive != data.activating){
3910
- $(event.target).pause();
3911
- } else if(isNativeHTML5){
3912
- ($.prop(event.target, 'pause')._supvalue || $.noop).apply(event.target);
3913
- }
3914
- }
3915
- }
3916
- };
3917
-
3918
- addMediaToStopEvents = function(elem){
3919
- $(elem)
3920
- .off(hidevents)
3921
- .on(hidevents, hidePlayerEvents)
3922
- ;
3923
- hideEvtArray.forEach(function(evt){
3924
- webshims.moveToFirstEvent(elem, evt);
3925
- });
3926
- };
3927
- addMediaToStopEvents(document);
3928
- }
3929
-
3930
-
3931
- mediaelement.setActive = function(elem, type, data){
3932
- if(!data){
3933
- data = webshims.data(elem, 'mediaelement');
3934
- }
3935
- if(!data || data.isActive == type){return;}
3936
- if(type != 'html5' && type != 'third'){
3937
- webshims.warn('wrong type for mediaelement activating: '+ type);
3938
- }
3939
- var shadowData = webshims.data(elem, 'shadowData');
3940
- data.activating = type;
3941
- $(elem).pause();
3942
- data.isActive = type;
3943
- if(type == 'third'){
3944
- shadowData.shadowElement = shadowData.shadowFocusElement = data.shadowElem[0];
3945
- $(elem).addClass('swf-api-active nonnative-api-active').hide().getShadowElement().show();
3946
- } else {
3947
- $(elem).removeClass('swf-api-active nonnative-api-active').show().getShadowElement().hide();
3948
- shadowData.shadowElement = shadowData.shadowFocusElement = false;
3949
- }
3950
- $(elem).trigger('mediaelementapichange');
3951
- };
3952
-
3953
-
3954
-
3955
- var resetSwfProps = (function(){
3956
- var resetProtoProps = ['_calledMeta', 'lastDuration', '_bufferedEnd', '_bufferedStart', '_ppFlag', 'currentSrc', 'currentTime', 'duration', 'ended', 'networkState', 'paused', 'seeking', 'videoHeight', 'videoWidth'];
3957
- var len = resetProtoProps.length;
3958
- return function(data){
3959
-
3960
- if(!data){return;}
3961
- clearTimeout(data._seekedTimer);
3962
- var lenI = len;
3963
- var networkState = data.networkState;
3964
- setReadyState(0, data);
3965
- clearTimeout(data._durationChangeTimer);
3966
- while(--lenI > -1){
3967
- delete data[resetProtoProps[lenI]];
3968
- }
3969
- data.actionQueue = [];
3970
- data.buffered.length = 0;
3971
- if(networkState){
3972
- trigger(data._elem, 'emptied');
3973
- }
3974
- };
3975
- })();
3976
-
3977
-
3978
- var getComputedDimension = (function(){
3979
- var dimCache = {};
3980
- var getVideoDims = function(data){
3981
- var ret, poster, img;
3982
- if(dimCache[data.currentSrc]){
3983
- ret = dimCache[data.currentSrc];
3984
- } else if(data.videoHeight && data.videoWidth){
3985
- dimCache[data.currentSrc] = {
3986
- width: data.videoWidth,
3987
- height: data.videoHeight
3988
- };
3989
- ret = dimCache[data.currentSrc];
3990
- } else if((poster = $.attr(data._elem, 'poster'))){
3991
- ret = dimCache[poster];
3992
- if(!ret){
3993
- img = document.createElement('img');
3994
- img.onload = function(){
3995
- dimCache[poster] = {
3996
- width: this.width,
3997
- height: this.height
3998
- };
3999
-
4000
- if(dimCache[poster].height && dimCache[poster].width){
4001
- setElementDimension(data, $.prop(data._elem, 'controls'));
4002
- } else {
4003
- delete dimCache[poster];
4004
- }
4005
- img.onload = null;
4006
- };
4007
- img.src = poster;
4008
- if(img.complete && img.onload){
4009
- img.onload();
4010
- }
4011
- }
4012
- }
4013
- return ret || {width: 300, height: data._elemNodeName == 'video' ? 150 : 50};
4014
- };
4015
-
4016
- var getCssStyle = function(elem, style){
4017
- return elem.style[style] || (elem.currentStyle && elem.currentStyle[style]) || (window.getComputedStyle && (window.getComputedStyle( elem, null ) || {} )[style]) || '';
4018
- };
4019
- var minMaxProps = ['minWidth', 'maxWidth', 'minHeight', 'maxHeight'];
4020
-
4021
- var addMinMax = function(elem, ret){
4022
- var i, prop;
4023
- var hasMinMax = false;
4024
- for (i = 0; i < 4; i++) {
4025
- prop = getCssStyle(elem, minMaxProps[i]);
4026
- if(parseFloat(prop, 10)){
4027
- hasMinMax = true;
4028
- ret[minMaxProps[i]] = prop;
4029
- }
4030
- }
4031
- return hasMinMax;
4032
- };
4033
- var retFn = function(data){
4034
- var videoDims, ratio, hasMinMax;
4035
- var elem = data._elem;
4036
- var autos = {
4037
- width: getCssStyle(elem, 'width') == 'auto',
4038
- height: getCssStyle(elem, 'height') == 'auto'
4039
- };
4040
- var ret = {
4041
- width: !autos.width && $(elem).width(),
4042
- height: !autos.height && $(elem).height()
4043
- };
4044
-
4045
- if(autos.width || autos.height){
4046
- videoDims = getVideoDims(data);
4047
- ratio = videoDims.width / videoDims.height;
4048
-
4049
- if(autos.width && autos.height){
4050
- ret.width = videoDims.width;
4051
- ret.height = videoDims.height;
4052
- } else if(autos.width){
4053
- ret.width = ret.height * ratio;
4054
- } else if(autos.height){
4055
- ret.height = ret.width / ratio;
4056
- }
4057
-
4058
- if(addMinMax(elem, ret)){
4059
- data.shadowElem.css(ret);
4060
- if(autos.width){
4061
- ret.width = data.shadowElem.height() * ratio;
4062
- }
4063
- if(autos.height){
4064
- ret.height = ((autos.width) ? ret.width : data.shadowElem.width()) / ratio;
4065
- }
4066
- if(autos.width && autos.height){
4067
- data.shadowElem.css(ret);
4068
- ret.height = data.shadowElem.width() / ratio;
4069
- ret.width = ret.height * ratio;
4070
-
4071
- data.shadowElem.css(ret);
4072
- ret.width = data.shadowElem.height() * ratio;
4073
- ret.height = ret.width / ratio;
4074
-
4075
- }
4076
- if(!Modernizr.video){
4077
- ret.width = data.shadowElem.width();
4078
- ret.height = data.shadowElem.height();
4079
- }
4080
- }
4081
- }
4082
- return ret;
4083
- };
4084
-
4085
- return retFn;
4086
- })();
4087
-
4088
- var setElementDimension = function(data, hasControls){
4089
- var dims;
4090
-
4091
- var box = data.shadowElem;
4092
- $(data._elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
4093
-
4094
- if(data.isActive == 'third' || data.activating == 'third'){
4095
- if(data._elemNodeName == 'audio' && !hasControls){
4096
- box.css({width: 0, height: 0});
4097
- } else {
4098
- data._elem.style.display = '';
4099
- dims = getComputedDimension(data);
4100
- data._elem.style.display = 'none';
4101
- box.css(dims);
4102
- }
4103
- }
4104
- };
4105
-
4106
- var bufferSrc = (function(){
4107
- var preloads = {
4108
- '': 1,
4109
- 'auto': 1
4110
- };
4111
- return function(elem){
4112
- var preload = $.attr(elem, 'preload');
4113
- if(preload == null || preload == 'none' || $.prop(elem, 'autoplay')){
4114
- return false;
4115
- }
4116
- preload = $.prop(elem, 'preload');
4117
- return !!(preloads[preload] || (preload == 'metadata' && $(elem).is('.preload-in-doubt, video:not([poster])')));
4118
- };
4119
- })();
4120
-
4121
- var regs = {
4122
- A: /&amp;/g,
4123
- a: /&/g,
4124
- e: /\=/g,
4125
- q: /\?/g
4126
- },
4127
- replaceVar = function(val){
4128
- return (val.replace) ? val.replace(regs.A, '%26').replace(regs.a, '%26').replace(regs.e, '%3D').replace(regs.q, '%3F') : val;
4129
- };
4130
-
4131
- if('matchMedia' in window){
4132
- var allowMediaSorting = false;
4133
- try {
4134
- allowMediaSorting = window.matchMedia('only all').matches;
4135
- } catch(er){}
4136
- if(allowMediaSorting){
4137
- mediaelement.sortMedia = function(src1, src2){
4138
- try {
4139
- src1 = !src1.media || matchMedia( src1.media ).matches;
4140
- src2 = !src2.media || matchMedia( src2.media ).matches;
4141
- } catch(er){
4142
- return 0;
4143
- }
4144
- return src1 == src2 ?
4145
- 0 :
4146
- src1 ? -1
4147
- : 1;
4148
- };
4149
- }
4150
- }
4151
-
4152
- mediaelement.createSWF = function( elem, canPlaySrc, data ){
4153
- if(!hasFlash){
4154
- setTimeout(function(){
4155
- $(elem).mediaLoad(); //<- this should produce a mediaerror
4156
- }, 1);
4157
- return;
4158
- }
4159
-
4160
- var attrStyle = {};
4161
-
4162
- if(loadedSwf < 1){
4163
- loadedSwf = 1;
4164
- } else {
4165
- loadedSwf++;
4166
- }
4167
- if(!data){
4168
- data = webshims.data(elem, 'mediaelement');
4169
- }
4170
-
4171
- if((attrStyle.height = $.attr(elem, 'height') || '') || (attrStyle.width = $.attr(elem, 'width') || '')){
4172
- $(elem).css(attrStyle);
4173
- webshims.warn("width or height content attributes used. Webshims prefers the usage of CSS (computed styles or inline styles) to detect size of a video/audio. It's really more powerfull.");
4174
- }
4175
-
4176
- var isRtmp = canPlaySrc.type == 'audio/rtmp' || canPlaySrc.type == 'video/rtmp';
4177
- var vars = $.extend({}, options.vars, {
4178
- poster: replaceVar($.attr(elem, 'poster') && $.prop(elem, 'poster') || ''),
4179
- source: replaceVar(canPlaySrc.streamId || canPlaySrc.srcProp),
4180
- server: replaceVar(canPlaySrc.server || '')
4181
- });
4182
- var elemVars = $(elem).data('vars') || {};
4183
-
4184
-
4185
-
4186
- var hasControls = $.prop(elem, 'controls');
4187
- var elemId = 'jarisplayer-'+ webshims.getID(elem);
4188
-
4189
- var params = $.extend(
4190
- {},
4191
- options.params,
4192
- $(elem).data('params')
4193
- );
4194
- var elemNodeName = elem.nodeName.toLowerCase();
4195
- var attrs = $.extend(
4196
- {},
4197
- options.attrs,
4198
- {
4199
- name: elemId,
4200
- id: elemId
4201
- },
4202
- $(elem).data('attrs')
4203
- );
4204
- var setDimension = function(){
4205
- if(data.isActive == 'third'){
4206
- setElementDimension(data, $.prop(elem, 'controls'));
4207
- }
4208
- };
4209
-
4210
- var box;
4211
-
4212
- if(data && data.swfCreated){
4213
- mediaelement.setActive(elem, 'third', data);
4214
-
4215
- data.currentSrc = canPlaySrc.srcProp;
4216
-
4217
- data.shadowElem.html('<div id="'+ elemId +'">');
4218
-
4219
- data.api = false;
4220
- data.actionQueue = [];
4221
- box = data.shadowElem;
4222
- resetSwfProps(data);
4223
- } else {
4224
- $(document.getElementById('wrapper-'+ elemId )).remove();
4225
- box = $('<div class="polyfill-'+ (elemNodeName) +' polyfill-mediaelement '+ webshims.shadowClass +'" id="wrapper-'+ elemId +'"><div id="'+ elemId +'"></div>')
4226
- .css({
4227
- position: 'relative',
4228
- overflow: 'hidden'
4229
- })
4230
- ;
4231
- data = webshims.data(elem, 'mediaelement', webshims.objectCreate(playerStateObj, {
4232
- actionQueue: {
4233
- value: []
4234
- },
4235
- shadowElem: {
4236
- value: box
4237
- },
4238
- _elemNodeName: {
4239
- value: elemNodeName
4240
- },
4241
- _elem: {
4242
- value: elem
4243
- },
4244
- currentSrc: {
4245
- value: canPlaySrc.srcProp
4246
- },
4247
- swfCreated: {
4248
- value: true
4249
- },
4250
- id: {
4251
- value: elemId.replace(/-/g, '')
4252
- },
4253
- buffered: {
4254
- value: {
4255
- start: function(index){
4256
- if(index >= data.buffered.length){
4257
- webshims.error('buffered index size error');
4258
- return;
4259
- }
4260
- return 0;
4261
- },
4262
- end: function(index){
4263
- if(index >= data.buffered.length){
4264
- webshims.error('buffered index size error');
4265
- return;
4266
- }
4267
- return ( (data.duration - data._bufferedStart) * data._bufferedEnd) + data._bufferedStart;
4268
- },
4269
- length: 0
4270
- }
4271
- }
4272
- }));
4273
-
4274
-
4275
-
4276
- box.insertBefore(elem);
4277
-
4278
- if(hasNative){
4279
- $.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted'), paused: $.prop(elem, 'paused')});
4280
- }
4281
-
4282
- webshims.addShadowDom(elem, box);
4283
- if(!webshims.data(elem, 'mediaelement')){
4284
- webshims.data(elem, 'mediaelement', data);
4285
- }
4286
- addMediaToStopEvents(elem);
4287
-
4288
- mediaelement.setActive(elem, 'third', data);
4289
-
4290
- setElementDimension(data, hasControls);
4291
-
4292
- $(elem)
4293
- .on({
4294
- 'updatemediaelementdimensions loadedmetadata emptied': setDimension,
4295
- 'remove': function(e){
4296
- if(!e.originalEvent && mediaelement.jarisEvent[data.id] && mediaelement.jarisEvent[data.id].elem == elem){
4297
- delete mediaelement.jarisEvent[data.id];
4298
- clearTimeout(localConnectionTimer);
4299
- clearTimeout(data.flashBlock);
4300
- }
4301
- }
4302
- })
4303
- .onWSOff('updateshadowdom', setDimension)
4304
- ;
4305
- }
4306
-
4307
- if(mediaelement.jarisEvent[data.id] && mediaelement.jarisEvent[data.id].elem != elem){
4308
- webshims.error('something went wrong');
4309
- return;
4310
- } else if(!mediaelement.jarisEvent[data.id]){
4311
-
4312
- mediaelement.jarisEvent[data.id] = function(jaris){
4313
-
4314
- if(jaris.type == 'ready'){
4315
- var onReady = function(){
4316
- if(data.api){
4317
- if(!data.paused){
4318
- data.api.api_play();
4319
- }
4320
- if(bufferSrc(elem)){
4321
- data.api.api_preload();
4322
- }
4323
- onEvent.ready(jaris, data);
4324
- }
4325
- };
4326
- if(data.api){
4327
- onReady();
4328
- } else {
4329
- setTimeout(onReady, 9);
4330
- }
4331
- } else {
4332
- data.currentTime = jaris.position;
4333
-
4334
- if(data.api){
4335
- if(!data._calledMeta && isNaN(jaris.duration) && data.duration != jaris.duration && isNaN(data.duration)){
4336
- onEvent.onDataInitialized(jaris, data);
4337
- }
4338
-
4339
- if(!data._ppFlag && jaris.type != 'onPlayPause'){
4340
- onEvent.onPlayPause(jaris, data);
4341
- }
4342
-
4343
- if(onEvent[jaris.type]){
4344
- onEvent[jaris.type](jaris, data);
4345
- }
4346
- }
4347
- data.duration = jaris.duration;
4348
- }
4349
- };
4350
- mediaelement.jarisEvent[data.id].elem = elem;
4351
- }
4352
-
4353
- $.extend(vars,
4354
- {
4355
- id: elemId,
4356
- evtId: data.id,
4357
- controls: ''+hasControls,
4358
- autostart: 'false',
4359
- nodename: elemNodeName
4360
- },
4361
- elemVars
4362
- );
4363
-
4364
- if(isRtmp){
4365
- vars.streamtype = 'rtmp';
4366
- } else if(canPlaySrc.type == 'audio/mpeg' || canPlaySrc.type == 'audio/mp3'){
4367
- vars.type = 'audio';
4368
- vars.streamtype = 'file';
4369
- } else if(canPlaySrc.type == 'video/youtube'){
4370
- vars.streamtype = 'youtube';
4371
- }
4372
- options.changeSWF(vars, elem, canPlaySrc, data, 'embed');
4373
- clearTimeout(data.flashBlock);
4374
-
4375
- swfmini.embedSWF(playerSwfPath, elemId, "100%", "100%", "9.0.115", false, vars, params, attrs, function(swfData){
4376
- if(swfData.success){
4377
- var fBlocker = function(){
4378
- if((!swfData.ref.parentNode && box[0].parentNode) || swfData.ref.style.display == "none"){
4379
- box.addClass('flashblocker-assumed');
4380
- $(elem).trigger('flashblocker');
4381
- webshims.warn("flashblocker assumed");
4382
- }
4383
- $(swfData.ref).css({'minHeight': '2px', 'minWidth': '2px', display: 'block'});
4384
- };
4385
- data.api = swfData.ref;
4386
-
4387
- if(!hasControls){
4388
- $(swfData.ref).attr('tabindex', '-1').css('outline', 'none');
4389
- }
4390
-
4391
- data.flashBlock = setTimeout(fBlocker, 99);
4392
-
4393
- if(!localConnectionTimer){
4394
- clearTimeout(localConnectionTimer);
4395
- localConnectionTimer = setTimeout(function(){
4396
- fBlocker();
4397
- var flash = $(swfData.ref);
4398
- if(flash[0].offsetWidth > 1 && flash[0].offsetHeight > 1 && location.protocol.indexOf('file:') === 0){
4399
- 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");
4400
- } else if(flash[0].offsetWidth < 2 || flash[0].offsetHeight < 2) {
4401
- webshims.warn("JS-SWF connection can't be established on hidden or unconnected flash objects");
4402
- }
4403
- flash = null;
4404
- }, 8000);
4405
- }
4406
- }
4407
- });
4408
-
4409
- };
4410
-
4411
-
4412
- var queueSwfMethod = function(elem, fn, args, data){
4413
- data = data || getSwfDataFromElem(elem);
4414
-
4415
- if(data){
4416
- if(data.api && data.api[fn]){
4417
- data.api[fn].apply(data.api, args || []);
4418
- } else {
4419
- //todo add to queue
4420
- data.actionQueue.push({fn: fn, args: args});
4421
-
4422
- if(data.actionQueue.length > 10){
4423
- setTimeout(function(){
4424
- if(data.actionQueue.length > 5){
4425
- data.actionQueue.shift();
4426
- }
4427
- }, 99);
4428
- }
4429
- }
4430
- return data;
4431
- }
4432
- return false;
4433
- };
4434
-
4435
- ['audio', 'video'].forEach(function(nodeName){
4436
- var descs = {};
4437
- var mediaSup;
4438
- var createGetProp = function(key){
4439
- if(nodeName == 'audio' && (key == 'videoHeight' || key == 'videoWidth')){return;}
4440
-
4441
- descs[key] = {
4442
- get: function(){
4443
- var data = getSwfDataFromElem(this);
4444
- if(data){
4445
- return data[key];
4446
- } else if(hasNative && mediaSup[key].prop._supget) {
4447
- return mediaSup[key].prop._supget.apply(this);
4448
- } else {
4449
- return playerStateObj[key];
4450
- }
4451
- },
4452
- writeable: false
4453
- };
4454
- };
4455
- var createGetSetProp = function(key, setFn){
4456
- createGetProp(key);
4457
- delete descs[key].writeable;
4458
- descs[key].set = setFn;
4459
- };
4460
-
4461
- createGetSetProp('seeking');
4462
-
4463
- createGetSetProp('volume', function(v){
4464
- var data = getSwfDataFromElem(this);
4465
- if(data){
4466
- v *= 1;
4467
- if(!isNaN(v)){
4468
-
4469
- if(v < 0 || v > 1){
4470
- webshims.error('volume greater or less than allowed '+ (v / 100));
4471
- }
4472
-
4473
- queueSwfMethod(this, 'api_volume', [v], data);
4474
-
4475
-
4476
- if(data.volume != v){
4477
- data.volume = v;
4478
- trigger(data._elem, 'volumechange');
4479
- }
4480
- data = null;
4481
- }
4482
- } else if(mediaSup.volume.prop._supset) {
4483
- return mediaSup.volume.prop._supset.apply(this, arguments);
4484
- }
4485
- });
4486
-
4487
- createGetSetProp('muted', function(m){
4488
- var data = getSwfDataFromElem(this);
4489
- if(data){
4490
- m = !!m;
4491
- queueSwfMethod(this, 'api_muted', [m], data);
4492
- if(data.muted != m){
4493
- data.muted = m;
4494
- trigger(data._elem, 'volumechange');
4495
- }
4496
- data = null;
4497
- } else if(mediaSup.muted.prop._supset) {
4498
- return mediaSup.muted.prop._supset.apply(this, arguments);
4499
- }
4500
- });
4501
-
4502
-
4503
- createGetSetProp('currentTime', function(t){
4504
- var data = getSwfDataFromElem(this);
4505
- if(data){
4506
- t *= 1;
4507
- if (!isNaN(t)) {
4508
- queueSwfMethod(this, 'api_seek', [t], data);
4509
- }
4510
-
4511
- } else if(mediaSup.currentTime.prop._supset) {
4512
- return mediaSup.currentTime.prop._supset.apply(this, arguments);
4513
- }
4514
- });
4515
-
4516
- ['play', 'pause'].forEach(function(fn){
4517
- descs[fn] = {
4518
- value: function(){
4519
- var data = getSwfDataFromElem(this);
4520
-
4521
- if(data){
4522
- if(data.stopPlayPause){
4523
- clearTimeout(data.stopPlayPause);
4524
- }
4525
- queueSwfMethod(this, fn == 'play' ? 'api_play' : 'api_pause', [], data);
4526
-
4527
- data._ppFlag = true;
4528
- if(data.paused != (fn != 'play')){
4529
- data.paused = fn != 'play';
4530
- trigger(data._elem, fn);
4531
- }
4532
- } else if(mediaSup[fn].prop._supvalue) {
4533
- return mediaSup[fn].prop._supvalue.apply(this, arguments);
4534
- }
4535
- }
4536
- };
4537
- });
4538
-
4539
- getPropKeys.forEach(createGetProp);
4540
-
4541
- webshims.onNodeNamesPropertyModify(nodeName, 'controls', function(val, boolProp){
4542
- var data = getSwfDataFromElem(this);
4543
-
4544
- $(this)[boolProp ? 'addClass' : 'removeClass']('webshims-controls');
4545
-
4546
- if(data){
4547
- if(nodeName == 'audio'){
4548
- setElementDimension(data, boolProp);
4549
- }
4550
- queueSwfMethod(this, 'api_controls', [boolProp], data);
4551
- }
4552
- });
4553
-
4554
-
4555
- webshims.onNodeNamesPropertyModify(nodeName, 'preload', function(val){
4556
- var data, baseData, elem;
4557
-
4558
-
4559
- if(bufferSrc(this)){
4560
- data = getSwfDataFromElem(this);
4561
- if(data){
4562
- queueSwfMethod(this, 'api_preload', [], data);
4563
- } else if(needsLoadPreload && this.paused && !this.error && !$.data(this, 'mediaerror') && !this.readyState && !this.networkState && !this.autoplay && $(this).is(':not(.nonnative-api-active)')){
4564
- elem = this;
4565
- baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
4566
- clearTimeout(baseData.loadTimer);
4567
- baseData.loadTimer = setTimeout(function(){
4568
- $(elem).mediaLoad();
4569
- }, 9);
4570
- }
4571
- }
4572
- });
4573
-
4574
- mediaSup = webshims.defineNodeNameProperties(nodeName, descs, 'prop');
4575
-
4576
- if(!Modernizr.mediaDefaultMuted){
4577
- webshims.defineNodeNameProperties(nodeName, {
4578
- defaultMuted: {
4579
- get: function(){
4580
- return $.attr(this, 'muted') != null;
4581
- },
4582
- set: function(val){
4583
- if(val){
4584
- $.attr(this, 'muted', '');
4585
- } else {
4586
- $(this).removeAttr('muted');
4587
- }
4588
- }
4589
- }
4590
- }, 'prop');
4591
- }
4592
- });
4593
-
4594
-
4595
- if(hasFlash && $.cleanData){
4596
- var oldClean = $.cleanData;
4597
- var objElem = document.createElement('object');
4598
- var noRemove = {
4599
- SetVariable: 1,
4600
- GetVariable: 1,
4601
- SetReturnValue: 1,
4602
- GetReturnValue: 1
4603
- };
4604
- var flashNames = {
4605
- object: 1,
4606
- OBJECT: 1
4607
- };
4608
-
4609
- $.cleanData = function(elems){
4610
- var i, len, prop;
4611
- var ret = oldClean.apply(this, arguments);
4612
- if(elems && (len = elems.length) && loadedSwf){
4613
-
4614
- for(i = 0; i < len; i++){
4615
- if(flashNames[elems[i].nodeName] && 'api_pause' in elems[i]){
4616
- loadedSwf--;
4617
- try {
4618
- elems[i].api_pause();
4619
- if(elems[i].readyState == 4){
4620
- for (prop in elems[i]) {
4621
- if (!noRemove[prop] && !objElem[prop] && typeof elems[i][prop] == "function") {
4622
- elems[i][prop] = null;
4623
- }
4624
- }
4625
- }
4626
- } catch(er){}
4627
- }
4628
- }
4629
-
4630
- }
4631
- return ret;
4632
- };
4633
- }
4634
-
4635
- if(!hasNative){
4636
-
4637
- ['poster', 'src'].forEach(function(prop){
4638
- webshims.defineNodeNamesProperty(prop == 'src' ? ['audio', 'video', 'source'] : ['video'], prop, {
4639
- //attr: {},
4640
- reflect: true,
4641
- propType: 'src'
4642
- });
4643
- });
4644
-
4645
- webshims.defineNodeNamesProperty(['audio', 'video'], 'preload', {
4646
- reflect: true,
4647
- propType: 'enumarated',
4648
- defaultValue: '',
4649
- limitedTo: ['', 'auto', 'metadata', 'none']
4650
- });
4651
-
4652
- webshims.reflectProperties('source', ['type', 'media']);
4653
-
4654
-
4655
- ['autoplay', 'controls'].forEach(function(name){
4656
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], name);
4657
- });
4658
-
4659
- webshims.defineNodeNamesProperties(['audio', 'video'], {
4660
- HAVE_CURRENT_DATA: {
4661
- value: 2
4662
- },
4663
- HAVE_ENOUGH_DATA: {
4664
- value: 4
4665
- },
4666
- HAVE_FUTURE_DATA: {
4667
- value: 3
4668
- },
4669
- HAVE_METADATA: {
4670
- value: 1
4671
- },
4672
- HAVE_NOTHING: {
4673
- value: 0
4674
- },
4675
- NETWORK_EMPTY: {
4676
- value: 0
4677
- },
4678
- NETWORK_IDLE: {
4679
- value: 1
4680
- },
4681
- NETWORK_LOADING: {
4682
- value: 2
4683
- },
4684
- NETWORK_NO_SOURCE: {
4685
- value: 3
4686
- }
4687
-
4688
- }, 'prop');
4689
-
4690
-
4691
- if(hasFlash){
4692
- webshims.ready('WINDOWLOAD', function(){
4693
- setTimeout(function(){
4694
- if(!loadedSwf){
4695
- document.createElement('img').src = playerSwfPath;
4696
- }
4697
- }, 9);
4698
- });
4699
- }
4700
- } else if(!('media' in document.createElement('source'))){
4701
- webshims.reflectProperties('source', ['media']);
4702
- }
4703
-
4704
- if(hasNative && hasFlash && !options.preferFlash){
4705
- var switchErrors = {
4706
- 3: 1,
4707
- 4: 1
4708
- };
4709
- var switchOptions = function(e){
4710
- var media, error, parent;
4711
- if(
4712
- ($(e.target).is('audio, video') || ((parent = e.target.parentNode) && $('source', parent).last()[0] == e.target)) &&
4713
- (media = $(e.target).closest('audio, video')) && !media.is('.nonnative-api-active')
4714
- ){
4715
- error = media.prop('error');
4716
- setTimeout(function(){
4717
- if(!media.is('.nonnative-api-active')){
4718
- if(error && switchErrors[error.code]){
4719
- options.preferFlash = true;
4720
- document.removeEventListener('error', switchOptions, true);
4721
- $('audio, video').each(function(){
4722
- webshims.mediaelement.selectSource(this);
4723
- });
4724
- webshims.error("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.currentSrc+" Mediaerror: "+ media.prop('error')+ ' error.code: '+ error.code);
4725
- }
4726
- webshims.warn('There was a mediaelement error. Run the following line in your console to get more info: webshim.mediaelement.loadDebugger();')
4727
- }
4728
- });
4729
-
4730
-
4731
- }
4732
- };
4733
-
4734
- document.addEventListener('error', switchOptions, true);
4735
- setTimeout(function(){
4736
- $('audio, video').each(function(){
4737
- var error = $.prop(this, 'error');
4738
- if(error && switchErrors[error]){
4739
- switchOptions({target: this});
4740
- }
4741
- });
4742
- });
4743
- }
4744
-
4745
- });