webshims-rails 0.4.7 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +15 -0
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/extras/custom-validity.js +1 -1
  4. data/vendor/assets/javascripts/webshims/extras/mousepress.js +1 -1
  5. data/vendor/assets/javascripts/webshims/polyfiller.js +197 -166
  6. data/vendor/assets/javascripts/webshims/shims/combos/1.js +1711 -1609
  7. data/vendor/assets/javascripts/webshims/shims/combos/10.js +2575 -2253
  8. data/vendor/assets/javascripts/webshims/shims/combos/11.js +2452 -1476
  9. data/vendor/assets/javascripts/webshims/shims/combos/12.js +1405 -1159
  10. data/vendor/assets/javascripts/webshims/shims/combos/13.js +1316 -963
  11. data/vendor/assets/javascripts/webshims/shims/combos/14.js +1862 -179
  12. data/vendor/assets/javascripts/webshims/shims/combos/15.js +4327 -287
  13. data/vendor/assets/javascripts/webshims/shims/combos/16.js +3887 -586
  14. data/vendor/assets/javascripts/webshims/shims/combos/17.js +2911 -2159
  15. data/vendor/assets/javascripts/webshims/shims/combos/18.js +3425 -1730
  16. data/vendor/assets/javascripts/webshims/shims/combos/19.js +2854 -1203
  17. data/vendor/assets/javascripts/webshims/shims/combos/2.js +3351 -2130
  18. data/vendor/assets/javascripts/webshims/shims/combos/20.js +2426 -581
  19. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1915 -1574
  20. data/vendor/assets/javascripts/webshims/shims/combos/22.js +864 -2275
  21. data/vendor/assets/javascripts/webshims/shims/combos/23.js +609 -1811
  22. data/vendor/assets/javascripts/webshims/shims/combos/3.js +1655 -2736
  23. data/vendor/assets/javascripts/webshims/shims/combos/4.js +1037 -603
  24. data/vendor/assets/javascripts/webshims/shims/combos/5.js +3100 -773
  25. data/vendor/assets/javascripts/webshims/shims/combos/6.js +3631 -840
  26. data/vendor/assets/javascripts/webshims/shims/combos/7.js +3596 -1354
  27. data/vendor/assets/javascripts/webshims/shims/combos/8.js +1731 -188
  28. data/vendor/assets/javascripts/webshims/shims/combos/9.js +3243 -1431
  29. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +107 -18
  30. data/vendor/assets/javascripts/webshims/shims/es5.js +1 -0
  31. data/vendor/assets/javascripts/webshims/shims/form-core.js +553 -464
  32. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +160 -154
  33. data/vendor/assets/javascripts/webshims/shims/form-message.js +73 -49
  34. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +18 -1
  35. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +161 -36
  36. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +2130 -813
  37. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +206 -58
  38. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ar.js → formcfg-ar.js} +30 -0
  39. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ch-ZN.js → formcfg-ch-ZN.js} +31 -0
  40. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-de.txt → formcfg-de.txt} +50 -11
  41. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-el.js → formcfg-el.js} +31 -0
  42. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-en.txt → formcfg-en.txt} +44 -11
  43. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-es.js → formcfg-es.js} +31 -0
  44. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-fr.js → formcfg-fr.js} +31 -0
  45. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-he.js → formcfg-he.js} +31 -0
  46. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-hi.js → formcfg-hi.js} +31 -0
  47. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-hu.js → formcfg-hu.js} +31 -0
  48. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-it.js → formcfg-it.js} +31 -0
  49. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ja.js → formcfg-ja.js} +31 -0
  50. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-nl.js → formcfg-nl.js} +31 -0
  51. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-pt-PT.js → formcfg-pt-PT.js} +31 -0
  52. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ru.js → formcfg-ru.js} +31 -0
  53. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-sv.js → formcfg-sv.js} +32 -0
  54. data/vendor/assets/javascripts/webshims/shims/json-storage.js +16 -10
  55. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +155 -122
  56. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +76 -41
  57. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +8 -16
  58. data/vendor/assets/javascripts/webshims/shims/range-ui.js +388 -0
  59. data/vendor/assets/javascripts/webshims/shims/styles/config.rb +12 -0
  60. data/vendor/assets/javascripts/webshims/shims/styles/forms.png +0 -0
  61. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +1186 -0
  62. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +868 -548
  63. data/vendor/assets/javascripts/webshims/shims/styles/vertical-range.png +0 -0
  64. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  65. data/vendor/assets/javascripts/webshims/shims/swfmini.js +497 -0
  66. data/vendor/assets/javascripts/webshims/shims/track-ui.js +3 -0
  67. data/vendor/assets/javascripts/webshims/shims/track.js +29 -29
  68. metadata +26 -125
  69. data/vendor/assets/javascripts/webshims/minified/extras/custom-validity.js +0 -1
  70. data/vendor/assets/javascripts/webshims/minified/extras/modernizr-custom.js +0 -1
  71. data/vendor/assets/javascripts/webshims/minified/extras/mousepress.js +0 -1
  72. data/vendor/assets/javascripts/webshims/minified/polyfiller.js +0 -1
  73. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/canvas2png.js +0 -1
  74. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/flashcanvas.js +0 -1
  75. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/flashcanvas.swf +0 -0
  76. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/proxy.php +0 -73
  77. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/save.php +0 -49
  78. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/canvas2png.js +0 -1
  79. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/flash10canvas.swf +0 -0
  80. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/flash9canvas.swf +0 -0
  81. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/flashcanvas.js +0 -1
  82. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/proxy.php +0 -73
  83. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/save.php +0 -49
  84. data/vendor/assets/javascripts/webshims/minified/shims/combos/1.js +0 -1
  85. data/vendor/assets/javascripts/webshims/minified/shims/combos/10.js +0 -1
  86. data/vendor/assets/javascripts/webshims/minified/shims/combos/11.js +0 -1
  87. data/vendor/assets/javascripts/webshims/minified/shims/combos/12.js +0 -1
  88. data/vendor/assets/javascripts/webshims/minified/shims/combos/13.js +0 -1
  89. data/vendor/assets/javascripts/webshims/minified/shims/combos/14.js +0 -1
  90. data/vendor/assets/javascripts/webshims/minified/shims/combos/15.js +0 -1
  91. data/vendor/assets/javascripts/webshims/minified/shims/combos/16.js +0 -1
  92. data/vendor/assets/javascripts/webshims/minified/shims/combos/17.js +0 -1
  93. data/vendor/assets/javascripts/webshims/minified/shims/combos/18.js +0 -1
  94. data/vendor/assets/javascripts/webshims/minified/shims/combos/19.js +0 -1
  95. data/vendor/assets/javascripts/webshims/minified/shims/combos/2.js +0 -1
  96. data/vendor/assets/javascripts/webshims/minified/shims/combos/20.js +0 -1
  97. data/vendor/assets/javascripts/webshims/minified/shims/combos/21.js +0 -1
  98. data/vendor/assets/javascripts/webshims/minified/shims/combos/22.js +0 -1
  99. data/vendor/assets/javascripts/webshims/minified/shims/combos/23.js +0 -1
  100. data/vendor/assets/javascripts/webshims/minified/shims/combos/24.js +0 -1
  101. data/vendor/assets/javascripts/webshims/minified/shims/combos/25.js +0 -1
  102. data/vendor/assets/javascripts/webshims/minified/shims/combos/26.js +0 -1
  103. data/vendor/assets/javascripts/webshims/minified/shims/combos/27.js +0 -1
  104. data/vendor/assets/javascripts/webshims/minified/shims/combos/3.js +0 -1
  105. data/vendor/assets/javascripts/webshims/minified/shims/combos/4.js +0 -1
  106. data/vendor/assets/javascripts/webshims/minified/shims/combos/5.js +0 -1
  107. data/vendor/assets/javascripts/webshims/minified/shims/combos/59.js +0 -1
  108. data/vendor/assets/javascripts/webshims/minified/shims/combos/6.js +0 -1
  109. data/vendor/assets/javascripts/webshims/minified/shims/combos/7.js +0 -1
  110. data/vendor/assets/javascripts/webshims/minified/shims/combos/8.js +0 -1
  111. data/vendor/assets/javascripts/webshims/minified/shims/combos/9.js +0 -1
  112. data/vendor/assets/javascripts/webshims/minified/shims/details.js +0 -1
  113. data/vendor/assets/javascripts/webshims/minified/shims/dom-extend.js +0 -1
  114. data/vendor/assets/javascripts/webshims/minified/shims/es5.js +0 -1
  115. data/vendor/assets/javascripts/webshims/minified/shims/excanvas.js +0 -1
  116. data/vendor/assets/javascripts/webshims/minified/shims/form-core.js +0 -1
  117. data/vendor/assets/javascripts/webshims/minified/shims/form-datalist.js +0 -1
  118. data/vendor/assets/javascripts/webshims/minified/shims/form-message.js +0 -1
  119. data/vendor/assets/javascripts/webshims/minified/shims/form-native-extend.js +0 -1
  120. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-api.js +0 -1
  121. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-ui.js +0 -1
  122. data/vendor/assets/javascripts/webshims/minified/shims/form-shim-extend.js +0 -1
  123. data/vendor/assets/javascripts/webshims/minified/shims/geolocation.js +0 -1
  124. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ar.js +0 -1
  125. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ch-ZN.js +0 -1
  126. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-de.txt +0 -33
  127. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-el.js +0 -1
  128. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-en.txt +0 -34
  129. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-es.js +0 -1
  130. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-fr.js +0 -1
  131. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-he.js +0 -1
  132. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-hi.js +0 -1
  133. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-hu.js +0 -1
  134. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-it.js +0 -1
  135. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ja.js +0 -1
  136. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-nl.js +0 -1
  137. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-pt-PT.js +0 -1
  138. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ru.js +0 -1
  139. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-sv.js +0 -1
  140. data/vendor/assets/javascripts/webshims/minified/shims/json-storage.js +0 -1
  141. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/license.txt +0 -1
  142. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/player.swf +0 -0
  143. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/readme.html +0 -87
  144. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-core.js +0 -1
  145. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-jaris.js +0 -1
  146. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-native-fix.js +0 -1
  147. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-swf.js +0 -1
  148. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-yt.js +0 -1
  149. data/vendor/assets/javascripts/webshims/minified/shims/styles/details-arrows.png +0 -0
  150. data/vendor/assets/javascripts/webshims/minified/shims/styles/forms.png +0 -0
  151. data/vendor/assets/javascripts/webshims/minified/shims/styles/polyfill-loader.gif +0 -0
  152. data/vendor/assets/javascripts/webshims/minified/shims/styles/shim.css +0 -1
  153. data/vendor/assets/javascripts/webshims/minified/shims/swf/JarisFLVPlayer.swf +0 -0
  154. data/vendor/assets/javascripts/webshims/minified/shims/swf/jwwebshims.swf +0 -0
  155. data/vendor/assets/javascripts/webshims/minified/shims/swf/localStorage.swf +0 -0
  156. data/vendor/assets/javascripts/webshims/minified/shims/track-ui.js +0 -1
  157. data/vendor/assets/javascripts/webshims/minified/shims/track.js +0 -1
  158. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/README +0 -62
  159. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/README +0 -82
  160. data/vendor/assets/javascripts/webshims/shims/combos/24.js +0 -2872
  161. data/vendor/assets/javascripts/webshims/shims/combos/25.js +0 -2376
  162. data/vendor/assets/javascripts/webshims/shims/combos/26.js +0 -3009
  163. data/vendor/assets/javascripts/webshims/shims/combos/27.js +0 -4150
  164. data/vendor/assets/javascripts/webshims/shims/combos/59.js +0 -1747
  165. data/vendor/assets/javascripts/webshims/shims/jwplayer/license.txt +0 -1
  166. data/vendor/assets/javascripts/webshims/shims/jwplayer/player.swf +0 -0
  167. data/vendor/assets/javascripts/webshims/shims/jwplayer/readme.html +0 -87
  168. data/vendor/assets/javascripts/webshims/shims/mediaelement-swf.js +0 -972
