webshims-rails 0.4.7 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +15 -0
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/extras/custom-validity.js +1 -1
  4. data/vendor/assets/javascripts/webshims/extras/mousepress.js +1 -1
  5. data/vendor/assets/javascripts/webshims/polyfiller.js +197 -166
  6. data/vendor/assets/javascripts/webshims/shims/combos/1.js +1711 -1609
  7. data/vendor/assets/javascripts/webshims/shims/combos/10.js +2575 -2253
  8. data/vendor/assets/javascripts/webshims/shims/combos/11.js +2452 -1476
  9. data/vendor/assets/javascripts/webshims/shims/combos/12.js +1405 -1159
  10. data/vendor/assets/javascripts/webshims/shims/combos/13.js +1316 -963
  11. data/vendor/assets/javascripts/webshims/shims/combos/14.js +1862 -179
  12. data/vendor/assets/javascripts/webshims/shims/combos/15.js +4327 -287
  13. data/vendor/assets/javascripts/webshims/shims/combos/16.js +3887 -586
  14. data/vendor/assets/javascripts/webshims/shims/combos/17.js +2911 -2159
  15. data/vendor/assets/javascripts/webshims/shims/combos/18.js +3425 -1730
  16. data/vendor/assets/javascripts/webshims/shims/combos/19.js +2854 -1203
  17. data/vendor/assets/javascripts/webshims/shims/combos/2.js +3351 -2130
  18. data/vendor/assets/javascripts/webshims/shims/combos/20.js +2426 -581
  19. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1915 -1574
  20. data/vendor/assets/javascripts/webshims/shims/combos/22.js +864 -2275
  21. data/vendor/assets/javascripts/webshims/shims/combos/23.js +609 -1811
  22. data/vendor/assets/javascripts/webshims/shims/combos/3.js +1655 -2736
  23. data/vendor/assets/javascripts/webshims/shims/combos/4.js +1037 -603
  24. data/vendor/assets/javascripts/webshims/shims/combos/5.js +3100 -773
  25. data/vendor/assets/javascripts/webshims/shims/combos/6.js +3631 -840
  26. data/vendor/assets/javascripts/webshims/shims/combos/7.js +3596 -1354
  27. data/vendor/assets/javascripts/webshims/shims/combos/8.js +1731 -188
  28. data/vendor/assets/javascripts/webshims/shims/combos/9.js +3243 -1431
  29. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +107 -18
  30. data/vendor/assets/javascripts/webshims/shims/es5.js +1 -0
  31. data/vendor/assets/javascripts/webshims/shims/form-core.js +553 -464
  32. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +160 -154
  33. data/vendor/assets/javascripts/webshims/shims/form-message.js +73 -49
  34. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +18 -1
  35. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +161 -36
  36. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +2130 -813
  37. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +206 -58
  38. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ar.js → formcfg-ar.js} +30 -0
  39. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ch-ZN.js → formcfg-ch-ZN.js} +31 -0
  40. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-de.txt → formcfg-de.txt} +50 -11
  41. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-el.js → formcfg-el.js} +31 -0
  42. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-en.txt → formcfg-en.txt} +44 -11
  43. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-es.js → formcfg-es.js} +31 -0
  44. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-fr.js → formcfg-fr.js} +31 -0
  45. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-he.js → formcfg-he.js} +31 -0
  46. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-hi.js → formcfg-hi.js} +31 -0
  47. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-hu.js → formcfg-hu.js} +31 -0
  48. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-it.js → formcfg-it.js} +31 -0
  49. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ja.js → formcfg-ja.js} +31 -0
  50. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-nl.js → formcfg-nl.js} +31 -0
  51. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-pt-PT.js → formcfg-pt-PT.js} +31 -0
  52. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ru.js → formcfg-ru.js} +31 -0
  53. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-sv.js → formcfg-sv.js} +32 -0
  54. data/vendor/assets/javascripts/webshims/shims/json-storage.js +16 -10
  55. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +155 -122
  56. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +76 -41
  57. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +8 -16
  58. data/vendor/assets/javascripts/webshims/shims/range-ui.js +388 -0
  59. data/vendor/assets/javascripts/webshims/shims/styles/config.rb +12 -0
  60. data/vendor/assets/javascripts/webshims/shims/styles/forms.png +0 -0
  61. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +1186 -0
  62. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +868 -548
  63. data/vendor/assets/javascripts/webshims/shims/styles/vertical-range.png +0 -0
  64. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  65. data/vendor/assets/javascripts/webshims/shims/swfmini.js +497 -0
  66. data/vendor/assets/javascripts/webshims/shims/track-ui.js +3 -0
  67. data/vendor/assets/javascripts/webshims/shims/track.js +29 -29
  68. metadata +26 -125
  69. data/vendor/assets/javascripts/webshims/minified/extras/custom-validity.js +0 -1
  70. data/vendor/assets/javascripts/webshims/minified/extras/modernizr-custom.js +0 -1
  71. data/vendor/assets/javascripts/webshims/minified/extras/mousepress.js +0 -1
  72. data/vendor/assets/javascripts/webshims/minified/polyfiller.js +0 -1
  73. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/canvas2png.js +0 -1
  74. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/flashcanvas.js +0 -1
  75. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/flashcanvas.swf +0 -0
  76. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/proxy.php +0 -73
  77. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/save.php +0 -49
  78. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/canvas2png.js +0 -1
  79. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/flash10canvas.swf +0 -0
  80. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/flash9canvas.swf +0 -0
  81. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/flashcanvas.js +0 -1
  82. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/proxy.php +0 -73
  83. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/save.php +0 -49
  84. data/vendor/assets/javascripts/webshims/minified/shims/combos/1.js +0 -1
  85. data/vendor/assets/javascripts/webshims/minified/shims/combos/10.js +0 -1
  86. data/vendor/assets/javascripts/webshims/minified/shims/combos/11.js +0 -1
  87. data/vendor/assets/javascripts/webshims/minified/shims/combos/12.js +0 -1
  88. data/vendor/assets/javascripts/webshims/minified/shims/combos/13.js +0 -1
  89. data/vendor/assets/javascripts/webshims/minified/shims/combos/14.js +0 -1
  90. data/vendor/assets/javascripts/webshims/minified/shims/combos/15.js +0 -1
  91. data/vendor/assets/javascripts/webshims/minified/shims/combos/16.js +0 -1
  92. data/vendor/assets/javascripts/webshims/minified/shims/combos/17.js +0 -1
  93. data/vendor/assets/javascripts/webshims/minified/shims/combos/18.js +0 -1
  94. data/vendor/assets/javascripts/webshims/minified/shims/combos/19.js +0 -1
  95. data/vendor/assets/javascripts/webshims/minified/shims/combos/2.js +0 -1
  96. data/vendor/assets/javascripts/webshims/minified/shims/combos/20.js +0 -1
  97. data/vendor/assets/javascripts/webshims/minified/shims/combos/21.js +0 -1
  98. data/vendor/assets/javascripts/webshims/minified/shims/combos/22.js +0 -1
  99. data/vendor/assets/javascripts/webshims/minified/shims/combos/23.js +0 -1
  100. data/vendor/assets/javascripts/webshims/minified/shims/combos/24.js +0 -1
  101. data/vendor/assets/javascripts/webshims/minified/shims/combos/25.js +0 -1
  102. data/vendor/assets/javascripts/webshims/minified/shims/combos/26.js +0 -1
  103. data/vendor/assets/javascripts/webshims/minified/shims/combos/27.js +0 -1
  104. data/vendor/assets/javascripts/webshims/minified/shims/combos/3.js +0 -1
  105. data/vendor/assets/javascripts/webshims/minified/shims/combos/4.js +0 -1
  106. data/vendor/assets/javascripts/webshims/minified/shims/combos/5.js +0 -1
  107. data/vendor/assets/javascripts/webshims/minified/shims/combos/59.js +0 -1
  108. data/vendor/assets/javascripts/webshims/minified/shims/combos/6.js +0 -1
  109. data/vendor/assets/javascripts/webshims/minified/shims/combos/7.js +0 -1
  110. data/vendor/assets/javascripts/webshims/minified/shims/combos/8.js +0 -1
  111. data/vendor/assets/javascripts/webshims/minified/shims/combos/9.js +0 -1
  112. data/vendor/assets/javascripts/webshims/minified/shims/details.js +0 -1
  113. data/vendor/assets/javascripts/webshims/minified/shims/dom-extend.js +0 -1
  114. data/vendor/assets/javascripts/webshims/minified/shims/es5.js +0 -1
  115. data/vendor/assets/javascripts/webshims/minified/shims/excanvas.js +0 -1
  116. data/vendor/assets/javascripts/webshims/minified/shims/form-core.js +0 -1
  117. data/vendor/assets/javascripts/webshims/minified/shims/form-datalist.js +0 -1
  118. data/vendor/assets/javascripts/webshims/minified/shims/form-message.js +0 -1
  119. data/vendor/assets/javascripts/webshims/minified/shims/form-native-extend.js +0 -1
  120. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-api.js +0 -1
  121. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-ui.js +0 -1
  122. data/vendor/assets/javascripts/webshims/minified/shims/form-shim-extend.js +0 -1
  123. data/vendor/assets/javascripts/webshims/minified/shims/geolocation.js +0 -1
  124. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ar.js +0 -1
  125. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ch-ZN.js +0 -1
  126. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-de.txt +0 -33
  127. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-el.js +0 -1
  128. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-en.txt +0 -34
  129. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-es.js +0 -1
  130. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-fr.js +0 -1
  131. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-he.js +0 -1
  132. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-hi.js +0 -1
  133. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-hu.js +0 -1
  134. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-it.js +0 -1
  135. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ja.js +0 -1
  136. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-nl.js +0 -1
  137. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-pt-PT.js +0 -1
  138. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ru.js +0 -1
  139. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-sv.js +0 -1
  140. data/vendor/assets/javascripts/webshims/minified/shims/json-storage.js +0 -1
  141. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/license.txt +0 -1
  142. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/player.swf +0 -0
  143. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/readme.html +0 -87
  144. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-core.js +0 -1
  145. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-jaris.js +0 -1
  146. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-native-fix.js +0 -1
  147. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-swf.js +0 -1
  148. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-yt.js +0 -1
  149. data/vendor/assets/javascripts/webshims/minified/shims/styles/details-arrows.png +0 -0
  150. data/vendor/assets/javascripts/webshims/minified/shims/styles/forms.png +0 -0
  151. data/vendor/assets/javascripts/webshims/minified/shims/styles/polyfill-loader.gif +0 -0
  152. data/vendor/assets/javascripts/webshims/minified/shims/styles/shim.css +0 -1
  153. data/vendor/assets/javascripts/webshims/minified/shims/swf/JarisFLVPlayer.swf +0 -0
  154. data/vendor/assets/javascripts/webshims/minified/shims/swf/jwwebshims.swf +0 -0
  155. data/vendor/assets/javascripts/webshims/minified/shims/swf/localStorage.swf +0 -0
  156. data/vendor/assets/javascripts/webshims/minified/shims/track-ui.js +0 -1
  157. data/vendor/assets/javascripts/webshims/minified/shims/track.js +0 -1
  158. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/README +0 -62
  159. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/README +0 -82
  160. data/vendor/assets/javascripts/webshims/shims/combos/24.js +0 -2872
  161. data/vendor/assets/javascripts/webshims/shims/combos/25.js +0 -2376
  162. data/vendor/assets/javascripts/webshims/shims/combos/26.js +0 -3009
  163. data/vendor/assets/javascripts/webshims/shims/combos/27.js +0 -4150
  164. data/vendor/assets/javascripts/webshims/shims/combos/59.js +0 -1747
  165. data/vendor/assets/javascripts/webshims/shims/jwplayer/license.txt +0 -1
  166. data/vendor/assets/javascripts/webshims/shims/jwplayer/player.swf +0 -0
  167. data/vendor/assets/javascripts/webshims/shims/jwplayer/readme.html +0 -87
  168. data/vendor/assets/javascripts/webshims/shims/mediaelement-swf.js +0 -972
