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,6 +1,1318 @@
1
+ /*! SWFMini - a SWFObject 2.2 cut down version for webshims
2
+ *
3
+ * based on SWFObject v2.2 <http://code.google.com/p/swfobject/>
4
+ is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
5
+ */
6
+
7
+ var swfmini = function() {
8
+
9
+ var UNDEF = "undefined",
10
+ OBJECT = "object",
11
+ webshims = jQuery.webshims,
12
+ SHOCKWAVE_FLASH = "Shockwave Flash",
13
+ SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
14
+ FLASH_MIME_TYPE = "application/x-shockwave-flash",
15
+
16
+ win = window,
17
+ doc = document,
18
+ nav = navigator,
19
+
20
+ plugin = false,
21
+ domLoadFnArr = [main],
22
+ objIdArr = [],
23
+ listenersArr = [],
24
+ storedAltContent,
25
+ storedAltContentId,
26
+ storedCallbackFn,
27
+ storedCallbackObj,
28
+ isDomLoaded = false,
29
+ dynamicStylesheet,
30
+ dynamicStylesheetMedia,
31
+ autoHideShow = true,
32
+
33
+ /* Centralized function for browser feature detection
34
+ - User agent string detection is only used when no good alternative is possible
35
+ - Is executed directly for optimal performance
36
+ */
37
+ ua = function() {
38
+ var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
39
+ u = nav.userAgent.toLowerCase(),
40
+ p = nav.platform.toLowerCase(),
41
+ windows = p ? /win/.test(p) : /win/.test(u),
42
+ mac = p ? /mac/.test(p) : /mac/.test(u),
43
+ webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
44
+ ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
45
+ playerVersion = [0,0,0],
46
+ d = null;
47
+ if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
48
+ d = nav.plugins[SHOCKWAVE_FLASH].description;
49
+ if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
50
+ plugin = true;
51
+ ie = false; // cascaded feature detection for Internet Explorer
52
+ d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
53
+ playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
54
+ playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
55
+ playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
56
+ }
57
+ }
58
+ else if (typeof win.ActiveXObject != UNDEF) {
59
+ try {
60
+ var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
61
+ if (a) { // a will return null when ActiveX is disabled
62
+ d = a.GetVariable("$version");
63
+ if (d) {
64
+ ie = true; // cascaded feature detection for Internet Explorer
65
+ d = d.split(" ")[1].split(",");
66
+ playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
67
+ }
68
+ }
69
+ }
70
+ catch(e) {}
71
+ }
72
+ return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
73
+ }();
74
+
75
+
76
+ function callDomLoadFunctions() {
77
+ if (isDomLoaded) { return; }
78
+ try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
79
+ var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
80
+ t.parentNode.removeChild(t);
81
+ }
82
+ catch (e) { return; }
83
+ isDomLoaded = true;
84
+ var dl = domLoadFnArr.length;
85
+ for (var i = 0; i < dl; i++) {
86
+ domLoadFnArr[i]();
87
+ }
88
+ }
89
+
90
+ function addDomLoadEvent(fn) {
91
+ if (isDomLoaded) {
92
+ fn();
93
+ }
94
+ else {
95
+ domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
96
+ }
97
+ }
98
+
99
+ /* Cross-browser onload
100
+ - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
101
+ - Will fire an event as soon as a web page including all of its assets are loaded
102
+ */
103
+ function addLoadEvent(fn) {
104
+
105
+ }
106
+
107
+ /* Main function
108
+ - Will preferably execute onDomLoad, otherwise onload (as a fallback)
109
+ */
110
+ function main() {
111
+ if (plugin) {
112
+ testPlayerVersion();
113
+ }
114
+ }
115
+
116
+ /* Detect the Flash Player version for non-Internet Explorer browsers
117
+ - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
118
+ a. Both release and build numbers can be detected
119
+ b. Avoid wrong descriptions by corrupt installers provided by Adobe
120
+ c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
121
+ - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
122
+ */
123
+ function testPlayerVersion() {
124
+ var b = doc.getElementsByTagName("body")[0];
125
+ var o = createElement(OBJECT);
126
+ o.setAttribute("type", FLASH_MIME_TYPE);
127
+ var t = b.appendChild(o);
128
+ if (t) {
129
+ var counter = 0;
130
+ (function(){
131
+ if (typeof t.GetVariable != UNDEF) {
132
+ var d = t.GetVariable("$version");
133
+ if (d) {
134
+ d = d.split(" ")[1].split(",");
135
+ ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
136
+ }
137
+ }
138
+ else if (counter < 10) {
139
+ counter++;
140
+ setTimeout(arguments.callee, 10);
141
+ return;
142
+ }
143
+ b.removeChild(o);
144
+ t = null;
145
+ })();
146
+ }
147
+ }
148
+
149
+
150
+ function getObjectById(objectIdStr) {
151
+ var r = null;
152
+ var o = getElementById(objectIdStr);
153
+ if (o && o.nodeName == "OBJECT") {
154
+ if (typeof o.SetVariable != UNDEF) {
155
+ r = o;
156
+ }
157
+ else {
158
+ var n = o.getElementsByTagName(OBJECT)[0];
159
+ if (n) {
160
+ r = n;
161
+ }
162
+ }
163
+ }
164
+ return r;
165
+ }
166
+
167
+
168
+ /* Functions to abstract and display alternative content
169
+ */
170
+ function displayAltContent(obj) {
171
+ if (ua.ie && ua.win && obj.readyState != 4) {
172
+ // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
173
+ // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
174
+ var el = createElement("div");
175
+ obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
176
+ el.parentNode.replaceChild(abstractAltContent(obj), el);
177
+ obj.style.display = "none";
178
+ (function(){
179
+ if (obj.readyState == 4) {
180
+ obj.parentNode.removeChild(obj);
181
+ }
182
+ else {
183
+ setTimeout(arguments.callee, 10);
184
+ }
185
+ })();
186
+ }
187
+ else {
188
+ obj.parentNode.replaceChild(abstractAltContent(obj), obj);
189
+ }
190
+ }
191
+
192
+ function abstractAltContent(obj) {
193
+ var ac = createElement("div");
194
+ if (ua.win && ua.ie) {
195
+ ac.innerHTML = obj.innerHTML;
196
+ }
197
+ else {
198
+ var nestedObj = obj.getElementsByTagName(OBJECT)[0];
199
+ if (nestedObj) {
200
+ var c = nestedObj.childNodes;
201
+ if (c) {
202
+ var cl = c.length;
203
+ for (var i = 0; i < cl; i++) {
204
+ if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
205
+ ac.appendChild(c[i].cloneNode(true));
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }
211
+ return ac;
212
+ }
213
+
214
+ /* Cross-browser dynamic SWF creation
215
+ */
216
+ function createSWF(attObj, parObj, id) {
217
+ var r, el = getElementById(id);
218
+ if (ua.wk && ua.wk < 312) { return r; }
219
+ if (el) {
220
+ if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
221
+ attObj.id = id;
222
+ }
223
+ if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
224
+ var att = "";
225
+ for (var i in attObj) {
226
+ if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
227
+ if (i.toLowerCase() == "data") {
228
+ parObj.movie = attObj[i];
229
+ }
230
+ else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
231
+ att += ' class="' + attObj[i] + '"';
232
+ }
233
+ else if (i.toLowerCase() != "classid") {
234
+ att += ' ' + i + '="' + attObj[i] + '"';
235
+ }
236
+ }
237
+ }
238
+ var par = "";
239
+ for (var j in parObj) {
240
+ if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
241
+ par += '<param name="' + j + '" value="' + parObj[j] + '" />';
242
+ }
243
+ }
244
+ el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
245
+ objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
246
+ r = getElementById(attObj.id);
247
+ }
248
+ else { // well-behaving browsers
249
+ var o = createElement(OBJECT);
250
+ o.setAttribute("type", FLASH_MIME_TYPE);
251
+ for (var m in attObj) {
252
+ if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
253
+ if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
254
+ o.setAttribute("class", attObj[m]);
255
+ }
256
+ else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
257
+ o.setAttribute(m, attObj[m]);
258
+ }
259
+ }
260
+ }
261
+ for (var n in parObj) {
262
+ if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element
263
+ createObjParam(o, n, parObj[n]);
264
+ }
265
+ }
266
+ el.parentNode.replaceChild(o, el);
267
+ r = o;
268
+ }
269
+ }
270
+ return r;
271
+ }
272
+
273
+ function createObjParam(el, pName, pValue) {
274
+ var p = createElement("param");
275
+ p.setAttribute("name", pName);
276
+ p.setAttribute("value", pValue);
277
+ el.appendChild(p);
278
+ }
279
+
280
+ /* Cross-browser SWF removal
281
+ - Especially needed to safely and completely remove a SWF in Internet Explorer
282
+ */
283
+ function removeSWF(id) {
284
+ var obj = getElementById(id);
285
+ if (obj && obj.nodeName == "OBJECT") {
286
+ if (ua.ie && ua.win) {
287
+ obj.style.display = "none";
288
+ (function(){
289
+ if (obj.readyState == 4) {
290
+ removeObjectInIE(id);
291
+ }
292
+ else {
293
+ setTimeout(arguments.callee, 10);
294
+ }
295
+ })();
296
+ }
297
+ else {
298
+ obj.parentNode.removeChild(obj);
299
+ }
300
+ }
301
+ }
302
+
303
+ function removeObjectInIE(id) {
304
+ var obj = getElementById(id);
305
+ if (obj) {
306
+ for (var i in obj) {
307
+ if (typeof obj[i] == "function") {
308
+ obj[i] = null;
309
+ }
310
+ }
311
+ obj.parentNode.removeChild(obj);
312
+ }
313
+ }
314
+
315
+ /* Functions to optimize JavaScript compression
316
+ */
317
+ function getElementById(id) {
318
+ var el = null;
319
+ try {
320
+ el = doc.getElementById(id);
321
+ }
322
+ catch (e) {}
323
+ return el;
324
+ }
325
+
326
+ function createElement(el) {
327
+ return doc.createElement(el);
328
+ }
329
+
330
+ /* Updated attachEvent function for Internet Explorer
331
+ - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
332
+ */
333
+ function addListener(target, eventType, fn) {
334
+ target.attachEvent(eventType, fn);
335
+ listenersArr[listenersArr.length] = [target, eventType, fn];
336
+ }
337
+
338
+ /* Flash Player and SWF content version matching
339
+ */
340
+ function hasPlayerVersion(rv) {
341
+ var pv = ua.pv, v = rv.split(".");
342
+ v[0] = parseInt(v[0], 10);
343
+ v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
344
+ v[2] = parseInt(v[2], 10) || 0;
345
+ return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
346
+ }
347
+
348
+
349
+
350
+ function setVisibility(id, isVisible) {
351
+ if (!autoHideShow) { return; }
352
+ var elem;
353
+ var v = isVisible ? "visible" : "hidden";
354
+ if (isDomLoaded && (elem && getElementById(id))) {
355
+ getElementById(id).style.visibility = v;
356
+ }
357
+ }
358
+
359
+ /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
360
+ */
361
+ var cleanup = function() {
362
+ if (ua.ie && ua.win && window.attachEvent) {
363
+ window.attachEvent("onunload", function() {
364
+ // remove listeners to avoid memory leaks
365
+ var ll = listenersArr.length;
366
+ for (var i = 0; i < ll; i++) {
367
+ listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
368
+ }
369
+ // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
370
+ var il = objIdArr.length;
371
+ for (var j = 0; j < il; j++) {
372
+ removeSWF(objIdArr[j]);
373
+ }
374
+ // cleanup library's main closures to avoid memory leaks
375
+ for (var k in ua) {
376
+ ua[k] = null;
377
+ }
378
+ ua = null;
379
+ for (var l in swfmini) {
380
+ swfmini[l] = null;
381
+ }
382
+ swfmini = null;
383
+ });
384
+ }
385
+ }();
386
+
387
+ webshims.ready('DOM', callDomLoadFunctions);
388
+
389
+ return {
390
+ /* Public API
391
+ - Reference: http://code.google.com/p/swfobject/wiki/documentation
392
+ */
393
+ registerObject: function() {
394
+
395
+ },
396
+
397
+ getObjectById: function(objectIdStr) {
398
+ if (ua.w3) {
399
+ return getObjectById(objectIdStr);
400
+ }
401
+ },
402
+
403
+ embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
404
+ var callbackObj = {success:false, id:replaceElemIdStr};
405
+ if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
406
+ setVisibility(replaceElemIdStr, false);
407
+ addDomLoadEvent(function() {
408
+ widthStr += ""; // auto-convert to string
409
+ heightStr += "";
410
+ var att = {};
411
+ if (attObj && typeof attObj === OBJECT) {
412
+ for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
413
+ att[i] = attObj[i];
414
+ }
415
+ }
416
+ att.data = swfUrlStr;
417
+ att.width = widthStr;
418
+ att.height = heightStr;
419
+ var par = {};
420
+ if (parObj && typeof parObj === OBJECT) {
421
+ for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
422
+ par[j] = parObj[j];
423
+ }
424
+ }
425
+ if (flashvarsObj && typeof flashvarsObj === OBJECT) {
426
+ for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
427
+ if (typeof par.flashvars != UNDEF) {
428
+ par.flashvars += "&" + k + "=" + flashvarsObj[k];
429
+ }
430
+ else {
431
+ par.flashvars = k + "=" + flashvarsObj[k];
432
+ }
433
+ }
434
+ }
435
+ if (hasPlayerVersion(swfVersionStr)) { // create SWF
436
+ var obj = createSWF(att, par, replaceElemIdStr);
437
+ if (att.id == replaceElemIdStr) {
438
+ setVisibility(replaceElemIdStr, true);
439
+ }
440
+ callbackObj.success = true;
441
+ callbackObj.ref = obj;
442
+ }
443
+ else { // show alternative content
444
+ setVisibility(replaceElemIdStr, true);
445
+ }
446
+ if (callbackFn) { callbackFn(callbackObj); }
447
+ });
448
+ }
449
+ else if (callbackFn) { callbackFn(callbackObj); }
450
+ },
451
+
452
+ switchOffAutoHideShow: function() {
453
+ autoHideShow = false;
454
+ },
455
+
456
+ ua: ua,
457
+
458
+ getFlashPlayerVersion: function() {
459
+ return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
460
+ },
461
+
462
+ hasFlashPlayerVersion: hasPlayerVersion,
463
+
464
+ createSWF: function(attObj, parObj, replaceElemIdStr) {
465
+ if (ua.w3) {
466
+ return createSWF(attObj, parObj, replaceElemIdStr);
467
+ }
468
+ else {
469
+ return undefined;
470
+ }
471
+ },
472
+
473
+ showExpressInstall: function() {
474
+
475
+ },
476
+
477
+ removeSWF: function(objElemIdStr) {
478
+ if (ua.w3) {
479
+ removeSWF(objElemIdStr);
480
+ }
481
+ },
482
+
483
+ createCSS: function() {
484
+
485
+ },
486
+
487
+ addDomLoadEvent: addDomLoadEvent,
488
+
489
+ addLoadEvent: addLoadEvent,
490
+
491
+
492
+ // For internal usage only
493
+ expressInstallCallback: function() {
494
+
495
+ }
496
+ };
497
+ }();
498
+
499
+ // vim: ts=4 sts=4 sw=4 expandtab
500
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
501
+ // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
502
+ // -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
503
+ // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
504
+ // -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
505
+ // -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
506
+ // -- kossnocorp Sasha Koss XXX TODO License or CLA
507
+ // -- bryanforbes Bryan Forbes XXX TODO License or CLA
508
+ // -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
509
+ // -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
510
+ // -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
511
+ // -- bbqsrc Brendan Molloy XXX TODO License or CLA
512
+ // -- iwyg XXX TODO License or CLA
513
+ // -- DomenicDenicola Domenic Denicola XXX TODO License or CLA
514
+ // -- xavierm02 Montillet Xavier XXX TODO License or CLA
515
+ // -- Raynos Raynos XXX TODO License or CLA
516
+ // -- samsonjs Sami Samhuri XXX TODO License or CLA
517
+ // -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
518
+ // -- lexer Alexey Zakharov XXX TODO License or CLA
519
+
520
+ /*!
521
+ Copyright (c) 2009, 280 North Inc. http://280north.com/
522
+ MIT License. http://github.com/280north/narwhal/blob/master/README.md
523
+ */
524
+
525
+ (function (undefined) {
526
+
527
+ /**
528
+ * Brings an environment as close to ECMAScript 5 compliance
529
+ * as is possible with the facilities of erstwhile engines.
530
+ *
531
+ * ES5 Draft
532
+ * http://www.ecma-international.org/publications/files/drafts/tc39-2009-050.pdf
533
+ *
534
+ * NOTE: this is a draft, and as such, the URL is subject to change. If the
535
+ * link is broken, check in the parent directory for the latest TC39 PDF.
536
+ * http://www.ecma-international.org/publications/files/drafts/
537
+ *
538
+ * Previous ES5 Draft
539
+ * http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
540
+ * This is a broken link to the previous draft of ES5 on which most of the
541
+ * numbered specification references and quotes herein were taken. Updating
542
+ * these references and quotes to reflect the new document would be a welcome
543
+ * volunteer project.
544
+ *
545
+ * @module
546
+ */
547
+
548
+ /*whatsupdoc*/
549
+
550
+ // Shortcut to an often accessed properties, in order to avoid multiple
551
+ // dereference that costs universally.
552
+ // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
553
+ // us it in defining shortcuts.
554
+ var call = Function.prototype.call;
555
+ var prototypeOfArray = Array.prototype;
556
+ var prototypeOfObject = Object.prototype;
557
+ var slice = prototypeOfArray.slice;
558
+ var owns;
559
+ var toString;
560
+
561
+ // ES-5 15.3.4.5
562
+ // http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
563
+
564
+ if (!Function.prototype.bind) {
565
+ Function.prototype.bind = function (that) { // .length is 1
566
+ // 1. Let Target be the this value.
567
+ var target = this;
568
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
569
+ if (typeof target != "function")
570
+ throw new TypeError(); // TODO message
571
+ // 3. Let A be a new (possibly empty) internal list of all of the
572
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
573
+ // XXX slicedArgs will stand in for "A" if used
574
+ var args = slice.call(arguments, 1); // for normal call
575
+ // 4. Let F be a new native ECMAScript object.
576
+ // 9. Set the [[Prototype]] internal property of F to the standard
577
+ // built-in Function prototype object as specified in 15.3.3.1.
578
+ // 10. Set the [[Call]] internal property of F as described in
579
+ // 15.3.4.5.1.
580
+ // 11. Set the [[Construct]] internal property of F as described in
581
+ // 15.3.4.5.2.
582
+ // 12. Set the [[HasInstance]] internal property of F as described in
583
+ // 15.3.4.5.3.
584
+ // 13. The [[Scope]] internal property of F is unused and need not
585
+ // exist.
586
+ var bound = function () {
587
+
588
+ if (this instanceof bound) {
589
+ // 15.3.4.5.2 [[Construct]]
590
+ // When the [[Construct]] internal method of a function object,
591
+ // F that was created using the bind function is called with a
592
+ // list of arguments ExtraArgs the following steps are taken:
593
+ // 1. Let target be the value of F's [[TargetFunction]]
594
+ // internal property.
595
+ // 2. If target has no [[Construct]] internal method, a
596
+ // TypeError exception is thrown.
597
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
598
+ // property.
599
+ // 4. Let args be a new list containing the same values as the
600
+ // list boundArgs in the same order followed by the same
601
+ // values as the list ExtraArgs in the same order.
602
+
603
+ var F = function(){};
604
+ F.prototype = target.prototype;
605
+ var self = new F;
606
+
607
+ var result = target.apply(
608
+ self,
609
+ args.concat(slice.call(arguments))
610
+ );
611
+ if (result !== null && Object(result) === result)
612
+ return result;
613
+ return self;
614
+
615
+ } else {
616
+ // 15.3.4.5.1 [[Call]]
617
+ // When the [[Call]] internal method of a function object, F,
618
+ // which was created using the bind function is called with a
619
+ // this value and a list of arguments ExtraArgs the following
620
+ // steps are taken:
621
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
622
+ // property.
623
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
624
+ // property.
625
+ // 3. Let target be the value of F's [[TargetFunction]] internal
626
+ // property.
627
+ // 4. Let args be a new list containing the same values as the list
628
+ // boundArgs in the same order followed by the same values as
629
+ // the list ExtraArgs in the same order. 5. Return the
630
+ // result of calling the [[Call]] internal method of target
631
+ // providing boundThis as the this value and providing args
632
+ // as the arguments.
633
+
634
+ // equiv: target.call(this, ...boundArgs, ...args)
635
+ return target.apply(
636
+ that,
637
+ args.concat(slice.call(arguments))
638
+ );
639
+
640
+ }
641
+
642
+ };
643
+ // XXX bound.length is never writable, so don't even try
644
+ //
645
+ // 16. The length own property of F is given attributes as specified in
646
+ // 15.3.5.1.
647
+ // TODO
648
+ // 17. Set the [[Extensible]] internal property of F to true.
649
+ // TODO
650
+ // 18. Call the [[DefineOwnProperty]] internal method of F with
651
+ // arguments "caller", PropertyDescriptor {[[Value]]: null,
652
+ // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
653
+ // false}, and false.
654
+ // TODO
655
+ // 19. Call the [[DefineOwnProperty]] internal method of F with
656
+ // arguments "arguments", PropertyDescriptor {[[Value]]: null,
657
+ // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
658
+ // false}, and false.
659
+ // TODO
660
+ // NOTE Function objects created using Function.prototype.bind do not
661
+ // have a prototype property.
662
+ // XXX can't delete it in pure-js.
663
+ return bound;
664
+ };
665
+ }
666
+
667
+ toString = call.bind(prototypeOfObject.toString);
668
+ owns = call.bind(prototypeOfObject.hasOwnProperty);
669
+
670
+
671
+ //
672
+ // Array
673
+ // =====
674
+ //
675
+
676
+ // ES5 15.4.3.2
677
+ if (!Array.isArray) {
678
+ Array.isArray = function (obj) {
679
+ return toString(obj) == "[object Array]";
680
+ };
681
+ }
682
+
683
+ // The IsCallable() check in the Array functions
684
+ // has been replaced with a strict check on the
685
+ // internal class of the object to trap cases where
686
+ // the provided function was actually a regular
687
+ // expression literal, which in V8 and
688
+ // JavaScriptCore is a typeof "function". Only in
689
+ // V8 are regular expression literals permitted as
690
+ // reduce parameters, so it is desirable in the
691
+ // general case for the shim to match the more
692
+ // strict and common behavior of rejecting regular
693
+ // expressions.
694
+
695
+ // ES5 15.4.4.18
696
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
697
+ if (!Array.prototype.forEach) {
698
+ Array.prototype.forEach = function (fun /*, thisp*/) {
699
+ var self = toObject(this),
700
+ thisp = arguments[1],
701
+ i = 0,
702
+ length = self.length >>> 0;
703
+
704
+ // If no callback function or if callback is not a callable function
705
+ if (toString(fun) != "[object Function]") {
706
+ throw new TypeError(); // TODO message
707
+ }
708
+
709
+ while (i < length) {
710
+ if (i in self) {
711
+ // Invoke the callback function with call, passing arguments:
712
+ // context, property value, property key, thisArg object context
713
+ fun.call(thisp, self[i], i, self);
714
+ }
715
+ i++;
716
+ }
717
+ };
718
+ }
719
+
720
+ // ES5 15.4.4.19
721
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
722
+ if (!Array.prototype.map) {
723
+ Array.prototype.map = function (fun /*, thisp*/) {
724
+ var self = toObject(this),
725
+ length = self.length >>> 0,
726
+ result = Array(length),
727
+ thisp = arguments[1];
728
+
729
+ // If no callback function or if callback is not a callable function
730
+ if (toString(fun) != "[object Function]") {
731
+ throw new TypeError(); // TODO message
732
+ }
733
+
734
+ for (var i = 0; i < length; i++) {
735
+ if (i in self)
736
+ result[i] = fun.call(thisp, self[i], i, self);
737
+ }
738
+ return result;
739
+ };
740
+ }
741
+
742
+ // ES5 15.4.4.20
743
+ if (!Array.prototype.filter) {
744
+ Array.prototype.filter = function (fun /*, thisp */) {
745
+ var self = toObject(this),
746
+ length = self.length >>> 0,
747
+ result = [],
748
+ thisp = arguments[1];
749
+
750
+ // If no callback function or if callback is not a callable function
751
+ if (toString(fun) != "[object Function]") {
752
+ throw new TypeError(); // TODO message
753
+ }
754
+
755
+ for (var i = 0; i < length; i++) {
756
+ if (i in self && fun.call(thisp, self[i], i, self))
757
+ result.push(self[i]);
758
+ }
759
+ return result;
760
+ };
761
+ }
762
+
763
+ // ES5 15.4.4.16
764
+ if (!Array.prototype.every) {
765
+ Array.prototype.every = function (fun /*, thisp */) {
766
+ var self = toObject(this),
767
+ length = self.length >>> 0,
768
+ thisp = arguments[1];
769
+
770
+ // If no callback function or if callback is not a callable function
771
+ if (toString(fun) != "[object Function]") {
772
+ throw new TypeError(); // TODO message
773
+ }
774
+
775
+ for (var i = 0; i < length; i++) {
776
+ if (i in self && !fun.call(thisp, self[i], i, self))
777
+ return false;
778
+ }
779
+ return true;
780
+ };
781
+ }
782
+
783
+ // ES5 15.4.4.17
784
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
785
+ if (!Array.prototype.some) {
786
+ Array.prototype.some = function (fun /*, thisp */) {
787
+ var self = toObject(this),
788
+ length = self.length >>> 0,
789
+ thisp = arguments[1];
790
+
791
+ // If no callback function or if callback is not a callable function
792
+ if (toString(fun) != "[object Function]") {
793
+ throw new TypeError(); // TODO message
794
+ }
795
+
796
+ for (var i = 0; i < length; i++) {
797
+ if (i in self && fun.call(thisp, self[i], i, self))
798
+ return true;
799
+ }
800
+ return false;
801
+ };
802
+ }
803
+
804
+ // ES5 15.4.4.21
805
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
806
+ if (!Array.prototype.reduce) {
807
+ Array.prototype.reduce = function (fun /*, initial*/) {
808
+ var self = toObject(this),
809
+ length = self.length >>> 0;
810
+
811
+ // If no callback function or if callback is not a callable function
812
+ if (toString(fun) != "[object Function]") {
813
+ throw new TypeError(); // TODO message
814
+ }
815
+
816
+ // no value to return if no initial value and an empty array
817
+ if (!length && arguments.length == 1)
818
+ throw new TypeError(); // TODO message
819
+
820
+ var i = 0;
821
+ var result;
822
+ if (arguments.length >= 2) {
823
+ result = arguments[1];
824
+ } else {
825
+ do {
826
+ if (i in self) {
827
+ result = self[i++];
828
+ break;
829
+ }
830
+
831
+ // if array contains no values, no initial value to return
832
+ if (++i >= length)
833
+ throw new TypeError(); // TODO message
834
+ } while (true);
835
+ }
836
+
837
+ for (; i < length; i++) {
838
+ if (i in self)
839
+ result = fun.call(void 0, result, self[i], i, self);
840
+ }
841
+
842
+ return result;
843
+ };
844
+ }
845
+
846
+ // ES5 15.4.4.22
847
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
848
+ if (!Array.prototype.reduceRight) {
849
+ Array.prototype.reduceRight = function (fun /*, initial*/) {
850
+ var self = toObject(this),
851
+ length = self.length >>> 0;
852
+
853
+ // If no callback function or if callback is not a callable function
854
+ if (toString(fun) != "[object Function]") {
855
+ throw new TypeError(); // TODO message
856
+ }
857
+
858
+ // no value to return if no initial value, empty array
859
+ if (!length && arguments.length == 1)
860
+ throw new TypeError(); // TODO message
861
+
862
+ var result, i = length - 1;
863
+ if (arguments.length >= 2) {
864
+ result = arguments[1];
865
+ } else {
866
+ do {
867
+ if (i in self) {
868
+ result = self[i--];
869
+ break;
870
+ }
871
+
872
+ // if array contains no values, no initial value to return
873
+ if (--i < 0)
874
+ throw new TypeError(); // TODO message
875
+ } while (true);
876
+ }
877
+
878
+ do {
879
+ if (i in this)
880
+ result = fun.call(void 0, result, self[i], i, self);
881
+ } while (i--);
882
+
883
+ return result;
884
+ };
885
+ }
886
+
887
+ // ES5 15.4.4.14
888
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
889
+ if (!Array.prototype.indexOf) {
890
+ Array.prototype.indexOf = function (sought /*, fromIndex */ ) {
891
+ var self = toObject(this),
892
+ length = self.length >>> 0;
893
+
894
+ if (!length)
895
+ return -1;
896
+
897
+ var i = 0;
898
+ if (arguments.length > 1)
899
+ i = toInteger(arguments[1]);
900
+
901
+ // handle negative indices
902
+ i = i >= 0 ? i : length - Math.abs(i);
903
+ for (; i < length; i++) {
904
+ if (i in self && self[i] === sought) {
905
+ return i;
906
+ }
907
+ }
908
+ return -1;
909
+ };
910
+ }
911
+
912
+ // ES5 15.4.4.15
913
+ if (!Array.prototype.lastIndexOf) {
914
+ Array.prototype.lastIndexOf = function (sought /*, fromIndex */) {
915
+ var self = toObject(this),
916
+ length = self.length >>> 0;
917
+
918
+ if (!length)
919
+ return -1;
920
+ var i = length - 1;
921
+ if (arguments.length > 1)
922
+ i = toInteger(arguments[1]);
923
+ // handle negative indices
924
+ i = i >= 0 ? i : length - Math.abs(i);
925
+ for (; i >= 0; i--) {
926
+ if (i in self && sought === self[i])
927
+ return i;
928
+ }
929
+ return -1;
930
+ };
931
+ }
932
+
933
+ //
934
+ // Array
935
+ // =====
936
+ //
937
+
938
+ // ES5 15.4.4.12
939
+ // http://es5.github.com/#x15.4.4.12
940
+ // Default value for second param
941
+ // [bugfix, ielt9, old browsers]
942
+ // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
943
+ if([1,2].splice(0).length != 2) {
944
+ var _origArraySplice = Array.prototype.splice;
945
+
946
+ Array.prototype.splice = function(start, deleteCount) {
947
+ if(!arguments.length)return [];
948
+
949
+ return _origArraySplice.apply(this, [
950
+ start === void 0 ? 0 : start,
951
+ deleteCount === void 0 ? (this.length - start) : deleteCount
952
+ ].concat(slice.call(arguments, 2)))
953
+ };
954
+ }
955
+
956
+ //
957
+ // Object
958
+ // ======
959
+ //
960
+
961
+
962
+ // ES5 15.2.3.14
963
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
964
+ if (!Object.keys) {
965
+
966
+ var hasDontEnumBug = true,
967
+ dontEnums = [
968
+ "toString",
969
+ "toLocaleString",
970
+ "valueOf",
971
+ "hasOwnProperty",
972
+ "isPrototypeOf",
973
+ "propertyIsEnumerable",
974
+ "constructor"
975
+ ],
976
+ dontEnumsLength = dontEnums.length;
977
+
978
+ for (var key in {"toString": null})
979
+ hasDontEnumBug = false;
980
+
981
+ Object.keys = function keys(object) {
982
+
983
+ if ((typeof object != "object" && typeof object != "function") || object === null)
984
+ throw new TypeError("Object.keys called on a non-object");
985
+
986
+ var keys = [];
987
+ for (var name in object) {
988
+ if (owns(object, name)) {
989
+ keys.push(name);
990
+ }
991
+ }
992
+
993
+ if (hasDontEnumBug) {
994
+ for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
995
+ var dontEnum = dontEnums[i];
996
+ if (owns(object, dontEnum)) {
997
+ keys.push(dontEnum);
998
+ }
999
+ }
1000
+ }
1001
+
1002
+ return keys;
1003
+ };
1004
+
1005
+ }
1006
+
1007
+ //
1008
+ // Date
1009
+ // ====
1010
+ //
1011
+
1012
+ // ES5 15.9.5.43
1013
+ // Format a Date object as a string according to a simplified subset of the ISO 8601
1014
+ // standard as defined in 15.9.1.15.
1015
+ if (!Date.prototype.toISOString) {
1016
+ Date.prototype.toISOString = function toISOString() {
1017
+ var result, length, value;
1018
+ if (!isFinite(this))
1019
+ throw new RangeError;
1020
+
1021
+ // the date time string format is specified in 15.9.1.15.
1022
+ result = [this.getUTCFullYear(), this.getUTCMonth() + 1, this.getUTCDate(),
1023
+ this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
1024
+
1025
+ length = result.length;
1026
+ while (length--) {
1027
+ value = result[length];
1028
+ // pad months, days, hours, minutes, and seconds to have two digits.
1029
+ if (value < 10)
1030
+ result[length] = "0" + value;
1031
+ }
1032
+ // pad milliseconds to have three digits.
1033
+ return result.slice(0, 3).join("-") + "T" + result.slice(3).join(":") + "." +
1034
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
1035
+ }
1036
+ }
1037
+
1038
+ // ES5 15.9.4.4
1039
+ if (!Date.now) {
1040
+ Date.now = function now() {
1041
+ return new Date().getTime();
1042
+ };
1043
+ }
1044
+
1045
+ // ES5 15.9.5.44
1046
+ if (!Date.prototype.toJSON) {
1047
+ Date.prototype.toJSON = function toJSON(key) {
1048
+ // This function provides a String representation of a Date object for
1049
+ // use by JSON.stringify (15.12.3). When the toJSON method is called
1050
+ // with argument key, the following steps are taken:
1051
+
1052
+ // 1. Let O be the result of calling ToObject, giving it the this
1053
+ // value as its argument.
1054
+ // 2. Let tv be ToPrimitive(O, hint Number).
1055
+ // 3. If tv is a Number and is not finite, return null.
1056
+ // XXX
1057
+ // 4. Let toISO be the result of calling the [[Get]] internal method of
1058
+ // O with argument "toISOString".
1059
+ // 5. If IsCallable(toISO) is false, throw a TypeError exception.
1060
+ if (typeof this.toISOString != "function")
1061
+ throw new TypeError(); // TODO message
1062
+ // 6. Return the result of calling the [[Call]] internal method of
1063
+ // toISO with O as the this value and an empty argument list.
1064
+ return this.toISOString();
1065
+
1066
+ // NOTE 1 The argument is ignored.
1067
+
1068
+ // NOTE 2 The toJSON function is intentionally generic; it does not
1069
+ // require that its this value be a Date object. Therefore, it can be
1070
+ // transferred to other kinds of objects for use as a method. However,
1071
+ // it does require that any such object have a toISOString method. An
1072
+ // object is free to use the argument key to filter its
1073
+ // stringification.
1074
+ };
1075
+ }
1076
+
1077
+
1078
+ //
1079
+ // String
1080
+ // ======
1081
+ //
1082
+
1083
+ // ES5 15.5.4.20
1084
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1085
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1086
+ "\u2029\uFEFF";
1087
+ if (!String.prototype.trim || ws.trim()) {
1088
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1089
+ // http://perfectionkills.com/whitespace-deviations/
1090
+ ws = "[" + ws + "]";
1091
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1092
+ trimEndRegexp = new RegExp(ws + ws + "*$");
1093
+ String.prototype.trim = function trim() {
1094
+ return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
1095
+ };
1096
+ }
1097
+
1098
+ // ES5 15.5.4.14
1099
+ // http://es5.github.com/#x15.5.4.14
1100
+ // [bugfix, chrome]
1101
+ // 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.
1102
+ // "0".split(undefined, 0) -> []
1103
+ if("0".split(void 0, 0).length) {
1104
+ var oldSplit = String.prototype.split;
1105
+ String.prototype.split = function(separator, limit) {
1106
+ if(separator === void 0 && limit === 0)return [];
1107
+ return oldSplit.apply(this, arguments);
1108
+ }
1109
+ }
1110
+
1111
+ // ECMA-262, 3rd B.2.3
1112
+ // Note an ECMAScript standart, although ECMAScript 3rd Edition has a non-normative section suggesting uniform semantics
1113
+ // and it should be normalized across all browsers
1114
+ // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1115
+ if("".substr && "0b".substr(-1) !== "b") {
1116
+ var oldSubstr = String.prototype.substr;
1117
+ /**
1118
+ * Get the substring of a string
1119
+ * @param {integer} start where to start the substring
1120
+ * @param {integer} length how many characters to return
1121
+ * @return {string}
1122
+ */
1123
+ String.prototype.substr = function(start, length) {
1124
+ return oldSubstr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);
1125
+ }
1126
+ }
1127
+
1128
+ //
1129
+ // Util
1130
+ // ======
1131
+ //
1132
+
1133
+ // http://jsperf.com/to-integer
1134
+ var toInteger = function (n) {
1135
+ n = +n;
1136
+ if (n !== n) // isNaN
1137
+ n = -1;
1138
+ else if (n !== 0 && n !== (1/0) && n !== -(1/0))
1139
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
1140
+ return n;
1141
+ };
1142
+
1143
+ var prepareString = "a"[0] != "a",
1144
+ // ES5 9.9
1145
+ toObject = function (o) {
1146
+ if (o == null) { // this matches both null and undefined
1147
+ throw new TypeError(); // TODO message
1148
+ }
1149
+ // If the implementation doesn't support by-index access of
1150
+ // string characters (ex. IE < 7), split the string
1151
+ if (prepareString && typeof o == "string" && o) {
1152
+ return o.split("");
1153
+ }
1154
+ return Object(o);
1155
+ };
1156
+
1157
+ })();
1158
+
1159
+
1160
+
1161
+ (function($, shims){
1162
+ var defineProperty = 'defineProperty';
1163
+ var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
1164
+ //safari5 has defineProperty-interface, but it can't be used on dom-object
1165
+ //only do this test in non-IE browsers, because this hurts dhtml-behavior in some IE8 versions
1166
+ if (advancedObjectProperties && Object[defineProperty] && Object.prototype.__defineGetter__) {
1167
+ (function(){
1168
+ try {
1169
+ var foo = document.createElement('foo');
1170
+ Object[defineProperty](foo, 'bar', {
1171
+ get: function(){
1172
+ return true;
1173
+ }
1174
+ });
1175
+ advancedObjectProperties = !!foo.bar;
1176
+ }
1177
+ catch (e) {
1178
+ advancedObjectProperties = false;
1179
+ }
1180
+ foo = null;
1181
+ })();
1182
+ }
1183
+
1184
+ Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)));
1185
+ Modernizr.advancedObjectProperties = advancedObjectProperties;
1186
+
1187
+ if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
1188
+ var call = Function.prototype.call;
1189
+ var prototypeOfObject = Object.prototype;
1190
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
1191
+
1192
+ shims.objectCreate = function(proto, props, opts, no__proto__){
1193
+ var o;
1194
+ var f = function(){};
1195
+
1196
+ f.prototype = proto;
1197
+ o = new f();
1198
+
1199
+ if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
1200
+ o.__proto__ = proto;
1201
+ }
1202
+
1203
+ if(props){
1204
+ shims.defineProperties(o, props);
1205
+ }
1206
+
1207
+ if(opts){
1208
+ o.options = jQuery.extend(true, {}, o.options || {}, opts);
1209
+ opts = o.options;
1210
+ }
1211
+
1212
+ if(o._create && jQuery.isFunction(o._create)){
1213
+ o._create(opts);
1214
+ }
1215
+ return o;
1216
+ };
1217
+
1218
+ shims.defineProperties = function(object, props){
1219
+ for (var name in props) {
1220
+ if (owns(props, name)) {
1221
+ shims.defineProperty(object, name, props[name]);
1222
+ }
1223
+ }
1224
+ return object;
1225
+ };
1226
+
1227
+ var descProps = ['configurable', 'enumerable', 'writable'];
1228
+ shims.defineProperty = function(proto, property, descriptor){
1229
+ if(typeof descriptor != "object" || descriptor === null){return proto;}
1230
+
1231
+ if(owns(descriptor, "value")){
1232
+ proto[property] = descriptor.value;
1233
+ return proto;
1234
+ }
1235
+
1236
+ if(proto.__defineGetter__){
1237
+ if (typeof descriptor.get == "function") {
1238
+ proto.__defineGetter__(property, descriptor.get);
1239
+ }
1240
+ if (typeof descriptor.set == "function"){
1241
+ proto.__defineSetter__(property, descriptor.set);
1242
+ }
1243
+ }
1244
+ return proto;
1245
+ };
1246
+
1247
+ shims.getPrototypeOf = function (object) {
1248
+ return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
1249
+ };
1250
+
1251
+ //based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
1252
+ shims.getOwnPropertyDescriptor = function(obj, prop){
1253
+ if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
1254
+ throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
1255
+ }
1256
+ var descriptor;
1257
+ if(Object.defineProperty && Object.getOwnPropertyDescriptor){
1258
+ try{
1259
+ descriptor = Object.getOwnPropertyDescriptor(obj, prop);
1260
+ return descriptor;
1261
+ } catch(e){}
1262
+ }
1263
+ descriptor = {
1264
+ configurable: true,
1265
+ enumerable: true,
1266
+ writable: true,
1267
+ value: undefined
1268
+ };
1269
+ var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
1270
+ setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
1271
+ ;
1272
+
1273
+ if (!getter && !setter) { // not an accessor so return prop
1274
+ if(!owns(obj, prop)){
1275
+ return;
1276
+ }
1277
+ descriptor.value = obj[prop];
1278
+ return descriptor;
1279
+ }
1280
+
1281
+ // there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
1282
+ delete descriptor.writable;
1283
+ delete descriptor.value;
1284
+ descriptor.get = descriptor.set = undefined;
1285
+
1286
+ if(getter){
1287
+ descriptor.get = getter;
1288
+ }
1289
+
1290
+ if(setter){
1291
+ descriptor.set = setter;
1292
+ }
1293
+
1294
+ return descriptor;
1295
+ };
1296
+
1297
+ }
1298
+ })(jQuery, jQuery.webshims);
1299
+
1300
+
1301
+
1
1302
  //DOM-Extension helper
