webshims-rails 1.13.0 → 1.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/extras/modernizr-custom.js +0 -0
  4. data/vendor/assets/javascripts/webshims/polyfiller.js +45 -26
  5. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/canvas2png.js +0 -0
  6. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/flashcanvas.js +0 -0
  7. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/flashcanvas.swf +0 -0
  8. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/proxy.php +0 -0
  9. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/save.php +0 -0
  10. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/canvas2png.js +0 -0
  11. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flash10canvas.swf +0 -0
  12. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flash9canvas.swf +0 -0
  13. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/flashcanvas.js +0 -0
  14. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/proxy.php +0 -0
  15. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/save.php +0 -0
  16. data/vendor/assets/javascripts/webshims/shims/color-picker.js +0 -0
  17. data/vendor/assets/javascripts/webshims/shims/combos/1.js +33 -2
  18. data/vendor/assets/javascripts/webshims/shims/combos/10.js +82 -29
  19. data/vendor/assets/javascripts/webshims/shims/combos/11.js +50 -27
  20. data/vendor/assets/javascripts/webshims/shims/combos/12.js +0 -0
  21. data/vendor/assets/javascripts/webshims/shims/combos/13.js +0 -0
  22. data/vendor/assets/javascripts/webshims/shims/combos/14.js +1 -1
  23. data/vendor/assets/javascripts/webshims/shims/combos/15.js +115 -43
  24. data/vendor/assets/javascripts/webshims/shims/combos/16.js +115 -43
  25. data/vendor/assets/javascripts/webshims/shims/combos/17.js +50 -27
  26. data/vendor/assets/javascripts/webshims/shims/combos/18.js +50 -27
  27. data/vendor/assets/javascripts/webshims/shims/combos/19.js +33 -3
  28. data/vendor/assets/javascripts/webshims/shims/combos/2.js +65 -4
  29. data/vendor/assets/javascripts/webshims/shims/combos/20.js +33 -3
  30. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1 -1
  31. data/vendor/assets/javascripts/webshims/shims/combos/22.js +0 -0
  32. data/vendor/assets/javascripts/webshims/shims/combos/23.js +0 -0
  33. data/vendor/assets/javascripts/webshims/shims/combos/25.js +492 -2580
  34. data/vendor/assets/javascripts/webshims/shims/combos/26.js +8314 -1432
  35. data/vendor/assets/javascripts/webshims/shims/combos/27.js +1642 -556
  36. data/vendor/assets/javascripts/webshims/shims/combos/28.js +50 -39
  37. data/vendor/assets/javascripts/webshims/shims/combos/29.js +0 -0
  38. data/vendor/assets/javascripts/webshims/shims/combos/3.js +66 -5
  39. data/vendor/assets/javascripts/webshims/shims/combos/30.js +66 -5
  40. data/vendor/assets/javascripts/webshims/shims/combos/31.js +65 -4
  41. data/vendor/assets/javascripts/webshims/shims/combos/32.js +0 -0
  42. data/vendor/assets/javascripts/webshims/shims/combos/33.js +0 -0
  43. data/vendor/assets/javascripts/webshims/shims/combos/34.js +32 -2
  44. data/vendor/assets/javascripts/webshims/shims/combos/4.js +33 -3
  45. data/vendor/assets/javascripts/webshims/shims/combos/5.js +50 -27
  46. data/vendor/assets/javascripts/webshims/shims/combos/6.js +50 -27
  47. data/vendor/assets/javascripts/webshims/shims/combos/7.js +66 -5
  48. data/vendor/assets/javascripts/webshims/shims/combos/8.js +66 -5
  49. data/vendor/assets/javascripts/webshims/shims/combos/9.js +82 -29
  50. data/vendor/assets/javascripts/webshims/shims/combos/97.js +0 -0
  51. data/vendor/assets/javascripts/webshims/shims/combos/98.js +1 -2
  52. data/vendor/assets/javascripts/webshims/shims/combos/99.js +1 -2
  53. data/vendor/assets/javascripts/webshims/shims/combos/comboinfo.json +1 -0
  54. data/vendor/assets/javascripts/webshims/shims/details.js +0 -0
  55. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +32 -2
  56. data/vendor/assets/javascripts/webshims/shims/es5.js +0 -0
  57. data/vendor/assets/javascripts/webshims/shims/excanvas.js +0 -0
  58. data/vendor/assets/javascripts/webshims/shims/filereader.js +441 -362
  59. data/vendor/assets/javascripts/webshims/shims/form-combat.js +19 -7
  60. data/vendor/assets/javascripts/webshims/shims/form-core.js +33 -2
  61. data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +0 -0
  62. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +0 -0
  63. data/vendor/assets/javascripts/webshims/shims/form-fixrangechange.js +0 -0
  64. data/vendor/assets/javascripts/webshims/shims/form-message.js +1 -1
  65. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +0 -0
  66. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +0 -0
  67. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +50 -27
  68. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +49 -38
  69. data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +45 -14
  70. data/vendor/assets/javascripts/webshims/shims/form-validation.js +105 -7
  71. data/vendor/assets/javascripts/webshims/shims/form-validators.js +212 -134
  72. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +15 -12
  73. data/vendor/assets/javascripts/webshims/shims/geolocation.js +0 -0
  74. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ar.js +0 -0
  75. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ch-CN.js +0 -0
  76. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-cs.js +0 -0
  77. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-de.js +0 -0
  78. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-el.js +0 -0
  79. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-en.js +0 -0
  80. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-es.js +0 -0
  81. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-fr.js +0 -0
  82. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-he.js +0 -0
  83. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-hi.js +0 -0
  84. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-hu.js +0 -0
  85. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-it.js +0 -0
  86. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ja.js +0 -0
  87. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-lt.js +0 -0
  88. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-nl.js +0 -0
  89. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pl.js +0 -0
  90. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pt-BR.js +0 -0
  91. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pt-PT.js +0 -0
  92. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pt.js +0 -0
  93. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ru.js +0 -0
  94. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-sv.js +0 -0
  95. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-zh-CN.js +0 -0
  96. data/vendor/assets/javascripts/webshims/shims/jajax.js +0 -0
  97. data/vendor/assets/javascripts/webshims/shims/jme/b.js +0 -0
  98. data/vendor/assets/javascripts/webshims/shims/jme/c.js +1 -2
  99. data/vendor/assets/javascripts/webshims/shims/jme/controls.css +0 -0
  100. data/vendor/assets/javascripts/webshims/shims/jme/controls.scss +0 -0
  101. data/vendor/assets/javascripts/webshims/shims/jme/mediacontrols-lazy.js +3 -3
  102. data/vendor/assets/javascripts/webshims/shims/jme/p.js +0 -0
  103. data/vendor/assets/javascripts/webshims/shims/jpicker/ChangeLog.txt +0 -0
  104. data/vendor/assets/javascripts/webshims/shims/jpicker/ReadMe.txt +0 -0
  105. data/vendor/assets/javascripts/webshims/shims/jpicker/images/AlphaBar.png +0 -0
  106. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Bars.png +0 -0
  107. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Maps.png +0 -0
  108. data/vendor/assets/javascripts/webshims/shims/jpicker/images/NoColor.png +0 -0
  109. data/vendor/assets/javascripts/webshims/shims/jpicker/images/bar-opacity.png +0 -0
  110. data/vendor/assets/javascripts/webshims/shims/jpicker/images/map-opacity.png +0 -0
  111. data/vendor/assets/javascripts/webshims/shims/jpicker/images/mappoint.gif +0 -0
  112. data/vendor/assets/javascripts/webshims/shims/jpicker/images/picker.gif +0 -0
  113. data/vendor/assets/javascripts/webshims/shims/jpicker/images/preview-opacity.png +0 -0
  114. data/vendor/assets/javascripts/webshims/shims/jpicker/images/rangearrows.gif +0 -0
  115. data/vendor/assets/javascripts/webshims/shims/jpicker/jpicker.css +0 -0
  116. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +0 -0
  117. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +1 -1
  118. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +0 -0
  119. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +1 -1
  120. data/vendor/assets/javascripts/webshims/shims/moxie/flash/Moxie.cdn.swf +0 -0
  121. data/vendor/assets/javascripts/webshims/shims/moxie/js/moxie.js +7994 -0
  122. data/vendor/assets/javascripts/webshims/shims/moxie/silverlight/Moxie.cdn.xap +0 -0
  123. data/vendor/assets/javascripts/webshims/shims/picture.js +50 -43
  124. data/vendor/assets/javascripts/webshims/shims/plugins/jquery.ui.position.js +0 -0
  125. data/vendor/assets/javascripts/webshims/shims/promise.js +0 -0
  126. data/vendor/assets/javascripts/webshims/shims/range-ui.js +0 -0
  127. data/vendor/assets/javascripts/webshims/shims/sizzle.js +0 -0
  128. data/vendor/assets/javascripts/webshims/shims/styles/color-picker.png +0 -0
  129. data/vendor/assets/javascripts/webshims/shims/styles/config.rb +0 -0
  130. data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +7 -2
  131. data/vendor/assets/javascripts/webshims/shims/styles/forms-picker.css +0 -0
  132. data/vendor/assets/javascripts/webshims/shims/styles/progress.gif +0 -0
  133. data/vendor/assets/javascripts/webshims/shims/styles/progress.png +0 -0
  134. data/vendor/assets/javascripts/webshims/shims/styles/scss/_api-forms-ext.scss +219 -0
  135. data/vendor/assets/javascripts/webshims/shims/styles/scss/_api-shim.scss +115 -0
  136. data/vendor/assets/javascripts/webshims/shims/styles/scss/_extends.scss +31 -0
  137. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +583 -0
  138. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-picker.scss +488 -0
  139. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim-ext.scss +2 -0
  140. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +736 -0
  141. data/vendor/assets/javascripts/webshims/shims/styles/shim-ext.css +105 -21
  142. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +91 -19
  143. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  144. data/vendor/assets/javascripts/webshims/shims/swf/filereader.swf +0 -0
  145. data/vendor/assets/javascripts/webshims/shims/swfmini-embed.js +0 -0
  146. data/vendor/assets/javascripts/webshims/shims/swfmini.js +0 -0
  147. data/vendor/assets/javascripts/webshims/shims/track-ui.js +1 -1
  148. data/vendor/assets/javascripts/webshims/shims/track.js +0 -0
  149. metadata +13 -2
@@ -1,1676 +1,4 @@
1
- /*! SWFMini - a SWFObject 2.2 cut down version for webshims
2
- *
3
- * based on SWFObject v2.2 <http://code.google.com/p/swfobject/>
4
- is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
5
- */
6
1
 