@@ -1,1755 +1,1857 @@
1
- // vim: ts=4 sts=4 sw=4 expandtab
2
- // -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
3
- // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
4
- // -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
5
- // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
6
- // -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
7
- // -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
8
- // -- kossnocorp Sasha Koss XXX TODO License or CLA
9
- // -- bryanforbes Bryan Forbes XXX TODO License or CLA
10
- // -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
11
- // -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
12
- // -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
13
- // -- bbqsrc Brendan Molloy XXX TODO License or CLA
14
- // -- iwyg XXX TODO License or CLA
15
- // -- DomenicDenicola Domenic Denicola XXX TODO License or CLA
16
- // -- xavierm02 Montillet Xavier XXX TODO License or CLA
17
- // -- Raynos Raynos XXX TODO License or CLA
18
- // -- samsonjs Sami Samhuri XXX TODO License or CLA
19
- // -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
20
- // -- lexer Alexey Zakharov XXX TODO License or CLA
21
-
22
- /*!
23
- Copyright (c) 2009, 280 North Inc. http://280north.com/
24
- MIT License. http://github.com/280north/narwhal/blob/master/README.md
25
- */
26
-
27
- (function (undefined) {
28
-
29
- /**
30
- * Brings an environment as close to ECMAScript 5 compliance
31
- * as is possible with the facilities of erstwhile engines.
32
- *
33
- * ES5 Draft
34
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-050.pdf
35
- *
36
- * NOTE: this is a draft, and as such, the URL is subject to change. If the
37
- * link is broken, check in the parent directory for the latest TC39 PDF.
38
- * http://www.ecma-international.org/publications/files/drafts/
39
- *
40
- * Previous ES5 Draft
41
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
42
- * This is a broken link to the previous draft of ES5 on which most of the
43
- * numbered specification references and quotes herein were taken. Updating
44
- * these references and quotes to reflect the new document would be a welcome
45
- * volunteer project.
46
- *
47
- * @module
48
- */
49
-
50
- /*whatsupdoc*/
51
-
52
- // Shortcut to an often accessed properties, in order to avoid multiple
53
- // dereference that costs universally.
54
- // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
55
- // us it in defining shortcuts.
56
- var call = Function.prototype.call;
57
- var prototypeOfArray = Array.prototype;
58
- var prototypeOfObject = Object.prototype;
59
- var slice = prototypeOfArray.slice;
60
- var owns;
61
- var toString;
62
-
63
- // ES-5 15.3.4.5
64
- // http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
65
-
66
- if (!Function.prototype.bind) {
67
- Function.prototype.bind = function (that) { // .length is 1
68
- // 1. Let Target be the this value.
69
- var target = this;
70
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
71
- if (typeof target != "function")
72
- throw new TypeError(); // TODO message
73
- // 3. Let A be a new (possibly empty) internal list of all of the
74
- // argument values provided after thisArg (arg1, arg2 etc), in order.
75
- // XXX slicedArgs will stand in for "A" if used
76
- var args = slice.call(arguments, 1); // for normal call
77
- // 4. Let F be a new native ECMAScript object.
78
- // 9. Set the [[Prototype]] internal property of F to the standard
79
- // built-in Function prototype object as specified in 15.3.3.1.
80
- // 10. Set the [[Call]] internal property of F as described in
81
- // 15.3.4.5.1.
82
- // 11. Set the [[Construct]] internal property of F as described in
83
- // 15.3.4.5.2.
84
- // 12. Set the [[HasInstance]] internal property of F as described in
85
- // 15.3.4.5.3.
86
- // 13. The [[Scope]] internal property of F is unused and need not
87
- // exist.
88
- var bound = function () {
89
-
90
- if (this instanceof bound) {
91
- // 15.3.4.5.2 [[Construct]]
92
- // When the [[Construct]] internal method of a function object,
93
- // F that was created using the bind function is called with a
94
- // list of arguments ExtraArgs the following steps are taken:
95
- // 1. Let target be the value of F's [[TargetFunction]]
96
- // internal property.
97
- // 2. If target has no [[Construct]] internal method, a
98
- // TypeError exception is thrown.
99
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
100
- // property.
101
- // 4. Let args be a new list containing the same values as the
102
- // list boundArgs in the same order followed by the same
103
- // values as the list ExtraArgs in the same order.
104
-
105
- var F = function(){};
106
- F.prototype = target.prototype;
107
- var self = new F;
108
-
109
- var result = target.apply(
110
- self,
111
- args.concat(slice.call(arguments))
112
- );
113
- if (result !== null && Object(result) === result)
114
- return result;
115
- return self;
116
-
117
- } else {
118
- // 15.3.4.5.1 [[Call]]
119
- // When the [[Call]] internal method of a function object, F,
120
- // which was created using the bind function is called with a
121
- // this value and a list of arguments ExtraArgs the following
122
- // steps are taken:
123
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
124
- // property.
125
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
126
- // property.
127
- // 3. Let target be the value of F's [[TargetFunction]] internal
128
- // property.
129
- // 4. Let args be a new list containing the same values as the list
130
- // boundArgs in the same order followed by the same values as
131
- // the list ExtraArgs in the same order. 5. Return the
132
- // result of calling the [[Call]] internal method of target
133
- // providing boundThis as the this value and providing args
134
- // as the arguments.
135
-
136
- // equiv: target.call(this, ...boundArgs, ...args)
137
- return target.apply(
138
- that,
139
- args.concat(slice.call(arguments))
140
- );
141
-
142
- }
143
-
144
- };
145
- // XXX bound.length is never writable, so don't even try
146
- //
147
- // 16. The length own property of F is given attributes as specified in
148
- // 15.3.5.1.
149
- // TODO
150
- // 17. Set the [[Extensible]] internal property of F to true.
151
- // TODO
152
- // 18. Call the [[DefineOwnProperty]] internal method of F with
153
- // arguments "caller", PropertyDescriptor {[[Value]]: null,
154
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
155
- // false}, and false.
156
- // TODO
157
- // 19. Call the [[DefineOwnProperty]] internal method of F with
158
- // arguments "arguments", PropertyDescriptor {[[Value]]: null,
159
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
160
- // false}, and false.
161
- // TODO
162
- // NOTE Function objects created using Function.prototype.bind do not
163
- // have a prototype property.
164
- // XXX can't delete it in pure-js.
165
- return bound;
166
- };
167
- }
168
-
169
- toString = call.bind(prototypeOfObject.toString);
170
- owns = call.bind(prototypeOfObject.hasOwnProperty);
171
-
172
-
173
- //
174
- // Array
175
- // =====
176
- //
177
-
178
- // ES5 15.4.3.2
179
- if (!Array.isArray) {
180
- Array.isArray = function (obj) {
181
- return toString(obj) == "[object Array]";
182
- };
183
- }
184
-
185
- // The IsCallable() check in the Array functions
186
- // has been replaced with a strict check on the
187
- // internal class of the object to trap cases where
188
- // the provided function was actually a regular
189
- // expression literal, which in V8 and
190
- // JavaScriptCore is a typeof "function". Only in
191
- // V8 are regular expression literals permitted as
192
- // reduce parameters, so it is desirable in the
193
- // general case for the shim to match the more
194
- // strict and common behavior of rejecting regular
195
- // expressions.
196
-
197
- // ES5 15.4.4.18
198
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
199
- if (!Array.prototype.forEach) {
200
- Array.prototype.forEach = function (fun /*, thisp*/) {
201
- var self = toObject(this),
202
- thisp = arguments[1],
203
- i = 0,
204
- length = self.length >>> 0;
205
-
206
- // If no callback function or if callback is not a callable function
207
- if (toString(fun) != "[object Function]") {
208
- throw new TypeError(); // TODO message
209
- }
210
-
211
- while (i < length) {
212
- if (i in self) {
213
- // Invoke the callback function with call, passing arguments:
214
- // context, property value, property key, thisArg object context
215
- fun.call(thisp, self[i], i, self);
216
- }
217
- i++;
218
- }
219
- };
220
- }
221
-
222
- // ES5 15.4.4.19
223
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
224
- if (!Array.prototype.map) {
225
- Array.prototype.map = function (fun /*, thisp*/) {
226
- var self = toObject(this),
227
- length = self.length >>> 0,
228
- result = Array(length),
229
- thisp = arguments[1];
230
-
231
- // If no callback function or if callback is not a callable function
232
- if (toString(fun) != "[object Function]") {
233
- throw new TypeError(); // TODO message
234
- }
235
-
236
- for (var i = 0; i < length; i++) {
237
- if (i in self)
238
- result[i] = fun.call(thisp, self[i], i, self);
239
- }
240
- return result;
241
- };
242
- }
243
-
244
- // ES5 15.4.4.20
245
- if (!Array.prototype.filter) {
246
- Array.prototype.filter = function (fun /*, thisp */) {
247
- var self = toObject(this),
248
- length = self.length >>> 0,
249
- result = [],
250
- thisp = arguments[1];
251
-
252
- // If no callback function or if callback is not a callable function
253
- if (toString(fun) != "[object Function]") {
254
- throw new TypeError(); // TODO message
255
- }
256
-
257
- for (var i = 0; i < length; i++) {
258
- if (i in self && fun.call(thisp, self[i], i, self))
259
- result.push(self[i]);
260
- }
261
- return result;
262
- };
263
- }
264
-
265
- // ES5 15.4.4.16
266
- if (!Array.prototype.every) {
267
- Array.prototype.every = function (fun /*, thisp */) {
268
- var self = toObject(this),
269
- length = self.length >>> 0,
270
- thisp = arguments[1];
271
-
272
- // If no callback function or if callback is not a callable function
273
- if (toString(fun) != "[object Function]") {
274
- throw new TypeError(); // TODO message
275
- }
276
-
277
- for (var i = 0; i < length; i++) {
278
- if (i in self && !fun.call(thisp, self[i], i, self))
279
- return false;
280
- }
281
- return true;
282
- };
283
- }
284
-
285
- // ES5 15.4.4.17
286
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
287
- if (!Array.prototype.some) {
288
- Array.prototype.some = function (fun /*, thisp */) {
289
- var self = toObject(this),
290
- length = self.length >>> 0,
291
- thisp = arguments[1];
292
-
293
- // If no callback function or if callback is not a callable function
294
- if (toString(fun) != "[object Function]") {
295
- throw new TypeError(); // TODO message
296
- }
297
-
298
- for (var i = 0; i < length; i++) {
299
- if (i in self && fun.call(thisp, self[i], i, self))
300
- return true;
301
- }
302
- return false;
303
- };
304
- }
305
-
306
- // ES5 15.4.4.21
307
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
308
- if (!Array.prototype.reduce) {
309
- Array.prototype.reduce = function (fun /*, initial*/) {
310
- var self = toObject(this),
311
- length = self.length >>> 0;
312
-
313
- // If no callback function or if callback is not a callable function
314
- if (toString(fun) != "[object Function]") {
315
- throw new TypeError(); // TODO message
316
- }
317
-
318
- // no value to return if no initial value and an empty array
319
- if (!length && arguments.length == 1)
320
- throw new TypeError(); // TODO message
321
-
322
- var i = 0;
323
- var result;
324
- if (arguments.length >= 2) {
325
- result = arguments[1];
326
- } else {
327
- do {
328
- if (i in self) {
329
- result = self[i++];
330
- break;
331
- }
332
-
333
- // if array contains no values, no initial value to return
334
- if (++i >= length)
335
- throw new TypeError(); // TODO message
336
- } while (true);
337
- }
338
-
339
- for (; i < length; i++) {
340
- if (i in self)
341
- result = fun.call(void 0, result, self[i], i, self);
342
- }
343
-
344
- return result;
345
- };
346
- }
347
-
348
- // ES5 15.4.4.22
349
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
350
- if (!Array.prototype.reduceRight) {
351
- Array.prototype.reduceRight = function (fun /*, initial*/) {
352
- var self = toObject(this),
353
- length = self.length >>> 0;
354
-
355
- // If no callback function or if callback is not a callable function
356
- if (toString(fun) != "[object Function]") {
357
- throw new TypeError(); // TODO message
358
- }
359
-
360
- // no value to return if no initial value, empty array
361
- if (!length && arguments.length == 1)
362
- throw new TypeError(); // TODO message
363
-
364
- var result, i = length - 1;
365
- if (arguments.length >= 2) {
366
- result = arguments[1];
367
- } else {
368
- do {
369
- if (i in self) {
370
- result = self[i--];
371
- break;
372
- }
373
-
374
- // if array contains no values, no initial value to return
375
- if (--i < 0)
376
- throw new TypeError(); // TODO message
377
- } while (true);
378
- }
379
-
380
- do {
381
- if (i in this)
382
- result = fun.call(void 0, result, self[i], i, self);
383
- } while (i--);
384
-
385
- return result;
386
- };
387
- }
388
-
389
- // ES5 15.4.4.14
390
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
391
- if (!Array.prototype.indexOf) {
392
- Array.prototype.indexOf = function (sought /*, fromIndex */ ) {
393
- var self = toObject(this),
394
- length = self.length >>> 0;
395
-
396
- if (!length)
397
- return -1;
398
-
399
- var i = 0;
400
- if (arguments.length > 1)
401
- i = toInteger(arguments[1]);
402
-
403
- // handle negative indices
404
- i = i >= 0 ? i : length - Math.abs(i);
405
- for (; i < length; i++) {
406
- if (i in self && self[i] === sought) {
407
- return i;
408
- }
409
- }
410
- return -1;
411
- };
412
- }
413
-
414
- // ES5 15.4.4.15
415
- if (!Array.prototype.lastIndexOf) {
416
- Array.prototype.lastIndexOf = function (sought /*, fromIndex */) {
417
- var self = toObject(this),
418
- length = self.length >>> 0;
419
-
420
- if (!length)
421
- return -1;
422
- var i = length - 1;
423
- if (arguments.length > 1)
424
- i = toInteger(arguments[1]);
425
- // handle negative indices
426
- i = i >= 0 ? i : length - Math.abs(i);
427
- for (; i >= 0; i--) {
428
- if (i in self && sought === self[i])
429
- return i;
430
- }
431
- return -1;
432
- };
433
- }
434
-
435
- //
436
- // Array
437
- // =====
438
- //
439
-
440
- // ES5 15.4.4.12
441
- // http://es5.github.com/#x15.4.4.12
442
- // Default value for second param
443
- // [bugfix, ielt9, old browsers]
444
- // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
445
- if([1,2].splice(0).length != 2) {
446
- var _origArraySplice = Array.prototype.splice;
447
-
448
- Array.prototype.splice = function(start, deleteCount) {
449
- if(!arguments.length)return [];
450
-
451
- return _origArraySplice.apply(this, [
452
- start === void 0 ? 0 : start,
453
- deleteCount === void 0 ? (this.length - start) : deleteCount
454
- ].concat(slice.call(arguments, 2)))
455
- };
456
- }
457
-
458
- //
459
- // Object
460
- // ======
461
- //
462
-
463
-
464
- // ES5 15.2.3.14
465
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
466
- if (!Object.keys) {
467
-
468
- var hasDontEnumBug = true,
469
- dontEnums = [
470
- "toString",
471
- "toLocaleString",
472
- "valueOf",
473
- "hasOwnProperty",
474
- "isPrototypeOf",
475
- "propertyIsEnumerable",
476
- "constructor"
477
- ],
478
- dontEnumsLength = dontEnums.length;
479
-
480
- for (var key in {"toString": null})
481
- hasDontEnumBug = false;
482
-
483
- Object.keys = function keys(object) {
484
-
485
- if ((typeof object != "object" && typeof object != "function") || object === null)
486
- throw new TypeError("Object.keys called on a non-object");
487
-
488
- var keys = [];
489
- for (var name in object) {
490
- if (owns(object, name)) {
491
- keys.push(name);
492
- }
493
- }
494
-
495
- if (hasDontEnumBug) {
496
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
497
- var dontEnum = dontEnums[i];
498
- if (owns(object, dontEnum)) {
499
- keys.push(dontEnum);
500
- }
501
- }
502
- }
503
-
504
- return keys;
505
- };
506
-
507
- }
508
-
509
- //
510
- // Date
511
- // ====
512
- //
513
-
514
- // ES5 15.9.5.43
515
- // Format a Date object as a string according to a simplified subset of the ISO 8601
516
- // standard as defined in 15.9.1.15.
517
- if (!Date.prototype.toISOString) {
518
- Date.prototype.toISOString = function toISOString() {
519
- var result, length, value;
520
- if (!isFinite(this))
521
- throw new RangeError;
522
-
523
- // the date time string format is specified in 15.9.1.15.
524
- result = [this.getUTCFullYear(), this.getUTCMonth() + 1, this.getUTCDate(),
525
- this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
526
-
527
- length = result.length;
528
- while (length--) {
529
- value = result[length];
530
- // pad months, days, hours, minutes, and seconds to have two digits.
531
- if (value < 10)
532
- result[length] = "0" + value;
533
- }
534
- // pad milliseconds to have three digits.
535
- return result.slice(0, 3).join("-") + "T" + result.slice(3).join(":") + "." +
536
- ("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
537
- }
538
- }
539
-
540
- // ES5 15.9.4.4
541
- if (!Date.now) {
542
- Date.now = function now() {
543
- return new Date().getTime();
544
- };
545
- }
546
-
547
- // ES5 15.9.5.44
548
- if (!Date.prototype.toJSON) {
549
- Date.prototype.toJSON = function toJSON(key) {
550
- // This function provides a String representation of a Date object for
551
- // use by JSON.stringify (15.12.3). When the toJSON method is called
552
- // with argument key, the following steps are taken:
553
-
554
- // 1. Let O be the result of calling ToObject, giving it the this
555
- // value as its argument.
556
- // 2. Let tv be ToPrimitive(O, hint Number).
557
- // 3. If tv is a Number and is not finite, return null.
558
- // XXX
559
- // 4. Let toISO be the result of calling the [[Get]] internal method of
560
- // O with argument "toISOString".
561
- // 5. If IsCallable(toISO) is false, throw a TypeError exception.
562
- if (typeof this.toISOString != "function")
563
- throw new TypeError(); // TODO message
564
- // 6. Return the result of calling the [[Call]] internal method of
565
- // toISO with O as the this value and an empty argument list.
566
- return this.toISOString();
567
-
568
- // NOTE 1 The argument is ignored.
569
-
570
- // NOTE 2 The toJSON function is intentionally generic; it does not
571
- // require that its this value be a Date object. Therefore, it can be
572
- // transferred to other kinds of objects for use as a method. However,
573
- // it does require that any such object have a toISOString method. An
574
- // object is free to use the argument key to filter its
575
- // stringification.
576
- };
577
- }
578
-
579
-
580
- //
581
- // String
582
- // ======
583
- //
584
-
585
- // ES5 15.5.4.20
586
- var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
587
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
588
- "\u2029\uFEFF";
589
- if (!String.prototype.trim || ws.trim()) {
590
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
591
- // http://perfectionkills.com/whitespace-deviations/
592
- ws = "[" + ws + "]";
593
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
594
- trimEndRegexp = new RegExp(ws + ws + "*$");
595
- String.prototype.trim = function trim() {
596
- return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
597
- };
598
- }
599
-
600
- // ES5 15.5.4.14
601
- // http://es5.github.com/#x15.5.4.14
602
- // [bugfix, chrome]
603
- // If separator is undefined, then the result array contains just one String, which is the this value (converted to a String). If limit is not undefined, then the output array is truncated so that it contains no more than limit elements.
604
- // "0".split(undefined, 0) -> []
605
- if("0".split(void 0, 0).length) {
606
- var oldSplit = String.prototype.split;
607
- String.prototype.split = function(separator, limit) {
608
- if(separator === void 0 && limit === 0)return [];
609
- return oldSplit.apply(this, arguments);
610
- }
611
- }
612
-
613
- // ECMA-262, 3rd B.2.3
614
- // Note an ECMAScript standart, although ECMAScript 3rd Edition has a non-normative section suggesting uniform semantics
615
- // and it should be normalized across all browsers
616
- // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
617
- if("".substr && "0b".substr(-1) !== "b") {
618
- var oldSubstr = String.prototype.substr;
619
- /**
620
- * Get the substring of a string
621
- * @param {integer} start where to start the substring
622
- * @param {integer} length how many characters to return
623
- * @return {string}
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>
624
5
  */
625
- String.prototype.substr = function(start, length) {
626
- return oldSubstr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);
627
- }
628
- }
629
-
630
- //
631
- // Util
632
- // ======
633
- //
634
-
635
- // http://jsperf.com/to-integer
636
- var toInteger = function (n) {
637
- n = +n;
638
- if (n !== n) // isNaN
639
- n = -1;
640
- else if (n !== 0 && n !== (1/0) && n !== -(1/0))
641
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
642
- return n;
643
- };
644
-
645
- var prepareString = "a"[0] != "a",
646
- // ES5 9.9
647
- toObject = function (o) {
648
- if (o == null) { // this matches both null and undefined
649
- throw new TypeError(); // TODO message
650
- }
651
- // If the implementation doesn't support by-index access of
652
- // string characters (ex. IE < 7), split the string
653
- if (prepareString && typeof o == "string" && o) {
654
- return o.split("");
655
- }
656
- return Object(o);
657
- };
658
-
659
- })();
660
6
 