2
1303
  jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
3
1304
  "use strict";
1305
+
1306
+ webshims.assumeARIA = Modernizr.localstorage || Modernizr.video || Modernizr.boxsizing;
1307
+
1308
+ if($('<input type="email" />').attr('type') == 'text' || $('<form />').attr('novalidate') === "" || ('required' in $('<input />')[0].attributes)){
1309
+ webshims.error("IE browser modes are busted in IE10. Please test your HTML/CSS/JS with a real IE version or at least IETester or similiar tools");
1310
+ }
1311
+
1312
+ if(!$.parseHTML){
1313
+ webshims.error("Webshims needs jQuery 1.8+ to work properly. Please update your jQuery version or downgrade webshims.");
1314
+ }
1315
+
4
1316
  //shortcus
5
1317
  var modules = webshims.modules;
6
1318
  var listReg = /\s*,\s*/;
@@ -13,14 +1325,11 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
13
1325
  var modifyProps = {};
14
1326
 
15
1327
  var oldVal = $.fn.val;
16
- var singleVal = function(elem, name, val, pass, _argless){
17
- return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
18
- };
19
-
20
- $.fn.onTrigger = function(evt, fn){
21
- return this.on(evt, fn).each(fn);
1328
+ var singleVal = function(elem, name, val, pass, _argless){
1329
+ return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
22
1330
  };
23
1331
 
1332
+
24
1333
  $.fn.val = function(val){
25
1334
  var elem = this[0];
26
1335
  if(arguments.length && val == null){
@@ -49,6 +1358,9 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
49
1358
  }
50
1359
  });