7
- var swfmini = function() {
8
- var wasRemoved = function(){webshims.error('This method was removed from swfmini');};
9
- var UNDEF = "undefined",
10
- OBJECT = "object",
11
- webshims = window.webshims,
12
- SHOCKWAVE_FLASH = "Shockwave Flash",
13
- SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
14
- FLASH_MIME_TYPE = "application/x-shockwave-flash",
15
-
16
- win = window,
17
- doc = document,
18
- nav = navigator,
19
-
20
- plugin = false,
21
- domLoadFnArr = [main],
22
-
23
- isDomLoaded = false,
24
- autoHideShow = true,
25
-
26
- /* Centralized function for browser feature detection
27
- - User agent string detection is only used when no good alternative is possible
28
- - Is executed directly for optimal performance
29
- */
30
- ua = function() {
31
- var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
32
- u = nav.userAgent.toLowerCase(),
33
- p = nav.platform.toLowerCase(),
34
- windows = p ? /win/.test(p) : /win/.test(u),
35
- mac = p ? /mac/.test(p) : /mac/.test(u),
36
- webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
37
- ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
38
- playerVersion = [0,0,0],
39
- d = null;
40
- if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
41
- d = nav.plugins[SHOCKWAVE_FLASH].description;
42
- if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
43
- plugin = true;
44
- ie = false; // cascaded feature detection for Internet Explorer
45
- d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
46
- playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
47
- playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
48
- playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
49
- }
50
- }
51
- else if (typeof win.ActiveXObject != UNDEF) {
52
- try {
53
- var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
54
- if (a) { // a will return null when ActiveX is disabled
55
- d = a.GetVariable("$version");
56
- if (d) {
57
- ie = true; // cascaded feature detection for Internet Explorer
58
- d = d.split(" ")[1].split(",");
59
- playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
60
- }
61
- }
62
- }
63
- catch(e) {}
64
- }
65
- return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
66
- }();
67
-
68
-
69
- function callDomLoadFunctions() {
70
- if (isDomLoaded) { return; }
71
- isDomLoaded = true;
72
- var dl = domLoadFnArr.length;
73
- for (var i = 0; i < dl; i++) {
74
- domLoadFnArr[i]();
75
- }
76
- }
77
-
78
- function addDomLoadEvent(fn) {
79
- if (isDomLoaded) {
80
- fn();
81
- }
82
- else {
83
- domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
84
- }
85
- }
86
-
87
-
88
- /* Main function
89
- - Will preferably execute onDomLoad, otherwise onload (as a fallback)
90
- */
91
- function main() {
92
- if (plugin) {
93
- testPlayerVersion();
94
- }
95
- }
96
-
97
- /* Detect the Flash Player version for non-Internet Explorer browsers
98
- - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
99
- a. Both release and build numbers can be detected
100
- b. Avoid wrong descriptions by corrupt installers provided by Adobe
101
- c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
102
- - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
103
- */
104
- function testPlayerVersion() {
105
- var b = doc.getElementsByTagName("body")[0];
106
- var o = createElement(OBJECT);
107
- o.setAttribute("type", FLASH_MIME_TYPE);
108
- var t = b.appendChild(o);
109
- if (t) {
110
- var counter = 0;
111
- (function(){
112
- if (typeof t.GetVariable != UNDEF) {
113
- var d = t.GetVariable("$version");
114
- if (d) {
115
- d = d.split(" ")[1].split(",");
116
- ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
117
- }
118
- }
119
- else if (counter < 10) {
120
- counter++;
121
- setTimeout(arguments.callee, 10);
122
- return;
123
- }
124
- b.removeChild(o);
125
- t = null;
126
- })();
127
- }
128
- }
129
-
130
-
131
- function createElement(el) {
132
- return doc.createElement(el);
133
- }
134
-
135
-
136
- /* Flash Player and SWF content version matching
137
- */
138
- function hasPlayerVersion(rv) {
139
- var pv = ua.pv, v = rv.split(".");
140
- v[0] = parseInt(v[0], 10);
141
- v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
142
- v[2] = parseInt(v[2], 10) || 0;
143
- return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
144
- }
145
-
146
-
147
-
148
-
149
-
150
- webshims.ready('DOM', callDomLoadFunctions);
151
-
152
- webshims.loader.addModule('swfmini-embed', {d: ['swfmini']});
153
- var loadEmbed = hasPlayerVersion('9.0.0') ?
154
- function(){
155
- webshims.loader.loadList(['swfmini-embed']);
156
- return true;
157
- } :
158
- webshims.$.noop
159
- ;
160
-
161
- if(!Modernizr.video){
162
- loadEmbed();
163
- } else {
164
- webshims.ready('WINDOWLOAD', loadEmbed);
165
- }
166
-
167
- return {
168
- /* Public API
169
- - Reference: http://code.google.com/p/swfobject/wiki/documentation
170
- */
171
- registerObject: wasRemoved,
172
-
173
- getObjectById: wasRemoved,
174
-
175
- embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
176
- var args = arguments;
177
- if(loadEmbed()){
178
- webshims.ready('swfmini-embed', function(){
179
- swfmini.embedSWF.apply(swfmini, args);
180
- });
181
- } else if(callbackFn) {
182
- callbackFn({success:false, id:replaceElemIdStr});
183
- }
184
- },
185
-
186
- switchOffAutoHideShow: function() {
187
- autoHideShow = false;
188
- },
189
-
190
- ua: ua,
191
-
192
- getFlashPlayerVersion: function() {
193
- return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
194
- },
195
-
196
- hasFlashPlayerVersion: hasPlayerVersion,
197
-
198
- createSWF: function(attObj, parObj, replaceElemIdStr) {
199
- if (ua.w3) {
200
- return createSWF(attObj, parObj, replaceElemIdStr);
201
- }
202
- else {
203
- return undefined;
204
- }
205
- },
206
-
207
- showExpressInstall: wasRemoved,
208
-
209
- removeSWF: wasRemoved,
210
-
211
- createCSS: wasRemoved,
212
-
213
- addDomLoadEvent: addDomLoadEvent,
214
-
215
- addLoadEvent: wasRemoved,
216
-
217
-
218
- // For internal usage only
219
- expressInstallCallback: wasRemoved
220
- };
221
- }();
222
-
223
- webshims.isReady('swfmini', true);
224
- ;// Copyright 2009-2012 by contributors, MIT License
225
- // vim: ts=4 sts=4 sw=4 expandtab
226
-
227
- (function () {
228
- setTimeout(function(){
229
- webshims.isReady('es5', true);
230
- });
231
- /**
232
- * Brings an environment as close to ECMAScript 5 compliance
233
- * as is possible with the facilities of erstwhile engines.
234
- *
235
- * Annotated ES5: http://es5.github.com/ (specific links below)
236
- * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
237
- * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
238
- */
239
-
240
- //
241
- // Function
242
- // ========
243
- //
244
-
245
- // ES-5 15.3.4.5
246
- // http://es5.github.com/#x15.3.4.5
247
-
248
- function Empty() {}
249
-
250
- if (!Function.prototype.bind) {
251
- Function.prototype.bind = function bind(that) { // .length is 1
252
- // 1. Let Target be the this value.
253
- var target = this;
254
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
255
- if (typeof target != "function") {
256
- throw new TypeError("Function.prototype.bind called on incompatible " + target);
257
- }
258
- // 3. Let A be a new (possibly empty) internal list of all of the
259
- // argument values provided after thisArg (arg1, arg2 etc), in order.
260
- // XXX slicedArgs will stand in for "A" if used
261
- var args = _Array_slice_.call(arguments, 1); // for normal call
262
- // 4. Let F be a new native ECMAScript object.
263
- // 11. Set the [[Prototype]] internal property of F to the standard
264
- // built-in Function prototype object as specified in 15.3.3.1.
265
- // 12. Set the [[Call]] internal property of F as described in
266
- // 15.3.4.5.1.
267
- // 13. Set the [[Construct]] internal property of F as described in
268
- // 15.3.4.5.2.
269
- // 14. Set the [[HasInstance]] internal property of F as described in
270
- // 15.3.4.5.3.
271
- var bound = function () {
272
-
273
- if (this instanceof bound) {
274
- // 15.3.4.5.2 [[Construct]]
275
- // When the [[Construct]] internal method of a function object,
276
- // F that was created using the bind function is called with a
277
- // list of arguments ExtraArgs, the following steps are taken:
278
- // 1. Let target be the value of F's [[TargetFunction]]
279
- // internal property.
280
- // 2. If target has no [[Construct]] internal method, a
281
- // TypeError exception is thrown.
282
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
283
- // property.
284
- // 4. Let args be a new list containing the same values as the
285
- // list boundArgs in the same order followed by the same
286
- // values as the list ExtraArgs in the same order.
287
- // 5. Return the result of calling the [[Construct]] internal
288
- // method of target providing args as the arguments.
289
-
290
- var result = target.apply(
291
- this,
292
- args.concat(_Array_slice_.call(arguments))
293
- );
294
- if (Object(result) === result) {
295
- return result;
296
- }
297
- return this;
298
-
299
- } else {
300
- // 15.3.4.5.1 [[Call]]
301
- // When the [[Call]] internal method of a function object, F,
302
- // which was created using the bind function is called with a
303
- // this value and a list of arguments ExtraArgs, the following
304
- // steps are taken:
305
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
306
- // property.
307
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
308
- // property.
309
- // 3. Let target be the value of F's [[TargetFunction]] internal
310
- // property.
311
- // 4. Let args be a new list containing the same values as the
312
- // list boundArgs in the same order followed by the same
313
- // values as the list ExtraArgs in the same order.
314
- // 5. Return the result of calling the [[Call]] internal method
315
- // of target providing boundThis as the this value and
316
- // providing args as the arguments.
317
-
318
- // equiv: target.call(this, ...boundArgs, ...args)
319
- return target.apply(
320
- that,
321
- args.concat(_Array_slice_.call(arguments))
322
- );
323
-
324
- }
325
-
326
- };
327
- if(target.prototype) {
328
- Empty.prototype = target.prototype;
329
- bound.prototype = new Empty();
330
- // Clean up dangling references.
331
- Empty.prototype = null;
332
- }
333
- // XXX bound.length is never writable, so don't even try
334
- //
335
- // 15. If the [[Class]] internal property of Target is "Function", then
336
- // a. Let L be the length property of Target minus the length of A.
337
- // b. Set the length own property of F to either 0 or L, whichever is
338
- // larger.
339
- // 16. Else set the length own property of F to 0.
340
- // 17. Set the attributes of the length own property of F to the values
341
- // specified in 15.3.5.1.
342
-
343
- // TODO
344
- // 18. Set the [[Extensible]] internal property of F to true.
345
-
346
- // TODO
347
- // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
348
- // 20. Call the [[DefineOwnProperty]] internal method of F with
349
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
350
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
351
- // false.
352
- // 21. Call the [[DefineOwnProperty]] internal method of F with
353
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
354
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
355
- // and false.
356
-
357
- // TODO
358
- // NOTE Function objects created using Function.prototype.bind do not
359
- // have a prototype property or the [[Code]], [[FormalParameters]], and
360
- // [[Scope]] internal properties.
361
- // XXX can't delete prototype in pure-js.
362
-
363
- // 22. Return F.
364
- return bound;
365
- };
366
- }
367
-
368
- // Shortcut to an often accessed properties, in order to avoid multiple
369
- // dereference that costs universally.
370
- // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
371
- // us it in defining shortcuts.
372
- var call = Function.prototype.call;
373
- var prototypeOfArray = Array.prototype;
374
- var prototypeOfObject = Object.prototype;
375
- var _Array_slice_ = prototypeOfArray.slice;
376
- // Having a toString local variable name breaks in Opera so use _toString.
377
- var _toString = call.bind(prototypeOfObject.toString);
378
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
379
-
380
- // If JS engine supports accessors creating shortcuts.
381
- var defineGetter;
382
- var defineSetter;
383
- var lookupGetter;
384
- var lookupSetter;
385
- var supportsAccessors;
386
- if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
387
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
388
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
389
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
390
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
391
- }
392
-
393
- //
394
- // Array
395
- // =====
396
- //
397
-
398
- // ES5 15.4.4.12
399
- // http://es5.github.com/#x15.4.4.12
400
- // Default value for second param
401
- // [bugfix, ielt9, old browsers]
402
- // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
403
- if ([1,2].splice(0).length != 2) {
404
- var array_splice = Array.prototype.splice;
405
-
406
- if(function() { // test IE < 9 to splice bug - see issue #138
407
- function makeArray(l) {
408
- var a = [];
409
- while (l--) {
410
- a.unshift(l)
411
- }
412
- return a
413
- }
414
-
415
- var array = []
416
- , lengthBefore
417
- ;
418
-
419
- array.splice.bind(array, 0, 0).apply(null, makeArray(20));
420
- array.splice.bind(array, 0, 0).apply(null, makeArray(26));
421
-
422
- lengthBefore = array.length; //20
423
- array.splice(5, 0, "XXX"); // add one element
424
-
425
- if(lengthBefore + 1 == array.length) {
426
- return true;// has right splice implementation without bugs
427
- }
428
- // else {
429
- // IE8 bug
430
- // }
431
- }()) {//IE 6/7
432
- Array.prototype.splice = function(start, deleteCount) {
433
- if (!arguments.length) {
434
- return [];
435
- } else {
436
- return array_splice.apply(this, [
437
- start === void 0 ? 0 : start,
438
- deleteCount === void 0 ? (this.length - start) : deleteCount
439
- ].concat(_Array_slice_.call(arguments, 2)))
440
- }
441
- };
442
- }
443
- else {//IE8
444
- Array.prototype.splice = function(start, deleteCount) {
445
- var result
446
- , args = _Array_slice_.call(arguments, 2)
447
- , addElementsCount = args.length
448
- ;
449
-
450
- if(!arguments.length) {
451
- return [];
452
- }
453
-
454
- if(start === void 0) { // default
455
- start = 0;
456
- }
457
- if(deleteCount === void 0) { // default
458
- deleteCount = this.length - start;
459
- }
460
-
461
- if(addElementsCount > 0) {
462
- if(deleteCount <= 0) {
463
- if(start == this.length) { // tiny optimisation #1
464
- this.push.apply(this, args);
465
- return [];
466
- }
467
-
468
- if(start == 0) { // tiny optimisation #2
469
- this.unshift.apply(this, args);
470
- return [];
471
- }
472
- }
473
-
474
- // Array.prototype.splice implementation
475
- result = _Array_slice_.call(this, start, start + deleteCount);// delete part
476
- args.push.apply(args, _Array_slice_.call(this, start + deleteCount, this.length));// right part
477
- args.unshift.apply(args, _Array_slice_.call(this, 0, start));// left part
478
-
479
- // delete all items from this array and replace it to 'left part' + _Array_slice_.call(arguments, 2) + 'right part'
480
- args.unshift(0, this.length);
481
-
482
- array_splice.apply(this, args);
483
-
484
- return result;
485
- }
486
-
487
- return array_splice.call(this, start, deleteCount);
488
- }
489
-
490
- }
491
- }
492
-
493
- // ES5 15.4.4.12
494
- // http://es5.github.com/#x15.4.4.13
495
- // Return len+argCount.
496
- // [bugfix, ielt8]
497
- // IE < 8 bug: [].unshift(0) == undefined but should be "1"
498
- if ([].unshift(0) != 1) {
499
- var array_unshift = Array.prototype.unshift;
500
- Array.prototype.unshift = function() {
501
- array_unshift.apply(this, arguments);
502
- return this.length;
503
- };
504
- }
505
-
506
- // ES5 15.4.3.2
507
- // http://es5.github.com/#x15.4.3.2
508
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
509
- if (!Array.isArray) {
510
- Array.isArray = function isArray(obj) {
511
- return _toString(obj) == "[object Array]";
512
- };
513
- }
514
-
515
- // The IsCallable() check in the Array functions
516
- // has been replaced with a strict check on the
517
- // internal class of the object to trap cases where
518
- // the provided function was actually a regular
519
- // expression literal, which in V8 and
520
- // JavaScriptCore is a typeof "function". Only in
521
- // V8 are regular expression literals permitted as
522
- // reduce parameters, so it is desirable in the
523
- // general case for the shim to match the more
524
- // strict and common behavior of rejecting regular
525
- // expressions.
526
-
527
- // ES5 15.4.4.18
528
- // http://es5.github.com/#x15.4.4.18
529
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
530
-
531
- // Check failure of by-index access of string characters (IE < 9)
532
- // and failure of `0 in boxedString` (Rhino)
533
- var boxedString = Object("a"),
534
- splitString = boxedString[0] != "a" || !(0 in boxedString);
535
-
536
- if (!Array.prototype.forEach) {
537
- Array.prototype.forEach = function forEach(fun /*, thisp*/) {
538
- var object = toObject(this),
539
- self = splitString && _toString(this) == "[object String]" ?
540
- this.split("") :
541
- object,
542
- thisp = arguments[1],
543
- i = -1,
544
- length = self.length >>> 0;
545
-
546
- // If no callback function or if callback is not a callable function
547
- if (_toString(fun) != "[object Function]") {
548
- throw new TypeError(); // TODO message
549
- }
550
-
551
- while (++i < length) {
552
- if (i in self) {
553
- // Invoke the callback function with call, passing arguments:
554
- // context, property value, property key, thisArg object
555
- // context
556
- fun.call(thisp, self[i], i, object);
557
- }
558
- }
559
- };
560
- }
561
-
562
- // ES5 15.4.4.19
563
- // http://es5.github.com/#x15.4.4.19
564
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
565
- if (!Array.prototype.map) {
566
- Array.prototype.map = function map(fun /*, thisp*/) {
567
- var object = toObject(this),
568
- self = splitString && _toString(this) == "[object String]" ?
569
- this.split("") :
570
- object,
571
- length = self.length >>> 0,
572
- result = Array(length),
573
- thisp = arguments[1];
574
-
575
- // If no callback function or if callback is not a callable function
576
- if (_toString(fun) != "[object Function]") {
577
- throw new TypeError(fun + " is not a function");
578
- }
579
-
580
- for (var i = 0; i < length; i++) {
581
- if (i in self)
582
- result[i] = fun.call(thisp, self[i], i, object);
583
- }
584
- return result;
585
- };
586
- }
587
-
588
- // ES5 15.4.4.20
589
- // http://es5.github.com/#x15.4.4.20
590
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
591
- if (!Array.prototype.filter) {
592
- Array.prototype.filter = function filter(fun /*, thisp */) {
593
- var object = toObject(this),
594
- self = splitString && _toString(this) == "[object String]" ?
595
- this.split("") :
596
- object,
597
- length = self.length >>> 0,
598
- result = [],
599
- value,
600
- thisp = arguments[1];
601
-
602
- // If no callback function or if callback is not a callable function
603
- if (_toString(fun) != "[object Function]") {
604
- throw new TypeError(fun + " is not a function");
605
- }
606
-
607
- for (var i = 0; i < length; i++) {
608
- if (i in self) {
609
- value = self[i];
610
- if (fun.call(thisp, value, i, object)) {
611
- result.push(value);
612
- }
613
- }
614
- }
615
- return result;
616
- };
617
- }
618
-
619
- // ES5 15.4.4.16
620
- // http://es5.github.com/#x15.4.4.16
621
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
622
- if (!Array.prototype.every) {
623
- Array.prototype.every = function every(fun /*, thisp */) {
624
- var object = toObject(this),
625
- self = splitString && _toString(this) == "[object String]" ?
626
- this.split("") :
627
- object,
628
- length = self.length >>> 0,
629
- thisp = arguments[1];
630
-
631
- // If no callback function or if callback is not a callable function
632
- if (_toString(fun) != "[object Function]") {
633
- throw new TypeError(fun + " is not a function");
634
- }
635
-
636
- for (var i = 0; i < length; i++) {
637
- if (i in self && !fun.call(thisp, self[i], i, object)) {
638
- return false;
639
- }
640
- }
641
- return true;
642
- };
643
- }
644
-
645
- // ES5 15.4.4.17
646
- // http://es5.github.com/#x15.4.4.17
647
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
648
- if (!Array.prototype.some) {
649
- Array.prototype.some = function some(fun /*, thisp */) {
650
- var object = toObject(this),
651
- self = splitString && _toString(this) == "[object String]" ?
652
- this.split("") :
653
- object,
654
- length = self.length >>> 0,
655
- thisp = arguments[1];
656
-
657
- // If no callback function or if callback is not a callable function
658
- if (_toString(fun) != "[object Function]") {
659
- throw new TypeError(fun + " is not a function");
660
- }
661
-
662
- for (var i = 0; i < length; i++) {
663
- if (i in self && fun.call(thisp, self[i], i, object)) {
664
- return true;
665
- }
666
- }
667
- return false;
668
- };
669
- }
670
-
671
- // ES5 15.4.4.21
672
- // http://es5.github.com/#x15.4.4.21
673
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
674
- if (!Array.prototype.reduce) {
675
- Array.prototype.reduce = function reduce(fun /*, initial*/) {
676
- var object = toObject(this),
677
- self = splitString && _toString(this) == "[object String]" ?
678
- this.split("") :
679
- object,
680
- length = self.length >>> 0;
681
-
682
- // If no callback function or if callback is not a callable function
683
- if (_toString(fun) != "[object Function]") {
684
- throw new TypeError(fun + " is not a function");
685
- }
686
-
687
- // no value to return if no initial value and an empty array
688
- if (!length && arguments.length == 1) {
689
- throw new TypeError("reduce of empty array with no initial value");
690
- }
691
-
692
- var i = 0;
693
- var result;
694
- if (arguments.length >= 2) {
695
- result = arguments[1];
696
- } else {
697
- do {
698
- if (i in self) {
699
- result = self[i++];
700
- break;
701
- }
702
-
703
- // if array contains no values, no initial value to return
704
- if (++i >= length) {
705
- throw new TypeError("reduce of empty array with no initial value");
706
- }
707
- } while (true);
708
- }
709
-
710
- for (; i < length; i++) {
711
- if (i in self) {
712
- result = fun.call(void 0, result, self[i], i, object);
713
- }
714
- }
715
-
716
- return result;
717
- };
718
- }
719
-
720
- // ES5 15.4.4.22
721
- // http://es5.github.com/#x15.4.4.22
722
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
723
- if (!Array.prototype.reduceRight) {
724
- Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
725
- var object = toObject(this),
726
- self = splitString && _toString(this) == "[object String]" ?
727
- this.split("") :
728
- object,
729
- length = self.length >>> 0;
730
-
731
- // If no callback function or if callback is not a callable function
732
- if (_toString(fun) != "[object Function]") {
733
- throw new TypeError(fun + " is not a function");
734
- }
735
-
736
- // no value to return if no initial value, empty array
737
- if (!length && arguments.length == 1) {
738
- throw new TypeError("reduceRight of empty array with no initial value");
739
- }
740
-
741
- var result, i = length - 1;
742
- if (arguments.length >= 2) {
743
- result = arguments[1];
744
- } else {
745
- do {
746
- if (i in self) {
747
- result = self[i--];
748
- break;
749
- }
750
-
751
- // if array contains no values, no initial value to return
752
- if (--i < 0) {
753
- throw new TypeError("reduceRight of empty array with no initial value");
754
- }
755
- } while (true);
756
- }
757
-
758
- if (i < 0) {
759
- return result;
760
- }
761
-
762
- do {
763
- if (i in this) {
764
- result = fun.call(void 0, result, self[i], i, object);
765
- }
766
- } while (i--);
767
-
768
- return result;
769
- };
770
- }
771
-
772
- // ES5 15.4.4.14
773
- // http://es5.github.com/#x15.4.4.14
774
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
775
- if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
776
- Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
777
- var self = splitString && _toString(this) == "[object String]" ?
778
- this.split("") :
779
- toObject(this),
780
- length = self.length >>> 0;
781
-
782
- if (!length) {
783
- return -1;
784
- }
785
-
786
- var i = 0;
787
- if (arguments.length > 1) {
788
- i = toInteger(arguments[1]);
789
- }
790
-
791
- // handle negative indices
792
- i = i >= 0 ? i : Math.max(0, length + i);
793
- for (; i < length; i++) {
794
- if (i in self && self[i] === sought) {
795
- return i;
796
- }
797
- }
798
- return -1;
799
- };
800
- }
801
-
802
- // ES5 15.4.4.15
803
- // http://es5.github.com/#x15.4.4.15
804
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
805
- if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
806
- Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
807
- var self = splitString && _toString(this) == "[object String]" ?
808
- this.split("") :
809
- toObject(this),
810
- length = self.length >>> 0;
811
-
812
- if (!length) {
813
- return -1;
814
- }
815
- var i = length - 1;
816
- if (arguments.length > 1) {
817
- i = Math.min(i, toInteger(arguments[1]));
818
- }
819
- // handle negative indices
820
- i = i >= 0 ? i : length - Math.abs(i);
821
- for (; i >= 0; i--) {
822
- if (i in self && sought === self[i]) {
823
- return i;
824
- }
825
- }
826
- return -1;
827
- };
828
- }
829
-
830
- //
831
- // Object
832
- // ======
833
- //
834
-
835
- // ES5 15.2.3.14
836
- // http://es5.github.com/#x15.2.3.14
837
- if (!Object.keys) {
838
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
839
- var hasDontEnumBug = true,
840
- dontEnums = [
841
- "toString",
842
- "toLocaleString",
843
- "valueOf",
844
- "hasOwnProperty",
845
- "isPrototypeOf",
846
- "propertyIsEnumerable",
847
- "constructor"
848
- ],
849
- dontEnumsLength = dontEnums.length;
850
-
851
- for (var key in {"toString": null}) {
852
- hasDontEnumBug = false;
853
- }
854
-
855
- Object.keys = function keys(object) {
856
-
857
- if (
858
- (typeof object != "object" && typeof object != "function") ||
859
- object === null
860
- ) {
861
- throw new TypeError("Object.keys called on a non-object");
862
- }
863
-
864
- var keys = [];
865
- for (var name in object) {
866
- if (owns(object, name)) {
867
- keys.push(name);
868
- }
869
- }
870
-
871
- if (hasDontEnumBug) {
872
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
873
- var dontEnum = dontEnums[i];
874
- if (owns(object, dontEnum)) {
875
- keys.push(dontEnum);
876
- }
877
- }
878
- }
879
- return keys;
880
- };
881
-
882
- }
883
-
884
- //
885
- // Date
886
- // ====
887
- //
888
-
889
- // ES5 15.9.5.43
890
- // http://es5.github.com/#x15.9.5.43
891
- // This function returns a String value represent the instance in time
892
- // represented by this Date object. The format of the String is the Date Time
893
- // string format defined in 15.9.1.15. All fields are present in the String.
894
- // The time zone is always UTC, denoted by the suffix Z. If the time value of
895
- // this object is not a finite Number a RangeError exception is thrown.
896
- var negativeDate = -62198755200000,
897
- negativeYearString = "-000001";
898
- if (
899
- !Date.prototype.toISOString ||
900
- (new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
901
- ) {
902
- Date.prototype.toISOString = function toISOString() {
903
- var result, length, value, year, month;
904
- if (!isFinite(this)) {
905
- throw new RangeError("Date.prototype.toISOString called on non-finite value.");
906
- }
907
-
908
- year = this.getUTCFullYear();
909
-
910
- month = this.getUTCMonth();
911
- // see https://github.com/kriskowal/es5-shim/issues/111
912
- year += Math.floor(month / 12);
913
- month = (month % 12 + 12) % 12;
914
-
915
- // the date time string format is specified in 15.9.1.15.
916
- result = [month + 1, this.getUTCDate(),
917
- this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
918
- year = (
919
- (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
920
- ("00000" + Math.abs(year))
921
- .slice(0 <= year && year <= 9999 ? -4 : -6)
922
- );
923
-
924
- length = result.length;
925
- while (length--) {
926
- value = result[length];
927
- // pad months, days, hours, minutes, and seconds to have two
928
- // digits.
929
- if (value < 10) {
930
- result[length] = "0" + value;
931
- }
932
- }
933
- // pad milliseconds to have three digits.
934
- return (
935
- year + "-" + result.slice(0, 2).join("-") +
936
- "T" + result.slice(2).join(":") + "." +
937
- ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
938
- );
939
- };
940
- }
941
-
942
-
943
- // ES5 15.9.5.44
944
- // http://es5.github.com/#x15.9.5.44
945
- // This function provides a String representation of a Date object for use by
946
- // JSON.stringify (15.12.3).
947
- var dateToJSONIsSupported = false;
948
- try {
949
- dateToJSONIsSupported = (
950
- Date.prototype.toJSON &&
951
- new Date(NaN).toJSON() === null &&
952
- new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
953
- Date.prototype.toJSON.call({ // generic
954
- toISOString: function () {
955
- return true;
956
- }
957
- })
958
- );
959
- } catch (e) {
960
- }
961
- if (!dateToJSONIsSupported) {
962
- Date.prototype.toJSON = function toJSON(key) {
963
- // When the toJSON method is called with argument key, the following
964
- // steps are taken:
965
-
966
- // 1. Let O be the result of calling ToObject, giving it the this
967
- // value as its argument.
968
- // 2. Let tv be toPrimitive(O, hint Number).
969
- var o = Object(this),
970
- tv = toPrimitive(o),
971
- toISO;
972
- // 3. If tv is a Number and is not finite, return null.
973
- if (typeof tv === "number" && !isFinite(tv)) {
974
- return null;
975
- }
976
- // 4. Let toISO be the result of calling the [[Get]] internal method of
977
- // O with argument "toISOString".
978
- toISO = o.toISOString;
979
- // 5. If IsCallable(toISO) is false, throw a TypeError exception.
980
- if (typeof toISO != "function") {
981
- throw new TypeError("toISOString property is not callable");
982
- }
983
- // 6. Return the result of calling the [[Call]] internal method of
984
- // toISO with O as the this value and an empty argument list.
985
- return toISO.call(o);
986
-
987
- // NOTE 1 The argument is ignored.
988
-
989
- // NOTE 2 The toJSON function is intentionally generic; it does not
990
- // require that its this value be a Date object. Therefore, it can be
991
- // transferred to other kinds of objects for use as a method. However,
992
- // it does require that any such object have a toISOString method. An
993
- // object is free to use the argument key to filter its
994
- // stringification.
995
- };
996
- }
997
-
998
- // ES5 15.9.4.2
999
- // http://es5.github.com/#x15.9.4.2
1000
- // based on work shared by Daniel Friesen (dantman)
1001
- // http://gist.github.com/303249
1002
- if (!Date.parse || "Date.parse is buggy") {
1003
- // XXX global assignment won't work in embeddings that use
1004
- // an alternate object for the context.
1005
- Date = (function(NativeDate) {
1006
-
1007
- // Date.length === 7
1008
- function Date(Y, M, D, h, m, s, ms) {
1009
- var length = arguments.length;
1010
- if (this instanceof NativeDate) {
1011
- var date = length == 1 && String(Y) === Y ? // isString(Y)
1012
- // We explicitly pass it through parse:
1013
- new NativeDate(Date.parse(Y)) :
1014
- // We have to manually make calls depending on argument
1015
- // length here
1016
- length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
1017
- length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
1018
- length >= 5 ? new NativeDate(Y, M, D, h, m) :
1019
- length >= 4 ? new NativeDate(Y, M, D, h) :
1020
- length >= 3 ? new NativeDate(Y, M, D) :
1021
- length >= 2 ? new NativeDate(Y, M) :
1022
- length >= 1 ? new NativeDate(Y) :
1023
- new NativeDate();
1024
- // Prevent mixups with unfixed Date object
1025
- date.constructor = Date;
1026
- return date;
1027
- }
1028
- return NativeDate.apply(this, arguments);
1029
- };
1030
-
1031
- // 15.9.1.15 Date Time String Format.
1032
- var isoDateExpression = new RegExp("^" +
1033
- "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
1034
- // 6-digit extended year
1035
- "(?:-(\\d{2})" + // optional month capture
1036
- "(?:-(\\d{2})" + // optional day capture
1037
- "(?:" + // capture hours:minutes:seconds.milliseconds
1038
- "T(\\d{2})" + // hours capture
1039
- ":(\\d{2})" + // minutes capture
1040
- "(?:" + // optional :seconds.milliseconds
1041
- ":(\\d{2})" + // seconds capture
1042
- "(?:(\\.\\d{1,}))?" + // milliseconds capture
1043
- ")?" +
1044
- "(" + // capture UTC offset component
1045
- "Z|" + // UTC capture
1046
- "(?:" + // offset specifier +/-hours:minutes
1047
- "([-+])" + // sign capture
1048
- "(\\d{2})" + // hours offset capture
1049
- ":(\\d{2})" + // minutes offset capture
1050
- ")" +
1051
- ")?)?)?)?" +
1052
- "$");
1053
-
1054
- var months = [
1055
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
1056
- ];
1057
-
1058
- function dayFromMonth(year, month) {
1059
- var t = month > 1 ? 1 : 0;
1060
- return (
1061
- months[month] +
1062
- Math.floor((year - 1969 + t) / 4) -
1063
- Math.floor((year - 1901 + t) / 100) +
1064
- Math.floor((year - 1601 + t) / 400) +
1065
- 365 * (year - 1970)
1066
- );
1067
- }
1068
-
1069
- // Copy any custom methods a 3rd party library may have added
1070
- for (var key in NativeDate) {
1071
- Date[key] = NativeDate[key];
1072
- }
1073
-
1074
- // Copy "native" methods explicitly; they may be non-enumerable
1075
- Date.now = NativeDate.now;
1076
- Date.UTC = NativeDate.UTC;
1077
- Date.prototype = NativeDate.prototype;
1078
- Date.prototype.constructor = Date;
1079
-
1080
- // Upgrade Date.parse to handle simplified ISO 8601 strings
1081
- Date.parse = function parse(string) {
1082
- var match = isoDateExpression.exec(string);
1083
- if (match) {
1084
- // parse months, days, hours, minutes, seconds, and milliseconds
1085
- // provide default values if necessary
1086
- // parse the UTC offset component
1087
- var year = Number(match[1]),
1088
- month = Number(match[2] || 1) - 1,
1089
- day = Number(match[3] || 1) - 1,
1090
- hour = Number(match[4] || 0),
1091
- minute = Number(match[5] || 0),
1092
- second = Number(match[6] || 0),
1093
- millisecond = Math.floor(Number(match[7] || 0) * 1000),
1094
- // When time zone is missed, local offset should be used
1095
- // (ES 5.1 bug)
1096
- // see https://bugs.ecmascript.org/show_bug.cgi?id=112
1097
- offset = !match[4] || match[8] ?
1098
- 0 : Number(new NativeDate(1970, 0)),
1099
- signOffset = match[9] === "-" ? 1 : -1,
1100
- hourOffset = Number(match[10] || 0),
1101
- minuteOffset = Number(match[11] || 0),
1102
- result;
1103
- if (
1104
- hour < (
1105
- minute > 0 || second > 0 || millisecond > 0 ?
1106
- 24 : 25
1107
- ) &&
1108
- minute < 60 && second < 60 && millisecond < 1000 &&
1109
- month > -1 && month < 12 && hourOffset < 24 &&
1110
- minuteOffset < 60 && // detect invalid offsets
1111
- day > -1 &&
1112
- day < (
1113
- dayFromMonth(year, month + 1) -
1114
- dayFromMonth(year, month)
1115
- )
1116
- ) {
1117
- result = (
1118
- (dayFromMonth(year, month) + day) * 24 +
1119
- hour +
1120
- hourOffset * signOffset
1121
- ) * 60;
1122
- result = (
1123
- (result + minute + minuteOffset * signOffset) * 60 +
1124
- second
1125
- ) * 1000 + millisecond + offset;
1126
- if (-8.64e15 <= result && result <= 8.64e15) {
1127
- return result;
1128
- }
1129
- }
1130
- return NaN;
1131
- }
1132
- return NativeDate.parse.apply(this, arguments);
1133
- };
1134
-
1135
- return Date;
1136
- })(Date);
1137
- }
1138
-
1139
- // ES5 15.9.4.4
1140
- // http://es5.github.com/#x15.9.4.4
1141
- if (!Date.now) {
1142
- Date.now = function now() {
1143
- return new Date().getTime();
1144
- };
1145
- }
1146
-
1147
-
1148
- //
1149
- // Number
1150
- // ======
1151
- //
1152
-
1153
- // ES5.1 15.7.4.5
1154
- // http://es5.github.com/#x15.7.4.5
1155
- if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' || (1000000000000000128).toFixed(0) !== "1000000000000000128") {
1156
- // Hide these variables and functions
1157
- (function () {
1158
- var base, size, data, i;
1159
-
1160
- base = 1e7;
1161
- size = 6;
1162
- data = [0, 0, 0, 0, 0, 0];
1163
-
1164
- function multiply(n, c) {
1165
- var i = -1;
1166
- while (++i < size) {
1167
- c += n * data[i];
1168
- data[i] = c % base;
1169
- c = Math.floor(c / base);
1170
- }
1171
- }
1172
-
1173
- function divide(n) {
1174
- var i = size, c = 0;
1175
- while (--i >= 0) {
1176
- c += data[i];
1177
- data[i] = Math.floor(c / n);
1178
- c = (c % n) * base;
1179
- }
1180
- }
1181
-
1182
- function toString() {
1183
- var i = size;
1184
- var s = '';
1185
- while (--i >= 0) {
1186
- if (s !== '' || i === 0 || data[i] !== 0) {
1187
- var t = String(data[i]);
1188
- if (s === '') {
1189
- s = t;
1190
- } else {
1191
- s += '0000000'.slice(0, 7 - t.length) + t;
1192
- }
1193
- }
1194
- }
1195
- return s;
1196
- }
1197
-
1198
- function pow(x, n, acc) {
1199
- return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
1200
- }
1201
-
1202
- function log(x) {
1203
- var n = 0;
1204
- while (x >= 4096) {
1205
- n += 12;
1206
- x /= 4096;
1207
- }
1208
- while (x >= 2) {
1209
- n += 1;
1210
- x /= 2;
1211
- }
1212
- return n;
1213
- }
1214
-
1215
- Number.prototype.toFixed = function (fractionDigits) {
1216
- var f, x, s, m, e, z, j, k;
1217
-
1218
- // Test for NaN and round fractionDigits down
1219
- f = Number(fractionDigits);
1220
- f = f !== f ? 0 : Math.floor(f);
1221
-
1222
- if (f < 0 || f > 20) {
1223
- throw new RangeError("Number.toFixed called with invalid number of decimals");
1224
- }
1225
-
1226
- x = Number(this);
1227
-
1228
- // Test for NaN
1229
- if (x !== x) {
1230
- return "NaN";
1231
- }
1232
-
1233
- // If it is too big or small, return the string value of the number
1234
- if (x <= -1e21 || x >= 1e21) {
1235
- return String(x);
1236
- }
1237
-
1238
- s = "";
1239
-
1240
- if (x < 0) {
1241
- s = "-";
1242
- x = -x;
1243
- }
1244
-
1245
- m = "0";
1246
-
1247
- if (x > 1e-21) {
1248
- // 1e-21 < x < 1e21
1249
- // -70 < log2(x) < 70
1250
- e = log(x * pow(2, 69, 1)) - 69;
1251
- z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
1252
- z *= 0x10000000000000; // Math.pow(2, 52);
1253
- e = 52 - e;
1254
-
1255
- // -18 < e < 122
1256
- // x = z / 2 ^ e
1257
- if (e > 0) {
1258
- multiply(0, z);
1259
- j = f;
1260
-
1261
- while (j >= 7) {
1262
- multiply(1e7, 0);
1263
- j -= 7;
1264
- }
1265
-
1266
- multiply(pow(10, j, 1), 0);
1267
- j = e - 1;
1268
-
1269
- while (j >= 23) {
1270
- divide(1 << 23);
1271
- j -= 23;
1272
- }
1273
-
1274
- divide(1 << j);
1275
- multiply(1, 1);
1276
- divide(2);
1277
- m = toString();
1278
- } else {
1279
- multiply(0, z);
1280
- multiply(1 << (-e), 0);
1281
- m = toString() + '0.00000000000000000000'.slice(2, 2 + f);
1282
- }
1283
- }
1284
-
1285
- if (f > 0) {
1286
- k = m.length;
1287
-
1288
- if (k <= f) {
1289
- m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1290
- } else {
1291
- m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1292
- }
1293
- } else {
1294
- m = s + m;
1295
- }
1296
-
1297
- return m;
1298
- }
1299
- }());
1300
- }
1301
-
1302
-
1303
- //
1304
- // String
1305
- // ======
1306
- //
1307
-
1308
-
1309
- // ES5 15.5.4.14
1310
- // http://es5.github.com/#x15.5.4.14
1311
-
1312
- // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
1313
- // Many browsers do not split properly with regular expressions or they
1314
- // do not perform the split correctly under obscure conditions.
1315
- // See http://blog.stevenlevithan.com/archives/cross-browser-split
1316
- // I've tested in many browsers and this seems to cover the deviant ones:
1317
- // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1318
- // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1319
- // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1320
- // [undefined, "t", undefined, "e", ...]
1321
- // ''.split(/.?/) should be [], not [""]
1322
- // '.'.split(/()()/) should be ["."], not ["", "", "."]
1323
-
1324
- var string_split = String.prototype.split;
1325
- if (
1326
- 'ab'.split(/(?:ab)*/).length !== 2 ||
1327
- '.'.split(/(.?)(.?)/).length !== 4 ||
1328
- 'tesst'.split(/(s)*/)[1] === "t" ||
1329
- ''.split(/.?/).length === 0 ||
1330
- '.'.split(/()()/).length > 1
1331
- ) {
1332
- (function () {
1333
- var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
1334
-
1335
- String.prototype.split = function (separator, limit) {
1336
- var string = this;
1337
- if (separator === void 0 && limit === 0)
1338
- return [];
1339
-
1340
- // If `separator` is not a regex, use native split
1341
- if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
1342
- return string_split.apply(this, arguments);
1343
- }
1344
-
1345
- var output = [],
1346
- flags = (separator.ignoreCase ? "i" : "") +
1347
- (separator.multiline ? "m" : "") +
1348
- (separator.extended ? "x" : "") + // Proposed for ES6
1349
- (separator.sticky ? "y" : ""), // Firefox 3+
1350
- lastLastIndex = 0,
1351
- // Make `global` and avoid `lastIndex` issues by working with a copy
1352
- separator = new RegExp(separator.source, flags + "g"),
1353
- separator2, match, lastIndex, lastLength;
1354
- string += ""; // Type-convert
1355
- if (!compliantExecNpcg) {
1356
- // Doesn't need flags gy, but they don't hurt
1357
- separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1358
- }
1359
- /* Values for `limit`, per the spec:
1360
- * If undefined: 4294967295 // Math.pow(2, 32) - 1
1361
- * If 0, Infinity, or NaN: 0
1362
- * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1363
- * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1364
- * If other: Type-convert, then use the above rules
1365
- */
1366
- limit = limit === void 0 ?
1367
- -1 >>> 0 : // Math.pow(2, 32) - 1
1368
- limit >>> 0; // ToUint32(limit)
1369
- while (match = separator.exec(string)) {
1370
- // `separator.lastIndex` is not reliable cross-browser
1371
- lastIndex = match.index + match[0].length;
1372
- if (lastIndex > lastLastIndex) {
1373
- output.push(string.slice(lastLastIndex, match.index));
1374
- // Fix browsers whose `exec` methods don't consistently return `undefined` for
1375
- // nonparticipating capturing groups
1376
- if (!compliantExecNpcg && match.length > 1) {
1377
- match[0].replace(separator2, function () {
1378
- for (var i = 1; i < arguments.length - 2; i++) {
1379
- if (arguments[i] === void 0) {
1380
- match[i] = void 0;
1381
- }
1382
- }
1383
- });
1384
- }
1385
- if (match.length > 1 && match.index < string.length) {
1386
- Array.prototype.push.apply(output, match.slice(1));
1387
- }
1388
- lastLength = match[0].length;
1389
- lastLastIndex = lastIndex;
1390
- if (output.length >= limit) {
1391
- break;
1392
- }
1393
- }
1394
- if (separator.lastIndex === match.index) {
1395
- separator.lastIndex++; // Avoid an infinite loop
1396
- }
1397
- }
1398
- if (lastLastIndex === string.length) {
1399
- if (lastLength || !separator.test("")) {
1400
- output.push("");
1401
- }
1402
- } else {
1403
- output.push(string.slice(lastLastIndex));
1404
- }
1405
- return output.length > limit ? output.slice(0, limit) : output;
1406
- };
1407
- }());
1408
-
1409
- // [bugfix, chrome]
1410
- // If separator is undefined, then the result array contains just one String,
1411
- // which is the this value (converted to a String). If limit is not undefined,
1412
- // then the output array is truncated so that it contains no more than limit
1413
- // elements.
1414
- // "0".split(undefined, 0) -> []
1415
- } else if ("0".split(void 0, 0).length) {
1416
- String.prototype.split = function(separator, limit) {
1417
- if (separator === void 0 && limit === 0) return [];
1418
- return string_split.apply(this, arguments);
1419
- }
1420
- }
1421
-
1422
-
1423
- // ECMA-262, 3rd B.2.3
1424
- // Note an ECMAScript standart, although ECMAScript 3rd Edition has a
1425
- // non-normative section suggesting uniform semantics and it should be
1426
- // normalized across all browsers
1427
- // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1428
- if("".substr && "0b".substr(-1) !== "b") {
1429
- var string_substr = String.prototype.substr;
1430
- /**
1431
- * Get the substring of a string
1432
- * @param {integer} start where to start the substring
1433
- * @param {integer} length how many characters to return
1434
- * @return {string}
1435
- */
1436
- String.prototype.substr = function(start, length) {
1437
- return string_substr.call(
1438
- this,
1439
- start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1440
- length
1441
- );
1442
- }
1443
- }
1444
-
1445
- // ES5 15.5.4.20
1446
- // http://es5.github.com/#x15.5.4.20
1447
- var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1448
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1449
- "\u2029\uFEFF";
1450
- if (!String.prototype.trim || ws.trim()) {
1451
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1452
- // http://perfectionkills.com/whitespace-deviations/
1453
- ws = "[" + ws + "]";
1454
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1455
- trimEndRegexp = new RegExp(ws + ws + "*$");
1456
- String.prototype.trim = function trim() {
1457
- if (this === void 0 || this === null) {
1458
- throw new TypeError("can't convert "+this+" to object");
1459
- }
1460
- return String(this)
1461
- .replace(trimBeginRegexp, "")
1462
- .replace(trimEndRegexp, "");
1463
- };
1464
- }
1465
-
1466
- //
1467
- // Util
1468
- // ======
1469
- //
1470
-
1471
- // ES5 9.4
1472
- // http://es5.github.com/#x9.4
1473
- // http://jsperf.com/to-integer
1474
-
1475
- function toInteger(n) {
1476
- n = +n;
1477
- if (n !== n) { // isNaN
1478
- n = 0;
1479
- } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
1480
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
1481
- }
1482
- return n;
1483
- }
1484
-
1485
- function isPrimitive(input) {
1486
- var type = typeof input;
1487
- return (
1488
- input === null ||
1489
- type === "undefined" ||
1490
- type === "boolean" ||
1491
- type === "number" ||
1492
- type === "string"
1493
- );
1494
- }
1495
-
1496
- function toPrimitive(input) {
1497
- var val, valueOf, toString;
1498
- if (isPrimitive(input)) {
1499
- return input;
1500
- }
1501
- valueOf = input.valueOf;
1502
- if (typeof valueOf === "function") {
1503
- val = valueOf.call(input);
1504
- if (isPrimitive(val)) {
1505
- return val;
1506
- }
1507
- }
1508
- toString = input.toString;
1509
- if (typeof toString === "function") {
1510
- val = toString.call(input);
1511
- if (isPrimitive(val)) {
1512
- return val;
1513
- }
1514
- }
1515
- throw new TypeError();
1516
- }
1517
-
1518
- // ES5 9.9
1519
- // http://es5.github.com/#x9.9
1520
- var toObject = function (o) {
1521
- if (o == null) { // this matches both null and undefined
1522
- throw new TypeError("can't convert "+o+" to object");
1523
- }
1524
- return Object(o);
1525
- };
1526
-
1527
- })();
1528
-
1529
-
1530
-
1531
-
1532
- (function($, shims){
1533
- var defineProperty = 'defineProperty';
1534
- var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
1535
- //safari5 has defineProperty-interface, but it can't be used on dom-object
1536
- //only do this test in non-IE browsers, because this hurts dhtml-behavior in some IE8 versions
1537
- if (advancedObjectProperties && Object[defineProperty] && Object.prototype.__defineGetter__) {
1538
- (function(){
1539
- try {
1540
- var foo = document.createElement('foo');
1541
- Object[defineProperty](foo, 'bar', {
1542
- get: function(){
1543
- return true;
1544
- }
1545
- });
1546
- advancedObjectProperties = !!foo.bar;
1547
- }
1548
- catch (e) {
1549
- advancedObjectProperties = false;
1550
- }
1551
- foo = null;
1552
- })();
1553
- }
1554
-
1555
- Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)));
1556
- Modernizr.advancedObjectProperties = advancedObjectProperties;
1557
-
1558
- if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
1559
- var call = Function.prototype.call;
1560
- var prototypeOfObject = Object.prototype;
1561
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
1562
-
1563
- shims.objectCreate = function(proto, props, opts, no__proto__){
1564
- var o;
1565
- var f = function(){};
1566
-
1567
- f.prototype = proto;
1568
- o = new f();
1569
-
1570
- if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
1571
- o.__proto__ = proto;
1572
- }
1573
-
1574
- if(props){
1575
- shims.defineProperties(o, props);
1576
- }
1577
-
1578
- if(opts){
1579
- o.options = $.extend(true, {}, o.options || {}, opts);
1580
- opts = o.options;
1581
- }
1582
-
1583
- if(o._create && $.isFunction(o._create)){
1584
- o._create(opts);
1585
- }
1586
- return o;
1587
- };
1588
-
1589
- shims.defineProperties = function(object, props){
1590
- for (var name in props) {
1591
- if (owns(props, name)) {
1592
- shims.defineProperty(object, name, props[name]);
1593
- }
1594
- }
1595
- return object;
1596
- };
1597
-
1598
- var descProps = ['configurable', 'enumerable', 'writable'];
1599
- shims.defineProperty = function(proto, property, descriptor){
1600
- if(typeof descriptor != "object" || descriptor === null){return proto;}
1601
-
1602
- if(owns(descriptor, "value")){
1603
- proto[property] = descriptor.value;
1604
- return proto;
1605
- }
1606
-
1607
- if(proto.__defineGetter__){
1608
- if (typeof descriptor.get == "function") {
1609
- proto.__defineGetter__(property, descriptor.get);
1610
- }
1611
- if (typeof descriptor.set == "function"){
1612
- proto.__defineSetter__(property, descriptor.set);
1613
- }
1614
- }
1615
- return proto;
1616
- };
1617
-
1618
- shims.getPrototypeOf = function (object) {
1619
- return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
1620
- };
1621
-
1622
- //based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
1623
- shims.getOwnPropertyDescriptor = function(obj, prop){
1624
- if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
1625
- throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
1626
- }
1627
- var descriptor;
1628
- if(Object.defineProperty && Object.getOwnPropertyDescriptor){
1629
- try{
1630
- descriptor = Object.getOwnPropertyDescriptor(obj, prop);
1631
- return descriptor;
1632
- } catch(e){}
1633
- }
1634
- descriptor = {
1635
- configurable: true,
1636
- enumerable: true,
1637
- writable: true,
1638
- value: undefined
1639
- };
1640
- var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
1641
- setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
1642
- ;
1643
-
1644
- if (!getter && !setter) { // not an accessor so return prop
1645
- if(!owns(obj, prop)){
1646
- return;
1647
- }
1648
- descriptor.value = obj[prop];
1649
- return descriptor;
1650
- }
1651
-
1652
- // there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
1653
- delete descriptor.writable;
1654
- delete descriptor.value;
1655
- descriptor.get = descriptor.set = undefined;
1656
-
1657
- if(getter){
1658
- descriptor.get = getter;
1659
- }
1660
-
1661
- if(setter){
1662
- descriptor.set = setter;
1663
- }
1664
-
1665
- return descriptor;
1666
- };
1667
-
1668
- }
1669
- webshims.isReady('es5', true);
1670
- })(webshims.$, webshims);
1671
-
1672
-
1673
- ;
1674
2
  //this might was already extended by ES5 shim feature