661
-
662
-
663
- (function($, shims){
664
- var defineProperty = 'defineProperty';
665
- var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
666
- //safari5 has defineProperty-interface, but it can't be used on dom-object
667
- if (advancedObjectProperties && Object[defineProperty] && Object.prototype.__defineGetter__) {
668
- (function(){
7
+ var swfmini = function() {
8
+
9
+ var UNDEF = "undefined",
10
+ OBJECT = "object",
11
+ webshims = jQuery.webshims,
12
+ SHOCKWAVE_FLASH = "Shockwave Flash",
13
+ SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
14
+ FLASH_MIME_TYPE = "application/x-shockwave-flash",
15
+
16
+ win = window,
17
+ doc = document,
18
+ nav = navigator,
19
+
20
+ plugin = false,
21
+ domLoadFnArr = [main],
22
+ objIdArr = [],
23
+ listenersArr = [],
24
+ storedAltContent,
25
+ storedAltContentId,
26
+ storedCallbackFn,
27
+ storedCallbackObj,
28
+ isDomLoaded = false,
29
+ dynamicStylesheet,
30
+ dynamicStylesheetMedia,
31
+ autoHideShow = true,
32
+
33
+ /* Centralized function for browser feature detection
34
+ - User agent string detection is only used when no good alternative is possible
35
+ - Is executed directly for optimal performance
36
+ */
37
+ ua = function() {
38
+ var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
39
+ u = nav.userAgent.toLowerCase(),
40
+ p = nav.platform.toLowerCase(),
41
+ windows = p ? /win/.test(p) : /win/.test(u),
42
+ mac = p ? /mac/.test(p) : /mac/.test(u),
43
+ webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
44
+ ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
45
+ playerVersion = [0,0,0],
46
+ d = null;
47
+ if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
48
+ d = nav.plugins[SHOCKWAVE_FLASH].description;
49
+ if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
50
+ plugin = true;
51
+ ie = false; // cascaded feature detection for Internet Explorer
52
+ d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
53
+ playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
54
+ playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
55
+ playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
56
+ }
57
+ }
58
+ else if (typeof win.ActiveXObject != UNDEF) {
669
59
  try {
670
- var foo = document.createElement('foo');
671
- Object[defineProperty](foo, 'bar', {
672
- get: function(){
673
- return true;
60
+ var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
61
+ if (a) { // a will return null when ActiveX is disabled
62
+ d = a.GetVariable("$version");
63
+ if (d) {
64
+ ie = true; // cascaded feature detection for Internet Explorer
65
+ d = d.split(" ")[1].split(",");
66
+ playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
674
67
  }
675
- });
676
- advancedObjectProperties = !!foo.bar;
677
- }
678
- catch (e) {
679
- advancedObjectProperties = false;
68
+ }
680
69
  }
681
- foo = null;
682
- })();
683
- }
70
+ catch(e) {}
71
+ }
72
+ return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
73
+ }();
684
74
 
685
- Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)));
686
- Modernizr.advancedObjectProperties = advancedObjectProperties;
687
75
 
688
- if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
689
- var call = Function.prototype.call;
690
- var prototypeOfObject = Object.prototype;
691
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
76
+ function callDomLoadFunctions() {
77
+ if (isDomLoaded) { return; }
78
+ try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
79
+ var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
80
+ t.parentNode.removeChild(t);
81
+ }
82
+ catch (e) { return; }
83
+ isDomLoaded = true;
84
+ var dl = domLoadFnArr.length;
85
+ for (var i = 0; i < dl; i++) {
86
+ domLoadFnArr[i]();
87
+ }
88
+ }
692
89
 
693
- shims.objectCreate = function(proto, props, opts, no__proto__){
694
- var o;
695
- var f = function(){};
696
-
697
- f.prototype = proto;
698
- o = new f();
699
-
700
- if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
701
- o.__proto__ = proto;
90
+ function addDomLoadEvent(fn) {
91
+ if (isDomLoaded) {
92
+ fn();
702
93
  }
703
-
704
- if(props){
705
- shims.defineProperties(o, props);
94
+ else {
95
+ domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
706
96
  }
97
+ }
98
+
99
+ /* Cross-browser onload
100
+ - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
101
+ - Will fire an event as soon as a web page including all of its assets are loaded
102
+ */
103
+ function addLoadEvent(fn) {
707
104
 
708
- if(opts){
709
- o.options = jQuery.extend(true, {}, o.options || {}, opts);
710
- opts = o.options;
105
+ }
106
+
107
+ /* Main function
108
+ - Will preferably execute onDomLoad, otherwise onload (as a fallback)
109
+ */
110
+ function main() {
111
+ if (plugin) {
112
+ testPlayerVersion();
711
113
  }
712
-
713
- if(o._create && jQuery.isFunction(o._create)){
714
- o._create(opts);
114
+ }
115
+
116
+ /* Detect the Flash Player version for non-Internet Explorer browsers
117
+ - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
118
+ a. Both release and build numbers can be detected
119
+ b. Avoid wrong descriptions by corrupt installers provided by Adobe
120
+ c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
121
+ - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
122
+ */
123
+ function testPlayerVersion() {
124
+ var b = doc.getElementsByTagName("body")[0];
125
+ var o = createElement(OBJECT);
126
+ o.setAttribute("type", FLASH_MIME_TYPE);
127
+ var t = b.appendChild(o);
128
+ if (t) {
129
+ var counter = 0;
130
+ (function(){
131
+ if (typeof t.GetVariable != UNDEF) {
132
+ var d = t.GetVariable("$version");
133
+ if (d) {
134
+ d = d.split(" ")[1].split(",");
135
+ ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
136
+ }
137
+ }
138
+ else if (counter < 10) {
139
+ counter++;
140
+ setTimeout(arguments.callee, 10);
141
+ return;
142
+ }
143
+ b.removeChild(o);
144
+ t = null;
145
+ })();
715
146
  }
716
- return o;
717
- };
147
+ }
148
+
718
149
 
719
- shims.defineProperties = function(object, props){
720
- for (var name in props) {
721
- if (owns(props, name)) {
722
- shims.defineProperty(object, name, props[name]);
150
+ function getObjectById(objectIdStr) {
151
+ var r = null;
152
+ var o = getElementById(objectIdStr);
153
+ if (o && o.nodeName == "OBJECT") {
154
+ if (typeof o.SetVariable != UNDEF) {
155
+ r = o;
156
+ }
157
+ else {
158
+ var n = o.getElementsByTagName(OBJECT)[0];
159
+ if (n) {
160
+ r = n;
161
+ }
723
162
  }
724
163
  }
725
- return object;
726
- };
164
+ return r;
165
+ }
727
166
 
728
- var descProps = ['configurable', 'enumerable', 'writable'];
729
- shims.defineProperty = function(proto, property, descriptor){
730
- if(typeof descriptor != "object" || descriptor === null){return proto;}
731
-
732
- if(owns(descriptor, "value")){
733
- proto[property] = descriptor.value;
734
- return proto;
167
+
168
+ /* Functions to abstract and display alternative content
169
+ */
170
+ function displayAltContent(obj) {
171
+ if (ua.ie && ua.win && obj.readyState != 4) {
172
+ // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
173
+ // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
174
+ var el = createElement("div");
175
+ obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
176
+ el.parentNode.replaceChild(abstractAltContent(obj), el);
177
+ obj.style.display = "none";
178
+ (function(){
179
+ if (obj.readyState == 4) {
180
+ obj.parentNode.removeChild(obj);
181
+ }
182
+ else {
183
+ setTimeout(arguments.callee, 10);
184
+ }
185
+ })();
735
186
  }
736
-
737
- if(proto.__defineGetter__){
738
- if (typeof descriptor.get == "function") {
739
- proto.__defineGetter__(property, descriptor.get);
187
+ else {
188
+ obj.parentNode.replaceChild(abstractAltContent(obj), obj);
189
+ }
190
+ }
191
+
192
+ function abstractAltContent(obj) {
193
+ var ac = createElement("div");
194
+ if (ua.win && ua.ie) {
195
+ ac.innerHTML = obj.innerHTML;
196
+ }
197
+ else {
198
+ var nestedObj = obj.getElementsByTagName(OBJECT)[0];
199
+ if (nestedObj) {
200
+ var c = nestedObj.childNodes;
201
+ if (c) {
202
+ var cl = c.length;
203
+ for (var i = 0; i < cl; i++) {
204
+ if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
205
+ ac.appendChild(c[i].cloneNode(true));
206
+ }
207
+ }
208
+ }
740
209
  }
741
- if (typeof descriptor.set == "function"){
742
- proto.__defineSetter__(property, descriptor.set);
210
+ }
211
+ return ac;
212
+ }
213
+
214
+ /* Cross-browser dynamic SWF creation
215
+ */
216
+ function createSWF(attObj, parObj, id) {
217
+ var r, el = getElementById(id);
218
+ if (ua.wk && ua.wk < 312) { return r; }
219
+ if (el) {
220
+ if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
221
+ attObj.id = id;
743
222
  }
744
- }
745
- return proto;
746
- };
223
+ if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
224
+ var att = "";
225
+ for (var i in attObj) {
226
+ if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
227
+ if (i.toLowerCase() == "data") {
228
+ parObj.movie = attObj[i];
229
+ }
230
+ else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
231
+ att += ' class="' + attObj[i] + '"';
232
+ }
233
+ else if (i.toLowerCase() != "classid") {
234
+ att += ' ' + i + '="' + attObj[i] + '"';
235
+ }
236
+ }
237
+ }
238
+ var par = "";
239
+ for (var j in parObj) {
240
+ if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
241
+ par += '<param name="' + j + '" value="' + parObj[j] + '" />';
242
+ }
243
+ }
244
+ el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
245
+ objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
246
+ r = getElementById(attObj.id);
247
+ }
248
+ else { // well-behaving browsers
249
+ var o = createElement(OBJECT);
250
+ o.setAttribute("type", FLASH_MIME_TYPE);
251
+ for (var m in attObj) {
252
+ if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
253
+ if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
254
+ o.setAttribute("class", attObj[m]);
255
+ }
256
+ else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
257
+ o.setAttribute(m, attObj[m]);
258
+ }
259
+ }
260
+ }
261
+ for (var n in parObj) {
262
+ if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element
263
+ createObjParam(o, n, parObj[n]);
264
+ }
265
+ }
266
+ el.parentNode.replaceChild(o, el);
267
+ r = o;
268
+ }
269
+ }
270
+ return r;
271
+ }
747
272
 
748
- shims.getPrototypeOf = function (object) {
749
- return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
750
- };
273
+ function createObjParam(el, pName, pValue) {
274
+ var p = createElement("param");
275
+ p.setAttribute("name", pName);
276
+ p.setAttribute("value", pValue);
277
+ el.appendChild(p);
278
+ }
751
279
 
752
- //based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
753
- shims.getOwnPropertyDescriptor = function(obj, prop){
754
- if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
755
- throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
756
- }
757
- var descriptor;
758
- if(Object.defineProperty && Object.getOwnPropertyDescriptor){
759
- try{
760
- descriptor = Object.getOwnPropertyDescriptor(obj, prop);
761
- return descriptor;
762
- } catch(e){}
280
+ /* Cross-browser SWF removal
281
+ - Especially needed to safely and completely remove a SWF in Internet Explorer
282
+ */
283
+ function removeSWF(id) {
284
+ var obj = getElementById(id);
285
+ if (obj && obj.nodeName == "OBJECT") {
286
+ if (ua.ie && ua.win) {
287
+ obj.style.display = "none";
288
+ (function(){
289
+ if (obj.readyState == 4) {
290
+ removeObjectInIE(id);
291
+ }
292
+ else {
293
+ setTimeout(arguments.callee, 10);
294
+ }
295
+ })();
296
+ }
297
+ else {
298
+ obj.parentNode.removeChild(obj);
299
+ }
763
300
  }
764
- descriptor = {
765
- configurable: true,
766
- enumerable: true,
767
- writable: true,
768
- value: undefined
769
- };
770
- var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
771
- setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
772
- ;
773
-
774
- if (!getter && !setter) { // not an accessor so return prop
775
- if(!owns(obj, prop)){
776
- return;
301
+ }
302
+
303
+ function removeObjectInIE(id) {
304
+ var obj = getElementById(id);
305
+ if (obj) {
306
+ for (var i in obj) {
307
+ if (typeof obj[i] == "function") {
308
+ obj[i] = null;
309
+ }
777
310
  }
778
- descriptor.value = obj[prop];
779
- return descriptor;
780
- }
781
-
782
- // there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
783
- delete descriptor.writable;
784
- delete descriptor.value;
785
- descriptor.get = descriptor.set = undefined;
786
-
787
- if(getter){
788
- descriptor.get = getter;
311
+ obj.parentNode.removeChild(obj);
789
312
  }
790
-
791
- if(setter){
792
- descriptor.set = setter;
313
+ }
314
+
315
+ /* Functions to optimize JavaScript compression
316
+ */
317
+ function getElementById(id) {
318
+ var el = null;
319
+ try {
320
+ el = doc.getElementById(id);
793
321
  }
794
-
795
- return descriptor;
796
- };
797
-
798
- }
799
- })(jQuery, jQuery.webshims);
800
-
801
-
802
-
803
- //DOM-Extension helper
804
- jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
805
- "use strict";
806
- //shortcus
807
- var modules = webshims.modules;
808
- var listReg = /\s*,\s*/;
809
-
810
- //proxying attribute
811
- var olds = {};
812
- var havePolyfill = {};
813
- var extendedProps = {};
814
- var extendQ = {};
815
- var modifyProps = {};
322
+ catch (e) {}
323
+ return el;
324
+ }
816
325
 
817
- var oldVal = $.fn.val;
818
- var singleVal = function(elem, name, val, pass, _argless){
819
- return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
820
- };
326
+ function createElement(el) {
327
+ return doc.createElement(el);
328
+ }
821
329
 
822
- $.fn.onTrigger = function(evt, fn){
823
- return this.on(evt, fn).each(fn);
824
- };
330
+ /* Updated attachEvent function for Internet Explorer
331
+ - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
332
+ */
333
+ function addListener(target, eventType, fn) {
334
+ target.attachEvent(eventType, fn);
335
+ listenersArr[listenersArr.length] = [target, eventType, fn];
336
+ }
825
337
 