51
1360
  };
1361
+ $.fn.onTrigger = function(evt, fn){
1362
+ return this.on(evt, fn).each(fn);
1363
+ };
52
1364
 
53
1365
  var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
54
1366
  var elementData = function(elem, key, val){
@@ -70,13 +1382,69 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
70
1382
 
71
1383
  [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
72
1384
  $.fn[data.name] = function(){
73
- return this.map(function(){
1385
+ var elems = [];
1386
+ this.each(function(){
74
1387
  var shadowData = elementData(this, 'shadowData');
75
- return shadowData && shadowData[data.prop] || this;
1388
+ var elem = shadowData && shadowData[data.prop] || this;
1389
+ if($.inArray(elem, elems) == -1){
1390
+ elems.push(elem);
1391
+ }
76
1392
  });
1393
+ return this.pushStack(elems);
77
1394
  };
78
1395
  });
79
1396
 
1397
+ if($.Tween.propHooks._default && $.css){
1398
+ (function(){
1399
+ var isjQ8 = false;
1400
+ try {
1401
+ isjQ8 = $.css($('<b style="width: 10px" />')[0], 'width', '') == '10px';
1402
+ } catch(er){
1403
+ webshims.error(er);
1404
+ }
1405
+ var css = isjQ8 ?
1406
+ function(elem, prop){
1407
+ return $.css( elem, prop, false, "" );
1408
+ } :
1409
+ function(elem, prop){
1410
+ return $.css( elem, prop, "" );
1411
+ }
1412
+ ;
1413
+
1414
+ $.extend($.Tween.propHooks._default, {
1415
+ get: function( tween ) {
1416
+ var result;
1417
+
1418
+ if ( (tween.elem[ tween.prop ] != null || havePolyfill[ tween.prop ]) &&
1419
+ (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
1420
+ return havePolyfill[ tween.prop ] ? $.prop(tween.elem, tween.prop) : tween.elem[ tween.prop ];
1421
+ }
1422
+
1423
+ // passing an empty string as a 3rd parameter to .css will automatically
1424
+ // attempt a parseFloat and fallback to a string if the parse fails
1425
+ // so, simple values such as "10px" are parsed to Float.
1426
+ // complex values such as "rotate(1rad)" are returned as is.
1427
+ result = css( tween.elem, tween.prop );
1428
+ // Empty strings, null, undefined and "auto" are converted to 0.
1429
+ return !result || result === "auto" ? 0 : result;
1430
+ },
1431
+ set: function( tween ) {
1432
+ // use step hook for back compat - use cssHook if its there - use .style if its
1433
+ // available and use plain properties where available
1434
+ if ( jQuery.fx.step[ tween.prop ] ) {
1435
+ jQuery.fx.step[ tween.prop ]( tween );
1436
+ } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
1437
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
1438
+ } else if( !havePolyfill[ tween.prop ] ) {
1439
+ tween.elem[ tween.prop ] = tween.now;
1440
+ } else {
1441
+ $.prop(tween.elem, tween.prop, tween.now);
1442
+ }
1443
+ }
1444
+ });
1445
+ })();
1446
+ }
1447
+
80
1448
 
81
1449
  ['removeAttr', 'prop', 'attr'].forEach(function(type){
82
1450
  olds[type] = $[type];
@@ -196,7 +1564,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
196
1564
  getSup('set', desc, oldDesc) :
197
1565
  (webshims.cfg.useStrict && prop == 'prop') ?
198
1566
  function(){throw(prop +' is readonly on '+ nodeName);} :
199
- $.noop
1567
+ function(){webshims.info(prop +' is readonly on '+ nodeName);}
200
1568
  ;
201
1569
  }
202
1570
  if(!desc.get){
@@ -214,15 +1582,14 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
214
1582
 
215
1583
  });
216
1584
 
217
- //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
218
- var isExtendNativeSave = Modernizr.ES5;
219
1585
  var extendNativeValue = (function(){
220
1586
  var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
221
1587
  var has = Object.prototype.hasOwnProperty;
1588
+ //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
1589
+ var isExtendNativeSave = Modernizr.advancedObjectProperties && Modernizr.objectAccessor;
222
1590
  return function(nodeName, prop, desc){
223
- var elem;
224
- var elemProto;
225
- if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
1591
+ var elem , elemProto;
1592
+ if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
226
1593
  var sup = elem[prop];
227
1594
  desc._supvalue = function(){
228
1595
  if(sup && sup.apply){
@@ -344,15 +1711,24 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
344
1711
  var ID = new Date().getTime();
345
1712
  return function(elem){
346
1713
  elem = $(elem);
347
- var id = elem.attr('id');
1714
+ var id = elem.prop('id');
348
1715
  if(!id){
349
1716
  ID++;
350
1717
  id = 'ID-'+ ID;
351
- elem.attr('id', id);
1718
+ elem.eq(0).prop('id', id);
352
1719
  }
353
1720
  return id;
354
1721
  };
355
1722
  })(),
1723
+ implement: function(elem, type){
1724
+ var data = elementData(elem, 'implemented') || elementData(elem, 'implemented', {});
1725
+ if(data[type]){
1726
+ webshims.info(type +' already implemented for element #'+elem.id);
1727
+ return false;
1728
+ }
1729
+ data[type] = true;
1730
+ return true;
1731
+ },
356
1732
  extendUNDEFProp: function(obj, props){
357
1733
  $.each(props, function(name, prop){
358
1734
  if( !(name in obj) ){
@@ -831,7 +2207,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
831
2207
  var callRegister = function(module){
832
2208
  if(registeredCallbacks[module]){
833
2209
  registeredCallbacks[module].forEach(function(data){
834
- data.callback();
2210
+ data.callback(currentLang, shortLang, '');
835
2211
  });
836
2212
  }
837
2213
  };
@@ -872,7 +2248,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
872
2248
  registeredCallbacks[lang.register] = [];
873
2249
  }
874
2250
  registeredCallbacks[lang.register].push(lang);
875
- lang.callback();
2251
+ lang.callback(currentLang, shortLang, '');
876
2252
  } else {
877
2253
  if(!lang.activeLang){
878
2254
  lang.activeLang = '';
@@ -909,8 +2285,20 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
909
2285
  });
910
2286
  //html5a11y
911
2287
  (function($, document){
912
- //if we support basic styleing or do not support ARIA (assumed) abort
913
- if(!Modernizr.localstorage || ('hidden' in document.createElement('a'))){return;}
2288
+ if(!$.webshims.assumeARIA || ('content' in document.createElement('template'))){return;}
2289
+
2290
+ $(function(){
2291
+ var main = $('main').attr({role: 'main'});
2292
+ if(main.length > 1){
2293
+ webshims.error('only one main element allowed in document');
2294
+ } else if(main.is('article *, section *')) {
2295
+ webshims.error('main not allowed inside of article/section elements');
2296
+ }
2297
+ });
2298
+
2299
+ if(('hidden' in document.createElement('a'))){
2300
+ return;
2301
+ }
914
2302
 
915
2303
  var elemMappings = {
916
2304
  article: "article",
@@ -926,6 +2314,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
926
2314
  }
927
2315
  };
928
2316
 
2317
+
929
2318
  $.webshims.addReady(function(context, contextElem){
930
2319
  $.each(elemMappings, function(name, role){
931
2320
  var elems = $(name, context).add(contextElem.filter(name));
@@ -937,6 +2326,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
937
2326
  var header = document.getElementsByTagName('header')[0];
938
2327
  var footers = document.getElementsByTagName('footer');
939
2328
  var footerLen = footers.length;
2329
+
940
2330
  if (header && !$(header).closest('section, article')[0]) {
941
2331
  addRole(header, 'banner');
942
2332
  }
@@ -952,1317 +2342,1578 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
952
2342
 
953
2343
  })(jQuery, document);
954
2344
 
955
- //additional tests for partial implementation of forms features
956
- (function($){
2345
+ (function($, Modernizr, webshims){
957
2346
  "use strict";
958
- var isWebkit = /webkit/i.test(navigator.userAgent);
959
- var Modernizr = window.Modernizr;
960
- var webshims = $.webshims;
2347
+ var hasNative = Modernizr.audio && Modernizr.video;
2348
+ var supportsLoop = false;
961
2349
  var bugs = webshims.bugs;
962
- var form = $('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /><input required="" name="a" /></form>');
963
- var testRequiredFind = function(){
964
- if(form[0].querySelector){
965
- try {
966
- bugs.findRequired = !(form[0].querySelector('select:required'));
967
- } catch(er){
968
- bugs.findRequired = false;
969
- }
970
- }
971
- };
972
- var inputElem = $('input', form).eq(0);
973
- var onDomextend = function(fn){
974
- webshims.loader.loadList(['dom-extend']);
975
- webshims.ready('dom-extend', fn);
976
- };
977
2350
 
978
- bugs.findRequired = false;
979
- bugs.validationMessage = false;
980
-
981
- webshims.capturingEventPrevented = function(e){
982
- if(!e._isPolyfilled){
983
- var isDefaultPrevented = e.isDefaultPrevented;
984
- var preventDefault = e.preventDefault;
985
- e.preventDefault = function(){
986
- clearTimeout($.data(e.target, e.type + 'DefaultPrevented'));
987
- $.data(e.target, e.type + 'DefaultPrevented', setTimeout(function(){
988
- $.removeData(e.target, e.type + 'DefaultPrevented');
989
- }, 30));
990
- return preventDefault.apply(this, arguments);
991
- };
992
- e.isDefaultPrevented = function(){
993
- return !!(isDefaultPrevented.apply(this, arguments) || $.data(e.target, e.type + 'DefaultPrevented') || false);
994
- };
995
- e._isPolyfilled = true;
996
- }
2351
+ var loadSwf = function(){
2352
+ webshims.ready(swfType, function(){
2353
+ if(!webshims.mediaelement.createSWF){
2354
+ webshims.mediaelement.loadSwf = true;
2355
+ webshims.reTest([swfType], hasNative);
2356
+ }
2357
+ });
997
2358
  };
998
-
999
- if(!Modernizr.formvalidation || bugs.bustedValidity){
1000
- testRequiredFind();
1001
- } else {
1002
- //create delegatable events
1003
- webshims.capturingEvents(['input']);
1004
- webshims.capturingEvents(['invalid'], true);
2359
+ var options = webshims.cfg.mediaelement;
2360
+ var swfType = 'mediaelement-jaris';
2361
+ var hasSwf;
2362
+ if(!options){
2363
+ webshims.error("mediaelement wasn't implemented but loaded");
2364
+ return;
2365
+ }
2366
+ if(hasNative){
2367
+ var videoElem = document.createElement('video');
2368
+ Modernizr.videoBuffered = ('buffered' in videoElem);
2369
+ supportsLoop = ('loop' in videoElem);
2370
+
2371
+ webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
1005
2372
 
1006
- if(window.opera || window.testGoodWithFix){
2373
+ if(!Modernizr.videoBuffered){
2374
+ webshims.addPolyfill('mediaelement-native-fix', {
2375
+ f: 'mediaelement',
2376
+ test: Modernizr.videoBuffered,
2377
+ d: ['dom-support']
2378
+ });
1007
2379
 
1008
- form.appendTo('head');
2380
+ webshims.reTest('mediaelement-native-fix');
2381
+ }
2382
+ }
2383
+
2384
+ if(hasNative && !options.preferFlash){
2385
+ var noSwitch = {
2386
+ 1: 1,
2387
+ 2: 1
2388
+ };
2389
+ var switchOptions = function(e){
2390
+ var media;
2391
+ var parent = e.target.parentNode;
2392
+ if(!options.preferFlash &&
2393
+ ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) &&
2394
+ (media = $(e.target).closest('audio, video')) && !noSwitch[media.prop('error')]
2395
+ ){
2396
+ $(function(){
2397
+ if(hasSwf && !options.preferFlash){
2398
+ loadSwf();
2399
+ webshims.ready('WINDOWLOAD '+swfType, function(){
2400
+ setTimeout(function(){
2401
+ if(!options.preferFlash && webshims.mediaelement.createSWF && !media.is('.nonnative-api-active')){
2402
+ options.preferFlash = true;
2403
+ document.removeEventListener('error', switchOptions, true);
2404
+ $('audio, video').each(function(){
2405
+ webshims.mediaelement.selectSource(this);
2406
+ });
2407
+ webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src+" Mediaerror: "+ media.prop('error'));
2408
+ }
2409
+ }, 9);
2410
+ });
2411
+ } else{
2412
+ document.removeEventListener('error', switchOptions, true);
2413
+ }
2414
+ });
2415
+ }
2416
+ };
2417
+ document.addEventListener('error', switchOptions, true);
2418
+ $('audio, video').each(function(){
2419
+ var error = $.prop(this, 'error');
2420
+ if(error && !noSwitch[error]){
2421
+ switchOptions({target: this});
2422
+ return false;
2423
+ }
2424
+ });
2425
+ }
2426
+
2427
+
2428
+ if(Modernizr.track && !bugs.track){
2429
+ (function(){
1009
2430
 
1010
- testRequiredFind();
1011
- bugs.validationMessage = !(inputElem.prop('validationMessage'));
2431
+ if(!bugs.track){
2432
+ bugs.track = typeof $('<track />')[0].readyState != 'number';
2433
+ }
1012
2434
 
1013
- webshims.reTest(['form-native-extend', 'form-message']);
2435
+ if(!bugs.track){
2436
+ try {
2437
+ new TextTrackCue(2, 3, '');
2438
+ } catch(e){
2439
+ bugs.track = true;
2440
+ }
2441
+ }
1014
2442
 
1015
- form.remove();
2443
+ var trackOptions = webshims.cfg.track;
2444
+ var trackListener = function(e){
2445
+ $(e.target).filter('track').each(changeApi);
2446
+ };
2447
+ var changeApi = function(){
2448
+ if(bugs.track || (!trackOptions.override && $.prop(this, 'readyState') == 3)){
2449
+ trackOptions.override = true;
2450
+ webshims.reTest('track');
2451
+ document.removeEventListener('error', trackListener, true);
2452
+ if(this && $.nodeName(this, 'track')){
2453
+ webshims.error("track support was overwritten. Please check your vtt including your vtt mime-type");
2454
+ } else {
2455
+ webshims.info("track support was overwritten. due to bad browser support");
2456
+ }
2457
+ return false;
2458
+ }
2459
+ };
2460
+ var detectTrackError = function(){
2461
+ document.addEventListener('error', trackListener, true);
1016
2462
 
1017
- $(function(){
1018
- onDomextend(function(){
1019
-
1020
- //Opera shows native validation bubbles in case of input.checkValidity()
1021
- // Opera 11.6/12 hasn't fixed this issue right, it's buggy
1022
- var preventDefault = function(e){
1023
- e.preventDefault();
1024
- };
1025
-
1026
- ['form', 'input', 'textarea', 'select'].forEach(function(name){
1027
- var desc = webshims.defineNodeNameProperty(name, 'checkValidity', {
1028
- prop: {
1029
- value: function(){
1030
- if (!webshims.fromSubmit) {
1031
- $(this).on('invalid.checkvalidity', preventDefault);
1032
- }
1033
-
1034
- webshims.fromCheckValidity = true;
1035
- var ret = desc.prop._supvalue.apply(this, arguments);
1036
- if (!webshims.fromSubmit) {
1037
- $(this).unbind('invalid.checkvalidity', preventDefault);
1038
- }
1039
- webshims.fromCheckValidity = false;
1040
- return ret;
1041
- }
1042
- }
1043
- });
1044
- });
1045
-
1046
- });
1047
- });
2463
+ if(bugs.track){
2464
+ changeApi();
2465
+ } else {
2466
+ $('track').each(changeApi);
2467
+ }
2468
+ };
2469
+ if(!trackOptions.override){
2470
+ if(webshims.isReady('track')){
2471
+ detectTrackError();
2472
+ } else {
2473
+ $(detectTrackError);
2474
+ }
2475
+ }
2476
+ })();
2477
+
2478
+ }
2479
+
2480
+ webshims.register('mediaelement-core', function($, webshims, window, document, undefined){
2481
+ hasSwf = swfmini.hasFlashPlayerVersion('9.0.115');
2482
+ $('html').addClass(hasSwf ? 'swf' : 'no-swf');
2483
+ var mediaelement = webshims.mediaelement;
2484
+ mediaelement.parseRtmp = function(data){
2485
+ var src = data.src.split('://');
2486
+ var paths = src[1].split('/');
2487
+ var i, len, found;
2488
+ data.server = src[0]+'://'+paths[0]+'/';
2489
+ data.streamId = [];
2490
+ for(i = 1, len = paths.length; i < len; i++){
2491
+ if(!found && paths[i].indexOf(':') !== -1){
2492
+ paths[i] = paths[i].split(':')[1];
2493
+ found = true;
2494
+ }
2495
+ if(!found){
2496
+ data.server += paths[i]+'/';
2497
+ } else {
2498
+ data.streamId.push(paths[i]);
2499
+ }
2500
+ }
2501
+ if(!data.streamId.length){
2502
+ webshims.error('Could not parse rtmp url');
2503
+ }
2504
+ data.streamId = data.streamId.join('/');
2505
+ };
2506
+ var getSrcObj = function(elem, nodeName){
2507
+ elem = $(elem);
2508
+ var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
2509
+ var tmp;
2510
+
2511
+ if(!src.src){return src;}
2512
+
2513
+ tmp = elem.attr('data-server');
2514
+ if(tmp != null){
2515
+ src.server = tmp;
1048
2516
  }
1049
2517
 
1050
- if(isWebkit && !webshims.bugs.bustedValidity){
1051
- (function(){
1052
- var elems = /^(?:textarea|input)$/i;
1053
- var form = false;
1054
-
1055
- document.addEventListener('contextmenu', function(e){
1056
- if(elems.test( e.target.nodeName || '') && (form = e.target.form)){
1057
- setTimeout(function(){
1058
- form = false;
1059
- }, 1);
1060
- }
1061
- }, false);
2518
+ tmp = elem.attr('type');
2519
+ if(tmp){
2520
+ src.type = tmp;
2521
+ src.container = $.trim(tmp.split(';')[0]);
2522
+ } else {
2523
+ if(!nodeName){
2524
+ nodeName = elem[0].nodeName.toLowerCase();
2525
+ if(nodeName == 'source'){
2526
+ nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
2527
+ }
2528
+ }
2529
+ if(src.server){
2530
+ src.type = nodeName+'/rtmp';
2531
+ src.container = nodeName+'/rtmp';
2532
+ } else {
1062
2533
 
1063
- $(window).on('invalid', function(e){
1064
- if(e.originalEvent && form && form == e.target.form){
1065
- e.wrongWebkitInvalid = true;
1066
- e.stopImmediatePropagation();
1067
- }
1068
- });
2534
+ tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
1069
2535
 
1070
- })();
2536
+ if(tmp){
2537
+ src.type = tmp;
2538
+ src.container = tmp;
2539
+ }
2540
+ }
1071
2541
  }
1072
- }
2542
+ tmp = elem.attr('media');
2543
+ if(tmp){
2544
+ src.media = tmp;
2545
+ }
2546
+ if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
2547
+ if(src.server){
2548
+ src.streamId = src.src;
2549
+ } else {
2550
+ mediaelement.parseRtmp(src);
2551
+ }
2552
+ }
2553
+ return src;
2554
+ };
1073
2555
 
1074
-
1075
-
1076
- jQuery.webshims.register('form-core', function($, webshims, window, document, undefined, options){
1077
- "use strict";
1078
2556
 
1079
2557
 
1080
- var checkTypes = {checkbox: 1, radio: 1};
1081
- var emptyJ = $([]);
1082
- var bugs = webshims.bugs;
1083
- var groupTypes = {radio: 1};
1084
- var getGroupElements = function(elem){
1085
- elem = $(elem);
1086
- var name;
1087
- var form;
1088
- var ret = emptyJ;
1089
- if(groupTypes[elem[0].type]){
1090
- form = elem.prop('form');
1091
- name = elem[0].name;
1092
- if(!name){
1093
- ret = elem;
1094
- } else if(form){
1095
- ret = $(form[name]);
1096
- } else {
1097
- ret = $(document.getElementsByName(name)).filter(function(){
1098
- return !$.prop(this, 'form');
1099
- });
1100
- }
1101
- ret = ret.filter('[type="radio"]');
2558
+ var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
2559
+
2560
+ var loadTrackUi = function(){
2561
+ if(loadTrackUi.loaded){return;}
2562
+ loadTrackUi.loaded = true;
2563
+ $(function(){
2564
+ webshims.loader.loadList(['track-ui']);
2565
+ });
2566
+ };
2567
+ var loadYt = (function(){
2568
+ var loaded;
2569
+ return function(){
2570
+ if(loaded || !hasYt){return;}
2571
+ loaded = true;
2572
+ webshims.loader.loadScript("https://www.youtube.com/player_api");
2573
+ $(function(){
2574
+ webshims._polyfill(["mediaelement-yt"]);
2575
+ });
2576
+ };
2577
+ })();
2578
+ var loadThird = function(){
2579
+ if(hasSwf){
2580
+ loadSwf();
2581
+ } else {
2582
+ loadYt();
1102
2583
  }
1103
- return ret;
1104
2584
  };
1105
2585
 
1106
- var getContentValidationMessage = webshims.getContentValidationMessage = function(elem, validity, key){
1107
- var message = $(elem).data('errormessage') || elem.getAttribute('x-moz-errormessage') || '';
1108
- if(key && message[key]){
1109
- message = message[key];
1110
- }
1111
- if(typeof message == 'object'){
1112
- validity = validity || $.prop(elem, 'validity') || {valid: 1};
1113
- if(!validity.valid){
1114
- $.each(validity, function(name, prop){
1115
- if(prop && name != 'valid' && message[name]){
1116
- message = message[name];
1117
- return false;
1118
- }
1119
- });
2586
+ webshims.addPolyfill('mediaelement-yt', {
2587
+ test: !hasYt,
2588
+ d: ['dom-support']
2589
+ });
2590
+
2591
+ mediaelement.mimeTypes = {
2592
+ audio: {
2593
+ //ogm shouldn´t be used!
2594
+ 'audio/ogg': ['ogg','oga', 'ogm'],
2595
+ 'audio/ogg;codecs="opus"': 'opus',
2596
+ 'audio/mpeg': ['mp2','mp3','mpga','mpega'],
2597
+ 'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
2598
+ 'audio/wav': ['wav'],
2599
+ 'audio/3gpp': ['3gp','3gpp'],
2600
+ 'audio/webm': ['webm'],
2601
+ 'audio/fla': ['flv', 'f4a', 'fla'],
2602
+ 'application/x-mpegURL': ['m3u8', 'm3u']
2603
+ },
2604
+ video: {
2605
+ //ogm shouldn´t be used!
2606
+ 'video/ogg': ['ogg','ogv', 'ogm'],
2607
+ 'video/mpeg': ['mpg','mpeg','mpe'],
2608
+ 'video/mp4': ['mp4','mpg4', 'm4v'],
2609
+ 'video/quicktime': ['mov','qt'],
2610
+ 'video/x-msvideo': ['avi'],
2611
+ 'video/x-ms-asf': ['asf', 'asx'],
2612
+ 'video/flv': ['flv', 'f4v'],
2613
+ 'video/3gpp': ['3gp','3gpp'],
2614
+ 'video/webm': ['webm'],
2615
+ 'application/x-mpegURL': ['m3u8', 'm3u'],
2616
+ 'video/MP2T': ['ts']
1120
2617
  }
1121
2618
  }
2619
+ ;
2620
+
2621
+ mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
2622
+
2623
+ mediaelement.getTypeForSrc = function(src, nodeName, data){
2624
+ if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
2625
+ return 'video/youtube';
2626
+ }
2627
+ if(src.indexOf('rtmp') === 0){
2628
+ return nodeName+'/rtmp';
2629
+ }
2630
+ src = src.split('?')[0].split('.');
2631
+ src = src[src.length - 1];
2632
+ var mt;
1122
2633
 
1123
- if(typeof message == 'object'){
1124
- message = message.defaultMessage;
2634
+ $.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
2635
+ if(exts.indexOf(src) !== -1){
2636
+ mt = mimeType;
2637
+ return false;
2638
+ }
2639
+ });
2640
+ return mt;
2641
+ };
2642
+
2643
+
2644
+ mediaelement.srces = function(mediaElem, srces){
2645
+ mediaElem = $(mediaElem);
2646
+ if(!srces){
2647
+ srces = [];
2648
+ var nodeName = mediaElem[0].nodeName.toLowerCase();
2649
+ var src = getSrcObj(mediaElem, nodeName);
2650
+
2651
+ if(!src.src){
2652
+
2653
+ $('source', mediaElem).each(function(){
2654
+ src = getSrcObj(this, nodeName);
2655
+ if(src.src){srces.push(src);}
2656
+ });
2657
+ } else {
2658
+ srces.push(src);
2659
+ }
2660
+ return srces;
2661
+ } else {
2662
+ mediaElem.removeAttr('src').removeAttr('type').find('source').remove();
2663
+ if(!$.isArray(srces)){
2664
+ srces = [srces];
2665
+ }
2666
+ srces.forEach(function(src){
2667
+ var source = document.createElement('source');
2668
+ if(typeof src == 'string'){
2669
+ src = {src: src};
2670
+ }
2671
+ source.setAttribute('src', src.src);
2672
+ if(src.type){
2673
+ source.setAttribute('type', src.type);
2674
+ }
2675
+ if(src.media){
2676
+ source.setAttribute('media', src.media);
2677
+ }
2678
+ mediaElem.append(source);
2679
+ });
2680
+
1125
2681
  }
1126
- return message || '';
1127
2682
  };
1128
2683
 
1129
- /*
1130
- * Selectors for all browsers
1131
- */
1132
- var rangeTypes = {number: 1, range: 1, date: 1/*, time: 1, 'datetime-local': 1, datetime: 1, month: 1, week: 1*/};
1133
- var hasInvalid = function(elem){
1134
- var ret = false;
1135
- $($.prop(elem, 'elements')).each(function(){
1136
- ret = $(this).is(':invalid');
1137
- if(ret){
1138
- return false;
2684
+
2685
+ $.fn.loadMediaSrc = function(srces, poster){
2686
+ return this.each(function(){
2687
+ if(poster !== undefined){
2688
+ $(this).removeAttr('poster');
2689
+ if(poster){
2690
+ $.attr(this, 'poster', poster);
2691
+ }
1139
2692
  }
2693
+ mediaelement.srces(this, srces);
2694
+ $(this).mediaLoad();
1140
2695
  });
2696
+ };
2697
+
2698
+ mediaelement.swfMimeTypes = ['video/3gpp', 'video/x-msvideo', 'video/quicktime', 'video/x-m4v', 'video/mp4', 'video/m4p', 'video/x-flv', 'video/flv', 'audio/mpeg', 'audio/aac', 'audio/mp4', 'audio/x-m4a', 'audio/m4a', 'audio/mp3', 'audio/x-fla', 'audio/fla', 'youtube/flv', 'video/jarisplayer', 'jarisplayer/jarisplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
2699
+
2700
+ mediaelement.canThirdPlaySrces = function(mediaElem, srces){
2701
+ var ret = '';
2702
+ if(hasSwf || hasYt){
2703
+ mediaElem = $(mediaElem);
2704
+ srces = srces || mediaelement.srces(mediaElem);
2705
+ $.each(srces, function(i, src){
2706
+ if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
2707
+ ret = src;
2708
+ return false;
2709
+ }
2710
+ });
2711
+
2712
+ }
2713
+
1141
2714
  return ret;
1142
2715
  };
1143
- $.extend($.expr[":"], {
1144
- "valid-element": function(elem){
1145
- return $.nodeName(elem, 'form') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
1146
- },
1147
- "invalid-element": function(elem){
1148
- return $.nodeName(elem, 'form') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
1149
- },
1150
- "required-element": function(elem){
1151
- return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
1152
- },
1153
- "user-error": function(elem){
1154
- return ($.prop(elem, 'willValidate') && $(elem).hasClass('user-error'));
1155
- },
1156
- "optional-element": function(elem){
1157
- return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
1158
- },
1159
- "in-range": function(elem){
1160
- if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1161
- return false;
2716
+
2717
+ var nativeCanPlayType = {};
2718
+ mediaelement.canNativePlaySrces = function(mediaElem, srces){
2719
+ var ret = '';
2720
+ if(hasNative){
2721
+ mediaElem = $(mediaElem);
2722
+ var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
2723
+ var nativeCanPlay = (nativeCanPlayType[nodeName] || {prop: {_supvalue: false}}).prop._supvalue || mediaElem[0].canPlayType;
2724
+ if(!nativeCanPlay){return ret;}
2725
+ srces = srces || mediaelement.srces(mediaElem);
2726
+
2727
+ $.each(srces, function(i, src){
2728
+ if(src.type && nativeCanPlay.call(mediaElem[0], src.type) ){
2729
+ ret = src;
2730
+ return false;
2731
+ }
2732
+ });
2733
+ }
2734
+ return ret;
2735
+ };
2736
+
2737
+ mediaelement.setError = function(elem, message){
2738
+ if(!message){
2739
+ message = "can't play sources";
2740
+ }
2741
+
2742
+ $(elem).pause().data('mediaerror', message);
2743
+ webshims.error('mediaelementError: '+ message);
2744
+ setTimeout(function(){
2745
+ if($(elem).data('mediaerror')){
2746
+ $(elem).trigger('mediaerror');
1162
2747
  }
1163
- var val = $.prop(elem, 'validity');
1164
- return !!(val && !val.rangeOverflow && !val.rangeUnderflow);
1165
- },
1166
- "out-of-range": function(elem){
1167
- if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1168
- return false;
2748
+ }, 1);
2749
+ };
2750
+
2751
+ var handleThird = (function(){
2752
+ var requested;
2753
+ return function( mediaElem, ret, data ){
2754
+ if(!requested){
2755
+ loadTrackUi();
2756
+ }
2757
+ webshims.ready(hasSwf ? swfType : 'mediaelement-yt', function(){
2758
+ if(mediaelement.createSWF){
2759
+ mediaelement.createSWF( mediaElem, ret, data );
2760
+ } else if(!requested) {
2761
+ requested = true;
2762
+ loadThird();
2763
+ //readd to ready
2764
+ handleThird( mediaElem, ret, data );
2765
+ }
2766
+ });
2767
+ if(!requested && hasYt && !mediaelement.createSWF){
2768
+ loadYt();
2769
+ }
2770
+ };
2771
+ })();
2772
+
2773
+ var stepSources = function(elem, data, useSwf, _srces, _noLoop){
2774
+ var ret;
2775
+ if(useSwf || (useSwf !== false && data && data.isActive == 'third')){
2776
+ ret = mediaelement.canThirdPlaySrces(elem, _srces);
2777
+ if(!ret){
2778
+ if(_noLoop){
2779
+ mediaelement.setError(elem, false);
2780
+ } else {
2781
+ stepSources(elem, data, false, _srces, true);
2782
+ }
2783
+ } else {
2784
+ handleThird(elem, ret, data);
2785
+ }
2786
+ } else {
2787
+ ret = mediaelement.canNativePlaySrces(elem, _srces);
2788
+ if(!ret){
2789
+ if(_noLoop){
2790
+ mediaelement.setError(elem, false);
2791
+ if(data && data.isActive == 'third') {
2792
+ mediaelement.setActive(elem, 'html5', data);
2793
+ }
2794
+ } else {
2795
+ stepSources(elem, data, true, _srces, true);
2796
+ }
2797
+ } else if(data && data.isActive == 'third') {
2798
+ mediaelement.setActive(elem, 'html5', data);
1169
2799
  }
1170
- var val = $.prop(elem, 'validity');
1171
- return !!(val && (val.rangeOverflow || val.rangeUnderflow));
1172
2800
  }
2801
+ };
2802
+ var stopParent = /^(?:embed|object|datalist)$/i;
2803
+ var selectSource = function(elem, data){
2804
+ var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
2805
+ var _srces = mediaelement.srces(elem);
2806
+ var parent = elem.parentNode;
1173
2807
 
1174
- });
1175
-
1176
- ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
1177
- $.expr[":"][name] = $.expr.filters[name+"-element"];
1178
- });
2808
+ clearTimeout(baseData.loadTimer);
2809
+ $.data(elem, 'mediaerror', false);
2810
+
2811
+ if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
2812
+ data = data || webshims.data(elem, 'mediaelement');
2813
+ stepSources(elem, data, options.preferFlash || undefined, _srces);
2814
+ };
2815
+ mediaelement.selectSource = selectSource;
1179
2816
 
1180
2817
 
1181
- $.expr[":"].focus = function( elem ) {
1182
- try {
1183
- var doc = elem.ownerDocument;
1184
- return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus());
1185
- } catch(e){}
1186
- return false;
1187
- };
2818
+ $(document).on('ended', function(e){
2819
+ var data = webshims.data(e.target, 'mediaelement');
2820
+ if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
2821
+ setTimeout(function(){
2822
+ if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
2823
+ $(e.target).prop('currentTime', 0).play();
2824
+ }, 1);
2825
+
2826
+ });
1188
2827
 
1189
- if(Modernizr.formvalidation && isWebkit && !webshims.bugs.bustedValidity){
1190
- (function(){
1191
- var retriggerRadioValidity = function(){
1192
- var validity;
1193
- if((validity = this.validity) && !validity.customError){
1194
- this.setCustomValidity('');
2828
+ webshims.ready('dom-support', function(){
2829
+ if(!supportsLoop){
2830
+ webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
2831
+ }
2832
+
2833
+ ['audio', 'video'].forEach(function(nodeName){
2834
+ var supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
2835
+ prop: {
2836
+ value: function(){
2837
+ var data = webshims.data(this, 'mediaelement');
2838
+ selectSource(this, data);
2839
+ if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
2840
+ supLoad.prop._supvalue.apply(this, arguments);
2841
+ }
2842
+ }
2843
+ }
2844
+ });
2845
+ nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
2846
+ prop: {
2847
+ value: function(type){
2848
+ var ret = '';
2849
+ if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
2850
+ ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
2851
+ if(ret == 'no'){
2852
+ ret = '';
2853
+ }
2854
+ }
2855
+ if(!ret && hasSwf){
2856
+ type = $.trim((type || '').split(';')[0]);
2857
+ if(mediaelement.swfMimeTypes.indexOf(type) != -1){
2858
+ ret = 'maybe';
2859
+ }
2860
+ }
2861
+ return ret;
2862
+ }
2863
+ }
2864
+ });
2865
+ });
2866
+ webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
2867
+ set: function(){
2868
+ var elem = this;
2869
+ var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
2870
+ clearTimeout(baseData.loadTimer);
2871
+ baseData.loadTimer = setTimeout(function(){
2872
+ selectSource(elem);
2873
+ elem = null;
2874
+ }, 9);
2875
+ }
2876
+ });
2877
+ });
2878
+
2879
+ var initMediaElements = function(){
2880
+ var testFixMedia = function(){
2881
+ if(webshims.implement(this, 'mediaelement')){
2882
+ selectSource(this);
2883
+
2884
+ if(hasNative){
2885
+ var bufferTimer;
2886
+ var lastBuffered;
2887
+ var elem = this;
2888
+ var getBufferedString = function(){
2889
+ var buffered = $.prop(elem, 'buffered');
2890
+ if(!buffered){return;}
2891
+ var bufferString = "";
2892
+ for(var i = 0, len = buffered.length; i < len;i++){
2893
+ bufferString += buffered.end(i);
2894
+ }
2895
+ return bufferString;
2896
+ };
2897
+ var testBuffer = function(){
2898
+ var buffered = getBufferedString();
2899
+ if(buffered != lastBuffered){
2900
+ lastBuffered = buffered;
2901
+ $(elem).triggerHandler('progress');
2902
+ }
2903
+ };
2904
+
2905
+ $(this)
2906
+ .on({
2907
+ 'play loadstart progress': function(e){
2908
+ if(e.type == 'progress'){
2909
+ lastBuffered = getBufferedString();
2910
+ }
2911
+ clearTimeout(bufferTimer);
2912
+ bufferTimer = setTimeout(testBuffer, 999);
2913
+ },
2914
+ 'emptied stalled mediaerror abort suspend': function(e){
2915
+ if(e.type == 'emptied'){
2916
+ lastBuffered = false;
2917
+ }
2918
+ clearTimeout(bufferTimer);
2919
+ }
2920
+ })
2921
+ ;
2922
+ if('ActiveXObject' in window && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay],.nonnative-api-active)')){
2923
+ $(this).prop('preload', 'metadata').mediaLoad();
2924
+ }
1195
2925
  }
1196
- };
2926
+ }
1197
2927
 
2928
+ };
2929
+ var handleMedia = false;
2930
+
2931
+
2932
+ webshims.ready('dom-support', function(){
2933
+ handleMedia = true;
2934
+ webshims.addReady(function(context, insertedElement){
2935
+ var media = $('video, audio', context)
2936
+ .add(insertedElement.filter('video, audio'))
2937
+ .each(testFixMedia)
2938
+ ;
2939
+ if(!loadTrackUi.loaded && $('track', media).length){
2940
+ loadTrackUi();
2941
+ }
2942
+ media = null;
2943
+ });
2944
+ });
2945
+
2946
+ if(hasNative && !handleMedia){
1198
2947
  webshims.addReady(function(context, insertedElement){
1199
- if(context !== document){
1200
- $('input[type="radio"]:invalid', context)
1201
- .add(insertedElement.filter('input[type="radio"]:invalid'))
1202
- .each(retriggerRadioValidity)
2948
+ if(!handleMedia){
2949
+ $('video, audio', context)
2950
+ .add(insertedElement.filter('video, audio'))
2951
+ .each(function(){
2952
+ if(!mediaelement.canNativePlaySrces(this) || (!loadTrackUi.loaded && $('track', this).length)){
2953
+ loadThird();
2954
+ handleMedia = true;
2955
+ return false;
2956
+ }
2957
+ })
1203
2958
  ;
1204
2959
  }
1205
2960
  });
1206
- })();
1207
- }
1208
-
1209
- var customEvents = $.event.customEvent || {};
1210
- var isValid = function(elem){
1211
- return ($.prop(elem, 'validity') || {valid: 1}).valid;
2961
+ }
1212
2962
  };
1213
2963
 
1214
- if (bugs.bustedValidity || bugs.findRequired) {
1215
- (function(){
1216
- var find = $.find;
1217
- var matchesSelector = $.find.matchesSelector;
1218
-
1219
- var regExp = /(\:valid|\:invalid|\:optional|\:required|\:in-range|\:out-of-range)(?=[\s\[\~\.\+\>\:\#*]|$)/ig;
1220
- var regFn = function(sel){
1221
- return sel + '-element';
1222
- };
1223
-
1224
- $.find = (function(){
1225
- var slice = Array.prototype.slice;
1226
- var fn = function(sel){
1227
- var ar = arguments;
1228
- ar = slice.call(ar, 1, ar.length);
1229
- ar.unshift(sel.replace(regExp, regFn));
1230
- return find.apply(this, ar);
1231
- };
1232
- for (var i in find) {
1233
- if(find.hasOwnProperty(i)){
1234
- fn[i] = find[i];
1235
- }
1236
- }
1237
- return fn;
1238
- })();
1239
- if(!Modernizr.prefixed || Modernizr.prefixed("matchesSelector", document.documentElement)){
1240
- $.find.matchesSelector = function(node, expr){
1241
- expr = expr.replace(regExp, regFn);
1242
- return matchesSelector.call(this, node, expr);
1243
- };
2964
+ if(Modernizr.track && !bugs.track){
2965
+ webshims.defineProperty(TextTrack.prototype, 'shimActiveCues', {
2966
+ get: function(){
2967
+ return this._shimActiveCues || this.activeCues;
1244
2968
  }
1245
-
1246
- })();
2969
+ });
1247
2970
  }
2971
+ //set native implementation ready, before swf api is retested
2972
+ if(hasNative){
2973
+ webshims.isReady('mediaelement-core', true);
2974
+ initMediaElements();
2975
+ webshims.ready('WINDOWLOAD mediaelement', loadThird);
2976
+ } else {
2977
+ webshims.ready(swfType, initMediaElements);
2978
+ }
2979
+ webshims.ready('WINDOWLOAD mediaelement', loadTrackUi);
2980
+ });
2981
+ })(jQuery, Modernizr, jQuery.webshims);
2982
+ jQuery.webshims.register('mediaelement-jaris', function($, webshims, window, document, undefined, options){
2983
+ "use strict";
1248
2984
 
1249
- //ToDo needs testing
1250
- var oldAttr = $.prop;
1251
- var changeVals = {selectedIndex: 1, value: 1, checked: 1, disabled: 1, readonly: 1};
1252
- $.prop = function(elem, name, val){
1253
- var ret = oldAttr.apply(this, arguments);
1254
- if(elem && 'form' in elem && changeVals[name] && val !== undefined && $(elem).hasClass(invalidClass)){
1255
- if(isValid(elem)){
1256
- $(elem).getShadowElement().removeClass(invalidClasses);
1257
- if(name == 'checked' && val) {
1258
- getGroupElements(elem).not(elem).removeClass(invalidClasses).removeAttr('aria-invalid');
2985
+ var mediaelement = webshims.mediaelement;
2986
+ var swfmini = window.swfmini;
2987
+ var hasNative = Modernizr.audio && Modernizr.video;
2988
+ var hasFlash = swfmini.hasFlashPlayerVersion('9.0.115');
2989
+ var loadedSwf = 0;
2990
+ var getProps = {
2991
+ paused: true,
2992
+ ended: false,
2993
+ currentSrc: '',
2994
+ duration: window.NaN,
2995
+ readyState: 0,
2996
+ networkState: 0,
2997
+ videoHeight: 0,
2998
+ videoWidth: 0,
2999
+ error: null,
3000
+ buffered: {
3001
+ start: function(index){
3002
+ if(index){
3003
+ webshims.error('buffered index size error');
3004
+ return;
1259
3005
  }
1260
- }
3006
+ return 0;
3007
+ },
3008
+ end: function(index){
3009
+ if(index){
3010
+ webshims.error('buffered index size error');
3011
+ return;
3012
+ }
3013
+ return 0;
3014
+ },
3015
+ length: 0
1261
3016
  }
1262
- return ret;
1263
3017
  };
3018
+ var getPropKeys = Object.keys(getProps);
1264
3019
 
1265
- var returnValidityCause = function(validity, elem){
1266
- var ret;
1267
- $.each(validity, function(name, value){
1268
- if(value){
1269
- ret = (name == 'customError') ? $.prop(elem, 'validationMessage') : name;
1270
- return false;
1271
- }
1272
- });
1273
- return ret;
3020
+ var getSetProps = {
3021
+ currentTime: 0,
3022
+ volume: 1,
3023
+ muted: false
1274
3024
  };
3025
+ var getSetPropKeys = Object.keys(getSetProps);
1275
3026
 
1276
- var isInGroup = function(name){
1277
- var ret;
1278
- try {
1279
- ret = document.activeElement.name === name;
1280
- } catch(e){}
1281
- return ret;
1282
- };
1283
- /* form-ui-invalid/form-ui-valid are deprecated. use user-error/user-success instead */
1284
- var invalidClass = 'user-error';
1285
- var invalidClasses = 'user-error form-ui-invalid';
1286
- var validClass = 'user-success';
1287
- var validClasses = 'user-success form-ui-valid';
1288
- var switchValidityClass = function(e){
1289
- var elem, timer;
1290
- if(!e.target){return;}
1291
- elem = $(e.target).getNativeElement()[0];
1292
- if(elem.type == 'submit' || !$.prop(elem, 'willValidate')){return;}
1293
- timer = $.data(elem, 'webshimsswitchvalidityclass');
1294
- var switchClass = function(){
1295
- if(e.type == 'focusout' && elem.type == 'radio' && isInGroup(elem.name)){return;}
1296
- var validity = $.prop(elem, 'validity');
1297
- var shadowElem = $(elem).getShadowElement();
1298
- var addClass, removeClass, trigger, generaltrigger, validityCause;
1299
-
1300
- $(elem).trigger('refreshCustomValidityRules');
1301
- if(validity.valid){
1302
- if(!shadowElem.hasClass(validClass)){
1303
- addClass = validClasses;
1304
- removeClass = invalidClasses;
1305
- generaltrigger = 'changedvaliditystate';
1306
- trigger = 'changedvalid';
1307
- if(checkTypes[elem.type] && elem.checked){
1308
- getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass).removeAttr('aria-invalid');
1309
- }
1310
- $.removeData(elem, 'webshimsinvalidcause');
1311
- }
1312
- } else {
1313
- validityCause = returnValidityCause(validity, elem);
1314
- if($.data(elem, 'webshimsinvalidcause') != validityCause){
1315
- $.data(elem, 'webshimsinvalidcause', validityCause);
1316
- generaltrigger = 'changedvaliditystate';
1317
- }
1318
- if(!shadowElem.hasClass(invalidClass)){
1319
- addClass = invalidClasses;
1320
- removeClass = validClasses;
1321
- if (checkTypes[elem.type] && !elem.checked) {
1322
- getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass);
1323
- }
1324
- trigger = 'changedinvalid';
1325
- }
1326
- }
1327
- if(addClass){
1328
- shadowElem.addClass(addClass).removeClass(removeClass);
1329
- //jQuery 1.6.1 IE9 bug (doubble trigger bug)
1330
- setTimeout(function(){
1331
- $(elem).trigger(trigger);
1332
- }, 0);
1333
- }
1334
- if(generaltrigger){
1335
- setTimeout(function(){
1336
- $(elem).trigger(generaltrigger);
1337
- }, 0);
1338
- }
1339
- $.removeData(e.target, 'webshimsswitchvalidityclass');
1340
- };
3027
+ var playerStateObj = $.extend({
3028
+ isActive: 'html5',
3029
+ activating: 'html5',
3030
+ wasSwfReady: false,
3031
+ _bufferedEnd: 0,
3032
+ _bufferedStart: 0,
3033
+ currentTime: 0,
3034
+ _ppFlag: undefined,
3035
+ _calledMeta: false,
3036
+ lastDuration: 0
3037
+ }, getProps, getSetProps);
3038
+
3039
+ var idRep = /^jarisplayer-/;
3040
+ var getSwfDataFromID = function(id){
1341
3041
 
1342
- if(timer){
1343
- clearTimeout(timer);
1344
- }
1345
- if(e.type == 'refreshvalidityui'){
1346
- switchClass();
1347
- } else {
1348
- $.data(elem, 'webshimsswitchvalidityclass', setTimeout(switchClass, 9));
1349
- }
3042
+ var elem = document.getElementById(id.replace(idRep, ''));
3043
+ if(!elem){return;}
3044
+ var data = webshims.data(elem, 'mediaelement');
3045
+ return data.isActive == 'third' ? data : null;
1350
3046
  };
1351
3047
 
1352
- $(document).on(options.validityUIEvents || 'focusout change refreshvalidityui', switchValidityClass);
1353
- customEvents.changedvaliditystate = true;
1354
- customEvents.refreshCustomValidityRules = true;
1355
- customEvents.changedvalid = true;
1356
- customEvents.changedinvalid = true;
1357
- customEvents.refreshvalidityui = true;
1358
3048
 
3049
+ var getSwfDataFromElem = function(elem){
3050
+ try {
3051
+ (elem.nodeName);
3052
+ } catch(er){
3053
+ return null;
3054
+ }
3055
+ var data = webshims.data(elem, 'mediaelement');
3056
+ return (data && data.isActive== 'third') ? data : null;
3057
+ };
1359
3058
 
1360
- webshims.triggerInlineForm = function(elem, event){
1361
- $(elem).trigger(event);
3059
+ var trigger = function(elem, evt){
3060
+ evt = $.Event(evt);
3061
+ evt.preventDefault();
3062
+ $.event.trigger(evt, undefined, elem);
1362
3063
  };
1363
3064
 
1364
- webshims.modules["form-core"].getGroupElements = getGroupElements;
3065
+ var playerSwfPath = options.playerPath || webshims.cfg.basePath + "swf/" + (options.playerName || 'JarisFLVPlayer.swf');
1365
3066
 
3067
+ webshims.extendUNDEFProp(options.params, {
3068
+ allowscriptaccess: 'always',
3069
+ allowfullscreen: 'true',
3070
+ wmode: 'transparent',
3071
+ allowNetworking: 'all'
3072
+ });
3073
+ webshims.extendUNDEFProp(options.vars, {
3074
+ controltype: '1',
3075
+ jsapi: '1'
3076
+ });
3077
+ webshims.extendUNDEFProp(options.attrs, {
3078
+ bgcolor: '#000000'
3079
+ });
1366
3080
 
1367
- var setRoot = function(){
1368
- webshims.scrollRoot = (isWebkit || document.compatMode == 'BackCompat') ?
1369
- $(document.body) :
1370
- $(document.documentElement)
1371
- ;
1372
- };
1373
- setRoot();
1374
- webshims.ready('DOM', setRoot);
1375
-
1376
- webshims.getRelOffset = function(posElem, relElem){
1377
- posElem = $(posElem);
1378
- var offset = $(relElem).offset();
1379
- var bodyOffset;
1380
- $.swap($(posElem)[0], {visibility: 'hidden', display: 'inline-block', left: 0, top: 0}, function(){
1381
- bodyOffset = posElem.offset();
1382
- });
1383
- offset.top -= bodyOffset.top;
1384
- offset.left -= bodyOffset.left;
1385
- return offset;
3081
+ var setReadyState = function(readyState, data){
3082
+ if(readyState < 3){
3083
+ clearTimeout(data._canplaythroughTimer);
3084
+ }
3085
+ if(readyState >= 3 && data.readyState < 3){
3086
+ data.readyState = readyState;
3087
+ trigger(data._elem, 'canplay');
3088
+ if(!data.paused){
3089
+ trigger(data._elem, 'playing');
3090
+ }
3091
+ clearTimeout(data._canplaythroughTimer);
3092
+ data._canplaythroughTimer = setTimeout(function(){
3093
+ setReadyState(4, data);
3094
+ }, 4000);
3095
+ }
3096
+ if(readyState >= 4 && data.readyState < 4){
3097
+ data.readyState = readyState;
3098
+ trigger(data._elem, 'canplaythrough');
3099
+ }
3100
+ data.readyState = readyState;
1386
3101
  };
1387
3102
 
1388
- /* some extra validation UI */
1389
- webshims.validityAlert = (function(){
1390
- var alertElem = 'span';
1391
- var errorBubble;
1392
- var hideTimer = false;
1393
- var focusTimer = false;
1394
- var resizeTimer = false;
1395
- var boundHide;
1396
-
1397
- var api = {
1398
- hideDelay: 5000,
1399
-
1400
- showFor: function(elem, message, noFocusElem, noBubble){
1401
- api._create();
1402
- elem = $(elem);
1403
- var visual = $(elem).getShadowElement();
1404
- var offset = api.getOffsetFromBody(visual);
1405
- api.clear();
1406
- if(noBubble){
1407
- this.hide();
1408
- } else {
1409
-
1410
- this.getMessage(elem, message);
1411
- this.position(visual, offset);
1412
-
1413
- this.show();
1414
- if(this.hideDelay){
1415
- hideTimer = setTimeout(boundHide, this.hideDelay);
1416
- }
1417
- $(window)
1418
- .on('resize.validityalert reposoverlay.validityalert', function(){
1419
- clearTimeout(resizeTimer);
1420
- resizeTimer = setTimeout(function(){
1421
- api.position(visual);
1422
- }, 9);
1423
- })
1424
- ;
1425
- }
1426
-
1427
- if(!noFocusElem){
1428
- this.setFocus(visual, offset);
1429
- }
1430
- },
1431
- getOffsetFromBody: function(elem){
1432
- return webshims.getRelOffset(errorBubble, elem);
1433
- },
1434
- setFocus: function(visual, offset){
1435
- var focusElem = $(visual).getShadowFocusElement();
1436
- var scrollTop = webshims.scrollRoot.scrollTop();
1437
- var elemTop = ((offset || focusElem.offset()).top) - 30;
1438
- var smooth;
1439
-
1440
- if(webshims.getID && alertElem == 'label'){
1441
- errorBubble.attr('for', webshims.getID(focusElem));
1442
- }
1443
-
1444
- if(scrollTop > elemTop){
1445
- webshims.scrollRoot.animate(
1446
- {scrollTop: elemTop - 5},
1447
- {
1448
- queue: false,
1449
- duration: Math.max( Math.min( 600, (scrollTop - elemTop) * 1.5 ), 80 )
1450
- }
1451
- );
1452
- smooth = true;
1453
- }
3103
+ $.extend($.event.customEvent, {
3104
+ updatemediaelementdimensions: true,
3105
+ flashblocker: true,
3106
+ swfstageresize: true,
3107
+ mediaelementapichange: true
3108
+ });
3109
+
3110
+ mediaelement.jarisEvent = {};
3111
+ var localConnectionTimer;
3112
+ var onEvent = {
3113
+ onPlayPause: function(jaris, data, override){
3114
+ var playing, type;
3115
+ if(override == null){
1454
3116
  try {
1455
- focusElem[0].focus();
3117
+ playing = data.api.api_get("isPlaying");
1456
3118
  } catch(e){}
1457
- if(smooth){
1458
- webshims.scrollRoot.scrollTop(scrollTop);
1459
- setTimeout(function(){
1460
- webshims.scrollRoot.scrollTop(scrollTop);
1461
- }, 0);
3119
+ } else {
3120
+ playing = override;
3121
+ }
3122
+ if(playing == data.paused){
3123
+
3124
+ data.paused = !playing;
3125
+ type = data.paused ? 'pause' : 'play';
3126
+ data._ppFlag = true;
3127
+ trigger(data._elem, type);
3128
+ if(data.readyState < 3){
3129
+ setReadyState(3, data);
1462
3130
  }
1463
- setTimeout(function(){
1464
- $(document).on('focusout.validityalert', boundHide);
1465
- }, 10);
1466
- $(window).triggerHandler('reposoverlay');
1467
- },
1468
- getMessage: function(elem, message){
1469
- if (!message) {
1470
- message = getContentValidationMessage(elem[0]) || elem.prop('customValidationMessage') || elem.prop('validationMessage');
3131
+ if(!data.paused){
3132
+ trigger(data._elem, 'playing');
1471
3133
  }
1472
- if (message) {
1473
- $('span.va-box', errorBubble).text(message);
3134
+ }
3135
+ },
3136
+ onNotBuffering: function(jaris, data){
3137
+ setReadyState(3, data);
3138
+ },
3139
+ onDataInitialized: function(jaris, data){
3140
+
3141
+ var oldDur = data.duration;
3142
+ var durDelta;
3143
+ data.duration = jaris.duration;
3144
+ if(oldDur == data.duration || isNaN(data.duration)){return;}
3145
+
3146
+ if(data._calledMeta && ((durDelta = Math.abs(data.lastDuration - data.duration)) < 2)){return;}
3147
+
3148
+
3149
+
3150
+ data.videoHeight = jaris.height;
3151
+ data.videoWidth = jaris.width;
3152
+
3153
+ if(!data.networkState){
3154
+ data.networkState = 2;
3155
+ }
3156
+ if(data.readyState < 1){
3157
+ setReadyState(1, data);
3158
+ }
3159
+ clearTimeout(data._durationChangeTimer);
3160
+ if(data._calledMeta && data.duration){
3161
+ data._durationChangeTimer = setTimeout(function(){
3162
+ data.lastDuration = data.duration;
3163
+ trigger(data._elem, 'durationchange');
3164
+ }, durDelta > 50 ? 0 : durDelta > 9 ? 9 : 99);
3165
+ } else {
3166
+ data.lastDuration = data.duration;
3167
+ if(data.duration){
3168
+ trigger(data._elem, 'durationchange');
1474
3169
  }
1475
- else {
1476
- this.hide();
3170
+ if(!data._calledMeta){
3171
+ trigger(data._elem, 'loadedmetadata');
1477
3172
  }
1478
- },
1479
- position: function(elem, offset){
1480
- offset = offset ? $.extend({}, offset) : api.getOffsetFromBody(elem);
1481
- offset.top += elem.outerHeight();
1482
- errorBubble.css(offset);
1483
- },
1484
- show: function(){
1485
- if(errorBubble.css('display') === 'none'){
1486
- errorBubble.css({opacity: 0}).show();
3173
+ }
3174
+ data._calledMeta = true;
3175
+ },
3176
+ onBuffering: function(jaris, data){
3177
+ if(data.ended){
3178
+ data.ended = false;
3179
+ }
3180
+ setReadyState(1, data);
3181
+ trigger(data._elem, 'waiting');
3182
+ },
3183
+ onTimeUpdate: function(jaris, data){
3184
+ if(data.ended){
3185
+ data.ended = false;
3186
+ }
3187
+ if(data.readyState < 3){
3188
+ setReadyState(3, data);
3189
+ trigger(data._elem, 'playing');
3190
+ }
3191
+
3192
+ trigger(data._elem, 'timeupdate');
3193
+ },
3194
+ onProgress: function(jaris, data){
3195
+ if(data.ended){
3196
+ data.ended = false;
3197
+ }
3198
+ if(!data.duration || isNaN(data.duration)){
3199
+ return;
3200
+ }
3201
+ var percentage = jaris.loaded / jaris.total;
3202
+ if(percentage > 0.02 && percentage < 0.2){
3203
+ setReadyState(3, data);
3204
+ } else if(percentage > 0.2){
3205
+ if(percentage > 0.99){
3206
+ data.networkState = 1;
3207
+ }
3208
+ setReadyState(4, data);
3209
+ }
3210
+ if(data._bufferedEnd && (data._bufferedEnd > percentage)){
3211
+ data._bufferedStart = data.currentTime || 0;
3212
+ }
3213
+
3214
+ data._bufferedEnd = percentage;
3215
+ data.buffered.length = 1;
3216
+
3217
+ $.event.trigger('progress', undefined, data._elem, true);
3218
+ },
3219
+ onPlaybackFinished: function(jaris, data){
3220
+ if(data.readyState < 4){
3221
+ setReadyState(4, data);
3222
+ }
3223
+ data.ended = true;
3224
+ trigger(data._elem, 'ended');
3225
+ },
3226
+ onVolumeChange: function(jaris, data){
3227
+ if(data.volume != jaris.volume || data.muted != jaris.mute){
3228
+ data.volume = jaris.volume;
3229
+ data.muted = jaris.mute;
3230
+ trigger(data._elem, 'volumechange');
3231
+ }
3232
+ },
3233
+ ready: (function(){
3234
+ var testAPI = function(data){
3235
+ var passed = true;
3236
+
3237
+ try {
3238
+ data.api.api_get('volume');
3239
+ } catch(er){
3240
+ passed = false;
1487
3241
  }
1488
- errorBubble.addClass('va-visible').fadeTo(400, 1);
1489
- },
1490
- hide: function(){
1491
- errorBubble.removeClass('va-visible').fadeOut();
1492
- },
1493
- clear: function(){
1494
- clearTimeout(focusTimer);
1495
- clearTimeout(hideTimer);
1496
- $(document).unbind('.validityalert');
1497
- $(window).unbind('.validityalert');
1498
- errorBubble.stop().removeAttr('for');
1499
- },
1500
- _create: function(){
1501
- if(errorBubble){return;}
1502
- errorBubble = api.errorBubble = $('<'+alertElem+' class="validity-alert-wrapper" role="alert"><span class="validity-alert"><span class="va-arrow"><span class="va-arrow-box"></span></span><span class="va-box"></span></span></'+alertElem+'>').css({position: 'absolute', display: 'none'});
1503
- webshims.ready('DOM', function(){
1504
- errorBubble.appendTo('body');
1505
- if($.fn.bgIframe){
1506
- errorBubble.bgIframe();
3242
+ return passed;
3243
+ };
3244
+
3245
+ return function(jaris, data){
3246
+ var i = 0;
3247
+ var doneFn = function(){
3248
+ if(i > 9){
3249
+ data.tryedReframeing = 0;
3250
+ return;
1507
3251
  }
1508
- });
1509
- }
1510
- };
1511
-
1512
-
1513
- boundHide = $.proxy(api, 'hide');
1514
-
1515
- return api;
1516
- })();
3252
+ i++;
3253
+
3254
+ data.tryedReframeing++;
3255
+ if(testAPI(data)){
3256
+ data.wasSwfReady = true;
3257
+ data.tryedReframeing = 0;
3258
+ startAutoPlay(data);
3259
+ workActionQueue(data);
3260
+ } else if(data.tryedReframeing < 6) {
3261
+ if(data.tryedReframeing < 3){
3262
+ data.reframeTimer = setTimeout(doneFn, 9);
3263
+ data.shadowElem.css({overflow: 'visible'});
3264
+ setTimeout(function(){
3265
+ data.shadowElem.css({overflow: 'hidden'});
3266
+ }, 1);
3267
+ } else {
3268
+ data.shadowElem.css({overflow: 'hidden'});
3269
+ $(data._elem).mediaLoad();
3270
+ }
3271
+ } else {
3272
+ clearTimeout(data.reframeTimer);
3273
+ webshims.error("reframing error");
3274
+ }
3275
+ };
3276
+ if(!data || !data.api){return;}
3277
+ if(!data.tryedReframeing){
3278
+ data.tryedReframeing = 0;
3279
+ }
3280
+ clearTimeout(localConnectionTimer);
3281
+ clearTimeout(data.reframeTimer);
3282
+ data.shadowElem.removeClass('flashblocker-assumed');
3283
+
3284
+ if(!i){
3285
+ doneFn();
3286
+ } else {
3287
+ data.reframeTimer = setTimeout(doneFn, 9);
3288
+ }
3289
+
3290
+ };
3291
+ })()
3292
+ };
1517
3293
 
3294
+ onEvent.onMute = onEvent.onVolumeChange;
1518
3295
 
1519
- /* extension, but also used to fix native implementation workaround/bugfixes */
1520
- (function(){
1521
- var firstEvent,
1522
- invalids = [],
1523
- stopSubmitTimer,
1524
- form
1525
- ;
3296
+
3297
+ var workActionQueue = function(data){
3298
+ var actionLen = data.actionQueue.length;
3299
+ var i = 0;
3300
+ var operation;
1526
3301
 
1527
- $(document).on('invalid', function(e){
1528
- if(e.wrongWebkitInvalid){return;}
1529
- var jElm = $(e.target);
1530
- var shadowElem = jElm.getShadowElement();
1531
- if(!shadowElem.hasClass(invalidClass)){
1532
- shadowElem.addClass(invalidClasses).removeClass(validClasses);
1533
- setTimeout(function(){
1534
- $(e.target).trigger('changedinvalid').trigger('changedvaliditystate');
1535
- }, 0);
3302
+ if(actionLen && data.isActive == 'third'){
3303
+ while(data.actionQueue.length && actionLen > i){
3304
+ i++;
3305
+ operation = data.actionQueue.shift();
3306
+ try{
3307
+ data.api[operation.fn].apply(data.api, operation.args);
3308
+ } catch(er){
3309
+ webshims.warn(er);
3310
+ }
1536
3311
  }
1537
-
1538
- if(!firstEvent){
1539
- //trigger firstinvalid
1540
- firstEvent = $.Event('firstinvalid');
1541
- firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
1542
- var firstSystemInvalid = $.Event('firstinvalidsystem');
1543
- $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
1544
- jElm.trigger(firstEvent);
1545
- }
1546
-
1547
- //if firstinvalid was prevented all invalids will be also prevented
1548
- if( firstEvent && firstEvent.isDefaultPrevented() ){
1549
- e.preventDefault();
1550
- }
1551
- invalids.push(e.target);
1552
- e.extraData = 'fix';
1553
- clearTimeout(stopSubmitTimer);
1554
- stopSubmitTimer = setTimeout(function(){
1555
- var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
1556
- //reset firstinvalid
1557
- firstEvent = false;
1558
- invalids = [];
1559
- $(e.target).trigger(lastEvent, lastEvent);
1560
- }, 9);
1561
- jElm = null;
1562
- shadowElem = null;
1563
- });
1564
- })();
1565
-
1566
- $.fn.getErrorMessage = function(){
1567
- var message = '';
1568
- var elem = this[0];
1569
- if(elem){
1570
- message = getContentValidationMessage(elem) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
1571
3312
  }
1572
- return message;
3313
+ if(data.actionQueue.length){
3314
+ data.actionQueue = [];
3315
+ }
3316
+ };
3317
+ var startAutoPlay = function(data){
3318
+ if(!data){return;}
3319
+ if( (data._ppFlag === undefined && ($.prop(data._elem, 'autoplay')) || !data.paused)){
3320
+ setTimeout(function(){
3321
+ if(data.isActive == 'third' && (data._ppFlag === undefined || !data.paused)){
3322
+
3323
+ try {
3324
+ $(data._elem).play();
3325
+ data._ppFlag = true;
3326
+ } catch(er){}
3327
+ }
3328
+ }, 1);
3329
+ }
3330
+
3331
+ if(data.muted){
3332
+ $.prop(data._elem, 'muted', true);
3333
+ }
3334
+ if(data.volume != 1){
3335
+ $.prop(data._elem, 'volume', data.volume);
3336
+ }
1573
3337
  };
1574
3338
 
1575
- if(options.replaceValidationUI){
1576
- webshims.ready('DOM forms', function(){
1577
- $(document).on('firstinvalid', function(e){
1578
- if(!e.isInvalidUIPrevented()){
1579
- e.preventDefault();
1580
- $.webshims.validityAlert.showFor( e.target );
3339
+
3340
+ var addMediaToStopEvents = $.noop;
3341
+ if(hasNative){
3342
+ var stopEvents = {
3343
+ play: 1,
3344
+ playing: 1
3345
+ };
3346
+ var hideEvtArray = ['play', 'pause', 'playing', 'canplay', 'progress', 'waiting', 'ended', 'loadedmetadata', 'durationchange', 'emptied'];
3347
+ var hidevents = hideEvtArray.map(function(evt){
3348
+ return evt +'.webshimspolyfill';
3349
+ }).join(' ');
3350
+
3351
+ var hidePlayerEvents = function(event){
3352
+ var data = webshims.data(event.target, 'mediaelement');
3353
+ if(!data){return;}
3354
+ var isNativeHTML5 = ( event.originalEvent && event.originalEvent.type === event.type );
3355
+ if( isNativeHTML5 == (data.activating == 'third') ){
3356
+ event.stopImmediatePropagation();
3357
+ if(stopEvents[event.type] && data.isActive != data.activating){
3358
+ $(event.target).pause();
1581
3359
  }
3360
+ }
3361
+ };
3362
+
3363
+ addMediaToStopEvents = function(elem){
3364
+ $(elem)
3365
+ .off(hidevents)
3366
+ .on(hidevents, hidePlayerEvents)
3367
+ ;
3368
+ hideEvtArray.forEach(function(evt){
3369
+ webshims.moveToFirstEvent(elem, evt);
1582
3370
  });
1583
- });
1584
- }
1585
- });
1586
-
1587
- })(jQuery);
1588
- jQuery.webshims.register('form-datalist', function($, webshims, window, document, undefined){
1589
- "use strict";
1590
- var doc = document;
1591
-
1592
- /*
1593
- * implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
1594
- */
1595
- webshims.propTypes.element = function(descs){
1596
- webshims.createPropDefault(descs, 'attr');
1597
- if(descs.prop){return;}
1598
- descs.prop = {
1599
- get: function(){
1600
- var elem = descs.attr.get.call(this);
1601
- if(elem){
1602
- elem = document.getElementById(elem);
1603
- if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
1604
- elem = null;
1605
- }
1606
- }
1607
- return elem || null;
1608
- },
1609
- writeable: false
1610
3371
  };
3372
+ addMediaToStopEvents(document);
3373
+ }
3374
+
3375
+
3376
+ mediaelement.setActive = function(elem, type, data){
3377
+ if(!data){
3378
+ data = webshims.data(elem, 'mediaelement');
3379
+ }
3380
+ if(!data || data.isActive == type){return;}
3381
+ if(type != 'html5' && type != 'third'){
3382
+ webshims.warn('wrong type for mediaelement activating: '+ type);
3383
+ }
3384
+ var shadowData = webshims.data(elem, 'shadowData');
3385
+ data.activating = type;
3386
+ $(elem).pause();
3387
+ data.isActive = type;
3388
+ if(type == 'third'){
3389
+ shadowData.shadowElement = shadowData.shadowFocusElement = data.shadowElem[0];
3390
+ $(elem).addClass('swf-api-active nonnative-api-active').hide().getShadowElement().show();
3391
+ } else {
3392
+ $(elem).removeClass('swf-api-active nonnative-api-active').show().getShadowElement().hide();
3393
+ shadowData.shadowElement = shadowData.shadowFocusElement = false;
3394
+ }
3395
+ $(elem).trigger('mediaelementapichange');
1611
3396
  };
1612
3397
 
1613
3398
 
1614
- /*
1615
- * Implements datalist element and list attribute
1616
- */
1617
3399
 
1618
- (function(){
1619
- var formsCFG = $.webshims.cfg.forms;
1620
- var listSupport = Modernizr.input.list;
1621
- if(listSupport && !formsCFG.customDatalist){return;}
1622
-
1623
- var initializeDatalist = function(){
1624
-
1625
-
1626
- if(!listSupport){
1627
- webshims.defineNodeNameProperty('datalist', 'options', {
1628
- prop: {
1629
- writeable: false,
1630
- get: function(){
1631
- var elem = this;
1632
- var select = $('select', elem);
1633
- var options;
1634
- if(select[0]){
1635
- options = select[0].options;
1636
- } else {
1637
- options = $('option', elem).get();
1638
- if(options.length){
1639
- webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
1640
- }
1641
- }
1642
- return options;
1643
- }
1644
- }
1645
- });
1646
- }
1647
-
1648
- var inputListProto = {
1649
- //override autocomplete
1650
- autocomplete: {
1651
- attr: {
1652
- get: function(){
1653
- var elem = this;
1654
- var data = $.data(elem, 'datalistWidget');
1655
- if(data){
1656
- return data._autocomplete;
1657
- }
1658
- return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
1659
- },
1660
- set: function(value){
1661
- var elem = this;
1662
- var data = $.data(elem, 'datalistWidget');
1663
- if(data){
1664
- data._autocomplete = value;
1665
- if(value == 'off'){
1666
- data.hideList();
1667
- }
1668
- } else {
1669
- if('autocomplete' in elem){
1670
- elem.autocomplete = value;
1671
- } else {
1672
- elem.setAttribute('autocomplete', value);
1673
- }
1674
- }
1675
- }
1676
- }
1677
- }
1678
- };
1679
-
1680
- // if(formsCFG.customDatalist && (!listSupport || !('selectedOption') in $('<input />')[0])){
1681
- // //currently not supported x-browser (FF4 has not implemented and is not polyfilled )
1682
- // inputListProto.selectedOption = {
1683
- // prop: {
1684
- // writeable: false,
1685
- // get: function(){
1686
- // var elem = this;
1687
- // var list = $.prop(elem, 'list');
1688
- // var ret = null;
1689
- // var value, options;
1690
- // if(!list){return ret;}
1691
- // value = $.prop(elem, 'value');
1692
- // if(!value){return ret;}
1693
- // options = $.prop(list, 'options');
1694
- // if(!options.length){return ret;}
1695
- // $.each(options, function(i, option){
1696
- // if(value == $.prop(option, 'value')){
1697
- // ret = option;
1698
- // return false;
1699
- // }
1700
- // });
1701
- // return ret;
1702
- // }
1703
- // }
1704
- // };
1705
- // }
1706
-
1707
- if(!listSupport){
1708
- inputListProto['list'] = {
1709
- attr: {
1710
- get: function(){
1711
- var val = webshims.contentAttr(this, 'list');
1712
- return (val == null) ? undefined : val;
1713
- },
1714
- set: function(value){
1715
- var elem = this;
1716
- webshims.contentAttr(elem, 'list', value);
1717
- webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1718
- }
1719
- },
1720
- initAttr: true,
1721
- reflect: true,
1722
- propType: 'element',
1723
- propNodeName: 'datalist'
1724
- };
1725
- } else {
1726
- //options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
1727
- if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
1728
- webshims.defineNodeNameProperty('datalist', 'options', {
1729
- prop: {
1730
- writeable: false,
1731
- get: function(){
1732
- var options = this.options || [];
1733
- if(!options.length){
1734
- var elem = this;
1735
- var select = $('select', elem);
1736
- if(select[0] && select[0].options && select[0].options.length){
1737
- options = select[0].options;
1738
- }
1739
- }
1740
- return options;
1741
- }
1742
- }
1743
- });
1744
- }
1745
- inputListProto['list'] = {
1746
- attr: {
1747
- get: function(){
1748
- var val = webshims.contentAttr(this, 'list');
1749
- if(val != null){
1750
- this.removeAttribute('list');
1751
- } else {
1752
- val = $.data(this, 'datalistListAttr');
1753
- }
1754
-
1755
- return (val == null) ? undefined : val;
1756
- },
1757
- set: function(value){
1758
- var elem = this;
1759
- $.data(elem, 'datalistListAttr', value);
1760
- webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1761
- }
1762
- },
1763
- initAttr: true,
1764
- reflect: true,
1765
- propType: 'element',
1766
- propNodeName: 'datalist'
1767
- };
1768
- }
1769
-
1770
-
1771
- webshims.defineNodeNameProperties('input', inputListProto);
3400
+ var resetSwfProps = (function(){
3401
+ var resetProtoProps = ['_calledMeta', 'lastDuration', '_bufferedEnd', '_bufferedStart', '_ppFlag', 'currentSrc', 'currentTime', 'duration', 'ended', 'networkState', 'paused', 'videoHeight', 'videoWidth'];
3402
+ var len = resetProtoProps.length;
3403
+ return function(data){
1772
3404
 
1773
- if($.event.customEvent){
1774
- $.event.customEvent.updateDatalist = true;
1775
- $.event.customEvent.updateInput = true;
1776
- $.event.customEvent.datalistselect = true;
1777
- }
1778
- webshims.addReady(function(context, contextElem){
1779
- contextElem
1780
- .filter('datalist > select, datalist, datalist > option, datalist > select > option')
1781
- .closest('datalist')
1782
- .triggerHandler('updateDatalist')
1783
- ;
1784
-
3405
+ if(!data){return;}
3406
+ var lenI = len;
3407
+ var networkState = data.networkState;
3408
+ setReadyState(0, data);
3409
+ clearTimeout(data._durationChangeTimer);
3410
+ while(--lenI > -1){
3411
+ delete data[resetProtoProps[lenI]];
3412
+ }
3413
+ data.actionQueue = [];
3414
+ data.buffered.length = 0;
3415
+ if(networkState){
3416
+ trigger(data._elem, 'emptied');
3417
+ }
3418
+ };
3419
+ })();
3420
+
3421
+ var setElementDimension = function(data, hasControls){
3422
+ var elem = data._elem;
3423
+ var box = data.shadowElem;
3424
+ $(elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
3425
+ if(data._elemNodeName == 'audio' && !hasControls){
3426
+ box.css({width: 0, height: 0});
3427
+ } else {
3428
+ box.css({
3429
+ width: elem.style.width || $(elem).width(),
3430
+ height: elem.style.height || $(elem).height()
1785
3431
  });
1786
-
1787
-
3432
+ }
3433
+ };
3434
+
3435
+ var bufferSrc = (function(){
3436
+ var preloads = {
3437
+ '': 1,
3438
+ 'auto': 1
3439
+ };
3440
+ return function(elem){
3441
+ var preload = $.attr(elem, 'preload');
3442
+ if(preload == null || preload == 'none' || $.prop(elem, 'autoplay')){
3443
+ return false;
3444
+ }
3445
+ preload = $.prop(elem, 'preload');
3446
+ return !!(preloads[preload] || (preload == 'metadata' && $(elem).is('.preload-in-doubt, video:not([poster])')));
1788
3447
  };
3448
+ })();
3449
+
3450
+ var regs = {
3451
+ A: /&amp;/g,
3452
+ a: /&/g,
3453
+ e: /\=/g,
3454
+ q: /\?/g
3455
+ },
3456
+ replaceVar = function(val){
3457
+ return (val.replace) ? val.replace(regs.A, '%26').replace(regs.a, '%26').replace(regs.e, '%3D').replace(regs.q, '%3F') : val;
3458
+ };
3459
+
3460
+ mediaelement.createSWF = function( elem, canPlaySrc, data ){
3461
+ if(!hasFlash){
3462
+ setTimeout(function(){
3463
+ $(elem).mediaLoad(); //<- this should produce a mediaerror
3464
+ }, 1);
3465
+ return;
3466
+ }
1789
3467
 
3468
+ if(loadedSwf < 1){
3469
+ loadedSwf = 1;
3470
+ } else {
3471
+ loadedSwf++;
3472
+ }
3473
+ if(!data){
3474
+ data = webshims.data(elem, 'mediaelement');
3475
+ }
1790
3476
 
1791
- /*
1792
- * ShadowList
1793
- */
1794
- var listidIndex = 0;
3477
+ if($.attr(elem, 'height') || $.attr(elem, 'width')){
3478
+ webshims.warn("width or height content attributes used. Webshims only uses CSS (computed styles or inline styles) to detect size of a video/audio");
3479
+ }
1795
3480
 
1796
- var noDatalistSupport = {
1797
- submit: 1,
1798
- button: 1,
1799
- reset: 1,
1800
- hidden: 1,
1801
-
1802
- //ToDo
1803
- range: 1,
1804
- date: 1
1805
- };
1806
- var globStoredOptions = {};
1807
- var getStoredOptions = function(name){
1808
- if(!name){return [];}
1809
- if(globStoredOptions[name]){
1810
- return globStoredOptions[name];
1811
- }
1812
- var data;
1813
- try {
1814
- data = JSON.parse(localStorage.getItem('storedDatalistOptions'+name));
1815
- } catch(e){}
1816
- globStoredOptions[name] = data || [];
1817
- return data || [];
1818
- };
1819
- var storeOptions = function(name, val){
1820
- if(!name){return;}
1821
- val = val || [];
1822
- try {
1823
- localStorage.setItem( 'storedDatalistOptions'+name, JSON.stringify(val) );
1824
- } catch(e){}
1825
- };
3481
+ var isRtmp = canPlaySrc.type == 'audio/rtmp' || canPlaySrc.type == 'video/rtmp';
3482
+ var vars = $.extend({}, options.vars, {
3483
+ poster: replaceVar($.attr(elem, 'poster') && $.prop(elem, 'poster') || ''),
3484
+ source: replaceVar(canPlaySrc.streamId || canPlaySrc.srcProp),
3485
+ server: replaceVar(canPlaySrc.server || '')
3486
+ });
3487
+ var elemVars = $(elem).data('vars') || {};
1826
3488
 
1827
- var getText = function(elem){
1828
- return (elem.textContent || elem.innerText || $.text([ elem ]) || '');
3489
+
3490
+
3491
+ var hasControls = $.prop(elem, 'controls');
3492
+ var elemId = 'jarisplayer-'+ webshims.getID(elem);
3493
+
3494
+ var params = $.extend(
3495
+ {},
3496
+ options.params,
3497
+ $(elem).data('params')
3498
+ );
3499
+ var elemNodeName = elem.nodeName.toLowerCase();
3500
+ var attrs = $.extend(
3501
+ {},
3502
+ options.attrs,
3503
+ {
3504
+ name: elemId,
3505
+ id: elemId
3506
+ },
3507
+ $(elem).data('attrs')
3508
+ );
3509
+ var setDimension = function(){
3510
+ setElementDimension(data, $.prop(elem, 'controls'));
1829
3511
  };
1830
3512
 
1831
- var shadowListProto = {
1832
- _create: function(opts){
1833
-
1834
- if(noDatalistSupport[$.prop(opts.input, 'type')]){return;}
1835
- var datalist = opts.datalist;
1836
- var data = $.data(opts.input, 'datalistWidget');
1837
- if(datalist && data && data.datalist !== datalist){
1838
- data.datalist = datalist;
1839
- data.id = opts.id;
1840
-
1841
- data.shadowList.prop('className', 'datalist-polyfill '+ (data.datalist.className || '') + ' '+ data.datalist.id +'-shadowdom');
1842
- if(formsCFG.positionDatalist){
1843
- data.shadowList.insertAfter(opts.input);
1844
- } else {
1845
- data.shadowList.appendTo('body');
1846
- }
1847
- $(data.datalist)
1848
- .off('updateDatalist.datalistWidget')
1849
- .on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
1850
- ;
1851
- data._resetListCached();
1852
- return;
1853
- } else if(!datalist){
1854
- if(data){
1855
- data.destroy();
1856
- }
1857
- return;
1858
- } else if(data && data.datalist === datalist){
1859
- return;
1860
- }
1861
- listidIndex++;
1862
- var that = this;
1863
- this.hideList = $.proxy(that, 'hideList');
1864
- this.timedHide = function(){
1865
- clearTimeout(that.hideTimer);
1866
- that.hideTimer = setTimeout(that.hideList, 9);
1867
- };
1868
- this.datalist = datalist;
1869
- this.id = opts.id;
1870
- this.hasViewableData = true;
1871
- this._autocomplete = $.attr(opts.input, 'autocomplete');
1872
- $.data(opts.input, 'datalistWidget', this);
1873
- this.shadowList = $('<div class="datalist-polyfill '+ (this.datalist.className || '') + ' '+ this.datalist.id +'-shadowdom' +'" />');
1874
-
1875
- if(formsCFG.positionDatalist || $(opts.input).hasClass('position-datalist')){
1876
- this.shadowList.insertAfter(opts.input);
1877
- } else {
1878
- this.shadowList.appendTo('body');
1879
- }
1880
-
1881
- this.index = -1;
1882
- this.input = opts.input;
1883
- this.arrayOptions = [];
1884
-
1885
- this.shadowList
1886
- .delegate('li', 'mouseenter.datalistWidget mousedown.datalistWidget click.datalistWidget', function(e){
1887
- var items = $('li:not(.hidden-item)', that.shadowList);
1888
- var select = (e.type == 'mousedown' || e.type == 'click');
1889
- that.markItem(items.index(e.currentTarget), select, items);
1890
- if(e.type == 'click'){
1891
- that.hideList();
1892
- if(formsCFG.customDatalist){
1893
- $(opts.input).trigger('datalistselect');
1894
- }
1895
- }
1896
- return (e.type != 'mousedown');
1897
- })
1898
- .on('focusout', this.timedHide)
1899
- ;
1900
-
1901
- opts.input.setAttribute('autocomplete', 'off');
1902
-
1903
- $(opts.input)
1904
- .attr({
1905
- //role: 'combobox',
1906
- 'aria-haspopup': 'true'
1907
- })
1908
- .on({
1909
- 'input.datalistWidget': function(){
1910
- if(!that.triggeredByDatalist){
1911
- that.changedValue = false;
1912
- that.showHideOptions();
1913
- }
1914
- },
1915
- 'keydown.datalistWidget': function(e){
1916
- var keyCode = e.keyCode;
1917
- var activeItem;
1918
- var items;
1919
- if(keyCode == 40 && !that.showList()){
1920
- that.markItem(that.index + 1, true);
1921
- return false;
1922
- }
1923
-
1924
- if(!that.isListVisible){return;}
1925
-
1926
-
1927
- if(keyCode == 38){
1928
- that.markItem(that.index - 1, true);
1929
- return false;
1930
- }
1931
- if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
1932
- that.markItem(0, true);
1933
- return false;
1934
- }
1935
- if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
1936
- items = $('li:not(.hidden-item)', that.shadowList);
1937
- that.markItem(items.length - 1, true, items);
1938
- return false;
1939
- }
1940
- if(keyCode == 13 || keyCode == 27){
1941
- if (keyCode == 13){
1942
- activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
1943
- that.changeValue( $('li.active-item:not(.hidden-item)', that.shadowList) );
1944
- }
1945
- that.hideList();
1946
- if(formsCFG.customDatalist && activeItem && activeItem[0]){
1947
- $(opts.input).trigger('datalistselect');
1948
- }
1949
- return false;
1950
- }
1951
- },
1952
- 'focus.datalistWidget': function(){
1953
- if($(this).hasClass('list-focus')){
1954
- that.showList();
3513
+ var box;
3514
+
3515
+ if(data && data.swfCreated){
3516
+ mediaelement.setActive(elem, 'third', data);
3517
+
3518
+ data.currentSrc = canPlaySrc.srcProp;
3519
+
3520
+ data.shadowElem.html('<div id="'+ elemId +'">');
3521
+
3522
+ data.api = false;
3523
+ data.actionQueue = [];
3524
+ box = data.shadowElem;
3525
+ resetSwfProps(data);
3526
+ } else {
3527
+ box = $('<div class="polyfill-'+ (elemNodeName) +' polyfill-mediaelement" id="wrapper-'+ elemId +'"><div id="'+ elemId +'"></div>')
3528
+ .css({
3529
+ position: 'relative',
3530
+ overflow: 'hidden'
3531
+ })
3532
+ ;
3533
+ data = webshims.data(elem, 'mediaelement', webshims.objectCreate(playerStateObj, {
3534
+ actionQueue: {
3535
+ value: []
3536
+ },
3537
+ shadowElem: {
3538
+ value: box
3539
+ },
3540
+ _elemNodeName: {
3541
+ value: elemNodeName
3542
+ },
3543
+ _elem: {
3544
+ value: elem
3545
+ },
3546
+ currentSrc: {
3547
+ value: canPlaySrc.srcProp
3548
+ },
3549
+ swfCreated: {
3550
+ value: true
3551
+ },
3552
+ id: {
3553
+ value: elemId.replace(/-/g, '')
3554
+ },
3555
+ buffered: {
3556
+ value: {
3557
+ start: function(index){
3558
+ if(index >= data.buffered.length){
3559
+ webshims.error('buffered index size error');
3560
+ return;
1955
3561
  }
3562
+ return 0;
1956
3563
  },
1957
- 'mousedown.datalistWidget': function(){
1958
- if($(this).is(':focus')){
1959
- that.showList();
3564
+ end: function(index){
3565
+ if(index >= data.buffered.length){
3566
+ webshims.error('buffered index size error');
3567
+ return;
1960
3568
  }
3569
+ return ( (data.duration - data._bufferedStart) * data._bufferedEnd) + data._bufferedStart;
1961
3570
  },
1962
- 'blur.datalistWidget': this.timedHide
1963
- })
1964
- ;
1965
-
1966
-
1967
- $(this.datalist)
1968
- .off('updateDatalist.datalistWidget')
1969
- .on('updateDatalist.datalistWidget', $.proxy(this, '_resetListCached'))
1970
- ;
1971
-
1972
- this._resetListCached();
1973
-
1974
- if(opts.input.form && (opts.input.name || opts.input.id)){
1975
- $(opts.input.form).on('submit.datalistWidget'+opts.input.id, function(){
1976
- if(!$(opts.input).hasClass('no-datalist-cache') && that._autocomplete != 'off'){
1977
- var val = $.prop(opts.input, 'value');
1978
- var name = (opts.input.name || opts.input.id) + $.prop(opts.input, 'type');
1979
- if(!that.storedOptions){
1980
- that.storedOptions = getStoredOptions( name );
1981
- }
1982
- if(val && that.storedOptions.indexOf(val) == -1){
1983
- that.storedOptions.push(val);
1984
- storeOptions(name, that.storedOptions );
3571
+ length: 0
3572
+ }
3573
+ }
3574
+ }));
3575
+ setElementDimension(data, hasControls);
3576
+
3577
+ box.insertBefore(elem);
3578
+
3579
+ if(hasNative){
3580
+ $.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted'), paused: $.prop(elem, 'paused')});
3581
+ }
3582
+
3583
+ webshims.addShadowDom(elem, box);
3584
+ addMediaToStopEvents(elem);
3585
+ mediaelement.setActive(elem, 'third', data);
3586
+ $(elem).on('updatemediaelementdimensions', setDimension);
3587
+ $(document).on('updateshadowdom', setDimension);
3588
+ }
3589
+
3590
+ if(!mediaelement.jarisEvent[data.id]){
3591
+ mediaelement.jarisEvent[data.id] = function(jaris){
3592
+ if(jaris.type == 'ready'){
3593
+ var onReady = function(){
3594
+ if(data.api){
3595
+ if(bufferSrc(elem)){
3596
+ data.api.api_preload();
1985
3597
  }
3598
+ onEvent.ready(jaris, data);
1986
3599
  }
1987
- });
1988
- }
1989
- $(window).on('unload.datalist'+this.id+' beforeunload.datalist'+this.id, function(){
1990
- that.destroy();
1991
- });
1992
- },
1993
- destroy: function(){
1994
- var autocomplete = $.attr(this.input, 'autocomplete');
1995
- $(this.input)
1996
- .off('.datalistWidget')
1997
- .removeData('datalistWidget')
1998
- ;
1999
- this.shadowList.remove();
2000
- $(document).off('.datalist'+this.id);
2001
- $(window).off('.datalist'+this.id);
2002
- if(this.input.form && this.input.id){
2003
- $(this.input.form).off('submit.datalistWidget'+this.input.id);
2004
- }
2005
- this.input.removeAttribute('aria-haspopup');
2006
- if(autocomplete === undefined){
2007
- this.input.removeAttribute('autocomplete');
2008
- } else {
2009
- $(this.input).attr('autocomplete', autocomplete);
2010
- }
2011
- },
2012
- _resetListCached: function(e){
2013
- var that = this;
2014
- var forceShow;
2015
- this.needsUpdate = true;
2016
- this.lastUpdatedValue = false;
2017
- this.lastUnfoundValue = '';
2018
-
2019
- if(!this.updateTimer){
2020
- if(window.QUnit || (forceShow = (e && document.activeElement == that.input))){
2021
- that.updateListOptions(forceShow);
3600
+ };
3601
+ if(data.api){
3602
+ onReady();
2022
3603
  } else {
2023
- webshims.ready('WINDOWLOAD', function(){
2024
- that.updateTimer = setTimeout(function(){
2025
- that.updateListOptions();
2026
- that = null;
2027
- listidIndex = 1;
2028
- }, 200 + (100 * listidIndex));
2029
- });
3604
+ setTimeout(onReady, 9);
3605
+ }
3606
+ } else {
3607
+ data.currentTime = jaris.position;
3608
+
3609
+ if(data.api){
3610
+ if(!data._calledMeta && isNaN(jaris.duration) && data.duration != jaris.duration && isNaN(data.duration)){
3611
+ onEvent.onDataInitialized(jaris, data);
3612
+ }
3613
+
3614
+ if(!data._ppFlag && jaris.type != 'onPlayPause'){
3615
+ onEvent.onPlayPause(jaris, data);
3616
+ }
3617
+
3618
+ if(onEvent[jaris.type]){
3619
+ onEvent[jaris.type](jaris, data);
3620
+ }
2030
3621
  }
3622
+ data.duration = jaris.duration;
2031
3623
  }
2032
- },
2033
- maskHTML: function(str){
2034
- return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
2035
- },
2036
- updateListOptions: function(_forceShow){
2037
- this.needsUpdate = false;
2038
- clearTimeout(this.updateTimer);
2039
- this.updateTimer = false;
2040
- this.shadowList
2041
- .css({
2042
- fontSize: $.css(this.input, 'fontSize'),
2043
- fontFamily: $.css(this.input, 'fontFamily')
2044
- })
2045
- ;
2046
- this.searchStart = formsCFG.customDatalist && $(this.input).hasClass('search-start');
2047
3624
 
2048
- var list = [];
3625
+ };
3626
+ }
3627
+
3628
+ $.extend(vars,
3629
+ {
3630
+ id: elemId,
3631
+ evtId: data.id,
3632
+ controls: ''+hasControls,
3633
+ autostart: 'false',
3634
+ nodename: elemNodeName
3635
+ },
3636
+ elemVars
3637
+ );
3638
+
3639
+ if(isRtmp){
3640
+ vars.streamtype = 'rtmp';
3641
+ } else if(canPlaySrc.type == 'audio/mpeg' || canPlaySrc.type == 'audio/mp3'){
3642
+ vars.type = 'audio';
3643
+ vars.streamtype = 'file';
3644
+ } else if(canPlaySrc.type == 'video/youtube'){
3645
+ vars.streamtype = 'youtube';
3646
+ }
3647
+ options.changeSWF(vars, elem, canPlaySrc, data, 'embed');
3648
+ clearTimeout(data.flashBlock);
3649
+
3650
+ swfmini.embedSWF(playerSwfPath, elemId, "100%", "100%", "9.0.115", false, vars, params, attrs, function(swfData){
3651
+
3652
+ if(swfData.success){
2049
3653
 
2050
- var values = [];
2051
- var allOptions = [];
2052
- var rElem, rItem, rOptions, rI, rLen, item;
2053
- for(rOptions = $.prop(this.datalist, 'options'), rI = 0, rLen = rOptions.length; rI < rLen; rI++){
2054
- rElem = rOptions[rI];
2055
- if(rElem.disabled){return;}
2056
- rItem = {
2057
- value: $(rElem).val() || '',
2058
- text: $.trim($.attr(rElem, 'label') || getText(rElem)),
2059
- className: rElem.className || '',
2060
- style: $.attr(rElem, 'style') || ''
2061
- };
2062
- if(!rItem.text){
2063
- rItem.text = rItem.value;
2064
- } else if(rItem.text != rItem.value){
2065
- rItem.className += ' different-label-value';
2066
- }
2067
- values[rI] = rItem.value;
2068
- allOptions[rI] = rItem;
2069
- }
3654
+ data.api = swfData.ref;
2070
3655
 
2071
- if(!this.storedOptions){
2072
- this.storedOptions = ($(this.input).hasClass('no-datalist-cache') || this._autocomplete == 'off') ? [] : getStoredOptions((this.input.name || this.input.id) + $.prop(this.input, 'type'));
3656
+ if(!hasControls){
3657
+ $(swfData.ref).attr('tabindex', '-1').css('outline', 'none');
2073
3658
  }
2074
3659
 
2075
- this.storedOptions.forEach(function(val, i){
2076
- if(values.indexOf(val) == -1){
2077
- allOptions.push({value: val, text: val, className: 'stored-suggest', style: ''});
3660
+ data.flashBlock = setTimeout(function(){
3661
+ if((!swfData.ref.parentNode && box[0].parentNode) || swfData.ref.style.display == "none"){
3662
+ box.addClass('flashblocker-assumed');
3663
+ $(elem).trigger('flashblocker');
3664
+ webshims.warn("flashblocker assumed");
2078
3665
  }
2079
- });
3666
+ $(swfData.ref).css({'minHeight': '2px', 'minWidth': '2px', display: 'block'});
3667
+ }, 9);
2080
3668
 
2081
- for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
2082
- item = allOptions[rI];
2083
- list[rI] = '<li class="'+ item.className +'" style="'+ item.style +'" tabindex="-1" role="listitem"><span class="option-label">'+ this.maskHTML(item.text) +'</span> <span class="option-value">'+ this.maskHTML(item.value) +'</span></li>';
3669
+ if(!localConnectionTimer){
3670
+ clearTimeout(localConnectionTimer);
3671
+ localConnectionTimer = setTimeout(function(){
3672
+ var flash = $(swfData.ref);
3673
+ if(flash[0].offsetWidth > 1 && flash[0].offsetHeight > 1 && location.protocol.indexOf('file:') === 0){
3674
+ 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");
3675
+ } else if(flash[0].offsetWidth < 2 || flash[0].offsetHeight < 2) {
3676
+ webshims.warn("JS-SWF connection can't be established on hidden or unconnected flash objects");
3677
+ }
3678
+ flash = null;
3679
+ }, 8000);
2084
3680
  }
3681
+ }
3682
+ });
3683
+
3684
+ };
3685
+
3686
+
3687
+ var queueSwfMethod = function(elem, fn, args, data){
3688
+ data = data || getSwfDataFromElem(elem);
3689
+
3690
+ if(data){
3691
+ if(data.api && data.api[fn]){
3692
+ data.api[fn].apply(data.api, args || []);
3693
+ } else {
3694
+ //todo add to queue
3695
+ data.actionQueue.push({fn: fn, args: args});
2085
3696
 
2086
- this.arrayOptions = allOptions;
2087
- this.shadowList.html('<div class="datalist-outer-box"><div class="datalist-box"><ul role="list">'+ list.join("\n") +'</ul></div></div>');
2088
-
2089
- if($.fn.bgIframe){
2090
- this.shadowList.bgIframe();
3697
+ if(data.actionQueue.length > 10){
3698
+ setTimeout(function(){
3699
+ if(data.actionQueue.length > 5){
3700
+ data.actionQueue.shift();
3701
+ }
3702
+ }, 99);
2091
3703
  }
2092
-
2093
- if(_forceShow || this.isListVisible){
2094
- this.showHideOptions();
3704
+ }
3705
+ return data;
3706
+ }
3707
+ return false;
3708
+ };
3709
+
3710
+ ['audio', 'video'].forEach(function(nodeName){
3711
+ var descs = {};
3712
+ var mediaSup;
3713
+ var createGetProp = function(key){
3714
+ if(nodeName == 'audio' && (key == 'videoHeight' || key == 'videoWidth')){return;}
3715
+
3716
+ descs[key] = {
3717
+ get: function(){
3718
+ var data = getSwfDataFromElem(this);
3719
+ if(data){
3720
+ return data[key];
3721
+ } else if(hasNative && mediaSup[key].prop._supget) {
3722
+ return mediaSup[key].prop._supget.apply(this);
3723
+ } else {
3724
+ return playerStateObj[key];
3725
+ }
3726
+ },
3727
+ writeable: false
3728
+ };
3729
+ };
3730
+ var createGetSetProp = function(key, setFn){
3731
+ createGetProp(key);
3732
+ delete descs[key].writeable;
3733
+ descs[key].set = setFn;
3734
+ };
3735
+
3736
+ createGetSetProp('volume', function(v){
3737
+ var data = getSwfDataFromElem(this);
3738
+ if(data){
3739
+ v *= 1;
3740
+ if(!isNaN(v)){
3741
+
3742
+ if(v < 0 || v > 1){
3743
+ webshims.error('volume greater or less than allowed '+ (v / 100));
3744
+ }
3745
+
3746
+ queueSwfMethod(this, 'api_volume', [v], data);
3747
+
3748
+
3749
+ if(data.volume != v){
3750
+ data.volume = v;
3751
+ trigger(data._elem, 'volumechange');
3752
+ }
3753
+ data = null;
3754
+ }
3755
+ } else if(mediaSup.volume.prop._supset) {
3756
+ return mediaSup.volume.prop._supset.apply(this, arguments);
3757
+ }
3758
+ });
3759
+
3760
+ createGetSetProp('muted', function(m){
3761
+ var data = getSwfDataFromElem(this);
3762
+ if(data){
3763
+ m = !!m;
3764
+ queueSwfMethod(this, 'api_muted', [m], data);
3765
+ if(data.muted != m){
3766
+ data.muted = m;
3767
+ trigger(data._elem, 'volumechange');
3768
+ }
3769
+ data = null;
3770
+ } else if(mediaSup.muted.prop._supset) {
3771
+ return mediaSup.muted.prop._supset.apply(this, arguments);
3772
+ }
3773
+ });
3774
+
3775
+
3776
+ createGetSetProp('currentTime', function(t){
3777
+ var data = getSwfDataFromElem(this);
3778
+ if(data){
3779
+ t *= 1;
3780
+ if (!isNaN(t)) {
3781
+ queueSwfMethod(this, 'api_seek', [t], data);
3782
+ }
3783
+
3784
+ } else if(mediaSup.currentTime.prop._supset) {
3785
+ return mediaSup.currentTime.prop._supset.apply(this, arguments);
3786
+ }
3787
+ });
3788
+
3789
+ ['play', 'pause'].forEach(function(fn){
3790
+ descs[fn] = {
3791
+ value: function(){
3792
+ var data = getSwfDataFromElem(this);
3793
+ if(data){
3794
+ if(data.stopPlayPause){
3795
+ clearTimeout(data.stopPlayPause);
3796
+ }
3797
+ queueSwfMethod(this, fn == 'play' ? 'api_play' : 'api_pause', [], data);
3798
+
3799
+ data._ppFlag = true;
3800
+ if(data.paused != (fn != 'play')){
3801
+ data.paused = fn != 'play';
3802
+ trigger(data._elem, fn);
3803
+ }
3804
+ } else if(mediaSup[fn].prop._supvalue) {
3805
+ return mediaSup[fn].prop._supvalue.apply(this, arguments);
3806
+ }
2095
3807
  }
2096
- },
2097
- showHideOptions: function(_fromShowList){
2098
- var value = $.prop(this.input, 'value').toLowerCase();
2099
- //first check prevent infinite loop, second creates simple lazy optimization
2100
- if(value === this.lastUpdatedValue || (this.lastUnfoundValue && value.indexOf(this.lastUnfoundValue) === 0)){
2101
- return;
3808
+ };
3809
+ });
3810
+
3811
+ getPropKeys.forEach(createGetProp);
3812
+
3813
+ webshims.onNodeNamesPropertyModify(nodeName, 'controls', function(val, boolProp){
3814
+ var data = getSwfDataFromElem(this);
3815
+ $(this)[boolProp ? 'addClass' : 'removeClass']('webshims-controls');
3816
+
3817
+ if(data){
3818
+ if(nodeName == 'audio'){
3819
+ setElementDimension(data, boolProp);
2102
3820
  }
3821
+ queueSwfMethod(this, 'api_controls', [boolProp], data);
3822
+ }
3823
+ });
3824
+
3825
+ webshims.onNodeNamesPropertyModify(nodeName, 'preload', function(val){
3826
+ var data = getSwfDataFromElem(this);
3827
+
3828
+
3829
+ if(data && bufferSrc(this)){
3830
+ queueSwfMethod(this, 'api_preload', [], data);
3831
+ }
3832
+ });
3833
+
3834
+ mediaSup = webshims.defineNodeNameProperties(nodeName, descs, 'prop');
3835
+ });
3836
+
3837
+ if(hasFlash && $.cleanData){
3838
+ var oldClean = $.cleanData;
3839
+ var flashNames = {
3840
+ object: 1,
3841
+ OBJECT: 1
3842
+ };
3843
+
3844
+ $.cleanData = function(elems){
3845
+ var i, len, prop;
3846
+ if(elems && (len = elems.length) && loadedSwf){
2103
3847
 
2104
- this.lastUpdatedValue = value;
2105
- var found = false;
2106
- var startSearch = this.searchStart;
2107
- var lis = $('li', this.shadowList);
2108
- if(value){
2109
- this.arrayOptions.forEach(function(item, i){
2110
- var search;
2111
- if(!('lowerText' in item)){
2112
- if(item.text != item.value){
2113
- item.lowerText = item.value.toLowerCase() + item.text.toLowerCase();
2114
- } else {
2115
- item.lowerText = item.text.toLowerCase();
2116
- }
2117
- }
2118
- search = item.lowerText.indexOf(value);
2119
- search = startSearch ? !search : search !== -1;
2120
- if(search){
2121
- $(lis[i]).removeClass('hidden-item');
2122
- found = true;
2123
- } else {
2124
- $(lis[i]).addClass('hidden-item');
3848
+ for(i = 0; i < len; i++){
3849
+ if(flashNames[elems[i].nodeName]){
3850
+ if('api_pause' in elems[i]){
3851
+ loadedSwf--;
3852
+ try {
3853
+ elems[i].api_pause();
3854
+ } catch(er){}
2125
3855
  }
2126
- });
2127
- } else if(lis.length) {
2128
- lis.removeClass('hidden-item');
2129
- found = true;
3856
+ }
2130
3857
  }
2131
3858
 
2132
- this.hasViewableData = found;
2133
- if(!_fromShowList && found){
2134
- this.showList();
2135
- }
2136
- if(!found){
2137
- this.lastUnfoundValue = value;
2138
- this.hideList();
2139
- }
3859
+ }
3860
+ return oldClean.apply(this, arguments);
3861
+ };
3862
+ }
3863
+
3864
+ if(!hasNative){
3865
+
3866
+ ['poster', 'src'].forEach(function(prop){
3867
+ webshims.defineNodeNamesProperty(prop == 'src' ? ['audio', 'video', 'source'] : ['video'], prop, {
3868
+ //attr: {},
3869
+ reflect: true,
3870
+ propType: 'src'
3871
+ });
3872
+ });
3873
+
3874
+ webshims.defineNodeNamesProperty(['audio', 'video'], 'preload', {
3875
+ reflect: true,
3876
+ propType: 'enumarated',
3877
+ defaultValue: '',
3878
+ limitedTo: ['', 'auto', 'metadata', 'none']
3879
+ });
3880
+
3881
+
3882
+ ['autoplay', 'controls'].forEach(function(name){
3883
+ webshims.defineNodeNamesBooleanProperty(['audio', 'video'], name);
3884
+ });
3885
+
3886
+ webshims.defineNodeNamesProperties(['audio', 'video'], {
3887
+ HAVE_CURRENT_DATA: {
3888
+ value: 2
2140
3889
  },
2141
- setPos: function(){
2142
- this.shadowList.css({marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0});
2143
- var css = (formsCFG.positionDatalist) ? $(this.input).position() : webshims.getRelOffset(this.shadowList, this.input);
2144
- css.top += $(this.input).outerHeight();
2145
- css.width = $(this.input).outerWidth() - (parseInt(this.shadowList.css('borderLeftWidth'), 10) || 0) - (parseInt(this.shadowList.css('borderRightWidth'), 10) || 0);
2146
- this.shadowList.css({marginTop: '', marginLeft: '', marginRight: '', marginBottom: ''}).css(css);
2147
- return css;
3890
+ HAVE_ENOUGH_DATA: {
3891
+ value: 4
2148
3892
  },
2149
- showList: function(){
2150
- if(this.isListVisible){return false;}
2151
- if(this.needsUpdate){
2152
- this.updateListOptions();
2153
- }
2154
- this.showHideOptions(true);
2155
- if(!this.hasViewableData){return false;}
2156
- this.isListVisible = true;
2157
- var that = this;
2158
-
2159
- that.setPos();
2160
- that.shadowList.addClass('datalist-visible').find('li.active-item').removeClass('active-item');
2161
-
2162
- $(window).unbind('.datalist'+that.id);
2163
- $(document)
2164
- .off('.datalist'+that.id)
2165
- .on('mousedown.datalist'+that.id +' focusin.datalist'+that.id, function(e){
2166
- if(e.target === that.input || that.shadowList[0] === e.target || $.contains( that.shadowList[0], e.target )){
2167
- clearTimeout(that.hideTimer);
2168
- setTimeout(function(){
2169
- clearTimeout(that.hideTimer);
2170
- }, 9);
2171
- } else {
2172
- that.timedHide();
2173
- }
2174
- })
2175
- .on('updateshadowdom.datalist'+that.id, function(){
2176
- that.setPos();
2177
- })
2178
- ;
2179
- return true;
3893
+ HAVE_FUTURE_DATA: {
3894
+ value: 3
2180
3895
  },
2181
- hideList: function(){
2182
- if(!this.isListVisible){return false;}
2183
- var that = this;
2184
- var triggerChange = function(e){
2185
- if(that.changedValue){
2186
- $(that.input).trigger('change');
2187
- }
2188
- that.changedValue = false;
2189
- };
2190
-
2191
- that.shadowList.removeClass('datalist-visible list-item-active');
2192
- that.index = -1;
2193
- that.isListVisible = false;
2194
- if(that.changedValue){
2195
- that.triggeredByDatalist = true;
2196
- webshims.triggerInlineForm && webshims.triggerInlineForm(that.input, 'input');
2197
- if($(that.input).is(':focus')){
2198
- $(that.input).one('blur', triggerChange);
2199
- } else {
2200
- triggerChange();
2201
- }
2202
- that.triggeredByDatalist = false;
2203
- }
2204
- $(document).unbind('.datalist'+that.id);
2205
- $(window)
2206
- .off('.datalist'+that.id)
2207
- .one('resize.datalist'+that.id, function(){
2208
- that.shadowList.css({top: 0, left: 0});
2209
- })
2210
- ;
2211
- return true;
3896
+ HAVE_METADATA: {
3897
+ value: 1
2212
3898
  },
2213
- scrollIntoView: function(elem){
2214
- var ul = $('ul', this.shadowList);
2215
- var div = $('div.datalist-box', this.shadowList);
2216
- var elemPos = elem.position();
2217
- var containerHeight;
2218
- elemPos.top -= (parseInt(ul.css('paddingTop'), 10) || 0) + (parseInt(ul.css('marginTop'), 10) || 0) + (parseInt(ul.css('borderTopWidth'), 10) || 0);
2219
- if(elemPos.top < 0){
2220
- div.scrollTop( div.scrollTop() + elemPos.top - 2);
2221
- return;
2222
- }
2223
- elemPos.top += elem.outerHeight();
2224
- containerHeight = div.height();
2225
- if(elemPos.top > containerHeight){
2226
- div.scrollTop( div.scrollTop() + (elemPos.top - containerHeight) + 2);
2227
- }
3899
+ HAVE_NOTHING: {
3900
+ value: 0
2228
3901
  },
2229
- changeValue: function(activeItem){
2230
- if(!activeItem[0]){return;}
2231
- var newValue = $('span.option-value', activeItem).text();
2232
- var oldValue = $.prop(this.input, 'value');
2233
- if(newValue != oldValue){
2234
- $(this.input)
2235
- .prop('value', newValue)
2236
- .triggerHandler('updateInput')
2237
- ;
2238
- this.changedValue = true;
2239
- }
3902
+ NETWORK_EMPTY: {
3903
+ value: 0
2240
3904
  },
2241
- markItem: function(index, doValue, items){
2242
- var activeItem;
2243
- var goesUp;
2244
-
2245
- items = items || $('li:not(.hidden-item)', this.shadowList);
2246
- if(!items.length){return;}
2247
- if(index < 0){
2248
- index = items.length - 1;
2249
- } else if(index >= items.length){
2250
- index = 0;
2251
- }
2252
- items.removeClass('active-item');
2253
- this.shadowList.addClass('list-item-active');
2254
- activeItem = items.filter(':eq('+ index +')').addClass('active-item');
2255
-
2256
- if(doValue){
2257
- this.changeValue(activeItem);
2258
- this.scrollIntoView(activeItem);
2259
- }
2260
- this.index = index;
3905
+ NETWORK_IDLE: {
3906
+ value: 1
3907
+ },
3908
+ NETWORK_LOADING: {
3909
+ value: 2
3910
+ },
3911
+ NETWORK_NO_SOURCE: {
3912
+ value: 3
2261
3913
  }
2262
- };
2263
-
2264
- //init datalist update
2265
- initializeDatalist();
2266
- })();
3914
+
3915
+ }, 'prop');
3916
+ }
3917
+
2267
3918
 
2268
3919
  });