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,3009 +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
- //additional tests for partial implementation of forms features
956
- (function($){
957
- "use strict";
958
- var isWebkit = /webkit/i.test(navigator.userAgent);
959
- var Modernizr = window.Modernizr;
960
- var webshims = $.webshims;
961
- 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
-
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
- }
997
- };
998
-
999
- if(!Modernizr.formvalidation || bugs.bustedValidity){
1000
- testRequiredFind();
1001
- } else {
1002
- //create delegatable events
1003
- webshims.capturingEvents(['input']);
1004
- webshims.capturingEvents(['invalid'], true);
1005
-
1006
- if(window.opera || window.testGoodWithFix){
1007
-
1008
- form.appendTo('head');
1009
-
1010
- testRequiredFind();
1011
- bugs.validationMessage = !(inputElem.prop('validationMessage'));
1012
-
1013
- webshims.reTest(['form-native-extend', 'form-message']);
1014
-
1015
- form.remove();
1016
-
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
- });
1048
- }
1049
-
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);
1062
-
1063
- $(window).on('invalid', function(e){
1064
- if(e.originalEvent && form && form == e.target.form){
1065
- e.wrongWebkitInvalid = true;
1066
- e.stopImmediatePropagation();
1067
- }
1068
- });
1069
-
1070
- })();
1071
- }
1072
- }
1073
-
1074
-
1075
-
1076
- jQuery.webshims.register('form-core', function($, webshims, window, document, undefined, options){
1077
- "use strict";
1078
-
1079
-
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"]');
1102
- }
1103
- return ret;
1104
- };
1105
-
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
- });
1120
- }
1121
- }
1122
-
1123
- if(typeof message == 'object'){
1124
- message = message.defaultMessage;
1125
- }
1126
- return message || '';
1127
- };
1128
-
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;
1139
- }
1140
- });
1141
- return ret;
1142
- };
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;
1162
- }
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;
1169
- }
1170
- var val = $.prop(elem, 'validity');
1171
- return !!(val && (val.rangeOverflow || val.rangeUnderflow));
1172
- }
1173
-
1174
- });
1175
-
1176
- ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
1177
- $.expr[":"][name] = $.expr.filters[name+"-element"];
1178
- });
1179
-
1180
-
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
- };
1188
-
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('');
1195
- }
1196
- };
1197
-
1198
- 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)
1203
- ;
1204
- }
1205
- });
1206
- })();
1207
- }
1208
-
1209
- var customEvents = $.event.customEvent || {};
1210
- var isValid = function(elem){
1211
- return ($.prop(elem, 'validity') || {valid: 1}).valid;
1212
- };
1213
-
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
- };
1244
- }
1245
-
1246
- })();
1247
- }
1248
-
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');
1259
- }
1260
- }
1261
- }
1262
- return ret;
1263
- };
1264
-
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;
1274
- };
1275
-
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
- };
1341
-
1342
- if(timer){
1343
- clearTimeout(timer);
1344
- }
1345
- if(e.type == 'refreshvalidityui'){
1346
- switchClass();
1347
- } else {
1348
- $.data(elem, 'webshimsswitchvalidityclass', setTimeout(switchClass, 9));
1349
- }
1350
- };
1351
-
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
-
1359
-
1360
- webshims.triggerInlineForm = function(elem, event){
1361
- $(elem).trigger(event);
1362
- };
1363
-
1364
- webshims.modules["form-core"].getGroupElements = getGroupElements;
1365
-
1366
-
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;
1386
- };
1387
-
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
- }
1454
- try {
1455
- focusElem[0].focus();
1456
- } catch(e){}
1457
- if(smooth){
1458
- webshims.scrollRoot.scrollTop(scrollTop);
1459
- setTimeout(function(){
1460
- webshims.scrollRoot.scrollTop(scrollTop);
1461
- }, 0);
1462
- }
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');
1471
- }
1472
- if (message) {
1473
- $('span.va-box', errorBubble).text(message);
1474
- }
1475
- else {
1476
- this.hide();
1477
- }
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();
1487
- }
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();
1507
- }
1508
- });
1509
- }
1510
- };
1511
-
1512
-
1513
- boundHide = $.proxy(api, 'hide');
1514
-
1515
- return api;
1516
- })();
1517
-
1518
-
1519
- /* extension, but also used to fix native implementation workaround/bugfixes */
1520
- (function(){
1521
- var firstEvent,
1522
- invalids = [],
1523
- stopSubmitTimer,
1524
- form
1525
- ;
1526
-
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);
1536
- }
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
- }
1572
- return message;
1573
- };
1574
-
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 );
1581
- }
1582
- });
1583
- });
1584
- }
1585
- });
1586
-
1587
- })(jQuery);
1588
- (function($, Modernizr, webshims){
1589
- "use strict";
1590
- var hasNative = Modernizr.audio && Modernizr.video;
1591
- var supportsLoop = false;
1592
- var bugs = webshims.bugs;
1593
-
1594
- var loadSwf = function(){
1595
- webshims.ready(swfType, function(){
1596
- if(!webshims.mediaelement.createSWF){
1597
- webshims.mediaelement.loadSwf = true;
1598
- webshims.reTest([swfType], hasNative);
1599
- }
1600
- });
1601
- };
1602
- var options = webshims.cfg.mediaelement;
1603
- var swfType = options && options.player == 'jwplayer' ? 'mediaelement-swf' : 'mediaelement-jaris';
1604
- var hasSwf;
1605
- if(!options){
1606
- webshims.error("mediaelement wasn't implemented but loaded");
1607
- return;
1608
- }
1609
- if(hasNative){
1610
- var videoElem = document.createElement('video');
1611
- Modernizr.videoBuffered = ('buffered' in videoElem);
1612
- supportsLoop = ('loop' in videoElem);
1613
-
1614
- webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
1615
-
1616
- if(!Modernizr.videoBuffered){
1617
- webshims.addPolyfill('mediaelement-native-fix', {
1618
- f: 'mediaelement',
1619
- test: Modernizr.videoBuffered,
1620
- d: ['dom-support']
1621
- });
1622
-
1623
- webshims.reTest('mediaelement-native-fix');
1624
- }
1625
- }
1626
-
1627
- if(hasNative && !options.preferFlash){
1628
- var switchOptions = function(e){
1629
- var parent = e.target.parentNode;
1630
- if(!options.preferFlash && ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) ){
1631
- webshims.ready('DOM mediaelement', function(){
1632
- if(hasSwf){
1633
- loadSwf();
1634
- }
1635
- webshims.ready('WINDOWLOAD '+swfType, function(){
1636
- setTimeout(function(){
1637
- if(hasSwf && !options.preferFlash && webshims.mediaelement.createSWF && !$(e.target).closest('audio, video').is('.nonnative-api-active')){
1638
- options.preferFlash = true;
1639
- document.removeEventListener('error', switchOptions, true);
1640
- $('audio, video').each(function(){
1641
- webshims.mediaelement.selectSource(this);
1642
- });
1643
- webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src);
1644
- } else if(!hasSwf){
1645
- document.removeEventListener('error', switchOptions, true);
1646
- }
1647
- }, 20);
1648
- });
1649
- });
1650
- }
1651
- };
1652
- document.addEventListener('error', switchOptions, true);
1653
- $('audio, video').each(function(){
1654
- if(this.error){
1655
- switchOptions({target: this});
1656
- }
1657
- });
1658
- }
1659
-
1660
-
1661
- if(Modernizr.track && !bugs.track){
1662
- (function(){
1663
-
1664
- if(!bugs.track){
1665
- bugs.track = typeof $('<track />')[0].readyState != 'number';
1666
- }
1667
-
1668
- if(!bugs.track){
1669
- try {
1670
- new TextTrackCue(2, 3, '');
1671
- } catch(e){
1672
- bugs.track = true;
1673
- }
1674
- }
1675
-
1676
- var trackOptions = webshims.cfg.track;
1677
- var trackListener = function(e){
1678
- $(e.target).filter('track').each(changeApi);
1679
- };
1680
- var changeApi = function(){
1681
- if(bugs.track || (!trackOptions.override && $.prop(this, 'readyState') == 3)){
1682
- trackOptions.override = true;
1683
- webshims.reTest('track');
1684
- document.removeEventListener('error', trackListener, true);
1685
- if(this && $.nodeName(this, 'track')){
1686
- webshims.error("track support was overwritten. Please check your vtt including your vtt mime-type");
1687
- } else {
1688
- webshims.info("track support was overwritten. due to bad browser support");
1689
- }
1690
- }
1691
- };
1692
- var detectTrackError = function(){
1693
- document.addEventListener('error', trackListener, true);
1694
-
1695
- if(bugs.track){
1696
- changeApi();
1697
- } else {
1698
- $('track').each(changeApi);
1699
- }
1700
- };
1701
- if(!trackOptions.override){
1702
- if(webshims.isReady('track')){
1703
- detectTrackError();
1704
- } else {
1705
- $(detectTrackError);
1706
- }
1707
- }
1708
- })();
1709
-
1710
- }
1711
-
1712
- webshims.register('mediaelement-core', function($, webshims, window, document, undefined){
1713
- hasSwf = swfobject.hasFlashPlayerVersion('9.0.115');
1714
- $('html').addClass(hasSwf ? 'swf' : 'no-swf');
1715
- var mediaelement = webshims.mediaelement;
1716
- mediaelement.parseRtmp = function(data){
1717
- var src = data.src.split('://');
1718
- var paths = src[1].split('/');
1719
- var i, len, found;
1720
- data.server = src[0]+'://'+paths[0]+'/';
1721
- data.streamId = [];
1722
- for(i = 1, len = paths.length; i < len; i++){
1723
- if(!found && paths[i].indexOf(':') !== -1){
1724
- paths[i] = paths[i].split(':')[1];
1725
- found = true;
1726
- }
1727
- if(!found){
1728
- data.server += paths[i]+'/';
1729
- } else {
1730
- data.streamId.push(paths[i]);
1731
- }
1732
- }
1733
- if(!data.streamId.length){
1734
- webshims.error('Could not parse rtmp url');
1735
- }
1736
- data.streamId = data.streamId.join('/');
1737
- };
1738
- var getSrcObj = function(elem, nodeName){
1739
- elem = $(elem);
1740
- var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
1741
- var tmp;
1742
-
1743
- if(!src.src){return src;}
1744
-
1745
- tmp = elem.attr('data-server');
1746
- if(tmp != null){
1747
- src.server = tmp;
1748
- }
1749
-
1750
- tmp = elem.attr('type');
1751
- if(tmp){
1752
- src.type = tmp;
1753
- src.container = $.trim(tmp.split(';')[0]);
1754
- } else {
1755
- if(!nodeName){
1756
- nodeName = elem[0].nodeName.toLowerCase();
1757
- if(nodeName == 'source'){
1758
- nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
1759
- }
1760
- }
1761
- if(src.server){
1762
- src.type = nodeName+'/rtmp';
1763
- src.container = nodeName+'/rtmp';
1764
- } else {
1765
-
1766
- tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
1767
-
1768
- if(tmp){
1769
- src.type = tmp;
1770
- src.container = tmp;
1771
- }
1772
- }
1773
- }
1774
- tmp = elem.attr('media');
1775
- if(tmp){
1776
- src.media = tmp;
1777
- }
1778
- if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
1779
- if(src.server){
1780
- src.streamId = src.src;
1781
- } else {
1782
- mediaelement.parseRtmp(src);
1783
- }
1784
- }
1785
- return src;
1786
- };
1787
-
1788
-
1789
-
1790
- var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
1791
-
1792
- var loadTrackUi = function(){
1793
- if(loadTrackUi.loaded){return;}
1794
- loadTrackUi.loaded = true;
1795
- $(function(){
1796
- webshims.loader.loadList(['track-ui']);
1797
- });
1798
- };
1799
- var loadYt = (function(){
1800
- var loaded;
1801
- return function(){
1802
- if(loaded || !hasYt){return;}
1803
- loaded = true;
1804
- webshims.loader.loadScript("https://www.youtube.com/player_api");
1805
- $(function(){
1806
- webshims.polyfill("mediaelement-yt");
1807
- });
1808
- };
1809
- })();
1810
- var loadThird = function(){
1811
- if(hasSwf){
1812
- loadSwf();
1813
- } else {
1814
- loadYt();
1815
- }
1816
- };
1817
-
1818
- webshims.addPolyfill('mediaelement-yt', {
1819
- test: !hasYt,
1820
- d: ['dom-support']
1821
- });
1822
-
1823
- mediaelement.mimeTypes = {
1824
- audio: {
1825
- //ogm shouldn´t be used!
1826
- 'audio/ogg': ['ogg','oga', 'ogm'],
1827
- 'audio/ogg;codecs="opus"': 'opus',
1828
- 'audio/mpeg': ['mp2','mp3','mpga','mpega'],
1829
- 'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
1830
- 'audio/wav': ['wav'],
1831
- 'audio/3gpp': ['3gp','3gpp'],
1832
- 'audio/webm': ['webm'],
1833
- 'audio/fla': ['flv', 'f4a', 'fla'],
1834
- 'application/x-mpegURL': ['m3u8', 'm3u']
1835
- },
1836
- video: {
1837
- //ogm shouldn´t be used!
1838
- 'video/ogg': ['ogg','ogv', 'ogm'],
1839
- 'video/mpeg': ['mpg','mpeg','mpe'],
1840
- 'video/mp4': ['mp4','mpg4', 'm4v'],
1841
- 'video/quicktime': ['mov','qt'],
1842
- 'video/x-msvideo': ['avi'],
1843
- 'video/x-ms-asf': ['asf', 'asx'],
1844
- 'video/flv': ['flv', 'f4v'],
1845
- 'video/3gpp': ['3gp','3gpp'],
1846
- 'video/webm': ['webm'],
1847
- 'application/x-mpegURL': ['m3u8', 'm3u'],
1848
- 'video/MP2T': ['ts']
1849
- }
1850
- }
1851
- ;
1852
-
1853
- mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
1854
-
1855
- mediaelement.getTypeForSrc = function(src, nodeName, data){
1856
- if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
1857
- return 'video/youtube';
1858
- }
1859
- if(src.indexOf('rtmp') === 0){
1860
- return nodeName+'/rtmp';
1861
- }
1862
- src = src.split('?')[0].split('.');
1863
- src = src[src.length - 1];
1864
- var mt;
1865
-
1866
- $.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
1867
- if(exts.indexOf(src) !== -1){
1868
- mt = mimeType;
1869
- return false;
1870
- }
1871
- });
1872
- return mt;
1873
- };
1874
-
1875
-
1876
- mediaelement.srces = function(mediaElem, srces){
1877
- mediaElem = $(mediaElem);
1878
- if(!srces){
1879
- srces = [];
1880
- var nodeName = mediaElem[0].nodeName.toLowerCase();
1881
- var src = getSrcObj(mediaElem, nodeName);
1882
-
1883
- if(!src.src){
1884
-
1885
- $('source', mediaElem).each(function(){
1886
- src = getSrcObj(this, nodeName);
1887
- if(src.src){srces.push(src);}
1888
- });
1889
- } else {
1890
- srces.push(src);
1891
- }
1892
- return srces;
1893
- } else {
1894
- mediaElem.removeAttr('src').removeAttr('type').find('source').remove();
1895
- if(!$.isArray(srces)){
1896
- srces = [srces];
1897
- }
1898
- srces.forEach(function(src){
1899
- var source = document.createElement('source');
1900
- if(typeof src == 'string'){
1901
- src = {src: src};
1902
- }
1903
- source.setAttribute('src', src.src);
1904
- if(src.type){
1905
- source.setAttribute('type', src.type);
1906
- }
1907
- if(src.media){
1908
- source.setAttribute('media', src.media);
1909
- }
1910
- mediaElem.append(source);
1911
- });
1912
-
1913
- }
1914
- };
1915
-
1916
-
1917
- $.fn.loadMediaSrc = function(srces, poster){
1918
- return this.each(function(){
1919
- if(poster !== undefined){
1920
- $(this).removeAttr('poster');
1921
- if(poster){
1922
- $.attr(this, 'poster', poster);
1923
- }
1924
- }
1925
- mediaelement.srces(this, srces);
1926
- $(this).mediaLoad();
1927
- });
1928
- };
1929
-
1930
- 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'];
1931
-
1932
- mediaelement.canThirdPlaySrces = function(mediaElem, srces){
1933
- var ret = '';
1934
- if(hasSwf || hasYt){
1935
- mediaElem = $(mediaElem);
1936
- srces = srces || mediaelement.srces(mediaElem);
1937
- $.each(srces, function(i, src){
1938
- if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
1939
- ret = src;
1940
- return false;
1941
- }
1942
- });
1943
-
1944
- }
1945
-
1946
- return ret;
1947
- };
1948
-
1949
- var nativeCanPlayType = {};
1950
- mediaelement.canNativePlaySrces = function(mediaElem, srces){
1951
- var ret = '';
1952
- if(hasNative){
1953
- mediaElem = $(mediaElem);
1954
- var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
1955
- if(!nativeCanPlayType[nodeName]){return ret;}
1956
- srces = srces || mediaelement.srces(mediaElem);
1957
-
1958
- $.each(srces, function(i, src){
1959
- if(src.type && nativeCanPlayType[nodeName].prop._supvalue.call(mediaElem[0], src.type) ){
1960
- ret = src;
1961
- return false;
1962
- }
1963
- });
1964
- }
1965
- return ret;
1966
- };
1967
-
1968
- mediaelement.setError = function(elem, message){
1969
- if(!message){
1970
- message = "can't play sources";
1971
- }
1972
-
1973
- $(elem).pause().data('mediaerror', message);
1974
- webshims.warn('mediaelementError: '+ message);
1975
- setTimeout(function(){
1976
- if($(elem).data('mediaerror')){
1977
- $(elem).trigger('mediaerror');
1978
- }
1979
- }, 1);
1980
- };
1981
-
1982
- var handleThird = (function(){
1983
- var requested;
1984
- return function( mediaElem, ret, data ){
1985
- if(!requested){
1986
- loadTrackUi();
1987
- }
1988
- webshims.ready(hasSwf ? swfType : 'mediaelement-yt', function(){
1989
- if(mediaelement.createSWF){
1990
- mediaelement.createSWF( mediaElem, ret, data );
1991
- } else if(!requested) {
1992
- requested = true;
1993
- loadThird();
1994
- //readd to ready
1995
- handleThird( mediaElem, ret, data );
1996
- }
1997
- });
1998
- if(!requested && hasYt && !mediaelement.createSWF){
1999
- loadYt();
2000
- }
2001
- };
2002
- })();
2003
-
2004
- var stepSources = function(elem, data, useSwf, _srces, _noLoop){
2005
- var ret;
2006
- if(useSwf || (useSwf !== false && data && data.isActive == 'third')){
2007
- ret = mediaelement.canThirdPlaySrces(elem, _srces);
2008
- if(!ret){
2009
- if(_noLoop){
2010
- mediaelement.setError(elem, false);
2011
- } else {
2012
- stepSources(elem, data, false, _srces, true);
2013
- }
2014
- } else {
2015
- handleThird(elem, ret, data);
2016
- }
2017
- } else {
2018
- ret = mediaelement.canNativePlaySrces(elem, _srces);
2019
- if(!ret){
2020
- if(_noLoop){
2021
- mediaelement.setError(elem, false);
2022
- if(data && data.isActive == 'third') {
2023
- mediaelement.setActive(elem, 'html5', data);
2024
- }
2025
- } else {
2026
- stepSources(elem, data, true, _srces, true);
2027
- }
2028
- } else if(data && data.isActive == 'third') {
2029
- mediaelement.setActive(elem, 'html5', data);
2030
- }
2031
- }
2032
- };
2033
- var stopParent = /^(?:embed|object|datalist)$/i;
2034
- var selectSource = function(elem, data){
2035
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
2036
- var _srces = mediaelement.srces(elem);
2037
- var parent = elem.parentNode;
2038
-
2039
- clearTimeout(baseData.loadTimer);
2040
- $.data(elem, 'mediaerror', false);
2041
-
2042
- if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
2043
- data = data || webshims.data(elem, 'mediaelement');
2044
- stepSources(elem, data, options.preferFlash || undefined, _srces);
2045
- };
2046
- mediaelement.selectSource = selectSource;
2047
-
2048
- $(document).on('ended', function(e){
2049
- var data = webshims.data(e.target, 'mediaelement');
2050
- if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
2051
- setTimeout(function(){
2052
- if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
2053
- $(e.target).prop('currentTime', 0).play();
2054
- }, 1);
2055
-
2056
- });
2057
- if(!supportsLoop){
2058
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
2059
- }
2060
-
2061
- ['audio', 'video'].forEach(function(nodeName){
2062
- var supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
2063
- prop: {
2064
- value: function(){
2065
- var data = webshims.data(this, 'mediaelement');
2066
- selectSource(this, data);
2067
- if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
2068
- supLoad.prop._supvalue.apply(this, arguments);
2069
- }
2070
- }
2071
- }
2072
- });
2073
- nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
2074
- prop: {
2075
- value: function(type){
2076
- var ret = '';
2077
- if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
2078
- ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
2079
- if(ret == 'no'){
2080
- ret = '';
2081
- }
2082
- }
2083
- if(!ret && hasSwf){
2084
- type = $.trim((type || '').split(';')[0]);
2085
- if(mediaelement.swfMimeTypes.indexOf(type) != -1){
2086
- ret = 'maybe';
2087
- }
2088
- }
2089
- return ret;
2090
- }
2091
- }
2092
- });
2093
- });
2094
- webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
2095
- set: function(){
2096
- var elem = this;
2097
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
2098
- clearTimeout(baseData.loadTimer);
2099
- baseData.loadTimer = setTimeout(function(){
2100
- selectSource(elem);
2101
- elem = null;
2102
- }, 9);
2103
- }
2104
- });
2105
-
2106
- var initMediaElements = function(){
2107
-
2108
- webshims.addReady(function(context, insertedElement){
2109
- var media = $('video, audio', context)
2110
- .add(insertedElement.filter('video, audio'))
2111
- .each(function(){
2112
- var data = webshims.data(this, 'mediaelement');
2113
-
2114
- if(hasNative && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay])') && (!data || data.isActive == 'html5')){
2115
- //IE controls not visible bug
2116
- $(this).prop('preload', 'metadata').mediaLoad();
2117
- } else {
2118
- selectSource(this, data);
2119
- }
2120
-
2121
- if(hasNative){
2122
-
2123
- //FF progress bug
2124
- (function(){
2125
- var bufferTimer;
2126
- var lastBuffered;
2127
- var elem = this;
2128
- var getBufferedString = function(){
2129
- var buffered = $.prop(elem, 'buffered');
2130
- if(!buffered){return;}
2131
- var bufferString = "";
2132
- for(var i = 0, len = buffered.length; i < len;i++){
2133
- bufferString += buffered.end(i);
2134
- }
2135
- return bufferString;
2136
- };
2137
- var testBuffer = function(){
2138
- var buffered = getBufferedString();
2139
- if(buffered != lastBuffered){
2140
- lastBuffered = buffered;
2141
- $(elem).triggerHandler('progress');
2142
- }
2143
- };
2144
-
2145
- $(this)
2146
- .on({
2147
- 'play loadstart progress': function(e){
2148
- if(e.type == 'progress'){
2149
- lastBuffered = getBufferedString();
2150
- }
2151
- clearTimeout(bufferTimer);
2152
- bufferTimer = setTimeout(testBuffer, 999);
2153
- },
2154
- 'emptied stalled mediaerror abort suspend': function(e){
2155
- if(e.type == 'emptied'){
2156
- lastBuffered = false;
2157
- }
2158
- clearTimeout(bufferTimer);
2159
- }
2160
- })
2161
- ;
2162
- })();
2163
- }
2164
-
2165
- })
2166
- ;
2167
- if(!loadTrackUi.loaded && $('track', media).length){
2168
- loadTrackUi();
2169
- }
2170
- media = null;
2171
- });
2172
- };
2173
-
2174
- if(Modernizr.track && !bugs.track){
2175
- webshims.defineProperty(TextTrack.prototype, 'shimActiveCues', {
2176
- get: function(){
2177
- return this._shimActiveCues || this.activeCues;
2178
- }
2179
- });
2180
- }
2181
- //set native implementation ready, before swf api is retested
2182
- if(hasNative){
2183
- webshims.isReady('mediaelement-core', true);
2184
- initMediaElements();
2185
- webshims.ready('WINDOWLOAD mediaelement', loadThird);
2186
- } else {
2187
- webshims.ready(swfType, initMediaElements);
2188
- }
2189
- webshims.ready('WINDOWLOAD mediaelement', loadTrackUi);
2190
- });
2191
- })(jQuery, Modernizr, jQuery.webshims);
2192
- jQuery.webshims.register('track', function($, webshims, window, document, undefined){
2193
- "use strict";
2194
- var mediaelement = webshims.mediaelement;
2195
- var id = new Date().getTime();
2196
- var ADDBACK = $.fn.addBack ? 'addBack' : 'andSelf';
2197
- //descriptions are not really shown, but they are inserted into the dom
2198
- var showTracks = {subtitles: 1, captions: 1, descriptions: 1};
2199
- var notImplemented = function(){
2200
- webshims.error('not implemented yet');
2201
- };
2202
- var dummyTrack = $('<track />');
2203
- var supportTrackMod = Modernizr.ES5 && Modernizr.objectAccessor;
2204
- var createEventTarget = function(obj){
2205
- var eventList = {};
2206
- obj.addEventListener = function(name, fn){
2207
- if(eventList[name]){
2208
- webshims.error('always use $.on to the shimed event: '+ name +' already bound fn was: '+ eventList[name] +' your fn was: '+ fn);
2209
- }
2210
- eventList[name] = fn;
2211
-
2212
- };
2213
- obj.removeEventListener = function(name, fn){
2214
- if(eventList[name] && eventList[name] != fn){
2215
- webshims.error('always use $.on/$.off to the shimed event: '+ name +' already bound fn was: '+ eventList[name] +' your fn was: '+ fn);
2216
- }
2217
- if(eventList[name]){
2218
- delete eventList[name];
2219
- }
2220
- };
2221
- return obj;
2222
- };
2223
-
2224
-
2225
- var cueListProto = {
2226
- getCueById: function(id){
2227
- var cue = null;
2228
- for(var i = 0, len = this.length; i < len; i++){
2229
- if(this[i].id === id){
2230
- cue = this[i];
2231
- break;
2232
- }
2233
- }
2234
- return cue;
2235
- }
2236
- };
2237
- var numericModes = {
2238
- 0: 'disabled',
2239
- 1: 'hidden',
2240
- 2: 'showing'
2241
- };
2242
-
2243
- var textTrackProto = {
2244
- shimActiveCues: null,
2245
- _shimActiveCues: null,
2246
- activeCues: null,
2247
- cues: null,
2248
- kind: 'subtitles',
2249
- label: '',
2250
- language: '',
2251
- mode: 'disabled',
2252
- readyState: 0,
2253
- oncuechange: null,
2254
- toString: function() {
2255
- return "[object TextTrack]";
2256
- },
2257
- addCue: function(cue){
2258
- if(!this.cues){
2259
- this.cues = mediaelement.createCueList();
2260
- } else {
2261
- var lastCue = this.cues[this.cues.length-1];
2262
- if(lastCue && lastCue.startTime > cue.startTime){
2263
- webshims.error("cue startTime higher than previous cue's startTime");
2264
- }
2265
- }
2266
- if(cue.track && cue.track.removeCue){
2267
- cue.track.removeCue(cue);
2268
- }
2269
- cue.track = this;
2270
- this.cues.push(cue);
2271
- },
2272
- //ToDo: make it more dynamic
2273
- removeCue: function(cue){
2274
- var cues = this.cues || [];
2275
- var i = 0;
2276
- var len = cues.length;
2277
- if(cue.track != this){
2278
- webshims.error("cue not part of track");
2279
- return;
2280
- }
2281
- for(; i < len; i++){
2282
- if(cues[i] === cue){
2283
- cues.splice(i, 1);
2284
- cue.track = null;
2285
- break;
2286
- }
2287
- }
2288
- if(cue.track){
2289
- webshims.error("cue not part of track");
2290
- return;
2291
- }
2292
- },
2293
- DISABLED: 'disabled',
2294
- OFF: 'disabled',
2295
- HIDDEN: 'hidden',
2296
- SHOWING: 'showing',
2297
- ERROR: 3,
2298
- LOADED: 2,
2299
- LOADING: 1,
2300
- NONE: 0
2301
- };
2302
- var copyProps = ['kind', 'label', 'srclang'];
2303
- var copyName = {srclang: 'language'};
2304
-
2305
- var owns = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
2306
-
2307
- var updateMediaTrackList = function(baseData, trackList){
2308
- var removed = [];
2309
- var added = [];
2310
- var newTracks = [];
2311
- var i, len;
2312
- if(!baseData){
2313
- baseData = webshims.data(this, 'mediaelementBase') || webshims.data(this, 'mediaelementBase', {});
2314
- }
2315
-
2316
- if(!trackList){
2317
- baseData.blockTrackListUpdate = true;
2318
- trackList = $.prop(this, 'textTracks');
2319
- baseData.blockTrackListUpdate = false;
2320
- }
2321
-
2322
- clearTimeout(baseData.updateTrackListTimer);
2323
-
2324
- $('track', this).each(function(){
2325
- var track = $.prop(this, 'track');
2326
- newTracks.push(track);
2327
- if(trackList.indexOf(track) == -1){
2328
- added.push(track);
2329
- }
2330
- });
2331
-
2332
- if(baseData.scriptedTextTracks){
2333
- for(i = 0, len = baseData.scriptedTextTracks.length; i < len; i++){
2334
- newTracks.push(baseData.scriptedTextTracks[i]);
2335
- if(trackList.indexOf(baseData.scriptedTextTracks[i]) == -1){
2336
- added.push(baseData.scriptedTextTracks[i]);
2337
- }
2338
- }
2339
- }
2340
-
2341
- for(i = 0, len = trackList.length; i < len; i++){
2342
- if(newTracks.indexOf(trackList[i]) == -1){
2343
- removed.push(trackList[i]);
2344
- }
2345
- }
2346
-
2347
- if(removed.length || added.length){
2348
- trackList.splice(0);
2349
-
2350
- for(i = 0, len = newTracks.length; i < len; i++){
2351
- trackList.push(newTracks[i]);
2352
- }
2353
- for(i = 0, len = removed.length; i < len; i++){
2354
- $([trackList]).triggerHandler($.Event({type: 'removetrack', track: removed[i]}));
2355
- }
2356
- for(i = 0, len = added.length; i < len; i++){
2357
- $([trackList]).triggerHandler($.Event({type: 'addtrack', track: added[i]}));
2358
- }
2359
- if(baseData.scriptedTextTracks || removed.length){
2360
- $(this).triggerHandler('updatetrackdisplay');
2361
- }
2362
- }
2363
- };
2364
-
2365
- var refreshTrack = function(track, trackData){
2366
- if(!trackData){
2367
- trackData = webshims.data(track, 'trackData');
2368
- }
2369
- if(trackData && !trackData.isTriggering){
2370
- trackData.isTriggering = true;
2371
- setTimeout(function(){
2372
- if(!(trackData.track || {}).readyState){
2373
- $(track).triggerHandler('checktrackmode');
2374
- } else {
2375
- $(track).closest('audio, video').triggerHandler('updatetrackdisplay');
2376
- }
2377
- trackData.isTriggering = false;
2378
- }, 1);
2379
- }
2380
- };
2381
-
2382
- var emptyDiv = $('<div />')[0];
2383
- window.TextTrackCue = function(startTime, endTime, text){
2384
- if(arguments.length != 3){
2385
- webshims.error("wrong arguments.length for TextTrackCue.constructor");
2386
- }
2387
-
2388
- this.startTime = startTime;
2389
- this.endTime = endTime;
2390
- this.text = text;
2391
-
2392
- this.id = "";
2393
- this.pauseOnExit = false;
2394
-
2395
- createEventTarget(this);
2396
- };
2397
-
2398
- window.TextTrackCue.prototype = {
2399
-
2400
- onenter: null,
2401
- onexit: null,
2402
- pauseOnExit: false,
2403
- getCueAsHTML: function(){
2404
- var lastText = "";
2405
- var parsedText = "";
2406
- var fragment = document.createDocumentFragment();
2407
- var fn;
2408
- if(!owns(this, 'getCueAsHTML')){
2409
- fn = this.getCueAsHTML = function(){
2410
- var i, len;
2411
- if(lastText != this.text){
2412
- lastText = this.text;
2413
- parsedText = mediaelement.parseCueTextToHTML(lastText);
2414
- emptyDiv.innerHTML = parsedText;
2415
-
2416
- for(i = 0, len = emptyDiv.childNodes.length; i < len; i++){
2417
- fragment.appendChild(emptyDiv.childNodes[i].cloneNode(true));
2418
- }
2419
- }
2420
- return fragment.cloneNode(true);
2421
- };
2422
-
2423
- }
2424
- return fn ? fn.apply(this, arguments) : fragment.cloneNode(true);
2425
- },
2426
- track: null,
2427
-
2428
-
2429
- id: ''
2430
- //todo-->
2431
- // ,
2432
- // snapToLines: true,
2433
- // line: 'auto',
2434
- // size: 100,
2435
- // position: 50,
2436
- // vertical: '',
2437
- // align: 'middle'
2438
- };
2439
-
2440
-
2441
-
2442
-
2443
-
2444
- mediaelement.createCueList = function(){
2445
- return $.extend([], cueListProto);
2446
- };
2447
-
2448
- mediaelement.parseCueTextToHTML = (function(){
2449
- var tagSplits = /(<\/?[^>]+>)/ig;
2450
- var allowedTags = /^(?:c|v|ruby|rt|b|i|u)/;
2451
- var regEnd = /\<\s*\//;
2452
- var addToTemplate = function(localName, attribute, tag, html){
2453
- var ret;
2454
- if(regEnd.test(html)){
2455
- ret = '</'+ localName +'>';
2456
- } else {
2457
- tag.splice(0, 1);
2458
- ret = '<'+ localName +' '+ attribute +'="'+ (tag.join(' ').replace(/\"/g, '&#34;')) +'">';
2459
- }
2460
- return ret;
2461
- };
2462
- var replacer = function(html){
2463
- var tag = html.replace(/[<\/>]+/ig,"").split(/[\s\.]+/);
2464
- if(tag[0]){
2465
- tag[0] = tag[0].toLowerCase();
2466
- if(allowedTags.test(tag[0])){
2467
- if(tag[0] == 'c'){
2468
- html = addToTemplate('span', 'class', tag, html);
2469
- } else if(tag[0] == 'v'){
2470
- html = addToTemplate('q', 'title', tag, html);
2471
- }
2472
- } else {
2473
- html = "";
2474
- }
2475
- }
2476
- return html;
2477
- };
2478
-
2479
- return function(cueText){
2480
- return cueText.replace(tagSplits, replacer);
2481
- };
2482
- })();
2483
-
2484
- mediaelement.loadTextTrack = function(mediaelem, track, trackData, _default){
2485
- var loadEvents = 'play playing timeupdate updatetrackdisplay';
2486
- var obj = trackData.track;
2487
- var load = function(){
2488
- var src = $.prop(track, 'src');
2489
- var error;
2490
- var ajax;
2491
- if(obj.mode != 'disabled' && src && $.attr(track, 'src')){
2492
- $(mediaelem).unbind(loadEvents, load);
2493
- $(track).unbind('checktrackmode', load);
2494
- if(!obj.readyState){
2495
- error = function(){
2496
- obj.readyState = 3;
2497
- obj.cues = null;
2498
- obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = null;
2499
- $(track).triggerHandler('error');
2500
- };
2501
- obj.readyState = 1;
2502
- try {
2503
- obj.cues = mediaelement.createCueList();
2504
- obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = mediaelement.createCueList();
2505
- ajax = $.ajax({
2506
- dataType: 'text',
2507
- url: src,
2508
- success: function(text){
2509
- if(ajax.getResponseHeader('content-type') != 'text/vtt'){
2510
- webshims.error('set the mime-type of your WebVTT files to text/vtt. see: http://dev.w3.org/html5/webvtt/#text/vtt');
2511
- }
2512
- mediaelement.parseCaptions(text, obj, function(cues){
2513
- if(cues && 'length' in cues){
2514
- obj.readyState = 2;
2515
- $(track).triggerHandler('load');
2516
- $(mediaelem).triggerHandler('updatetrackdisplay');
2517
- } else {
2518
- error();
2519
- }
2520
- });
2521
-
2522
- },
2523
- error: error
2524
- });
2525
- } catch(er){
2526
- error();
2527
- webshims.warn(er);
2528
- }
2529
- }
2530
- }
2531
- };
2532
- obj.readyState = 0;
2533
- obj.shimActiveCues = null;
2534
- obj._shimActiveCues = null;
2535
- obj.activeCues = null;
2536
- obj.cues = null;
2537
- $(mediaelem).unbind(loadEvents, load);
2538
- $(track).unbind('checktrackmode', load);
2539
- $(mediaelem).on(loadEvents, load);
2540
- $(track).on('checktrackmode', load);
2541
- if(_default){
2542
- obj.mode = showTracks[obj.kind] ? 'showing' : 'hidden';
2543
- load();
2544
- }
2545
- };
2546
-
2547
- mediaelement.createTextTrack = function(mediaelem, track){
2548
- var obj, trackData;
2549
- if(track.nodeName){
2550
- trackData = webshims.data(track, 'trackData');
2551
-
2552
- if(trackData){
2553
- refreshTrack(track, trackData);
2554
- obj = trackData.track;
2555
- }
2556
- }
2557
-
2558
- if(!obj){
2559
- obj = createEventTarget(webshims.objectCreate(textTrackProto));
2560
-
2561
- if(!supportTrackMod){
2562
- copyProps.forEach(function(copyProp){
2563
- var prop = $.prop(track, copyProp);
2564
- if(prop){
2565
- obj[copyName[copyProp] || copyProp] = prop;
2566
- }
2567
- });
2568
- }
2569
-
2570
-
2571
- if(track.nodeName){
2572
-
2573
- if(supportTrackMod){
2574
- copyProps.forEach(function(copyProp){
2575
- webshims.defineProperty(obj, copyName[copyProp] || copyProp, {
2576
- get: function(){
2577
- return $.prop(track, copyProp);
2578
- }
2579
- });
2580
- });
2581
- }
2582
-
2583
- trackData = webshims.data(track, 'trackData', {track: obj});
2584
- mediaelement.loadTextTrack(mediaelem, track, trackData, ($.prop(track, 'default') && $(track).siblings('track[default]')[ADDBACK]()[0] == track));
2585
- } else {
2586
- if(supportTrackMod){
2587
- copyProps.forEach(function(copyProp){
2588
- webshims.defineProperty(obj, copyName[copyProp] || copyProp, {
2589
- value: track[copyProp],
2590
- writeable: false
2591
- });
2592
- });
2593
- }
2594
- obj.cues = mediaelement.createCueList();
2595
- obj.activeCues = obj._shimActiveCues = obj.shimActiveCues = mediaelement.createCueList();
2596
- obj.mode = 'hidden';
2597
- obj.readyState = 2;
2598
- }
2599
- }
2600
- return obj;
2601
- };
2602
-
2603
-
2604
- /*
2605
- taken from:
2606
- Captionator 0.5.1 [CaptionCrunch]
2607
- Christopher Giffard, 2011
2608
- Share and enjoy
2609
-
2610
- https://github.com/cgiffard/Captionator
2611
-
2612
- modified for webshims
2613
- */
2614
- mediaelement.parseCaptionChunk = (function(){
2615
- // Set up timestamp parsers
2616
- var WebVTTTimestampParser = /^(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s+\-\-\>\s+(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s*(.*)/;
2617
- var GoogleTimestampParser = /^([\d\.]+)\s+\+([\d\.]+)\s*(.*)/;
2618
- var WebVTTDEFAULTSCueParser = /^(DEFAULTS|DEFAULT)\s+\-\-\>\s+(.*)/g;
2619
- var WebVTTSTYLECueParser = /^(STYLE|STYLES)\s+\-\-\>\s*\n([\s\S]*)/g;
2620
- var WebVTTCOMMENTCueParser = /^(COMMENT|COMMENTS)\s+\-\-\>\s+(.*)/g;
2621
-
2622
- return function(subtitleElement,objectCount){
2623
- var cueDefaults = [];
2624
-
2625
- var subtitleParts, timeIn, timeOut, html, timeData, subtitlePartIndex, cueSettings = "", id, specialCueData;
2626
- var timestampMatch, tmpCue;
2627
-
2628
- // WebVTT Special Cue Logic
2629
- if ((specialCueData = WebVTTDEFAULTSCueParser.exec(subtitleElement))) {
2630
- // cueDefaults = specialCueData.slice(2).join("");
2631
- // cueDefaults = cueDefaults.split(/\s+/g).filter(function(def) { return def && !!def.length; });
2632
- return null;
2633
- } else if ((specialCueData = WebVTTSTYLECueParser.exec(subtitleElement))) {
2634
- return null;
2635
- } else if ((specialCueData = WebVTTCOMMENTCueParser.exec(subtitleElement))) {
2636
- return null; // At this stage, we don't want to do anything with these.
2637
- }
2638
-
2639
- subtitleParts = subtitleElement.split(/\n/g);
2640
-
2641
- // Trim off any blank lines (logically, should only be max. one, but loop to be sure)
2642
- while (!subtitleParts[0].replace(/\s+/ig,"").length && subtitleParts.length > 0) {
2643
- subtitleParts.shift();
2644
- }
2645
-
2646
- if (subtitleParts[0].match(/^\s*[a-z0-9-\_]+\s*$/ig)) {
2647
- // The identifier becomes the cue ID (when *we* load the cues from file. Programatically created cues can have an ID of whatever.)
2648
- id = String(subtitleParts.shift().replace(/\s*/ig,""));
2649
- }
2650
-
2651
- for (subtitlePartIndex = 0; subtitlePartIndex < subtitleParts.length; subtitlePartIndex ++) {
2652
- var timestamp = subtitleParts[subtitlePartIndex];
2653
-
2654
- if ((timestampMatch = WebVTTTimestampParser.exec(timestamp))) {
2655
-
2656
- // WebVTT
2657
-
2658
- timeData = timestampMatch.slice(1);
2659
-
2660
- timeIn = parseInt((timeData[0]||0) * 60 * 60,10) + // Hours
2661
- parseInt((timeData[1]||0) * 60,10) + // Minutes
2662
- parseInt((timeData[2]||0),10) + // Seconds
2663
- parseFloat("0." + (timeData[3]||0)); // MS
2664
-
2665
- timeOut = parseInt((timeData[4]||0) * 60 * 60,10) + // Hours
2666
- parseInt((timeData[5]||0) * 60,10) + // Minutes
2667
- parseInt((timeData[6]||0),10) + // Seconds
2668
- parseFloat("0." + (timeData[7]||0)); // MS
2669
- /*
2670
- if (timeData[8]) {
2671
- cueSettings = timeData[8];
2672
- }
2673
- */
2674
- }
2675
-
2676
- // We've got the timestamp - return all the other unmatched lines as the raw subtitle data
2677
- subtitleParts = subtitleParts.slice(0,subtitlePartIndex).concat(subtitleParts.slice(subtitlePartIndex+1));
2678
- break;
2679
- }
2680
-
2681
- if (!timeIn && !timeOut) {
2682
- // We didn't extract any time information. Assume the cue is invalid!
2683
- webshims.warn("couldn't extract time information: "+[timeIn, timeOut, subtitleParts.join("\n"), id].join(' ; '));
2684
- return null;
2685
- }
2686
- /*
2687
- // Consolidate cue settings, convert defaults to object
2688
- var compositeCueSettings =
2689
- cueDefaults
2690
- .reduce(function(previous,current,index,array){
2691
- previous[current.split(":")[0]] = current.split(":")[1];
2692
- return previous;
2693
- },{});
2694
-
2695
- // Loop through cue settings, replace defaults with cue specific settings if they exist
2696
- compositeCueSettings =
2697
- cueSettings
2698
- .split(/\s+/g)
2699
- .filter(function(set) { return set && !!set.length; })
2700
- // Convert array to a key/val object
2701
- .reduce(function(previous,current,index,array){
2702
- previous[current.split(":")[0]] = current.split(":")[1];
2703
- return previous;
2704
- },compositeCueSettings);
2705
-
2706
- // Turn back into string like the TextTrackCue constructor expects
2707
- cueSettings = "";
2708
- for (var key in compositeCueSettings) {
2709
- if (compositeCueSettings.hasOwnProperty(key)) {
2710
- cueSettings += !!cueSettings.length ? " " : "";
2711
- cueSettings += key + ":" + compositeCueSettings[key];
2712
- }
2713
- }
2714
- */
2715
- // The remaining lines are the subtitle payload itself (after removing an ID if present, and the time);
2716
- html = subtitleParts.join("\n");
2717
- tmpCue = new TextTrackCue(timeIn, timeOut, html);
2718
- if(id){
2719
- tmpCue.id = id;
2720
- }
2721
- return tmpCue;
2722
- };
2723
- })();
2724
-
2725
- mediaelement.parseCaptions = function(captionData, track, complete) {
2726
- var subtitles = mediaelement.createCueList();
2727
- var cue, lazyProcess, regWevVTT;
2728
- var startDate;
2729
- var isWEBVTT;
2730
- if (captionData) {
2731
-
2732
- regWevVTT = /^WEBVTT(\s*FILE)?/ig;
2733
-
2734
- lazyProcess = function(i, len){
2735
-
2736
- for(; i < len; i++){
2737
- cue = captionData[i];
2738
- if(regWevVTT.test(cue)){
2739
- isWEBVTT = true;
2740
- } else if(cue.replace(/\s*/ig,"").length){
2741
- if(!isWEBVTT){
2742
- webshims.error('please use WebVTT format. This is the standard');
2743
- complete(null);
2744
- break;
2745
- }
2746
- cue = mediaelement.parseCaptionChunk(cue, i);
2747
- if(cue){
2748
- track.addCue(cue);
2749
- }
2750
- }
2751
- if(startDate < (new Date().getTime()) - 30){
2752
- i++;
2753
- setTimeout(function(){
2754
- startDate = new Date().getTime();
2755
- lazyProcess(i, len);
2756
- }, 90);
2757
-
2758
- break;
2759
- }
2760
- }
2761
- if(i >= len){
2762
- if(!isWEBVTT){
2763
- webshims.error('please use WebVTT format. This is the standard');
2764
- }
2765
- complete(track.cues);
2766
- }
2767
- };
2768
-
2769
- captionData = captionData.replace(/\r\n/g,"\n");
2770
-
2771
- setTimeout(function(){
2772
- captionData = captionData.replace(/\r/g,"\n");
2773
- setTimeout(function(){
2774
- startDate = new Date().getTime();
2775
- captionData = captionData.split(/\n\n+/g);
2776
- lazyProcess(0, captionData.length);
2777
- }, 9);
2778
- }, 9);
2779
-
2780
- } else {
2781
- webshims.error("Required parameter captionData not supplied.");
2782
- }
2783
- };
2784
-
2785
-
2786
- mediaelement.createTrackList = function(mediaelem, baseData){
2787
- baseData = baseData || webshims.data(mediaelem, 'mediaelementBase') || webshims.data(mediaelem, 'mediaelementBase', {});
2788
- if(!baseData.textTracks){
2789
- baseData.textTracks = [];
2790
- webshims.defineProperties(baseData.textTracks, {
2791
- onaddtrack: {value: null},
2792
- onremovetrack: {value: null}
2793
- });
2794
- createEventTarget(baseData.textTracks);
2795
- }
2796
- return baseData.textTracks;
2797
- };
2798
-
2799
- if(!Modernizr.track){
2800
- webshims.defineNodeNamesBooleanProperty(['track'], 'default');
2801
- webshims.reflectProperties(['track'], ['srclang', 'label']);
2802
-
2803
- webshims.defineNodeNameProperties('track', {
2804
- src: {
2805
- //attr: {},
2806
- reflect: true,
2807
- propType: 'src'
2808
- }
2809
- });
2810
- }
2811
-
2812
- webshims.defineNodeNameProperties('track', {
2813
- kind: {
2814
- attr: Modernizr.track ? {
2815
- set: function(value){
2816
- var trackData = webshims.data(this, 'trackData');
2817
- this.setAttribute('data-kind', value);
2818
- if(trackData){
2819
- trackData.attrKind = value;
2820
- }
2821
- },
2822
- get: function(){
2823
- var trackData = webshims.data(this, 'trackData');
2824
- if(trackData && ('attrKind' in trackData)){
2825
- return trackData.attrKind;
2826
- }
2827
- return this.getAttribute('kind');
2828
- }
2829
- } : {},
2830
- reflect: true,
2831
- propType: 'enumarated',
2832
- defaultValue: 'subtitles',
2833
- limitedTo: ['subtitles', 'captions', 'descriptions', 'chapters', 'metadata']
2834
- }
2835
- });
2836
-
2837
- $.each(copyProps, function(i, copyProp){
2838
- var name = copyName[copyProp] || copyProp;
2839
- webshims.onNodeNamesPropertyModify('track', copyProp, function(){
2840
- var trackData = webshims.data(this, 'trackData');
2841
- var track = this;
2842
- if(trackData){
2843
- if(copyProp == 'kind'){
2844
- refreshTrack(this, trackData);
2845
- }
2846
- if(!supportTrackMod){
2847
- trackData.track[name] = $.prop(this, copyProp);
2848
- }
2849
- clearTimeout(trackData.changedTrackPropTimer);
2850
- trackData.changedTrackPropTimer = setTimeout(function(){
2851
- $(track).trigger('updatesubtitlestate');
2852
- }, 1);
2853
- }
2854
- });
2855
- });
2856
-
2857
-
2858
- webshims.onNodeNamesPropertyModify('track', 'src', function(val){
2859
- if(val){
2860
- var data = webshims.data(this, 'trackData');
2861
- var media;
2862
- if(data){
2863
- media = $(this).closest('video, audio');
2864
- if(media[0]){
2865
- mediaelement.loadTextTrack(media, this, data);
2866
- }
2867
- }
2868
- }
2869
-
2870
- });
2871
-
2872
- //
2873
-
2874
- webshims.defineNodeNamesProperties(['track'], {
2875
- ERROR: {
2876
- value: 3
2877
- },
2878
- LOADED: {
2879
- value: 2
2880
- },
2881
- LOADING: {
2882
- value: 1
2883
- },
2884
- NONE: {
2885
- value: 0
2886
- },
2887
- readyState: {
2888
- get: function(){
2889
- return ($.prop(this, 'track') || {readyState: 0}).readyState;
2890
- },
2891
- writeable: false
2892
- },
2893
- track: {
2894
- get: function(){
2895
- return mediaelement.createTextTrack($(this).closest('audio, video')[0], this);
2896
- },
2897
- writeable: false
2898
- }
2899
- }, 'prop');
2900
-
2901
- webshims.defineNodeNamesProperties(['audio', 'video'], {
2902
- textTracks: {
2903
- get: function(){
2904
- var media = this;
2905
- var baseData = webshims.data(media, 'mediaelementBase') || webshims.data(media, 'mediaelementBase', {});
2906
- var tracks = mediaelement.createTrackList(media, baseData);
2907
- if(!baseData.blockTrackListUpdate){
2908
- updateMediaTrackList.call(media, baseData, tracks);
2909
- }
2910
- return tracks;
2911
- },
2912
- writeable: false
2913
- },
2914
- addTextTrack: {
2915
- value: function(kind, label, lang){
2916
- var textTrack = mediaelement.createTextTrack(this, {
2917
- kind: dummyTrack.prop('kind', kind || '').prop('kind'),
2918
- label: label || '',
2919
- srclang: lang || ''
2920
- });
2921
- var baseData = webshims.data(this, 'mediaelementBase') || webshims.data(this, 'mediaelementBase', {});
2922
- if (!baseData.scriptedTextTracks) {
2923
- baseData.scriptedTextTracks = [];
2924
- }
2925
- baseData.scriptedTextTracks.push(textTrack);
2926
- updateMediaTrackList.call(this);
2927
- return textTrack;
2928
- }
2929
- }
2930
- }, 'prop');
2931
-
2932
-
2933
- $(document).on('emptied ended updatetracklist', function(e){
2934
- if($(e.target).is('audio, video')){
2935
- var baseData = webshims.data(e.target, 'mediaelementBase');
2936
- if(baseData){
2937
- clearTimeout(baseData.updateTrackListTimer);
2938
- baseData.updateTrackListTimer = setTimeout(function(){
2939
- updateMediaTrackList.call(e.target, baseData);
2940
- }, 0);
2941
- }
2942
- }
2943
- });
2944
-
2945
- var getNativeReadyState = function(trackElem, textTrack){
2946
- return textTrack.readyState || trackElem.readyState;
2947
- };
2948
-
2949
- webshims.addReady(function(context, insertedElement){
2950
- var insertedMedia = insertedElement.filter('video, audio, track').closest('audio, video');
2951
- $('video, audio', context)
2952
- .add(insertedMedia)
2953
- .each(function(){
2954
- updateMediaTrackList.call(this);
2955
- })
2956
- .each(function(){
2957
- if(Modernizr.track){
2958
- var shimedTextTracks = $.prop(this, 'textTracks');
2959
- var origTextTracks = this.textTracks;
2960
- if(shimedTextTracks.length != origTextTracks.length){
2961
- webshims.error("textTracks couldn't be copied");
2962
- }
2963
-
2964
- $('track', this)
2965
- .each(function(){
2966
- var shimedTrack = $.prop(this, 'track');
2967
- var origTrack = this.track;
2968
- var kind;
2969
- var readyState;
2970
- if(origTrack){
2971
- kind = $.prop(this, 'kind');
2972
- readyState = getNativeReadyState(this, origTrack);
2973
- if (origTrack.mode || readyState) {
2974
- shimedTrack.mode = numericModes[origTrack.mode] || origTrack.mode;
2975
- }
2976
- //disable track from showing + remove UI
2977
- if(kind != 'descriptions'){
2978
- origTrack.mode = (typeof origTrack.mode == 'string') ? 'disabled' : 0;
2979
- this.kind = 'metadata';
2980
- $(this).attr({kind: kind});
2981
- }
2982
-
2983
- }
2984
- })
2985
- .on('load error', function(e){
2986
- if(e.originalEvent){
2987
- e.stopImmediatePropagation();
2988
- }
2989
- })
2990
- ;
2991
- }
2992
- })
2993
- ;
2994
- insertedMedia.each(function(){
2995
- var media = this;
2996
- var baseData = webshims.data(media, 'mediaelementBase');
2997
- if(baseData){
2998
- clearTimeout(baseData.updateTrackListTimer);
2999
- baseData.updateTrackListTimer = setTimeout(function(){
3000
- updateMediaTrackList.call(media, baseData);
3001
- }, 9);
3002
- }
3003
- });
3004
- });
3005
-
3006
- if(Modernizr.track){
3007
- $('video, audio').trigger('trackapichange');
3008
- }
3009
- });