1675
3
  (function($){
1676
4
  "use strict";
@@ -1851,8 +179,8 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1851
179
  });
1852
180
  return this;
1853
181
  };
1854
-
1855
- var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
182
+ var idCount = 0;
183
+ var dataID = '_webshims'+ (Math.round(Math.random() * 1000));
1856
184
  var elementData = function(elem, key, val){
1857
185
  elem = elem.jquery ? elem[0] : elem;
1858
186
  if(!elem){return val || {};}
@@ -1883,6 +211,35 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
1883
211
  return this.pushStack(elems);
1884
212
  };
1885
213
  });
214
+
215
+ function clone(elem, dataAndEvents, uniqueIds){
216
+ var cloned = $.clone( elem, dataAndEvents, false );
217
+ $(cloned.querySelectorAll('.'+webshims.shadowClass)).detach();
218
+ if(uniqueIds){
219
+ idCount++;
220
+ $(cloned.querySelectorAll('[id]')).prop('id', function(i, id){
221
+ return id +idCount;
222
+ });
223
+ } else {
224
+ $(cloned.querySelectorAll('audio[id^="ID-"], video[id^="ID-"], label[id^="ID-"]')).removeAttr('id');
225
+ }
226
+ return cloned;
227
+ }
228
+
229
+ $.fn.clonePolyfill = function(dataAndEvents, uniqueIds){
230
+ dataAndEvents = dataAndEvents || false;
231
+ return this
232
+ .map(function() {
233
+ var cloned = clone( this, dataAndEvents, uniqueIds );
234
+ setTimeout(function(){
235
+ if($.contains(document.body, cloned)){
236
+ $(cloned).updatePolyfill();
237
+ }
238
+ });
239
+ return cloned;
240
+ })
241
+ ;
242
+ };
1886
243
 