826
- $.fn.val = function(val){
827
- var elem = this[0];
828
- if(arguments.length && val == null){
829
- val = '';
830
- }
831
- if(!arguments.length){
832
- if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
833
- return $.prop(elem, 'value', val, 'val', true);
338
+ /* Flash Player and SWF content version matching
339
+ */
340
+ function hasPlayerVersion(rv) {
341
+ var pv = ua.pv, v = rv.split(".");
342
+ v[0] = parseInt(v[0], 10);
343
+ v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
344
+ v[2] = parseInt(v[2], 10) || 0;
345
+ return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
346
+ }
347
+
348
+
349
+
350
+ function setVisibility(id, isVisible) {
351
+ if (!autoHideShow) { return; }
352
+ var elem;
353
+ var v = isVisible ? "visible" : "hidden";
354
+ if (isDomLoaded && (elem && getElementById(id))) {
355
+ getElementById(id).style.visibility = v;
834
356
  }
835
- if($.isArray(val)){
836
- return oldVal.apply(this, arguments);
357
+ }
358
+
359
+ /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
360
+ */
361
+ var cleanup = function() {
362
+ if (ua.ie && ua.win && window.attachEvent) {
363
+ window.attachEvent("onunload", function() {
364
+ // remove listeners to avoid memory leaks
365
+ var ll = listenersArr.length;
366
+ for (var i = 0; i < ll; i++) {
367
+ listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
368
+ }
369
+ // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
370
+ var il = objIdArr.length;
371
+ for (var j = 0; j < il; j++) {
372
+ removeSWF(objIdArr[j]);
373
+ }
374
+ // cleanup library's main closures to avoid memory leaks
375
+ for (var k in ua) {
376
+ ua[k] = null;
377
+ }
378
+ ua = null;
379
+ for (var l in swfmini) {
380
+ swfmini[l] = null;
381
+ }
382
+ swfmini = null;
383
+ });
837
384
  }
838
- var isFunction = $.isFunction(val);
839
- return this.each(function(i){
840
- elem = this;
841
- if(elem.nodeType === 1){
842
- if(isFunction){
843
- var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
844
- if(genVal == null){
845
- genVal = '';
385
+ }();
386
+
387
+ webshims.ready('DOM', callDomLoadFunctions);
388
+
389
+ return {
390
+ /* Public API
391
+ - Reference: http://code.google.com/p/swfobject/wiki/documentation
392
+ */
393
+ registerObject: function() {
394
+
395
+ },
396
+
397
+ getObjectById: function(objectIdStr) {
398
+ if (ua.w3) {
399
+ return getObjectById(objectIdStr);
400
+ }
401
+ },
402
+
403
+ embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
404
+ var callbackObj = {success:false, id:replaceElemIdStr};
405
+ if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
406
+ setVisibility(replaceElemIdStr, false);
407
+ addDomLoadEvent(function() {
408
+ widthStr += ""; // auto-convert to string
409
+ heightStr += "";
410
+ var att = {};
411
+ if (attObj && typeof attObj === OBJECT) {
412
+ for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
413
+ att[i] = attObj[i];
414
+ }
846
415
  }
847
- $.prop(elem, 'value', genVal, 'val') ;
848
- } else {
849
- $.prop(elem, 'value', val, 'val');
850
- }
416
+ att.data = swfUrlStr;
417
+ att.width = widthStr;
418
+ att.height = heightStr;
419
+ var par = {};
420
+ if (parObj && typeof parObj === OBJECT) {
421
+ for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
422
+ par[j] = parObj[j];
423
+ }
424
+ }
425
+ if (flashvarsObj && typeof flashvarsObj === OBJECT) {
426
+ for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
427
+ if (typeof par.flashvars != UNDEF) {
428
+ par.flashvars += "&" + k + "=" + flashvarsObj[k];
429
+ }
430
+ else {
431
+ par.flashvars = k + "=" + flashvarsObj[k];
432
+ }
433
+ }
434
+ }
435
+ if (hasPlayerVersion(swfVersionStr)) { // create SWF
436
+ var obj = createSWF(att, par, replaceElemIdStr);
437
+ if (att.id == replaceElemIdStr) {
438
+ setVisibility(replaceElemIdStr, true);
439
+ }
440
+ callbackObj.success = true;
441
+ callbackObj.ref = obj;
442
+ }
443
+ else { // show alternative content
444
+ setVisibility(replaceElemIdStr, true);
445
+ }
446
+ if (callbackFn) { callbackFn(callbackObj); }
447
+ });
851
448
  }
852
- });
853
- };
854
-
855
- var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
856
- var elementData = function(elem, key, val){
857
- elem = elem.jquery ? elem[0] : elem;
858
- if(!elem){return val || {};}
859
- var data = $.data(elem, dataID);
860
- if(val !== undefined){
861
- if(!data){
862
- data = $.data(elem, dataID, {});
449
+ else if (callbackFn) { callbackFn(callbackObj); }
450
+ },
451
+
452
+ switchOffAutoHideShow: function() {
453
+ autoHideShow = false;
454
+ },
455
+
456
+ ua: ua,
457
+
458
+ getFlashPlayerVersion: function() {
459
+ return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
460
+ },
461
+
462
+ hasFlashPlayerVersion: hasPlayerVersion,
463
+
464
+ createSWF: function(attObj, parObj, replaceElemIdStr) {
465
+ if (ua.w3) {
466
+ return createSWF(attObj, parObj, replaceElemIdStr);
863
467
  }
864
- if(key){
865
- data[key] = val;
468
+ else {
469
+ return undefined;
866
470
  }
867
- }
471
+ },
472
+
473
+ showExpressInstall: function() {
474
+
475
+ },
476
+
477
+ removeSWF: function(objElemIdStr) {
478
+ if (ua.w3) {
479
+ removeSWF(objElemIdStr);
480
+ }
481
+ },
482
+
483
+ createCSS: function() {
484
+
485
+ },
486
+
487
+ addDomLoadEvent: addDomLoadEvent,
488
+
489
+ addLoadEvent: addLoadEvent,
490
+
868
491
 
869
- return key ? data && data[key] : data;
492
+ // For internal usage only
493
+ expressInstallCallback: function() {
494
+
495
+ }
870
496
  };
497
+ }();
871
498
 
872
-
873
- [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
874
- $.fn[data.name] = function(){
875
- return this.map(function(){
876
- var shadowData = elementData(this, 'shadowData');
877
- return shadowData && shadowData[data.prop] || this;
878
- });
879
- };
880
- });
499
+ //additional tests for partial implementation of forms features
500
+ (function($){
501
+ "use strict";
502
+ var isWebkit = 'webkitURL' in window;
503
+ var Modernizr = window.Modernizr;
504
+ var webshims = $.webshims;
505
+ var bugs = webshims.bugs;
506
+ var form = $('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /><input required="" name="a" /></form>');
507
+ var testRequiredFind = function(){
508
+ if(form[0].querySelector){
509
+ try {
510
+ bugs.findRequired = !(form[0].querySelector('select:required'));
511
+ } catch(er){
512
+ bugs.findRequired = false;
513
+ }
514
+ }
515
+ };
516
+ var inputElem = $('input', form).eq(0);
517
+ var onDomextend = function(fn){
518
+ webshims.loader.loadList(['dom-extend']);
519
+ webshims.ready('dom-extend', fn);
520
+ };
881
521
 
522
+ bugs.findRequired = false;
523
+ bugs.validationMessage = false;
882
524
 
883
- ['removeAttr', 'prop', 'attr'].forEach(function(type){
884
- olds[type] = $[type];
885
- $[type] = function(elem, name, value, pass, _argless){
886
- var isVal = (pass == 'val');
887
- var oldMethod = !isVal ? olds[type] : singleVal;
888
- if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
889
- return oldMethod(elem, name, value, pass, _argless);
890
- }
525
+ webshims.capturingEventPrevented = function(e){
526
+ if(!e._isPolyfilled){
527
+ var isDefaultPrevented = e.isDefaultPrevented;
528
+ var preventDefault = e.preventDefault;
529
+ e.preventDefault = function(){
530
+ clearTimeout($.data(e.target, e.type + 'DefaultPrevented'));
531
+ $.data(e.target, e.type + 'DefaultPrevented', setTimeout(function(){
532
+ $.removeData(e.target, e.type + 'DefaultPrevented');
533
+ }, 30));
534
+ return preventDefault.apply(this, arguments);
535
+ };
536
+ e.isDefaultPrevented = function(){
537
+ return !!(isDefaultPrevented.apply(this, arguments) || $.data(e.target, e.type + 'DefaultPrevented') || false);
538
+ };
539
+ e._isPolyfilled = true;
540
+ }
541
+ };
542
+
543
+ if(!Modernizr.formvalidation || bugs.bustedValidity){
544
+ testRequiredFind();
545
+ } else {
546
+ //create delegatable events
547
+ webshims.capturingEvents(['invalid'], true);
548
+
549
+ if(window.opera || window.testGoodWithFix){
891
550
 
892
- var nodeName = (elem.nodeName || '').toLowerCase();
893
- var desc = extendedProps[nodeName];
894
- var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
895
- var propMethod;
896
- var oldValMethod;
897
- var ret;
551
+ form.appendTo('head');
898
552
 
553
+ testRequiredFind();
554
+ bugs.validationMessage = !(inputElem.prop('validationMessage'));
899
555
 
900
- if(!desc){
901
- desc = extendedProps['*'];
556
+ webshims.reTest(['form-native-extend', 'form-message']);
557
+
558
+ form.remove();
559
+
560
+ $(function(){
561
+ onDomextend(function(){
562
+
563
+ //Opera shows native validation bubbles in case of input.checkValidity()
564
+ // Opera 11.6/12 hasn't fixed this issue right, it's buggy
565
+ var preventDefault = function(e){
566
+ e.preventDefault();
567
+ };
568
+
569
+ ['form', 'input', 'textarea', 'select'].forEach(function(name){
570
+ var desc = webshims.defineNodeNameProperty(name, 'checkValidity', {
571
+ prop: {
572
+ value: function(){
573
+ if (!webshims.fromSubmit) {
574
+ $(this).on('invalid.checkvalidity', preventDefault);
575
+ }
576
+
577
+ webshims.fromCheckValidity = true;
578
+ var ret = desc.prop._supvalue.apply(this, arguments);
579
+ if (!webshims.fromSubmit) {
580
+ $(this).unbind('invalid.checkvalidity', preventDefault);
581
+ }
582
+ webshims.fromCheckValidity = false;
583
+ return ret;
584
+ }
585
+ }
586
+ });
587
+ });
588
+
589
+ });
590
+ });
591
+ }
592
+
593
+ if(isWebkit && !webshims.bugs.bustedValidity){
594
+ (function(){
595
+ var elems = /^(?:textarea|input)$/i;
596
+ var form = false;
597
+
598
+ document.addEventListener('contextmenu', function(e){
599
+ if(elems.test( e.target.nodeName || '') && (form = e.target.form)){
600
+ setTimeout(function(){
601
+ form = false;
602
+ }, 1);
603
+ }
604
+ }, false);
605
+
606
+ $(window).on('invalid', function(e){
607
+ if(e.originalEvent && form && form == e.target.form){
608
+ e.wrongWebkitInvalid = true;
609
+ e.stopImmediatePropagation();
610
+ }
611
+ });
612
+
613
+ })();
614
+ }
615
+ }
616
+
617
+ $.webshims.register('form-core', function($, webshims, window, document, undefined, options){
618
+
619
+ var checkTypes = {checkbox: 1, radio: 1};
620
+ var emptyJ = $([]);
621
+ var bugs = webshims.bugs;
622
+ var getGroupElements = function(elem){
623
+ elem = $(elem);
624
+ var name;
625
+ var form;
626
+ var ret = emptyJ;
627
+ if(elem[0].type == 'radio'){
628
+ form = elem.prop('form');
629
+ name = elem[0].name;
630
+ if(!name){
631
+ ret = elem;
632
+ } else if(form){
633
+ ret = $(form[name]);
634
+ } else {
635
+ ret = $(document.getElementsByName(name)).filter(function(){
636
+ return !$.prop(this, 'form');
637
+ });
638
+ }
639
+ ret = ret.filter('[type="radio"]');
640
+ }
641
+ return ret;
642
+ };
643
+
644
+ var getContentValidationMessage = webshims.getContentValidationMessage = function(elem, validity, key){
645
+ var message = $(elem).data('errormessage') || elem.getAttribute('x-moz-errormessage') || '';
646
+ if(key && message[key]){
647
+ message = message[key];
902
648
  }
903
- if(desc){
904
- desc = desc[name];
649
+ if(typeof message == 'object'){
650
+ validity = validity || $.prop(elem, 'validity') || {valid: 1};
651
+ if(!validity.valid){
652
+ $.each(validity, function(name, prop){
653
+ if(prop && name != 'valid' && message[name]){
654
+ message = message[name];
655
+ return false;
656
+ }
657
+ });
658
+ }
905
659
  }
906
660
 
907
- if(desc){
908
- propMethod = desc[curType];
661
+ if(typeof message == 'object'){
662
+ message = message.defaultMessage;
909
663
  }
910
-
911
- if(propMethod){
912
- if(name == 'value'){
913
- oldValMethod = propMethod.isVal;
914
- propMethod.isVal = isVal;
664
+ return message || '';
665
+ };
666
+
667
+ /*
668
+ * Selectors for all browsers
669
+ */
670
+ var rangeTypes = {number: 1, range: 1, date: 1/*, time: 1, 'datetime-local': 1, datetime: 1, month: 1, week: 1*/};
671
+ var hasInvalid = function(elem){
672
+ var ret = false;
673
+ $($.prop(elem, 'elements')).each(function(){
674
+ ret = $(this).is(':invalid');
675
+ if(ret){
676
+ return false;
915
677
  }
916
- if(curType === 'removeAttr'){
917
- return propMethod.value.call(elem);
918
- } else if(value === undefined){
919
- return (propMethod.get) ?
920
- propMethod.get.call(elem) :
921
- propMethod.value
922
- ;
923
- } else if(propMethod.set) {
924
- if(type == 'attr' && value === true){
925
- value = name;
926
- }
927
-
928
- ret = propMethod.set.call(elem, value);
678
+ });
679
+ return ret;
680
+ };
681
+ $.extend($.expr[":"], {
682
+ "valid-element": function(elem){
683
+ return $.nodeName(elem, 'form') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
684
+ },
685
+ "invalid-element": function(elem){
686
+ return $.nodeName(elem, 'form') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
687
+ },
688
+ "required-element": function(elem){
689
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
690
+ },
691
+ "user-error": function(elem){
692
+ return ($.prop(elem, 'willValidate') && $(elem).hasClass('user-error'));
693
+ },
694
+ "optional-element": function(elem){
695
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
696
+ },
697
+ "in-range": function(elem){
698
+ if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
699
+ return false;
929
700
  }
930
- if(name == 'value'){
931
- propMethod.isVal = oldValMethod;
701
+ var val = $.prop(elem, 'validity');
702
+ return !!(val && !val.rangeOverflow && !val.rangeUnderflow);
703
+ },
704
+ "out-of-range": function(elem){
705
+ if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
706
+ return false;
932
707
  }
933
- } else {
934
- ret = oldMethod(elem, name, value, pass, _argless);
708
+ var val = $.prop(elem, 'validity');
709
+ return !!(val && (val.rangeOverflow || val.rangeUnderflow));
935
710
  }
936
- if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
711
+
712
+ });
713
+
714
+ ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
715
+ $.expr[":"][name] = $.expr.filters[name+"-element"];
716
+ });
717
+
718
+
719
+ $.expr[":"].focus = function( elem ) {
720
+ try {
721
+ var doc = elem.ownerDocument;
722
+ return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus());
723
+ } catch(e){}
724
+ return false;
725
+ };
726
+
727
+
728
+ var customEvents = $.event.customEvent || {};
729
+ var isValid = function(elem){
730
+ return ($.prop(elem, 'validity') || {valid: 1}).valid;
731
+ };
732
+
733
+ if (bugs.bustedValidity || bugs.findRequired) {
734
+ (function(){
735
+ var find = $.find;
736
+ var matchesSelector = $.find.matchesSelector;
937
737
 
938
- var boolValue;
939
- if(curType == 'removeAttr'){
940
- boolValue = false;
941
- } else if(curType == 'prop'){
942
- boolValue = !!(value);
943
- } else {
944
- boolValue = true;
738
+ var regExp = /(\:valid|\:invalid|\:optional|\:required|\:in-range|\:out-of-range)(?=[\s\[\~\.\+\>\:\#*]|$)/ig;
739
+ var regFn = function(sel){
740
+ return sel + '-element';
741
+ };
742
+
743
+ $.find = (function(){
744
+ var slice = Array.prototype.slice;
745
+ var fn = function(sel){
746
+ var ar = arguments;
747
+ ar = slice.call(ar, 1, ar.length);
748
+ ar.unshift(sel.replace(regExp, regFn));
749
+ return find.apply(this, ar);
750
+ };
751
+ for (var i in find) {
752
+ if(find.hasOwnProperty(i)){
753
+ fn[i] = find[i];
754
+ }
755
+ }
756
+ return fn;
757
+ })();
758
+ if(!Modernizr.prefixed || Modernizr.prefixed("matchesSelector", document.documentElement)){
759
+ $.find.matchesSelector = function(node, expr){
760
+ expr = expr.replace(regExp, regFn);
761
+ return matchesSelector.call(this, node, expr);
762
+ };
945
763
  }
946
764
 
947
- modifyProps[nodeName][name].forEach(function(fn){
948
- if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
949
- fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
765
+ })();
766
+ }
767
+
768
+ //ToDo needs testing
769
+ var oldAttr = $.prop;
770
+ var changeVals = {selectedIndex: 1, value: 1, checked: 1, disabled: 1, readonly: 1};
771
+ $.prop = function(elem, name, val){
772
+ var ret = oldAttr.apply(this, arguments);
773
+ if(elem && 'form' in elem && changeVals[name] && val !== undefined && $(elem).hasClass(invalidClass)){
774
+ if(isValid(elem)){
775
+ $(elem).getShadowElement().removeClass(invalidClass);
776
+ if(name == 'checked' && val) {
777
+ getGroupElements(elem).not(elem).removeClass(invalidClass).removeAttr('aria-invalid');
950
778
  }
951
- });
779
+ }
952
780
  }
953
781
  return ret;
954
782
  };
955
783
 
956
- extendQ[type] = function(nodeName, prop, desc){
957
-
958
- if(!extendedProps[nodeName]){
959
- extendedProps[nodeName] = {};
960
- }
961
- if(!extendedProps[nodeName][prop]){
962
- extendedProps[nodeName][prop] = {};
963
- }
964
- var oldDesc = extendedProps[nodeName][prop][type];
965
- var getSup = function(propType, descriptor, oDesc){
966
- if(descriptor && descriptor[propType]){
967
- return descriptor[propType];
968
- }
969
- if(oDesc && oDesc[propType]){
970
- return oDesc[propType];
971
- }
972
- if(type == 'prop' && prop == 'value'){
973
- return function(value){
974
- var elem = this;
975
- return (desc.isVal) ?
976
- singleVal(elem, prop, value, false, (arguments.length === 0)) :
977
- olds[type](elem, prop, value)
978
- ;
979
- };
784
+ var returnValidityCause = function(validity, elem){
785
+ var ret;
786
+ $.each(validity, function(name, value){
787
+ if(value){
788
+ ret = (name == 'customError') ? $.prop(elem, 'validationMessage') : name;
789
+ return false;
980
790
  }
981
- if(type == 'prop' && propType == 'value' && desc.value.apply){
982
- return function(value){
983
- var sup = olds[type](this, prop);
984
- if(sup && sup.apply){
985
- sup = sup.apply(this, arguments);
986
- }
987
- return sup;
988
- };
791
+ });
792
+ return ret;
793
+ };
794
+
795
+ var isInGroup = function(name){
796
+ var ret;
797
+ try {
798
+ ret = document.activeElement.name === name;
799
+ } catch(e){}
800
+ return ret;
801
+ };
802
+ /* form-ui-invalid/form-ui-valid are deprecated. use user-error/user-success instead */
803
+ var invalidClass = 'user-error';
804
+ var validClass = 'user-success';
805
+ var stopChangeTypes = {
806
+ time: 1,
807
+ date: 1,
808
+ month: 1,
809
+ datetime: 1,
810
+ week: 1,
811
+ 'datetime-local': 1
812
+ };
813
+ var switchValidityClass = function(e){
814
+ var elem, timer;
815
+ if(!e.target){return;}
816
+ elem = $(e.target).getNativeElement()[0];
817
+ if(elem.type == 'submit' || !$.prop(elem, 'willValidate')){return;}
818
+ timer = $.data(elem, 'webshimsswitchvalidityclass');
819
+ var switchClass = function(){
820
+ if(e.type == 'focusout' && elem.type == 'radio' && isInGroup(elem.name)){return;}
821
+ var validity = $.prop(elem, 'validity');
822
+ var shadowElem = $(elem).getShadowElement();
823
+ var addClass, removeClass, trigger, generaltrigger, validityCause;
824
+
825
+ if(isWebkit && e.type == 'change' && !bugs.bustedValidity && stopChangeTypes[shadowElem.prop('type')] && shadowElem.is(':focus')){return;}
826
+
827
+ $(elem).trigger('refreshCustomValidityRules');
828
+
829
+ if(validity.valid){
830
+ if(!shadowElem.hasClass(validClass)){
831
+ addClass = validClass;
832
+ removeClass = invalidClass;
833
+ generaltrigger = 'changedvaliditystate';
834
+ trigger = 'changedvalid';
835
+ if(checkTypes[elem.type] && elem.checked){
836
+ getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass).removeAttr('aria-invalid');
837
+ }
838
+ $.removeData(elem, 'webshimsinvalidcause');
839
+ }
840
+ } else {
841
+ validityCause = returnValidityCause(validity, elem);
842
+ if($.data(elem, 'webshimsinvalidcause') != validityCause){
843
+ $.data(elem, 'webshimsinvalidcause', validityCause);
844
+ generaltrigger = 'changedvaliditystate';
845
+ }
846
+ if(!shadowElem.hasClass(invalidClass)){
847
+ addClass = invalidClass;
848
+ removeClass = validClass;
849
+ if (checkTypes[elem.type] && !elem.checked) {
850
+ getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass);
851
+ }
852
+ trigger = 'changedinvalid';
853
+ }
989
854
  }
990
- return function(value){
991
- return olds[type](this, prop, value);
992
- };
993
- };
994
- extendedProps[nodeName][prop][type] = desc;
995
- if(desc.value === undefined){
996
- if(!desc.set){
997
- desc.set = desc.writeable ?
998
- getSup('set', desc, oldDesc) :
999
- (webshims.cfg.useStrict && prop == 'prop') ?
1000
- function(){throw(prop +' is readonly on '+ nodeName);} :
1001
- $.noop
1002
- ;
855
+
856
+ if(addClass){
857
+ shadowElem.addClass(addClass).removeClass(removeClass);
858
+ //jQuery 1.6.1 IE9 bug (doubble trigger bug)
859
+ setTimeout(function(){
860
+ $(elem).trigger(trigger);
861
+ }, 0);
1003
862
  }
1004
- if(!desc.get){
1005
- desc.get = getSup('get', desc, oldDesc);
863
+ if(generaltrigger){
864
+ setTimeout(function(){
865
+ $(elem).trigger(generaltrigger);
866
+ }, 0);
1006
867
  }
1007
868
 
1008
- }
869
+ $.removeData(elem, 'webshimsswitchvalidityclass');
870
+ };
1009
871
 
1010
- ['value', 'get', 'set'].forEach(function(descProp){
1011
- if(desc[descProp]){
1012
- desc['_sup'+descProp] = getSup(descProp, oldDesc);
1013
- }
872
+ if(timer){
873
+ clearTimeout(timer);
874
+ }
875
+ if(e.type == 'refreshvalidityui'){
876
+ switchClass();
877
+ } else {
878
+ $.data(elem, 'webshimsswitchvalidityclass', setTimeout(switchClass, 9));
879
+ }
880
+ };
881
+
882
+ $(document).on(options.validityUIEvents || 'focusout change refreshvalidityui', switchValidityClass);
883
+ customEvents.changedvaliditystate = true;
884
+ customEvents.refreshCustomValidityRules = true;
885
+ customEvents.changedvalid = true;
886
+ customEvents.changedinvalid = true;
887
+ customEvents.refreshvalidityui = true;
888
+
889
+
890
+ webshims.triggerInlineForm = function(elem, event){
891
+ $(elem).trigger(event);
892
+ };
893
+
894
+ webshims.modules["form-core"].getGroupElements = getGroupElements;
895
+
896
+
897
+ var setRoot = function(){
898
+ webshims.scrollRoot = (isWebkit || document.compatMode == 'BackCompat') ?
899
+ $(document.body) :
900
+ $(document.documentElement)
901
+ ;
902
+ };
903
+ var minWidth = (Modernizr.boxSizing || Modernizr['display-table'] || $.support.getSetAttribute) ?
904
+ 'minWidth' :
905
+ 'width'
906
+ ;
907
+ setRoot();
908
+ webshims.ready('DOM', setRoot);
909
+
910
+ webshims.getRelOffset = function(posElem, relElem){
911
+ posElem = $(posElem);
912
+ var offset = $(relElem).offset();
913
+ var bodyOffset;
914
+ $.swap($(posElem)[0], {visibility: 'hidden', display: 'inline-block', left: 0, top: 0}, function(){
915
+ bodyOffset = posElem.offset();
1014
916
  });
917
+ offset.top -= bodyOffset.top;
918
+ offset.left -= bodyOffset.left;
919
+ return offset;
1015
920
  };
1016
921
 
1017
- });
922
+ webshims.wsPopover = {
923
+ _create: function(){
924
+ this.options = $.extend({}, webshims.cfg.wspopover, this.options);
925
+ this.id = webshims.wsPopover.id++;
926
+ this.eventns = '.wsoverlay'+this.id;
927
+ this.timers = {};
928
+ this.element = $('<div class="ws-popover" tabindex="-1"><div class="ws-po-outerbox"><div class="ws-po-arrow"><div class="ws-po-arrowbox" /></div><div class="ws-po-box" /></div></div>');
929
+ this.contentElement = $('.ws-po-box', this.element);
930
+ this.lastElement = $([]);
931
+ this.bindElement();
932
+
933
+ this.element.data('wspopover', this);
934
+
935
+ },
936
+ options: {},
937
+ content: function(html){
938
+ this.contentElement.html(html);
939
+ },
940
+ bindElement: function(){
941
+ var that = this;
942
+ var stopBlur = function(){
943
+ that.stopBlur = false;
944
+ };
945
+ this.preventBlur = function(e){
946
+ that.stopBlur = true;
947
+ clearTimeout(that.timers.stopBlur);
948
+ that.timers.stopBlur = setTimeout(stopBlur, 9);
949
+ };
950
+ this.element.on({
951
+ 'mousedown': this.preventBlur
952
+ });
953
+ },
954
+
955
+ isInElement: function(container, contained){
956
+ return container == contained || $.contains(container, contained);
957
+ },
958
+ show: function(element){
959
+ var e = $.Event('wspopoverbeforeshow');
960
+ this.element.trigger(e);
961
+ if(e.isDefaultPrevented() || this.isVisible){return;}
962
+ this.isVisible = true;
963
+ element = $(element || this.options.prepareFor).getNativeElement() ;
964
+
965
+ var that = this;
966
+ var visual = $(element).getShadowElement();
1018
967
 
1019
- //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
1020
- var isExtendNativeSave = Modernizr.ES5;
1021
- var extendNativeValue = (function(){
1022
- var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
1023
- var has = Object.prototype.hasOwnProperty;
1024
- return function(nodeName, prop, desc){
1025
- var elem;
1026
- var elemProto;
1027
- if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
1028
- var sup = elem[prop];
1029
- desc._supvalue = function(){
1030
- if(sup && sup.apply){
1031
- return sup.apply(this, arguments);
968
+ this.clear();
969
+ this.element.removeClass('ws-po-visible').css('display', 'none');
970
+
971
+ this.prepareFor(element, visual);
972
+
973
+ this.position(visual);
974
+ that.timers.show = setTimeout(function(){
975
+ that.element.css('display', '');
976
+ that.timers.show = setTimeout(function(){
977
+ that.element.addClass('ws-po-visible').trigger('wspopovershow');
978
+ }, 9);
979
+ }, 9);
980
+ $(document).on('focusin'+this.eventns+' mousedown'+this.eventns, function(e){
981
+ if(that.options.hideOnBlur && !that.stopBlur && !that.isInElement(that.lastElement[0] || document.body, e.target) && !that.isInElement(element[0] || document.body, e.target) && !that.isInElement(that.element[0], e.target)){
982
+ that.hide();
1032
983
  }
1033
- return sup;
1034
- };
1035
- elemProto[prop] = desc.value;
1036
- } else {
1037
- desc._supvalue = function(){
1038
- var data = elementData(this, 'propValue');
1039
- if(data && data[prop] && data[prop].apply){
1040
- return data[prop].apply(this, arguments);
984
+ });
985
+ $(window).on('resize'+this.eventns + ' pospopover'+this.eventns, function(){
986
+ clearTimeout(that.timers.repos);
987
+ that.timers.repos = setTimeout(function(){
988
+ that.position(visual);
989
+ }, 900);
990
+ });
991
+ },
992
+ prepareFor: function(element, visual){
993
+ var onBlur;
994
+ var opts = $.extend({}, this.options, $(element.prop('form') || []).data('wspopover') || {}, element.data('wspopover'));
995
+ var that = this;
996
+ var css = {};
997
+ this.lastElement = $(element).getShadowFocusElement();
998
+ if(opts.appendTo == 'element'){
999
+ this.element.insertAfter(element);
1000
+ } else {
1001
+ this.element.appendTo(opts.appendTo);
1002
+ }
1003
+
1004
+ this.element.attr({
1005
+ 'data-class': element.prop('className'),
1006
+ 'data-id': element.prop('id')
1007
+ });
1008
+
1009
+ css[minWidth] = opts.constrainWidth ? visual.outerWidth() : '';
1010
+
1011
+ this.element.css(css);
1012
+
1013
+ if(opts.hideOnBlur){
1014
+ onBlur = function(e){
1015
+ if(that.stopBlur){
1016
+ e.stopImmediatePropagation();
1017
+ } else {
1018
+ that.hide();
1019
+ }
1020
+ };
1021
+
1022
+ that.timers.bindBlur = setTimeout(function(){
1023
+ that.lastElement.off(that.eventns).on('focusout'+that.eventns + ' blur'+that.eventns, onBlur);
1024
+ that.lastElement.getNativeElement().off(that.eventns);
1025
+ }, 10);
1026
+
1027
+
1028
+ }
1029
+
1030
+ if(!this.prepared){
1031
+
1032
+ if($.fn.bgIframe){
1033
+ this.element.bgIframe();
1041
1034
  }
1042
- return data && data[prop];
1035
+ }
1036
+ this.prepared = true;
1037
+ },
1038
+ clear: function(){
1039
+ $(window).off(this.eventns);
1040
+ $(document).off(this.eventns);
1041
+
1042
+ this.stopBlur = false;
1043
+ $.each(this.timers, function(timerName, val){
1044
+ clearTimeout(val);
1045
+ });
1046
+ },
1047
+ hide: function(){
1048
+ var e = $.Event('wspopoverbeforehide');
1049
+ this.element.trigger(e);
1050
+ if(e.isDefaultPrevented() || !this.isVisible){return;}
1051
+ this.isVisible = false;
1052
+ var that = this;
1053
+ var forceHide = function(){
1054
+ that.element.css('display', 'none').attr({'data-id': '', 'data-class': '', 'hidden': 'hidden'});
1055
+ clearTimeout(that.timers.forcehide);
1043
1056
  };
1044
- initProp.extendValue(nodeName, prop, desc.value);
1057
+ this.clear();
1058
+ this.element.removeClass('ws-po-visible').trigger('wspopoverhide');
1059
+ $(window).on('resize'+this.eventns, forceHide);
1060
+ that.timers.forcehide = setTimeout(forceHide, 999);
1061
+ },
1062
+ position: function(element){
1063
+ var offset = webshims.getRelOffset(this.element.css({marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0}).removeAttr('hidden'), element);
1064
+ offset.top += element.outerHeight();
1065
+ this.element.css({marginTop: '', marginLeft: '', marginRight: '', marginBottom: ''}).css(offset);
1045
1066
  }
1046
- desc.value._supvalue = desc._supvalue;
1047
1067
  };
1048
- })();
1049
1068
 
1050
- var initProp = (function(){
1069
+ webshims.wsPopover.id = 0;
1051
1070
 
1052
- var initProps = {};
1053
-
1054
- webshims.addReady(function(context, contextElem){
1055
- var nodeNameCache = {};
1056
- var getElementsByName = function(name){
1057
- if(!nodeNameCache[name]){
1058
- nodeNameCache[name] = $(context.getElementsByTagName(name));
1059
- if(contextElem[0] && $.nodeName(contextElem[0], name)){
1060
- nodeNameCache[name] = nodeNameCache[name].add(contextElem);
1071
+ /* some extra validation UI */
1072
+ webshims.validityAlert = (function(){
1073
+
1074
+
1075
+ var focusTimer = false;
1076
+
1077
+ var api = webshims.objectCreate(webshims.wsPopover, {}, options.messagePopover);
1078
+ var boundHide = api.hide.bind(api);
1079
+
1080
+ api.element.addClass('validity-alert').attr({role: 'alert'});
1081
+ $.extend(api, {
1082
+ hideDelay: 5000,
1083
+ showFor: function(elem, message, noFocusElem, noBubble){
1084
+
1085
+ elem = $(elem).getNativeElement();
1086
+ this.clear();
1087
+ this.hide();
1088
+ if(!noBubble){
1089
+ this.getMessage(elem, message);
1090
+
1091
+ this.show(elem);
1092
+ if(this.hideDelay){
1093
+ this.timers.delayedHide = setTimeout(boundHide, this.hideDelay);
1094
+ }
1095
+
1096
+ }
1097
+
1098
+ if(!noFocusElem){
1099
+ this.setFocus(elem);
1100
+ }
1101
+ },
1102
+ setFocus: function(element){
1103
+ var focusElem = $(element).getShadowFocusElement();
1104
+ var scrollTop = webshims.scrollRoot.scrollTop();
1105
+ var elemTop = focusElem.offset().top - 30;
1106
+ var smooth;
1107
+
1108
+ if(scrollTop > elemTop){
1109
+ webshims.scrollRoot.animate(
1110
+ {scrollTop: elemTop - 5},
1111
+ {
1112
+ queue: false,
1113
+ duration: Math.max( Math.min( 600, (scrollTop - elemTop) * 1.5 ), 80 )
1114
+ }
1115
+ );
1116
+ smooth = true;
1117
+ }
1118
+ try {
1119
+ focusElem[0].focus();
1120
+ } catch(e){}
1121
+ if(smooth){
1122
+ webshims.scrollRoot.scrollTop(scrollTop);
1123
+ setTimeout(function(){
1124
+ webshims.scrollRoot.scrollTop(scrollTop);
1125
+ }, 0);
1126
+ }
1127
+
1128
+ $(window).triggerHandler('pospopover'+this.eventns);
1129
+ },
1130
+ getMessage: function(elem, message){
1131
+ if (!message) {
1132
+ message = getContentValidationMessage(elem[0]) || elem.prop('customValidationMessage') || elem.prop('validationMessage');
1133
+ }
1134
+ if (message) {
1135
+ api.contentElement.text(message);
1136
+ } else {
1137
+ this.hide();
1061
1138
  }
1062
1139
  }
1063
- };
1140
+ });
1064
1141
 
1065
1142
 
1066
- $.each(initProps, function(name, fns){
1067
- getElementsByName(name);
1068
- if(!fns || !fns.forEach){
1069
- webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
1070
- return;
1143
+ return api;
1144
+ })();
1145
+
1146
+
1147
+ /* extension, but also used to fix native implementation workaround/bugfixes */
1148
+ (function(){
1149
+ var firstEvent,
1150
+ invalids = [],
1151
+ stopSubmitTimer,
1152
+ form
1153
+ ;
1154
+
1155
+ $(document).on('invalid', function(e){
1156
+ if(e.wrongWebkitInvalid){return;}
1157
+ var jElm = $(e.target);
1158
+ var shadowElem = jElm.getShadowElement();
1159
+ if(!shadowElem.hasClass(invalidClass)){
1160
+ shadowElem.addClass(invalidClass).removeClass(validClass);
1161
+ setTimeout(function(){
1162
+ $(e.target).trigger('changedinvalid').trigger('changedvaliditystate');
1163
+ }, 0);
1071
1164
  }
1072
- fns.forEach(function(fn){
1073
- nodeNameCache[name].each(fn);
1074
- });
1165
+
1166
+ if(!firstEvent){
1167
+ //trigger firstinvalid
1168
+ firstEvent = $.Event('firstinvalid');
1169
+ firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
1170
+ var firstSystemInvalid = $.Event('firstinvalidsystem');
1171
+ $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
1172
+ jElm.trigger(firstEvent);
1173
+ }
1174
+
1175
+ //if firstinvalid was prevented all invalids will be also prevented
1176
+ if( firstEvent && firstEvent.isDefaultPrevented() ){
1177
+ e.preventDefault();
1178
+ }
1179
+ invalids.push(e.target);
1180
+ e.extraData = 'fix';
1181
+ clearTimeout(stopSubmitTimer);
1182
+ stopSubmitTimer = setTimeout(function(){
1183
+ var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
1184
+ //reset firstinvalid
1185
+ firstEvent = false;
1186
+ invalids = [];
1187
+ $(e.target).trigger(lastEvent, lastEvent);
1188
+ }, 9);
1189
+ jElm = null;
1190
+ shadowElem = null;
1075
1191
  });
1076
- nodeNameCache = null;
1077
- });
1192
+ })();
1078
1193
 
1079
- var tempCache;
1080
- var emptyQ = $([]);
1081
- var createNodeNameInit = function(nodeName, fn){
1082
- if(!initProps[nodeName]){
1083
- initProps[nodeName] = [fn];
1084
- } else {
1085
- initProps[nodeName].push(fn);
1086
- }
1087
- if($.isDOMReady){
1088
- (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
1194
+ $.fn.getErrorMessage = function(){
1195
+ var message = '';
1196
+ var elem = this[0];
1197
+ if(elem){
1198
+ message = getContentValidationMessage(elem) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
1089
1199
  }
1200
+ return message;
1090
1201
  };
1091
1202
 
1092
- var elementExtends = {};
1093
- return {
1094
- createTmpCache: function(nodeName){
1095
- if($.isDOMReady){
1096
- tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
1097
- }
1098
- return tempCache || emptyQ;
1099
- },
1100
- flushTmpCache: function(){
1101
- tempCache = null;
1102
- },
1103
- content: function(nodeName, prop){
1104
- createNodeNameInit(nodeName, function(){
1105
- var val = $.attr(this, prop);
1106
- if(val != null){
1107
- $.attr(this, prop, val);
1203
+ if(options.replaceValidationUI){
1204
+ if(options.overrideMessages && (options.customMessages || options.customMessages == null)){
1205
+ options.customMessages = true;
1206
+ options.overrideMessages = false;
1207
+ webshims.info("set overrideMessages to false. Use customMessages instead");
1208
+ }
1209
+ webshims.ready('DOM forms', function(){
1210
+ $(document).on('firstinvalid', function(e){
1211
+ if(!e.isInvalidUIPrevented()){
1212
+ e.preventDefault();
1213
+ $.webshims.validityAlert.showFor( e.target );
1108
1214
  }
1109
1215
  });
1110
- },
1111
- createElement: function(nodeName, fn){
1112
- createNodeNameInit(nodeName, fn);
1113
- },
1114
- extendValue: function(nodeName, prop, value){
1115
- createNodeNameInit(nodeName, function(){
1116
- $(this).each(function(){
1117
- var data = elementData(this, 'propValue', {});
1118
- data[prop] = this[prop];
1119
- this[prop] = value;
1120
- });
1121
- });
1216
+ });
1217
+ }
1218
+ });
1219
+
1220
+ })(jQuery);
1221
+ (function($, Modernizr, webshims){
1222
+ "use strict";
1223
+ var hasNative = Modernizr.audio && Modernizr.video;
1224
+ var supportsLoop = false;
1225
+ var bugs = webshims.bugs;
1226
+
1227
+ var loadSwf = function(){
1228
+ webshims.ready(swfType, function(){
1229
+ if(!webshims.mediaelement.createSWF){
1230
+ webshims.mediaelement.loadSwf = true;
1231
+ webshims.reTest([swfType], hasNative);
1122
1232
  }
1123
- };
1124
- })();
1233
+ });
1234
+ };
1235
+ var options = webshims.cfg.mediaelement;
1236
+ var swfType = 'mediaelement-jaris';
1237
+ var hasSwf;
1238
+ if(!options){
1239
+ webshims.error("mediaelement wasn't implemented but loaded");
1240
+ return;
1241
+ }
1242
+ if(hasNative){
1243
+ var videoElem = document.createElement('video');
1244
+ Modernizr.videoBuffered = ('buffered' in videoElem);
1245
+ supportsLoop = ('loop' in videoElem);
1125
1246
 
1126
- var createPropDefault = function(descs, removeType){
1127
- if(descs.defaultValue === undefined){
1128
- descs.defaultValue = '';
1129
- }
1130
- if(!descs.removeAttr){
1131
- descs.removeAttr = {
1132
- value: function(){
1133
- descs[removeType || 'prop'].set.call(this, descs.defaultValue);
1134
- descs.removeAttr._supvalue.call(this);
1135
- }
1136
- };
1137
- }
1138
- if(!descs.attr){
1139
- descs.attr = {};
1247
+ webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
1248
+
1249
+ if(!Modernizr.videoBuffered){
1250
+ webshims.addPolyfill('mediaelement-native-fix', {
1251
+ f: 'mediaelement',
1252
+ test: Modernizr.videoBuffered,
1253
+ d: ['dom-support']
1254
+ });
1255
+
1256
+ webshims.reTest('mediaelement-native-fix');
1140
1257
  }
1141
- };
1258
+ }
1142
1259
 
1143
- $.extend(webshims, {
1144
-
1145
- getID: (function(){
1146
- var ID = new Date().getTime();
1147
- return function(elem){
1148
- elem = $(elem);
1149
- var id = elem.attr('id');
1150
- if(!id){
1151
- ID++;
1152
- id = 'ID-'+ ID;
1153
- elem.attr('id', id);
1154
- }
1155
- return id;
1156
- };
1157
- })(),
1158
- extendUNDEFProp: function(obj, props){
1159
- $.each(props, function(name, prop){
1160
- if( !(name in obj) ){
1161
- obj[name] = prop;
1162
- }
1163
- });
1164
- },
1165
- //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
1166
- createPropDefault: createPropDefault,
1167
- data: elementData,
1168
- moveToFirstEvent: function(elem, eventType, bindType){
1169
- var events = ($._data(elem, 'events') || {})[eventType];
1170
- var fn;
1260
+ if(hasNative && !options.preferFlash){
1261
+ var noSwitch = {
1262
+ 1: 1,
1263
+ 2: 1
1264
+ };
1265
+ var switchOptions = function(e){
1266
+ var media;
1267
+ var parent = e.target.parentNode;
1268
+ if(!options.preferFlash &&
1269
+ ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) &&
1270
+ (media = $(e.target).closest('audio, video')) && !noSwitch[media.prop('error')]
1271
+ ){
1272
+ $(function(){
1273
+ if(hasSwf && !options.preferFlash){
1274
+ loadSwf();
1275
+ webshims.ready('WINDOWLOAD '+swfType, function(){
1276
+ setTimeout(function(){
1277
+ if(!options.preferFlash && webshims.mediaelement.createSWF && !media.is('.nonnative-api-active')){
1278
+ options.preferFlash = true;
1279
+ document.removeEventListener('error', switchOptions, true);
1280
+ $('audio, video').each(function(){
1281
+ webshims.mediaelement.selectSource(this);
1282
+ });
1283
+ webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src+" Mediaerror: "+ media.prop('error'));
1284
+ }
1285
+ }, 9);
1286
+ });
1287
+ } else{
1288
+ document.removeEventListener('error', switchOptions, true);
1289
+ }
1290
+ });
1291
+ }
1292
+ };
1293
+ document.addEventListener('error', switchOptions, true);
1294
+ $('audio, video').each(function(){
1295
+ var error = $.prop(this, 'error');
1296
+ if(error && !noSwitch[error]){
1297
+ switchOptions({target: this});
1298
+ return false;
1299
+ }
1300
+ });
1301
+ }
1302
+
1303
+
1304
+ if(Modernizr.track && !bugs.track){
1305
+ (function(){
1306
+
1307
+ if(!bugs.track){
1308
+ bugs.track = typeof $('<track />')[0].readyState != 'number';
1309
+ }
1171
1310
 
1172
- if(events && events.length > 1){
1173
- fn = events.pop();
1174
- if(!bindType){
1175
- bindType = 'bind';
1311
+ if(!bugs.track){
1312
+ try {
1313
+ new TextTrackCue(2, 3, '');
1314
+ } catch(e){
1315
+ bugs.track = true;
1176
1316
  }
1177
- if(bindType == 'bind' && events.delegateCount){
1178
- events.splice( events.delegateCount, 0, fn);
1179
- } else {
1180
- events.unshift( fn );
1181
- }
1182
-
1183
-
1184
1317
  }
1185
- elem = null;
1186
- },
1187
- addShadowDom: (function(){
1188
- var resizeTimer;
1189
- var lastHeight;
1190
- var lastWidth;
1191
1318
 
1192
- var docObserve = {
1193
- init: false,
1194
- runs: 0,
1195
- test: function(){
1196
- var height = docObserve.getHeight();
1197
- var width = docObserve.getWidth();
1198
-
1199
- if(height != docObserve.height || width != docObserve.width){
1200
- docObserve.height = height;
1201
- docObserve.width = width;
1202
- docObserve.handler({type: 'docresize'});
1203
- docObserve.runs++;
1204
- if(docObserve.runs < 9){
1205
- setTimeout(docObserve.test, 90);
1206
- }
1319
+ var trackOptions = webshims.cfg.track;
1320
+ var trackListener = function(e){
1321
+ $(e.target).filter('track').each(changeApi);
1322
+ };
1323
+ var changeApi = function(){
1324
+ if(bugs.track || (!trackOptions.override && $.prop(this, 'readyState') == 3)){
1325
+ trackOptions.override = true;
1326
+ webshims.reTest('track');
1327
+ document.removeEventListener('error', trackListener, true);
1328
+ if(this && $.nodeName(this, 'track')){
1329
+ webshims.error("track support was overwritten. Please check your vtt including your vtt mime-type");
1207
1330
  } else {
1208
- docObserve.runs = 0;
1209
- }
1210
- },
1211
- handler: function(e){
1212
- clearTimeout(resizeTimer);
1213
- resizeTimer = setTimeout(function(){
1214
- if(e.type == 'resize'){
1215
- var width = $(window).width();
1216
- var height = $(window).width();
1217
- if(height == lastHeight && width == lastWidth){
1218
- return;
1219
- }
1220
- lastHeight = height;
1221
- lastWidth = width;
1222
-
1223
- docObserve.height = docObserve.getHeight();
1224
- docObserve.width = docObserve.getWidth();
1225
-
1226
- }
1227
- $(document).triggerHandler('updateshadowdom');
1228
- }, (e.type == 'resize') ? 50 : 9);
1229
- },
1230
- _create: function(){
1231
- $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
1232
- var body = document.body;
1233
- var doc = document.documentElement;
1234
- docObserve[type] = function(){
1235
- return Math.max(
1236
- body[ "scroll" + name ], doc[ "scroll" + name ],
1237
- body[ "offset" + name ], doc[ "offset" + name ],
1238
- doc[ "client" + name ]
1239
- );
1240
- };
1241
- });
1242
- },
1243
- start: function(){
1244
- if(!this.init && document.body){
1245
- this.init = true;
1246
- this._create();
1247
- this.height = docObserve.getHeight();
1248
- this.width = docObserve.getWidth();
1249
- setInterval(this.test, 600);
1250
- $(this.test);
1251
- webshims.ready('WINDOWLOAD', this.test);
1252
- $(window).bind('resize', this.handler);
1253
- (function(){
1254
- var oldAnimate = $.fn.animate;
1255
- var animationTimer;
1256
-
1257
- $.fn.animate = function(){
1258
- clearTimeout(animationTimer);
1259
- animationTimer = setTimeout(function(){
1260
- docObserve.test();
1261
- }, 99);
1262
-
1263
- return oldAnimate.apply(this, arguments);
1264
- };
1265
- })();
1331
+ webshims.info("track support was overwritten. due to bad browser support");
1266
1332
  }
1333
+ return false;
1267
1334
  }
1268
1335
  };
1269
-
1270
-
1271
- webshims.docObserve = function(){
1272
- webshims.ready('DOM', function(){
1273
- docObserve.start();
1274
- });
1275
- };
1276
- return function(nativeElem, shadowElem, opts){
1277
- opts = opts || {};
1278
- if(nativeElem.jquery){
1279
- nativeElem = nativeElem[0];
1280
- }
1281
- if(shadowElem.jquery){
1282
- shadowElem = shadowElem[0];
1283
- }
1284
- var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
1285
- var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
1286
- var shadowFocusElementData = {};
1287
- if(!opts.shadowFocusElement){
1288
- opts.shadowFocusElement = shadowElem;
1289
- } else if(opts.shadowFocusElement){
1290
- if(opts.shadowFocusElement.jquery){
1291
- opts.shadowFocusElement = opts.shadowFocusElement[0];
1292
- }
1293
- shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
1294
- }
1295
-
1296
- nativeData.hasShadow = shadowElem;
1297
- shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
1298
- shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
1299
- nativeElement: nativeElem,
1300
- shadowElement: shadowElem,
1301
- shadowFocusElement: opts.shadowFocusElement
1302
- };
1303
- if(opts.shadowChilds){
1304
- opts.shadowChilds.each(function(){
1305
- elementData(this, 'shadowData', shadowData.shadowData);
1306
- });
1307
- }
1336
+ var detectTrackError = function(){
1337
+ document.addEventListener('error', trackListener, true);
1308
1338
 
1309
- if(opts.data){
1310
- shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
1339
+ if(bugs.track){
1340
+ changeApi();
1341
+ } else {
1342
+ $('track').each(changeApi);
1311
1343
  }
1312
- opts = null;
1313
- webshims.docObserve();
1314
1344
  };
1315
- })(),
1316
- propTypes: {
1317
- standard: function(descs, name){
1318
- createPropDefault(descs);
1319
- if(descs.prop){return;}
1320
- descs.prop = {
1321
- set: function(val){
1322
- descs.attr.set.call(this, ''+val);
1323
- },
1324
- get: function(){
1325
- return descs.attr.get.call(this) || descs.defaultValue;
1326
- }
1327
- };
1328
-
1329
- },
1330
- "boolean": function(descs, name){
1331
-
1332
- createPropDefault(descs);
1333
- if(descs.prop){return;}
1334
- descs.prop = {
1335
- set: function(val){
1336
- if(val){
1337
- descs.attr.set.call(this, "");
1338
- } else {
1339
- descs.removeAttr.value.call(this);
1340
- }
1341
- },
1342
- get: function(){
1343
- return descs.attr.get.call(this) != null;
1344
- }
1345
- };
1346
- },
1347
- "src": (function(){
1348
- var anchor = document.createElement('a');
1349
- anchor.style.display = "none";
1350
- return function(descs, name){
1351
-
1352
- createPropDefault(descs);
1353
- if(descs.prop){return;}
1354
- descs.prop = {
1355
- set: function(val){
1356
- descs.attr.set.call(this, val);
1357
- },
1358
- get: function(){
1359
- var href = this.getAttribute(name);
1360
- var ret;
1361
- if(href == null){return '';}
1362
-
1363
- anchor.setAttribute('href', href+'' );
1364
-
1365
- if(!$.support.hrefNormalized){
1366
- try {
1367
- $(anchor).insertAfter(this);
1368
- ret = anchor.getAttribute('href', 4);
1369
- } catch(er){
1370
- ret = anchor.getAttribute('href', 4);
1371
- }
1372
- $(anchor).detach();
1373
- }
1374
- return ret || anchor.href;
1375
- }
1376
- };
1377
- };
1378
- })(),
1379
- enumarated: function(descs, name){
1380
-
1381
- createPropDefault(descs);
1382
- if(descs.prop){return;}
1383
- descs.prop = {
1384
- set: function(val){
1385
- descs.attr.set.call(this, val);
1386
- },
1387
- get: function(){
1388
- var val = (descs.attr.get.call(this) || '').toLowerCase();
1389
- if(!val || descs.limitedTo.indexOf(val) == -1){
1390
- val = descs.defaultValue;
1391
- }
1392
- return val;
1393
- }
1394
- };
1345
+ if(!trackOptions.override){
1346
+ if(webshims.isReady('track')){
1347
+ detectTrackError();
1348
+ } else {
1349
+ $(detectTrackError);
1395
1350
  }
1396
-
1397
- // ,unsignedLong: $.noop
1398
- // ,"doubble": $.noop
1399
- // ,"long": $.noop
1400
- // ,tokenlist: $.noop
1401
- // ,settableTokenlist: $.noop
1402
- },
1403
- reflectProperties: function(nodeNames, props){
1404
- if(typeof props == 'string'){
1405
- props = props.split(listReg);
1406
1351
  }
1407
- props.forEach(function(prop){
1408
- webshims.defineNodeNamesProperty(nodeNames, prop, {
1409
- prop: {
1410
- set: function(val){
1411
- $.attr(this, prop, val);
1412
- },
1413
- get: function(){
1414
- return $.attr(this, prop) || '';
1415
- }
1416
- }
1417
- });
1418
- });
1419
- },
1420
- defineNodeNameProperty: function(nodeName, prop, descs){
1421
- havePolyfill[prop] = true;
1422
-
1423
- if(descs.reflect){
1424
- webshims.propTypes[descs.propType || 'standard'](descs, prop);
1352
+ })();
1353
+
1354
+ }
1355
+
1356
+ webshims.register('mediaelement-core', function($, webshims, window, document, undefined){
1357
+ hasSwf = swfmini.hasFlashPlayerVersion('9.0.115');
1358
+ $('html').addClass(hasSwf ? 'swf' : 'no-swf');
1359
+ var mediaelement = webshims.mediaelement;
1360
+ mediaelement.parseRtmp = function(data){
1361
+ var src = data.src.split('://');
1362
+ var paths = src[1].split('/');
1363
+ var i, len, found;
1364
+ data.server = src[0]+'://'+paths[0]+'/';
1365
+ data.streamId = [];
1366
+ for(i = 1, len = paths.length; i < len; i++){
1367
+ if(!found && paths[i].indexOf(':') !== -1){
1368
+ paths[i] = paths[i].split(':')[1];
1369
+ found = true;
1425
1370
  }
1426
-
1427
- ['prop', 'attr', 'removeAttr'].forEach(function(type){
1428
- var desc = descs[type];
1429
- if(desc){
1430
- if(type === 'prop'){
1431
- desc = $.extend({writeable: true}, desc);
1432
- } else {
1433
- desc = $.extend({}, desc, {writeable: true});
1434
- }
1435
-
1436
- extendQ[type](nodeName, prop, desc);
1437
- if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
1438
- extendNativeValue(nodeName, prop, desc);
1439
- }
1440
- descs[type] = desc;
1441
- }
1442
- });
1443
- if(descs.initAttr){
1444
- initProp.content(nodeName, prop);
1371
+ if(!found){
1372
+ data.server += paths[i]+'/';
1373
+ } else {
1374
+ data.streamId.push(paths[i]);
1445
1375
  }
1446
- return descs;
1447
- },
1376
+ }
1377
+ if(!data.streamId.length){
1378
+ webshims.error('Could not parse rtmp url');
1379
+ }
1380
+ data.streamId = data.streamId.join('/');
1381
+ };
1382
+ var getSrcObj = function(elem, nodeName){
1383
+ elem = $(elem);
1384
+ var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
1385
+ var tmp;
1448
1386
 
1449
- defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
1450
- var olddesc;
1451
- for(var prop in descs){
1452
- if(!_noTmpCache && descs[prop].initAttr){
1453
- initProp.createTmpCache(name);
1454
- }
1455
- if(propType){
1456
- if(descs[prop][propType]){
1457
- //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
1458
- } else {
1459
- descs[prop][propType] = {};
1460
- ['value', 'set', 'get'].forEach(function(copyProp){
1461
- if(copyProp in descs[prop]){
1462
- descs[prop][propType][copyProp] = descs[prop][copyProp];
1463
- delete descs[prop][copyProp];
1464
- }
1465
- });
1466
- }
1387
+ if(!src.src){return src;}
1388
+
1389
+ tmp = elem.attr('data-server');
1390
+ if(tmp != null){
1391
+ src.server = tmp;
1392
+ }
1393
+
1394
+ tmp = elem.attr('type');
1395
+ if(tmp){
1396
+ src.type = tmp;
1397
+ src.container = $.trim(tmp.split(';')[0]);
1398
+ } else {
1399
+ if(!nodeName){
1400
+ nodeName = elem[0].nodeName.toLowerCase();
1401
+ if(nodeName == 'source'){
1402
+ nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
1467
1403
  }
1468
- descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
1469
- }
1470
- if(!_noTmpCache){
1471
- initProp.flushTmpCache();
1472
1404
  }
1473
- return descs;
1474
- },
1475
-
1476
- createElement: function(nodeName, create, descs){
1477
- var ret;
1478
- if($.isFunction(create)){
1479
- create = {
1480
- after: create
1481
- };
1405
+ if(src.server){
1406
+ src.type = nodeName+'/rtmp';
1407
+ src.container = nodeName+'/rtmp';
1408
+ } else {
1409
+
1410
+ tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
1411
+
1412
+ if(tmp){
1413
+ src.type = tmp;
1414
+ src.container = tmp;
1415
+ }
1482
1416
  }
1483
- initProp.createTmpCache(nodeName);
1484
- if(create.before){
1485
- initProp.createElement(nodeName, create.before);
1417
+ }
1418
+ tmp = elem.attr('media');
1419
+ if(tmp){
1420
+ src.media = tmp;
1421
+ }
1422
+ if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
1423
+ if(src.server){
1424
+ src.streamId = src.src;
1425
+ } else {
1426
+ mediaelement.parseRtmp(src);
1486
1427
  }
1487
- if(descs){
1488
- ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
1428
+ }
1429
+ return src;
1430
+ };
1431
+
1432
+
1433
+
1434
+ var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
1435
+
1436
+ var loadTrackUi = function(){
1437
+ if(loadTrackUi.loaded){return;}
1438
+ loadTrackUi.loaded = true;
1439
+ $(function(){
1440
+ webshims.loader.loadList(['track-ui']);
1441
+ });
1442
+ };
1443
+ var loadYt = (function(){
1444
+ var loaded;
1445
+ return function(){
1446
+ if(loaded || !hasYt){return;}
1447
+ loaded = true;
1448
+ webshims.loader.loadScript("https://www.youtube.com/player_api");
1449
+ $(function(){
1450
+ webshims._polyfill(["mediaelement-yt"]);
1451
+ });
1452
+ };
1453
+ })();
1454
+ var loadThird = function(){
1455
+ if(hasSwf){
1456
+ loadSwf();
1457
+ } else {
1458
+ loadYt();
1459
+ }
1460
+ };
1461
+
1462
+ webshims.addPolyfill('mediaelement-yt', {
1463
+ test: !hasYt,
1464
+ d: ['dom-support']
1465
+ });
1466
+
1467
+ mediaelement.mimeTypes = {
1468
+ audio: {
1469
+ //ogm shouldn´t be used!
1470
+ 'audio/ogg': ['ogg','oga', 'ogm'],
1471
+ 'audio/ogg;codecs="opus"': 'opus',
1472
+ 'audio/mpeg': ['mp2','mp3','mpga','mpega'],
1473
+ 'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
1474
+ 'audio/wav': ['wav'],
1475
+ 'audio/3gpp': ['3gp','3gpp'],
1476
+ 'audio/webm': ['webm'],
1477
+ 'audio/fla': ['flv', 'f4a', 'fla'],
1478
+ 'application/x-mpegURL': ['m3u8', 'm3u']
1479
+ },
1480
+ video: {
1481
+ //ogm shouldn´t be used!
1482
+ 'video/ogg': ['ogg','ogv', 'ogm'],
1483
+ 'video/mpeg': ['mpg','mpeg','mpe'],
1484
+ 'video/mp4': ['mp4','mpg4', 'm4v'],
1485
+ 'video/quicktime': ['mov','qt'],
1486
+ 'video/x-msvideo': ['avi'],
1487
+ 'video/x-ms-asf': ['asf', 'asx'],
1488
+ 'video/flv': ['flv', 'f4v'],
1489
+ 'video/3gpp': ['3gp','3gpp'],
1490
+ 'video/webm': ['webm'],
1491
+ 'application/x-mpegURL': ['m3u8', 'm3u'],
1492
+ 'video/MP2T': ['ts']
1489
1493
  }
1490
- if(create.after){
1491
- initProp.createElement(nodeName, create.after);
1494
+ }
1495
+ ;
1496
+
1497
+ mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
1498
+
1499
+ mediaelement.getTypeForSrc = function(src, nodeName, data){
1500
+ if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
1501
+ return 'video/youtube';
1502
+ }
1503
+ if(src.indexOf('rtmp') === 0){
1504
+ return nodeName+'/rtmp';
1505
+ }
1506
+ src = src.split('?')[0].split('.');
1507
+ src = src[src.length - 1];
1508
+ var mt;
1509
+
1510
+ $.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
1511
+ if(exts.indexOf(src) !== -1){
1512
+ mt = mimeType;
1513
+ return false;
1492
1514
  }
1493
- initProp.flushTmpCache();
1494
- return ret;
1495
- },
1496
- onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
1497
- if(typeof nodeNames == 'string'){
1498
- nodeNames = nodeNames.split(listReg);
1515
+ });
1516
+ return mt;
1517
+ };
1518
+
1519
+
1520
+ mediaelement.srces = function(mediaElem, srces){
1521
+ mediaElem = $(mediaElem);
1522
+ if(!srces){
1523
+ srces = [];
1524
+ var nodeName = mediaElem[0].nodeName.toLowerCase();
1525
+ var src = getSrcObj(mediaElem, nodeName);
1526
+
1527
+ if(!src.src){
1528
+
1529
+ $('source', mediaElem).each(function(){
1530
+ src = getSrcObj(this, nodeName);
1531
+ if(src.src){srces.push(src);}
1532
+ });
1533
+ } else {
1534
+ srces.push(src);
1499
1535
  }
1500
- if($.isFunction(desc)){
1501
- desc = {set: desc};
1536
+ return srces;
1537
+ } else {
1538
+ mediaElem.removeAttr('src').removeAttr('type').find('source').remove();
1539
+ if(!$.isArray(srces)){
1540
+ srces = [srces];
1502
1541
  }
1542
+ srces.forEach(function(src){
1543
+ var source = document.createElement('source');
1544
+ if(typeof src == 'string'){
1545
+ src = {src: src};
1546
+ }
1547
+ source.setAttribute('src', src.src);
1548
+ if(src.type){
1549
+ source.setAttribute('type', src.type);
1550
+ }
1551
+ if(src.media){
1552
+ source.setAttribute('media', src.media);
1553
+ }
1554
+ mediaElem.append(source);
1555
+ });
1503
1556
 
1504
- nodeNames.forEach(function(name){
1505
- if(!modifyProps[name]){
1506
- modifyProps[name] = {};
1557
+ }
1558
+ };
1559
+
1560
+
1561
+ $.fn.loadMediaSrc = function(srces, poster){
1562
+ return this.each(function(){
1563
+ if(poster !== undefined){
1564
+ $(this).removeAttr('poster');
1565
+ if(poster){
1566
+ $.attr(this, 'poster', poster);
1507
1567
  }
1508
- if(typeof props == 'string'){
1509
- props = props.split(listReg);
1568
+ }
1569
+ mediaelement.srces(this, srces);
1570
+ $(this).mediaLoad();
1571
+ });
1572
+ };
1573
+
1574
+ 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'];
1575
+
1576
+ mediaelement.canThirdPlaySrces = function(mediaElem, srces){
1577
+ var ret = '';
1578
+ if(hasSwf || hasYt){
1579
+ mediaElem = $(mediaElem);
1580
+ srces = srces || mediaelement.srces(mediaElem);
1581
+ $.each(srces, function(i, src){
1582
+ if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
1583
+ ret = src;
1584
+ return false;
1510
1585
  }
1511
- if(desc.initAttr){
1512
- initProp.createTmpCache(name);
1586
+ });
1587
+
1588
+ }
1589
+
1590
+ return ret;
1591
+ };
1592
+
1593
+ var nativeCanPlayType = {};
1594
+ mediaelement.canNativePlaySrces = function(mediaElem, srces){
1595
+ var ret = '';
1596
+ if(hasNative){
1597
+ mediaElem = $(mediaElem);
1598
+ var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
1599
+ var nativeCanPlay = (nativeCanPlayType[nodeName] || {prop: {_supvalue: false}}).prop._supvalue || mediaElem[0].canPlayType;
1600
+ if(!nativeCanPlay){return ret;}
1601
+ srces = srces || mediaelement.srces(mediaElem);
1602
+
1603
+ $.each(srces, function(i, src){
1604
+ if(src.type && nativeCanPlay.call(mediaElem[0], src.type) ){
1605
+ ret = src;
1606
+ return false;
1513
1607
  }
1514
- props.forEach(function(prop){
1515
- if(!modifyProps[name][prop]){
1516
- modifyProps[name][prop] = [];
1517
- havePolyfill[prop] = true;
1518
- }
1519
- if(desc.set){
1520
- if(only){
1521
- desc.set.only = only;
1522
- }
1523
- modifyProps[name][prop].push(desc.set);
1524
- }
1525
-
1526
- if(desc.initAttr){
1527
- initProp.content(name, prop);
1528
- }
1529
- });
1530
- initProp.flushTmpCache();
1531
-
1532
1608
  });
1533
- },
1534
- defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
1535
- if(!descs){
1536
- descs = {};
1609
+ }
1610
+ return ret;
1611
+ };
1612
+
1613
+ mediaelement.setError = function(elem, message){
1614
+ if(!message){
1615
+ message = "can't play sources";
1616
+ }
1617
+
1618
+ $(elem).pause().data('mediaerror', message);
1619
+ webshims.error('mediaelementError: '+ message);
1620
+ setTimeout(function(){
1621
+ if($(elem).data('mediaerror')){
1622
+ $(elem).trigger('mediaerror');
1537
1623
  }
1538
- if($.isFunction(descs)){
1539
- descs.set = descs;
1624
+ }, 1);
1625
+ };
1626
+
1627
+ var handleThird = (function(){
1628
+ var requested;
1629
+ return function( mediaElem, ret, data ){
1630
+ if(!requested){
1631
+ loadTrackUi();
1540
1632
  }
1541
- webshims.defineNodeNamesProperty(elementNames, prop, {
1542
- attr: {
1543
- set: function(val){
1544
- this.setAttribute(prop, val);
1545
- if(descs.set){
1546
- descs.set.call(this, true);
1547
- }
1548
- },
1549
- get: function(){
1550
- var ret = this.getAttribute(prop);
1551
- return (ret == null) ? undefined : prop;
1552
- }
1553
- },
1554
- removeAttr: {
1555
- value: function(){
1556
- this.removeAttribute(prop);
1557
- if(descs.set){
1558
- descs.set.call(this, false);
1559
- }
1560
- }
1561
- },
1562
- reflect: true,
1563
- propType: 'boolean',
1564
- initAttr: descs.initAttr || false
1633
+ webshims.ready(hasSwf ? swfType : 'mediaelement-yt', function(){
1634
+ if(mediaelement.createSWF){
1635
+ mediaelement.createSWF( mediaElem, ret, data );
1636
+ } else if(!requested) {
1637
+ requested = true;
1638
+ loadThird();
1639
+ //readd to ready
1640
+ handleThird( mediaElem, ret, data );
1641
+ }
1565
1642
  });
1566
- },
1567
- contentAttr: function(elem, name, val){
1568
- if(!elem.nodeName){return;}
1569
- var attr;
1570
- if(val === undefined){
1571
- attr = (elem.attributes[name] || {});
1572
- val = attr.specified ? attr.value : null;
1573
- return (val == null) ? undefined : val;
1643
+ if(!requested && hasYt && !mediaelement.createSWF){
1644
+ loadYt();
1574
1645
  }
1575
-
1576
- if(typeof val == 'boolean'){
1577
- if(!val){
1578
- elem.removeAttribute(name);
1646
+ };
1647
+ })();
1648
+
1649
+ var stepSources = function(elem, data, useSwf, _srces, _noLoop){
1650
+ var ret;
1651
+ if(useSwf || (useSwf !== false && data && data.isActive == 'third')){
1652
+ ret = mediaelement.canThirdPlaySrces(elem, _srces);
1653
+ if(!ret){
1654
+ if(_noLoop){
1655
+ mediaelement.setError(elem, false);
1579
1656
  } else {
1580
- elem.setAttribute(name, name);
1657
+ stepSources(elem, data, false, _srces, true);
1581
1658
  }
1582
1659
  } else {
1583
- elem.setAttribute(name, val);
1660
+ handleThird(elem, ret, data);
1584
1661
  }
1585
- },
1586
-
1587
- // set current Lang:
1588
- // - webshims.activeLang(lang:string);
1589
- // get current lang
1590
- // - webshims.activeLang();
1591
- // get current lang
1592
- // webshims.activeLang({
1593
- // register: moduleName:string,
1594
- // callback: callback:function
1595
- // });
1596
- // get/set including removeLang
1597
- // - webshims.activeLang({
1598
- // module: moduleName:string,
1599
- // callback: callback:function,
1600
- // langObj: languageObj:array/object
1601
- // });
1602
- activeLang: (function(){
1603
- var callbacks = [];
1604
- var registeredCallbacks = {};
1605
- var currentLang;
1606
- var shortLang;
1607
- var notLocal = /:\/\/|^\.*\//;
1608
- var loadRemoteLang = function(data, lang, options){
1609
- var langSrc;
1610
- if(lang && options && $.inArray(lang, options.availabeLangs || []) !== -1){
1611
- data.loading = true;
1612
- langSrc = options.langSrc;
1613
- if(!notLocal.test(langSrc)){
1614
- langSrc = webshims.cfg.basePath+langSrc;
1662
+ } else {
1663
+ ret = mediaelement.canNativePlaySrces(elem, _srces);
1664
+ if(!ret){
1665
+ if(_noLoop){
1666
+ mediaelement.setError(elem, false);
1667
+ if(data && data.isActive == 'third') {
1668
+ mediaelement.setActive(elem, 'html5', data);
1615
1669
  }
1616
- webshims.loader.loadScript(langSrc+lang+'.js', function(){
1617
- if(data.langObj[lang]){
1618
- data.loading = false;
1619
- callLang(data, true);
1620
- } else {
1621
- $(function(){
1622
- if(data.langObj[lang]){
1623
- callLang(data, true);
1624
- }
1625
- data.loading = false;
1626
- });
1627
- }
1628
- });
1629
- return true;
1670
+ } else {
1671
+ stepSources(elem, data, true, _srces, true);
1630
1672
  }
1631
- return false;
1632
- };
1633
- var callRegister = function(module){
1634
- if(registeredCallbacks[module]){
1635
- registeredCallbacks[module].forEach(function(data){
1636
- data.callback();
1637
- });
1673
+ } else if(data && data.isActive == 'third') {
1674
+ mediaelement.setActive(elem, 'html5', data);
1675
+ }
1676
+ }
1677
+ };
1678
+ var stopParent = /^(?:embed|object|datalist)$/i;
1679
+ var selectSource = function(elem, data){
1680
+ var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
1681
+ var _srces = mediaelement.srces(elem);
1682
+ var parent = elem.parentNode;
1683
+
1684
+ clearTimeout(baseData.loadTimer);
1685
+ $.data(elem, 'mediaerror', false);
1686
+
1687
+ if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
1688
+ data = data || webshims.data(elem, 'mediaelement');
1689
+ stepSources(elem, data, options.preferFlash || undefined, _srces);
1690
+ };
1691
+ mediaelement.selectSource = selectSource;
1692
+
1693
+
1694
+ $(document).on('ended', function(e){
1695
+ var data = webshims.data(e.target, 'mediaelement');
1696
+ if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
1697
+ setTimeout(function(){
1698
+ if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
1699
+ $(e.target).prop('currentTime', 0).play();
1700
+ }, 1);
1701
+
1702
+ });
1703
+
1704
+ webshims.ready('dom-support', function(){
1705
+ if(!supportsLoop){
1706
+ webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
1707
+ }
1708
+
1709
+ ['audio', 'video'].forEach(function(nodeName){
1710
+ var supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
1711
+ prop: {
1712
+ value: function(){
1713
+ var data = webshims.data(this, 'mediaelement');
1714
+ selectSource(this, data);
1715
+ if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
1716
+ supLoad.prop._supvalue.apply(this, arguments);
1717
+ }
1718
+ }
1638
1719
  }
1639
- };
1640
- var callLang = function(data, _noLoop){
1641
- if(data.activeLang != currentLang && data.activeLang !== shortLang){
1642
- var options = modules[data.module].options;
1643
- if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
1644
- data.activeLang = currentLang;
1645
- data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
1646
- callRegister(data.module);
1647
- } else if( !_noLoop &&
1648
- !loadRemoteLang(data, currentLang, options) &&
1649
- !loadRemoteLang(data, shortLang, options) &&
1650
- data.langObj[''] && data.activeLang !== '' ) {
1651
- data.activeLang = '';
1652
- data.callback(data.langObj[''], currentLang);
1653
- callRegister(data.module);
1720
+ });
1721
+ nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
1722
+ prop: {
1723
+ value: function(type){
1724
+ var ret = '';
1725
+ if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
1726
+ ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
1727
+ if(ret == 'no'){
1728
+ ret = '';
1729
+ }
1730
+ }
1731
+ if(!ret && hasSwf){
1732
+ type = $.trim((type || '').split(';')[0]);
1733
+ if(mediaelement.swfMimeTypes.indexOf(type) != -1){
1734
+ ret = 'maybe';
1735
+ }
1736
+ }
1737
+ return ret;
1654
1738
  }
1655
1739
  }
1656
- };
1657
-
1658
-
1659
- var activeLang = function(lang){
1740
+ });
1741
+ });
1742
+ webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
1743
+ set: function(){
1744
+ var elem = this;
1745
+ var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
1746
+ clearTimeout(baseData.loadTimer);
1747
+ baseData.loadTimer = setTimeout(function(){
1748
+ selectSource(elem);
1749
+ elem = null;
1750
+ }, 9);
1751
+ }
1752
+ });
1753
+ });
1754
+
1755
+ var initMediaElements = function(){
1756
+ var testFixMedia = function(){
1757
+ if(webshims.implement(this, 'mediaelement')){
1758
+ selectSource(this);
1660
1759
 
1661
- if(typeof lang == 'string' && lang !== currentLang){
1662
- currentLang = lang;
1663
- shortLang = currentLang.split('-')[0];
1664
- if(currentLang == shortLang){
1665
- shortLang = false;
1666
- }
1667
- $.each(callbacks, function(i, data){
1668
- callLang(data);
1669
- });
1670
- } else if(typeof lang == 'object'){
1671
-
1672
- if(lang.register){
1673
- if(!registeredCallbacks[lang.register]){
1674
- registeredCallbacks[lang.register] = [];
1760
+ if(hasNative){
1761
+ var bufferTimer;
1762
+ var lastBuffered;
1763
+ var elem = this;
1764
+ var getBufferedString = function(){
1765
+ var buffered = $.prop(elem, 'buffered');
1766
+ if(!buffered){return;}
1767
+ var bufferString = "";
1768
+ for(var i = 0, len = buffered.length; i < len;i++){
1769
+ bufferString += buffered.end(i);
1675
1770
  }
1676
- registeredCallbacks[lang.register].push(lang);
1677
- lang.callback();
1678
- } else {
1679
- if(!lang.activeLang){
1680
- lang.activeLang = '';
1771
+ return bufferString;
1772
+ };
1773
+ var testBuffer = function(){
1774
+ var buffered = getBufferedString();
1775
+ if(buffered != lastBuffered){
1776
+ lastBuffered = buffered;
1777
+ $(elem).triggerHandler('progress');
1681
1778
  }
1682
- callbacks.push(lang);
1683
- callLang(lang);
1779
+ };
1780
+
1781
+ $(this)
1782
+ .on({
1783
+ 'play loadstart progress': function(e){
1784
+ if(e.type == 'progress'){
1785
+ lastBuffered = getBufferedString();
1786
+ }
1787
+ clearTimeout(bufferTimer);
1788
+ bufferTimer = setTimeout(testBuffer, 999);
1789
+ },
1790
+ 'emptied stalled mediaerror abort suspend': function(e){
1791
+ if(e.type == 'emptied'){
1792
+ lastBuffered = false;
1793
+ }
1794
+ clearTimeout(bufferTimer);
1795
+ }
1796
+ })
1797
+ ;
1798
+ if('ActiveXObject' in window && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay],.nonnative-api-active)')){
1799
+ $(this).prop('preload', 'metadata').mediaLoad();
1684
1800
  }
1685
1801
  }
1686
- return currentLang;
1687
- };
1688
-
1689
- return activeLang;
1690
- })()
1691
- });
1692
-
1693
- $.each({
1694
- defineNodeNamesProperty: 'defineNodeNameProperty',
1695
- defineNodeNamesProperties: 'defineNodeNameProperties',
1696
- createElements: 'createElement'
1697
- }, function(name, baseMethod){
1698
- webshims[name] = function(names, a, b, c){
1699
- if(typeof names == 'string'){
1700
- names = names.split(listReg);
1701
1802
  }
1702
- var retDesc = {};
1703
- names.forEach(function(nodeName){
1704
- retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
1705
- });
1706
- return retDesc;
1803
+
1707
1804
  };
1708
- });
1709
-
1710
- webshims.isReady('webshimLocalization', true);
1711
- });
1712
- //html5a11y
1713
- (function($, document){
1714
- //if we support basic styleing or do not support ARIA (assumed) abort
1715
- if(!Modernizr.localstorage || ('hidden' in document.createElement('a'))){return;}
1716
-
1717
- var elemMappings = {
1718
- article: "article",
1719
- aside: "complementary",
1720
- section: "region",
1721
- nav: "navigation",
1722
- address: "contentinfo"
1723
- };
1724
- var addRole = function(elem, role){
1725
- var hasRole = elem.getAttribute('role');
1726
- if (!hasRole) {
1727
- elem.setAttribute('role', role);
1805
+ var handleMedia = false;
1806
+
1807
+
1808
+ webshims.ready('dom-support', function(){
1809
+ handleMedia = true;
1810
+ webshims.addReady(function(context, insertedElement){
1811
+ var media = $('video, audio', context)
1812
+ .add(insertedElement.filter('video, audio'))
1813
+ .each(testFixMedia)
1814
+ ;
1815
+ if(!loadTrackUi.loaded && $('track', media).length){
1816
+ loadTrackUi();
1817
+ }
1818
+ media = null;
1819
+ });
1820
+ });
1821
+
1822
+ if(hasNative && !handleMedia){
1823
+ webshims.addReady(function(context, insertedElement){
1824
+ if(!handleMedia){
1825
+ $('video, audio', context)
1826
+ .add(insertedElement.filter('video, audio'))
1827
+ .each(function(){
1828
+ if(!mediaelement.canNativePlaySrces(this) || (!loadTrackUi.loaded && $('track', this).length)){
1829
+ loadThird();
1830
+ handleMedia = true;
1831
+ return false;
1832
+ }
1833
+ })
1834
+ ;
1835
+ }
1836
+ });
1728
1837
  }
1729
1838
  };
1730
1839
 
1731
- $.webshims.addReady(function(context, contextElem){
1732
- $.each(elemMappings, function(name, role){
1733
- var elems = $(name, context).add(contextElem.filter(name));
1734
- for (var i = 0, len = elems.length; i < len; i++) {
1735
- addRole(elems[i], role);
1840
+ if(Modernizr.track && !bugs.track){
1841
+ webshims.defineProperty(TextTrack.prototype, 'shimActiveCues', {
1842
+ get: function(){
1843
+ return this._shimActiveCues || this.activeCues;
1736
1844
  }
1737
1845
  });
1738
- if (context === document) {
1739
- var header = document.getElementsByTagName('header')[0];
1740
- var footers = document.getElementsByTagName('footer');
1741
- var footerLen = footers.length;
1742
- if (header && !$(header).closest('section, article')[0]) {
1743
- addRole(header, 'banner');
1744
- }
1745
- if (!footerLen) {
1746
- return;
1747
- }
1748
- var footer = footers[footerLen - 1];
1749
- if (!$(footer).closest('section, article')[0]) {
1750
- addRole(footer, 'contentinfo');
1751
- }
1752
- }
1753
- });
1754
-
1755
- })(jQuery, document);
1846
+ }
1847
+ //set native implementation ready, before swf api is retested
1848
+ if(hasNative){
1849
+ webshims.isReady('mediaelement-core', true);
1850
+ initMediaElements();
1851
+ webshims.ready('WINDOWLOAD mediaelement', loadThird);
1852
+ } else {
1853
+ webshims.ready(swfType, initMediaElements);
1854
+ }
1855
+ webshims.ready('WINDOWLOAD mediaelement', loadTrackUi);
1856
+ });
1857
+ })(jQuery, Modernizr, jQuery.webshims);