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,2376 +0,0 @@
1
- //DOM-Extension helper
2
- jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
3
- "use strict";
4
- //shortcus
5
- var modules = webshims.modules;
6
- var listReg = /\s*,\s*/;
7
-
8
- //proxying attribute
9
- var olds = {};
10
- var havePolyfill = {};
11
- var extendedProps = {};
12
- var extendQ = {};
13
- var modifyProps = {};
14
-
15
- 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);
22
- };
23
-
24
- $.fn.val = function(val){
25
- var elem = this[0];
26
- if(arguments.length && val == null){
27
- val = '';
28
- }
29
- if(!arguments.length){
30
- if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
31
- return $.prop(elem, 'value', val, 'val', true);
32
- }
33
- if($.isArray(val)){
34
- return oldVal.apply(this, arguments);
35
- }
36
- var isFunction = $.isFunction(val);
37
- return this.each(function(i){
38
- elem = this;
39
- if(elem.nodeType === 1){
40
- if(isFunction){
41
- var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
42
- if(genVal == null){
43
- genVal = '';
44
- }
45
- $.prop(elem, 'value', genVal, 'val') ;
46
- } else {
47
- $.prop(elem, 'value', val, 'val');
48
- }
49
- }
50
- });
51
- };
52
-
53
- var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
54
- var elementData = function(elem, key, val){
55
- elem = elem.jquery ? elem[0] : elem;
56
- if(!elem){return val || {};}
57
- var data = $.data(elem, dataID);
58
- if(val !== undefined){
59
- if(!data){
60
- data = $.data(elem, dataID, {});
61
- }
62
- if(key){
63
- data[key] = val;
64
- }
65
- }
66
-
67
- return key ? data && data[key] : data;
68
- };
69
-
70
-
71
- [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
72
- $.fn[data.name] = function(){
73
- return this.map(function(){
74
- var shadowData = elementData(this, 'shadowData');
75
- return shadowData && shadowData[data.prop] || this;
76
- });
77
- };
78
- });
79
-
80
-
81
- ['removeAttr', 'prop', 'attr'].forEach(function(type){
82
- olds[type] = $[type];
83
- $[type] = function(elem, name, value, pass, _argless){
84
- var isVal = (pass == 'val');
85
- var oldMethod = !isVal ? olds[type] : singleVal;
86
- if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
87
- return oldMethod(elem, name, value, pass, _argless);
88
- }
89
-
90
- var nodeName = (elem.nodeName || '').toLowerCase();
91
- var desc = extendedProps[nodeName];
92
- var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
93
- var propMethod;
94
- var oldValMethod;
95
- var ret;
96
-
97
-
98
- if(!desc){
99
- desc = extendedProps['*'];
100
- }
101
- if(desc){
102
- desc = desc[name];
103
- }
104
-
105
- if(desc){
106
- propMethod = desc[curType];
107
- }
108
-
109
- if(propMethod){
110
- if(name == 'value'){
111
- oldValMethod = propMethod.isVal;
112
- propMethod.isVal = isVal;
113
- }
114
- if(curType === 'removeAttr'){
115
- return propMethod.value.call(elem);
116
- } else if(value === undefined){
117
- return (propMethod.get) ?
118
- propMethod.get.call(elem) :
119
- propMethod.value
120
- ;
121
- } else if(propMethod.set) {
122
- if(type == 'attr' && value === true){
123
- value = name;
124
- }
125
-
126
- ret = propMethod.set.call(elem, value);
127
- }
128
- if(name == 'value'){
129
- propMethod.isVal = oldValMethod;
130
- }
131
- } else {
132
- ret = oldMethod(elem, name, value, pass, _argless);
133
- }
134
- if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
135
-
136
- var boolValue;
137
- if(curType == 'removeAttr'){
138
- boolValue = false;
139
- } else if(curType == 'prop'){
140
- boolValue = !!(value);
141
- } else {
142
- boolValue = true;
143
- }
144
-
145
- modifyProps[nodeName][name].forEach(function(fn){
146
- if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
147
- fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
148
- }
149
- });
150
- }
151
- return ret;
152
- };
153
-
154
- extendQ[type] = function(nodeName, prop, desc){
155
-
156
- if(!extendedProps[nodeName]){
157
- extendedProps[nodeName] = {};
158
- }
159
- if(!extendedProps[nodeName][prop]){
160
- extendedProps[nodeName][prop] = {};
161
- }
162
- var oldDesc = extendedProps[nodeName][prop][type];
163
- var getSup = function(propType, descriptor, oDesc){
164
- if(descriptor && descriptor[propType]){
165
- return descriptor[propType];
166
- }
167
- if(oDesc && oDesc[propType]){
168
- return oDesc[propType];
169
- }
170
- if(type == 'prop' && prop == 'value'){
171
- return function(value){
172
- var elem = this;
173
- return (desc.isVal) ?
174
- singleVal(elem, prop, value, false, (arguments.length === 0)) :
175
- olds[type](elem, prop, value)
176
- ;
177
- };
178
- }
179
- if(type == 'prop' && propType == 'value' && desc.value.apply){
180
- return function(value){
181
- var sup = olds[type](this, prop);
182
- if(sup && sup.apply){
183
- sup = sup.apply(this, arguments);
184
- }
185
- return sup;
186
- };
187
- }
188
- return function(value){
189
- return olds[type](this, prop, value);
190
- };
191
- };
192
- extendedProps[nodeName][prop][type] = desc;
193
- if(desc.value === undefined){
194
- if(!desc.set){
195
- desc.set = desc.writeable ?
196
- getSup('set', desc, oldDesc) :
197
- (webshims.cfg.useStrict && prop == 'prop') ?
198
- function(){throw(prop +' is readonly on '+ nodeName);} :
199
- $.noop
200
- ;
201
- }
202
- if(!desc.get){
203
- desc.get = getSup('get', desc, oldDesc);
204
- }
205
-
206
- }
207
-
208
- ['value', 'get', 'set'].forEach(function(descProp){
209
- if(desc[descProp]){
210
- desc['_sup'+descProp] = getSup(descProp, oldDesc);
211
- }
212
- });
213
- };
214
-
215
- });
216
-
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
- var extendNativeValue = (function(){
220
- var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
221
- var has = Object.prototype.hasOwnProperty;
222
- 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) ) ){
226
- var sup = elem[prop];
227
- desc._supvalue = function(){
228
- if(sup && sup.apply){
229
- return sup.apply(this, arguments);
230
- }
231
- return sup;
232
- };
233
- elemProto[prop] = desc.value;
234
- } else {
235
- desc._supvalue = function(){
236
- var data = elementData(this, 'propValue');
237
- if(data && data[prop] && data[prop].apply){
238
- return data[prop].apply(this, arguments);
239
- }
240
- return data && data[prop];
241
- };
242
- initProp.extendValue(nodeName, prop, desc.value);
243
- }
244
- desc.value._supvalue = desc._supvalue;
245
- };
246
- })();
247
-
248
- var initProp = (function(){
249
-
250
- var initProps = {};
251
-
252
- webshims.addReady(function(context, contextElem){
253
- var nodeNameCache = {};
254
- var getElementsByName = function(name){
255
- if(!nodeNameCache[name]){
256
- nodeNameCache[name] = $(context.getElementsByTagName(name));
257
- if(contextElem[0] && $.nodeName(contextElem[0], name)){
258
- nodeNameCache[name] = nodeNameCache[name].add(contextElem);
259
- }
260
- }
261
- };
262
-
263
-
264
- $.each(initProps, function(name, fns){
265
- getElementsByName(name);
266
- if(!fns || !fns.forEach){
267
- webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
268
- return;
269
- }
270
- fns.forEach(function(fn){
271
- nodeNameCache[name].each(fn);
272
- });
273
- });
274
- nodeNameCache = null;
275
- });
276
-
277
- var tempCache;
278
- var emptyQ = $([]);
279
- var createNodeNameInit = function(nodeName, fn){
280
- if(!initProps[nodeName]){
281
- initProps[nodeName] = [fn];
282
- } else {
283
- initProps[nodeName].push(fn);
284
- }
285
- if($.isDOMReady){
286
- (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
287
- }
288
- };
289
-
290
- var elementExtends = {};
291
- return {
292
- createTmpCache: function(nodeName){
293
- if($.isDOMReady){
294
- tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
295
- }
296
- return tempCache || emptyQ;
297
- },
298
- flushTmpCache: function(){
299
- tempCache = null;
300
- },
301
- content: function(nodeName, prop){
302
- createNodeNameInit(nodeName, function(){
303
- var val = $.attr(this, prop);
304
- if(val != null){
305
- $.attr(this, prop, val);
306
- }
307
- });
308
- },
309
- createElement: function(nodeName, fn){
310
- createNodeNameInit(nodeName, fn);
311
- },
312
- extendValue: function(nodeName, prop, value){
313
- createNodeNameInit(nodeName, function(){
314
- $(this).each(function(){
315
- var data = elementData(this, 'propValue', {});
316
- data[prop] = this[prop];
317
- this[prop] = value;
318
- });
319
- });
320
- }
321
- };
322
- })();
323
-
324
- var createPropDefault = function(descs, removeType){
325
- if(descs.defaultValue === undefined){
326
- descs.defaultValue = '';
327
- }
328
- if(!descs.removeAttr){
329
- descs.removeAttr = {
330
- value: function(){
331
- descs[removeType || 'prop'].set.call(this, descs.defaultValue);
332
- descs.removeAttr._supvalue.call(this);
333
- }
334
- };
335
- }
336
- if(!descs.attr){
337
- descs.attr = {};
338
- }
339
- };
340
-
341
- $.extend(webshims, {
342
-
343
- getID: (function(){
344
- var ID = new Date().getTime();
345
- return function(elem){
346
- elem = $(elem);
347
- var id = elem.attr('id');
348
- if(!id){
349
- ID++;
350
- id = 'ID-'+ ID;
351
- elem.attr('id', id);
352
- }
353
- return id;
354
- };
355
- })(),
356
- extendUNDEFProp: function(obj, props){
357
- $.each(props, function(name, prop){
358
- if( !(name in obj) ){
359
- obj[name] = prop;
360
- }
361
- });
362
- },
363
- //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
364
- createPropDefault: createPropDefault,
365
- data: elementData,
366
- moveToFirstEvent: function(elem, eventType, bindType){
367
- var events = ($._data(elem, 'events') || {})[eventType];
368
- var fn;
369
-
370
- if(events && events.length > 1){
371
- fn = events.pop();
372
- if(!bindType){
373
- bindType = 'bind';
374
- }
375
- if(bindType == 'bind' && events.delegateCount){
376
- events.splice( events.delegateCount, 0, fn);
377
- } else {
378
- events.unshift( fn );
379
- }
380
-
381
-
382
- }
383
- elem = null;
384
- },
385
- addShadowDom: (function(){
386
- var resizeTimer;
387
- var lastHeight;
388
- var lastWidth;
389
-
390
- var docObserve = {
391
- init: false,
392
- runs: 0,
393
- test: function(){
394
- var height = docObserve.getHeight();
395
- var width = docObserve.getWidth();
396
-
397
- if(height != docObserve.height || width != docObserve.width){
398
- docObserve.height = height;
399
- docObserve.width = width;
400
- docObserve.handler({type: 'docresize'});
401
- docObserve.runs++;
402
- if(docObserve.runs < 9){
403
- setTimeout(docObserve.test, 90);
404
- }
405
- } else {
406
- docObserve.runs = 0;
407
- }
408
- },
409
- handler: function(e){
410
- clearTimeout(resizeTimer);
411
- resizeTimer = setTimeout(function(){
412
- if(e.type == 'resize'){
413
- var width = $(window).width();
414
- var height = $(window).width();
415
- if(height == lastHeight && width == lastWidth){
416
- return;
417
- }
418
- lastHeight = height;
419
- lastWidth = width;
420
-
421
- docObserve.height = docObserve.getHeight();
422
- docObserve.width = docObserve.getWidth();
423
-
424
- }
425
- $(document).triggerHandler('updateshadowdom');
426
- }, (e.type == 'resize') ? 50 : 9);
427
- },
428
- _create: function(){
429
- $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
430
- var body = document.body;
431
- var doc = document.documentElement;
432
- docObserve[type] = function(){
433
- return Math.max(
434
- body[ "scroll" + name ], doc[ "scroll" + name ],
435
- body[ "offset" + name ], doc[ "offset" + name ],
436
- doc[ "client" + name ]
437
- );
438
- };
439
- });
440
- },
441
- start: function(){
442
- if(!this.init && document.body){
443
- this.init = true;
444
- this._create();
445
- this.height = docObserve.getHeight();
446
- this.width = docObserve.getWidth();
447
- setInterval(this.test, 600);
448
- $(this.test);
449
- webshims.ready('WINDOWLOAD', this.test);
450
- $(window).bind('resize', this.handler);
451
- (function(){
452
- var oldAnimate = $.fn.animate;
453
- var animationTimer;
454
-
455
- $.fn.animate = function(){
456
- clearTimeout(animationTimer);
457
- animationTimer = setTimeout(function(){
458
- docObserve.test();
459
- }, 99);
460
-
461
- return oldAnimate.apply(this, arguments);
462
- };
463
- })();
464
- }
465
- }
466
- };
467
-
468
-
469
- webshims.docObserve = function(){
470
- webshims.ready('DOM', function(){
471
- docObserve.start();
472
- });
473
- };
474
- return function(nativeElem, shadowElem, opts){
475
- opts = opts || {};
476
- if(nativeElem.jquery){
477
- nativeElem = nativeElem[0];
478
- }
479
- if(shadowElem.jquery){
480
- shadowElem = shadowElem[0];
481
- }
482
- var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
483
- var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
484
- var shadowFocusElementData = {};
485
- if(!opts.shadowFocusElement){
486
- opts.shadowFocusElement = shadowElem;
487
- } else if(opts.shadowFocusElement){
488
- if(opts.shadowFocusElement.jquery){
489
- opts.shadowFocusElement = opts.shadowFocusElement[0];
490
- }
491
- shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
492
- }
493
-
494
- nativeData.hasShadow = shadowElem;
495
- shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
496
- shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
497
- nativeElement: nativeElem,
498
- shadowElement: shadowElem,
499
- shadowFocusElement: opts.shadowFocusElement
500
- };
501
- if(opts.shadowChilds){
502
- opts.shadowChilds.each(function(){
503
- elementData(this, 'shadowData', shadowData.shadowData);
504
- });
505
- }
506
-
507
- if(opts.data){
508
- shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
509
- }
510
- opts = null;
511
- webshims.docObserve();
512
- };
513
- })(),
514
- propTypes: {
515
- standard: function(descs, name){
516
- createPropDefault(descs);
517
- if(descs.prop){return;}
518
- descs.prop = {
519
- set: function(val){
520
- descs.attr.set.call(this, ''+val);
521
- },
522
- get: function(){
523
- return descs.attr.get.call(this) || descs.defaultValue;
524
- }
525
- };
526
-
527
- },
528
- "boolean": function(descs, name){
529
-
530
- createPropDefault(descs);
531
- if(descs.prop){return;}
532
- descs.prop = {
533
- set: function(val){
534
- if(val){
535
- descs.attr.set.call(this, "");
536
- } else {
537
- descs.removeAttr.value.call(this);
538
- }
539
- },
540
- get: function(){
541
- return descs.attr.get.call(this) != null;
542
- }
543
- };
544
- },
545
- "src": (function(){
546
- var anchor = document.createElement('a');
547
- anchor.style.display = "none";
548
- return function(descs, name){
549
-
550
- createPropDefault(descs);
551
- if(descs.prop){return;}
552
- descs.prop = {
553
- set: function(val){
554
- descs.attr.set.call(this, val);
555
- },
556
- get: function(){
557
- var href = this.getAttribute(name);
558
- var ret;
559
- if(href == null){return '';}
560
-
561
- anchor.setAttribute('href', href+'' );
562
-
563
- if(!$.support.hrefNormalized){
564
- try {
565
- $(anchor).insertAfter(this);
566
- ret = anchor.getAttribute('href', 4);
567
- } catch(er){
568
- ret = anchor.getAttribute('href', 4);
569
- }
570
- $(anchor).detach();
571
- }
572
- return ret || anchor.href;
573
- }
574
- };
575
- };
576
- })(),
577
- enumarated: function(descs, name){
578
-
579
- createPropDefault(descs);
580
- if(descs.prop){return;}
581
- descs.prop = {
582
- set: function(val){
583
- descs.attr.set.call(this, val);
584
- },
585
- get: function(){
586
- var val = (descs.attr.get.call(this) || '').toLowerCase();
587
- if(!val || descs.limitedTo.indexOf(val) == -1){
588
- val = descs.defaultValue;
589
- }
590
- return val;
591
- }
592
- };
593
- }
594
-
595
- // ,unsignedLong: $.noop
596
- // ,"doubble": $.noop
597
- // ,"long": $.noop
598
- // ,tokenlist: $.noop
599
- // ,settableTokenlist: $.noop
600
- },
601
- reflectProperties: function(nodeNames, props){
602
- if(typeof props == 'string'){
603
- props = props.split(listReg);
604
- }
605
- props.forEach(function(prop){
606
- webshims.defineNodeNamesProperty(nodeNames, prop, {
607
- prop: {
608
- set: function(val){
609
- $.attr(this, prop, val);
610
- },
611
- get: function(){
612
- return $.attr(this, prop) || '';
613
- }
614
- }
615
- });
616
- });
617
- },
618
- defineNodeNameProperty: function(nodeName, prop, descs){
619
- havePolyfill[prop] = true;
620
-
621
- if(descs.reflect){
622
- webshims.propTypes[descs.propType || 'standard'](descs, prop);
623
- }
624
-
625
- ['prop', 'attr', 'removeAttr'].forEach(function(type){
626
- var desc = descs[type];
627
- if(desc){
628
- if(type === 'prop'){
629
- desc = $.extend({writeable: true}, desc);
630
- } else {
631
- desc = $.extend({}, desc, {writeable: true});
632
- }
633
-
634
- extendQ[type](nodeName, prop, desc);
635
- if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
636
- extendNativeValue(nodeName, prop, desc);
637
- }
638
- descs[type] = desc;
639
- }
640
- });
641
- if(descs.initAttr){
642
- initProp.content(nodeName, prop);
643
- }
644
- return descs;
645
- },
646
-
647
- defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
648
- var olddesc;
649
- for(var prop in descs){
650
- if(!_noTmpCache && descs[prop].initAttr){
651
- initProp.createTmpCache(name);
652
- }
653
- if(propType){
654
- if(descs[prop][propType]){
655
- //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
656
- } else {
657
- descs[prop][propType] = {};
658
- ['value', 'set', 'get'].forEach(function(copyProp){
659
- if(copyProp in descs[prop]){
660
- descs[prop][propType][copyProp] = descs[prop][copyProp];
661
- delete descs[prop][copyProp];
662
- }
663
- });
664
- }
665
- }
666
- descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
667
- }
668
- if(!_noTmpCache){
669
- initProp.flushTmpCache();
670
- }
671
- return descs;
672
- },
673
-
674
- createElement: function(nodeName, create, descs){
675
- var ret;
676
- if($.isFunction(create)){
677
- create = {
678
- after: create
679
- };
680
- }
681
- initProp.createTmpCache(nodeName);
682
- if(create.before){
683
- initProp.createElement(nodeName, create.before);
684
- }
685
- if(descs){
686
- ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
687
- }
688
- if(create.after){
689
- initProp.createElement(nodeName, create.after);
690
- }
691
- initProp.flushTmpCache();
692
- return ret;
693
- },
694
- onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
695
- if(typeof nodeNames == 'string'){
696
- nodeNames = nodeNames.split(listReg);
697
- }
698
- if($.isFunction(desc)){
699
- desc = {set: desc};
700
- }
701
-
702
- nodeNames.forEach(function(name){
703
- if(!modifyProps[name]){
704
- modifyProps[name] = {};
705
- }
706
- if(typeof props == 'string'){
707
- props = props.split(listReg);
708
- }
709
- if(desc.initAttr){
710
- initProp.createTmpCache(name);
711
- }
712
- props.forEach(function(prop){
713
- if(!modifyProps[name][prop]){
714
- modifyProps[name][prop] = [];
715
- havePolyfill[prop] = true;
716
- }
717
- if(desc.set){
718
- if(only){
719
- desc.set.only = only;
720
- }
721
- modifyProps[name][prop].push(desc.set);
722
- }
723
-
724
- if(desc.initAttr){
725
- initProp.content(name, prop);
726
- }
727
- });
728
- initProp.flushTmpCache();
729
-
730
- });
731
- },
732
- defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
733
- if(!descs){
734
- descs = {};
735
- }
736
- if($.isFunction(descs)){
737
- descs.set = descs;
738
- }
739
- webshims.defineNodeNamesProperty(elementNames, prop, {
740
- attr: {
741
- set: function(val){
742
- this.setAttribute(prop, val);
743
- if(descs.set){
744
- descs.set.call(this, true);
745
- }
746
- },
747
- get: function(){
748
- var ret = this.getAttribute(prop);
749
- return (ret == null) ? undefined : prop;
750
- }
751
- },
752
- removeAttr: {
753
- value: function(){
754
- this.removeAttribute(prop);
755
- if(descs.set){
756
- descs.set.call(this, false);
757
- }
758
- }
759
- },
760
- reflect: true,
761
- propType: 'boolean',
762
- initAttr: descs.initAttr || false
763
- });
764
- },
765
- contentAttr: function(elem, name, val){
766
- if(!elem.nodeName){return;}
767
- var attr;
768
- if(val === undefined){
769
- attr = (elem.attributes[name] || {});
770
- val = attr.specified ? attr.value : null;
771
- return (val == null) ? undefined : val;
772
- }
773
-
774
- if(typeof val == 'boolean'){
775
- if(!val){
776
- elem.removeAttribute(name);
777
- } else {
778
- elem.setAttribute(name, name);
779
- }
780
- } else {
781
- elem.setAttribute(name, val);
782
- }
783
- },
784
-
785
- // set current Lang:
786
- // - webshims.activeLang(lang:string);
787
- // get current lang
788
- // - webshims.activeLang();
789
- // get current lang
790
- // webshims.activeLang({
791
- // register: moduleName:string,
792
- // callback: callback:function
793
- // });
794
- // get/set including removeLang
795
- // - webshims.activeLang({
796
- // module: moduleName:string,
797
- // callback: callback:function,
798
- // langObj: languageObj:array/object
799
- // });
800
- activeLang: (function(){
801
- var callbacks = [];
802
- var registeredCallbacks = {};
803
- var currentLang;
804
- var shortLang;
805
- var notLocal = /:\/\/|^\.*\//;
806
- var loadRemoteLang = function(data, lang, options){
807
- var langSrc;
808
- if(lang && options && $.inArray(lang, options.availabeLangs || []) !== -1){
809
- data.loading = true;
810
- langSrc = options.langSrc;
811
- if(!notLocal.test(langSrc)){
812
- langSrc = webshims.cfg.basePath+langSrc;
813
- }
814
- webshims.loader.loadScript(langSrc+lang+'.js', function(){
815
- if(data.langObj[lang]){
816
- data.loading = false;
817
- callLang(data, true);
818
- } else {
819
- $(function(){
820
- if(data.langObj[lang]){
821
- callLang(data, true);
822
- }
823
- data.loading = false;
824
- });
825
- }
826
- });
827
- return true;
828
- }
829
- return false;
830
- };
831
- var callRegister = function(module){
832
- if(registeredCallbacks[module]){
833
- registeredCallbacks[module].forEach(function(data){
834
- data.callback();
835
- });
836
- }
837
- };
838
- var callLang = function(data, _noLoop){
839
- if(data.activeLang != currentLang && data.activeLang !== shortLang){
840
- var options = modules[data.module].options;
841
- if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
842
- data.activeLang = currentLang;
843
- data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
844
- callRegister(data.module);
845
- } else if( !_noLoop &&
846
- !loadRemoteLang(data, currentLang, options) &&
847
- !loadRemoteLang(data, shortLang, options) &&
848
- data.langObj[''] && data.activeLang !== '' ) {
849
- data.activeLang = '';
850
- data.callback(data.langObj[''], currentLang);
851
- callRegister(data.module);
852
- }
853
- }
854
- };
855
-
856
-
857
- var activeLang = function(lang){
858
-
859
- if(typeof lang == 'string' && lang !== currentLang){
860
- currentLang = lang;
861
- shortLang = currentLang.split('-')[0];
862
- if(currentLang == shortLang){
863
- shortLang = false;
864
- }
865
- $.each(callbacks, function(i, data){
866
- callLang(data);
867
- });
868
- } else if(typeof lang == 'object'){
869
-
870
- if(lang.register){
871
- if(!registeredCallbacks[lang.register]){
872
- registeredCallbacks[lang.register] = [];
873
- }
874
- registeredCallbacks[lang.register].push(lang);
875
- lang.callback();
876
- } else {
877
- if(!lang.activeLang){
878
- lang.activeLang = '';
879
- }
880
- callbacks.push(lang);
881
- callLang(lang);
882
- }
883
- }
884
- return currentLang;
885
- };
886
-
887
- return activeLang;
888
- })()
889
- });
890
-
891
- $.each({
892
- defineNodeNamesProperty: 'defineNodeNameProperty',
893
- defineNodeNamesProperties: 'defineNodeNameProperties',
894
- createElements: 'createElement'
895
- }, function(name, baseMethod){
896
- webshims[name] = function(names, a, b, c){
897
- if(typeof names == 'string'){
898
- names = names.split(listReg);
899
- }
900
- var retDesc = {};
901
- names.forEach(function(nodeName){
902
- retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
903
- });
904
- return retDesc;
905
- };
906
- });
907
-
908
- webshims.isReady('webshimLocalization', true);
909
- });
910
- //html5a11y
911
- (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;}
914
-
915
- var elemMappings = {
916
- article: "article",
917
- aside: "complementary",
918
- section: "region",
919
- nav: "navigation",
920
- address: "contentinfo"
921
- };
922
- var addRole = function(elem, role){
923
- var hasRole = elem.getAttribute('role');
924
- if (!hasRole) {
925
- elem.setAttribute('role', role);
926
- }
927
- };
928
-
929
- $.webshims.addReady(function(context, contextElem){
930
- $.each(elemMappings, function(name, role){
931
- var elems = $(name, context).add(contextElem.filter(name));
932
- for (var i = 0, len = elems.length; i < len; i++) {
933
- addRole(elems[i], role);
934
- }
935
- });
936
- if (context === document) {
937
- var header = document.getElementsByTagName('header')[0];
938
- var footers = document.getElementsByTagName('footer');
939
- var footerLen = footers.length;
940
- if (header && !$(header).closest('section, article')[0]) {
941
- addRole(header, 'banner');
942
- }
943
- if (!footerLen) {
944
- return;
945
- }
946
- var footer = footers[footerLen - 1];
947
- if (!$(footer).closest('section, article')[0]) {
948
- addRole(footer, 'contentinfo');
949
- }
950
- }
951
- });
952
-
953
- })(jQuery, document);
954
-
955
- (function($, Modernizr, webshims){
956
- "use strict";
957
- var hasNative = Modernizr.audio && Modernizr.video;
958
- var supportsLoop = false;
959
- var bugs = webshims.bugs;
960
-
961
- var loadSwf = function(){
962
- webshims.ready(swfType, function(){
963
- if(!webshims.mediaelement.createSWF){
964
- webshims.mediaelement.loadSwf = true;
965
- webshims.reTest([swfType], hasNative);
966
- }
967
- });
968
- };
969
- var options = webshims.cfg.mediaelement;
970
- var swfType = options && options.player == 'jwplayer' ? 'mediaelement-swf' : 'mediaelement-jaris';
971
- var hasSwf;
972
- if(!options){
973
- webshims.error("mediaelement wasn't implemented but loaded");
974
- return;
975
- }
976
- if(hasNative){
977
- var videoElem = document.createElement('video');
978
- Modernizr.videoBuffered = ('buffered' in videoElem);
979
- supportsLoop = ('loop' in videoElem);
980
-
981
- webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
982
-
983
- if(!Modernizr.videoBuffered){
984
- webshims.addPolyfill('mediaelement-native-fix', {
985
- f: 'mediaelement',
986
- test: Modernizr.videoBuffered,
987
- d: ['dom-support']
988
- });
989
-
990
- webshims.reTest('mediaelement-native-fix');
991
- }
992
- }
993
-
994
- if(hasNative && !options.preferFlash){
995
- var switchOptions = function(e){
996
- var parent = e.target.parentNode;
997
- if(!options.preferFlash && ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) ){
998
- webshims.ready('DOM mediaelement', function(){
999
- if(hasSwf){
1000
- loadSwf();
1001
- }
1002
- webshims.ready('WINDOWLOAD '+swfType, function(){
1003
- setTimeout(function(){
1004
- if(hasSwf && !options.preferFlash && webshims.mediaelement.createSWF && !$(e.target).closest('audio, video').is('.nonnative-api-active')){
1005
- options.preferFlash = true;
1006
- document.removeEventListener('error', switchOptions, true);
1007
- $('audio, video').each(function(){
1008
- webshims.mediaelement.selectSource(this);
1009
- });
1010
- webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src);
1011
- } else if(!hasSwf){
1012
- document.removeEventListener('error', switchOptions, true);
1013
- }
1014
- }, 20);
1015
- });
1016
- });
1017
- }
1018
- };
1019
- document.addEventListener('error', switchOptions, true);
1020
- $('audio, video').each(function(){
1021
- if(this.error){
1022
- switchOptions({target: this});
1023
- }
1024
- });
1025
- }
1026
-
1027
-
1028
- if(Modernizr.track && !bugs.track){
1029
- (function(){
1030
-
1031
- if(!bugs.track){
1032
- bugs.track = typeof $('<track />')[0].readyState != 'number';
1033
- }
1034
-
1035
- if(!bugs.track){
1036
- try {
1037
- new TextTrackCue(2, 3, '');
1038
- } catch(e){
1039
- bugs.track = true;
1040
- }
1041
- }
1042
-
1043
- var trackOptions = webshims.cfg.track;
1044
- var trackListener = function(e){
1045
- $(e.target).filter('track').each(changeApi);
1046
- };
1047
- var changeApi = function(){
1048
- if(bugs.track || (!trackOptions.override && $.prop(this, 'readyState') == 3)){
1049
- trackOptions.override = true;
1050
- webshims.reTest('track');
1051
- document.removeEventListener('error', trackListener, true);
1052
- if(this && $.nodeName(this, 'track')){
1053
- webshims.error("track support was overwritten. Please check your vtt including your vtt mime-type");
1054
- } else {
1055
- webshims.info("track support was overwritten. due to bad browser support");
1056
- }
1057
- }
1058
- };
1059
- var detectTrackError = function(){
1060
- document.addEventListener('error', trackListener, true);
1061
-
1062
- if(bugs.track){
1063
- changeApi();
1064
- } else {
1065
- $('track').each(changeApi);
1066
- }
1067
- };
1068
- if(!trackOptions.override){
1069
- if(webshims.isReady('track')){
1070
- detectTrackError();
1071
- } else {
1072
- $(detectTrackError);
1073
- }
1074
- }
1075
- })();
1076
-
1077
- }
1078
-
1079
- webshims.register('mediaelement-core', function($, webshims, window, document, undefined){
1080
- hasSwf = swfobject.hasFlashPlayerVersion('9.0.115');
1081
- $('html').addClass(hasSwf ? 'swf' : 'no-swf');
1082
- var mediaelement = webshims.mediaelement;
1083
- mediaelement.parseRtmp = function(data){
1084
- var src = data.src.split('://');
1085
- var paths = src[1].split('/');
1086
- var i, len, found;
1087
- data.server = src[0]+'://'+paths[0]+'/';
1088
- data.streamId = [];
1089
- for(i = 1, len = paths.length; i < len; i++){
1090
- if(!found && paths[i].indexOf(':') !== -1){
1091
- paths[i] = paths[i].split(':')[1];
1092
- found = true;
1093
- }
1094
- if(!found){
1095
- data.server += paths[i]+'/';
1096
- } else {
1097
- data.streamId.push(paths[i]);
1098
- }
1099
- }
1100
- if(!data.streamId.length){
1101
- webshims.error('Could not parse rtmp url');
1102
- }
1103
- data.streamId = data.streamId.join('/');
1104
- };
1105
- var getSrcObj = function(elem, nodeName){
1106
- elem = $(elem);
1107
- var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
1108
- var tmp;
1109
-
1110
- if(!src.src){return src;}
1111
-
1112
- tmp = elem.attr('data-server');
1113
- if(tmp != null){
1114
- src.server = tmp;
1115
- }
1116
-
1117
- tmp = elem.attr('type');
1118
- if(tmp){
1119
- src.type = tmp;
1120
- src.container = $.trim(tmp.split(';')[0]);
1121
- } else {
1122
- if(!nodeName){
1123
- nodeName = elem[0].nodeName.toLowerCase();
1124
- if(nodeName == 'source'){
1125
- nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
1126
- }
1127
- }
1128
- if(src.server){
1129
- src.type = nodeName+'/rtmp';
1130
- src.container = nodeName+'/rtmp';
1131
- } else {
1132
-
1133
- tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
1134
-
1135
- if(tmp){
1136
- src.type = tmp;
1137
- src.container = tmp;
1138
- }
1139
- }
1140
- }
1141
- tmp = elem.attr('media');
1142
- if(tmp){
1143
- src.media = tmp;
1144
- }
1145
- if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
1146
- if(src.server){
1147
- src.streamId = src.src;
1148
- } else {
1149
- mediaelement.parseRtmp(src);
1150
- }
1151
- }
1152
- return src;
1153
- };
1154
-
1155
-
1156
-
1157
- var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
1158
-
1159
- var loadTrackUi = function(){
1160
- if(loadTrackUi.loaded){return;}
1161
- loadTrackUi.loaded = true;
1162
- $(function(){
1163
- webshims.loader.loadList(['track-ui']);
1164
- });
1165
- };
1166
- var loadYt = (function(){
1167
- var loaded;
1168
- return function(){
1169
- if(loaded || !hasYt){return;}
1170
- loaded = true;
1171
- webshims.loader.loadScript("https://www.youtube.com/player_api");
1172
- $(function(){
1173
- webshims.polyfill("mediaelement-yt");
1174
- });
1175
- };
1176
- })();
1177
- var loadThird = function(){
1178
- if(hasSwf){
1179
- loadSwf();
1180
- } else {
1181
- loadYt();
1182
- }
1183
- };
1184
-
1185
- webshims.addPolyfill('mediaelement-yt', {
1186
- test: !hasYt,
1187
- d: ['dom-support']
1188
- });
1189
-
1190
- mediaelement.mimeTypes = {
1191
- audio: {
1192
- //ogm shouldn´t be used!
1193
- 'audio/ogg': ['ogg','oga', 'ogm'],
1194
- 'audio/ogg;codecs="opus"': 'opus',
1195
- 'audio/mpeg': ['mp2','mp3','mpga','mpega'],
1196
- 'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
1197
- 'audio/wav': ['wav'],
1198
- 'audio/3gpp': ['3gp','3gpp'],
1199
- 'audio/webm': ['webm'],
1200
- 'audio/fla': ['flv', 'f4a', 'fla'],
1201
- 'application/x-mpegURL': ['m3u8', 'm3u']
1202
- },
1203
- video: {
1204
- //ogm shouldn´t be used!
1205
- 'video/ogg': ['ogg','ogv', 'ogm'],
1206
- 'video/mpeg': ['mpg','mpeg','mpe'],
1207
- 'video/mp4': ['mp4','mpg4', 'm4v'],
1208
- 'video/quicktime': ['mov','qt'],
1209
- 'video/x-msvideo': ['avi'],
1210
- 'video/x-ms-asf': ['asf', 'asx'],
1211
- 'video/flv': ['flv', 'f4v'],
1212
- 'video/3gpp': ['3gp','3gpp'],
1213
- 'video/webm': ['webm'],
1214
- 'application/x-mpegURL': ['m3u8', 'm3u'],
1215
- 'video/MP2T': ['ts']
1216
- }
1217
- }
1218
- ;
1219
-
1220
- mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
1221
-
1222
- mediaelement.getTypeForSrc = function(src, nodeName, data){
1223
- if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
1224
- return 'video/youtube';
1225
- }
1226
- if(src.indexOf('rtmp') === 0){
1227
- return nodeName+'/rtmp';
1228
- }
1229
- src = src.split('?')[0].split('.');
1230
- src = src[src.length - 1];
1231
- var mt;
1232
-
1233
- $.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
1234
- if(exts.indexOf(src) !== -1){
1235
- mt = mimeType;
1236
- return false;
1237
- }
1238
- });
1239
- return mt;
1240
- };
1241
-
1242
-
1243
- mediaelement.srces = function(mediaElem, srces){
1244
- mediaElem = $(mediaElem);
1245
- if(!srces){
1246
- srces = [];
1247
- var nodeName = mediaElem[0].nodeName.toLowerCase();
1248
- var src = getSrcObj(mediaElem, nodeName);
1249
-
1250
- if(!src.src){
1251
-
1252
- $('source', mediaElem).each(function(){
1253
- src = getSrcObj(this, nodeName);
1254
- if(src.src){srces.push(src);}
1255
- });
1256
- } else {
1257
- srces.push(src);
1258
- }
1259
- return srces;
1260
- } else {
1261
- mediaElem.removeAttr('src').removeAttr('type').find('source').remove();
1262
- if(!$.isArray(srces)){
1263
- srces = [srces];
1264
- }
1265
- srces.forEach(function(src){
1266
- var source = document.createElement('source');
1267
- if(typeof src == 'string'){
1268
- src = {src: src};
1269
- }
1270
- source.setAttribute('src', src.src);
1271
- if(src.type){
1272
- source.setAttribute('type', src.type);
1273
- }
1274
- if(src.media){
1275
- source.setAttribute('media', src.media);
1276
- }
1277
- mediaElem.append(source);
1278
- });
1279
-
1280
- }
1281
- };
1282
-
1283
-
1284
- $.fn.loadMediaSrc = function(srces, poster){
1285
- return this.each(function(){
1286
- if(poster !== undefined){
1287
- $(this).removeAttr('poster');
1288
- if(poster){
1289
- $.attr(this, 'poster', poster);
1290
- }
1291
- }
1292
- mediaelement.srces(this, srces);
1293
- $(this).mediaLoad();
1294
- });
1295
- };
1296
-
1297
- mediaelement.swfMimeTypes = ['video/3gpp', 'video/x-msvideo', 'video/quicktime', 'video/x-m4v', 'video/mp4', 'video/m4p', 'video/x-flv', 'video/flv', 'audio/mpeg', 'audio/aac', 'audio/mp4', 'audio/x-m4a', 'audio/m4a', 'audio/mp3', 'audio/x-fla', 'audio/fla', 'youtube/flv', 'jwplayer/jwplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
1298
-
1299
- mediaelement.canThirdPlaySrces = function(mediaElem, srces){
1300
- var ret = '';
1301
- if(hasSwf || hasYt){
1302
- mediaElem = $(mediaElem);
1303
- srces = srces || mediaelement.srces(mediaElem);
1304
- $.each(srces, function(i, src){
1305
- if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
1306
- ret = src;
1307
- return false;
1308
- }
1309
- });
1310
-
1311
- }
1312
-
1313
- return ret;
1314
- };
1315
-
1316
- var nativeCanPlayType = {};
1317
- mediaelement.canNativePlaySrces = function(mediaElem, srces){
1318
- var ret = '';
1319
- if(hasNative){
1320
- mediaElem = $(mediaElem);
1321
- var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
1322
- if(!nativeCanPlayType[nodeName]){return ret;}
1323
- srces = srces || mediaelement.srces(mediaElem);
1324
-
1325
- $.each(srces, function(i, src){
1326
- if(src.type && nativeCanPlayType[nodeName].prop._supvalue.call(mediaElem[0], src.type) ){
1327
- ret = src;
1328
- return false;
1329
- }
1330
- });
1331
- }
1332
- return ret;
1333
- };
1334
-
1335
- mediaelement.setError = function(elem, message){
1336
- if(!message){
1337
- message = "can't play sources";
1338
- }
1339
-
1340
- $(elem).pause().data('mediaerror', message);
1341
- webshims.warn('mediaelementError: '+ message);
1342
- setTimeout(function(){
1343
- if($(elem).data('mediaerror')){
1344
- $(elem).trigger('mediaerror');
1345
- }
1346
- }, 1);
1347
- };
1348
-
1349
- var handleThird = (function(){
1350
- var requested;
1351
- return function( mediaElem, ret, data ){
1352
- if(!requested){
1353
- loadTrackUi();
1354
- }
1355
- webshims.ready(hasSwf ? swfType : 'mediaelement-yt', function(){
1356
- if(mediaelement.createSWF){
1357
- mediaelement.createSWF( mediaElem, ret, data );
1358
- } else if(!requested) {
1359
- requested = true;
1360
- loadThird();
1361
- //readd to ready
1362
- handleThird( mediaElem, ret, data );
1363
- }
1364
- });
1365
- if(!requested && hasYt && !mediaelement.createSWF){
1366
- loadYt();
1367
- }
1368
- };
1369
- })();
1370
-
1371
- var stepSources = function(elem, data, useSwf, _srces, _noLoop){
1372
- var ret;
1373
- if(useSwf || (useSwf !== false && data && data.isActive == 'third')){
1374
- ret = mediaelement.canThirdPlaySrces(elem, _srces);
1375
- if(!ret){
1376
- if(_noLoop){
1377
- mediaelement.setError(elem, false);
1378
- } else {
1379
- stepSources(elem, data, false, _srces, true);
1380
- }
1381
- } else {
1382
- handleThird(elem, ret, data);
1383
- }
1384
- } else {
1385
- ret = mediaelement.canNativePlaySrces(elem, _srces);
1386
- if(!ret){
1387
- if(_noLoop){
1388
- mediaelement.setError(elem, false);
1389
- if(data && data.isActive == 'third') {
1390
- mediaelement.setActive(elem, 'html5', data);
1391
- }
1392
- } else {
1393
- stepSources(elem, data, true, _srces, true);
1394
- }
1395
- } else if(data && data.isActive == 'third') {
1396
- mediaelement.setActive(elem, 'html5', data);
1397
- }
1398
- }
1399
- };
1400
- var stopParent = /^(?:embed|object|datalist)$/i;
1401
- var selectSource = function(elem, data){
1402
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
1403
- var _srces = mediaelement.srces(elem);
1404
- var parent = elem.parentNode;
1405
-
1406
- clearTimeout(baseData.loadTimer);
1407
- $.data(elem, 'mediaerror', false);
1408
-
1409
- if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
1410
- data = data || webshims.data(elem, 'mediaelement');
1411
- stepSources(elem, data, options.preferFlash || undefined, _srces);
1412
- };
1413
- mediaelement.selectSource = selectSource;
1414
-
1415
- $(document).on('ended', function(e){
1416
- var data = webshims.data(e.target, 'mediaelement');
1417
- if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
1418
- setTimeout(function(){
1419
- if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
1420
- $(e.target).prop('currentTime', 0).play();
1421
- }, 1);
1422
-
1423
- });
1424
- if(!supportsLoop){
1425
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
1426
- }
1427
-
1428
- ['audio', 'video'].forEach(function(nodeName){
1429
- var supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
1430
- prop: {
1431
- value: function(){
1432
- var data = webshims.data(this, 'mediaelement');
1433
- selectSource(this, data);
1434
- if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
1435
- supLoad.prop._supvalue.apply(this, arguments);
1436
- }
1437
- }
1438
- }
1439
- });
1440
- nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
1441
- prop: {
1442
- value: function(type){
1443
- var ret = '';
1444
- if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
1445
- ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
1446
- if(ret == 'no'){
1447
- ret = '';
1448
- }
1449
- }
1450
- if(!ret && hasSwf){
1451
- type = $.trim((type || '').split(';')[0]);
1452
- if(mediaelement.swfMimeTypes.indexOf(type) != -1){
1453
- ret = 'maybe';
1454
- }
1455
- }
1456
- return ret;
1457
- }
1458
- }
1459
- });
1460
- });
1461
- webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
1462
- set: function(){
1463
- var elem = this;
1464
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
1465
- clearTimeout(baseData.loadTimer);
1466
- baseData.loadTimer = setTimeout(function(){
1467
- selectSource(elem);
1468
- elem = null;
1469
- }, 9);
1470
- }
1471
- });
1472
-
1473
- var initMediaElements = function(){
1474
-
1475
- webshims.addReady(function(context, insertedElement){
1476
- var media = $('video, audio', context)
1477
- .add(insertedElement.filter('video, audio'))
1478
- .each(function(){
1479
- var data = webshims.data(this, 'mediaelement');
1480
-
1481
- if(hasNative && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay])') && (!data || data.isActive == 'html5')){
1482
- //IE controls not visible bug
1483
- $(this).prop('preload', 'metadata').mediaLoad();
1484
- } else {
1485
- selectSource(this, data);
1486
- }
1487
-
1488
- if(hasNative){
1489
-
1490
- //FF progress bug
1491
- (function(){
1492
- var bufferTimer;
1493
- var lastBuffered;
1494
- var elem = this;
1495
- var getBufferedString = function(){
1496
- var buffered = $.prop(elem, 'buffered');
1497
- if(!buffered){return;}
1498
- var bufferString = "";
1499
- for(var i = 0, len = buffered.length; i < len;i++){
1500
- bufferString += buffered.end(i);
1501
- }
1502
- return bufferString;
1503
- };
1504
- var testBuffer = function(){
1505
- var buffered = getBufferedString();
1506
- if(buffered != lastBuffered){
1507
- lastBuffered = buffered;
1508
- $(elem).triggerHandler('progress');
1509
- }
1510
- };
1511
-
1512
- $(this)
1513
- .on({
1514
- 'play loadstart progress': function(e){
1515
- if(e.type == 'progress'){
1516
- lastBuffered = getBufferedString();
1517
- }
1518
- clearTimeout(bufferTimer);
1519
- bufferTimer = setTimeout(testBuffer, 999);
1520
- },
1521
- 'emptied stalled mediaerror abort suspend': function(e){
1522
- if(e.type == 'emptied'){
1523
- lastBuffered = false;
1524
- }
1525
- clearTimeout(bufferTimer);
1526
- }
1527
- })
1528
- ;
1529
- })();
1530
- }
1531
-
1532
- })
1533
- ;
1534
- if(!loadTrackUi.loaded && $('track', media).length){
1535
- loadTrackUi();
1536
- }
1537
- media = null;
1538
- });
1539
- };
1540
-
1541
- if(Modernizr.track && !bugs.track){
1542
- webshims.defineProperty(TextTrack.prototype, 'shimActiveCues', {
1543
- get: function(){
1544
- return this._shimActiveCues || this.activeCues;
1545
- }
1546
- });
1547
- }
1548
- //set native implementation ready, before swf api is retested
1549
- if(hasNative){
1550
- webshims.isReady('mediaelement-core', true);
1551
- initMediaElements();
1552
- webshims.ready('WINDOWLOAD mediaelement', loadThird);
1553
- } else {
1554
- webshims.ready(swfType, initMediaElements);
1555
- }
1556
- webshims.ready('WINDOWLOAD mediaelement', loadTrackUi);
1557
- });
1558
- })(jQuery, Modernizr, jQuery.webshims);
1559
- jQuery.webshims.register('track', function($, webshims, window, document, undefined){
1560
- "use strict";
1561
- var mediaelement = webshims.mediaelement;
1562
- var id = new Date().getTime();
1563
- var ADDBACK = $.fn.addBack ? 'addBack' : 'andSelf';
1564
- //descriptions are not really shown, but they are inserted into the dom
1565
- var showTracks = {subtitles: 1, captions: 1, descriptions: 1};
1566
- var notImplemented = function(){
1567
- webshims.error('not implemented yet');
1568
- };
1569
- var dummyTrack = $('<track />');
1570
- var supportTrackMod = Modernizr.ES5 && Modernizr.objectAccessor;
1571
- var createEventTarget = function(obj){
1572
- var eventList = {};
1573
- obj.addEventListener = function(name, fn){
1574
- if(eventList[name]){
1575
- webshims.error('always use $.on to the shimed event: '+ name +' already bound fn was: '+ eventList[name] +' your fn was: '+ fn);
1576
- }
1577
- eventList[name] = fn;
1578
-
1579
- };
1580
- obj.removeEventListener = function(name, fn){
1581
- if(eventList[name] && eventList[name] != fn){
1582
- webshims.error('always use $.on/$.off to the shimed event: '+ name +' already bound fn was: '+ eventList[name] +' your fn was: '+ fn);
1583
- }
1584
- if(eventList[name]){
1585
- delete eventList[name];
1586
- }
1587
- };
1588
- return obj;
1589
- };
1590
-
1591
-
1592
- var cueListProto = {
1593
- getCueById: function(id){
1594
- var cue = null;
1595
- for(var i = 0, len = this.length; i < len; i++){
1596
- if(this[i].id === id){
1597
- cue = this[i];
1598
- break;
1599
- }
1600
- }
1601
- return cue;
1602
- }
1603
- };
1604
- var numericModes = {
1605
- 0: 'disabled',
1606
- 1: 'hidden',
1607
- 2: 'showing'
1608
- };
1609
-
1610
- var textTrackProto = {
1611
- shimActiveCues: null,
1612
- _shimActiveCues: null,
1613
- activeCues: null,
1614
- cues: null,
1615
- kind: 'subtitles',
1616
- label: '',
1617
- language: '',
1618
- mode: 'disabled',
1619
- readyState: 0,
1620
- oncuechange: null,
1621
- toString: function() {
1622
- return "[object TextTrack]";
1623
- },
1624
- addCue: function(cue){
1625
- if(!this.cues){
1626
- this.cues = mediaelement.createCueList();
1627
- } else {
1628
- var lastCue = this.cues[this.cues.length-1];
1629
- if(lastCue && lastCue.startTime > cue.startTime){
1630
- webshims.error("cue startTime higher than previous cue's startTime");
1631
- }
1632
- }
1633
- if(cue.track && cue.track.removeCue){
1634
- cue.track.removeCue(cue);
1635
- }
1636
- cue.track = this;
1637
- this.cues.push(cue);
1638
- },
1639
- //ToDo: make it more dynamic
1640
- removeCue: function(cue){
1641
- var cues = this.cues || [];
1642
- var i = 0;
1643
- var len = cues.length;
1644
- if(cue.track != this){
1645
- webshims.error("cue not part of track");
1646
- return;
1647
- }
1648
- for(; i < len; i++){
1649
- if(cues[i] === cue){
1650
- cues.splice(i, 1);
1651
- cue.track = null;
1652
- break;
1653
- }
1654
- }
1655
- if(cue.track){
1656
- webshims.error("cue not part of track");
1657
- return;
1658
- }
1659
- },
1660
- DISABLED: 'disabled',
1661
- OFF: 'disabled',
1662
- HIDDEN: 'hidden',
1663
- SHOWING: 'showing',
1664
- ERROR: 3,
1665
- LOADED: 2,
1666
- LOADING: 1,
1667
- NONE: 0
1668
- };
1669
- var copyProps = ['kind', 'label', 'srclang'];
1670
- var copyName = {srclang: 'language'};
1671
-
1672
- var owns = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
1673
-
1674
- var updateMediaTrackList = function(baseData, trackList){
1675
- var removed = [];
1676
- var added = [];
1677
- var newTracks = [];
1678
- var i, len;
1679
- if(!baseData){
1680
- baseData = webshims.data(this, 'mediaelementBase') || webshims.data(this, 'mediaelementBase', {});
1681
- }
1682
-
1683
- if(!trackList){
1684
- baseData.blockTrackListUpdate = true;
1685
- trackList = $.prop(this, 'textTracks');
1686
- baseData.blockTrackListUpdate = false;
1687
- }
1688
-
1689
- clearTimeout(baseData.updateTrackListTimer);
1690
-
1691
- $('track', this).each(function(){
1692
- var track = $.prop(this, 'track');
1693
- newTracks.push(track);
1694
- if(trackList.indexOf(track) == -1){
1695
- added.push(track);
1696
- }
1697
- });
1698
-
1699
- if(baseData.scriptedTextTracks){
1700
- for(i = 0, len = baseData.scriptedTextTracks.length; i < len; i++){
1701
- newTracks.push(baseData.scriptedTextTracks[i]);
1702
- if(trackList.indexOf(baseData.scriptedTextTracks[i]) == -1){
1703
- added.push(baseData.scriptedTextTracks[i]);
1704
- }
1705
- }
1706
- }
1707
-
1708
- for(i = 0, len = trackList.length; i < len; i++){
1709
- if(newTracks.indexOf(trackList[i]) == -1){
1710
- removed.push(trackList[i]);
1711
- }
1712
- }
1713
-
1714
- if(removed.length || added.length){
1715
- trackList.splice(0);
1716
-
1717
- for(i = 0, len = newTracks.length; i < len; i++){
1718
- trackList.push(newTracks[i]);
1719
- }
1720
- for(i = 0, len = removed.length; i < len; i++){
1721
- $([trackList]).triggerHandler($.Event({type: 'removetrack', track: removed[i]}));
1722
- }
1723
- for(i = 0, len = added.length; i < len; i++){
1724
- $([trackList]).triggerHandler($.Event({type: 'addtrack', track: added[i]}));
1725
- }
1726
- if(baseData.scriptedTextTracks || removed.length){
1727
- $(this).triggerHandler('updatetrackdisplay');
1728
- }
1729
- }
1730
- };
1731
-
1732
- var refreshTrack = function(track, trackData){
1733
- if(!trackData){
1734
- trackData = webshims.data(track, 'trackData');
1735
- }
1736
- if(trackData && !trackData.isTriggering){
1737
- trackData.isTriggering = true;
1738
- setTimeout(function(){
1739
- if(!(trackData.track || {}).readyState){
1740
- $(track).triggerHandler('checktrackmode');
1741
- } else {
1742
- $(track).closest('audio, video').triggerHandler('updatetrackdisplay');
1743
- }
1744
- trackData.isTriggering = false;
1745
- }, 1);
1746
- }
1747
- };
1748
-
1749
- var emptyDiv = $('<div />')[0];
1750
- window.TextTrackCue = function(startTime, endTime, text){
1751
- if(arguments.length != 3){
1752
- webshims.error("wrong arguments.length for TextTrackCue.constructor");
1753
- }
1754
-
1755
- this.startTime = startTime;
1756
- this.endTime = endTime;
1757
- this.text = text;
1758
-
1759
- this.id = "";
1760
- this.pauseOnExit = false;
1761
-
1762
- createEventTarget(this);
1763
- };
1764
-
1765
- window.TextTrackCue.prototype = {
1766
-
1767
- onenter: null,
1768
- onexit: null,
1769
- pauseOnExit: false,
1770
- getCueAsHTML: function(){
1771
- var lastText = "";
1772
- var parsedText = "";
1773
- var fragment = document.createDocumentFragment();
1774
- var fn;
1775
- if(!owns(this, 'getCueAsHTML')){
1776
- fn = this.getCueAsHTML = function(){
1777
- var i, len;
1778
- if(lastText != this.text){
1779
- lastText = this.text;
1780
- parsedText = mediaelement.parseCueTextToHTML(lastText);
1781
- emptyDiv.innerHTML = parsedText;
1782
-
1783
- for(i = 0, len = emptyDiv.childNodes.length; i < len; i++){
1784
- fragment.appendChild(emptyDiv.childNodes[i].cloneNode(true));
1785
- }
1786
- }
1787
- return fragment.cloneNode(true);
1788
- };
1789
-
1790
- }
1791
- return fn ? fn.apply(this, arguments) : fragment.cloneNode(true);
1792
- },
1793
- track: null,
1794
-
1795
-
1796
- id: ''
1797
- //todo-->
1798
- // ,
1799
- // snapToLines: true,
1800
- // line: 'auto',
1801
- // size: 100,
1802
- // position: 50,
1803
- // vertical: '',
1804
- // align: 'middle'
1805
- };
1806
-
1807
-
1808
-
1809
-
1810
-
1811
- mediaelement.createCueList = function(){
1812
- return $.extend([], cueListProto);
1813
- };
1814
-
1815
- mediaelement.parseCueTextToHTML = (function(){
1816
- var tagSplits = /(<\/?[^>]+>)/ig;
1817
- var allowedTags = /^(?:c|v|ruby|rt|b|i|u)/;
1818
- var regEnd = /\<\s*\//;
1819
- var addToTemplate = function(localName, attribute, tag, html){
1820
- var ret;
1821
- if(regEnd.test(html)){
1822
- ret = '</'+ localName +'>';
1823
- } else {
1824
- tag.splice(0, 1);
1825
- ret = '<'+ localName +' '+ attribute +'="'+ (tag.join(' ').replace(/\"/g, '&#34;')) +'">';
1826
- }
1827
- return ret;
1828
- };
1829
- var replacer = function(html){
1830
- var tag = html.replace(/[<\/>]+/ig,"").split(/[\s\.]+/);
1831
- if(tag[0]){
1832
- tag[0] = tag[0].toLowerCase();
1833
- if(allowedTags.test(tag[0])){
1834
- if(tag[0] == 'c'){
1835
- html = addToTemplate('span', 'class', tag, html);
1836
- } else if(tag[0] == 'v'){
1837
- html = addToTemplate('q', 'title', tag, html);
1838
- }
1839
- } else {
1840
- html = "";
1841
- }
1842
- }
1843
- return html;
1844
- };
1845
-
1846
- return function(cueText){
1847
- return cueText.replace(tagSplits, replacer);
1848
- };
1849
- })();
1850
-
1851
- mediaelement.loadTextTrack = function(mediaelem, track, trackData, _default){
1852
- var loadEvents = 'play playing timeupdate updatetrackdisplay';
1853
- var obj = trackData.track;
1854
- var load = function(){
1855
- var src = $.prop(track, 'src');
1856
- var error;
1857
- var ajax;
1858
- if(obj.mode != 'disabled' && src && $.attr(track, 'src')){
1859
- $(mediaelem).unbind(loadEvents, load);
1860
- $(track).unbind('checktrackmode', load);
1861
- if(!obj.readyState){
1862
- error = function(){
1863
- obj.readyState = 3;
1864
- obj.cues = null;
1865
- obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = null;
1866
- $(track).triggerHandler('error');
1867
- };
1868
- obj.readyState = 1;
1869
- try {
1870
- obj.cues = mediaelement.createCueList();
1871
- obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = mediaelement.createCueList();
1872
- ajax = $.ajax({
1873
- dataType: 'text',
1874
- url: src,
1875
- success: function(text){
1876
- if(ajax.getResponseHeader('content-type') != 'text/vtt'){
1877
- webshims.error('set the mime-type of your WebVTT files to text/vtt. see: http://dev.w3.org/html5/webvtt/#text/vtt');
1878
- }
1879
- mediaelement.parseCaptions(text, obj, function(cues){
1880
- if(cues && 'length' in cues){
1881
- obj.readyState = 2;
1882
- $(track).triggerHandler('load');
1883
- $(mediaelem).triggerHandler('updatetrackdisplay');
1884
- } else {
1885
- error();
1886
- }
1887
- });
1888
-
1889
- },
1890
- error: error
1891
- });
1892
- } catch(er){
1893
- error();
1894
- webshims.warn(er);
1895
- }
1896
- }
1897
- }
1898
- };
1899
- obj.readyState = 0;
1900
- obj.shimActiveCues = null;
1901
- obj._shimActiveCues = null;
1902
- obj.activeCues = null;
1903
- obj.cues = null;
1904
- $(mediaelem).unbind(loadEvents, load);
1905
- $(track).unbind('checktrackmode', load);
1906
- $(mediaelem).on(loadEvents, load);
1907
- $(track).on('checktrackmode', load);
1908
- if(_default){
1909
- obj.mode = showTracks[obj.kind] ? 'showing' : 'hidden';
1910
- load();
1911
- }
1912
- };
1913
-
1914
- mediaelement.createTextTrack = function(mediaelem, track){
1915
- var obj, trackData;
1916
- if(track.nodeName){
1917
- trackData = webshims.data(track, 'trackData');
1918
-
1919
- if(trackData){
1920
- refreshTrack(track, trackData);
1921
- obj = trackData.track;
1922
- }
1923
- }
1924
-
1925
- if(!obj){
1926
- obj = createEventTarget(webshims.objectCreate(textTrackProto));
1927
-
1928
- if(!supportTrackMod){
1929
- copyProps.forEach(function(copyProp){
1930
- var prop = $.prop(track, copyProp);
1931
- if(prop){
1932
- obj[copyName[copyProp] || copyProp] = prop;
1933
- }
1934
- });
1935
- }
1936
-
1937
-
1938
- if(track.nodeName){
1939
-
1940
- if(supportTrackMod){
1941
- copyProps.forEach(function(copyProp){
1942
- webshims.defineProperty(obj, copyName[copyProp] || copyProp, {
1943
- get: function(){
1944
- return $.prop(track, copyProp);
1945
- }
1946
- });
1947
- });
1948
- }
1949
-
1950
- trackData = webshims.data(track, 'trackData', {track: obj});
1951
- mediaelement.loadTextTrack(mediaelem, track, trackData, ($.prop(track, 'default') && $(track).siblings('track[default]')[ADDBACK]()[0] == track));
1952
- } else {
1953
- if(supportTrackMod){
1954
- copyProps.forEach(function(copyProp){
1955
- webshims.defineProperty(obj, copyName[copyProp] || copyProp, {
1956
- value: track[copyProp],
1957
- writeable: false
1958
- });
1959
- });
1960
- }
1961
- obj.cues = mediaelement.createCueList();
1962
- obj.activeCues = obj._shimActiveCues = obj.shimActiveCues = mediaelement.createCueList();
1963
- obj.mode = 'hidden';
1964
- obj.readyState = 2;
1965
- }
1966
- }
1967
- return obj;
1968
- };
1969
-
1970
-
1971
- /*
1972
- taken from:
1973
- Captionator 0.5.1 [CaptionCrunch]
1974
- Christopher Giffard, 2011
1975
- Share and enjoy
1976
-
1977
- https://github.com/cgiffard/Captionator
1978
-
1979
- modified for webshims
1980
- */
1981
- mediaelement.parseCaptionChunk = (function(){
1982
- // Set up timestamp parsers
1983
- var WebVTTTimestampParser = /^(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s+\-\-\>\s+(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s*(.*)/;
1984
- var GoogleTimestampParser = /^([\d\.]+)\s+\+([\d\.]+)\s*(.*)/;
1985
- var WebVTTDEFAULTSCueParser = /^(DEFAULTS|DEFAULT)\s+\-\-\>\s+(.*)/g;
1986
- var WebVTTSTYLECueParser = /^(STYLE|STYLES)\s+\-\-\>\s*\n([\s\S]*)/g;
1987
- var WebVTTCOMMENTCueParser = /^(COMMENT|COMMENTS)\s+\-\-\>\s+(.*)/g;
1988
-
1989
- return function(subtitleElement,objectCount){
1990
- var cueDefaults = [];
1991
-
1992
- var subtitleParts, timeIn, timeOut, html, timeData, subtitlePartIndex, cueSettings = "", id, specialCueData;
1993
- var timestampMatch, tmpCue;
1994
-
1995
- // WebVTT Special Cue Logic
1996
- if ((specialCueData = WebVTTDEFAULTSCueParser.exec(subtitleElement))) {
1997
- // cueDefaults = specialCueData.slice(2).join("");
1998
- // cueDefaults = cueDefaults.split(/\s+/g).filter(function(def) { return def && !!def.length; });
1999
- return null;
2000
- } else if ((specialCueData = WebVTTSTYLECueParser.exec(subtitleElement))) {
2001
- return null;
2002
- } else if ((specialCueData = WebVTTCOMMENTCueParser.exec(subtitleElement))) {
2003
- return null; // At this stage, we don't want to do anything with these.
2004
- }
2005
-
2006
- subtitleParts = subtitleElement.split(/\n/g);
2007
-
2008
- // Trim off any blank lines (logically, should only be max. one, but loop to be sure)
2009
- while (!subtitleParts[0].replace(/\s+/ig,"").length && subtitleParts.length > 0) {
2010
- subtitleParts.shift();
2011
- }
2012
-
2013
- if (subtitleParts[0].match(/^\s*[a-z0-9-\_]+\s*$/ig)) {
2014
- // The identifier becomes the cue ID (when *we* load the cues from file. Programatically created cues can have an ID of whatever.)
2015
- id = String(subtitleParts.shift().replace(/\s*/ig,""));
2016
- }
2017
-
2018
- for (subtitlePartIndex = 0; subtitlePartIndex < subtitleParts.length; subtitlePartIndex ++) {
2019
- var timestamp = subtitleParts[subtitlePartIndex];
2020
-
2021
- if ((timestampMatch = WebVTTTimestampParser.exec(timestamp))) {
2022
-
2023
- // WebVTT
2024
-
2025
- timeData = timestampMatch.slice(1);
2026
-
2027
- timeIn = parseInt((timeData[0]||0) * 60 * 60,10) + // Hours
2028
- parseInt((timeData[1]||0) * 60,10) + // Minutes
2029
- parseInt((timeData[2]||0),10) + // Seconds
2030
- parseFloat("0." + (timeData[3]||0)); // MS
2031
-
2032
- timeOut = parseInt((timeData[4]||0) * 60 * 60,10) + // Hours
2033
- parseInt((timeData[5]||0) * 60,10) + // Minutes
2034
- parseInt((timeData[6]||0),10) + // Seconds
2035
- parseFloat("0." + (timeData[7]||0)); // MS
2036
- /*
2037
- if (timeData[8]) {
2038
- cueSettings = timeData[8];
2039
- }
2040
- */
2041
- }
2042
-
2043
- // We've got the timestamp - return all the other unmatched lines as the raw subtitle data
2044
- subtitleParts = subtitleParts.slice(0,subtitlePartIndex).concat(subtitleParts.slice(subtitlePartIndex+1));
2045
- break;
2046
- }
2047
-
2048
- if (!timeIn && !timeOut) {
2049
- // We didn't extract any time information. Assume the cue is invalid!
2050
- webshims.warn("couldn't extract time information: "+[timeIn, timeOut, subtitleParts.join("\n"), id].join(' ; '));
2051
- return null;
2052
- }
2053
- /*
2054
- // Consolidate cue settings, convert defaults to object
2055
- var compositeCueSettings =
2056
- cueDefaults
2057
- .reduce(function(previous,current,index,array){
2058
- previous[current.split(":")[0]] = current.split(":")[1];
2059
- return previous;
2060
- },{});
2061
-
2062
- // Loop through cue settings, replace defaults with cue specific settings if they exist
2063
- compositeCueSettings =
2064
- cueSettings
2065
- .split(/\s+/g)
2066
- .filter(function(set) { return set && !!set.length; })
2067
- // Convert array to a key/val object
2068
- .reduce(function(previous,current,index,array){
2069
- previous[current.split(":")[0]] = current.split(":")[1];
2070
- return previous;
2071
- },compositeCueSettings);
2072
-
2073
- // Turn back into string like the TextTrackCue constructor expects
2074
- cueSettings = "";
2075
- for (var key in compositeCueSettings) {
2076
- if (compositeCueSettings.hasOwnProperty(key)) {
2077
- cueSettings += !!cueSettings.length ? " " : "";
2078
- cueSettings += key + ":" + compositeCueSettings[key];
2079
- }
2080
- }
2081
- */
2082
- // The remaining lines are the subtitle payload itself (after removing an ID if present, and the time);
2083
- html = subtitleParts.join("\n");
2084
- tmpCue = new TextTrackCue(timeIn, timeOut, html);
2085
- if(id){
2086
- tmpCue.id = id;
2087
- }
2088
- return tmpCue;
2089
- };
2090
- })();
2091
-
2092
- mediaelement.parseCaptions = function(captionData, track, complete) {
2093
- var subtitles = mediaelement.createCueList();
2094
- var cue, lazyProcess, regWevVTT;
2095
- var startDate;
2096
- var isWEBVTT;
2097
- if (captionData) {
2098
-
2099
- regWevVTT = /^WEBVTT(\s*FILE)?/ig;
2100
-
2101
- lazyProcess = function(i, len){
2102
-
2103
- for(; i < len; i++){
2104
- cue = captionData[i];
2105
- if(regWevVTT.test(cue)){
2106
- isWEBVTT = true;
2107
- } else if(cue.replace(/\s*/ig,"").length){
2108
- if(!isWEBVTT){
2109
- webshims.error('please use WebVTT format. This is the standard');
2110
- complete(null);
2111
- break;
2112
- }
2113
- cue = mediaelement.parseCaptionChunk(cue, i);
2114
- if(cue){
2115
- track.addCue(cue);
2116
- }
2117
- }
2118
- if(startDate < (new Date().getTime()) - 30){
2119
- i++;
2120
- setTimeout(function(){
2121
- startDate = new Date().getTime();
2122
- lazyProcess(i, len);
2123
- }, 90);
2124
-
2125
- break;
2126
- }
2127
- }
2128
- if(i >= len){
2129
- if(!isWEBVTT){
2130
- webshims.error('please use WebVTT format. This is the standard');
2131
- }
2132
- complete(track.cues);
2133
- }
2134
- };
2135
-
2136
- captionData = captionData.replace(/\r\n/g,"\n");
2137
-
2138
- setTimeout(function(){
2139
- captionData = captionData.replace(/\r/g,"\n");
2140
- setTimeout(function(){
2141
- startDate = new Date().getTime();
2142
- captionData = captionData.split(/\n\n+/g);
2143
- lazyProcess(0, captionData.length);
2144
- }, 9);
2145
- }, 9);
2146
-
2147
- } else {
2148
- webshims.error("Required parameter captionData not supplied.");
2149
- }
2150
- };
2151
-
2152
-
2153
- mediaelement.createTrackList = function(mediaelem, baseData){
2154
- baseData = baseData || webshims.data(mediaelem, 'mediaelementBase') || webshims.data(mediaelem, 'mediaelementBase', {});
2155
- if(!baseData.textTracks){
2156
- baseData.textTracks = [];
2157
- webshims.defineProperties(baseData.textTracks, {
2158
- onaddtrack: {value: null},
2159
- onremovetrack: {value: null}
2160
- });
2161
- createEventTarget(baseData.textTracks);
2162
- }
2163
- return baseData.textTracks;
2164
- };
2165
-
2166
- if(!Modernizr.track){
2167
- webshims.defineNodeNamesBooleanProperty(['track'], 'default');
2168
- webshims.reflectProperties(['track'], ['srclang', 'label']);
2169
-
2170
- webshims.defineNodeNameProperties('track', {
2171
- src: {
2172
- //attr: {},
2173
- reflect: true,
2174
- propType: 'src'
2175
- }
2176
- });
2177
- }
2178
-
2179
- webshims.defineNodeNameProperties('track', {
2180
- kind: {
2181
- attr: Modernizr.track ? {
2182
- set: function(value){
2183
- var trackData = webshims.data(this, 'trackData');
2184
- this.setAttribute('data-kind', value);
2185
- if(trackData){
2186
- trackData.attrKind = value;
2187
- }
2188
- },
2189
- get: function(){
2190
- var trackData = webshims.data(this, 'trackData');
2191
- if(trackData && ('attrKind' in trackData)){
2192
- return trackData.attrKind;
2193
- }
2194
- return this.getAttribute('kind');
2195
- }
2196
- } : {},
2197
- reflect: true,
2198
- propType: 'enumarated',
2199
- defaultValue: 'subtitles',
2200
- limitedTo: ['subtitles', 'captions', 'descriptions', 'chapters', 'metadata']
2201
- }
2202
- });
2203
-
2204
- $.each(copyProps, function(i, copyProp){
2205
- var name = copyName[copyProp] || copyProp;
2206
- webshims.onNodeNamesPropertyModify('track', copyProp, function(){
2207
- var trackData = webshims.data(this, 'trackData');
2208
- var track = this;
2209
- if(trackData){
2210
- if(copyProp == 'kind'){
2211
- refreshTrack(this, trackData);
2212
- }
2213
- if(!supportTrackMod){
2214
- trackData.track[name] = $.prop(this, copyProp);
2215
- }
2216
- clearTimeout(trackData.changedTrackPropTimer);
2217
- trackData.changedTrackPropTimer = setTimeout(function(){
2218
- $(track).trigger('updatesubtitlestate');
2219
- }, 1);
2220
- }
2221
- });
2222
- });
2223
-
2224
-
2225
- webshims.onNodeNamesPropertyModify('track', 'src', function(val){
2226
- if(val){
2227
- var data = webshims.data(this, 'trackData');
2228
- var media;
2229
- if(data){
2230
- media = $(this).closest('video, audio');
2231
- if(media[0]){
2232
- mediaelement.loadTextTrack(media, this, data);
2233
- }
2234
- }
2235
- }
2236
-
2237
- });
2238
-
2239
- //
2240
-
2241
- webshims.defineNodeNamesProperties(['track'], {
2242
- ERROR: {
2243
- value: 3
2244
- },
2245
- LOADED: {
2246
- value: 2
2247
- },
2248
- LOADING: {
2249
- value: 1
2250
- },
2251
- NONE: {
2252
- value: 0
2253
- },
2254
- readyState: {
2255
- get: function(){
2256
- return ($.prop(this, 'track') || {readyState: 0}).readyState;
2257
- },
2258
- writeable: false
2259
- },
2260
- track: {
2261
- get: function(){
2262
- return mediaelement.createTextTrack($(this).closest('audio, video')[0], this);
2263
- },
2264
- writeable: false
2265
- }
2266
- }, 'prop');
2267
-
2268
- webshims.defineNodeNamesProperties(['audio', 'video'], {
2269
- textTracks: {
2270
- get: function(){
2271
- var media = this;
2272
- var baseData = webshims.data(media, 'mediaelementBase') || webshims.data(media, 'mediaelementBase', {});
2273
- var tracks = mediaelement.createTrackList(media, baseData);
2274
- if(!baseData.blockTrackListUpdate){
2275
- updateMediaTrackList.call(media, baseData, tracks);
2276
- }
2277
- return tracks;
2278
- },
2279
- writeable: false
2280
- },
2281
- addTextTrack: {
2282
- value: function(kind, label, lang){
2283
- var textTrack = mediaelement.createTextTrack(this, {
2284
- kind: dummyTrack.prop('kind', kind || '').prop('kind'),
2285
- label: label || '',
2286
- srclang: lang || ''
2287
- });
2288
- var baseData = webshims.data(this, 'mediaelementBase') || webshims.data(this, 'mediaelementBase', {});
2289
- if (!baseData.scriptedTextTracks) {
2290
- baseData.scriptedTextTracks = [];
2291
- }
2292
- baseData.scriptedTextTracks.push(textTrack);
2293
- updateMediaTrackList.call(this);
2294
- return textTrack;
2295
- }
2296
- }
2297
- }, 'prop');
2298
-
2299
-
2300
- $(document).on('emptied ended updatetracklist', function(e){
2301
- if($(e.target).is('audio, video')){
2302
- var baseData = webshims.data(e.target, 'mediaelementBase');
2303
- if(baseData){
2304
- clearTimeout(baseData.updateTrackListTimer);
2305
- baseData.updateTrackListTimer = setTimeout(function(){
2306
- updateMediaTrackList.call(e.target, baseData);
2307
- }, 0);
2308
- }
2309
- }
2310
- });
2311
-
2312
- var getNativeReadyState = function(trackElem, textTrack){
2313
- return textTrack.readyState || trackElem.readyState;
2314
- };
2315
-
2316
- webshims.addReady(function(context, insertedElement){
2317
- var insertedMedia = insertedElement.filter('video, audio, track').closest('audio, video');
2318
- $('video, audio', context)
2319
- .add(insertedMedia)
2320
- .each(function(){
2321
- updateMediaTrackList.call(this);
2322
- })
2323
- .each(function(){
2324
- if(Modernizr.track){
2325
- var shimedTextTracks = $.prop(this, 'textTracks');
2326
- var origTextTracks = this.textTracks;
2327
- if(shimedTextTracks.length != origTextTracks.length){
2328
- webshims.error("textTracks couldn't be copied");
2329
- }
2330
-
2331
- $('track', this)
2332
- .each(function(){
2333
- var shimedTrack = $.prop(this, 'track');
2334
- var origTrack = this.track;
2335
- var kind;
2336
- var readyState;
2337
- if(origTrack){
2338
- kind = $.prop(this, 'kind');
2339
- readyState = getNativeReadyState(this, origTrack);
2340
- if (origTrack.mode || readyState) {
2341
- shimedTrack.mode = numericModes[origTrack.mode] || origTrack.mode;
2342
- }
2343
- //disable track from showing + remove UI
2344
- if(kind != 'descriptions'){
2345
- origTrack.mode = (typeof origTrack.mode == 'string') ? 'disabled' : 0;
2346
- this.kind = 'metadata';
2347
- $(this).attr({kind: kind});
2348
- }
2349
-
2350
- }
2351
- })
2352
- .on('load error', function(e){
2353
- if(e.originalEvent){
2354
- e.stopImmediatePropagation();
2355
- }
2356
- })
2357
- ;
2358
- }
2359
- })
2360
- ;
2361
- insertedMedia.each(function(){
2362
- var media = this;
2363
- var baseData = webshims.data(media, 'mediaelementBase');
2364
- if(baseData){
2365
- clearTimeout(baseData.updateTrackListTimer);
2366
- baseData.updateTrackListTimer = setTimeout(function(){
2367
- updateMediaTrackList.call(media, baseData);
2368
- }, 9);
2369
- }
2370
- });
2371
- });
2372
-
2373
- if(Modernizr.track){
2374
- $('video, audio').trigger('trackapichange');
2375
- }
2376
- });