1887
244
  //add support for $('video').trigger('play') in case extendNative is set to false
1888
245
  if(!webshims.cfg.extendNative && !webshims.cfg.noTriggerOverride){
@@ -2194,6 +551,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2194
551
  return id;
2195
552
  };
2196
553
  })(),
554
+ shadowClass: 'wsshadow-'+(Date.now()),
2197
555
  implement: function(elem, type){
2198
556
  var data = elementData(elem, 'implemented') || elementData(elem, 'implemented', {});
2199
557
  if(data[type]){
@@ -2831,950 +1189,504 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
2831
1189
  if (!hasRole) {
2832
1190
  elem.setAttribute('role', role);
2833
1191
  }
2834
- };
2835
-
2836
-
2837
- $.webshims.addReady(function(context, contextElem){
2838
- $.each(elemMappings, function(name, role){
2839
- var elems = $(name, context).add(contextElem.filter(name));
2840
- for (var i = 0, len = elems.length; i < len; i++) {
2841
- addRole(elems[i], role);
2842
- }
2843
- });
2844
- if (context === document) {
2845
- var header = document.getElementsByTagName('header')[0];
2846
- var footers = document.getElementsByTagName('footer');
2847
- var footerLen = footers.length;
2848
-
2849
- if (header && !$(header).closest('section, article')[0]) {
2850
- addRole(header, 'banner');
2851
- }
2852
- if (!footerLen) {
2853
- return;
2854
- }
2855
- var footer = footers[footerLen - 1];
2856
- if (!$(footer).closest('section, article')[0]) {
2857
- addRole(footer, 'contentinfo');
2858
- }
2859
- }
2860
- });
2861
-
2862
- })();
2863
- });
2864
- ;webshims.register('filereader', function( $, webshims ){
2865
- "use strict";
2866
- /**
2867
- * Code is based on https://github.com/Jahdrien/FileReader
2868
- *
2869
- */
2870
- (function(){
2871
- var swfobject = window.swfmini || window.swfobject;
2872
-
2873
- var readyCallbacks = $.Callbacks('once unique memory'),
2874
- inputsCount = 0,
2875
- currentTarget = null;
2876
-
2877
- // if native FileReader support, then dont add the polyfill and make the plugin do nothing
2878
- if (window.FileReader) {
2879
- $.fn.fileReader = function () { return this; }
2880
- return ;
2881
- }
2882
-
2883
- /**
2884
- * JQuery Plugin
2885
- */
2886
- $.fn.fileReader = function( options ) {
2887
- if(this.length){
2888
- options = $.extend($.fn.fileReader.defaults, options);
2889
-
2890
- var self = this;
2891
- readyCallbacks.add(function() {
2892
- return main(self, options);
2893
- });
2894
- if ($.isFunction(options.callback)) readyCallbacks.add(options.callback);
2895
-
2896
- if (!FileAPIProxy.ready) {
2897
- FileAPIProxy.init(options);
2898
- }
2899
- }
2900
- return this;
2901
- };
2902
-
2903
- /**
2904
- * Default options
2905
- * allows user set default options
2906
- */
2907
- $.fn.fileReader.defaults = {
2908
- id : 'fileReaderSWFObject', // ID for the created swf object container,
2909
- multiple : null,
2910
- accept : null,
2911
- label : null,
2912
- extensions : null,
2913
- filereader : 'files/filereader.swf', // The path to the filereader swf file
2914
- expressInstall : null, // The path to the express install swf file
2915
- debugMode : false,
2916
- callback : false // Callback function when Filereader is ready
2917
- };
2918
-
2919
- /**
2920
- * Plugin callback
2921
- * adds an input to registry
2922
- */
2923
- var main = function(el, options) {
2924
- return el.each(function(i, input) {
2925
- input = $(input);
2926
- var id = input.attr('id');
2927
- var multiple, accept, label;
2928
- if (!id) {
2929
- id = 'flashFileInput' + inputsCount;
2930
- input.attr('id', id);
2931
- inputsCount++;
2932
- }
2933
- multiple = input.prop('multiple');
2934
- accept = input.data('swfaccept') || input.prop('accept') || options.accept;
2935
- label = input.jProp('labels')
2936
- .map(function(){
2937
- return $(this).text();
2938
- }).get().join(' ') ||
2939
- input.data('swflabel') ||
2940
- options.label;
2941
-
2942
- FileAPIProxy.inputs[id] = input;
2943
- FileAPIProxy.swfObject.add(id, multiple, accept, label, options.extensions);
2944
-
2945
- input.css('z-index', 0)
2946
- .mouseover(function (e) {
2947
- if (id !== currentTarget) {
2948
- e = e || window.event;
2949
- currentTarget = id;
2950
- FileAPIProxy.swfObject.mouseover(id);
2951
- FileAPIProxy.container
2952
- .height(input.outerHeight())
2953
- .width(input.outerWidth())
2954
- .css(input.offset());
2955
- }
2956
- })
2957
- .click(function(e) {
2958
- e.preventDefault();
2959
- e.stopPropagation();
2960
- e.stopImmediatePropagation();
2961
- return false;
2962
- });
2963
- });
2964
- };
2965
-
2966
- /**
2967
- * Flash FileReader Proxy
2968
- */
2969
- window.FileAPIProxy = {
2970
- ready: false,
2971
- _inititalized: false,
2972
- init: function(o) {
2973
- var self = this;
2974
- this.debugMode = o.debugMode;
2975
-
2976
- if(!this.container){
2977
- this.container = $('<div>').attr('id', o.id)
2978
- .wrap('<div>')
2979
- .parent()
2980
- .css({
2981
- position:'fixed',
2982
- // top:'0px',
2983
- width:'1px',
2984
- height:'1px',
2985
- display:'inline-block',
2986
- background:'transparent',
2987
- 'z-index':99999
2988
- })
2989
- // Hands over mouse events to original input for css styles
2990
- .on('mouseover mouseout mousedown mouseup', function(evt) {
2991
- if(currentTarget){
2992
- $('#' + currentTarget).trigger(evt.type);
2993
- }
2994
- })
2995
- .appendTo('body');
2996
-
2997
- swfobject.embedSWF(o.filereader, o.id, '100%', '100%', '10', o.expressInstall, {debugMode: o.debugMode ? true : ''}, {'wmode':'transparent','allowScriptAccess':'sameDomain'}, {}, function(e) {
2998
- self.swfObject = e.ref;
2999
- $(self.swfObject)
3000
- .css({
3001
- display: 'block',
3002
- outline: 0
3003
- })
3004
- .attr('tabindex', 0);
3005
-
3006
- self.ready = e.success && typeof e.ref.add === "function";
3007
-
3008
- if (self.ready) {
3009
- readyCallbacks.fire();
3010
- }
3011
- });
3012
- }
3013
- },
3014
- swfObject: null,
3015
- container: null,
3016
- // Inputs Registry
3017
- inputs: {},
3018
- // Readers Registry
3019
- readers: {},
3020
- // Receives FileInput events
3021
- onFileInputEvent: function(evt) {
3022
- if (this.debugMode) console.info('FileInput Event ', evt.type, evt);
3023
- if (evt.target in this.inputs) {
3024
- var el = this.inputs[evt.target];
3025
- evt.target = el[0];
3026
- if( evt.type === 'change') {
3027
- webshims.data(evt.target, 'fileList', new FileList(evt.files));
3028
- }
3029
- el.trigger(evt);
3030
- }
3031
- window.focus();
3032
- },
3033
- // Receives FileReader ProgressEvents
3034
- onFileReaderEvent: function(evt) {
3035
- if (this.debugMode) console.info('FileReader Event ', evt.type, evt, evt.target in this.readers);
3036
- if (evt.target in this.readers) {
3037
- var reader = this.readers[evt.target];
3038
- evt.target = reader;
3039
- reader._handleFlashEvent.call(reader, evt);
3040
- }
3041
- },
3042
- // Receives flash FileReader Error Events
3043
- onFileReaderError: function(error) {
3044
- if (this.debugMode) console.log(error);
3045
- },
3046
- onSWFReady: function() {
3047
- this.container.css({position: 'absolute'});
3048
- this.ready = typeof this.swfObject.add === "function";
3049
- if (this.ready) {
3050
- readyCallbacks.fire();
3051
- }
3052
-
3053
- return true;
3054
- }
3055
- };
3056
-
3057
-
3058
- /**
3059
- * Add FileReader to the window object
3060
- */
3061
- window.FileReader = function () {
3062
- // states
3063
- this.EMPTY = 0;
3064
- this.LOADING = 1;
3065
- this.DONE = 2;
3066
-
3067
- this.readyState = 0;
3068
-
3069
- // File or Blob data
3070
- this.result = null;
3071
-
3072
- this.error = null;
3073
-
3074
- // event handler attributes
3075
- this.onloadstart = null;
3076
- this.onprogress = null;
3077
- this.onload = null;
3078
- this.onabort = null;
3079
- this.onerror = null;
3080
- this.onloadend = null;
3081
-
3082
- // Event Listeners handling using JQuery Callbacks
3083
- this._callbacks = {
3084
- loadstart : $.Callbacks( "unique" ),
3085
- progress : $.Callbacks( "unique" ),
3086
- abort : $.Callbacks( "unique" ),
3087
- error : $.Callbacks( "unique" ),
3088
- load : $.Callbacks( "unique" ),
3089
- loadend : $.Callbacks( "unique" )
3090
- };
3091
-
3092
- // Custom properties
3093
- this._id = null;
3094
- };
3095
-
3096
- window.FileReader.prototype = {
3097
- // async read methods
3098
- readAsBinaryString: function (file) {
3099
- this._start(file);
3100
- FileAPIProxy.swfObject.read(file.input, file.name, 'readAsBinaryString');
3101
- },
3102
- readAsText: function (file, encoding) {
3103
- this._start(file);
3104
- FileAPIProxy.swfObject.read(file.input, file.name, 'readAsText');
3105
- },
3106
- readAsDataURL: function (file) {
3107
- this._start(file);
3108
- FileAPIProxy.swfObject.read(file.input, file.name, 'readAsDataURL');
3109
- },
3110
- readAsArrayBuffer: function(file){
3111
- throw("Whoops FileReader.readAsArrayBuffer is unimplemented");
3112
- },
3113
-
3114
- abort: function () {
3115
- this.result = null;
3116
- if (this.readyState === this.EMPTY || this.readyState === this.DONE) return;
3117
- FileAPIProxy.swfObject.abort(this._id);
3118
- },
3119
-
3120
- // Event Target interface
3121
- addEventListener: function (type, listener) {
3122
- if (type in this._callbacks) this._callbacks[type].add(listener);
3123
- },
3124
- removeEventListener: function (type, listener) {
3125
- if (type in this._callbacks) this._callbacks[type].remove(listener);
3126
- },
3127
- dispatchEvent: function (event) {
3128
- event.target = this;
3129
- if (event.type in this._callbacks) {
3130
- var fn = this['on' + event.type];
3131
- if ($.isFunction(fn)) fn(event);
3132
- this._callbacks[event.type].fire(event);
3133
- }
3134
- return true;
3135
- },
3136
-
3137
- // Custom private methods
3138
-
3139
- // Registers FileReader instance for flash callbacks
3140
- _register: function(file) {
3141
- this._id = file.input + '.' + file.name;
3142
- FileAPIProxy.readers[this._id] = this;
3143
- },
3144
- _start: function(file) {
3145
- this._register(file);
3146
- if (this.readyState === this.LOADING) throw {type: 'InvalidStateError', code: 11, message: 'The object is in an invalid state.'};
3147
- },
3148
- _handleFlashEvent: function(evt) {
3149
- switch (evt.type) {
3150
- case 'loadstart':
3151
- this.readyState = this.LOADING;
3152
- break;
3153
- case 'loadend':
3154
- this.readyState = this.DONE;
3155
- break;
3156
- case 'load':
3157
- this.readyState = this.DONE;
3158
- this.result = FileAPIProxy.swfObject.result(this._id);
3159
- break;
3160
- case 'error':
3161
- this.result = null;
3162
- this.error = {
3163
- name: 'NotReadableError',
3164
- message: 'The File cannot be read!'
3165
- };
3166
- }
3167
- this.dispatchEvent(new FileReaderEvent(evt));
3168
- }
3169
- };
3170
-
3171
- /**
3172
- * FileReader ProgressEvent implenting Event interface
3173
- */
3174
- window.FileReaderEvent = function (e) {
3175
- this.initEvent(e);
3176
- };
3177
-
3178
- window.FileReaderEvent.prototype = {
3179
- initEvent: function (event) {
3180
- $.extend(this, {
3181
- type: null,
3182
- target: null,
3183
- currentTarget: null,
3184
-
3185
- eventPhase: 2,
3186
-
3187
- bubbles: false,
3188
- cancelable: false,
3189
-
3190
- defaultPrevented: false,
3191
-
3192
- isTrusted: false,
3193
- timeStamp: new Date().getTime()
3194
- }, event);
3195
- },
3196
- stopPropagation: function (){
3197
- },
3198
- stopImmediatePropagation: function (){
3199
- },
3200
- preventDefault: function (){
3201
- }
3202
- };
3203
-
3204
- /**
3205
- * FileList interface (Object with item function)
3206
- */
3207
- window.FileList = function(array) {
3208
- if (array) {
3209
- for (var i = 0; i < array.length; i++) {
3210
- this[i] = array[i];
3211
- }
3212
- this.length = array.length;
3213
- } else {
3214
- this.length = 0;
3215
- }
3216
- };
3217
-
3218
- window.FileList.prototype = {
3219
- item: function(index) {
3220
- return (index in this) ? this[index] : null;
3221
- }
3222
- };
3223
- })();
3224
-
3225
- webshims.defineNodeNameProperty('input', 'files', {
3226
- prop: {
3227
- writeable: false,
3228
- get: function(){
3229
- if(this.type != 'file'){return null;}
3230
- if(!$(this).is('.ws-filereader')){
3231
- webshims.error("please add the 'ws-filereader' class to your input[type='file'] to implement files-property");
3232
- }
3233
- return webshims.data(this, 'fileList') || webshims.data(this, 'fileList', new FileList());
3234
- }
3235
- }
3236
- }
3237
- );
3238
-
3239
- webshims.defineNodeNamesBooleanProperty('input', 'multiple');
3240
-
3241
- //webshims
3242
- $.fn.fileReader.defaults.filereader = webshims.cfg.basePath +'swf/filereader.swf';
3243
- var wait = ['DOM'];
3244
- if(webshims.modules["form-core"].loaded){
3245
- wait.push('forms');
3246
- }
3247
- webshims.ready(wait, function(){
3248
- webshims.addReady(function(context, contextElem){
3249
- $('input[type="file"].ws-filereader', context).fileReader();
3250
- });
3251
- });
3252
- });
3253
- ;(function(Modernizr, webshims){
3254
- "use strict";
3255
- var hasNative = Modernizr.audio && Modernizr.video;
3256
- var supportsLoop = false;
3257
- var bugs = webshims.bugs;
3258
- var swfType = 'mediaelement-jaris';
3259
- var loadSwf = function(){
3260
- webshims.ready(swfType, function(){
3261
- if(!webshims.mediaelement.createSWF){
3262
- webshims.mediaelement.loadSwf = true;
3263
- webshims.reTest([swfType], hasNative);
3264
- }
3265
- });
3266
- };
3267
-
3268
- var wsCfg = webshims.cfg;
3269
- var options = wsCfg.mediaelement;
3270
- var hasSwf;
3271
- if(!options){
3272
- webshims.error("mediaelement wasn't implemented but loaded");
3273
- return;
3274
- }
3275
-
3276
- if(hasNative){
3277
- var videoElem = document.createElement('video');
3278
- Modernizr.videoBuffered = ('buffered' in videoElem);
3279
- Modernizr.mediaDefaultMuted = ('defaultMuted' in videoElem);
3280
- supportsLoop = ('loop' in videoElem);
3281
- Modernizr.mediaLoop = supportsLoop;
3282
-
3283
- webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
3284
-
3285
- if( !Modernizr.videoBuffered || !supportsLoop || (!Modernizr.mediaDefaultMuted && navigator.userAgent.indexOf('MSIE') != -1 && 'ActiveXObject' in window) ){
3286
- webshims.addPolyfill('mediaelement-native-fix', {
3287
- d: ['dom-support']
3288
- });
3289
- webshims.loader.loadList(['mediaelement-native-fix']);
3290
- }
3291
- }
3292
-
3293
- if(Modernizr.track && !bugs.track){
3294
- (function(){
3295
- if(!bugs.track){
3296
-
3297
- if(window.VTTCue && !window.TextTrackCue){
3298
- window.TextTrackCue = window.VTTCue;
3299
- } else if(!window.VTTCue){
3300
- window.VTTCue = window.TextTrackCue;
3301
- }
3302
-
3303
- try {
3304
- new VTTCue(2, 3, '');
3305
- } catch(e){
3306
- bugs.track = true;
3307
- }
3308
- }
3309
- })();
3310
- }
3311
-
3312
- webshims.register('mediaelement-core', function($, webshims, window, document, undefined, options){
3313
- hasSwf = swfmini.hasFlashPlayerVersion('10.0.3');
3314
- var mediaelement = webshims.mediaelement;
3315
-
3316
- mediaelement.parseRtmp = function(data){
3317
- var src = data.src.split('://');
3318
- var paths = src[1].split('/');
3319
- var i, len, found;
3320
- data.server = src[0]+'://'+paths[0]+'/';
3321
- data.streamId = [];
3322
- for(i = 1, len = paths.length; i < len; i++){
3323
- if(!found && paths[i].indexOf(':') !== -1){
3324
- paths[i] = paths[i].split(':')[1];
3325
- found = true;
3326
- }
3327
- if(!found){
3328
- data.server += paths[i]+'/';
3329
- } else {
3330
- data.streamId.push(paths[i]);
3331
- }
3332
- }
3333
- if(!data.streamId.length){
3334
- webshims.error('Could not parse rtmp url');
3335
- }
3336
- data.streamId = data.streamId.join('/');
3337
- };
3338
-
3339
- var getSrcObj = function(elem, nodeName){
3340
- elem = $(elem);
3341
- var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
3342
- var tmp;
3343
-
3344
- if(!src.src){return src;}
3345
-
3346
- tmp = elem.attr('data-server');
3347
- if(tmp != null){
3348
- src.server = tmp;
3349
- }
3350
-
3351
- tmp = elem.attr('type') || elem.attr('data-type');
3352
- if(tmp){
3353
- src.type = tmp;
3354
- src.container = $.trim(tmp.split(';')[0]);
3355
- } else {
3356
- if(!nodeName){
3357
- nodeName = elem[0].nodeName.toLowerCase();
3358
- if(nodeName == 'source'){
3359
- nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
3360
- }
3361
- }
3362
- if(src.server){
3363
- src.type = nodeName+'/rtmp';
3364
- src.container = nodeName+'/rtmp';
3365
- } else {
3366
-
3367
- tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
3368
-
3369
- if(tmp){
3370
- src.type = tmp;
3371
- src.container = tmp;
3372
- }
3373
- }
3374
- }
3375
-
3376
- if(!src.container){
3377
- $(elem).attr('data-wsrecheckmimetype', '');
3378
- }
3379
-
3380
- tmp = elem.attr('media');
3381
- if(tmp){
3382
- src.media = tmp;
3383
- }
3384
- if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
3385
- if(src.server){
3386
- src.streamId = src.src;
3387
- } else {
3388
- mediaelement.parseRtmp(src);
3389
- }
3390
- }
3391
- return src;
3392
- };
3393
-
3394
-
3395
-
3396
- var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
3397
-
3398
- var loadTrackUi = function(){
3399
- if(loadTrackUi.loaded){return;}
3400
- loadTrackUi.loaded = true;
3401
- if(!options.noAutoTrack){
3402
- webshims.ready('WINDOWLOAD', function(){
3403
- loadThird();
3404
- webshims.loader.loadList(['track-ui']);
3405
- });
3406
- }
3407
- };
3408
-
3409
- var loadYt = (function(){
3410
- var loaded;
3411
- return function(){
3412
- if(loaded || !hasYt){return;}
3413
- loaded = true;
3414
- webshims.loader.loadScript("https://www.youtube.com/player_api");
3415
- $(function(){
3416
- webshims._polyfill(["mediaelement-yt"]);
3417
- });
3418
- };
3419
- })();
3420
- var loadThird = function(){
3421
- if(hasSwf){
3422
- loadSwf();
3423
- } else {
3424
- loadYt();
3425
- }
3426
- };
3427
-
3428
- webshims.addPolyfill('mediaelement-yt', {
3429
- test: !hasYt,
3430
- d: ['dom-support']
3431
- });
3432
-
3433
-
3434
-
3435
- mediaelement.mimeTypes = {
3436
- audio: {
3437
- //ogm shouldn´t be used!
3438
- 'audio/ogg': ['ogg','oga', 'ogm'],
3439
- 'audio/ogg;codecs="opus"': 'opus',
3440
- 'audio/mpeg': ['mp2','mp3','mpga','mpega'],
3441
- 'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
3442
- 'audio/wav': ['wav'],
3443
- 'audio/3gpp': ['3gp','3gpp'],
3444
- 'audio/webm': ['webm'],
3445
- 'audio/fla': ['flv', 'f4a', 'fla'],
3446
- 'application/x-mpegURL': ['m3u8', 'm3u']
3447
- },
3448
- video: {
3449
- //ogm shouldn´t be used!
3450
- 'video/ogg': ['ogg','ogv', 'ogm'],
3451
- 'video/mpeg': ['mpg','mpeg','mpe'],
3452
- 'video/mp4': ['mp4','mpg4', 'm4v'],
3453
- 'video/quicktime': ['mov','qt'],
3454
- 'video/x-msvideo': ['avi'],
3455
- 'video/x-ms-asf': ['asf', 'asx'],
3456
- 'video/flv': ['flv', 'f4v'],
3457
- 'video/3gpp': ['3gp','3gpp'],
3458
- 'video/webm': ['webm'],
3459
- 'application/x-mpegURL': ['m3u8', 'm3u'],
3460
- 'video/MP2T': ['ts']
3461
- }
3462
- }
3463
- ;
1192
+ };
3464
1193
 
3465
- mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
3466
1194
 
3467
- mediaelement.getTypeForSrc = function(src, nodeName){
3468
- if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
3469
- return 'video/youtube';
3470
- }
3471
- if(src.indexOf('rtmp') === 0){
3472
- return nodeName+'/rtmp';
3473
- }
3474
- src = src.split('?')[0].split('#')[0].split('.');
3475
- src = src[src.length - 1];
3476
- var mt;
3477
-
3478
- $.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
3479
- if(exts.indexOf(src) !== -1){
3480
- mt = mimeType;
3481
- return false;
1195
+ $.webshims.addReady(function(context, contextElem){
1196
+ $.each(elemMappings, function(name, role){
1197
+ var elems = $(name, context).add(contextElem.filter(name));
1198
+ for (var i = 0, len = elems.length; i < len; i++) {
1199
+ addRole(elems[i], role);
3482
1200
  }
3483
1201
  });
3484
- return mt;
3485
- };
3486
-
3487
-
3488
- mediaelement.srces = function(mediaElem, srces){
3489
- mediaElem = $(mediaElem);
3490
- if(!srces){
3491
- srces = [];
3492
- var nodeName = mediaElem[0].nodeName.toLowerCase();
3493
- var src = getSrcObj(mediaElem, nodeName);
1202
+ if (context === document) {
1203
+ var header = document.getElementsByTagName('header')[0];
1204
+ var footers = document.getElementsByTagName('footer');
1205
+ var footerLen = footers.length;
3494
1206
 
3495
- if(!src.src){
3496
- $('source', mediaElem).each(function(){
3497
- src = getSrcObj(this, nodeName);
3498
- if(src.src){srces.push(src);}
3499
- });
3500
- } else {
3501
- srces.push(src);
1207
+ if (header && !$(header).closest('section, article')[0]) {
1208
+ addRole(header, 'banner');
1209
+ }
1210
+ if (!footerLen) {
1211
+ return;
1212
+ }
1213
+ var footer = footers[footerLen - 1];
1214
+ if (!$(footer).closest('section, article')[0]) {
1215
+ addRole(footer, 'contentinfo');
3502
1216
  }
3503
- return srces;
3504
- } else {
3505
- webshims.error('setting sources was removed.');
3506
1217
  }
3507
- };
3508
-
1218
+ });
3509
1219
 
3510
- $.fn.loadMediaSrc = function(){
3511
- webshims.error('loadMediaSrc was removed.');
1220
+ })();
1221
+ });
1222
+ ;webshim.register('filereader', function($, webshim, window, document, undefined, featureOptions){
1223
+ "use strict";
1224
+ var mOxie, moxie, hasXDomain;
1225
+ var FormData = $.noop;
1226
+ var sel = 'input[type="file"].ws-filereader';
1227
+ var loadMoxie = function (){
1228
+ webshim.loader.loadList(['moxie']);
3512
1229
  };
3513
-
3514
- mediaelement.swfMimeTypes = ['video/3gpp', 'video/x-msvideo', 'video/quicktime', 'video/x-m4v', 'video/mp4', 'video/m4p', 'video/x-flv', 'video/flv', 'audio/mpeg', 'audio/aac', 'audio/mp4', 'audio/x-m4a', 'audio/m4a', 'audio/mp3', 'audio/x-fla', 'audio/fla', 'youtube/flv', 'video/jarisplayer', 'jarisplayer/jarisplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
3515
-
3516
- mediaelement.canThirdPlaySrces = function(mediaElem, srces){
3517
- var ret = '';
3518
- if(hasSwf || hasYt){
3519
- mediaElem = $(mediaElem);
3520
- srces = srces || mediaelement.srces(mediaElem);
3521
- $.each(srces, function(i, src){
3522
- if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
3523
- ret = src;
3524
- return false;
1230
+ var _createFilePicker = function(){
1231
+ var $input, picker, $parent, onReset;
1232
+ var input = this;
1233
+
1234
+ if(webshim.implement(input, 'filepicker')){
1235
+
1236
+ input = this;
1237
+ $input = $(this);
1238
+ $parent = $input.parent();
1239
+ onReset = function(){
1240
+ if(!input.value){
1241
+ $input.prop('value', '');
3525
1242
  }
1243
+ };
1244
+
1245
+ $input.attr('tabindex', '-1').on('mousedown.filereaderwaiting click.filereaderwaiting', false);
1246
+ $parent.addClass('ws-loading');
1247
+ picker = new mOxie.FileInput({
1248
+ browse_button: this,
1249
+ accept: $.prop(this, 'accept'),
1250
+ multiple: $.prop(this, 'multiple')
3526
1251
  });
3527
-
3528
- }
3529
-
3530
- return ret;
3531
- };
3532
-
3533
- var nativeCanPlayType = {};
3534
- mediaelement.canNativePlaySrces = function(mediaElem, srces){
3535
- var ret = '';
3536
- if(hasNative){
3537
- mediaElem = $(mediaElem);
3538
- var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
3539
- var nativeCanPlay = (nativeCanPlayType[nodeName] || {prop: {_supvalue: false}}).prop._supvalue || mediaElem[0].canPlayType;
3540
- if(!nativeCanPlay){return ret;}
3541
- srces = srces || mediaelement.srces(mediaElem);
3542
-
3543
- $.each(srces, function(i, src){
3544
- if(src.type && nativeCanPlay.call(mediaElem[0], src.type) ){
3545
- ret = src;
3546
- return false;
3547
- }
1252
+
1253
+ $input.jProp('form').on('reset', function(){
1254
+ setTimeout(onReset);
1255
+ });
1256
+ picker.onready = function(){
1257
+ $input.off('.fileraderwaiting');
1258
+ $parent.removeClass('ws-waiting');
1259
+ };
1260
+
1261
+ picker.onchange = function(e){
1262
+ webshim.data(input, 'fileList', e.target.files);
1263
+ $input.trigger('change');
1264
+ };
1265
+ picker.onmouseenter = function(){
1266
+ $input.trigger('mouseover');
1267
+ $parent.addClass('ws-mouseenter');
1268
+ };
1269
+ picker.onmouseleave = function(){
1270
+ $input.trigger('mouseout');
1271
+ $parent.removeClass('ws-mouseenter');
1272
+ };
1273
+ picker.onmousedown = function(){
1274
+ $input.trigger('mousedown');
1275
+ $parent.addClass('ws-active');
1276
+ };
1277
+ picker.onmouseup = function(){
1278
+ $input.trigger('mouseup');
1279
+ $parent.removeClass('ws-active');
1280
+ };
1281
+
1282
+ webshim.data(input, 'filePicker', picker);
1283
+
1284
+ webshim.ready('WINDOWLOAD', function(){
1285
+ var lastWidth;
1286
+ $input.onWSOff('updateshadowdom', function(){
1287
+ var curWitdth = input.offsetWidth;
1288
+ if(curWitdth && lastWidth != curWitdth){
1289
+ lastWidth = curWitdth;
1290
+ picker.refresh();
1291
+ }
1292
+ });
3548
1293
  });
1294
+
1295
+ webshim.addShadowDom();
1296
+
1297
+ picker.init();
1298
+ if(input.disabled){
1299
+ picker.disable(true);
1300
+ }
3549
1301
  }
3550
- return ret;
3551
1302
  };
3552
- var emptyType = (/^\s*application\/octet\-stream\s*$/i);
3553
- var getRemoveEmptyType = function(){
3554
- var ret = emptyType.test($.attr(this, 'type') || '');
3555
- if(ret){
3556
- $(this).removeAttr('type');
3557
- }
3558
- return ret;
1303
+ var getFileNames = function(file){
1304
+ return file.name;
3559
1305
  };
3560
- mediaelement.setError = function(elem, message){
3561
- if($('source', elem).filter(getRemoveEmptyType).length){
3562
- webshims.error('"application/octet-stream" is a useless mimetype for audio/video. Please change this attribute.');
3563
- try {
3564
- $(elem).mediaLoad();
3565
- } catch(er){}
3566
- } else {
3567
- if(!message){
3568
- message = "can't play sources";
3569
- }
3570
- $(elem).pause().data('mediaerror', message);
3571
- webshims.error('mediaelementError: '+ message);
3572
- setTimeout(function(){
3573
- if($(elem).data('mediaerror')){
3574
- $(elem).addClass('media-error').trigger('mediaerror');
1306
+ var createFilePicker = function(){
1307
+ var elem = this;
1308
+ loadMoxie();
1309
+ $(elem)
1310
+ .on('mousedown.filereaderwaiting click.filereaderwaiting', false)
1311
+ .parent()
1312
+ .addClass('ws-loading')
1313
+ ;
1314
+ webshim.ready('moxie', function(){
1315
+ createFilePicker.call(elem);
1316
+ });
1317
+ };
1318
+ var noxhr = /^(?:script|jsonp)$/i;
1319
+ var notReadyYet = function(){
1320
+ loadMoxie();
1321
+ webshim.error('filereader/formdata not ready yet. please wait for moxie to load `webshim.ready("moxie", callbackFn);`` or wait for the first change event on input[type="file"].ws-filereader.')
1322
+ };
1323
+ var inputValueDesc = webshim.defineNodeNameProperty('input', 'value', {
1324
+ prop: {
1325
+ get: function(){
1326
+ var fileList = webshim.data(this, 'fileList');
1327
+
1328
+ if(fileList && fileList.map){
1329
+ return fileList.map(getFileNames).join(', ');
1330
+ }
1331
+
1332
+ return inputValueDesc.prop._supget.call(this);
1333
+ },
1334
+ set: function(val){
1335
+ if(val === '' && this.type == 'file' && $(this).hasClass('ws-filereader')){
1336
+ webshim.data(this, 'fileList', []);
1337
+ }
1338
+ inputValueDesc.prop._supset.call(this);
3575
1339
  }
3576
- }, 1);
1340
+ }
3577
1341
  }
3578
-
3579
-
1342
+ );
1343
+ var shimMoxiePath = webshim.cfg.basePath+'moxie/';
1344
+ var crossXMLMessage = 'You nedd a crossdomain.xml to get all "filereader" / "XHR2" / "CORS" features to work. Or host moxie.swf/moxie.xap on your server an configure filereader options: "swfpath"/"xappath"';
1345
+ var testMoxie = function(options){
1346
+ return (options.wsType == 'moxie' || (options.data && options.data instanceof mOxie.FormData) || (options.crossDomain && $.support.cors !== false && hasXDomain != 'no' && !noxhr.test(options.dataType || '')));
3580
1347
  };
3581
-
3582
- var handleThird = (function(){
3583
- var requested;
3584
- var readyType = hasSwf ? swfType : 'mediaelement-yt';
3585
- return function( mediaElem, ret, data ){
3586
- //readd to ready
1348
+ var createMoxieTransport = function (options){
1349
+
1350
+ if(testMoxie(options)){
1351
+ var ajax;
1352
+ webshim.info('moxie transfer used for $.ajax');
1353
+ if(hasXDomain == 'no'){
1354
+ webshim.error(crossXMLMessage);
1355
+ }
1356
+ return {
1357
+ send: function( headers, completeCallback ) {
1358
+
1359
+ var proressEvent = function(obj, name){
1360
+ if(options[name]){
1361
+ var called = false;
1362
+ ajax.addEventListener('load', function(e){
1363
+ if(!called){
1364
+ options[name]({type: 'progress', lengthComputable: true, total: 1, loaded: 1});
1365
+ } else if(called.lengthComputable && called.total > called.loaded){
1366
+ options[name]({type: 'progress', lengthComputable: true, total: called.total, loaded: called.total});
1367
+ }
1368
+ });
1369
+ obj.addEventListener('progress', function(e){
1370
+ called = e;
1371
+ options[name](e);
1372
+ });
1373
+ }
1374
+ };
1375
+ ajax = new moxie.xhr.XMLHttpRequest();
3587
1376
 
3588
- webshims.ready(readyType, function(){
3589
- if(mediaelement.createSWF && $(mediaElem).parent()[0]){
3590
- mediaelement.createSWF( mediaElem, ret, data );
3591
- } else if(!requested) {
3592
- requested = true;
3593
- loadThird();
3594
-
3595
- handleThird( mediaElem, ret, data );
1377
+ ajax.open(options.type, options.url, options.async, options.username, options.password);
1378
+
1379
+ proressEvent(ajax.upload, featureOptions.uploadprogress);
1380
+ proressEvent(ajax.upload, featureOptions.progress);
1381
+
1382
+ ajax.addEventListener('load', function(e){
1383
+ var responses = {
1384
+ text: ajax.responseText,
1385
+ xml: ajax.responseXML
1386
+ };
1387
+ completeCallback(ajax.status, ajax.statusText, responses, ajax.getAllResponseHeaders());
1388
+ });
1389
+
1390
+ if(options.xhrFields && options.xhrFields.withCredentials){
1391
+ ajax.withCredentials = true;
1392
+ }
1393
+
1394
+ if(options.timeout){
1395
+ ajax.timeout = options.timeout;
1396
+ }
1397
+
1398
+ $.each(headers, function(name, value){
1399
+ ajax.setRequestHeader(name, value);
1400
+ });
1401
+
1402
+
1403
+ ajax.send(options.data);
1404
+
1405
+ },
1406
+ abort: function() {
1407
+ if(ajax){
1408
+ ajax.abort();
1409
+ }
3596
1410
  }
3597
- });
3598
- if(!requested && hasYt && !mediaelement.createSWF){
3599
- loadYt();
3600
- }
3601
- };
3602
- })();
3603
-
3604
- var stepSources = function(elem, data, useSwf, _srces, _noLoop){
3605
- var ret;
3606
- if(useSwf || (useSwf !== false && data && data.isActive == 'third')){
3607
- ret = mediaelement.canThirdPlaySrces(elem, _srces);
3608
- if(!ret){
3609
- if(_noLoop){
3610
- mediaelement.setError(elem, false);
3611
- } else {
3612
- stepSources(elem, data, false, _srces, true);
1411
+ };
1412
+ }
1413
+ };
1414
+ var transports = {
1415
+ //based on script: https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest
1416
+ xdomain: (function(){
1417
+ var httpRegEx = /^https?:\/\//i;
1418
+ var getOrPostRegEx = /^get|post$/i;
1419
+ var sameSchemeRegEx = new RegExp('^'+location.protocol, 'i');
1420
+ return function(options, userOptions, jqXHR) {
1421
+
1422
+ // Only continue if the request is: asynchronous, uses GET or POST method, has HTTP or HTTPS protocol, and has the same scheme as the calling page
1423
+ if (!options.crossDomain || options.username || (options.xhrFields && options.xhrFields.withCredentials) || !options.async || !getOrPostRegEx.test(options.type) || !httpRegEx.test(options.url) || !sameSchemeRegEx.test(options.url) || (options.data && options.data instanceof mOxie.FormData) || noxhr.test(options.dataType || '')) {
1424
+ return;
3613
1425
  }
3614
- } else {
3615
- handleThird(elem, ret, data);
3616
- }
3617
- } else {
3618
- ret = mediaelement.canNativePlaySrces(elem, _srces);
3619
- if(!ret){
3620
- if(_noLoop){
3621
- mediaelement.setError(elem, false);
3622
- if(data && data.isActive == 'third') {
3623
- mediaelement.setActive(elem, 'html5', data);
1426
+
1427
+ var xdr = null;
1428
+ webshim.info('xdomain transport used.');
1429
+
1430
+ return {
1431
+ send: function(headers, complete) {
1432
+ var postData = '';
1433
+ var userType = (userOptions.dataType || '').toLowerCase();
1434
+
1435
+ xdr = new XDomainRequest();
1436
+ if (/^\d+$/.test(userOptions.timeout)) {
1437
+ xdr.timeout = userOptions.timeout;
1438
+ }
1439
+
1440
+ xdr.ontimeout = function() {
1441
+ complete(500, 'timeout');
1442
+ };
1443
+
1444
+ xdr.onload = function() {
1445
+ var allResponseHeaders = 'Content-Length: ' + xdr.responseText.length + '\r\nContent-Type: ' + xdr.contentType;
1446
+ var status = {
1447
+ code: xdr.status || 200,
1448
+ message: xdr.statusText || 'OK'
1449
+ };
1450
+ var responses = {
1451
+ text: xdr.responseText,
1452
+ xml: xdr.responseXML
1453
+ };
1454
+ try {
1455
+ if (userType === 'html' || /text\/html/i.test(xdr.contentType)) {
1456
+ responses.html = xdr.responseText;
1457
+ } else if (userType === 'json' || (userType !== 'text' && /\/json/i.test(xdr.contentType))) {
1458
+ try {
1459
+ responses.json = $.parseJSON(xdr.responseText);
1460
+ } catch(e) {
1461
+
1462
+ }
1463
+ } else if (userType === 'xml' && !xdr.responseXML) {
1464
+ var doc;
1465
+ try {
1466
+ doc = new ActiveXObject('Microsoft.XMLDOM');
1467
+ doc.async = false;
1468
+ doc.loadXML(xdr.responseText);
1469
+ } catch(e) {
1470
+
1471
+ }
1472
+
1473
+ responses.xml = doc;
1474
+ }
1475
+ } catch(parseMessage) {}
1476
+ complete(status.code, status.message, responses, allResponseHeaders);
1477
+ };
1478
+
1479
+ // set an empty handler for 'onprogress' so requests don't get aborted
1480
+ xdr.onprogress = function(){};
1481
+ xdr.onerror = function() {
1482
+ complete(500, 'error', {
1483
+ text: xdr.responseText
1484
+ });
1485
+ };
1486
+
1487
+ if (userOptions.data) {
1488
+ postData = ($.type(userOptions.data) === 'string') ? userOptions.data : $.param(userOptions.data);
1489
+ }
1490
+ xdr.open(options.type, options.url);
1491
+ xdr.send(postData);
1492
+ },
1493
+ abort: function() {
1494
+ if (xdr) {
1495
+ xdr.abort();
1496
+ }
3624
1497
  }
3625
- } else {
3626
- stepSources(elem, data, true, _srces, true);
3627
- }
3628
- } else if(data && data.isActive == 'third') {
3629
- mediaelement.setActive(elem, 'html5', data);
1498
+ };
1499
+ };
1500
+ })(),
1501
+ moxie: function (options, originalOptions, jqXHR){
1502
+ if(testMoxie(options)){
1503
+ loadMoxie(options);
1504
+ var ajax;
1505
+
1506
+ var tmpTransport = {
1507
+ send: function( headers, completeCallback ) {
1508
+ ajax = true;
1509
+ webshim.ready('moxie', function(){
1510
+ if(ajax){
1511
+ ajax = createMoxieTransport(options, originalOptions, jqXHR);
1512
+ tmpTransport.send = ajax.send;
1513
+ tmpTransport.abort = ajax.abort;
1514
+ ajax.send(headers, completeCallback);
1515
+ }
1516
+ });
1517
+ },
1518
+ abort: function() {
1519
+ ajax = false;
1520
+ }
1521
+ };
1522
+ return tmpTransport;
3630
1523
  }
3631
1524
  }
3632
1525
  };
3633
- var stopParent = /^(?:embed|object|datalist)$/i;
3634
- var selectSource = function(elem, data){
3635
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
3636
- var _srces = mediaelement.srces(elem);
3637
- var parent = elem.parentNode;
3638
-
3639
- clearTimeout(baseData.loadTimer);
3640
- $(elem).removeClass('media-error');
3641
- $.data(elem, 'mediaerror', false);
3642
-
3643
- if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
3644
- data = data || webshims.data(elem, 'mediaelement');
3645
- if(mediaelement.sortMedia){
3646
- _srces.sort(mediaelement.sortMedia);
1526
+
1527
+ if(!featureOptions.progress){
1528
+ featureOptions.progress = 'onprogress';
1529
+ }
1530
+
1531
+ if(!featureOptions.uploadprogress){
1532
+ featureOptions.uploadprogress = 'onuploadprogress';
1533
+ }
1534
+
1535
+ if(!featureOptions.swfpath){
1536
+ featureOptions.swfpath = shimMoxiePath+'flash/Moxie.cdn.swf';
1537
+ }
1538
+ if(!featureOptions.xappath){
1539
+ featureOptions.xappath = shimMoxiePath+'silverlight/Moxie.cdn.xap';
1540
+ }
1541
+
1542
+ if($.support.cors !== false || !window.XDomainRequest){
1543
+ delete transports.xdomain;
1544
+ }
1545
+
1546
+
1547
+ $.ajaxTransport("+*", function( options, originalOptions, jqXHR ) {
1548
+ var ajax, type;
1549
+
1550
+ if(options.wsType || transports[transports]){
1551
+ ajax = transports[transports](options, originalOptions, jqXHR);
3647
1552
  }
3648
- stepSources(elem, data, options.preferFlash || undefined, _srces);
3649
- };
3650
- mediaelement.selectSource = selectSource;
3651
-
3652
-
3653
- $(document).on('ended', function(e){
3654
- var data = webshims.data(e.target, 'mediaelement');
3655
- if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
3656
- setTimeout(function(){
3657
- if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
3658
- $(e.target).prop('currentTime', 0).play();
3659
- }, 1);
3660
-
1553
+ if(!ajax){
1554
+ for(type in transports){
1555
+ ajax = transports[type](options, originalOptions, jqXHR);
1556
+ if(ajax){break;}
1557
+ }
1558
+ }
1559
+ return ajax;
3661
1560
  });
3662
-
3663
- var handleMedia = false;
3664
- var initMediaElements = function(){
3665
- var testFixMedia = function(){
3666
- if(webshims.implement(this, 'mediaelement')){
3667
- selectSource(this);
3668
- if(!Modernizr.mediaDefaultMuted && $.attr(this, 'muted') != null){
3669
- $.prop(this, 'muted', true);
1561
+
1562
+ webshim.defineNodeNameProperty('input', 'files', {
1563
+ prop: {
1564
+ writeable: false,
1565
+ get: function(){
1566
+ if(this.type != 'file'){return null;}
1567
+ if(!$(this).is('.ws-filereader')){
1568
+ webshim.info("please add the 'ws-filereader' class to your input[type='file'] to implement files-property");
1569
+ }
1570
+ return webshim.data(this, 'fileList') || [];
3670
1571
  }
3671
1572
  }
3672
-
3673
- };
3674
-
3675
- webshims.ready('dom-support', function(){
3676
- handleMedia = true;
3677
-
3678
- if(!supportsLoop){
3679
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
3680
- }
3681
-
3682
- ['audio', 'video'].forEach(function(nodeName){
3683
- var supLoad;
3684
- supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
3685
- prop: {
3686
- value: function(){
3687
- var data = webshims.data(this, 'mediaelement');
3688
- selectSource(this, data);
3689
- if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
3690
- supLoad.prop._supvalue.apply(this, arguments);
3691
- }
3692
- if(!loadTrackUi.loaded && $('track', this).length){
3693
- loadTrackUi();
3694
- }
3695
- $(this).triggerHandler('wsmediareload');
3696
- }
1573
+ }
1574
+ );
1575
+
1576
+ webshim.reflectProperties(['input'], ['accept']);
1577
+
1578
+ if($('<input />').prop('multiple') == null){
1579
+ webshim.defineNodeNamesBooleanProperty(['input'], ['multiple']);
1580
+ }
1581
+
1582
+ webshim.onNodeNamesPropertyModify('input', 'disabled', function(value, boolVal, type){
1583
+ var picker = webshim.data(this, 'filePicker');
1584
+ if(picker){
1585
+ picker.disable(boolVal);
1586
+ }
1587
+ });
1588
+
1589
+ window.FileReader = notReadyYet;
1590
+ window.FormData = notReadyYet;
1591
+ webshim.ready('moxie', function(){
1592
+ var wsMimes = 'application/xml,xml';
1593
+ moxie = window.moxie;
1594
+ mOxie = window.mOxie;
1595
+
1596
+ mOxie.Env.swf_url = featureOptions.swfpath;
1597
+ mOxie.Env.xap_url = featureOptions.xappath;
1598
+
1599
+ window.FileReader = mOxie.FileReader;
1600
+
1601
+ window.FormData = function(form){
1602
+ var appendData, i, len, files, fileI, fileLen, inputName;
1603
+ var moxieData = new mOxie.FormData();
1604
+ if(form && $.nodeName(form, 'form')){
1605
+ appendData = $(form).serializeArray();
1606
+ for(i = 0; i < appendData.length; i++){
1607
+ if(Array.isArray(appendData[i].value)){
1608
+ appendData[i].value.forEach(function(val){
1609
+ moxieData.append(appendData[i].name, val);
1610
+ });
1611
+ } else {
1612
+ moxieData.append(appendData[i].name, appendData[i].value);
3697
1613
  }
3698
- });
3699
- nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
3700
- prop: {
3701
- value: function(type){
3702
- var ret = '';
3703
- if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
3704
- ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
3705
- if(ret == 'no'){
3706
- ret = '';
3707
- }
1614
+ }
1615
+
1616
+ appendData = form.querySelectorAll('input[type="file"][name]');
1617
+
1618
+ for(i = 0, len = appendData.length; i < appendData.length; i++){
1619
+ inputName = appendData[i].name;
1620
+ if(inputName && !$(appendData[i]).is(':disabled')){
1621
+ files = $.prop(appendData[i], 'files') || [];
1622
+ if(files.length){
1623
+ if(files.length > 1){
1624
+ webshim.error('FormData shim can only handle one file per ajax. Use multiple ajax request. One per file.');
3708
1625
  }
3709
- if(!ret && hasSwf){
3710
- type = $.trim((type || '').split(';')[0]);
3711
- if(mediaelement.swfMimeTypes.indexOf(type) != -1){
3712
- ret = 'maybe';
3713
- }
1626
+ for(fileI = 0, fileLen = files.length; fileI < fileLen; fileI++){
1627
+ moxieData.append(inputName, files[fileI]);
3714
1628
  }
3715
- return ret;
3716
1629
  }
3717
1630
  }
3718
- });
3719
- });
3720
-
3721
-
3722
- webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
3723
- set: function(){
3724
- var elem = this;
3725
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
3726
- clearTimeout(baseData.loadTimer);
3727
- baseData.loadTimer = setTimeout(function(){
3728
- selectSource(elem);
3729
- elem = null;
3730
- }, 9);
3731
- }
3732
- });
3733
-
3734
-
3735
- webshims.addReady(function(context, insertedElement){
3736
- var media = $('video, audio', context)
3737
- .add(insertedElement.filter('video, audio'))
3738
- .each(testFixMedia)
3739
- ;
3740
- if(!loadTrackUi.loaded && $('track', media).length){
3741
- loadTrackUi();
3742
- }
3743
- media = null;
3744
- });
3745
- });
3746
-
3747
- if(hasNative && !handleMedia){
3748
- webshims.addReady(function(context, insertedElement){
3749
- if(!handleMedia){
3750
- $('video, audio', context)
3751
- .add(insertedElement.filter('video, audio'))
3752
- .each(function(){
3753
- if(!mediaelement.canNativePlaySrces(this)){
3754
- loadThird();
3755
- handleMedia = true;
3756
- return false;
3757
- }
3758
- })
3759
- ;
3760
1631
  }
3761
- });
1632
+ }
1633
+
1634
+ return moxieData;
1635
+ };
1636
+ FormData = window.FormData;
1637
+
1638
+ createFilePicker = _createFilePicker;
1639
+ transports.moxie = createMoxieTransport;
1640
+
1641
+ featureOptions.mimeTypes = (featureOptions.mimeTypes) ? wsMimes+','+featureOptions.mimeTypes : wsMimes;
1642
+ try {
1643
+ mOxie.Mime.addMimeType(featureOptions.mimeTypes);
1644
+ } catch(e){
1645
+ webshim.warn('mimetype to moxie error: '+e);
3762
1646
  }
3763
- };
3764
-
3765
1647
 
3766
- //set native implementation ready, before swf api is retested
3767
- if(hasNative){
3768
- webshims.isReady('mediaelement-core', true);
3769
- initMediaElements();
3770
- webshims.ready('WINDOWLOAD mediaelement', loadThird);
3771
- } else {
3772
- webshims.ready(swfType, initMediaElements);
1648
+ });
1649
+
1650
+ webshim.addReady(function(context, contextElem){
1651
+ $(context.querySelectorAll(sel)).add(contextElem.filter(sel)).each(createFilePicker);
1652
+ });
1653
+ webshim.ready('WINDOWLOAD', loadMoxie);
1654
+
1655
+ if(webshim.cfg.debug !== false && featureOptions.swfpath.indexOf((location.protocol+'//'+location.hostname)) && featureOptions.swfpath.indexOf(('https://'+location.hostname))){
1656
+ webshim.ready('WINDOWLOAD', function(){
1657
+
1658
+ var printMessage = function(){
1659
+ if(hasXDomain == 'no'){
1660
+ webshim.error(crossXMLMessage);
1661
+ }
1662
+ };
1663
+
1664
+ try {
1665
+ hasXDomain = sessionStorage.getItem('wsXdomain.xml');
1666
+ } catch(e){}
1667
+ printMessage();
1668
+ if(hasXDomain == null){
1669
+ $.ajax({
1670
+ url: 'crossdomain.xml',
1671
+ type: 'HEAD',
1672
+ dataType: 'xml',
1673
+ success: function(){
1674
+ hasXDomain = 'yes';
1675
+ },
1676
+ error: function(){
1677
+ hasXDomain = 'no';
1678
+ },
1679
+ complete: function(){
1680
+ try {
1681
+ sessionStorage.setItem('wsXdomain.xml', hasXDomain);
1682
+ } catch(e){}
1683
+ printMessage();
1684
+ }
1685
+ });
1686
+ }
1687
+ });
3773
1688
  }
3774
- webshims.ready('track', loadTrackUi);
3775
1689
  });
3776
-
3777
- })(Modernizr, webshims);
3778
1690
  ;webshims.register('mediaelement-jaris', function($, webshims, window, document, undefined, options){
3779
1691
  "use strict";
3780
1692
 
@@ -4478,7 +2390,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
4478
2390
  resetSwfProps(data);
4479
2391
  } else {
4480
2392
  $(document.getElementById('wrapper-'+ elemId )).remove();
4481
- box = $('<div class="polyfill-'+ (elemNodeName) +' polyfill-mediaelement" id="wrapper-'+ elemId +'"><div id="'+ elemId +'"></div>')
2393
+ box = $('<div class="polyfill-'+ (elemNodeName) +' polyfill-mediaelement '+ webshims.shadowClass +'" id="wrapper-'+ elemId +'"><div id="'+ elemId +'"></div>')
4482
2394
  .css({
4483
2395
  position: 'relative',
4484
2396
  overflow: 'hidden'