@@ -1,4150 +0,0 @@
1
- // vim: ts=4 sts=4 sw=4 expandtab
2
- // -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
3
- // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
4
- // -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
5
- // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
6
- // -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
7
- // -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
8
- // -- kossnocorp Sasha Koss XXX TODO License or CLA
9
- // -- bryanforbes Bryan Forbes XXX TODO License or CLA
10
- // -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
11
- // -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
12
- // -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
13
- // -- bbqsrc Brendan Molloy XXX TODO License or CLA
14
- // -- iwyg XXX TODO License or CLA
15
- // -- DomenicDenicola Domenic Denicola XXX TODO License or CLA
16
- // -- xavierm02 Montillet Xavier XXX TODO License or CLA
17
- // -- Raynos Raynos XXX TODO License or CLA
18
- // -- samsonjs Sami Samhuri XXX TODO License or CLA
19
- // -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
20
- // -- lexer Alexey Zakharov XXX TODO License or CLA
21
-
22
- /*!
23
- Copyright (c) 2009, 280 North Inc. http://280north.com/
24
- MIT License. http://github.com/280north/narwhal/blob/master/README.md
25
- */
26
-
27
- (function (undefined) {
28
-
29
- /**
30
- * Brings an environment as close to ECMAScript 5 compliance
31
- * as is possible with the facilities of erstwhile engines.
32
- *
33
- * ES5 Draft
34
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-050.pdf
35
- *
36
- * NOTE: this is a draft, and as such, the URL is subject to change. If the
37
- * link is broken, check in the parent directory for the latest TC39 PDF.
38
- * http://www.ecma-international.org/publications/files/drafts/
39
- *
40
- * Previous ES5 Draft
41
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
42
- * This is a broken link to the previous draft of ES5 on which most of the
43
- * numbered specification references and quotes herein were taken. Updating
44
- * these references and quotes to reflect the new document would be a welcome
45
- * volunteer project.
46
- *
47
- * @module
48
- */
49
-
50
- /*whatsupdoc*/
51
-
52
- // Shortcut to an often accessed properties, in order to avoid multiple
53
- // dereference that costs universally.
54
- // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
55
- // us it in defining shortcuts.
56
- var call = Function.prototype.call;
57
- var prototypeOfArray = Array.prototype;
58
- var prototypeOfObject = Object.prototype;
59
- var slice = prototypeOfArray.slice;
60
- var owns;
61
- var toString;
62
-
63
- // ES-5 15.3.4.5
64
- // http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
65
-
66
- if (!Function.prototype.bind) {
67
- Function.prototype.bind = function (that) { // .length is 1
68
- // 1. Let Target be the this value.
69
- var target = this;
70
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
71
- if (typeof target != "function")
72
- throw new TypeError(); // TODO message
73
- // 3. Let A be a new (possibly empty) internal list of all of the
74
- // argument values provided after thisArg (arg1, arg2 etc), in order.
75
- // XXX slicedArgs will stand in for "A" if used
76
- var args = slice.call(arguments, 1); // for normal call
77
- // 4. Let F be a new native ECMAScript object.
78
- // 9. Set the [[Prototype]] internal property of F to the standard
79
- // built-in Function prototype object as specified in 15.3.3.1.
80
- // 10. Set the [[Call]] internal property of F as described in
81
- // 15.3.4.5.1.
82
- // 11. Set the [[Construct]] internal property of F as described in
83
- // 15.3.4.5.2.
84
- // 12. Set the [[HasInstance]] internal property of F as described in
85
- // 15.3.4.5.3.
86
- // 13. The [[Scope]] internal property of F is unused and need not
87
- // exist.
88
- var bound = function () {
89
-
90
- if (this instanceof bound) {
91
- // 15.3.4.5.2 [[Construct]]
92
- // When the [[Construct]] internal method of a function object,
93
- // F that was created using the bind function is called with a
94
- // list of arguments ExtraArgs the following steps are taken:
95
- // 1. Let target be the value of F's [[TargetFunction]]
96
- // internal property.
97
- // 2. If target has no [[Construct]] internal method, a
98
- // TypeError exception is thrown.
99
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
100
- // property.
101
- // 4. Let args be a new list containing the same values as the
102
- // list boundArgs in the same order followed by the same
103
- // values as the list ExtraArgs in the same order.
104
-
105
- var F = function(){};
106
- F.prototype = target.prototype;
107
- var self = new F;
108
-
109
- var result = target.apply(
110
- self,
111
- args.concat(slice.call(arguments))
112
- );
113
- if (result !== null && Object(result) === result)
114
- return result;
115
- return self;
116
-
117
- } else {
118
- // 15.3.4.5.1 [[Call]]
119
- // When the [[Call]] internal method of a function object, F,
120
- // which was created using the bind function is called with a
121
- // this value and a list of arguments ExtraArgs the following
122
- // steps are taken:
123
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
124
- // property.
125
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
126
- // property.
127
- // 3. Let target be the value of F's [[TargetFunction]] internal
128
- // property.
129
- // 4. Let args be a new list containing the same values as the list
130
- // boundArgs in the same order followed by the same values as
131
- // the list ExtraArgs in the same order. 5. Return the
132
- // result of calling the [[Call]] internal method of target
133
- // providing boundThis as the this value and providing args
134
- // as the arguments.
135
-
136
- // equiv: target.call(this, ...boundArgs, ...args)
137
- return target.apply(
138
- that,
139
- args.concat(slice.call(arguments))
140
- );
141
-
142
- }
143
-
144
- };
145
- // XXX bound.length is never writable, so don't even try
146
- //
147
- // 16. The length own property of F is given attributes as specified in
148
- // 15.3.5.1.
149
- // TODO
150
- // 17. Set the [[Extensible]] internal property of F to true.
151
- // TODO
152
- // 18. Call the [[DefineOwnProperty]] internal method of F with
153
- // arguments "caller", PropertyDescriptor {[[Value]]: null,
154
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
155
- // false}, and false.
156
- // TODO
157
- // 19. Call the [[DefineOwnProperty]] internal method of F with
158
- // arguments "arguments", PropertyDescriptor {[[Value]]: null,
159
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
160
- // false}, and false.
161
- // TODO
162
- // NOTE Function objects created using Function.prototype.bind do not
163
- // have a prototype property.
164
- // XXX can't delete it in pure-js.
165
- return bound;
166
- };
167
- }
168
-
169
- toString = call.bind(prototypeOfObject.toString);
170
- owns = call.bind(prototypeOfObject.hasOwnProperty);
171
-
172
-
173
- //
174
- // Array
175
- // =====
176
- //
177
-
178
- // ES5 15.4.3.2
179
- if (!Array.isArray) {
180
- Array.isArray = function (obj) {
181
- return toString(obj) == "[object Array]";
182
- };
183
- }
184
-
185
- // The IsCallable() check in the Array functions
186
- // has been replaced with a strict check on the
187
- // internal class of the object to trap cases where
188
- // the provided function was actually a regular
189
- // expression literal, which in V8 and
190
- // JavaScriptCore is a typeof "function". Only in
191
- // V8 are regular expression literals permitted as
192
- // reduce parameters, so it is desirable in the
193
- // general case for the shim to match the more
194
- // strict and common behavior of rejecting regular
195
- // expressions.
196
-
197
- // ES5 15.4.4.18
198
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
199
- if (!Array.prototype.forEach) {
200
- Array.prototype.forEach = function (fun /*, thisp*/) {
201
- var self = toObject(this),
202
- thisp = arguments[1],
203
- i = 0,
204
- length = self.length >>> 0;
205
-
206
- // If no callback function or if callback is not a callable function
207
- if (toString(fun) != "[object Function]") {
208
- throw new TypeError(); // TODO message
209
- }
210
-
211
- while (i < length) {
212
- if (i in self) {
213
- // Invoke the callback function with call, passing arguments:
214
- // context, property value, property key, thisArg object context
215
- fun.call(thisp, self[i], i, self);
216
- }
217
- i++;
218
- }
219
- };
220
- }
221
-
222
- // ES5 15.4.4.19
223
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
224
- if (!Array.prototype.map) {
225
- Array.prototype.map = function (fun /*, thisp*/) {
226
- var self = toObject(this),
227
- length = self.length >>> 0,
228
- result = Array(length),
229
- thisp = arguments[1];
230
-
231
- // If no callback function or if callback is not a callable function
232
- if (toString(fun) != "[object Function]") {
233
- throw new TypeError(); // TODO message
234
- }
235
-
236
- for (var i = 0; i < length; i++) {
237
- if (i in self)
238
- result[i] = fun.call(thisp, self[i], i, self);
239
- }
240
- return result;
241
- };
242
- }
243
-
244
- // ES5 15.4.4.20
245
- if (!Array.prototype.filter) {
246
- Array.prototype.filter = function (fun /*, thisp */) {
247
- var self = toObject(this),
248
- length = self.length >>> 0,
249
- result = [],
250
- thisp = arguments[1];
251
-
252
- // If no callback function or if callback is not a callable function
253
- if (toString(fun) != "[object Function]") {
254
- throw new TypeError(); // TODO message
255
- }
256
-
257
- for (var i = 0; i < length; i++) {
258
- if (i in self && fun.call(thisp, self[i], i, self))
259
- result.push(self[i]);
260
- }
261
- return result;
262
- };
263
- }
264
-
265
- // ES5 15.4.4.16
266
- if (!Array.prototype.every) {
267
- Array.prototype.every = function (fun /*, thisp */) {
268
- var self = toObject(this),
269
- length = self.length >>> 0,
270
- thisp = arguments[1];
271
-
272
- // If no callback function or if callback is not a callable function
273
- if (toString(fun) != "[object Function]") {
274
- throw new TypeError(); // TODO message
275
- }
276
-
277
- for (var i = 0; i < length; i++) {
278
- if (i in self && !fun.call(thisp, self[i], i, self))
279
- return false;
280
- }
281
- return true;
282
- };
283
- }
284
-
285
- // ES5 15.4.4.17
286
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
287
- if (!Array.prototype.some) {
288
- Array.prototype.some = function (fun /*, thisp */) {
289
- var self = toObject(this),
290
- length = self.length >>> 0,
291
- thisp = arguments[1];
292
-
293
- // If no callback function or if callback is not a callable function
294
- if (toString(fun) != "[object Function]") {
295
- throw new TypeError(); // TODO message
296
- }
297
-
298
- for (var i = 0; i < length; i++) {
299
- if (i in self && fun.call(thisp, self[i], i, self))
300
- return true;
301
- }
302
- return false;
303
- };
304
- }
305
-
306
- // ES5 15.4.4.21
307
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
308
- if (!Array.prototype.reduce) {
309
- Array.prototype.reduce = function (fun /*, initial*/) {
310
- var self = toObject(this),
311
- length = self.length >>> 0;
312
-
313
- // If no callback function or if callback is not a callable function
314
- if (toString(fun) != "[object Function]") {
315
- throw new TypeError(); // TODO message
316
- }
317
-
318
- // no value to return if no initial value and an empty array
319
- if (!length && arguments.length == 1)
320
- throw new TypeError(); // TODO message
321
-
322
- var i = 0;
323
- var result;
324
- if (arguments.length >= 2) {
325
- result = arguments[1];
326
- } else {
327
- do {
328
- if (i in self) {
329
- result = self[i++];
330
- break;
331
- }
332
-
333
- // if array contains no values, no initial value to return
334
- if (++i >= length)
335
- throw new TypeError(); // TODO message
336
- } while (true);
337
- }
338
-
339
- for (; i < length; i++) {
340
- if (i in self)
341
- result = fun.call(void 0, result, self[i], i, self);
342
- }
343
-
344
- return result;
345
- };
346
- }
347
-
348
- // ES5 15.4.4.22
349
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
350
- if (!Array.prototype.reduceRight) {
351
- Array.prototype.reduceRight = function (fun /*, initial*/) {
352
- var self = toObject(this),
353
- length = self.length >>> 0;
354
-
355
- // If no callback function or if callback is not a callable function
356
- if (toString(fun) != "[object Function]") {
357
- throw new TypeError(); // TODO message
358
- }
359
-
360
- // no value to return if no initial value, empty array
361
- if (!length && arguments.length == 1)
362
- throw new TypeError(); // TODO message
363
-
364
- var result, i = length - 1;
365
- if (arguments.length >= 2) {
366
- result = arguments[1];
367
- } else {
368
- do {
369
- if (i in self) {
370
- result = self[i--];
371
- break;
372
- }
373
-
374
- // if array contains no values, no initial value to return
375
- if (--i < 0)
376
- throw new TypeError(); // TODO message
377
- } while (true);
378
- }
379
-
380
- do {
381
- if (i in this)
382
- result = fun.call(void 0, result, self[i], i, self);
383
- } while (i--);
384
-
385
- return result;
386
- };
387
- }
388
-
389
- // ES5 15.4.4.14
390
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
391
- if (!Array.prototype.indexOf) {
392
- Array.prototype.indexOf = function (sought /*, fromIndex */ ) {
393
- var self = toObject(this),
394
- length = self.length >>> 0;
395
-
396
- if (!length)
397
- return -1;
398
-
399
- var i = 0;
400
- if (arguments.length > 1)
401
- i = toInteger(arguments[1]);
402
-
403
- // handle negative indices
404
- i = i >= 0 ? i : length - Math.abs(i);
405
- for (; i < length; i++) {
406
- if (i in self && self[i] === sought) {
407
- return i;
408
- }
409
- }
410
- return -1;
411
- };
412
- }
413
-
414
- // ES5 15.4.4.15
415
- if (!Array.prototype.lastIndexOf) {
416
- Array.prototype.lastIndexOf = function (sought /*, fromIndex */) {
417
- var self = toObject(this),
418
- length = self.length >>> 0;
419
-
420
- if (!length)
421
- return -1;
422
- var i = length - 1;
423
- if (arguments.length > 1)
424
- i = toInteger(arguments[1]);
425
- // handle negative indices
426
- i = i >= 0 ? i : length - Math.abs(i);
427
- for (; i >= 0; i--) {
428
- if (i in self && sought === self[i])
429
- return i;
430
- }
431
- return -1;
432
- };
433
- }
434
-
435
- //
436
- // Array
437
- // =====
438
- //
439
-
440
- // ES5 15.4.4.12
441
- // http://es5.github.com/#x15.4.4.12
442
- // Default value for second param
443
- // [bugfix, ielt9, old browsers]
444
- // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
445
- if([1,2].splice(0).length != 2) {
446
- var _origArraySplice = Array.prototype.splice;
447
-
448
- Array.prototype.splice = function(start, deleteCount) {
449
- if(!arguments.length)return [];
450
-
451
- return _origArraySplice.apply(this, [
452
- start === void 0 ? 0 : start,
453
- deleteCount === void 0 ? (this.length - start) : deleteCount
454
- ].concat(slice.call(arguments, 2)))
455
- };
456
- }
457
-
458
- //
459
- // Object
460
- // ======
461
- //
462
-
463
-
464
- // ES5 15.2.3.14
465
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
466
- if (!Object.keys) {
467
-
468
- var hasDontEnumBug = true,
469
- dontEnums = [
470
- "toString",
471
- "toLocaleString",
472
- "valueOf",
473
- "hasOwnProperty",
474
- "isPrototypeOf",
475
- "propertyIsEnumerable",
476
- "constructor"
477
- ],
478
- dontEnumsLength = dontEnums.length;
479
-
480
- for (var key in {"toString": null})
481
- hasDontEnumBug = false;
482
-
483
- Object.keys = function keys(object) {
484
-
485
- if ((typeof object != "object" && typeof object != "function") || object === null)
486
- throw new TypeError("Object.keys called on a non-object");
487
-
488
- var keys = [];
489
- for (var name in object) {
490
- if (owns(object, name)) {
491
- keys.push(name);
492
- }
493
- }
494
-
495
- if (hasDontEnumBug) {
496
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
497
- var dontEnum = dontEnums[i];
498
- if (owns(object, dontEnum)) {
499
- keys.push(dontEnum);
500
- }
501
- }
502
- }
503
-
504
- return keys;
505
- };
506
-
507
- }
508
-
509
- //
510
- // Date
511
- // ====
512
- //
513
-
514
- // ES5 15.9.5.43
515
- // Format a Date object as a string according to a simplified subset of the ISO 8601
516
- // standard as defined in 15.9.1.15.
517
- if (!Date.prototype.toISOString) {
518
- Date.prototype.toISOString = function toISOString() {
519
- var result, length, value;
520
- if (!isFinite(this))
521
- throw new RangeError;
522
-
523
- // the date time string format is specified in 15.9.1.15.
524
- result = [this.getUTCFullYear(), this.getUTCMonth() + 1, this.getUTCDate(),
525
- this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
526
-
527
- length = result.length;
528
- while (length--) {
529
- value = result[length];
530
- // pad months, days, hours, minutes, and seconds to have two digits.
531
- if (value < 10)
532
- result[length] = "0" + value;
533
- }
534
- // pad milliseconds to have three digits.
535
- return result.slice(0, 3).join("-") + "T" + result.slice(3).join(":") + "." +
536
- ("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
537
- }
538
- }
539
-
540
- // ES5 15.9.4.4
541
- if (!Date.now) {
542
- Date.now = function now() {
543
- return new Date().getTime();
544
- };
545
- }
546
-
547
- // ES5 15.9.5.44
548
- if (!Date.prototype.toJSON) {
549
- Date.prototype.toJSON = function toJSON(key) {
550
- // This function provides a String representation of a Date object for
551
- // use by JSON.stringify (15.12.3). When the toJSON method is called
552
- // with argument key, the following steps are taken:
553
-
554
- // 1. Let O be the result of calling ToObject, giving it the this
555
- // value as its argument.
556
- // 2. Let tv be ToPrimitive(O, hint Number).
557
- // 3. If tv is a Number and is not finite, return null.
558
- // XXX
559
- // 4. Let toISO be the result of calling the [[Get]] internal method of
560
- // O with argument "toISOString".
561
- // 5. If IsCallable(toISO) is false, throw a TypeError exception.
562
- if (typeof this.toISOString != "function")
563
- throw new TypeError(); // TODO message
564
- // 6. Return the result of calling the [[Call]] internal method of
565
- // toISO with O as the this value and an empty argument list.
566
- return this.toISOString();
567
-
568
- // NOTE 1 The argument is ignored.
569
-
570
- // NOTE 2 The toJSON function is intentionally generic; it does not
571
- // require that its this value be a Date object. Therefore, it can be
572
- // transferred to other kinds of objects for use as a method. However,
573
- // it does require that any such object have a toISOString method. An
574
- // object is free to use the argument key to filter its
575
- // stringification.
576
- };
577
- }
578
-
579
-
580
- //
581
- // String
582
- // ======
583
- //
584
-
585
- // ES5 15.5.4.20
586
- var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
587
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
588
- "\u2029\uFEFF";
589
- if (!String.prototype.trim || ws.trim()) {
590
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
591
- // http://perfectionkills.com/whitespace-deviations/
592
- ws = "[" + ws + "]";
593
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
594
- trimEndRegexp = new RegExp(ws + ws + "*$");
595
- String.prototype.trim = function trim() {
596
- return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
597
- };
598
- }
599
-
600
- // ES5 15.5.4.14
601
- // http://es5.github.com/#x15.5.4.14
602
- // [bugfix, chrome]
603
- // If separator is undefined, then the result array contains just one String, which is the this value (converted to a String). If limit is not undefined, then the output array is truncated so that it contains no more than limit elements.
604
- // "0".split(undefined, 0) -> []
605
- if("0".split(void 0, 0).length) {
606
- var oldSplit = String.prototype.split;
607
- String.prototype.split = function(separator, limit) {
608
- if(separator === void 0 && limit === 0)return [];
609
- return oldSplit.apply(this, arguments);
610
- }
611
- }
612
-
613
- // ECMA-262, 3rd B.2.3
614
- // Note an ECMAScript standart, although ECMAScript 3rd Edition has a non-normative section suggesting uniform semantics
615
- // and it should be normalized across all browsers
616
- // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
617
- if("".substr && "0b".substr(-1) !== "b") {
618
- var oldSubstr = String.prototype.substr;
619
- /**
620
- * Get the substring of a string
621
- * @param {integer} start where to start the substring
622
- * @param {integer} length how many characters to return
623
- * @return {string}
624
- */
625
- String.prototype.substr = function(start, length) {
626
- return oldSubstr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);
627
- }
628
- }
629
-
630
- //
631
- // Util
632
- // ======
633
- //
634
-
635
- // http://jsperf.com/to-integer
636
- var toInteger = function (n) {
637
- n = +n;
638
- if (n !== n) // isNaN
639
- n = -1;
640
- else if (n !== 0 && n !== (1/0) && n !== -(1/0))
641
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
642
- return n;
643
- };
644
-
645
- var prepareString = "a"[0] != "a",
646
- // ES5 9.9
647
- toObject = function (o) {
648
- if (o == null) { // this matches both null and undefined
649
- throw new TypeError(); // TODO message
650
- }
651
- // If the implementation doesn't support by-index access of
652
- // string characters (ex. IE < 7), split the string
653
- if (prepareString && typeof o == "string" && o) {
654
- return o.split("");
655
- }
656
- return Object(o);
657
- };
658
-
659
- })();
660
-
661
-
662
-
663
- (function($, shims){
664
- var defineProperty = 'defineProperty';
665
- var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
666
- //safari5 has defineProperty-interface, but it can't be used on dom-object
667
- if (advancedObjectProperties && Object[defineProperty] && Object.prototype.__defineGetter__) {
668
- (function(){
669
- try {
670
- var foo = document.createElement('foo');
671
- Object[defineProperty](foo, 'bar', {
672
- get: function(){
673
- return true;
674
- }
675
- });
676
- advancedObjectProperties = !!foo.bar;
677
- }
678
- catch (e) {
679
- advancedObjectProperties = false;
680
- }
681
- foo = null;
682
- })();
683
- }
684
-
685
- Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)));
686
- Modernizr.advancedObjectProperties = advancedObjectProperties;
687
-
688
- if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
689
- var call = Function.prototype.call;
690
- var prototypeOfObject = Object.prototype;
691
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
692
-
693
- shims.objectCreate = function(proto, props, opts, no__proto__){
694
- var o;
695
- var f = function(){};
696
-
697
- f.prototype = proto;
698
- o = new f();
699
-
700
- if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
701
- o.__proto__ = proto;
702
- }
703
-
704
- if(props){
705
- shims.defineProperties(o, props);
706
- }
707
-
708
- if(opts){
709
- o.options = jQuery.extend(true, {}, o.options || {}, opts);
710
- opts = o.options;
711
- }
712
-
713
- if(o._create && jQuery.isFunction(o._create)){
714
- o._create(opts);
715
- }
716
- return o;
717
- };
718
-
719
- shims.defineProperties = function(object, props){
720
- for (var name in props) {
721
- if (owns(props, name)) {
722
- shims.defineProperty(object, name, props[name]);
723
- }
724
- }
725
- return object;
726
- };
727
-
728
- var descProps = ['configurable', 'enumerable', 'writable'];
729
- shims.defineProperty = function(proto, property, descriptor){
730
- if(typeof descriptor != "object" || descriptor === null){return proto;}
731
-
732
- if(owns(descriptor, "value")){
733
- proto[property] = descriptor.value;
734
- return proto;
735
- }
736
-
737
- if(proto.__defineGetter__){
738
- if (typeof descriptor.get == "function") {
739
- proto.__defineGetter__(property, descriptor.get);
740
- }
741
- if (typeof descriptor.set == "function"){
742
- proto.__defineSetter__(property, descriptor.set);
743
- }
744
- }
745
- return proto;
746
- };
747
-
748
- shims.getPrototypeOf = function (object) {
749
- return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
750
- };
751
-
752
- //based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
753
- shims.getOwnPropertyDescriptor = function(obj, prop){
754
- if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
755
- throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
756
- }
757
- var descriptor;
758
- if(Object.defineProperty && Object.getOwnPropertyDescriptor){
759
- try{
760
- descriptor = Object.getOwnPropertyDescriptor(obj, prop);
761
- return descriptor;
762
- } catch(e){}
763
- }
764
- descriptor = {
765
- configurable: true,
766
- enumerable: true,
767
- writable: true,
768
- value: undefined
769
- };
770
- var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
771
- setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
772
- ;
773
-
774
- if (!getter && !setter) { // not an accessor so return prop
775
- if(!owns(obj, prop)){
776
- return;
777
- }
778
- descriptor.value = obj[prop];
779
- return descriptor;
780
- }
781
-
782
- // there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
783
- delete descriptor.writable;
784
- delete descriptor.value;
785
- descriptor.get = descriptor.set = undefined;
786
-
787
- if(getter){
788
- descriptor.get = getter;
789
- }
790
-
791
- if(setter){
792
- descriptor.set = setter;
793
- }
794
-
795
- return descriptor;
796
- };
797
-
798
- }
799
- })(jQuery, jQuery.webshims);
800
-
801
-
802
-
803
- //DOM-Extension helper
804
- jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
805
- "use strict";
806
- //shortcus
807
- var modules = webshims.modules;
808
- var listReg = /\s*,\s*/;
809
-
810
- //proxying attribute
811
- var olds = {};
812
- var havePolyfill = {};
813
- var extendedProps = {};
814
- var extendQ = {};
815
- var modifyProps = {};
816
-
817
- var oldVal = $.fn.val;
818
- var singleVal = function(elem, name, val, pass, _argless){
819
- return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
820
- };
821
-
822
- $.fn.onTrigger = function(evt, fn){
823
- return this.on(evt, fn).each(fn);
824
- };
825
-
826
- $.fn.val = function(val){
827
- var elem = this[0];
828
- if(arguments.length && val == null){
829
- val = '';
830
- }
831
- if(!arguments.length){
832
- if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
833
- return $.prop(elem, 'value', val, 'val', true);
834
- }
835
- if($.isArray(val)){
836
- return oldVal.apply(this, arguments);
837
- }
838
- var isFunction = $.isFunction(val);
839
- return this.each(function(i){
840
- elem = this;
841
- if(elem.nodeType === 1){
842
- if(isFunction){
843
- var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
844
- if(genVal == null){
845
- genVal = '';
846
- }
847
- $.prop(elem, 'value', genVal, 'val') ;
848
- } else {
849
- $.prop(elem, 'value', val, 'val');
850
- }
851
- }
852
- });
853
- };
854
-
855
- var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
856
- var elementData = function(elem, key, val){
857
- elem = elem.jquery ? elem[0] : elem;
858
- if(!elem){return val || {};}
859
- var data = $.data(elem, dataID);
860
- if(val !== undefined){
861
- if(!data){
862
- data = $.data(elem, dataID, {});
863
- }
864
- if(key){
865
- data[key] = val;
866
- }
867
- }
868
-
869
- return key ? data && data[key] : data;
870
- };
871
-
872
-
873
- [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
874
- $.fn[data.name] = function(){
875
- return this.map(function(){
876
- var shadowData = elementData(this, 'shadowData');
877
- return shadowData && shadowData[data.prop] || this;
878
- });
879
- };
880
- });
881
-
882
-
883
- ['removeAttr', 'prop', 'attr'].forEach(function(type){
884
- olds[type] = $[type];
885
- $[type] = function(elem, name, value, pass, _argless){
886
- var isVal = (pass == 'val');
887
- var oldMethod = !isVal ? olds[type] : singleVal;
888
- if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
889
- return oldMethod(elem, name, value, pass, _argless);
890
- }
891
-
892
- var nodeName = (elem.nodeName || '').toLowerCase();
893
- var desc = extendedProps[nodeName];
894
- var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
895
- var propMethod;
896
- var oldValMethod;
897
- var ret;
898
-
899
-
900
- if(!desc){
901
- desc = extendedProps['*'];
902
- }
903
- if(desc){
904
- desc = desc[name];
905
- }
906
-
907
- if(desc){
908
- propMethod = desc[curType];
909
- }
910
-
911
- if(propMethod){
912
- if(name == 'value'){
913
- oldValMethod = propMethod.isVal;
914
- propMethod.isVal = isVal;
915
- }
916
- if(curType === 'removeAttr'){
917
- return propMethod.value.call(elem);
918
- } else if(value === undefined){
919
- return (propMethod.get) ?
920
- propMethod.get.call(elem) :
921
- propMethod.value
922
- ;
923
- } else if(propMethod.set) {
924
- if(type == 'attr' && value === true){
925
- value = name;
926
- }
927
-
928
- ret = propMethod.set.call(elem, value);
929
- }
930
- if(name == 'value'){
931
- propMethod.isVal = oldValMethod;
932
- }
933
- } else {
934
- ret = oldMethod(elem, name, value, pass, _argless);
935
- }
936
- if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
937
-
938
- var boolValue;
939
- if(curType == 'removeAttr'){
940
- boolValue = false;
941
- } else if(curType == 'prop'){
942
- boolValue = !!(value);
943
- } else {
944
- boolValue = true;
945
- }
946
-
947
- modifyProps[nodeName][name].forEach(function(fn){
948
- if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
949
- fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
950
- }
951
- });
952
- }
953
- return ret;
954
- };
955
-
956
- extendQ[type] = function(nodeName, prop, desc){
957
-
958
- if(!extendedProps[nodeName]){
959
- extendedProps[nodeName] = {};
960
- }
961
- if(!extendedProps[nodeName][prop]){
962
- extendedProps[nodeName][prop] = {};
963
- }
964
- var oldDesc = extendedProps[nodeName][prop][type];
965
- var getSup = function(propType, descriptor, oDesc){
966
- if(descriptor && descriptor[propType]){
967
- return descriptor[propType];
968
- }
969
- if(oDesc && oDesc[propType]){
970
- return oDesc[propType];
971
- }
972
- if(type == 'prop' && prop == 'value'){
973
- return function(value){
974
- var elem = this;
975
- return (desc.isVal) ?
976
- singleVal(elem, prop, value, false, (arguments.length === 0)) :
977
- olds[type](elem, prop, value)
978
- ;
979
- };
980
- }
981
- if(type == 'prop' && propType == 'value' && desc.value.apply){
982
- return function(value){
983
- var sup = olds[type](this, prop);
984
- if(sup && sup.apply){
985
- sup = sup.apply(this, arguments);
986
- }
987
- return sup;
988
- };
989
- }
990
- return function(value){
991
- return olds[type](this, prop, value);
992
- };
993
- };
994
- extendedProps[nodeName][prop][type] = desc;
995
- if(desc.value === undefined){
996
- if(!desc.set){
997
- desc.set = desc.writeable ?
998
- getSup('set', desc, oldDesc) :
999
- (webshims.cfg.useStrict && prop == 'prop') ?
1000
- function(){throw(prop +' is readonly on '+ nodeName);} :
1001
- $.noop
1002
- ;
1003
- }
1004
- if(!desc.get){
1005
- desc.get = getSup('get', desc, oldDesc);
1006
- }
1007
-
1008
- }
1009
-
1010
- ['value', 'get', 'set'].forEach(function(descProp){
1011
- if(desc[descProp]){
1012
- desc['_sup'+descProp] = getSup(descProp, oldDesc);
1013
- }
1014
- });
1015
- };
1016
-
1017
- });
1018
-
1019
- //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
1020
- var isExtendNativeSave = Modernizr.ES5;
1021
- var extendNativeValue = (function(){
1022
- var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
1023
- var has = Object.prototype.hasOwnProperty;
1024
- return function(nodeName, prop, desc){
1025
- var elem;
1026
- var elemProto;
1027
- if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
1028
- var sup = elem[prop];
1029
- desc._supvalue = function(){
1030
- if(sup && sup.apply){
1031
- return sup.apply(this, arguments);
1032
- }
1033
- return sup;
1034
- };
1035
- elemProto[prop] = desc.value;
1036
- } else {
1037
- desc._supvalue = function(){
1038
- var data = elementData(this, 'propValue');
1039
- if(data && data[prop] && data[prop].apply){
1040
- return data[prop].apply(this, arguments);
1041
- }
1042
- return data && data[prop];
1043
- };
1044
- initProp.extendValue(nodeName, prop, desc.value);
1045
- }
1046
- desc.value._supvalue = desc._supvalue;
1047
- };
1048
- })();
1049
-
1050
- var initProp = (function(){
1051
-
1052
- var initProps = {};
1053
-
1054
- webshims.addReady(function(context, contextElem){
1055
- var nodeNameCache = {};
1056
- var getElementsByName = function(name){
1057
- if(!nodeNameCache[name]){
1058
- nodeNameCache[name] = $(context.getElementsByTagName(name));
1059
- if(contextElem[0] && $.nodeName(contextElem[0], name)){
1060
- nodeNameCache[name] = nodeNameCache[name].add(contextElem);
1061
- }
1062
- }
1063
- };
1064
-
1065
-
1066
- $.each(initProps, function(name, fns){
1067
- getElementsByName(name);
1068
- if(!fns || !fns.forEach){
1069
- webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
1070
- return;
1071
- }
1072
- fns.forEach(function(fn){
1073
- nodeNameCache[name].each(fn);
1074
- });
1075
- });
1076
- nodeNameCache = null;
1077
- });
1078
-
1079
- var tempCache;
1080
- var emptyQ = $([]);
1081
- var createNodeNameInit = function(nodeName, fn){
1082
- if(!initProps[nodeName]){
1083
- initProps[nodeName] = [fn];
1084
- } else {
1085
- initProps[nodeName].push(fn);
1086
- }
1087
- if($.isDOMReady){
1088
- (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
1089
- }
1090
- };
1091
-
1092
- var elementExtends = {};
1093
- return {
1094
- createTmpCache: function(nodeName){
1095
- if($.isDOMReady){
1096
- tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
1097
- }
1098
- return tempCache || emptyQ;
1099
- },
1100
- flushTmpCache: function(){
1101
- tempCache = null;
1102
- },
1103
- content: function(nodeName, prop){
1104
- createNodeNameInit(nodeName, function(){
1105
- var val = $.attr(this, prop);
1106
- if(val != null){
1107
- $.attr(this, prop, val);
1108
- }
1109
- });
1110
- },
1111
- createElement: function(nodeName, fn){
1112
- createNodeNameInit(nodeName, fn);
1113
- },
1114
- extendValue: function(nodeName, prop, value){
1115
- createNodeNameInit(nodeName, function(){
1116
- $(this).each(function(){
1117
- var data = elementData(this, 'propValue', {});
1118
- data[prop] = this[prop];
1119
- this[prop] = value;
1120
- });
1121
- });
1122
- }
1123
- };
1124
- })();
1125
-
1126
- var createPropDefault = function(descs, removeType){
1127
- if(descs.defaultValue === undefined){
1128
- descs.defaultValue = '';
1129
- }
1130
- if(!descs.removeAttr){
1131
- descs.removeAttr = {
1132
- value: function(){
1133
- descs[removeType || 'prop'].set.call(this, descs.defaultValue);
1134
- descs.removeAttr._supvalue.call(this);
1135
- }
1136
- };
1137
- }
1138
- if(!descs.attr){
1139
- descs.attr = {};
1140
- }
1141
- };
1142
-
1143
- $.extend(webshims, {
1144
-
1145
- getID: (function(){
1146
- var ID = new Date().getTime();
1147
- return function(elem){
1148
- elem = $(elem);
1149
- var id = elem.attr('id');
1150
- if(!id){
1151
- ID++;
1152
- id = 'ID-'+ ID;
1153
- elem.attr('id', id);
1154
- }
1155
- return id;
1156
- };
1157
- })(),
1158
- extendUNDEFProp: function(obj, props){
1159
- $.each(props, function(name, prop){
1160
- if( !(name in obj) ){
1161
- obj[name] = prop;
1162
- }
1163
- });
1164
- },
1165
- //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
1166
- createPropDefault: createPropDefault,
1167
- data: elementData,
1168
- moveToFirstEvent: function(elem, eventType, bindType){
1169
- var events = ($._data(elem, 'events') || {})[eventType];
1170
- var fn;
1171
-
1172
- if(events && events.length > 1){
1173
- fn = events.pop();
1174
- if(!bindType){
1175
- bindType = 'bind';
1176
- }
1177
- if(bindType == 'bind' && events.delegateCount){
1178
- events.splice( events.delegateCount, 0, fn);
1179
- } else {
1180
- events.unshift( fn );
1181
- }
1182
-
1183
-
1184
- }
1185
- elem = null;
1186
- },
1187
- addShadowDom: (function(){
1188
- var resizeTimer;
1189
- var lastHeight;
1190
- var lastWidth;
1191
-
1192
- var docObserve = {
1193
- init: false,
1194
- runs: 0,
1195
- test: function(){
1196
- var height = docObserve.getHeight();
1197
- var width = docObserve.getWidth();
1198
-
1199
- if(height != docObserve.height || width != docObserve.width){
1200
- docObserve.height = height;
1201
- docObserve.width = width;
1202
- docObserve.handler({type: 'docresize'});
1203
- docObserve.runs++;
1204
- if(docObserve.runs < 9){
1205
- setTimeout(docObserve.test, 90);
1206
- }
1207
- } else {
1208
- docObserve.runs = 0;
1209
- }
1210
- },
1211
- handler: function(e){
1212
- clearTimeout(resizeTimer);
1213
- resizeTimer = setTimeout(function(){
1214
- if(e.type == 'resize'){
1215
- var width = $(window).width();
1216
- var height = $(window).width();
1217
- if(height == lastHeight && width == lastWidth){
1218
- return;
1219
- }
1220
- lastHeight = height;
1221
- lastWidth = width;
1222
-
1223
- docObserve.height = docObserve.getHeight();
1224
- docObserve.width = docObserve.getWidth();
1225
-
1226
- }
1227
- $(document).triggerHandler('updateshadowdom');
1228
- }, (e.type == 'resize') ? 50 : 9);
1229
- },
1230
- _create: function(){
1231
- $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
1232
- var body = document.body;
1233
- var doc = document.documentElement;
1234
- docObserve[type] = function(){
1235
- return Math.max(
1236
- body[ "scroll" + name ], doc[ "scroll" + name ],
1237
- body[ "offset" + name ], doc[ "offset" + name ],
1238
- doc[ "client" + name ]
1239
- );
1240
- };
1241
- });
1242
- },
1243
- start: function(){
1244
- if(!this.init && document.body){
1245
- this.init = true;
1246
- this._create();
1247
- this.height = docObserve.getHeight();
1248
- this.width = docObserve.getWidth();
1249
- setInterval(this.test, 600);
1250
- $(this.test);
1251
- webshims.ready('WINDOWLOAD', this.test);
1252
- $(window).bind('resize', this.handler);
1253
- (function(){
1254
- var oldAnimate = $.fn.animate;
1255
- var animationTimer;
1256
-
1257
- $.fn.animate = function(){
1258
- clearTimeout(animationTimer);
1259
- animationTimer = setTimeout(function(){
1260
- docObserve.test();
1261
- }, 99);
1262
-
1263
- return oldAnimate.apply(this, arguments);
1264
- };
1265
- })();
1266
- }
1267
- }
1268
- };
1269
-
1270
-
1271
- webshims.docObserve = function(){
1272
- webshims.ready('DOM', function(){
1273
- docObserve.start();
1274
- });
1275
- };
1276
- return function(nativeElem, shadowElem, opts){
1277
- opts = opts || {};
1278
- if(nativeElem.jquery){
1279
- nativeElem = nativeElem[0];
1280
- }
1281
- if(shadowElem.jquery){
1282
- shadowElem = shadowElem[0];
1283
- }
1284
- var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
1285
- var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
1286
- var shadowFocusElementData = {};
1287
- if(!opts.shadowFocusElement){
1288
- opts.shadowFocusElement = shadowElem;
1289
- } else if(opts.shadowFocusElement){
1290
- if(opts.shadowFocusElement.jquery){
1291
- opts.shadowFocusElement = opts.shadowFocusElement[0];
1292
- }
1293
- shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
1294
- }
1295
-
1296
- nativeData.hasShadow = shadowElem;
1297
- shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
1298
- shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
1299
- nativeElement: nativeElem,
1300
- shadowElement: shadowElem,
1301
- shadowFocusElement: opts.shadowFocusElement
1302
- };
1303
- if(opts.shadowChilds){
1304
- opts.shadowChilds.each(function(){
1305
- elementData(this, 'shadowData', shadowData.shadowData);
1306
- });
1307
- }
1308
-
1309
- if(opts.data){
1310
- shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
1311
- }
1312
- opts = null;
1313
- webshims.docObserve();
1314
- };
1315
- })(),
1316
- propTypes: {
1317
- standard: function(descs, name){
1318
- createPropDefault(descs);
1319
- if(descs.prop){return;}
1320
- descs.prop = {
1321
- set: function(val){
1322
- descs.attr.set.call(this, ''+val);
1323
- },
1324
- get: function(){
1325
- return descs.attr.get.call(this) || descs.defaultValue;
1326
- }
1327
- };
1328
-
1329
- },
1330
- "boolean": function(descs, name){
1331
-
1332
- createPropDefault(descs);
1333
- if(descs.prop){return;}
1334
- descs.prop = {
1335
- set: function(val){
1336
- if(val){
1337
- descs.attr.set.call(this, "");
1338
- } else {
1339
- descs.removeAttr.value.call(this);
1340
- }
1341
- },
1342
- get: function(){
1343
- return descs.attr.get.call(this) != null;
1344
- }
1345
- };
1346
- },
1347
- "src": (function(){
1348
- var anchor = document.createElement('a');
1349
- anchor.style.display = "none";
1350
- return function(descs, name){
1351
-
1352
- createPropDefault(descs);
1353
- if(descs.prop){return;}
1354
- descs.prop = {
1355
- set: function(val){
1356
- descs.attr.set.call(this, val);
1357
- },
1358
- get: function(){
1359
- var href = this.getAttribute(name);
1360
- var ret;
1361
- if(href == null){return '';}
1362
-
1363
- anchor.setAttribute('href', href+'' );
1364
-
1365
- if(!$.support.hrefNormalized){
1366
- try {
1367
- $(anchor).insertAfter(this);
1368
- ret = anchor.getAttribute('href', 4);
1369
- } catch(er){
1370
- ret = anchor.getAttribute('href', 4);
1371
- }
1372
- $(anchor).detach();
1373
- }
1374
- return ret || anchor.href;
1375
- }
1376
- };
1377
- };
1378
- })(),
1379
- enumarated: function(descs, name){
1380
-
1381
- createPropDefault(descs);
1382
- if(descs.prop){return;}
1383
- descs.prop = {
1384
- set: function(val){
1385
- descs.attr.set.call(this, val);
1386
- },
1387
- get: function(){
1388
- var val = (descs.attr.get.call(this) || '').toLowerCase();
1389
- if(!val || descs.limitedTo.indexOf(val) == -1){
1390
- val = descs.defaultValue;
1391
- }
1392
- return val;
1393
- }
1394
- };
1395
- }
1396
-
1397
- // ,unsignedLong: $.noop
1398
- // ,"doubble": $.noop
1399
- // ,"long": $.noop
1400
- // ,tokenlist: $.noop
1401
- // ,settableTokenlist: $.noop
1402
- },
1403
- reflectProperties: function(nodeNames, props){
1404
- if(typeof props == 'string'){
1405
- props = props.split(listReg);
1406
- }
1407
- props.forEach(function(prop){
1408
- webshims.defineNodeNamesProperty(nodeNames, prop, {
1409
- prop: {
1410
- set: function(val){
1411
- $.attr(this, prop, val);
1412
- },
1413
- get: function(){
1414
- return $.attr(this, prop) || '';
1415
- }
1416
- }
1417
- });
1418
- });
1419
- },
1420
- defineNodeNameProperty: function(nodeName, prop, descs){
1421
- havePolyfill[prop] = true;
1422
-
1423
- if(descs.reflect){
1424
- webshims.propTypes[descs.propType || 'standard'](descs, prop);
1425
- }
1426
-
1427
- ['prop', 'attr', 'removeAttr'].forEach(function(type){
1428
- var desc = descs[type];
1429
- if(desc){
1430
- if(type === 'prop'){
1431
- desc = $.extend({writeable: true}, desc);
1432
- } else {
1433
- desc = $.extend({}, desc, {writeable: true});
1434
- }
1435
-
1436
- extendQ[type](nodeName, prop, desc);
1437
- if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
1438
- extendNativeValue(nodeName, prop, desc);
1439
- }
1440
- descs[type] = desc;
1441
- }
1442
- });
1443
- if(descs.initAttr){
1444
- initProp.content(nodeName, prop);
1445
- }
1446
- return descs;
1447
- },
1448
-
1449
- defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
1450
- var olddesc;
1451
- for(var prop in descs){
1452
- if(!_noTmpCache && descs[prop].initAttr){
1453
- initProp.createTmpCache(name);
1454
- }
1455
- if(propType){
1456
- if(descs[prop][propType]){
1457
- //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
1458
- } else {
1459
- descs[prop][propType] = {};
1460
- ['value', 'set', 'get'].forEach(function(copyProp){
1461
- if(copyProp in descs[prop]){
1462
- descs[prop][propType][copyProp] = descs[prop][copyProp];
1463
- delete descs[prop][copyProp];
1464
- }
1465
- });
1466
- }
1467
- }
1468
- descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
1469
- }
1470
- if(!_noTmpCache){
1471
- initProp.flushTmpCache();
1472
- }
1473
- return descs;
1474
- },
1475
-
1476
- createElement: function(nodeName, create, descs){
1477
- var ret;
1478
- if($.isFunction(create)){
1479
- create = {
1480
- after: create
1481
- };
1482
- }
1483
- initProp.createTmpCache(nodeName);
1484
- if(create.before){
1485
- initProp.createElement(nodeName, create.before);
1486
- }
1487
- if(descs){
1488
- ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
1489
- }
1490
- if(create.after){
1491
- initProp.createElement(nodeName, create.after);
1492
- }
1493
- initProp.flushTmpCache();
1494
- return ret;
1495
- },
1496
- onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
1497
- if(typeof nodeNames == 'string'){
1498
- nodeNames = nodeNames.split(listReg);
1499
- }
1500
- if($.isFunction(desc)){
1501
- desc = {set: desc};
1502
- }
1503
-
1504
- nodeNames.forEach(function(name){
1505
- if(!modifyProps[name]){
1506
- modifyProps[name] = {};
1507
- }
1508
- if(typeof props == 'string'){
1509
- props = props.split(listReg);
1510
- }
1511
- if(desc.initAttr){
1512
- initProp.createTmpCache(name);
1513
- }
1514
- props.forEach(function(prop){
1515
- if(!modifyProps[name][prop]){
1516
- modifyProps[name][prop] = [];
1517
- havePolyfill[prop] = true;
1518
- }
1519
- if(desc.set){
1520
- if(only){
1521
- desc.set.only = only;
1522
- }
1523
- modifyProps[name][prop].push(desc.set);
1524
- }
1525
-
1526
- if(desc.initAttr){
1527
- initProp.content(name, prop);
1528
- }
1529
- });
1530
- initProp.flushTmpCache();
1531
-
1532
- });
1533
- },
1534
- defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
1535
- if(!descs){
1536
- descs = {};
1537
- }
1538
- if($.isFunction(descs)){
1539
- descs.set = descs;
1540
- }
1541
- webshims.defineNodeNamesProperty(elementNames, prop, {
1542
- attr: {
1543
- set: function(val){
1544
- this.setAttribute(prop, val);
1545
- if(descs.set){
1546
- descs.set.call(this, true);
1547
- }
1548
- },
1549
- get: function(){
1550
- var ret = this.getAttribute(prop);
1551
- return (ret == null) ? undefined : prop;
1552
- }
1553
- },
1554
- removeAttr: {
1555
- value: function(){
1556
- this.removeAttribute(prop);
1557
- if(descs.set){
1558
- descs.set.call(this, false);
1559
- }
1560
- }
1561
- },
1562
- reflect: true,
1563
- propType: 'boolean',
1564
- initAttr: descs.initAttr || false
1565
- });
1566
- },
1567
- contentAttr: function(elem, name, val){
1568
- if(!elem.nodeName){return;}
1569
- var attr;
1570
- if(val === undefined){
1571
- attr = (elem.attributes[name] || {});
1572
- val = attr.specified ? attr.value : null;
1573
- return (val == null) ? undefined : val;
1574
- }
1575
-
1576
- if(typeof val == 'boolean'){
1577
- if(!val){
1578
- elem.removeAttribute(name);
1579
- } else {
1580
- elem.setAttribute(name, name);
1581
- }
1582
- } else {
1583
- elem.setAttribute(name, val);
1584
- }
1585
- },
1586
-
1587
- // set current Lang:
1588
- // - webshims.activeLang(lang:string);
1589
- // get current lang
1590
- // - webshims.activeLang();
1591
- // get current lang
1592
- // webshims.activeLang({
1593
- // register: moduleName:string,
1594
- // callback: callback:function
1595
- // });
1596
- // get/set including removeLang
1597
- // - webshims.activeLang({
1598
- // module: moduleName:string,
1599
- // callback: callback:function,
1600
- // langObj: languageObj:array/object
1601
- // });
1602
- activeLang: (function(){
1603
- var callbacks = [];
1604
- var registeredCallbacks = {};
1605
- var currentLang;
1606
- var shortLang;
1607
- var notLocal = /:\/\/|^\.*\//;
1608
- var loadRemoteLang = function(data, lang, options){
1609
- var langSrc;
1610
- if(lang && options && $.inArray(lang, options.availabeLangs || []) !== -1){
1611
- data.loading = true;
1612
- langSrc = options.langSrc;
1613
- if(!notLocal.test(langSrc)){
1614
- langSrc = webshims.cfg.basePath+langSrc;
1615
- }
1616
- webshims.loader.loadScript(langSrc+lang+'.js', function(){
1617
- if(data.langObj[lang]){
1618
- data.loading = false;
1619
- callLang(data, true);
1620
- } else {
1621
- $(function(){
1622
- if(data.langObj[lang]){
1623
- callLang(data, true);
1624
- }
1625
- data.loading = false;
1626
- });
1627
- }
1628
- });
1629
- return true;
1630
- }
1631
- return false;
1632
- };
1633
- var callRegister = function(module){
1634
- if(registeredCallbacks[module]){
1635
- registeredCallbacks[module].forEach(function(data){
1636
- data.callback();
1637
- });
1638
- }
1639
- };
1640
- var callLang = function(data, _noLoop){
1641
- if(data.activeLang != currentLang && data.activeLang !== shortLang){
1642
- var options = modules[data.module].options;
1643
- if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
1644
- data.activeLang = currentLang;
1645
- data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
1646
- callRegister(data.module);
1647
- } else if( !_noLoop &&
1648
- !loadRemoteLang(data, currentLang, options) &&
1649
- !loadRemoteLang(data, shortLang, options) &&
1650
- data.langObj[''] && data.activeLang !== '' ) {
1651
- data.activeLang = '';
1652
- data.callback(data.langObj[''], currentLang);
1653
- callRegister(data.module);
1654
- }
1655
- }
1656
- };
1657
-
1658
-
1659
- var activeLang = function(lang){
1660
-
1661
- if(typeof lang == 'string' && lang !== currentLang){
1662
- currentLang = lang;
1663
- shortLang = currentLang.split('-')[0];
1664
- if(currentLang == shortLang){
1665
- shortLang = false;
1666
- }
1667
- $.each(callbacks, function(i, data){
1668
- callLang(data);
1669
- });
1670
- } else if(typeof lang == 'object'){
1671
-
1672
- if(lang.register){
1673
- if(!registeredCallbacks[lang.register]){
1674
- registeredCallbacks[lang.register] = [];
1675
- }
1676
- registeredCallbacks[lang.register].push(lang);
1677
- lang.callback();
1678
- } else {
1679
- if(!lang.activeLang){
1680
- lang.activeLang = '';
1681
- }
1682
- callbacks.push(lang);
1683
- callLang(lang);
1684
- }
1685
- }
1686
- return currentLang;
1687
- };
1688
-
1689
- return activeLang;
1690
- })()
1691
- });
1692
-
1693
- $.each({
1694
- defineNodeNamesProperty: 'defineNodeNameProperty',
1695
- defineNodeNamesProperties: 'defineNodeNameProperties',
1696
- createElements: 'createElement'
1697
- }, function(name, baseMethod){
1698
- webshims[name] = function(names, a, b, c){
1699
- if(typeof names == 'string'){
1700
- names = names.split(listReg);
1701
- }
1702
- var retDesc = {};
1703
- names.forEach(function(nodeName){
1704
- retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
1705
- });
1706
- return retDesc;
1707
- };
1708
- });
1709
-
1710
- webshims.isReady('webshimLocalization', true);
1711
- });
1712
- //html5a11y
1713
- (function($, document){
1714
- //if we support basic styleing or do not support ARIA (assumed) abort
1715
- if(!Modernizr.localstorage || ('hidden' in document.createElement('a'))){return;}
1716
-
1717
- var elemMappings = {
1718
- article: "article",
1719
- aside: "complementary",
1720
- section: "region",
1721
- nav: "navigation",
1722
- address: "contentinfo"
1723
- };
1724
- var addRole = function(elem, role){
1725
- var hasRole = elem.getAttribute('role');
1726
- if (!hasRole) {
1727
- elem.setAttribute('role', role);
1728
- }
1729
- };
1730
-
1731
- $.webshims.addReady(function(context, contextElem){
1732
- $.each(elemMappings, function(name, role){
1733
- var elems = $(name, context).add(contextElem.filter(name));
1734
- for (var i = 0, len = elems.length; i < len; i++) {
1735
- addRole(elems[i], role);
1736
- }
1737
- });
1738
- if (context === document) {
1739
- var header = document.getElementsByTagName('header')[0];
1740
- var footers = document.getElementsByTagName('footer');
1741
- var footerLen = footers.length;
1742
- if (header && !$(header).closest('section, article')[0]) {
1743
- addRole(header, 'banner');
1744
- }
1745
- if (!footerLen) {
1746
- return;
1747
- }
1748
- var footer = footers[footerLen - 1];
1749
- if (!$(footer).closest('section, article')[0]) {
1750
- addRole(footer, 'contentinfo');
1751
- }
1752
- }
1753
- });
1754
-
1755
- })(jQuery, document);
1756
-
1757
- (function($, Modernizr, webshims){
1758
- "use strict";
1759
- var hasNative = Modernizr.audio && Modernizr.video;
1760
- var supportsLoop = false;
1761
- var bugs = webshims.bugs;
1762
-
1763
- var loadSwf = function(){
1764
- webshims.ready(swfType, function(){
1765
- if(!webshims.mediaelement.createSWF){
1766
- webshims.mediaelement.loadSwf = true;
1767
- webshims.reTest([swfType], hasNative);
1768
- }
1769
- });
1770
- };
1771
- var options = webshims.cfg.mediaelement;
1772
- var swfType = options && options.player == 'jwplayer' ? 'mediaelement-swf' : 'mediaelement-jaris';
1773
- var hasSwf;
1774
- if(!options){
1775
- webshims.error("mediaelement wasn't implemented but loaded");
1776
- return;
1777
- }
1778
- if(hasNative){
1779
- var videoElem = document.createElement('video');
1780
- Modernizr.videoBuffered = ('buffered' in videoElem);
1781
- supportsLoop = ('loop' in videoElem);
1782
-
1783
- webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
1784
-
1785
- if(!Modernizr.videoBuffered){
1786
- webshims.addPolyfill('mediaelement-native-fix', {
1787
- f: 'mediaelement',
1788
- test: Modernizr.videoBuffered,
1789
- d: ['dom-support']
1790
- });
1791
-
1792
- webshims.reTest('mediaelement-native-fix');
1793
- }
1794
- }
1795
-
1796
- if(hasNative && !options.preferFlash){
1797
- var switchOptions = function(e){
1798
- var parent = e.target.parentNode;
1799
- if(!options.preferFlash && ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) ){
1800
- webshims.ready('DOM mediaelement', function(){
1801
- if(hasSwf){
1802
- loadSwf();
1803
- }
1804
- webshims.ready('WINDOWLOAD '+swfType, function(){
1805
- setTimeout(function(){
1806
- if(hasSwf && !options.preferFlash && webshims.mediaelement.createSWF && !$(e.target).closest('audio, video').is('.nonnative-api-active')){
1807
- options.preferFlash = true;
1808
- document.removeEventListener('error', switchOptions, true);
1809
- $('audio, video').each(function(){
1810
- webshims.mediaelement.selectSource(this);
1811
- });
1812
- webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src);
1813
- } else if(!hasSwf){
1814
- document.removeEventListener('error', switchOptions, true);
1815
- }
1816
- }, 20);
1817
- });
1818
- });
1819
- }
1820
- };
1821
- document.addEventListener('error', switchOptions, true);
1822
- $('audio, video').each(function(){
1823
- if(this.error){
1824
- switchOptions({target: this});
1825
- }
1826
- });
1827
- }
1828
-
1829
-
1830
- if(Modernizr.track && !bugs.track){
1831
- (function(){
1832
-
1833
- if(!bugs.track){
1834
- bugs.track = typeof $('<track />')[0].readyState != 'number';
1835
- }
1836
-
1837
- if(!bugs.track){
1838
- try {
1839
- new TextTrackCue(2, 3, '');
1840
- } catch(e){
1841
- bugs.track = true;
1842
- }
1843
- }
1844
-
1845
- var trackOptions = webshims.cfg.track;
1846
- var trackListener = function(e){
1847
- $(e.target).filter('track').each(changeApi);
1848
- };
1849
- var changeApi = function(){
1850
- if(bugs.track || (!trackOptions.override && $.prop(this, 'readyState') == 3)){
1851
- trackOptions.override = true;
1852
- webshims.reTest('track');
1853
- document.removeEventListener('error', trackListener, true);
1854
- if(this && $.nodeName(this, 'track')){
1855
- webshims.error("track support was overwritten. Please check your vtt including your vtt mime-type");
1856
- } else {
1857
- webshims.info("track support was overwritten. due to bad browser support");
1858
- }
1859
- }
1860
- };
1861
- var detectTrackError = function(){
1862
- document.addEventListener('error', trackListener, true);
1863
-
1864
- if(bugs.track){
1865
- changeApi();
1866
- } else {
1867
- $('track').each(changeApi);
1868
- }
1869
- };
1870
- if(!trackOptions.override){
1871
- if(webshims.isReady('track')){
1872
- detectTrackError();
1873
- } else {
1874
- $(detectTrackError);
1875
- }
1876
- }
1877
- })();
1878
-
1879
- }
1880
-
1881
- webshims.register('mediaelement-core', function($, webshims, window, document, undefined){
1882
- hasSwf = swfobject.hasFlashPlayerVersion('9.0.115');
1883
- $('html').addClass(hasSwf ? 'swf' : 'no-swf');
1884
- var mediaelement = webshims.mediaelement;
1885
- mediaelement.parseRtmp = function(data){
1886
- var src = data.src.split('://');
1887
- var paths = src[1].split('/');
1888
- var i, len, found;
1889
- data.server = src[0]+'://'+paths[0]+'/';
1890
- data.streamId = [];
1891
- for(i = 1, len = paths.length; i < len; i++){
1892
- if(!found && paths[i].indexOf(':') !== -1){
1893
- paths[i] = paths[i].split(':')[1];
1894
- found = true;
1895
- }
1896
- if(!found){
1897
- data.server += paths[i]+'/';
1898
- } else {
1899
- data.streamId.push(paths[i]);
1900
- }
1901
- }
1902
- if(!data.streamId.length){
1903
- webshims.error('Could not parse rtmp url');
1904
- }
1905
- data.streamId = data.streamId.join('/');
1906
- };
1907
- var getSrcObj = function(elem, nodeName){
1908
- elem = $(elem);
1909
- var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
1910
- var tmp;
1911
-
1912
- if(!src.src){return src;}
1913
-
1914
- tmp = elem.attr('data-server');
1915
- if(tmp != null){
1916
- src.server = tmp;
1917
- }
1918
-
1919
- tmp = elem.attr('type');
1920
- if(tmp){
1921
- src.type = tmp;
1922
- src.container = $.trim(tmp.split(';')[0]);
1923
- } else {
1924
- if(!nodeName){
1925
- nodeName = elem[0].nodeName.toLowerCase();
1926
- if(nodeName == 'source'){
1927
- nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
1928
- }
1929
- }
1930
- if(src.server){
1931
- src.type = nodeName+'/rtmp';
1932
- src.container = nodeName+'/rtmp';
1933
- } else {
1934
-
1935
- tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
1936
-
1937
- if(tmp){
1938
- src.type = tmp;
1939
- src.container = tmp;
1940
- }
1941
- }
1942
- }
1943
- tmp = elem.attr('media');
1944
- if(tmp){
1945
- src.media = tmp;
1946
- }
1947
- if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
1948
- if(src.server){
1949
- src.streamId = src.src;
1950
- } else {
1951
- mediaelement.parseRtmp(src);
1952
- }
1953
- }
1954
- return src;
1955
- };
1956
-
1957
-
1958
-
1959
- var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
1960
-
1961
- var loadTrackUi = function(){
1962
- if(loadTrackUi.loaded){return;}
1963
- loadTrackUi.loaded = true;
1964
- $(function(){
1965
- webshims.loader.loadList(['track-ui']);
1966
- });
1967
- };
1968
- var loadYt = (function(){
1969
- var loaded;
1970
- return function(){
1971
- if(loaded || !hasYt){return;}
1972
- loaded = true;
1973
- webshims.loader.loadScript("https://www.youtube.com/player_api");
1974
- $(function(){
1975
- webshims.polyfill("mediaelement-yt");
1976
- });
1977
- };
1978
- })();
1979
- var loadThird = function(){
1980
- if(hasSwf){
1981
- loadSwf();
1982
- } else {
1983
- loadYt();
1984
- }
1985
- };
1986
-
1987
- webshims.addPolyfill('mediaelement-yt', {
1988
- test: !hasYt,
1989
- d: ['dom-support']
1990
- });
1991
-
1992
- mediaelement.mimeTypes = {
1993
- audio: {
1994
- //ogm shouldn´t be used!
1995
- 'audio/ogg': ['ogg','oga', 'ogm'],
1996
- 'audio/ogg;codecs="opus"': 'opus',
1997
- 'audio/mpeg': ['mp2','mp3','mpga','mpega'],
1998
- 'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
1999
- 'audio/wav': ['wav'],
2000
- 'audio/3gpp': ['3gp','3gpp'],
2001
- 'audio/webm': ['webm'],
2002
- 'audio/fla': ['flv', 'f4a', 'fla'],
2003
- 'application/x-mpegURL': ['m3u8', 'm3u']
2004
- },
2005
- video: {
2006
- //ogm shouldn´t be used!
2007
- 'video/ogg': ['ogg','ogv', 'ogm'],
2008
- 'video/mpeg': ['mpg','mpeg','mpe'],
2009
- 'video/mp4': ['mp4','mpg4', 'm4v'],
2010
- 'video/quicktime': ['mov','qt'],
2011
- 'video/x-msvideo': ['avi'],
2012
- 'video/x-ms-asf': ['asf', 'asx'],
2013
- 'video/flv': ['flv', 'f4v'],
2014
- 'video/3gpp': ['3gp','3gpp'],
2015
- 'video/webm': ['webm'],
2016
- 'application/x-mpegURL': ['m3u8', 'm3u'],
2017
- 'video/MP2T': ['ts']
2018
- }
2019
- }
2020
- ;
2021
-
2022
- mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
2023
-
2024
- mediaelement.getTypeForSrc = function(src, nodeName, data){
2025
- if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
2026
- return 'video/youtube';
2027
- }
2028
- if(src.indexOf('rtmp') === 0){
2029
- return nodeName+'/rtmp';
2030
- }
2031
- src = src.split('?')[0].split('.');
2032
- src = src[src.length - 1];
2033
- var mt;
2034
-
2035
- $.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
2036
- if(exts.indexOf(src) !== -1){
2037
- mt = mimeType;
2038
- return false;
2039
- }
2040
- });
2041
- return mt;
2042
- };
2043
-
2044
-
2045
- mediaelement.srces = function(mediaElem, srces){
2046
- mediaElem = $(mediaElem);
2047
- if(!srces){
2048
- srces = [];
2049
- var nodeName = mediaElem[0].nodeName.toLowerCase();
2050
- var src = getSrcObj(mediaElem, nodeName);
2051
-
2052
- if(!src.src){
2053
-
2054
- $('source', mediaElem).each(function(){
2055
- src = getSrcObj(this, nodeName);
2056
- if(src.src){srces.push(src);}
2057
- });
2058
- } else {
2059
- srces.push(src);
2060
- }
2061
- return srces;
2062
- } else {
2063
- mediaElem.removeAttr('src').removeAttr('type').find('source').remove();
2064
- if(!$.isArray(srces)){
2065
- srces = [srces];
2066
- }
2067
- srces.forEach(function(src){
2068
- var source = document.createElement('source');
2069
- if(typeof src == 'string'){
2070
- src = {src: src};
2071
- }
2072
- source.setAttribute('src', src.src);
2073
- if(src.type){
2074
- source.setAttribute('type', src.type);
2075
- }
2076
- if(src.media){
2077
- source.setAttribute('media', src.media);
2078
- }
2079
- mediaElem.append(source);
2080
- });
2081
-
2082
- }
2083
- };
2084
-
2085
-
2086
- $.fn.loadMediaSrc = function(srces, poster){
2087
- return this.each(function(){
2088
- if(poster !== undefined){
2089
- $(this).removeAttr('poster');
2090
- if(poster){
2091
- $.attr(this, 'poster', poster);
2092
- }
2093
- }
2094
- mediaelement.srces(this, srces);
2095
- $(this).mediaLoad();
2096
- });
2097
- };
2098
-
2099
- mediaelement.swfMimeTypes = ['video/3gpp', 'video/x-msvideo', 'video/quicktime', 'video/x-m4v', 'video/mp4', 'video/m4p', 'video/x-flv', 'video/flv', 'audio/mpeg', 'audio/aac', 'audio/mp4', 'audio/x-m4a', 'audio/m4a', 'audio/mp3', 'audio/x-fla', 'audio/fla', 'youtube/flv', 'jwplayer/jwplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
2100
-
2101
- mediaelement.canThirdPlaySrces = function(mediaElem, srces){
2102
- var ret = '';
2103
- if(hasSwf || hasYt){
2104
- mediaElem = $(mediaElem);
2105
- srces = srces || mediaelement.srces(mediaElem);
2106
- $.each(srces, function(i, src){
2107
- if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
2108
- ret = src;
2109
- return false;
2110
- }
2111
- });
2112
-
2113
- }
2114
-
2115
- return ret;
2116
- };
2117
-
2118
- var nativeCanPlayType = {};
2119
- mediaelement.canNativePlaySrces = function(mediaElem, srces){
2120
- var ret = '';
2121
- if(hasNative){
2122
- mediaElem = $(mediaElem);
2123
- var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
2124
- if(!nativeCanPlayType[nodeName]){return ret;}
2125
- srces = srces || mediaelement.srces(mediaElem);
2126
-
2127
- $.each(srces, function(i, src){
2128
- if(src.type && nativeCanPlayType[nodeName].prop._supvalue.call(mediaElem[0], src.type) ){
2129
- ret = src;
2130
- return false;
2131
- }
2132
- });
2133
- }
2134
- return ret;
2135
- };
2136
-
2137
- mediaelement.setError = function(elem, message){
2138
- if(!message){
2139
- message = "can't play sources";
2140
- }
2141
-
2142
- $(elem).pause().data('mediaerror', message);
2143
- webshims.warn('mediaelementError: '+ message);
2144
- setTimeout(function(){
2145
- if($(elem).data('mediaerror')){
2146
- $(elem).trigger('mediaerror');
2147
- }
2148
- }, 1);
2149
- };
2150
-
2151
- var handleThird = (function(){
2152
- var requested;
2153
- return function( mediaElem, ret, data ){
2154
- if(!requested){
2155
- loadTrackUi();
2156
- }
2157
- webshims.ready(hasSwf ? swfType : 'mediaelement-yt', function(){
2158
- if(mediaelement.createSWF){
2159
- mediaelement.createSWF( mediaElem, ret, data );
2160
- } else if(!requested) {
2161
- requested = true;
2162
- loadThird();
2163
- //readd to ready
2164
- handleThird( mediaElem, ret, data );
2165
- }
2166
- });
2167
- if(!requested && hasYt && !mediaelement.createSWF){
2168
- loadYt();
2169
- }
2170
- };
2171
- })();
2172
-
2173
- var stepSources = function(elem, data, useSwf, _srces, _noLoop){
2174
- var ret;
2175
- if(useSwf || (useSwf !== false && data && data.isActive == 'third')){
2176
- ret = mediaelement.canThirdPlaySrces(elem, _srces);
2177
- if(!ret){
2178
- if(_noLoop){
2179
- mediaelement.setError(elem, false);
2180
- } else {
2181
- stepSources(elem, data, false, _srces, true);
2182
- }
2183
- } else {
2184
- handleThird(elem, ret, data);
2185
- }
2186
- } else {
2187
- ret = mediaelement.canNativePlaySrces(elem, _srces);
2188
- if(!ret){
2189
- if(_noLoop){
2190
- mediaelement.setError(elem, false);
2191
- if(data && data.isActive == 'third') {
2192
- mediaelement.setActive(elem, 'html5', data);
2193
- }
2194
- } else {
2195
- stepSources(elem, data, true, _srces, true);
2196
- }
2197
- } else if(data && data.isActive == 'third') {
2198
- mediaelement.setActive(elem, 'html5', data);
2199
- }
2200
- }
2201
- };
2202
- var stopParent = /^(?:embed|object|datalist)$/i;
2203
- var selectSource = function(elem, data){
2204
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
2205
- var _srces = mediaelement.srces(elem);
2206
- var parent = elem.parentNode;
2207
-
2208
- clearTimeout(baseData.loadTimer);
2209
- $.data(elem, 'mediaerror', false);
2210
-
2211
- if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
2212
- data = data || webshims.data(elem, 'mediaelement');
2213
- stepSources(elem, data, options.preferFlash || undefined, _srces);
2214
- };
2215
- mediaelement.selectSource = selectSource;
2216
-
2217
- $(document).on('ended', function(e){
2218
- var data = webshims.data(e.target, 'mediaelement');
2219
- if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
2220
- setTimeout(function(){
2221
- if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
2222
- $(e.target).prop('currentTime', 0).play();
2223
- }, 1);
2224
-
2225
- });
2226
- if(!supportsLoop){
2227
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
2228
- }
2229
-
2230
- ['audio', 'video'].forEach(function(nodeName){
2231
- var supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
2232
- prop: {
2233
- value: function(){
2234
- var data = webshims.data(this, 'mediaelement');
2235
- selectSource(this, data);
2236
- if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
2237
- supLoad.prop._supvalue.apply(this, arguments);
2238
- }
2239
- }
2240
- }
2241
- });
2242
- nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
2243
- prop: {
2244
- value: function(type){
2245
- var ret = '';
2246
- if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
2247
- ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
2248
- if(ret == 'no'){
2249
- ret = '';
2250
- }
2251
- }
2252
- if(!ret && hasSwf){
2253
- type = $.trim((type || '').split(';')[0]);
2254
- if(mediaelement.swfMimeTypes.indexOf(type) != -1){
2255
- ret = 'maybe';
2256
- }
2257
- }
2258
- return ret;
2259
- }
2260
- }
2261
- });
2262
- });
2263
- webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
2264
- set: function(){
2265
- var elem = this;
2266
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
2267
- clearTimeout(baseData.loadTimer);
2268
- baseData.loadTimer = setTimeout(function(){
2269
- selectSource(elem);
2270
- elem = null;
2271
- }, 9);
2272
- }
2273
- });
2274
-
2275
- var initMediaElements = function(){
2276
-
2277
- webshims.addReady(function(context, insertedElement){
2278
- var media = $('video, audio', context)
2279
- .add(insertedElement.filter('video, audio'))
2280
- .each(function(){
2281
- var data = webshims.data(this, 'mediaelement');
2282
-
2283
- if(hasNative && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay])') && (!data || data.isActive == 'html5')){
2284
- //IE controls not visible bug
2285
- $(this).prop('preload', 'metadata').mediaLoad();
2286
- } else {
2287
- selectSource(this, data);
2288
- }
2289
-
2290
- if(hasNative){
2291
-
2292
- //FF progress bug
2293
- (function(){
2294
- var bufferTimer;
2295
- var lastBuffered;
2296
- var elem = this;
2297
- var getBufferedString = function(){
2298
- var buffered = $.prop(elem, 'buffered');
2299
- if(!buffered){return;}
2300
- var bufferString = "";
2301
- for(var i = 0, len = buffered.length; i < len;i++){
2302
- bufferString += buffered.end(i);
2303
- }
2304
- return bufferString;
2305
- };
2306
- var testBuffer = function(){
2307
- var buffered = getBufferedString();
2308
- if(buffered != lastBuffered){
2309
- lastBuffered = buffered;
2310
- $(elem).triggerHandler('progress');
2311
- }
2312
- };
2313
-
2314
- $(this)
2315
- .on({
2316
- 'play loadstart progress': function(e){
2317
- if(e.type == 'progress'){
2318
- lastBuffered = getBufferedString();
2319
- }
2320
- clearTimeout(bufferTimer);
2321
- bufferTimer = setTimeout(testBuffer, 999);
2322
- },
2323
- 'emptied stalled mediaerror abort suspend': function(e){
2324
- if(e.type == 'emptied'){
2325
- lastBuffered = false;
2326
- }
2327
- clearTimeout(bufferTimer);
2328
- }
2329
- })
2330
- ;
2331
- })();
2332
- }
2333
-
2334
- })
2335
- ;
2336
- if(!loadTrackUi.loaded && $('track', media).length){
2337
- loadTrackUi();
2338
- }
2339
- media = null;
2340
- });
2341
- };
2342
-
2343
- if(Modernizr.track && !bugs.track){
2344
- webshims.defineProperty(TextTrack.prototype, 'shimActiveCues', {
2345
- get: function(){
2346
- return this._shimActiveCues || this.activeCues;
2347
- }
2348
- });
2349
- }
2350
- //set native implementation ready, before swf api is retested
2351
- if(hasNative){
2352
- webshims.isReady('mediaelement-core', true);
2353
- initMediaElements();
2354
- webshims.ready('WINDOWLOAD mediaelement', loadThird);
2355
- } else {
2356
- webshims.ready(swfType, initMediaElements);
2357
- }
2358
- webshims.ready('WINDOWLOAD mediaelement', loadTrackUi);
2359
- });
2360
- })(jQuery, Modernizr, jQuery.webshims);
2361
- /*
2362
- * todos:
2363
- * - decouple muted/volume (needs improvement)
2364
- * - implement video <-> flashcanvas pro API
2365
- * - improve buffered-property with youtube/rtmp
2366
- * - use jwplayer5 api instead of old flash4 api
2367
- */
2368
-
2369
- jQuery.webshims.register('mediaelement-swf', function($, webshims, window, document, undefined, options){
2370
- "use strict";
2371
- var SENDEVENT = 'sendEvent';
2372
- var mediaelement = webshims.mediaelement;
2373
- var swfobject = window.swfobject;
2374
- var hasNative = Modernizr.audio && Modernizr.video;
2375
- var hasFlash = swfobject.hasFlashPlayerVersion('9.0.115');
2376
- var loadedSwf = 0;
2377
- var getProps = {
2378
- paused: true,
2379
- ended: false,
2380
- currentSrc: '',
2381
- duration: window.NaN,
2382
-
2383
- readyState: 0,
2384
- networkState: 0,
2385
- videoHeight: 0,
2386
- videoWidth: 0,
2387
- error: null,
2388
- buffered: {
2389
- start: function(index){
2390
- if(index){
2391
- webshims.error('buffered index size error');
2392
- return;
2393
- }
2394
- return 0;
2395
- },
2396
- end: function(index){
2397
- if(index){
2398
- webshims.error('buffered index size error');
2399
- return;
2400
- }
2401
- return 0;
2402
- },
2403
- length: 0
2404
- }
2405
- };
2406
- var getPropKeys = Object.keys(getProps);
2407
-
2408
- var getSetProps = {
2409
- currentTime: 0,
2410
- volume: 1,
2411
- muted: false
2412
- };
2413
- var getSetPropKeys = Object.keys(getSetProps);
2414
-
2415
- var playerStateObj = $.extend({
2416
- isActive: 'html5',
2417
- activating: 'html5',
2418
- wasSwfReady: false,
2419
- _bufferedEnd: 0,
2420
- _bufferedStart: 0,
2421
- _metadata: false,
2422
- _durationCalcs: -1,
2423
- _callMeta: false,
2424
- currentTime: 0,
2425
- _ppFlag: undefined
2426
- }, getProps, getSetProps);
2427
-
2428
- var idRep = /^jwplayer-/;
2429
- var getSwfDataFromID = function(id){
2430
-
2431
- var elem = document.getElementById(id.replace(idRep, ''));
2432
- if(!elem){return;}
2433
- var data = webshims.data(elem, 'mediaelement');
2434
- return data.isActive == 'third' ? data : null;
2435
- };
2436
-
2437
-
2438
- var getSwfDataFromElem = function(elem){
2439
- try {
2440
- (elem.nodeName);
2441
- } catch(er){
2442
- return null;
2443
- }
2444
- var data = webshims.data(elem, 'mediaelement');
2445
- return (data && data.isActive== 'third') ? data : null;
2446
- };
2447
-
2448
- var trigger = function(elem, evt){
2449
- evt = $.Event(evt);
2450
- evt.preventDefault();
2451
- $.event.trigger(evt, undefined, elem);
2452
- };
2453
-
2454
- var playerSwfPath = options.playerPath || webshims.cfg.basePath + "jwplayer/" + (options.playerName || "player.swf");
2455
- var jwplugin = options.pluginPath || webshims.cfg.basePath +'swf/jwwebshims.swf';
2456
-
2457
- webshims.extendUNDEFProp(options.params, {
2458
- allowscriptaccess: 'always',
2459
- allowfullscreen: 'true',
2460
- wmode: 'transparent'
2461
- });
2462
- webshims.extendUNDEFProp(options.vars, {
2463
- screencolor: 'ffffffff'
2464
- });
2465
- webshims.extendUNDEFProp(options.attrs, {
2466
- bgcolor: '#000000'
2467
- });
2468
-
2469
- var getDuration = function(data, obj){
2470
- var curDuration = data.duration;
2471
- if(curDuration && data._durationCalcs > 0){return;}
2472
- try {
2473
- data.duration = data.jwapi.getPlaylist()[0].duration;
2474
- if(!data.duration || data.duration <= 0 || data.duration === data._lastDuration){
2475
- data.duration = curDuration;
2476
- }
2477
- } catch(er){}
2478
- if(data.duration && data.duration != data._lastDuration){
2479
- trigger(data._elem, 'durationchange');
2480
- if(data._elemNodeName == 'audio' || data._callMeta){
2481
- mediaelement.jwEvents.Model.META($.extend({duration: data.duration}, obj), data);
2482
- }
2483
- data._durationCalcs--;
2484
- } else {
2485
- data._durationCalcs++;
2486
- }
2487
- };
2488
- var setReadyState = function(readyState, data){
2489
- if(readyState < 3){
2490
- clearTimeout(data._canplaythroughTimer);
2491
- }
2492
- if(readyState >= 3 && data.readyState < 3){
2493
- data.readyState = readyState;
2494
- trigger(data._elem, 'canplay');
2495
- clearTimeout(data._canplaythroughTimer);
2496
- data._canplaythroughTimer = setTimeout(function(){
2497
- setReadyState(4, data);
2498
- }, 4000);
2499
- }
2500
- if(readyState >= 4 && data.readyState < 4){
2501
- data.readyState = readyState;
2502
- trigger(data._elem, 'canplaythrough');
2503
- }
2504
- data.readyState = readyState;
2505
- };
2506
-
2507
- $.extend($.event.customEvent, {
2508
- updatemediaelementdimensions: true,
2509
- flashblocker: true,
2510
- swfstageresize: true,
2511
- mediaelementapichange: true
2512
- });
2513
-
2514
- mediaelement.jwEvents = {
2515
- View: {
2516
-
2517
- PLAY: function(obj){
2518
- var data = getSwfDataFromID(obj.id);
2519
- if(!data || data.stopPlayPause){return;}
2520
- data._ppFlag = true;
2521
- if(data.paused == obj.state){
2522
- data.paused = !obj.state;
2523
- if(data.ended){
2524
- data.ended = false;
2525
- }
2526
- trigger(data._elem, obj.state ? 'play' : 'pause');
2527
- }
2528
- }
2529
- },
2530
- Model: {
2531
-
2532
- BUFFER: function(obj){
2533
- var data = getSwfDataFromID(obj.id);
2534
- if(!data || !('percentage' in obj) || data._bufferedEnd == obj.percentage){return;}
2535
- data.networkState = (obj.percentage == 100) ? 1 : 2;
2536
- if(isNaN(data.duration) || (obj.percentage > 5 && obj.percentage < 25) || (obj.percentage === 100)){
2537
- getDuration(data, obj);
2538
- }
2539
-
2540
- if(data.ended){
2541
- data.ended = false;
2542
- }
2543
- if(!data.duration){
2544
- return;
2545
- }
2546
- if(obj.percentage > 2 && obj.percentage < 20){
2547
- setReadyState(3, data);
2548
- } else if(obj.percentage > 20){
2549
- setReadyState(4, data);
2550
- }
2551
- if(data._bufferedEnd && (data._bufferedEnd > obj.percentage)){
2552
- data._bufferedStart = data.currentTime || 0;
2553
- }
2554
-
2555
- data._bufferedEnd = obj.percentage;
2556
- data.buffered.length = 1;
2557
- if(obj.percentage == 100){
2558
- data.networkState = 1;
2559
- setReadyState(4, data);
2560
- }
2561
- $.event.trigger('progress', undefined, data._elem, true);
2562
- },
2563
- META: function(obj, data){
2564
-
2565
- data = data && data.networkState ? data : getSwfDataFromID(obj.id);
2566
-
2567
- if(!data){return;}
2568
- if( !('duration' in obj) ){
2569
- data._callMeta = true;
2570
- return;
2571
- }
2572
-
2573
- if( data._metadata && (!obj.height || data.videoHeight == obj.height) && (obj.duration === data.duration) ){return;}
2574
-
2575
- data._metadata = true;
2576
-
2577
- var oldDur = data.duration;
2578
- if(obj.duration){
2579
- data.duration = obj.duration;
2580
- }
2581
- data._lastDuration = data.duration;
2582
- if(obj.height || obj.width){
2583
- data.videoHeight = obj.height || 0;
2584
- data.videoWidth = obj.width || 0;
2585
- }
2586
- if(!data.networkState){
2587
- data.networkState = 2;
2588
- }
2589
- if(data.readyState < 1){
2590
- setReadyState(1, data);
2591
- }
2592
- if(data.duration && oldDur !== data.duration){
2593
- trigger(data._elem, 'durationchange');
2594
- }
2595
-
2596
- trigger(data._elem, 'loadedmetadata');
2597
- },
2598
- TIME: function(obj){
2599
- var data = getSwfDataFromID(obj.id);
2600
- if(!data || data.currentTime === obj.position){return;}
2601
- data.currentTime = obj.position;
2602
- if(data.duration && data.duration < data.currentTime){
2603
- getDuration(data, obj);
2604
- }
2605
- if(data.readyState < 2){
2606
- setReadyState(2, data);
2607
- }
2608
- if(data.ended){
2609
- data.ended = false;
2610
- }
2611
- trigger(data._elem, 'timeupdate');
2612
-
2613
- },
2614
- STATE: function(obj){
2615
- var data = getSwfDataFromID(obj.id);
2616
- if(!data){return;}
2617
- switch(obj.newstate) {
2618
- case 'BUFFERING':
2619
-
2620
- if(data.ended){
2621
- data.ended = false;
2622
- }
2623
- setReadyState(1, data);
2624
- trigger(data._elem, 'waiting');
2625
- break;
2626
- case 'PLAYING':
2627
- data.paused = false;
2628
- data._ppFlag = true;
2629
- if(!data.duration){
2630
- getDuration(data, obj);
2631
- }
2632
- if(data.readyState < 3){
2633
- setReadyState(3, data);
2634
- }
2635
- if(data.ended){
2636
- data.ended = false;
2637
- }
2638
- trigger(data._elem, 'playing');
2639
- break;
2640
- case 'PAUSED':
2641
- if(!data.paused && !data.stopPlayPause){
2642
- data.paused = true;
2643
- data._ppFlag = true;
2644
- trigger(data._elem, 'pause');
2645
- }
2646
- break;
2647
- case 'COMPLETED':
2648
- if(data.readyState < 4){
2649
- setReadyState(4, data);
2650
- }
2651
- data.ended = true;
2652
- trigger(data._elem, 'ended');
2653
- break;
2654
- }
2655
- }
2656
- }
2657
- ,Controller: {
2658
-
2659
- ERROR: function(obj){
2660
- var data = getSwfDataFromID(obj.id);
2661
- if(!data){return;}
2662
- mediaelement.setError(data._elem, obj.message);
2663
- },
2664
- SEEK: function(obj){
2665
- var data = getSwfDataFromID(obj.id);
2666
- if(!data){return;}
2667
- if(data.ended){
2668
- data.ended = false;
2669
- }
2670
- if(data.paused){
2671
- try {
2672
- data.jwapi[SENDEVENT]('play', 'false');
2673
- } catch(er){}
2674
- }
2675
- if(data.currentTime != obj.position){
2676
- data.currentTime = obj.position;
2677
- trigger(data._elem, 'timeupdate');
2678
- }
2679
-
2680
-
2681
- },
2682
- VOLUME: function(obj){
2683
- var data = getSwfDataFromID(obj.id);
2684
- if(!data){return;}
2685
- var newVolume = obj.percentage / 100;
2686
- if(data.volume == newVolume){return;}
2687
- data.volume = newVolume;
2688
- trigger(data._elem, 'volumechange');
2689
- },
2690
- MUTE: function(obj){
2691
- if(obj.state){return;}
2692
- var data = getSwfDataFromID(obj.id);
2693
- if(!data){return;}
2694
- if(data.muted == obj.state){return;}
2695
- data.muted = obj.state;
2696
- trigger(data._elem, 'volumechange');
2697
- }
2698
- }
2699
- };
2700
-
2701
- var initEvents = function(data){
2702
- var passed = true;
2703
- $.each(mediaelement.jwEvents, function(mvcName, evts){
2704
- $.each(evts, function(evtName){
2705
- try {
2706
- data.jwapi['add'+ mvcName +'Listener'](evtName, 'jQuery.webshims.mediaelement.jwEvents.'+ mvcName +'.'+ evtName);
2707
- } catch(er){
2708
- passed = false;
2709
- return false;
2710
- }
2711
- });
2712
- });
2713
- return passed;
2714
- };
2715
-
2716
- var workActionQueue = function(data){
2717
- var actionLen = data.actionQueue.length;
2718
- var i = 0;
2719
- var operation;
2720
- if(actionLen && data.isActive == 'third'){
2721
- while(data.actionQueue.length && actionLen > i){
2722
- i++;
2723
- operation = data.actionQueue.shift();
2724
- data.jwapi[operation.fn].apply(data.jwapi, operation.args);
2725
- }
2726
- }
2727
- if(data.actionQueue.length){
2728
- data.actionQueue = [];
2729
- }
2730
- };
2731
- var startAutoPlay = function(data){
2732
- if(!data){return;}
2733
- if( (data._ppFlag === undefined && ($.prop(data._elem, 'autoplay')) || !data.paused)){
2734
- setTimeout(function(){
2735
- if(data.isActive == 'third' && (data._ppFlag === undefined || !data.paused)){
2736
- try {
2737
- $(data._elem).play();
2738
- } catch(er){}
2739
- }
2740
- }, 1);
2741
- }
2742
- };
2743
-
2744
-
2745
- mediaelement.playerResize = function(id){
2746
- if(!id){return;}
2747
- var elem = document.getElementById(id.replace(idRep, ''));
2748
-
2749
- if(elem){
2750
- $(elem).triggerHandler('swfstageresize');
2751
- }
2752
- elem = null;
2753
- };
2754
-
2755
-
2756
- $(document).on('emptied', function(e){
2757
- var data = getSwfDataFromElem(e.target);
2758
- startAutoPlay(data);
2759
- });
2760
-
2761
- var localConnectionTimer;
2762
- mediaelement.jwPlayerReady = function(jwData){
2763
- var data = getSwfDataFromID(jwData.id);
2764
- var passed = true;
2765
- var i = 0;
2766
- var doneFn = function(){
2767
- if(i > 9){return;}
2768
- i++;
2769
- if(initEvents(data)){
2770
- if(!data.wasSwfReady){
2771
- var version = parseFloat( jwData.version, 10);
2772
- if(version < 5.1 || version >= 6){
2773
- webshims.warn('mediaelement-swf is only testet with jwplayer 5.6+');
2774
- }
2775
- } else {
2776
- $(data._elem).mediaLoad();
2777
-
2778
- }
2779
- data.wasSwfReady = true;
2780
- data.tryedReframeing = 0;
2781
- workActionQueue(data);
2782
- startAutoPlay(data);
2783
- } else {
2784
- clearTimeout(data.reframeTimer);
2785
- data.reframeTimer = setTimeout(doneFn, 9 * i);
2786
- if(i > 2 && data.tryedReframeing < 9){
2787
- data.tryedReframeing++;
2788
- data.shadowElem.css({overflow: 'visible'});
2789
- setTimeout(function(){
2790
- data.shadowElem.css({overflow: 'hidden'});
2791
- }, 16);
2792
- }
2793
- }
2794
- };
2795
- if(!data || !data.jwapi){return;}
2796
- if(!data.tryedReframeing){
2797
- data.tryedReframeing = 0;
2798
- }
2799
- clearTimeout(localConnectionTimer);
2800
- data.jwData = jwData;
2801
- data.shadowElem.removeClass('flashblocker-assumed');
2802
- $.prop(data._elem, 'volume', data.volume);
2803
- $.prop(data._elem, 'muted', data.muted);
2804
- doneFn();
2805
-
2806
- };
2807
-
2808
- var addMediaToStopEvents = $.noop;
2809
- if(hasNative){
2810
- var stopEvents = {
2811
- play: 1,
2812
- playing: 1
2813
- };
2814
- var hideEvtArray = ['play', 'pause', 'playing', 'canplay', 'progress', 'waiting', 'ended', 'loadedmetadata', 'durationchange', 'emptied'];
2815
- var hidevents = hideEvtArray.map(function(evt){
2816
- return evt +'.webshimspolyfill';
2817
- }).join(' ');
2818
- var opposite = {
2819
- 'html5': 'third',
2820
- 'third': 'html5'
2821
- };
2822
- var hidePlayerEvents = function(event){
2823
- var data = webshims.data(event.target, 'mediaelement');
2824
- if(!data){return;}
2825
- var isNativeHTML5 = ( event.originalEvent && event.originalEvent.type === event.type );
2826
- if( isNativeHTML5 == (data.activating == 'third') ){
2827
- event.stopImmediatePropagation();
2828
- if(stopEvents[event.type]){
2829
- if(data.isActive != data.activating){
2830
- $(event.target).pause();
2831
- } else {
2832
- data.isActive = opposite[data.isActive];
2833
- $(event.target).pause();
2834
- data.isActive = opposite[data.isActive];
2835
- }
2836
- }
2837
- }
2838
- };
2839
-
2840
-
2841
- addMediaToStopEvents = function(elem){
2842
- $(elem)
2843
- .off(hidevents)
2844
- .on(hidevents, hidePlayerEvents)
2845
- ;
2846
- hideEvtArray.forEach(function(evt){
2847
- webshims.moveToFirstEvent(elem, evt);
2848
- });
2849
- };
2850
- addMediaToStopEvents(document);
2851
- }
2852
-
2853
-
2854
- mediaelement.setActive = function(elem, type, data){
2855
- if(!data){
2856
- data = webshims.data(elem, 'mediaelement');
2857
- }
2858
- if(!data || data.isActive == type){return;}
2859
- if(type != 'html5' && type != 'third'){
2860
- webshims.warn('wrong type for mediaelement activating: '+ type);
2861
- }
2862
- var shadowData = webshims.data(elem, 'shadowData');
2863
- data.activating = type;
2864
- $(elem).pause();
2865
- data.isActive = type;
2866
- if(type == 'third'){
2867
- shadowData.shadowElement = shadowData.shadowFocusElement = data.shadowElem[0];
2868
- $(elem).addClass('swf-api-active nonnative-api-active').hide().getShadowElement().show();
2869
- } else {
2870
- $(elem).removeClass('swf-api-active nonnative-api-active').show().getShadowElement().hide();
2871
- shadowData.shadowElement = shadowData.shadowFocusElement = false;
2872
- }
2873
- $(elem).trigger('mediaelementapichange');
2874
- };
2875
-
2876
-
2877
-
2878
- var resetSwfProps = (function(){
2879
- var resetProtoProps = ['_bufferedEnd', '_bufferedStart', '_metadata', '_ppFlag', 'currentSrc', 'currentTime', 'duration', 'ended', 'networkState', 'paused', 'videoHeight', 'videoWidth', '_callMeta', '_durationCalcs'];
2880
- var len = resetProtoProps.length;
2881
- return function(data){
2882
-
2883
- if(!data){return;}
2884
- var lenI = len;
2885
- var networkState = data.networkState;
2886
- setReadyState(0, data);
2887
- while(--lenI){
2888
- delete data[resetProtoProps[lenI]];
2889
- }
2890
- data.actionQueue = [];
2891
- data.buffered.length = 0;
2892
- if(networkState){
2893
- trigger(data._elem, 'emptied');
2894
- }
2895
- };
2896
- })();
2897
-
2898
- var setElementDimension = function(data, hasControls){
2899
- var elem = data._elem;
2900
- var box = data.shadowElem;
2901
- $(elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
2902
- if(data._elemNodeName == 'audio' && !hasControls){
2903
- box.css({width: 0, height: 0});
2904
- } else {
2905
- box.css({
2906
- width: elem.style.width || $(elem).width(),
2907
- height: elem.style.height || $(elem).height()
2908
- });
2909
- }
2910
- };
2911
-
2912
- mediaelement.createSWF = function( elem, canPlaySrc, data ){
2913
- if(!hasFlash){
2914
- setTimeout(function(){
2915
- $(elem).mediaLoad(); //<- this should produce a mediaerror
2916
- }, 1);
2917
- return;
2918
- }
2919
-
2920
- if(loadedSwf < 1){
2921
- loadedSwf = 1;
2922
- } else {
2923
- loadedSwf++;
2924
- }
2925
- var vars = $.extend({}, options.vars, {
2926
- image: $.attr(elem, 'poster') && $.prop(elem, 'poster') || '',
2927
- file: canPlaySrc.streamId || canPlaySrc.srcProp
2928
- });
2929
- var elemVars = $(elem).data('vars') || {};
2930
-
2931
- if(canPlaySrc.server){
2932
- vars.streamer = canPlaySrc.server;
2933
- }
2934
- if(!data){
2935
- data = webshims.data(elem, 'mediaelement');
2936
- }
2937
-
2938
- if(data && data.swfCreated){
2939
- mediaelement.setActive(elem, 'third', data);
2940
- resetSwfProps(data);
2941
- data.currentSrc = canPlaySrc.srcProp;
2942
- $.extend(vars, elemVars);
2943
- options.changeSWF(vars, elem, canPlaySrc, data, 'load');
2944
- queueSwfMethod(elem, SENDEVENT, ['LOAD', vars]);
2945
- return;
2946
- }
2947
-
2948
-
2949
- var hasControls = $.prop(elem, 'controls');
2950
- var elemId = 'jwplayer-'+ webshims.getID(elem);
2951
- var params = $.extend(
2952
- {},
2953
- options.params,
2954
- $(elem).data('params')
2955
- );
2956
- var elemNodeName = elem.nodeName.toLowerCase();
2957
- var attrs = $.extend(
2958
- {},
2959
- options.attrs,
2960
- {
2961
- name: elemId,
2962
- id: elemId
2963
- },
2964
- $(elem).data('attrs')
2965
- );
2966
- var box = $('<div class="polyfill-'+ (elemNodeName) +' polyfill-mediaelement" id="wrapper-'+ elemId +'"><div id="'+ elemId +'"></div>')
2967
- .css({
2968
- position: 'relative',
2969
- overflow: 'hidden'
2970
- })
2971
- ;
2972
- var setDimensions = function(){
2973
- setElementDimension(data, $.prop(elem, 'controls'));
2974
- };
2975
-
2976
- data = webshims.data(elem, 'mediaelement', webshims.objectCreate(playerStateObj, {
2977
- actionQueue: {
2978
- value: []
2979
- },
2980
- shadowElem: {
2981
- value: box
2982
- },
2983
- _elemNodeName: {
2984
- value: elemNodeName
2985
- },
2986
- _elem: {
2987
- value: elem
2988
- },
2989
- currentSrc: {
2990
- value: canPlaySrc.srcProp
2991
- },
2992
- swfCreated: {
2993
- value: true
2994
- },
2995
- buffered: {
2996
- value: {
2997
- start: function(index){
2998
- if(index >= data.buffered.length){
2999
- webshims.error('buffered index size error');
3000
- return;
3001
- }
3002
- return 0;
3003
- },
3004
- end: function(index){
3005
- if(index >= data.buffered.length){
3006
- webshims.error('buffered index size error');
3007
- return;
3008
- }
3009
- return ( (data.duration - data._bufferedStart) * data._bufferedEnd / 100) + data._bufferedStart;
3010
- },
3011
- length: 0
3012
- }
3013
- }
3014
- }));
3015
-
3016
- setElementDimension(data, hasControls);
3017
-
3018
- box.insertBefore(elem);
3019
-
3020
- if(hasNative){
3021
- $.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted')});
3022
- }
3023
-
3024
- $.extend(vars,
3025
- {
3026
- id: elemId,
3027
- controlbar: hasControls ? options.vars.controlbar || (elemNodeName == 'video' ? 'over' : 'bottom') : (elemNodeName == 'video') ? 'none' : 'bottom',
3028
- icons: ''+ (hasControls && elemNodeName == 'video')
3029
- },
3030
- elemVars,
3031
- {playerready: 'jQuery.webshims.mediaelement.jwPlayerReady'}
3032
- );
3033
- if(vars.plugins){
3034
- vars.plugins += ','+jwplugin;
3035
- } else {
3036
- vars.plugins = jwplugin;
3037
- }
3038
-
3039
-
3040
- webshims.addShadowDom(elem, box);
3041
-
3042
- addMediaToStopEvents(elem);
3043
-
3044
- mediaelement.setActive(elem, 'third', data);
3045
-
3046
- options.changeSWF(vars, elem, canPlaySrc, data, 'embed');
3047
-
3048
-
3049
- $(document).on('updateshadowdom', setDimensions);
3050
- $(elem).on('updatemediaelementdimensions', setDimensions);
3051
-
3052
-
3053
- swfobject.embedSWF(playerSwfPath, elemId, "100%", "100%", "9.0.0", false, vars, params, attrs, function(swfData){
3054
-
3055
- if(swfData.success){
3056
- data.jwapi = swfData.ref;
3057
-
3058
- if(!hasControls){
3059
- $(swfData.ref).attr('tabindex', '-1').css('outline', 'none');
3060
- }
3061
- setTimeout(function(){
3062
- if((!swfData.ref.parentNode && box[0].parentNode) || swfData.ref.style.display == "none"){
3063
- box.addClass('flashblocker-assumed');
3064
- $(elem).trigger('flashblocker');
3065
- webshims.warn("flashblocker assumed");
3066
- }
3067
- $(swfData.ref).css({'minHeight': '2px', 'minWidth': '2px', display: 'block'});
3068
- }, 9);
3069
- if(!localConnectionTimer){
3070
- clearTimeout(localConnectionTimer);
3071
- localConnectionTimer = setTimeout(function(){
3072
- var flash = $(swfData.ref);
3073
- if(flash[0].offsetWidth > 1 && flash[0].offsetHeight > 1 && location.protocol.indexOf('file:') === 0){
3074
- 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");
3075
- } else if(flash[0].offsetWidth < 2 || flash[0].offsetHeight < 2) {
3076
- webshims.warn("JS-SWF connection can't be established on hidden or unconnected flash objects");
3077
- }
3078
- flash = null;
3079
- }, 8000);
3080
- }
3081
- }
3082
- });
3083
- };
3084
-
3085
-
3086
- var queueSwfMethod = function(elem, fn, args, data){
3087
- data = data || getSwfDataFromElem(elem);
3088
- if(data){
3089
- if(data.jwapi && data.jwapi[fn]){
3090
- data.jwapi[fn].apply(data.jwapi, args || []);
3091
- } else {
3092
- //todo add to queue
3093
- data.actionQueue.push({fn: fn, args: args});
3094
- if(data.actionQueue.length > 10){
3095
- setTimeout(function(){
3096
- if(data.actionQueue.length > 5){
3097
- data.actionQueue.shift();
3098
- }
3099
- }, 99);
3100
- }
3101
- }
3102
- return data;
3103
- }
3104
- return false;
3105
- };
3106
-
3107
- ['audio', 'video'].forEach(function(nodeName){
3108
- var descs = {};
3109
- var mediaSup;
3110
- var createGetProp = function(key){
3111
- if(nodeName == 'audio' && (key == 'videoHeight' || key == 'videoWidth')){return;}
3112
-
3113
- descs[key] = {
3114
- get: function(){
3115
- var data = getSwfDataFromElem(this);
3116
- if(data){
3117
- return data[key];
3118
- } else if(hasNative && mediaSup[key].prop._supget) {
3119
- return mediaSup[key].prop._supget.apply(this);
3120
- } else {
3121
- return playerStateObj[key];
3122
- }
3123
- },
3124
- writeable: false
3125
- };
3126
- };
3127
- var createGetSetProp = function(key, setFn){
3128
- createGetProp(key);
3129
- delete descs[key].writeable;
3130
- descs[key].set = setFn;
3131
- };
3132
-
3133
- createGetSetProp('volume', function(v){
3134
- var data = getSwfDataFromElem(this);
3135
- if(data){
3136
- v *= 100;
3137
- if(!isNaN(v)){
3138
- var muted = data.muted;
3139
- if(v < 0 || v > 100){
3140
- webshims.error('volume greater or less than allowed '+ (v / 100));
3141
- }
3142
-
3143
- queueSwfMethod(this, SENDEVENT, ['VOLUME', v], data);
3144
- if(muted){
3145
- try {
3146
- data.jwapi.sendEvent('mute', 'true');
3147
- } catch(er){}
3148
- }
3149
- v /= 100;
3150
- if(data.volume == v || data.isActive != 'third'){return;}
3151
- data.volume = v;
3152
- trigger(data._elem, 'volumechange');
3153
- data = null;
3154
- }
3155
- } else if(mediaSup.volume.prop._supset) {
3156
- return mediaSup.volume.prop._supset.apply(this, arguments);
3157
- }
3158
- });
3159
-
3160
- createGetSetProp('muted', function(m){
3161
- var data = getSwfDataFromElem(this);
3162
- if(data){
3163
- m = !!m;
3164
- queueSwfMethod(this, SENDEVENT, ['mute', ''+m], data);
3165
- if(data.muted == m || data.isActive != 'third'){return;}
3166
- data.muted = m;
3167
- trigger(data._elem, 'volumechange');
3168
- data = null;
3169
- } else if(mediaSup.muted.prop._supset) {
3170
- return mediaSup.muted.prop._supset.apply(this, arguments);
3171
- }
3172
- });
3173
-
3174
-
3175
- createGetSetProp('currentTime', function(t){
3176
- var data = getSwfDataFromElem(this);
3177
- if(data){
3178
- t *= 1;
3179
- if (!isNaN(t)) {
3180
- if(data.paused){
3181
- clearTimeout(data.stopPlayPause);
3182
- data.stopPlayPause = setTimeout(function(){
3183
- data.paused = true;
3184
- data.stopPlayPause = false;
3185
- }, 50);
3186
- }
3187
- queueSwfMethod(this, SENDEVENT, ['SEEK', '' + t], data);
3188
-
3189
- if(data.paused){
3190
- if(data.readyState > 0){
3191
- data.currentTime = t;
3192
- trigger(data._elem, 'timeupdate');
3193
- }
3194
- try {
3195
- data.jwapi[SENDEVENT]('play', 'false');
3196
- } catch(er){}
3197
-
3198
- }
3199
- }
3200
-
3201
- } else if(mediaSup.currentTime.prop._supset) {
3202
- return mediaSup.currentTime.prop._supset.apply(this, arguments);
3203
- }
3204
- });
3205
-
3206
- ['play', 'pause'].forEach(function(fn){
3207
- descs[fn] = {
3208
- value: function(){
3209
- var data = getSwfDataFromElem(this);
3210
- if(data){
3211
- if(data.stopPlayPause){
3212
- clearTimeout(data.stopPlayPause);
3213
- }
3214
- queueSwfMethod(this, SENDEVENT, ['play', fn == 'play'], data);
3215
- setTimeout(function(){
3216
- if(data.isActive == 'third'){
3217
- data._ppFlag = true;
3218
- if(data.paused != (fn != 'play')){
3219
- data.paused = fn != 'play';
3220
- trigger(data._elem, fn);
3221
- }
3222
- }
3223
- }, 1);
3224
- } else if(mediaSup[fn].prop._supvalue) {
3225
- return mediaSup[fn].prop._supvalue.apply(this, arguments);
3226
- }
3227
- }
3228
- };
3229
- });
3230
-
3231
- getPropKeys.forEach(createGetProp);
3232
-
3233
- webshims.onNodeNamesPropertyModify(nodeName, 'controls', function(val, boolProp){
3234
- var data = getSwfDataFromElem(this);
3235
- $(this)[boolProp ? 'addClass' : 'removeClass']('webshims-controls');
3236
-
3237
- if(data){
3238
- try {
3239
- queueSwfMethod(this, boolProp ? 'showControls' : 'hideControls', [nodeName], data);
3240
- } catch(er){
3241
- webshims.warn("you need to generate a crossdomain.xml");
3242
- }
3243
- if(nodeName == 'audio'){
3244
- setElementDimension(data, boolProp);
3245
- }
3246
- $(data.jwapi).attr('tabindex', boolProp ? '0' : '-1');
3247
- }
3248
- });
3249
-
3250
- mediaSup = webshims.defineNodeNameProperties(nodeName, descs, 'prop');
3251
- });
3252
-
3253
- if(hasFlash && $.cleanData){
3254
- var oldClean = $.cleanData;
3255
- var flashNames = {
3256
- object: 1,
3257
- OBJECT: 1
3258
- };
3259
- $.cleanData = function(elems){
3260
- var i, len, prop;
3261
- if(elems && (len = elems.length) && loadedSwf){
3262
-
3263
- for(i = 0; i < len; i++){
3264
- if(flashNames[elems[i].nodeName]){
3265
- if(SENDEVENT in elems[i]){
3266
- loadedSwf--;
3267
- try {
3268
- elems[i][SENDEVENT]('play', false);
3269
- } catch(er){}
3270
- }
3271
- try {
3272
- for (prop in elems[i]) {
3273
- if (typeof elems[i][prop] == "function") {
3274
- elems[i][prop] = null;
3275
- }
3276
- }
3277
- } catch(er){}
3278
- }
3279
- }
3280
-
3281
- }
3282
- return oldClean.apply(this, arguments);
3283
- };
3284
- }
3285
-
3286
- if(!hasNative){
3287
-
3288
- ['poster', 'src'].forEach(function(prop){
3289
- webshims.defineNodeNamesProperty(prop == 'src' ? ['audio', 'video', 'source'] : ['video'], prop, {
3290
- //attr: {},
3291
- reflect: true,
3292
- propType: 'src'
3293
- });
3294
- });
3295
-
3296
-
3297
- ['autoplay', 'controls'].forEach(function(name){
3298
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], name);
3299
- });
3300
-
3301
- webshims.defineNodeNamesProperties(['audio', 'video'], {
3302
- HAVE_CURRENT_DATA: {
3303
- value: 2
3304
- },
3305
- HAVE_ENOUGH_DATA: {
3306
- value: 4
3307
- },
3308
- HAVE_FUTURE_DATA: {
3309
- value: 3
3310
- },
3311
- HAVE_METADATA: {
3312
- value: 1
3313
- },
3314
- HAVE_NOTHING: {
3315
- value: 0
3316
- },
3317
- NETWORK_EMPTY: {
3318
- value: 0
3319
- },
3320
- NETWORK_IDLE: {
3321
- value: 1
3322
- },
3323
- NETWORK_LOADING: {
3324
- value: 2
3325
- },
3326
- NETWORK_NO_SOURCE: {
3327
- value: 3
3328
- }
3329
-
3330
- }, 'prop');
3331
- }
3332
- });
3333
- jQuery.webshims.register('track', function($, webshims, window, document, undefined){
3334
- "use strict";
3335
- var mediaelement = webshims.mediaelement;
3336
- var id = new Date().getTime();
3337
- var ADDBACK = $.fn.addBack ? 'addBack' : 'andSelf';
3338
- //descriptions are not really shown, but they are inserted into the dom
3339
- var showTracks = {subtitles: 1, captions: 1, descriptions: 1};
3340
- var notImplemented = function(){
3341
- webshims.error('not implemented yet');
3342
- };
3343
- var dummyTrack = $('<track />');
3344
- var supportTrackMod = Modernizr.ES5 && Modernizr.objectAccessor;
3345
- var createEventTarget = function(obj){
3346
- var eventList = {};
3347
- obj.addEventListener = function(name, fn){
3348
- if(eventList[name]){
3349
- webshims.error('always use $.on to the shimed event: '+ name +' already bound fn was: '+ eventList[name] +' your fn was: '+ fn);
3350
- }
3351
- eventList[name] = fn;
3352
-
3353
- };
3354
- obj.removeEventListener = function(name, fn){
3355
- if(eventList[name] && eventList[name] != fn){
3356
- webshims.error('always use $.on/$.off to the shimed event: '+ name +' already bound fn was: '+ eventList[name] +' your fn was: '+ fn);
3357
- }
3358
- if(eventList[name]){
3359
- delete eventList[name];
3360
- }
3361
- };
3362
- return obj;
3363
- };
3364
-
3365
-
3366
- var cueListProto = {
3367
- getCueById: function(id){
3368
- var cue = null;
3369
- for(var i = 0, len = this.length; i < len; i++){
3370
- if(this[i].id === id){
3371
- cue = this[i];
3372
- break;
3373
- }
3374
- }
3375
- return cue;
3376
- }
3377
- };
3378
- var numericModes = {
3379
- 0: 'disabled',
3380
- 1: 'hidden',
3381
- 2: 'showing'
3382
- };
3383
-
3384
- var textTrackProto = {
3385
- shimActiveCues: null,
3386
- _shimActiveCues: null,
3387
- activeCues: null,
3388
- cues: null,
3389
- kind: 'subtitles',
3390
- label: '',
3391
- language: '',
3392
- mode: 'disabled',
3393
- readyState: 0,
3394
- oncuechange: null,
3395
- toString: function() {
3396
- return "[object TextTrack]";
3397
- },
3398
- addCue: function(cue){
3399
- if(!this.cues){
3400
- this.cues = mediaelement.createCueList();
3401
- } else {
3402
- var lastCue = this.cues[this.cues.length-1];
3403
- if(lastCue && lastCue.startTime > cue.startTime){
3404
- webshims.error("cue startTime higher than previous cue's startTime");
3405
- }
3406
- }
3407
- if(cue.track && cue.track.removeCue){
3408
- cue.track.removeCue(cue);
3409
- }
3410
- cue.track = this;
3411
- this.cues.push(cue);
3412
- },
3413
- //ToDo: make it more dynamic
3414
- removeCue: function(cue){
3415
- var cues = this.cues || [];
3416
- var i = 0;
3417
- var len = cues.length;
3418
- if(cue.track != this){
3419
- webshims.error("cue not part of track");
3420
- return;
3421
- }
3422
- for(; i < len; i++){
3423
- if(cues[i] === cue){
3424
- cues.splice(i, 1);
3425
- cue.track = null;
3426
- break;
3427
- }
3428
- }
3429
- if(cue.track){
3430
- webshims.error("cue not part of track");
3431
- return;
3432
- }
3433
- },
3434
- DISABLED: 'disabled',
3435
- OFF: 'disabled',
3436
- HIDDEN: 'hidden',
3437
- SHOWING: 'showing',
3438
- ERROR: 3,
3439
- LOADED: 2,
3440
- LOADING: 1,
3441
- NONE: 0
3442
- };
3443
- var copyProps = ['kind', 'label', 'srclang'];
3444
- var copyName = {srclang: 'language'};
3445
-
3446
- var owns = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
3447
-
3448
- var updateMediaTrackList = function(baseData, trackList){
3449
- var removed = [];
3450
- var added = [];
3451
- var newTracks = [];
3452
- var i, len;
3453
- if(!baseData){
3454
- baseData = webshims.data(this, 'mediaelementBase') || webshims.data(this, 'mediaelementBase', {});
3455
- }
3456
-
3457
- if(!trackList){
3458
- baseData.blockTrackListUpdate = true;
3459
- trackList = $.prop(this, 'textTracks');
3460
- baseData.blockTrackListUpdate = false;
3461
- }
3462
-
3463
- clearTimeout(baseData.updateTrackListTimer);
3464
-
3465
- $('track', this).each(function(){
3466
- var track = $.prop(this, 'track');
3467
- newTracks.push(track);
3468
- if(trackList.indexOf(track) == -1){
3469
- added.push(track);
3470
- }
3471
- });
3472
-
3473
- if(baseData.scriptedTextTracks){
3474
- for(i = 0, len = baseData.scriptedTextTracks.length; i < len; i++){
3475
- newTracks.push(baseData.scriptedTextTracks[i]);
3476
- if(trackList.indexOf(baseData.scriptedTextTracks[i]) == -1){
3477
- added.push(baseData.scriptedTextTracks[i]);
3478
- }
3479
- }
3480
- }
3481
-
3482
- for(i = 0, len = trackList.length; i < len; i++){
3483
- if(newTracks.indexOf(trackList[i]) == -1){
3484
- removed.push(trackList[i]);
3485
- }
3486
- }
3487
-
3488
- if(removed.length || added.length){
3489
- trackList.splice(0);
3490
-
3491
- for(i = 0, len = newTracks.length; i < len; i++){
3492
- trackList.push(newTracks[i]);
3493
- }
3494
- for(i = 0, len = removed.length; i < len; i++){
3495
- $([trackList]).triggerHandler($.Event({type: 'removetrack', track: removed[i]}));
3496
- }
3497
- for(i = 0, len = added.length; i < len; i++){
3498
- $([trackList]).triggerHandler($.Event({type: 'addtrack', track: added[i]}));
3499
- }
3500
- if(baseData.scriptedTextTracks || removed.length){
3501
- $(this).triggerHandler('updatetrackdisplay');
3502
- }
3503
- }
3504
- };
3505
-
3506
- var refreshTrack = function(track, trackData){
3507
- if(!trackData){
3508
- trackData = webshims.data(track, 'trackData');
3509
- }
3510
- if(trackData && !trackData.isTriggering){
3511
- trackData.isTriggering = true;
3512
- setTimeout(function(){
3513
- if(!(trackData.track || {}).readyState){
3514
- $(track).triggerHandler('checktrackmode');
3515
- } else {
3516
- $(track).closest('audio, video').triggerHandler('updatetrackdisplay');
3517
- }
3518
- trackData.isTriggering = false;
3519
- }, 1);
3520
- }
3521
- };
3522
-
3523
- var emptyDiv = $('<div />')[0];
3524
- window.TextTrackCue = function(startTime, endTime, text){
3525
- if(arguments.length != 3){
3526
- webshims.error("wrong arguments.length for TextTrackCue.constructor");
3527
- }
3528
-
3529
- this.startTime = startTime;
3530
- this.endTime = endTime;
3531
- this.text = text;
3532
-
3533
- this.id = "";
3534
- this.pauseOnExit = false;
3535
-
3536
- createEventTarget(this);
3537
- };
3538
-
3539
- window.TextTrackCue.prototype = {
3540
-
3541
- onenter: null,
3542
- onexit: null,
3543
- pauseOnExit: false,
3544
- getCueAsHTML: function(){
3545
- var lastText = "";
3546
- var parsedText = "";
3547
- var fragment = document.createDocumentFragment();
3548
- var fn;
3549
- if(!owns(this, 'getCueAsHTML')){
3550
- fn = this.getCueAsHTML = function(){
3551
- var i, len;
3552
- if(lastText != this.text){
3553
- lastText = this.text;
3554
- parsedText = mediaelement.parseCueTextToHTML(lastText);
3555
- emptyDiv.innerHTML = parsedText;
3556
-
3557
- for(i = 0, len = emptyDiv.childNodes.length; i < len; i++){
3558
- fragment.appendChild(emptyDiv.childNodes[i].cloneNode(true));
3559
- }
3560
- }
3561
- return fragment.cloneNode(true);
3562
- };
3563
-
3564
- }
3565
- return fn ? fn.apply(this, arguments) : fragment.cloneNode(true);
3566
- },
3567
- track: null,
3568
-
3569
-
3570
- id: ''
3571
- //todo-->
3572
- // ,
3573
- // snapToLines: true,
3574
- // line: 'auto',
3575
- // size: 100,
3576
- // position: 50,
3577
- // vertical: '',
3578
- // align: 'middle'
3579
- };
3580
-
3581
-
3582
-
3583
-
3584
-
3585
- mediaelement.createCueList = function(){
3586
- return $.extend([], cueListProto);
3587
- };
3588
-
3589
- mediaelement.parseCueTextToHTML = (function(){
3590
- var tagSplits = /(<\/?[^>]+>)/ig;
3591
- var allowedTags = /^(?:c|v|ruby|rt|b|i|u)/;
3592
- var regEnd = /\<\s*\//;
3593
- var addToTemplate = function(localName, attribute, tag, html){
3594
- var ret;
3595
- if(regEnd.test(html)){
3596
- ret = '</'+ localName +'>';
3597
- } else {
3598
- tag.splice(0, 1);
3599
- ret = '<'+ localName +' '+ attribute +'="'+ (tag.join(' ').replace(/\"/g, '&#34;')) +'">';
3600
- }
3601
- return ret;
3602
- };
3603
- var replacer = function(html){
3604
- var tag = html.replace(/[<\/>]+/ig,"").split(/[\s\.]+/);
3605
- if(tag[0]){
3606
- tag[0] = tag[0].toLowerCase();
3607
- if(allowedTags.test(tag[0])){
3608
- if(tag[0] == 'c'){
3609
- html = addToTemplate('span', 'class', tag, html);
3610
- } else if(tag[0] == 'v'){
3611
- html = addToTemplate('q', 'title', tag, html);
3612
- }
3613
- } else {
3614
- html = "";
3615
- }
3616
- }
3617
- return html;
3618
- };
3619
-
3620
- return function(cueText){
3621
- return cueText.replace(tagSplits, replacer);
3622
- };
3623
- })();
3624
-
3625
- mediaelement.loadTextTrack = function(mediaelem, track, trackData, _default){
3626
- var loadEvents = 'play playing timeupdate updatetrackdisplay';
3627
- var obj = trackData.track;
3628
- var load = function(){
3629
- var src = $.prop(track, 'src');
3630
- var error;
3631
- var ajax;
3632
- if(obj.mode != 'disabled' && src && $.attr(track, 'src')){
3633
- $(mediaelem).unbind(loadEvents, load);
3634
- $(track).unbind('checktrackmode', load);
3635
- if(!obj.readyState){
3636
- error = function(){
3637
- obj.readyState = 3;
3638
- obj.cues = null;
3639
- obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = null;
3640
- $(track).triggerHandler('error');
3641
- };
3642
- obj.readyState = 1;
3643
- try {
3644
- obj.cues = mediaelement.createCueList();
3645
- obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = mediaelement.createCueList();
3646
- ajax = $.ajax({
3647
- dataType: 'text',
3648
- url: src,
3649
- success: function(text){
3650
- if(ajax.getResponseHeader('content-type') != 'text/vtt'){
3651
- webshims.error('set the mime-type of your WebVTT files to text/vtt. see: http://dev.w3.org/html5/webvtt/#text/vtt');
3652
- }
3653
- mediaelement.parseCaptions(text, obj, function(cues){
3654
- if(cues && 'length' in cues){
3655
- obj.readyState = 2;
3656
- $(track).triggerHandler('load');
3657
- $(mediaelem).triggerHandler('updatetrackdisplay');
3658
- } else {
3659
- error();
3660
- }
3661
- });
3662
-
3663
- },
3664
- error: error
3665
- });
3666
- } catch(er){
3667
- error();
3668
- webshims.warn(er);
3669
- }
3670
- }
3671
- }
3672
- };
3673
- obj.readyState = 0;
3674
- obj.shimActiveCues = null;
3675
- obj._shimActiveCues = null;
3676
- obj.activeCues = null;
3677
- obj.cues = null;
3678
- $(mediaelem).unbind(loadEvents, load);
3679
- $(track).unbind('checktrackmode', load);
3680
- $(mediaelem).on(loadEvents, load);
3681
- $(track).on('checktrackmode', load);
3682
- if(_default){
3683
- obj.mode = showTracks[obj.kind] ? 'showing' : 'hidden';
3684
- load();
3685
- }
3686
- };
3687
-
3688
- mediaelement.createTextTrack = function(mediaelem, track){
3689
- var obj, trackData;
3690
- if(track.nodeName){
3691
- trackData = webshims.data(track, 'trackData');
3692
-
3693
- if(trackData){
3694
- refreshTrack(track, trackData);
3695
- obj = trackData.track;
3696
- }
3697
- }
3698
-
3699
- if(!obj){
3700
- obj = createEventTarget(webshims.objectCreate(textTrackProto));
3701
-
3702
- if(!supportTrackMod){
3703
- copyProps.forEach(function(copyProp){
3704
- var prop = $.prop(track, copyProp);
3705
- if(prop){
3706
- obj[copyName[copyProp] || copyProp] = prop;
3707
- }
3708
- });
3709
- }
3710
-
3711
-
3712
- if(track.nodeName){
3713
-
3714
- if(supportTrackMod){
3715
- copyProps.forEach(function(copyProp){
3716
- webshims.defineProperty(obj, copyName[copyProp] || copyProp, {
3717
- get: function(){
3718
- return $.prop(track, copyProp);
3719
- }
3720
- });
3721
- });
3722
- }
3723
-
3724
- trackData = webshims.data(track, 'trackData', {track: obj});
3725
- mediaelement.loadTextTrack(mediaelem, track, trackData, ($.prop(track, 'default') && $(track).siblings('track[default]')[ADDBACK]()[0] == track));
3726
- } else {
3727
- if(supportTrackMod){
3728
- copyProps.forEach(function(copyProp){
3729
- webshims.defineProperty(obj, copyName[copyProp] || copyProp, {
3730
- value: track[copyProp],
3731
- writeable: false
3732
- });
3733
- });
3734
- }
3735
- obj.cues = mediaelement.createCueList();
3736
- obj.activeCues = obj._shimActiveCues = obj.shimActiveCues = mediaelement.createCueList();
3737
- obj.mode = 'hidden';
3738
- obj.readyState = 2;
3739
- }
3740
- }
3741
- return obj;
3742
- };
3743
-
3744
-
3745
- /*
3746
- taken from:
3747
- Captionator 0.5.1 [CaptionCrunch]
3748
- Christopher Giffard, 2011
3749
- Share and enjoy
3750
-
3751
- https://github.com/cgiffard/Captionator
3752
-
3753
- modified for webshims
3754
- */
3755
- mediaelement.parseCaptionChunk = (function(){
3756
- // Set up timestamp parsers
3757
- var WebVTTTimestampParser = /^(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s+\-\-\>\s+(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s*(.*)/;
3758
- var GoogleTimestampParser = /^([\d\.]+)\s+\+([\d\.]+)\s*(.*)/;
3759
- var WebVTTDEFAULTSCueParser = /^(DEFAULTS|DEFAULT)\s+\-\-\>\s+(.*)/g;
3760
- var WebVTTSTYLECueParser = /^(STYLE|STYLES)\s+\-\-\>\s*\n([\s\S]*)/g;
3761
- var WebVTTCOMMENTCueParser = /^(COMMENT|COMMENTS)\s+\-\-\>\s+(.*)/g;
3762
-
3763
- return function(subtitleElement,objectCount){
3764
- var cueDefaults = [];
3765
-
3766
- var subtitleParts, timeIn, timeOut, html, timeData, subtitlePartIndex, cueSettings = "", id, specialCueData;
3767
- var timestampMatch, tmpCue;
3768
-
3769
- // WebVTT Special Cue Logic
3770
- if ((specialCueData = WebVTTDEFAULTSCueParser.exec(subtitleElement))) {
3771
- // cueDefaults = specialCueData.slice(2).join("");
3772
- // cueDefaults = cueDefaults.split(/\s+/g).filter(function(def) { return def && !!def.length; });
3773
- return null;
3774
- } else if ((specialCueData = WebVTTSTYLECueParser.exec(subtitleElement))) {
3775
- return null;
3776
- } else if ((specialCueData = WebVTTCOMMENTCueParser.exec(subtitleElement))) {
3777
- return null; // At this stage, we don't want to do anything with these.
3778
- }
3779
-
3780
- subtitleParts = subtitleElement.split(/\n/g);
3781
-
3782
- // Trim off any blank lines (logically, should only be max. one, but loop to be sure)
3783
- while (!subtitleParts[0].replace(/\s+/ig,"").length && subtitleParts.length > 0) {
3784
- subtitleParts.shift();
3785
- }
3786
-
3787
- if (subtitleParts[0].match(/^\s*[a-z0-9-\_]+\s*$/ig)) {
3788
- // The identifier becomes the cue ID (when *we* load the cues from file. Programatically created cues can have an ID of whatever.)
3789
- id = String(subtitleParts.shift().replace(/\s*/ig,""));
3790
- }
3791
-
3792
- for (subtitlePartIndex = 0; subtitlePartIndex < subtitleParts.length; subtitlePartIndex ++) {
3793
- var timestamp = subtitleParts[subtitlePartIndex];
3794
-
3795
- if ((timestampMatch = WebVTTTimestampParser.exec(timestamp))) {
3796
-
3797
- // WebVTT
3798
-
3799
- timeData = timestampMatch.slice(1);
3800
-
3801
- timeIn = parseInt((timeData[0]||0) * 60 * 60,10) + // Hours
3802
- parseInt((timeData[1]||0) * 60,10) + // Minutes
3803
- parseInt((timeData[2]||0),10) + // Seconds
3804
- parseFloat("0." + (timeData[3]||0)); // MS
3805
-
3806
- timeOut = parseInt((timeData[4]||0) * 60 * 60,10) + // Hours
3807
- parseInt((timeData[5]||0) * 60,10) + // Minutes
3808
- parseInt((timeData[6]||0),10) + // Seconds
3809
- parseFloat("0." + (timeData[7]||0)); // MS
3810
- /*
3811
- if (timeData[8]) {
3812
- cueSettings = timeData[8];
3813
- }
3814
- */
3815
- }
3816
-
3817
- // We've got the timestamp - return all the other unmatched lines as the raw subtitle data
3818
- subtitleParts = subtitleParts.slice(0,subtitlePartIndex).concat(subtitleParts.slice(subtitlePartIndex+1));
3819
- break;
3820
- }
3821
-
3822
- if (!timeIn && !timeOut) {
3823
- // We didn't extract any time information. Assume the cue is invalid!
3824
- webshims.warn("couldn't extract time information: "+[timeIn, timeOut, subtitleParts.join("\n"), id].join(' ; '));
3825
- return null;
3826
- }
3827
- /*
3828
- // Consolidate cue settings, convert defaults to object
3829
- var compositeCueSettings =
3830
- cueDefaults
3831
- .reduce(function(previous,current,index,array){
3832
- previous[current.split(":")[0]] = current.split(":")[1];
3833
- return previous;
3834
- },{});
3835
-
3836
- // Loop through cue settings, replace defaults with cue specific settings if they exist
3837
- compositeCueSettings =
3838
- cueSettings
3839
- .split(/\s+/g)
3840
- .filter(function(set) { return set && !!set.length; })
3841
- // Convert array to a key/val object
3842
- .reduce(function(previous,current,index,array){
3843
- previous[current.split(":")[0]] = current.split(":")[1];
3844
- return previous;
3845
- },compositeCueSettings);
3846
-
3847
- // Turn back into string like the TextTrackCue constructor expects
3848
- cueSettings = "";
3849
- for (var key in compositeCueSettings) {
3850
- if (compositeCueSettings.hasOwnProperty(key)) {
3851
- cueSettings += !!cueSettings.length ? " " : "";
3852
- cueSettings += key + ":" + compositeCueSettings[key];
3853
- }
3854
- }
3855
- */
3856
- // The remaining lines are the subtitle payload itself (after removing an ID if present, and the time);
3857
- html = subtitleParts.join("\n");
3858
- tmpCue = new TextTrackCue(timeIn, timeOut, html);
3859
- if(id){
3860
- tmpCue.id = id;
3861
- }
3862
- return tmpCue;
3863
- };
3864
- })();
3865
-
3866
- mediaelement.parseCaptions = function(captionData, track, complete) {
3867
- var subtitles = mediaelement.createCueList();
3868
- var cue, lazyProcess, regWevVTT;
3869
- var startDate;
3870
- var isWEBVTT;
3871
- if (captionData) {
3872
-
3873
- regWevVTT = /^WEBVTT(\s*FILE)?/ig;
3874
-
3875
- lazyProcess = function(i, len){
3876
-
3877
- for(; i < len; i++){
3878
- cue = captionData[i];
3879
- if(regWevVTT.test(cue)){
3880
- isWEBVTT = true;
3881
- } else if(cue.replace(/\s*/ig,"").length){
3882
- if(!isWEBVTT){
3883
- webshims.error('please use WebVTT format. This is the standard');
3884
- complete(null);
3885
- break;
3886
- }
3887
- cue = mediaelement.parseCaptionChunk(cue, i);
3888
- if(cue){
3889
- track.addCue(cue);
3890
- }
3891
- }
3892
- if(startDate < (new Date().getTime()) - 30){
3893
- i++;
3894
- setTimeout(function(){
3895
- startDate = new Date().getTime();
3896
- lazyProcess(i, len);
3897
- }, 90);
3898
-
3899
- break;
3900
- }
3901
- }
3902
- if(i >= len){
3903
- if(!isWEBVTT){
3904
- webshims.error('please use WebVTT format. This is the standard');
3905
- }
3906
- complete(track.cues);
3907
- }
3908
- };
3909
-
3910
- captionData = captionData.replace(/\r\n/g,"\n");
3911
-
3912
- setTimeout(function(){
3913
- captionData = captionData.replace(/\r/g,"\n");
3914
- setTimeout(function(){
3915
- startDate = new Date().getTime();
3916
- captionData = captionData.split(/\n\n+/g);
3917
- lazyProcess(0, captionData.length);
3918
- }, 9);
3919
- }, 9);
3920
-
3921
- } else {
3922
- webshims.error("Required parameter captionData not supplied.");
3923
- }
3924
- };
3925
-
3926
-
3927
- mediaelement.createTrackList = function(mediaelem, baseData){
3928
- baseData = baseData || webshims.data(mediaelem, 'mediaelementBase') || webshims.data(mediaelem, 'mediaelementBase', {});
3929
- if(!baseData.textTracks){
3930
- baseData.textTracks = [];
3931
- webshims.defineProperties(baseData.textTracks, {
3932
- onaddtrack: {value: null},
3933
- onremovetrack: {value: null}
3934
- });
3935
- createEventTarget(baseData.textTracks);
3936
- }
3937
- return baseData.textTracks;
3938
- };
3939
-
3940
- if(!Modernizr.track){
3941
- webshims.defineNodeNamesBooleanProperty(['track'], 'default');
3942
- webshims.reflectProperties(['track'], ['srclang', 'label']);
3943
-
3944
- webshims.defineNodeNameProperties('track', {
3945
- src: {
3946
- //attr: {},
3947
- reflect: true,
3948
- propType: 'src'
3949
- }
3950
- });
3951
- }
3952
-
3953
- webshims.defineNodeNameProperties('track', {
3954
- kind: {
3955
- attr: Modernizr.track ? {
3956
- set: function(value){
3957
- var trackData = webshims.data(this, 'trackData');
3958
- this.setAttribute('data-kind', value);
3959
- if(trackData){
3960
- trackData.attrKind = value;
3961
- }
3962
- },
3963
- get: function(){
3964
- var trackData = webshims.data(this, 'trackData');
3965
- if(trackData && ('attrKind' in trackData)){
3966
- return trackData.attrKind;
3967
- }
3968
- return this.getAttribute('kind');
3969
- }
3970
- } : {},
3971
- reflect: true,
3972
- propType: 'enumarated',
3973
- defaultValue: 'subtitles',
3974
- limitedTo: ['subtitles', 'captions', 'descriptions', 'chapters', 'metadata']
3975
- }
3976
- });
3977
-
3978
- $.each(copyProps, function(i, copyProp){
3979
- var name = copyName[copyProp] || copyProp;
3980
- webshims.onNodeNamesPropertyModify('track', copyProp, function(){
3981
- var trackData = webshims.data(this, 'trackData');
3982
- var track = this;
3983
- if(trackData){
3984
- if(copyProp == 'kind'){
3985
- refreshTrack(this, trackData);
3986
- }
3987
- if(!supportTrackMod){
3988
- trackData.track[name] = $.prop(this, copyProp);
3989
- }
3990
- clearTimeout(trackData.changedTrackPropTimer);
3991
- trackData.changedTrackPropTimer = setTimeout(function(){
3992
- $(track).trigger('updatesubtitlestate');
3993
- }, 1);
3994
- }
3995
- });
3996
- });
3997
-
3998
-
3999
- webshims.onNodeNamesPropertyModify('track', 'src', function(val){
4000
- if(val){
4001
- var data = webshims.data(this, 'trackData');
4002
- var media;
4003
- if(data){
4004
- media = $(this).closest('video, audio');
4005
- if(media[0]){
4006
- mediaelement.loadTextTrack(media, this, data);
4007
- }
4008
- }
4009
- }
4010
-
4011
- });
4012
-
4013
- //
4014
-
4015
- webshims.defineNodeNamesProperties(['track'], {
4016
- ERROR: {
4017
- value: 3
4018
- },
4019
- LOADED: {
4020
- value: 2
4021
- },
4022
- LOADING: {
4023
- value: 1
4024
- },
4025
- NONE: {
4026
- value: 0
4027
- },
4028
- readyState: {
4029
- get: function(){
4030
- return ($.prop(this, 'track') || {readyState: 0}).readyState;
4031
- },
4032
- writeable: false
4033
- },
4034
- track: {
4035
- get: function(){
4036
- return mediaelement.createTextTrack($(this).closest('audio, video')[0], this);
4037
- },
4038
- writeable: false
4039
- }
4040
- }, 'prop');
4041
-
4042
- webshims.defineNodeNamesProperties(['audio', 'video'], {
4043
- textTracks: {
4044
- get: function(){
4045
- var media = this;
4046
- var baseData = webshims.data(media, 'mediaelementBase') || webshims.data(media, 'mediaelementBase', {});
4047
- var tracks = mediaelement.createTrackList(media, baseData);
4048
- if(!baseData.blockTrackListUpdate){
4049
- updateMediaTrackList.call(media, baseData, tracks);
4050
- }
4051
- return tracks;
4052
- },
4053
- writeable: false
4054
- },
4055
- addTextTrack: {
4056
- value: function(kind, label, lang){
4057
- var textTrack = mediaelement.createTextTrack(this, {
4058
- kind: dummyTrack.prop('kind', kind || '').prop('kind'),
4059
- label: label || '',
4060
- srclang: lang || ''
4061
- });
4062
- var baseData = webshims.data(this, 'mediaelementBase') || webshims.data(this, 'mediaelementBase', {});
4063
- if (!baseData.scriptedTextTracks) {
4064
- baseData.scriptedTextTracks = [];
4065
- }
4066
- baseData.scriptedTextTracks.push(textTrack);
4067
- updateMediaTrackList.call(this);
4068
- return textTrack;
4069
- }
4070
- }
4071
- }, 'prop');
4072
-
4073
-
4074
- $(document).on('emptied ended updatetracklist', function(e){
4075
- if($(e.target).is('audio, video')){
4076
- var baseData = webshims.data(e.target, 'mediaelementBase');
4077
- if(baseData){
4078
- clearTimeout(baseData.updateTrackListTimer);
4079
- baseData.updateTrackListTimer = setTimeout(function(){
4080
- updateMediaTrackList.call(e.target, baseData);
4081
- }, 0);
4082
- }
4083
- }
4084
- });
4085
-
4086
- var getNativeReadyState = function(trackElem, textTrack){
4087
- return textTrack.readyState || trackElem.readyState;
4088
- };
4089
-
4090
- webshims.addReady(function(context, insertedElement){
4091
- var insertedMedia = insertedElement.filter('video, audio, track').closest('audio, video');
4092
- $('video, audio', context)
4093
- .add(insertedMedia)
4094
- .each(function(){
4095
- updateMediaTrackList.call(this);
4096
- })
4097
- .each(function(){
4098
- if(Modernizr.track){
4099
- var shimedTextTracks = $.prop(this, 'textTracks');
4100
- var origTextTracks = this.textTracks;
4101
- if(shimedTextTracks.length != origTextTracks.length){
4102
- webshims.error("textTracks couldn't be copied");
4103
- }
4104
-
4105
- $('track', this)
4106
- .each(function(){
4107
- var shimedTrack = $.prop(this, 'track');
4108
- var origTrack = this.track;
4109
- var kind;
4110
- var readyState;
4111
- if(origTrack){
4112
- kind = $.prop(this, 'kind');
4113
- readyState = getNativeReadyState(this, origTrack);
4114
- if (origTrack.mode || readyState) {
4115
- shimedTrack.mode = numericModes[origTrack.mode] || origTrack.mode;
4116
- }
4117
- //disable track from showing + remove UI
4118
- if(kind != 'descriptions'){
4119
- origTrack.mode = (typeof origTrack.mode == 'string') ? 'disabled' : 0;
4120
- this.kind = 'metadata';
4121
- $(this).attr({kind: kind});
4122
- }
4123
-
4124
- }
4125
- })
4126
- .on('load error', function(e){
4127
- if(e.originalEvent){
4128
- e.stopImmediatePropagation();
4129
- }
4130
- })
4131
- ;
4132
- }
4133
- })
4134
- ;
4135
- insertedMedia.each(function(){
4136
- var media = this;
4137
- var baseData = webshims.data(media, 'mediaelementBase');
4138
- if(baseData){
4139
- clearTimeout(baseData.updateTrackListTimer);
4140
- baseData.updateTrackListTimer = setTimeout(function(){
4141
- updateMediaTrackList.call(media, baseData);
4142
- }, 9);
4143
- }
4144
- });
4145
- });
4146
-
4147
- if(Modernizr.track){
4148
- $('video, audio').trigger('trackapichange');
4149
- }
4150
- });