webshims-rails 0.4.7 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +15 -0
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/extras/custom-validity.js +1 -1
  4. data/vendor/assets/javascripts/webshims/extras/mousepress.js +1 -1
  5. data/vendor/assets/javascripts/webshims/polyfiller.js +197 -166
  6. data/vendor/assets/javascripts/webshims/shims/combos/1.js +1711 -1609
  7. data/vendor/assets/javascripts/webshims/shims/combos/10.js +2575 -2253
  8. data/vendor/assets/javascripts/webshims/shims/combos/11.js +2452 -1476
  9. data/vendor/assets/javascripts/webshims/shims/combos/12.js +1405 -1159
  10. data/vendor/assets/javascripts/webshims/shims/combos/13.js +1316 -963
  11. data/vendor/assets/javascripts/webshims/shims/combos/14.js +1862 -179
  12. data/vendor/assets/javascripts/webshims/shims/combos/15.js +4327 -287
  13. data/vendor/assets/javascripts/webshims/shims/combos/16.js +3887 -586
  14. data/vendor/assets/javascripts/webshims/shims/combos/17.js +2911 -2159
  15. data/vendor/assets/javascripts/webshims/shims/combos/18.js +3425 -1730
  16. data/vendor/assets/javascripts/webshims/shims/combos/19.js +2854 -1203
  17. data/vendor/assets/javascripts/webshims/shims/combos/2.js +3351 -2130
  18. data/vendor/assets/javascripts/webshims/shims/combos/20.js +2426 -581
  19. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1915 -1574
  20. data/vendor/assets/javascripts/webshims/shims/combos/22.js +864 -2275
  21. data/vendor/assets/javascripts/webshims/shims/combos/23.js +609 -1811
  22. data/vendor/assets/javascripts/webshims/shims/combos/3.js +1655 -2736
  23. data/vendor/assets/javascripts/webshims/shims/combos/4.js +1037 -603
  24. data/vendor/assets/javascripts/webshims/shims/combos/5.js +3100 -773
  25. data/vendor/assets/javascripts/webshims/shims/combos/6.js +3631 -840
  26. data/vendor/assets/javascripts/webshims/shims/combos/7.js +3596 -1354
  27. data/vendor/assets/javascripts/webshims/shims/combos/8.js +1731 -188
  28. data/vendor/assets/javascripts/webshims/shims/combos/9.js +3243 -1431
  29. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +107 -18
  30. data/vendor/assets/javascripts/webshims/shims/es5.js +1 -0
  31. data/vendor/assets/javascripts/webshims/shims/form-core.js +553 -464
  32. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +160 -154
  33. data/vendor/assets/javascripts/webshims/shims/form-message.js +73 -49
  34. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +18 -1
  35. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +161 -36
  36. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +2130 -813
  37. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +206 -58
  38. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ar.js → formcfg-ar.js} +30 -0
  39. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ch-ZN.js → formcfg-ch-ZN.js} +31 -0
  40. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-de.txt → formcfg-de.txt} +50 -11
  41. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-el.js → formcfg-el.js} +31 -0
  42. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-en.txt → formcfg-en.txt} +44 -11
  43. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-es.js → formcfg-es.js} +31 -0
  44. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-fr.js → formcfg-fr.js} +31 -0
  45. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-he.js → formcfg-he.js} +31 -0
  46. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-hi.js → formcfg-hi.js} +31 -0
  47. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-hu.js → formcfg-hu.js} +31 -0
  48. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-it.js → formcfg-it.js} +31 -0
  49. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ja.js → formcfg-ja.js} +31 -0
  50. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-nl.js → formcfg-nl.js} +31 -0
  51. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-pt-PT.js → formcfg-pt-PT.js} +31 -0
  52. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-ru.js → formcfg-ru.js} +31 -0
  53. data/vendor/assets/javascripts/webshims/shims/i18n/{errormessages-sv.js → formcfg-sv.js} +32 -0
  54. data/vendor/assets/javascripts/webshims/shims/json-storage.js +16 -10
  55. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +155 -122
  56. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +76 -41
  57. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +8 -16
  58. data/vendor/assets/javascripts/webshims/shims/range-ui.js +388 -0
  59. data/vendor/assets/javascripts/webshims/shims/styles/config.rb +12 -0
  60. data/vendor/assets/javascripts/webshims/shims/styles/forms.png +0 -0
  61. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +1186 -0
  62. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +868 -548
  63. data/vendor/assets/javascripts/webshims/shims/styles/vertical-range.png +0 -0
  64. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  65. data/vendor/assets/javascripts/webshims/shims/swfmini.js +497 -0
  66. data/vendor/assets/javascripts/webshims/shims/track-ui.js +3 -0
  67. data/vendor/assets/javascripts/webshims/shims/track.js +29 -29
  68. metadata +26 -125
  69. data/vendor/assets/javascripts/webshims/minified/extras/custom-validity.js +0 -1
  70. data/vendor/assets/javascripts/webshims/minified/extras/modernizr-custom.js +0 -1
  71. data/vendor/assets/javascripts/webshims/minified/extras/mousepress.js +0 -1
  72. data/vendor/assets/javascripts/webshims/minified/polyfiller.js +0 -1
  73. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/canvas2png.js +0 -1
  74. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/flashcanvas.js +0 -1
  75. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/flashcanvas.swf +0 -0
  76. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/proxy.php +0 -73
  77. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvas/save.php +0 -49
  78. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/canvas2png.js +0 -1
  79. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/flash10canvas.swf +0 -0
  80. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/flash9canvas.swf +0 -0
  81. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/flashcanvas.js +0 -1
  82. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/proxy.php +0 -73
  83. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/save.php +0 -49
  84. data/vendor/assets/javascripts/webshims/minified/shims/combos/1.js +0 -1
  85. data/vendor/assets/javascripts/webshims/minified/shims/combos/10.js +0 -1
  86. data/vendor/assets/javascripts/webshims/minified/shims/combos/11.js +0 -1
  87. data/vendor/assets/javascripts/webshims/minified/shims/combos/12.js +0 -1
  88. data/vendor/assets/javascripts/webshims/minified/shims/combos/13.js +0 -1
  89. data/vendor/assets/javascripts/webshims/minified/shims/combos/14.js +0 -1
  90. data/vendor/assets/javascripts/webshims/minified/shims/combos/15.js +0 -1
  91. data/vendor/assets/javascripts/webshims/minified/shims/combos/16.js +0 -1
  92. data/vendor/assets/javascripts/webshims/minified/shims/combos/17.js +0 -1
  93. data/vendor/assets/javascripts/webshims/minified/shims/combos/18.js +0 -1
  94. data/vendor/assets/javascripts/webshims/minified/shims/combos/19.js +0 -1
  95. data/vendor/assets/javascripts/webshims/minified/shims/combos/2.js +0 -1
  96. data/vendor/assets/javascripts/webshims/minified/shims/combos/20.js +0 -1
  97. data/vendor/assets/javascripts/webshims/minified/shims/combos/21.js +0 -1
  98. data/vendor/assets/javascripts/webshims/minified/shims/combos/22.js +0 -1
  99. data/vendor/assets/javascripts/webshims/minified/shims/combos/23.js +0 -1
  100. data/vendor/assets/javascripts/webshims/minified/shims/combos/24.js +0 -1
  101. data/vendor/assets/javascripts/webshims/minified/shims/combos/25.js +0 -1
  102. data/vendor/assets/javascripts/webshims/minified/shims/combos/26.js +0 -1
  103. data/vendor/assets/javascripts/webshims/minified/shims/combos/27.js +0 -1
  104. data/vendor/assets/javascripts/webshims/minified/shims/combos/3.js +0 -1
  105. data/vendor/assets/javascripts/webshims/minified/shims/combos/4.js +0 -1
  106. data/vendor/assets/javascripts/webshims/minified/shims/combos/5.js +0 -1
  107. data/vendor/assets/javascripts/webshims/minified/shims/combos/59.js +0 -1
  108. data/vendor/assets/javascripts/webshims/minified/shims/combos/6.js +0 -1
  109. data/vendor/assets/javascripts/webshims/minified/shims/combos/7.js +0 -1
  110. data/vendor/assets/javascripts/webshims/minified/shims/combos/8.js +0 -1
  111. data/vendor/assets/javascripts/webshims/minified/shims/combos/9.js +0 -1
  112. data/vendor/assets/javascripts/webshims/minified/shims/details.js +0 -1
  113. data/vendor/assets/javascripts/webshims/minified/shims/dom-extend.js +0 -1
  114. data/vendor/assets/javascripts/webshims/minified/shims/es5.js +0 -1
  115. data/vendor/assets/javascripts/webshims/minified/shims/excanvas.js +0 -1
  116. data/vendor/assets/javascripts/webshims/minified/shims/form-core.js +0 -1
  117. data/vendor/assets/javascripts/webshims/minified/shims/form-datalist.js +0 -1
  118. data/vendor/assets/javascripts/webshims/minified/shims/form-message.js +0 -1
  119. data/vendor/assets/javascripts/webshims/minified/shims/form-native-extend.js +0 -1
  120. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-api.js +0 -1
  121. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-ui.js +0 -1
  122. data/vendor/assets/javascripts/webshims/minified/shims/form-shim-extend.js +0 -1
  123. data/vendor/assets/javascripts/webshims/minified/shims/geolocation.js +0 -1
  124. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ar.js +0 -1
  125. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ch-ZN.js +0 -1
  126. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-de.txt +0 -33
  127. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-el.js +0 -1
  128. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-en.txt +0 -34
  129. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-es.js +0 -1
  130. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-fr.js +0 -1
  131. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-he.js +0 -1
  132. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-hi.js +0 -1
  133. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-hu.js +0 -1
  134. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-it.js +0 -1
  135. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ja.js +0 -1
  136. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-nl.js +0 -1
  137. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-pt-PT.js +0 -1
  138. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-ru.js +0 -1
  139. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-sv.js +0 -1
  140. data/vendor/assets/javascripts/webshims/minified/shims/json-storage.js +0 -1
  141. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/license.txt +0 -1
  142. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/player.swf +0 -0
  143. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/readme.html +0 -87
  144. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-core.js +0 -1
  145. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-jaris.js +0 -1
  146. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-native-fix.js +0 -1
  147. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-swf.js +0 -1
  148. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-yt.js +0 -1
  149. data/vendor/assets/javascripts/webshims/minified/shims/styles/details-arrows.png +0 -0
  150. data/vendor/assets/javascripts/webshims/minified/shims/styles/forms.png +0 -0
  151. data/vendor/assets/javascripts/webshims/minified/shims/styles/polyfill-loader.gif +0 -0
  152. data/vendor/assets/javascripts/webshims/minified/shims/styles/shim.css +0 -1
  153. data/vendor/assets/javascripts/webshims/minified/shims/swf/JarisFLVPlayer.swf +0 -0
  154. data/vendor/assets/javascripts/webshims/minified/shims/swf/jwwebshims.swf +0 -0
  155. data/vendor/assets/javascripts/webshims/minified/shims/swf/localStorage.swf +0 -0
  156. data/vendor/assets/javascripts/webshims/minified/shims/track-ui.js +0 -1
  157. data/vendor/assets/javascripts/webshims/minified/shims/track.js +0 -1
  158. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/README +0 -62
  159. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/README +0 -82
  160. data/vendor/assets/javascripts/webshims/shims/combos/24.js +0 -2872
  161. data/vendor/assets/javascripts/webshims/shims/combos/25.js +0 -2376
  162. data/vendor/assets/javascripts/webshims/shims/combos/26.js +0 -3009
  163. data/vendor/assets/javascripts/webshims/shims/combos/27.js +0 -4150
  164. data/vendor/assets/javascripts/webshims/shims/combos/59.js +0 -1747
  165. data/vendor/assets/javascripts/webshims/shims/jwplayer/license.txt +0 -1
  166. data/vendor/assets/javascripts/webshims/shims/jwplayer/player.swf +0 -0
  167. data/vendor/assets/javascripts/webshims/shims/jwplayer/readme.html +0 -87
  168. data/vendor/assets/javascripts/webshims/shims/mediaelement-swf.js +0 -972
@@ -1,6 +1,515 @@
1
+ /*! SWFMini - a SWFObject 2.2 cut down version for webshims
2
+ *
3
+ * based on SWFObject v2.2 <http://code.google.com/p/swfobject/>
4
+ is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
5
+ */
6
+
7
+ var swfmini = function() {
8
+
9
+ var UNDEF = "undefined",
10
+ OBJECT = "object",
11
+ webshims = jQuery.webshims,
12
+ SHOCKWAVE_FLASH = "Shockwave Flash",
13
+ SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
14
+ FLASH_MIME_TYPE = "application/x-shockwave-flash",
15
+
16
+ win = window,
17
+ doc = document,
18
+ nav = navigator,
19
+
20
+ plugin = false,
21
+ domLoadFnArr = [main],
22
+ objIdArr = [],
23
+ listenersArr = [],
24
+ storedAltContent,
25
+ storedAltContentId,
26
+ storedCallbackFn,
27
+ storedCallbackObj,
28
+ isDomLoaded = false,
29
+ dynamicStylesheet,
30
+ dynamicStylesheetMedia,
31
+ autoHideShow = true,
32
+
33
+ /* Centralized function for browser feature detection
34
+ - User agent string detection is only used when no good alternative is possible
35
+ - Is executed directly for optimal performance
36
+ */
37
+ ua = function() {
38
+ var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
39
+ u = nav.userAgent.toLowerCase(),
40
+ p = nav.platform.toLowerCase(),
41
+ windows = p ? /win/.test(p) : /win/.test(u),
42
+ mac = p ? /mac/.test(p) : /mac/.test(u),
43
+ webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
44
+ ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
45
+ playerVersion = [0,0,0],
46
+ d = null;
47
+ if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
48
+ d = nav.plugins[SHOCKWAVE_FLASH].description;
49
+ if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
50
+ plugin = true;
51
+ ie = false; // cascaded feature detection for Internet Explorer
52
+ d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
53
+ playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
54
+ playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
55
+ playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
56
+ }
57
+ }
58
+ else if (typeof win.ActiveXObject != UNDEF) {
59
+ try {
60
+ var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
61
+ if (a) { // a will return null when ActiveX is disabled
62
+ d = a.GetVariable("$version");
63
+ if (d) {
64
+ ie = true; // cascaded feature detection for Internet Explorer
65
+ d = d.split(" ")[1].split(",");
66
+ playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
67
+ }
68
+ }
69
+ }
70
+ catch(e) {}
71
+ }
72
+ return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
73
+ }();
74
+
75
+
76
+ function callDomLoadFunctions() {
77
+ if (isDomLoaded) { return; }
78
+ try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
79
+ var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
80
+ t.parentNode.removeChild(t);
81
+ }
82
+ catch (e) { return; }
83
+ isDomLoaded = true;
84
+ var dl = domLoadFnArr.length;
85
+ for (var i = 0; i < dl; i++) {
86
+ domLoadFnArr[i]();
87
+ }
88
+ }
89
+
90
+ function addDomLoadEvent(fn) {
91
+ if (isDomLoaded) {
92
+ fn();
93
+ }
94
+ else {
95
+ domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
96
+ }
97
+ }
98
+
99
+ /* Cross-browser onload
100
+ - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
101
+ - Will fire an event as soon as a web page including all of its assets are loaded
102
+ */
103
+ function addLoadEvent(fn) {
104
+
105
+ }
106
+
107
+ /* Main function
108
+ - Will preferably execute onDomLoad, otherwise onload (as a fallback)
109
+ */
110
+ function main() {
111
+ if (plugin) {
112
+ testPlayerVersion();
113
+ }
114
+ }
115
+
116
+ /* Detect the Flash Player version for non-Internet Explorer browsers
117
+ - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
118
+ a. Both release and build numbers can be detected
119
+ b. Avoid wrong descriptions by corrupt installers provided by Adobe
120
+ c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
121
+ - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
122
+ */
123
+ function testPlayerVersion() {
124
+ var b = doc.getElementsByTagName("body")[0];
125
+ var o = createElement(OBJECT);
126
+ o.setAttribute("type", FLASH_MIME_TYPE);
127
+ var t = b.appendChild(o);
128
+ if (t) {
129
+ var counter = 0;
130
+ (function(){
131
+ if (typeof t.GetVariable != UNDEF) {
132
+ var d = t.GetVariable("$version");
133
+ if (d) {
134
+ d = d.split(" ")[1].split(",");
135
+ ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
136
+ }
137
+ }
138
+ else if (counter < 10) {
139
+ counter++;
140
+ setTimeout(arguments.callee, 10);
141
+ return;
142
+ }
143
+ b.removeChild(o);
144
+ t = null;
145
+ })();
146
+ }
147
+ }
148
+
149
+
150
+ function getObjectById(objectIdStr) {
151
+ var r = null;
152
+ var o = getElementById(objectIdStr);
153
+ if (o && o.nodeName == "OBJECT") {
154
+ if (typeof o.SetVariable != UNDEF) {
155
+ r = o;
156
+ }
157
+ else {
158
+ var n = o.getElementsByTagName(OBJECT)[0];
159
+ if (n) {
160
+ r = n;
161
+ }
162
+ }
163
+ }
164
+ return r;
165
+ }
166
+
167
+
168
+ /* Functions to abstract and display alternative content
169
+ */
170
+ function displayAltContent(obj) {
171
+ if (ua.ie && ua.win && obj.readyState != 4) {
172
+ // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
173
+ // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
174
+ var el = createElement("div");
175
+ obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
176
+ el.parentNode.replaceChild(abstractAltContent(obj), el);
177
+ obj.style.display = "none";
178
+ (function(){
179
+ if (obj.readyState == 4) {
180
+ obj.parentNode.removeChild(obj);
181
+ }
182
+ else {
183
+ setTimeout(arguments.callee, 10);
184
+ }
185
+ })();
186
+ }
187
+ else {
188
+ obj.parentNode.replaceChild(abstractAltContent(obj), obj);
189
+ }
190
+ }
191
+
192
+ function abstractAltContent(obj) {
193
+ var ac = createElement("div");
194
+ if (ua.win && ua.ie) {
195
+ ac.innerHTML = obj.innerHTML;
196
+ }
197
+ else {
198
+ var nestedObj = obj.getElementsByTagName(OBJECT)[0];
199
+ if (nestedObj) {
200
+ var c = nestedObj.childNodes;
201
+ if (c) {
202
+ var cl = c.length;
203
+ for (var i = 0; i < cl; i++) {
204
+ if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
205
+ ac.appendChild(c[i].cloneNode(true));
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }
211
+ return ac;
212
+ }
213
+
214
+ /* Cross-browser dynamic SWF creation
215
+ */
216
+ function createSWF(attObj, parObj, id) {
217
+ var r, el = getElementById(id);
218
+ if (ua.wk && ua.wk < 312) { return r; }
219
+ if (el) {
220
+ if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
221
+ attObj.id = id;
222
+ }
223
+ if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
224
+ var att = "";
225
+ for (var i in attObj) {
226
+ if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
227
+ if (i.toLowerCase() == "data") {
228
+ parObj.movie = attObj[i];
229
+ }
230
+ else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
231
+ att += ' class="' + attObj[i] + '"';
232
+ }
233
+ else if (i.toLowerCase() != "classid") {
234
+ att += ' ' + i + '="' + attObj[i] + '"';
235
+ }
236
+ }
237
+ }
238
+ var par = "";
239
+ for (var j in parObj) {
240
+ if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
241
+ par += '<param name="' + j + '" value="' + parObj[j] + '" />';
242
+ }
243
+ }
244
+ el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
245
+ objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
246
+ r = getElementById(attObj.id);
247
+ }
248
+ else { // well-behaving browsers
249
+ var o = createElement(OBJECT);
250
+ o.setAttribute("type", FLASH_MIME_TYPE);
251
+ for (var m in attObj) {
252
+ if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
253
+ if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
254
+ o.setAttribute("class", attObj[m]);
255
+ }
256
+ else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
257
+ o.setAttribute(m, attObj[m]);
258
+ }
259
+ }
260
+ }
261
+ for (var n in parObj) {
262
+ if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element
263
+ createObjParam(o, n, parObj[n]);
264
+ }
265
+ }
266
+ el.parentNode.replaceChild(o, el);
267
+ r = o;
268
+ }
269
+ }
270
+ return r;
271
+ }
272
+
273
+ function createObjParam(el, pName, pValue) {
274
+ var p = createElement("param");
275
+ p.setAttribute("name", pName);
276
+ p.setAttribute("value", pValue);
277
+ el.appendChild(p);
278
+ }
279
+
280
+ /* Cross-browser SWF removal
281
+ - Especially needed to safely and completely remove a SWF in Internet Explorer
282
+ */
283
+ function removeSWF(id) {
284
+ var obj = getElementById(id);
285
+ if (obj && obj.nodeName == "OBJECT") {
286
+ if (ua.ie && ua.win) {
287
+ obj.style.display = "none";
288
+ (function(){
289
+ if (obj.readyState == 4) {
290
+ removeObjectInIE(id);
291
+ }
292
+ else {
293
+ setTimeout(arguments.callee, 10);
294
+ }
295
+ })();
296
+ }
297
+ else {
298
+ obj.parentNode.removeChild(obj);
299
+ }
300
+ }
301
+ }
302
+
303
+ function removeObjectInIE(id) {
304
+ var obj = getElementById(id);
305
+ if (obj) {
306
+ for (var i in obj) {
307
+ if (typeof obj[i] == "function") {
308
+ obj[i] = null;
309
+ }
310
+ }
311
+ obj.parentNode.removeChild(obj);
312
+ }
313
+ }
314
+
315
+ /* Functions to optimize JavaScript compression
316
+ */
317
+ function getElementById(id) {
318
+ var el = null;
319
+ try {
320
+ el = doc.getElementById(id);
321
+ }
322
+ catch (e) {}
323
+ return el;
324
+ }
325
+
326
+ function createElement(el) {
327
+ return doc.createElement(el);
328
+ }
329
+
330
+ /* Updated attachEvent function for Internet Explorer
331
+ - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
332
+ */
333
+ function addListener(target, eventType, fn) {
334
+ target.attachEvent(eventType, fn);
335
+ listenersArr[listenersArr.length] = [target, eventType, fn];
336
+ }
337
+
338
+ /* Flash Player and SWF content version matching
339
+ */
340
+ function hasPlayerVersion(rv) {
341
+ var pv = ua.pv, v = rv.split(".");
342
+ v[0] = parseInt(v[0], 10);
343
+ v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
344
+ v[2] = parseInt(v[2], 10) || 0;
345
+ return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
346
+ }
347
+
348
+
349
+
350
+ function setVisibility(id, isVisible) {
351
+ if (!autoHideShow) { return; }
352
+ var elem;
353
+ var v = isVisible ? "visible" : "hidden";
354
+ if (isDomLoaded && (elem && getElementById(id))) {
355
+ getElementById(id).style.visibility = v;
356
+ }
357
+ }
358
+
359
+ /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
360
+ */
361
+ var cleanup = function() {
362
+ if (ua.ie && ua.win && window.attachEvent) {
363
+ window.attachEvent("onunload", function() {
364
+ // remove listeners to avoid memory leaks
365
+ var ll = listenersArr.length;
366
+ for (var i = 0; i < ll; i++) {
367
+ listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
368
+ }
369
+ // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
370
+ var il = objIdArr.length;
371
+ for (var j = 0; j < il; j++) {
372
+ removeSWF(objIdArr[j]);
373
+ }
374
+ // cleanup library's main closures to avoid memory leaks
375
+ for (var k in ua) {
376
+ ua[k] = null;
377
+ }
378
+ ua = null;
379
+ for (var l in swfmini) {
380
+ swfmini[l] = null;
381
+ }
382
+ swfmini = null;
383
+ });
384
+ }
385
+ }();
386
+
387
+ webshims.ready('DOM', callDomLoadFunctions);
388
+
389
+ return {
390
+ /* Public API
391
+ - Reference: http://code.google.com/p/swfobject/wiki/documentation
392
+ */
393
+ registerObject: function() {
394
+
395
+ },
396
+
397
+ getObjectById: function(objectIdStr) {
398
+ if (ua.w3) {
399
+ return getObjectById(objectIdStr);
400
+ }
401
+ },
402
+
403
+ embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
404
+ var callbackObj = {success:false, id:replaceElemIdStr};
405
+ if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
406
+ setVisibility(replaceElemIdStr, false);
407
+ addDomLoadEvent(function() {
408
+ widthStr += ""; // auto-convert to string
409
+ heightStr += "";
410
+ var att = {};
411
+ if (attObj && typeof attObj === OBJECT) {
412
+ for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
413
+ att[i] = attObj[i];
414
+ }
415
+ }
416
+ att.data = swfUrlStr;
417
+ att.width = widthStr;
418
+ att.height = heightStr;
419
+ var par = {};
420
+ if (parObj && typeof parObj === OBJECT) {
421
+ for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
422
+ par[j] = parObj[j];
423
+ }
424
+ }
425
+ if (flashvarsObj && typeof flashvarsObj === OBJECT) {
426
+ for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
427
+ if (typeof par.flashvars != UNDEF) {
428
+ par.flashvars += "&" + k + "=" + flashvarsObj[k];
429
+ }
430
+ else {
431
+ par.flashvars = k + "=" + flashvarsObj[k];
432
+ }
433
+ }
434
+ }
435
+ if (hasPlayerVersion(swfVersionStr)) { // create SWF
436
+ var obj = createSWF(att, par, replaceElemIdStr);
437
+ if (att.id == replaceElemIdStr) {
438
+ setVisibility(replaceElemIdStr, true);
439
+ }
440
+ callbackObj.success = true;
441
+ callbackObj.ref = obj;
442
+ }
443
+ else { // show alternative content
444
+ setVisibility(replaceElemIdStr, true);
445
+ }
446
+ if (callbackFn) { callbackFn(callbackObj); }
447
+ });
448
+ }
449
+ else if (callbackFn) { callbackFn(callbackObj); }
450
+ },
451
+
452
+ switchOffAutoHideShow: function() {
453
+ autoHideShow = false;
454
+ },
455
+
456
+ ua: ua,
457
+
458
+ getFlashPlayerVersion: function() {
459
+ return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
460
+ },
461
+
462
+ hasFlashPlayerVersion: hasPlayerVersion,
463
+
464
+ createSWF: function(attObj, parObj, replaceElemIdStr) {
465
+ if (ua.w3) {
466
+ return createSWF(attObj, parObj, replaceElemIdStr);
467
+ }
468
+ else {
469
+ return undefined;
470
+ }
471
+ },
472
+
473
+ showExpressInstall: function() {
474
+
475
+ },
476
+
477
+ removeSWF: function(objElemIdStr) {
478
+ if (ua.w3) {
479
+ removeSWF(objElemIdStr);
480
+ }
481
+ },
482
+
483
+ createCSS: function() {
484
+
485
+ },
486
+
487
+ addDomLoadEvent: addDomLoadEvent,
488
+
489
+ addLoadEvent: addLoadEvent,
490
+
491
+
492
+ // For internal usage only
493
+ expressInstallCallback: function() {
494
+
495
+ }
496
+ };
497
+ }();
498
+
1
499
  //DOM-Extension helper
2
500
  jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
3
501
  "use strict";
502
+
503
+ webshims.assumeARIA = Modernizr.localstorage || Modernizr.video || Modernizr.boxsizing;
504
+
505
+ if($('<input type="email" />').attr('type') == 'text' || $('<form />').attr('novalidate') === "" || ('required' in $('<input />')[0].attributes)){
506
+ webshims.error("IE browser modes are busted in IE10. Please test your HTML/CSS/JS with a real IE version or at least IETester or similiar tools");
507
+ }
508
+
509
+ if(!$.parseHTML){
510
+ webshims.error("Webshims needs jQuery 1.8+ to work properly. Please update your jQuery version or downgrade webshims.");
511
+ }
512
+
4
513
  //shortcus
5
514
  var modules = webshims.modules;
6
515
  var listReg = /\s*,\s*/;
@@ -17,10 +526,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
17
526
  return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
18
527
  };
19
528
 
20
- $.fn.onTrigger = function(evt, fn){
21
- return this.on(evt, fn).each(fn);
22
- };
23
-
529
+
24
530
  $.fn.val = function(val){
25
531
  var elem = this[0];
26
532
  if(arguments.length && val == null){
@@ -49,6 +555,9 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
49
555
  }
50
556
  });
51
557
  };
558
+ $.fn.onTrigger = function(evt, fn){
559
+ return this.on(evt, fn).each(fn);
560
+ };
52
561
 
53
562
  var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
54
563
  var elementData = function(elem, key, val){
@@ -70,13 +579,69 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
70
579
 
71
580
  [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
72
581
  $.fn[data.name] = function(){
73
- return this.map(function(){
582
+ var elems = [];
583
+ this.each(function(){
74
584
  var shadowData = elementData(this, 'shadowData');
75
- return shadowData && shadowData[data.prop] || this;
585
+ var elem = shadowData && shadowData[data.prop] || this;
586
+ if($.inArray(elem, elems) == -1){
587
+ elems.push(elem);
588
+ }
76
589
  });
590
+ return this.pushStack(elems);
77
591
  };
78
592
  });
79
593
 
594
+ if($.Tween.propHooks._default && $.css){
595
+ (function(){
596
+ var isjQ8 = false;
597
+ try {
598
+ isjQ8 = $.css($('<b style="width: 10px" />')[0], 'width', '') == '10px';
599
+ } catch(er){
600
+ webshims.error(er);
601
+ }
602
+ var css = isjQ8 ?
603
+ function(elem, prop){
604
+ return $.css( elem, prop, false, "" );
605
+ } :
606
+ function(elem, prop){
607
+ return $.css( elem, prop, "" );
608
+ }
609
+ ;
610
+
611
+ $.extend($.Tween.propHooks._default, {
612
+ get: function( tween ) {
613
+ var result;
614
+
615
+ if ( (tween.elem[ tween.prop ] != null || havePolyfill[ tween.prop ]) &&
616
+ (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
617
+ return havePolyfill[ tween.prop ] ? $.prop(tween.elem, tween.prop) : tween.elem[ tween.prop ];
618
+ }
619
+
620
+ // passing an empty string as a 3rd parameter to .css will automatically
621
+ // attempt a parseFloat and fallback to a string if the parse fails
622
+ // so, simple values such as "10px" are parsed to Float.
623
+ // complex values such as "rotate(1rad)" are returned as is.
624
+ result = css( tween.elem, tween.prop );
625
+ // Empty strings, null, undefined and "auto" are converted to 0.
626
+ return !result || result === "auto" ? 0 : result;
627
+ },
628
+ set: function( tween ) {
629
+ // use step hook for back compat - use cssHook if its there - use .style if its
630
+ // available and use plain properties where available
631
+ if ( jQuery.fx.step[ tween.prop ] ) {
632
+ jQuery.fx.step[ tween.prop ]( tween );
633
+ } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
634
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
635
+ } else if( !havePolyfill[ tween.prop ] ) {
636
+ tween.elem[ tween.prop ] = tween.now;
637
+ } else {
638
+ $.prop(tween.elem, tween.prop, tween.now);
639
+ }
640
+ }
641
+ });
642
+ })();
643
+ }
644
+
80
645
 
81
646
  ['removeAttr', 'prop', 'attr'].forEach(function(type){
82
647
  olds[type] = $[type];
@@ -196,7 +761,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
196
761
  getSup('set', desc, oldDesc) :
197
762
  (webshims.cfg.useStrict && prop == 'prop') ?
198
763
  function(){throw(prop +' is readonly on '+ nodeName);} :
199
- $.noop
764
+ function(){webshims.info(prop +' is readonly on '+ nodeName);}
200
765
  ;
201
766
  }
202
767
  if(!desc.get){
@@ -214,15 +779,14 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
214
779
 
215
780
  });
216
781
 
217
- //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
218
- var isExtendNativeSave = Modernizr.ES5;
219
782
  var extendNativeValue = (function(){
220
783
  var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
221
784
  var has = Object.prototype.hasOwnProperty;
785
+ //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
786
+ var isExtendNativeSave = Modernizr.advancedObjectProperties && Modernizr.objectAccessor;
222
787
  return function(nodeName, prop, desc){
223
- var elem;
224
- var elemProto;
225
- if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
788
+ var elem , elemProto;
789
+ if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
226
790
  var sup = elem[prop];
227
791
  desc._supvalue = function(){
228
792
  if(sup && sup.apply){
@@ -344,15 +908,24 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
344
908
  var ID = new Date().getTime();
345
909
  return function(elem){
346
910
  elem = $(elem);
347
- var id = elem.attr('id');
911
+ var id = elem.prop('id');
348
912
  if(!id){
349
913
  ID++;
350
914
  id = 'ID-'+ ID;
351
- elem.attr('id', id);
915
+ elem.eq(0).prop('id', id);
352
916
  }
353
917
  return id;
354
918
  };
355
919
  })(),
920
+ implement: function(elem, type){
921
+ var data = elementData(elem, 'implemented') || elementData(elem, 'implemented', {});
922
+ if(data[type]){
923
+ webshims.info(type +' already implemented for element #'+elem.id);
924
+ return false;
925
+ }
926
+ data[type] = true;
927
+ return true;
928
+ },
356
929
  extendUNDEFProp: function(obj, props){
357
930
  $.each(props, function(name, prop){
358
931
  if( !(name in obj) ){
@@ -831,7 +1404,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
831
1404
  var callRegister = function(module){
832
1405
  if(registeredCallbacks[module]){
833
1406
  registeredCallbacks[module].forEach(function(data){
834
- data.callback();
1407
+ data.callback(currentLang, shortLang, '');
835
1408
  });
836
1409
  }
837
1410
  };
@@ -872,7 +1445,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
872
1445
  registeredCallbacks[lang.register] = [];
873
1446
  }
874
1447
  registeredCallbacks[lang.register].push(lang);
875
- lang.callback();
1448
+ lang.callback(currentLang, shortLang, '');
876
1449
  } else {
877
1450
  if(!lang.activeLang){
878
1451
  lang.activeLang = '';
@@ -909,8 +1482,20 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
909
1482
  });
910
1483
  //html5a11y
911
1484
  (function($, document){
912
- //if we support basic styleing or do not support ARIA (assumed) abort
913
- if(!Modernizr.localstorage || ('hidden' in document.createElement('a'))){return;}
1485
+ if(!$.webshims.assumeARIA || ('content' in document.createElement('template'))){return;}
1486
+
1487
+ $(function(){
1488
+ var main = $('main').attr({role: 'main'});
1489
+ if(main.length > 1){
1490
+ webshims.error('only one main element allowed in document');
1491
+ } else if(main.is('article *, section *')) {
1492
+ webshims.error('main not allowed inside of article/section elements');
1493
+ }
1494
+ });
1495
+
1496
+ if(('hidden' in document.createElement('a'))){
1497
+ return;
1498
+ }
914
1499
 
915
1500
  var elemMappings = {
916
1501
  article: "article",
@@ -926,6 +1511,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
926
1511
  }
927
1512
  };
928
1513
 
1514
+
929
1515
  $.webshims.addReady(function(context, contextElem){
930
1516
  $.each(elemMappings, function(name, role){
931
1517
  var elems = $(name, context).add(contextElem.filter(name));
@@ -937,6 +1523,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
937
1523
  var header = document.getElementsByTagName('header')[0];
938
1524
  var footers = document.getElementsByTagName('footer');
939
1525
  var footerLen = footers.length;
1526
+
940
1527
  if (header && !$(header).closest('section, article')[0]) {
941
1528
  addRole(header, 'banner');
942
1529
  }
@@ -955,7 +1542,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
955
1542
  //additional tests for partial implementation of forms features
956
1543
  (function($){
957
1544
  "use strict";
958
- var isWebkit = /webkit/i.test(navigator.userAgent);
1545
+ var isWebkit = 'webkitURL' in window;
959
1546
  var Modernizr = window.Modernizr;
960
1547
  var webshims = $.webshims;
961
1548
  var bugs = webshims.bugs;
@@ -1000,7 +1587,6 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
1000
1587
  testRequiredFind();
1001
1588
  } else {
1002
1589
  //create delegatable events
1003
- webshims.capturingEvents(['input']);
1004
1590
  webshims.capturingEvents(['invalid'], true);
1005
1591
 
1006
1592
  if(window.opera || window.testGoodWithFix){
@@ -1070,521 +1656,3203 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
1070
1656
  })();
1071
1657
  }
1072
1658
  }
1073
-
1074
1659
 
1075
-
1076
- jQuery.webshims.register('form-core', function($, webshims, window, document, undefined, options){
1077
- "use strict";
1078
-
1079
-
1080
- var checkTypes = {checkbox: 1, radio: 1};
1081
- var emptyJ = $([]);
1082
- var bugs = webshims.bugs;
1083
- var groupTypes = {radio: 1};
1084
- var getGroupElements = function(elem){
1085
- elem = $(elem);
1086
- var name;
1087
- var form;
1088
- var ret = emptyJ;
1089
- if(groupTypes[elem[0].type]){
1090
- form = elem.prop('form');
1091
- name = elem[0].name;
1092
- if(!name){
1093
- ret = elem;
1094
- } else if(form){
1095
- ret = $(form[name]);
1096
- } else {
1097
- ret = $(document.getElementsByName(name)).filter(function(){
1098
- return !$.prop(this, 'form');
1099
- });
1100
- }
1101
- ret = ret.filter('[type="radio"]');
1102
- }
1103
- return ret;
1104
- };
1660
+ $.webshims.register('form-core', function($, webshims, window, document, undefined, options){
1105
1661
 
1106
- var getContentValidationMessage = webshims.getContentValidationMessage = function(elem, validity, key){
1107
- var message = $(elem).data('errormessage') || elem.getAttribute('x-moz-errormessage') || '';
1108
- if(key && message[key]){
1109
- message = message[key];
1110
- }
1111
- if(typeof message == 'object'){
1112
- validity = validity || $.prop(elem, 'validity') || {valid: 1};
1113
- if(!validity.valid){
1114
- $.each(validity, function(name, prop){
1115
- if(prop && name != 'valid' && message[name]){
1116
- message = message[name];
1117
- return false;
1118
- }
1119
- });
1662
+ var checkTypes = {checkbox: 1, radio: 1};
1663
+ var emptyJ = $([]);
1664
+ var bugs = webshims.bugs;
1665
+ var getGroupElements = function(elem){
1666
+ elem = $(elem);
1667
+ var name;
1668
+ var form;
1669
+ var ret = emptyJ;
1670
+ if(elem[0].type == 'radio'){
1671
+ form = elem.prop('form');
1672
+ name = elem[0].name;
1673
+ if(!name){
1674
+ ret = elem;
1675
+ } else if(form){
1676
+ ret = $(form[name]);
1677
+ } else {
1678
+ ret = $(document.getElementsByName(name)).filter(function(){
1679
+ return !$.prop(this, 'form');
1680
+ });
1681
+ }
1682
+ ret = ret.filter('[type="radio"]');
1120
1683
  }
1121
- }
1684
+ return ret;
1685
+ };
1122
1686
 
1123
- if(typeof message == 'object'){
1124
- message = message.defaultMessage;
1125
- }
1126
- return message || '';
1127
- };
1128
-
1129
- /*
1130
- * Selectors for all browsers
1131
- */
1132
- var rangeTypes = {number: 1, range: 1, date: 1/*, time: 1, 'datetime-local': 1, datetime: 1, month: 1, week: 1*/};
1133
- var hasInvalid = function(elem){
1134
- var ret = false;
1135
- $($.prop(elem, 'elements')).each(function(){
1136
- ret = $(this).is(':invalid');
1137
- if(ret){
1138
- return false;
1687
+ var getContentValidationMessage = webshims.getContentValidationMessage = function(elem, validity, key){
1688
+ var message = $(elem).data('errormessage') || elem.getAttribute('x-moz-errormessage') || '';
1689
+ if(key && message[key]){
1690
+ message = message[key];
1139
1691
  }
1140
- });
1141
- return ret;
1142
- };
1143
- $.extend($.expr[":"], {
1144
- "valid-element": function(elem){
1145
- return $.nodeName(elem, 'form') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
1146
- },
1147
- "invalid-element": function(elem){
1148
- return $.nodeName(elem, 'form') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
1149
- },
1150
- "required-element": function(elem){
1151
- return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
1152
- },
1153
- "user-error": function(elem){
1154
- return ($.prop(elem, 'willValidate') && $(elem).hasClass('user-error'));
1155
- },
1156
- "optional-element": function(elem){
1157
- return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
1158
- },
1159
- "in-range": function(elem){
1160
- if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1161
- return false;
1692
+ if(typeof message == 'object'){
1693
+ validity = validity || $.prop(elem, 'validity') || {valid: 1};
1694
+ if(!validity.valid){
1695
+ $.each(validity, function(name, prop){
1696
+ if(prop && name != 'valid' && message[name]){
1697
+ message = message[name];
1698
+ return false;
1699
+ }
1700
+ });
1701
+ }
1162
1702
  }
1163
- var val = $.prop(elem, 'validity');
1164
- return !!(val && !val.rangeOverflow && !val.rangeUnderflow);
1165
- },
1166
- "out-of-range": function(elem){
1167
- if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1168
- return false;
1703
+
1704
+ if(typeof message == 'object'){
1705
+ message = message.defaultMessage;
1169
1706
  }
1170
- var val = $.prop(elem, 'validity');
1171
- return !!(val && (val.rangeOverflow || val.rangeUnderflow));
1172
- }
1707
+ return message || '';
1708
+ };
1173
1709
 
1174
- });
1710
+ /*
1711
+ * Selectors for all browsers
1712
+ */
1713
+ var rangeTypes = {number: 1, range: 1, date: 1/*, time: 1, 'datetime-local': 1, datetime: 1, month: 1, week: 1*/};
1714
+ var hasInvalid = function(elem){
1715
+ var ret = false;
1716
+ $($.prop(elem, 'elements')).each(function(){
1717
+ ret = $(this).is(':invalid');
1718
+ if(ret){
1719
+ return false;
1720
+ }
1721
+ });
1722
+ return ret;
1723
+ };
1724
+ $.extend($.expr[":"], {
1725
+ "valid-element": function(elem){
1726
+ return $.nodeName(elem, 'form') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
1727
+ },
1728
+ "invalid-element": function(elem){
1729
+ return $.nodeName(elem, 'form') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
1730
+ },
1731
+ "required-element": function(elem){
1732
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
1733
+ },
1734
+ "user-error": function(elem){
1735
+ return ($.prop(elem, 'willValidate') && $(elem).hasClass('user-error'));
1736
+ },
1737
+ "optional-element": function(elem){
1738
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
1739
+ },
1740
+ "in-range": function(elem){
1741
+ if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1742
+ return false;
1743
+ }
1744
+ var val = $.prop(elem, 'validity');
1745
+ return !!(val && !val.rangeOverflow && !val.rangeUnderflow);
1746
+ },
1747
+ "out-of-range": function(elem){
1748
+ if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1749
+ return false;
1750
+ }
1751
+ var val = $.prop(elem, 'validity');
1752
+ return !!(val && (val.rangeOverflow || val.rangeUnderflow));
1753
+ }
1754
+
1755
+ });
1756
+
1757
+ ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
1758
+ $.expr[":"][name] = $.expr.filters[name+"-element"];
1759
+ });
1760
+
1761
+
1762
+ $.expr[":"].focus = function( elem ) {
1763
+ try {
1764
+ var doc = elem.ownerDocument;
1765
+ return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus());
1766
+ } catch(e){}
1767
+ return false;
1768
+ };
1769
+
1770
+
1771
+ var customEvents = $.event.customEvent || {};
1772
+ var isValid = function(elem){
1773
+ return ($.prop(elem, 'validity') || {valid: 1}).valid;
1774
+ };
1775
+
1776
+ if (bugs.bustedValidity || bugs.findRequired) {
1777
+ (function(){
1778
+ var find = $.find;
1779
+ var matchesSelector = $.find.matchesSelector;
1780
+
1781
+ var regExp = /(\:valid|\:invalid|\:optional|\:required|\:in-range|\:out-of-range)(?=[\s\[\~\.\+\>\:\#*]|$)/ig;
1782
+ var regFn = function(sel){
1783
+ return sel + '-element';
1784
+ };
1785
+
1786
+ $.find = (function(){
1787
+ var slice = Array.prototype.slice;
1788
+ var fn = function(sel){
1789
+ var ar = arguments;
1790
+ ar = slice.call(ar, 1, ar.length);
1791
+ ar.unshift(sel.replace(regExp, regFn));
1792
+ return find.apply(this, ar);
1793
+ };
1794
+ for (var i in find) {
1795
+ if(find.hasOwnProperty(i)){
1796
+ fn[i] = find[i];
1797
+ }
1798
+ }
1799
+ return fn;
1800
+ })();
1801
+ if(!Modernizr.prefixed || Modernizr.prefixed("matchesSelector", document.documentElement)){
1802
+ $.find.matchesSelector = function(node, expr){
1803
+ expr = expr.replace(regExp, regFn);
1804
+ return matchesSelector.call(this, node, expr);
1805
+ };
1806
+ }
1807
+
1808
+ })();
1809
+ }
1810
+
1811
+ //ToDo needs testing
1812
+ var oldAttr = $.prop;
1813
+ var changeVals = {selectedIndex: 1, value: 1, checked: 1, disabled: 1, readonly: 1};
1814
+ $.prop = function(elem, name, val){
1815
+ var ret = oldAttr.apply(this, arguments);
1816
+ if(elem && 'form' in elem && changeVals[name] && val !== undefined && $(elem).hasClass(invalidClass)){
1817
+ if(isValid(elem)){
1818
+ $(elem).getShadowElement().removeClass(invalidClass);
1819
+ if(name == 'checked' && val) {
1820
+ getGroupElements(elem).not(elem).removeClass(invalidClass).removeAttr('aria-invalid');
1821
+ }
1822
+ }
1823
+ }
1824
+ return ret;
1825
+ };
1826
+
1827
+ var returnValidityCause = function(validity, elem){
1828
+ var ret;
1829
+ $.each(validity, function(name, value){
1830
+ if(value){
1831
+ ret = (name == 'customError') ? $.prop(elem, 'validationMessage') : name;
1832
+ return false;
1833
+ }
1834
+ });
1835
+ return ret;
1836
+ };
1837
+
1838
+ var isInGroup = function(name){
1839
+ var ret;
1840
+ try {
1841
+ ret = document.activeElement.name === name;
1842
+ } catch(e){}
1843
+ return ret;
1844
+ };
1845
+ /* form-ui-invalid/form-ui-valid are deprecated. use user-error/user-success instead */
1846
+ var invalidClass = 'user-error';
1847
+ var validClass = 'user-success';
1848
+ var stopChangeTypes = {
1849
+ time: 1,
1850
+ date: 1,
1851
+ month: 1,
1852
+ datetime: 1,
1853
+ week: 1,
1854
+ 'datetime-local': 1
1855
+ };
1856
+ var switchValidityClass = function(e){
1857
+ var elem, timer;
1858
+ if(!e.target){return;}
1859
+ elem = $(e.target).getNativeElement()[0];
1860
+ if(elem.type == 'submit' || !$.prop(elem, 'willValidate')){return;}
1861
+ timer = $.data(elem, 'webshimsswitchvalidityclass');
1862
+ var switchClass = function(){
1863
+ if(e.type == 'focusout' && elem.type == 'radio' && isInGroup(elem.name)){return;}
1864
+ var validity = $.prop(elem, 'validity');
1865
+ var shadowElem = $(elem).getShadowElement();
1866
+ var addClass, removeClass, trigger, generaltrigger, validityCause;
1867
+
1868
+ if(isWebkit && e.type == 'change' && !bugs.bustedValidity && stopChangeTypes[shadowElem.prop('type')] && shadowElem.is(':focus')){return;}
1869
+
1870
+ $(elem).trigger('refreshCustomValidityRules');
1871
+
1872
+ if(validity.valid){
1873
+ if(!shadowElem.hasClass(validClass)){
1874
+ addClass = validClass;
1875
+ removeClass = invalidClass;
1876
+ generaltrigger = 'changedvaliditystate';
1877
+ trigger = 'changedvalid';
1878
+ if(checkTypes[elem.type] && elem.checked){
1879
+ getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass).removeAttr('aria-invalid');
1880
+ }
1881
+ $.removeData(elem, 'webshimsinvalidcause');
1882
+ }
1883
+ } else {
1884
+ validityCause = returnValidityCause(validity, elem);
1885
+ if($.data(elem, 'webshimsinvalidcause') != validityCause){
1886
+ $.data(elem, 'webshimsinvalidcause', validityCause);
1887
+ generaltrigger = 'changedvaliditystate';
1888
+ }
1889
+ if(!shadowElem.hasClass(invalidClass)){
1890
+ addClass = invalidClass;
1891
+ removeClass = validClass;
1892
+ if (checkTypes[elem.type] && !elem.checked) {
1893
+ getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass);
1894
+ }
1895
+ trigger = 'changedinvalid';
1896
+ }
1897
+ }
1898
+
1899
+ if(addClass){
1900
+ shadowElem.addClass(addClass).removeClass(removeClass);
1901
+ //jQuery 1.6.1 IE9 bug (doubble trigger bug)
1902
+ setTimeout(function(){
1903
+ $(elem).trigger(trigger);
1904
+ }, 0);
1905
+ }
1906
+ if(generaltrigger){
1907
+ setTimeout(function(){
1908
+ $(elem).trigger(generaltrigger);
1909
+ }, 0);
1910
+ }
1911
+
1912
+ $.removeData(elem, 'webshimsswitchvalidityclass');
1913
+ };
1914
+
1915
+ if(timer){
1916
+ clearTimeout(timer);
1917
+ }
1918
+ if(e.type == 'refreshvalidityui'){
1919
+ switchClass();
1920
+ } else {
1921
+ $.data(elem, 'webshimsswitchvalidityclass', setTimeout(switchClass, 9));
1922
+ }
1923
+ };
1924
+
1925
+ $(document).on(options.validityUIEvents || 'focusout change refreshvalidityui', switchValidityClass);
1926
+ customEvents.changedvaliditystate = true;
1927
+ customEvents.refreshCustomValidityRules = true;
1928
+ customEvents.changedvalid = true;
1929
+ customEvents.changedinvalid = true;
1930
+ customEvents.refreshvalidityui = true;
1931
+
1932
+
1933
+ webshims.triggerInlineForm = function(elem, event){
1934
+ $(elem).trigger(event);
1935
+ };
1936
+
1937
+ webshims.modules["form-core"].getGroupElements = getGroupElements;
1938
+
1939
+
1940
+ var setRoot = function(){
1941
+ webshims.scrollRoot = (isWebkit || document.compatMode == 'BackCompat') ?
1942
+ $(document.body) :
1943
+ $(document.documentElement)
1944
+ ;
1945
+ };
1946
+ var minWidth = (Modernizr.boxSizing || Modernizr['display-table'] || $.support.getSetAttribute) ?
1947
+ 'minWidth' :
1948
+ 'width'
1949
+ ;
1950
+ setRoot();
1951
+ webshims.ready('DOM', setRoot);
1952
+
1953
+ webshims.getRelOffset = function(posElem, relElem){
1954
+ posElem = $(posElem);
1955
+ var offset = $(relElem).offset();
1956
+ var bodyOffset;
1957
+ $.swap($(posElem)[0], {visibility: 'hidden', display: 'inline-block', left: 0, top: 0}, function(){
1958
+ bodyOffset = posElem.offset();
1959
+ });
1960
+ offset.top -= bodyOffset.top;
1961
+ offset.left -= bodyOffset.left;
1962
+ return offset;
1963
+ };
1964
+
1965
+ webshims.wsPopover = {
1966
+ _create: function(){
1967
+ this.options = $.extend({}, webshims.cfg.wspopover, this.options);
1968
+ this.id = webshims.wsPopover.id++;
1969
+ this.eventns = '.wsoverlay'+this.id;
1970
+ this.timers = {};
1971
+ 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>');
1972
+ this.contentElement = $('.ws-po-box', this.element);
1973
+ this.lastElement = $([]);
1974
+ this.bindElement();
1975
+
1976
+ this.element.data('wspopover', this);
1977
+
1978
+ },
1979
+ options: {},
1980
+ content: function(html){
1981
+ this.contentElement.html(html);
1982
+ },
1983
+ bindElement: function(){
1984
+ var that = this;
1985
+ var stopBlur = function(){
1986
+ that.stopBlur = false;
1987
+ };
1988
+ this.preventBlur = function(e){
1989
+ that.stopBlur = true;
1990
+ clearTimeout(that.timers.stopBlur);
1991
+ that.timers.stopBlur = setTimeout(stopBlur, 9);
1992
+ };
1993
+ this.element.on({
1994
+ 'mousedown': this.preventBlur
1995
+ });
1996
+ },
1997
+
1998
+ isInElement: function(container, contained){
1999
+ return container == contained || $.contains(container, contained);
2000
+ },
2001
+ show: function(element){
2002
+ var e = $.Event('wspopoverbeforeshow');
2003
+ this.element.trigger(e);
2004
+ if(e.isDefaultPrevented() || this.isVisible){return;}
2005
+ this.isVisible = true;
2006
+ element = $(element || this.options.prepareFor).getNativeElement() ;
2007
+
2008
+ var that = this;
2009
+ var visual = $(element).getShadowElement();
2010
+
2011
+ this.clear();
2012
+ this.element.removeClass('ws-po-visible').css('display', 'none');
2013
+
2014
+ this.prepareFor(element, visual);
2015
+
2016
+ this.position(visual);
2017
+ that.timers.show = setTimeout(function(){
2018
+ that.element.css('display', '');
2019
+ that.timers.show = setTimeout(function(){
2020
+ that.element.addClass('ws-po-visible').trigger('wspopovershow');
2021
+ }, 9);
2022
+ }, 9);
2023
+ $(document).on('focusin'+this.eventns+' mousedown'+this.eventns, function(e){
2024
+ 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)){
2025
+ that.hide();
2026
+ }
2027
+ });
2028
+ $(window).on('resize'+this.eventns + ' pospopover'+this.eventns, function(){
2029
+ clearTimeout(that.timers.repos);
2030
+ that.timers.repos = setTimeout(function(){
2031
+ that.position(visual);
2032
+ }, 900);
2033
+ });
2034
+ },
2035
+ prepareFor: function(element, visual){
2036
+ var onBlur;
2037
+ var opts = $.extend({}, this.options, $(element.prop('form') || []).data('wspopover') || {}, element.data('wspopover'));
2038
+ var that = this;
2039
+ var css = {};
2040
+ this.lastElement = $(element).getShadowFocusElement();
2041
+ if(opts.appendTo == 'element'){
2042
+ this.element.insertAfter(element);
2043
+ } else {
2044
+ this.element.appendTo(opts.appendTo);
2045
+ }
2046
+
2047
+ this.element.attr({
2048
+ 'data-class': element.prop('className'),
2049
+ 'data-id': element.prop('id')
2050
+ });
2051
+
2052
+ css[minWidth] = opts.constrainWidth ? visual.outerWidth() : '';
2053
+
2054
+ this.element.css(css);
2055
+
2056
+ if(opts.hideOnBlur){
2057
+ onBlur = function(e){
2058
+ if(that.stopBlur){
2059
+ e.stopImmediatePropagation();
2060
+ } else {
2061
+ that.hide();
2062
+ }
2063
+ };
2064
+
2065
+ that.timers.bindBlur = setTimeout(function(){
2066
+ that.lastElement.off(that.eventns).on('focusout'+that.eventns + ' blur'+that.eventns, onBlur);
2067
+ that.lastElement.getNativeElement().off(that.eventns);
2068
+ }, 10);
2069
+
2070
+
2071
+ }
2072
+
2073
+ if(!this.prepared){
2074
+
2075
+ if($.fn.bgIframe){
2076
+ this.element.bgIframe();
2077
+ }
2078
+ }
2079
+ this.prepared = true;
2080
+ },
2081
+ clear: function(){
2082
+ $(window).off(this.eventns);
2083
+ $(document).off(this.eventns);
2084
+
2085
+ this.stopBlur = false;
2086
+ $.each(this.timers, function(timerName, val){
2087
+ clearTimeout(val);
2088
+ });
2089
+ },
2090
+ hide: function(){
2091
+ var e = $.Event('wspopoverbeforehide');
2092
+ this.element.trigger(e);
2093
+ if(e.isDefaultPrevented() || !this.isVisible){return;}
2094
+ this.isVisible = false;
2095
+ var that = this;
2096
+ var forceHide = function(){
2097
+ that.element.css('display', 'none').attr({'data-id': '', 'data-class': '', 'hidden': 'hidden'});
2098
+ clearTimeout(that.timers.forcehide);
2099
+ };
2100
+ this.clear();
2101
+ this.element.removeClass('ws-po-visible').trigger('wspopoverhide');
2102
+ $(window).on('resize'+this.eventns, forceHide);
2103
+ that.timers.forcehide = setTimeout(forceHide, 999);
2104
+ },
2105
+ position: function(element){
2106
+ var offset = webshims.getRelOffset(this.element.css({marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0}).removeAttr('hidden'), element);
2107
+ offset.top += element.outerHeight();
2108
+ this.element.css({marginTop: '', marginLeft: '', marginRight: '', marginBottom: ''}).css(offset);
2109
+ }
2110
+ };
2111
+
2112
+ webshims.wsPopover.id = 0;
2113
+
2114
+ /* some extra validation UI */
2115
+ webshims.validityAlert = (function(){
2116
+
2117
+
2118
+ var focusTimer = false;
2119
+
2120
+ var api = webshims.objectCreate(webshims.wsPopover, {}, options.messagePopover);
2121
+ var boundHide = api.hide.bind(api);
2122
+
2123
+ api.element.addClass('validity-alert').attr({role: 'alert'});
2124
+ $.extend(api, {
2125
+ hideDelay: 5000,
2126
+ showFor: function(elem, message, noFocusElem, noBubble){
2127
+
2128
+ elem = $(elem).getNativeElement();
2129
+ this.clear();
2130
+ this.hide();
2131
+ if(!noBubble){
2132
+ this.getMessage(elem, message);
2133
+
2134
+ this.show(elem);
2135
+ if(this.hideDelay){
2136
+ this.timers.delayedHide = setTimeout(boundHide, this.hideDelay);
2137
+ }
2138
+
2139
+ }
2140
+
2141
+ if(!noFocusElem){
2142
+ this.setFocus(elem);
2143
+ }
2144
+ },
2145
+ setFocus: function(element){
2146
+ var focusElem = $(element).getShadowFocusElement();
2147
+ var scrollTop = webshims.scrollRoot.scrollTop();
2148
+ var elemTop = focusElem.offset().top - 30;
2149
+ var smooth;
2150
+
2151
+ if(scrollTop > elemTop){
2152
+ webshims.scrollRoot.animate(
2153
+ {scrollTop: elemTop - 5},
2154
+ {
2155
+ queue: false,
2156
+ duration: Math.max( Math.min( 600, (scrollTop - elemTop) * 1.5 ), 80 )
2157
+ }
2158
+ );
2159
+ smooth = true;
2160
+ }
2161
+ try {
2162
+ focusElem[0].focus();
2163
+ } catch(e){}
2164
+ if(smooth){
2165
+ webshims.scrollRoot.scrollTop(scrollTop);
2166
+ setTimeout(function(){
2167
+ webshims.scrollRoot.scrollTop(scrollTop);
2168
+ }, 0);
2169
+ }
2170
+
2171
+ $(window).triggerHandler('pospopover'+this.eventns);
2172
+ },
2173
+ getMessage: function(elem, message){
2174
+ if (!message) {
2175
+ message = getContentValidationMessage(elem[0]) || elem.prop('customValidationMessage') || elem.prop('validationMessage');
2176
+ }
2177
+ if (message) {
2178
+ api.contentElement.text(message);
2179
+ } else {
2180
+ this.hide();
2181
+ }
2182
+ }
2183
+ });
2184
+
2185
+
2186
+ return api;
2187
+ })();
2188
+
2189
+
2190
+ /* extension, but also used to fix native implementation workaround/bugfixes */
2191
+ (function(){
2192
+ var firstEvent,
2193
+ invalids = [],
2194
+ stopSubmitTimer,
2195
+ form
2196
+ ;
2197
+
2198
+ $(document).on('invalid', function(e){
2199
+ if(e.wrongWebkitInvalid){return;}
2200
+ var jElm = $(e.target);
2201
+ var shadowElem = jElm.getShadowElement();
2202
+ if(!shadowElem.hasClass(invalidClass)){
2203
+ shadowElem.addClass(invalidClass).removeClass(validClass);
2204
+ setTimeout(function(){
2205
+ $(e.target).trigger('changedinvalid').trigger('changedvaliditystate');
2206
+ }, 0);
2207
+ }
2208
+
2209
+ if(!firstEvent){
2210
+ //trigger firstinvalid
2211
+ firstEvent = $.Event('firstinvalid');
2212
+ firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
2213
+ var firstSystemInvalid = $.Event('firstinvalidsystem');
2214
+ $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
2215
+ jElm.trigger(firstEvent);
2216
+ }
2217
+
2218
+ //if firstinvalid was prevented all invalids will be also prevented
2219
+ if( firstEvent && firstEvent.isDefaultPrevented() ){
2220
+ e.preventDefault();
2221
+ }
2222
+ invalids.push(e.target);
2223
+ e.extraData = 'fix';
2224
+ clearTimeout(stopSubmitTimer);
2225
+ stopSubmitTimer = setTimeout(function(){
2226
+ var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
2227
+ //reset firstinvalid
2228
+ firstEvent = false;
2229
+ invalids = [];
2230
+ $(e.target).trigger(lastEvent, lastEvent);
2231
+ }, 9);
2232
+ jElm = null;
2233
+ shadowElem = null;
2234
+ });
2235
+ })();
2236
+
2237
+ $.fn.getErrorMessage = function(){
2238
+ var message = '';
2239
+ var elem = this[0];
2240
+ if(elem){
2241
+ message = getContentValidationMessage(elem) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
2242
+ }
2243
+ return message;
2244
+ };
2245
+
2246
+ if(options.replaceValidationUI){
2247
+ if(options.overrideMessages && (options.customMessages || options.customMessages == null)){
2248
+ options.customMessages = true;
2249
+ options.overrideMessages = false;
2250
+ webshims.info("set overrideMessages to false. Use customMessages instead");
2251
+ }
2252
+ webshims.ready('DOM forms', function(){
2253
+ $(document).on('firstinvalid', function(e){
2254
+ if(!e.isInvalidUIPrevented()){
2255
+ e.preventDefault();
2256
+ $.webshims.validityAlert.showFor( e.target );
2257
+ }
2258
+ });
2259
+ });
2260
+ }
2261
+ });
2262
+
2263
+ })(jQuery);
2264
+ if(!Modernizr.formvalidation || jQuery.webshims.bugs.bustedValidity){
2265
+ jQuery.webshims.register('form-shim-extend', function($, webshims, window, document){
2266
+ "use strict";
2267
+ webshims.inputTypes = webshims.inputTypes || {};
2268
+ //some helper-functions
2269
+ var cfg = webshims.cfg.forms;
2270
+ var isSubmit;
2271
+
2272
+ var isNumber = function(string){
2273
+ return (typeof string == 'number' || (string && string == string * 1));
2274
+ },
2275
+ typeModels = webshims.inputTypes,
2276
+ checkTypes = {
2277
+ radio: 1,
2278
+ checkbox: 1
2279
+ },
2280
+ getType = function(elem){
2281
+ return (elem.getAttribute('type') || elem.type || '').toLowerCase();
2282
+ }
2283
+ ;
2284
+
2285
+ //API to add new input types
2286
+ webshims.addInputType = function(type, obj){
2287
+ typeModels[type] = obj;
2288
+ };
2289
+
2290
+ //contsrain-validation-api
2291
+ var validityPrototype = {
2292
+ customError: false,
2293
+
2294
+ typeMismatch: false,
2295
+ rangeUnderflow: false,
2296
+ rangeOverflow: false,
2297
+ stepMismatch: false,
2298
+ tooLong: false,
2299
+ patternMismatch: false,
2300
+ valueMissing: false,
2301
+
2302
+ valid: true
2303
+ };
2304
+
2305
+ var isPlaceholderOptionSelected = function(select){
2306
+ if(select.type == 'select-one' && select.size < 2){
2307
+ var option = $('> option:first-child', select);
2308
+ return !!option.prop('selected');
2309
+ }
2310
+ return false;
2311
+ };
2312
+
2313
+ var validityRules = {
2314
+ valueMissing: function(input, val, cache){
2315
+ if(!input.prop('required')){return false;}
2316
+ var ret = false;
2317
+ if(!('type' in cache)){
2318
+ cache.type = getType(input[0]);
2319
+ }
2320
+ if(cache.nodeName == 'select'){
2321
+ ret = (!val && (input[0].selectedIndex < 0 || isPlaceholderOptionSelected(input[0]) ));
2322
+ } else if(checkTypes[cache.type]){
2323
+ ret = (cache.type == 'checkbox') ? !input.is(':checked') : !webshims.modules["form-core"].getGroupElements(input).filter(':checked')[0];
2324
+ } else {
2325
+ ret = !(val);
2326
+ }
2327
+ return ret;
2328
+ },
2329
+ tooLong: function(){
2330
+ return false;
2331
+ },
2332
+ typeMismatch: function (input, val, cache){
2333
+ if(val === '' || cache.nodeName == 'select'){return false;}
2334
+ var ret = false;
2335
+ if(!('type' in cache)){
2336
+ cache.type = getType(input[0]);
2337
+ }
2338
+
2339
+ if(typeModels[cache.type] && typeModels[cache.type].mismatch){
2340
+ ret = typeModels[cache.type].mismatch(val, input);
2341
+ } else if('validity' in input[0]){
2342
+ ret = input[0].validity.typeMismatch;
2343
+ }
2344
+ return ret;
2345
+ },
2346
+ patternMismatch: function(input, val, cache) {
2347
+ if(val === '' || cache.nodeName == 'select'){return false;}
2348
+ var pattern = input.attr('pattern');
2349
+ if(!pattern){return false;}
2350
+ try {
2351
+ pattern = new RegExp('^(?:' + pattern + ')$');
2352
+ } catch(er){
2353
+ webshims.error('invalid pattern value: "'+ pattern +'" | '+ er);
2354
+ pattern = false;
2355
+ }
2356
+ if(!pattern){return false;}
2357
+ return !(pattern.test(val));
2358
+ }
2359
+ }
2360
+ ;
2361
+
2362
+ webshims.addValidityRule = function(type, fn){
2363
+ validityRules[type] = fn;
2364
+ };
2365
+
2366
+ $.event.special.invalid = {
2367
+ add: function(){
2368
+ $.event.special.invalid.setup.call(this.form || this);
2369
+ },
2370
+ setup: function(){
2371
+ var form = this.form || this;
2372
+ if( $.data(form, 'invalidEventShim') ){
2373
+ form = null;
2374
+ return;
2375
+ }
2376
+ $(form)
2377
+ .data('invalidEventShim', true)
2378
+ .on('submit', $.event.special.invalid.handler)
2379
+ ;
2380
+ webshims.moveToFirstEvent(form, 'submit');
2381
+ if(webshims.bugs.bustedValidity && $.nodeName(form, 'form')){
2382
+ (function(){
2383
+ var noValidate = form.getAttribute('novalidate');
2384
+ form.setAttribute('novalidate', 'novalidate');
2385
+ webshims.data(form, 'bustedNoValidate', (noValidate == null) ? null : noValidate);
2386
+ })();
2387
+ }
2388
+ form = null;
2389
+ },
2390
+ teardown: $.noop,
2391
+ handler: function(e, d){
2392
+
2393
+ if( e.type != 'submit' || e.testedValidity || !e.originalEvent || !$.nodeName(e.target, 'form') || $.prop(e.target, 'noValidate') ){return;}
2394
+
2395
+ isSubmit = true;
2396
+ e.testedValidity = true;
2397
+ var notValid = !($(e.target).checkValidity());
2398
+ if(notValid){
2399
+ e.stopImmediatePropagation();
2400
+ isSubmit = false;
2401
+ return false;
2402
+ }
2403
+ isSubmit = false;
2404
+ }
2405
+ };
2406
+
2407
+ var addSubmitBubbles = function(form){
2408
+ if (!$.support.submitBubbles && form && typeof form == 'object' && !form._submit_attached ) {
2409
+
2410
+ $.event.add( form, 'submit._submit', function( event ) {
2411
+ event._submit_bubble = true;
2412
+ });
2413
+
2414
+ form._submit_attached = true;
2415
+ }
2416
+ };
2417
+ if(!$.support.submitBubbles && $.event.special.submit){
2418
+ $.event.special.submit.setup = function() {
2419
+ // Only need this for delegated form submit events
2420
+ if ( $.nodeName( this, "form" ) ) {
2421
+ return false;
2422
+ }
2423
+
2424
+ // Lazy-add a submit handler when a descendant form may potentially be submitted
2425
+ $.event.add( this, "click._submit keypress._submit", function( e ) {
2426
+ // Node name check avoids a VML-related crash in IE (#9807)
2427
+ var elem = e.target,
2428
+ form = $.nodeName( elem, 'input' ) || $.nodeName( elem, 'button' ) ? $.prop(elem, 'form') : undefined;
2429
+ addSubmitBubbles(form);
2430
+
2431
+ });
2432
+ // return undefined since we don't need an event listener
2433
+ };
2434
+ }
2435
+
2436
+ $.event.special.submit = $.event.special.submit || {setup: function(){return false;}};
2437
+ var submitSetup = $.event.special.submit.setup;
2438
+ $.extend($.event.special.submit, {
2439
+ setup: function(){
2440
+ if($.nodeName(this, 'form')){
2441
+ $(this).on('invalid', $.noop);
2442
+ } else {
2443
+ $('form', this).on('invalid', $.noop);
2444
+ }
2445
+ return submitSetup.apply(this, arguments);
2446
+ }
2447
+ });
2448
+
2449
+ $(window).on('invalid', $.noop);
2450
+
2451
+
2452
+ webshims.addInputType('email', {
2453
+ mismatch: (function(){
2454
+ //taken from http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
2455
+ var test = cfg.emailReg || /^[a-zA-Z0-9.!#$%&'*+-\/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
2456
+ return function(val){
2457
+ return !test.test(val);
2458
+ };
2459
+ })()
2460
+ });
2461
+
2462
+ webshims.addInputType('url', {
2463
+ mismatch: (function(){
2464
+ //taken from scott gonzales
2465
+ var test = cfg.urlReg || /^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
2466
+ return function(val){
2467
+ return !test.test(val);
2468
+ };
2469
+ })()
2470
+ });
2471
+
2472
+ webshims.defineNodeNameProperty('input', 'type', {
2473
+ prop: {
2474
+ get: function(){
2475
+ var elem = this;
2476
+ var type = (elem.getAttribute('type') || '').toLowerCase();
2477
+ return (webshims.inputTypes[type]) ? type : elem.type;
2478
+ }
2479
+ }
2480
+ });
2481
+
2482
+ // IDLs for constrain validation API
2483
+ //ToDo: add object to this list
2484
+ webshims.defineNodeNamesProperties(['button', 'fieldset', 'output'], {
2485
+ checkValidity: {
2486
+ value: function(){return true;}
2487
+ },
2488
+ willValidate: {
2489
+ value: false
2490
+ },
2491
+ setCustomValidity: {
2492
+ value: $.noop
2493
+ },
2494
+ validity: {
2495
+ writeable: false,
2496
+ get: function(){
2497
+ return $.extend({}, validityPrototype);
2498
+ }
2499
+ }
2500
+ }, 'prop');
2501
+
2502
+ var baseCheckValidity = function(elem){
2503
+ var e,
2504
+ v = $.prop(elem, 'validity')
2505
+ ;
2506
+ if(v){
2507
+ $.data(elem, 'cachedValidity', v);
2508
+ } else {
2509
+ return true;
2510
+ }
2511
+ if( !v.valid ){
2512
+ e = $.Event('invalid');
2513
+ var jElm = $(elem).trigger(e);
2514
+ if(isSubmit && !baseCheckValidity.unhandledInvalids && !e.isDefaultPrevented()){
2515
+ webshims.validityAlert.showFor(jElm);
2516
+ baseCheckValidity.unhandledInvalids = true;
2517
+ }
2518
+ }
2519
+ $.removeData(elem, 'cachedValidity');
2520
+ return v.valid;
2521
+ };
2522
+ var rsubmittable = /^(?:select|textarea|input)/i;
2523
+ webshims.defineNodeNameProperty('form', 'checkValidity', {
2524
+ prop: {
2525
+ value: function(){
2526
+
2527
+ var ret = true,
2528
+ elems = $($.prop(this, 'elements')).filter(function(){
2529
+ if(!rsubmittable.test(this.nodeName)){return false;}
2530
+ var shadowData = webshims.data(this, 'shadowData');
2531
+ return !shadowData || !shadowData.nativeElement || shadowData.nativeElement === this;
2532
+ })
2533
+ ;
2534
+
2535
+ baseCheckValidity.unhandledInvalids = false;
2536
+ for(var i = 0, len = elems.length; i < len; i++){
2537
+ if( !baseCheckValidity(elems[i]) ){
2538
+ ret = false;
2539
+ }
2540
+ }
2541
+ return ret;
2542
+ }
2543
+ }
2544
+ });
2545
+
2546
+ webshims.defineNodeNamesProperties(['input', 'textarea', 'select'], {
2547
+ checkValidity: {
2548
+ value: function(){
2549
+ baseCheckValidity.unhandledInvalids = false;
2550
+ return baseCheckValidity($(this).getNativeElement()[0]);
2551
+ }
2552
+ },
2553
+ setCustomValidity: {
2554
+ value: function(error){
2555
+ $.removeData(this, 'cachedValidity');
2556
+ webshims.data(this, 'customvalidationMessage', ''+error);
2557
+ }
2558
+ },
2559
+ willValidate: {
2560
+ writeable: false,
2561
+ get: (function(){
2562
+ var types = {
2563
+ button: 1,
2564
+ reset: 1,
2565
+ hidden: 1,
2566
+ image: 1
2567
+ }
2568
+ ;
2569
+ return function(){
2570
+ var elem = $(this).getNativeElement()[0];
2571
+ //elem.name && <- we don't use to make it easier for developers
2572
+ return !!(!elem.disabled && !elem.readOnly && !types[elem.type] );
2573
+ };
2574
+ })()
2575
+ },
2576
+ validity: {
2577
+ writeable: false,
2578
+ get: function(){
2579
+ var jElm = $(this).getNativeElement();
2580
+ var elem = jElm[0];
2581
+ var validityState = $.data(elem, 'cachedValidity');
2582
+ if(validityState){
2583
+ return validityState;
2584
+ }
2585
+ validityState = $.extend({}, validityPrototype);
2586
+
2587
+ if( !$.prop(elem, 'willValidate') || elem.type == 'submit' ){
2588
+ return validityState;
2589
+ }
2590
+ var val = jElm.val(),
2591
+ cache = {nodeName: elem.nodeName.toLowerCase()}
2592
+ ;
2593
+
2594
+ validityState.customError = !!(webshims.data(elem, 'customvalidationMessage'));
2595
+ if( validityState.customError ){
2596
+ validityState.valid = false;
2597
+ }
2598
+
2599
+ $.each(validityRules, function(rule, fn){
2600
+ if (fn(jElm, val, cache)) {
2601
+ validityState[rule] = true;
2602
+ validityState.valid = false;
2603
+ }
2604
+ });
2605
+ $(this).getShadowFocusElement().attr('aria-invalid', validityState.valid ? 'false' : 'true');
2606
+ jElm = null;
2607
+ elem = null;
2608
+ return validityState;
2609
+ }
2610
+ }
2611
+ }, 'prop');
2612
+
2613
+ webshims.defineNodeNamesBooleanProperty(['input', 'textarea', 'select'], 'required', {
2614
+ set: function(value){
2615
+ $(this).getShadowFocusElement().attr('aria-required', !!(value)+'');
2616
+ },
2617
+ initAttr: Modernizr.localstorage //only if we have aria-support
2618
+ });
2619
+
2620
+ webshims.reflectProperties(['input'], ['pattern']);
2621
+
2622
+
2623
+ if( !('maxLength' in document.createElement('textarea')) ){
2624
+ var constrainMaxLength = (function(){
2625
+ var timer;
2626
+ var curLength = 0;
2627
+ var lastElement = $([]);
2628
+ var max = 1e9;
2629
+ var constrainLength = function(){
2630
+ var nowValue = lastElement.prop('value');
2631
+ var nowLen = nowValue.length;
2632
+ if(nowLen > curLength && nowLen > max){
2633
+ nowLen = Math.max(curLength, max);
2634
+ lastElement.prop('value', nowValue.substr(0, nowLen ));
2635
+ }
2636
+ curLength = nowLen;
2637
+ };
2638
+ var remove = function(){
2639
+ clearTimeout(timer);
2640
+ lastElement.unbind('.maxlengthconstraint');
2641
+ };
2642
+ return function(element, maxLength){
2643
+ remove();
2644
+ if(maxLength > -1){
2645
+ max = maxLength;
2646
+ curLength = $.prop(element, 'value').length;
2647
+ lastElement = $(element);
2648
+ lastElement.on({
2649
+ 'keydown.maxlengthconstraint keypress.maxlengthconstraint paste.maxlengthconstraint cut.maxlengthconstraint': function(e){
2650
+ setTimeout(constrainLength, 0);
2651
+ },
2652
+ 'keyup.maxlengthconstraint': constrainLength,
2653
+ 'blur.maxlengthconstraint': remove
2654
+ });
2655
+ timer = setInterval(constrainLength, 200);
2656
+ }
2657
+ };
2658
+ })();
2659
+
2660
+ constrainMaxLength.update = function(element, maxLength){
2661
+ if($(element).is(':focus')){
2662
+ if(!maxLength){
2663
+ maxLength = $.prop(element, 'maxlength');
2664
+ }
2665
+ constrainMaxLength(element, maxLength);
2666
+ }
2667
+ };
2668
+
2669
+ $(document).on('focusin', function(e){
2670
+ var maxLength;
2671
+ if(e.target.nodeName == "TEXTAREA" && (maxLength = $.prop(e.target, 'maxlength')) > -1){
2672
+ constrainMaxLength(e.target, maxLength);
2673
+ }
2674
+ });
2675
+
2676
+ webshims.defineNodeNameProperty('textarea', 'maxlength', {
2677
+ attr: {
2678
+ set: function(val){
2679
+ this.setAttribute('maxlength', ''+val);
2680
+ constrainMaxLength.update(this);
2681
+ },
2682
+ get: function(){
2683
+ var ret = this.getAttribute('maxlength');
2684
+ return ret == null ? undefined : ret;
2685
+ }
2686
+ },
2687
+ prop: {
2688
+ set: function(val){
2689
+ if(isNumber(val)){
2690
+ if(val < 0){
2691
+ throw('INDEX_SIZE_ERR');
2692
+ }
2693
+ val = parseInt(val, 10);
2694
+ this.setAttribute('maxlength', val);
2695
+ constrainMaxLength.update(this, val);
2696
+ return;
2697
+ }
2698
+ this.setAttribute('maxlength', '0');
2699
+ constrainMaxLength.update(this, 0);
2700
+ },
2701
+ get: function(){
2702
+ var val = this.getAttribute('maxlength');
2703
+ return (isNumber(val) && val >= 0) ? parseInt(val, 10) : -1;
2704
+
2705
+ }
2706
+ }
2707
+ });
2708
+ webshims.defineNodeNameProperty('textarea', 'maxLength', {
2709
+ prop: {
2710
+ set: function(val){
2711
+ $.prop(this, 'maxlength', val);
2712
+ },
2713
+ get: function(){
2714
+ return $.prop(this, 'maxlength');
2715
+ }
2716
+ }
2717
+ });
2718
+ }
2719
+
2720
+
2721
+
2722
+ var submitterTypes = {submit: 1, button: 1, image: 1};
2723
+ var formSubmitterDescriptors = {};
2724
+ [
2725
+ {
2726
+ name: "enctype",
2727
+ limitedTo: {
2728
+ "application/x-www-form-urlencoded": 1,
2729
+ "multipart/form-data": 1,
2730
+ "text/plain": 1
2731
+ },
2732
+ defaultProp: "application/x-www-form-urlencoded",
2733
+ proptype: "enum"
2734
+ },
2735
+ {
2736
+ name: "method",
2737
+ limitedTo: {
2738
+ "get": 1,
2739
+ "post": 1
2740
+ },
2741
+ defaultProp: "get",
2742
+ proptype: "enum"
2743
+ },
2744
+ {
2745
+ name: "action",
2746
+ proptype: "url"
2747
+ },
2748
+ {
2749
+ name: "target"
2750
+ },
2751
+ {
2752
+ name: "novalidate",
2753
+ propName: "noValidate",
2754
+ proptype: "boolean"
2755
+ }
2756
+ ].forEach(function(desc){
2757
+ var propName = 'form'+ (desc.propName || desc.name).replace(/^[a-z]/, function(f){
2758
+ return f.toUpperCase();
2759
+ });
2760
+ var attrName = 'form'+ desc.name;
2761
+ var formName = desc.name;
2762
+ var eventName = 'click.webshimssubmittermutate'+formName;
2763
+
2764
+ var changeSubmitter = function(){
2765
+ var elem = this;
2766
+ if( !('form' in elem) || !submitterTypes[elem.type] ){return;}
2767
+ var form = $.prop(elem, 'form');
2768
+ if(!form){return;}
2769
+ var attr = $.attr(elem, attrName);
2770
+ if(attr != null && ( !desc.limitedTo || attr.toLowerCase() === $.prop(elem, propName))){
2771
+
2772
+ var oldAttr = $.attr(form, formName);
2773
+
2774
+ $.attr(form, formName, attr);
2775
+ setTimeout(function(){
2776
+ if(oldAttr != null){
2777
+ $.attr(form, formName, oldAttr);
2778
+ } else {
2779
+ try {
2780
+ $(form).removeAttr(formName);
2781
+ } catch(er){
2782
+ form.removeAttribute(formName);
2783
+ }
2784
+ }
2785
+ }, 9);
2786
+ }
2787
+ };
2788
+
2789
+
2790
+
2791
+ switch(desc.proptype) {
2792
+ case "url":
2793
+ var urlForm = document.createElement('form');
2794
+ formSubmitterDescriptors[propName] = {
2795
+ prop: {
2796
+ set: function(value){
2797
+ $.attr(this, attrName, value);
2798
+ },
2799
+ get: function(){
2800
+ var value = $.attr(this, attrName);
2801
+ if(value == null){return '';}
2802
+ urlForm.setAttribute('action', value);
2803
+ return urlForm.action;
2804
+ }
2805
+ }
2806
+ };
2807
+ break;
2808
+ case "boolean":
2809
+ formSubmitterDescriptors[propName] = {
2810
+ prop: {
2811
+ set: function(val){
2812
+ val = !!val;
2813
+ if(val){
2814
+ $.attr(this, 'formnovalidate', 'formnovalidate');
2815
+ } else {
2816
+ $(this).removeAttr('formnovalidate');
2817
+ }
2818
+ },
2819
+ get: function(){
2820
+ return $.attr(this, 'formnovalidate') != null;
2821
+ }
2822
+ }
2823
+ };
2824
+ break;
2825
+ case "enum":
2826
+ formSubmitterDescriptors[propName] = {
2827
+ prop: {
2828
+ set: function(value){
2829
+ $.attr(this, attrName, value);
2830
+ },
2831
+ get: function(){
2832
+ var value = $.attr(this, attrName);
2833
+ return (!value || ( (value = value.toLowerCase()) && !desc.limitedTo[value] )) ? desc.defaultProp : value;
2834
+ }
2835
+ }
2836
+ };
2837
+ break;
2838
+ default:
2839
+ formSubmitterDescriptors[propName] = {
2840
+ prop: {
2841
+ set: function(value){
2842
+ $.attr(this, attrName, value);
2843
+ },
2844
+ get: function(){
2845
+ var value = $.attr(this, attrName);
2846
+ return (value != null) ? value : "";
2847
+ }
2848
+ }
2849
+ };
2850
+ }
2851
+
2852
+
2853
+ if(!formSubmitterDescriptors[attrName]){
2854
+ formSubmitterDescriptors[attrName] = {};
2855
+ }
2856
+ formSubmitterDescriptors[attrName].attr = {
2857
+ set: function(value){
2858
+ formSubmitterDescriptors[attrName].attr._supset.call(this, value);
2859
+ $(this).unbind(eventName).on(eventName, changeSubmitter);
2860
+ },
2861
+ get: function(){
2862
+ return formSubmitterDescriptors[attrName].attr._supget.call(this);
2863
+ }
2864
+ };
2865
+ formSubmitterDescriptors[attrName].initAttr = true;
2866
+ formSubmitterDescriptors[attrName].removeAttr = {
2867
+ value: function(){
2868
+ $(this).unbind(eventName);
2869
+ formSubmitterDescriptors[attrName].removeAttr._supvalue.call(this);
2870
+ }
2871
+ };
2872
+ });
2873
+
2874
+ webshims.defineNodeNamesProperties(['input', 'button'], formSubmitterDescriptors);
2875
+
2876
+
2877
+ if(!$.support.getSetAttribute && $('<form novalidate></form>').attr('novalidate') == null){
2878
+ webshims.defineNodeNameProperty('form', 'novalidate', {
2879
+ attr: {
2880
+ set: function(val){
2881
+ this.setAttribute('novalidate', ''+val);
2882
+ },
2883
+ get: function(){
2884
+ var ret = this.getAttribute('novalidate');
2885
+ return ret == null ? undefined : ret;
2886
+ }
2887
+ }
2888
+ });
2889
+ } else if(webshims.bugs.bustedValidity){
2890
+
2891
+ webshims.defineNodeNameProperty('form', 'novalidate', {
2892
+ attr: {
2893
+ set: function(val){
2894
+ webshims.data(this, 'bustedNoValidate', ''+val);
2895
+ },
2896
+ get: function(){
2897
+ var ret = webshims.data(this, 'bustedNoValidate');
2898
+ return ret == null ? undefined : ret;
2899
+ }
2900
+ },
2901
+ removeAttr: {
2902
+ value: function(){
2903
+ webshims.data(this, 'bustedNoValidate', null);
2904
+ }
2905
+ }
2906
+ });
2907
+
2908
+ $.each(['rangeUnderflow', 'rangeOverflow', 'stepMismatch'], function(i, name){
2909
+ validityRules[name] = function(elem){
2910
+ return (elem[0].validity || {})[name] || false;
2911
+ };
2912
+ });
2913
+
2914
+ }
2915
+
2916
+ webshims.defineNodeNameProperty('form', 'noValidate', {
2917
+ prop: {
2918
+ set: function(val){
2919
+ val = !!val;
2920
+ if(val){
2921
+ $.attr(this, 'novalidate', 'novalidate');
2922
+ } else {
2923
+ $(this).removeAttr('novalidate');
2924
+ }
2925
+ },
2926
+ get: function(){
2927
+ return $.attr(this, 'novalidate') != null;
2928
+ }
2929
+ }
2930
+ });
2931
+
2932
+ if(Modernizr.inputtypes.date && /webkit/i.test(navigator.userAgent)){
2933
+ (function(){
2934
+
2935
+ var noInputTriggerEvts = {updateInput: 1, input: 1},
2936
+ fixInputTypes = {
2937
+ date: 1,
2938
+ time: 1,
2939
+ "datetime-local": 1
2940
+ },
2941
+ noFocusEvents = {
2942
+ focusout: 1,
2943
+ blur: 1
2944
+ },
2945
+ changeEvts = {
2946
+ updateInput: 1,
2947
+ change: 1
2948
+ },
2949
+ observe = function(input){
2950
+ var timer,
2951
+ focusedin = true,
2952
+ lastInputVal = input.prop('value'),
2953
+ lastChangeVal = lastInputVal,
2954
+ trigger = function(e){
2955
+ //input === null
2956
+ if(!input){return;}
2957
+ var newVal = input.prop('value');
2958
+
2959
+ if(newVal !== lastInputVal){
2960
+ lastInputVal = newVal;
2961
+ if(!e || !noInputTriggerEvts[e.type]){
2962
+ input.trigger('input');
2963
+ }
2964
+ }
2965
+ if(e && changeEvts[e.type]){
2966
+ lastChangeVal = newVal;
2967
+ }
2968
+ if(!focusedin && newVal !== lastChangeVal){
2969
+ input.trigger('change');
2970
+ }
2971
+ },
2972
+ extraTimer,
2973
+ extraTest = function(){
2974
+ clearTimeout(extraTimer);
2975
+ extraTimer = setTimeout(trigger, 9);
2976
+ },
2977
+ unbind = function(e){
2978
+ clearInterval(timer);
2979
+ setTimeout(function(){
2980
+ if(e && noFocusEvents[e.type]){
2981
+ focusedin = false;
2982
+ }
2983
+ if(input){
2984
+ input.unbind('focusout blur', unbind).unbind('input change updateInput', trigger);
2985
+ trigger();
2986
+ }
2987
+ input = null;
2988
+ }, 1);
2989
+
2990
+ }
2991
+ ;
2992
+
2993
+ clearInterval(timer);
2994
+ timer = setInterval(trigger, 160);
2995
+ extraTest();
2996
+ input
2997
+ .off({
2998
+ 'focusout blur': unbind,
2999
+ 'input change updateInput': trigger
3000
+ })
3001
+ .on({
3002
+ 'focusout blur': unbind,
3003
+ 'input updateInput change': trigger
3004
+ })
3005
+ ;
3006
+ }
3007
+ ;
3008
+ if($.event.customEvent){
3009
+ $.event.customEvent.updateInput = true;
3010
+ }
3011
+
3012
+ (function(){
3013
+
3014
+ var correctValue = function(elem){
3015
+ var i = 1;
3016
+ var len = 3;
3017
+ var abort, val;
3018
+ if(elem.type == 'date' && (isSubmit || !$(elem).is(':focus'))){
3019
+ val = elem.value;
3020
+ if(val && val.length < 10 && (val = val.split('-')) && val.length == len){
3021
+ for(; i < len; i++){
3022
+ if(val[i].length == 1){
3023
+ val[i] = '0'+val[i];
3024
+ } else if(val[i].length != 2){
3025
+ abort = true;
3026
+ break;
3027
+ }
3028
+ }
3029
+ if(!abort){
3030
+ val = val.join('-');
3031
+ $.prop(elem, 'value', val);
3032
+ return val;
3033
+ }
3034
+ }
3035
+ }
3036
+ };
3037
+ var inputCheckValidityDesc, formCheckValidityDesc, inputValueDesc, inputValidityDesc;
3038
+
3039
+ inputCheckValidityDesc = webshims.defineNodeNameProperty('input', 'checkValidity', {
3040
+ prop: {
3041
+ value: function(){
3042
+ correctValue(this);
3043
+ return inputCheckValidityDesc.prop._supvalue.apply(this, arguments);
3044
+ }
3045
+ }
3046
+ });
3047
+
3048
+ formCheckValidityDesc = webshims.defineNodeNameProperty('form', 'checkValidity', {
3049
+ prop: {
3050
+ value: function(){
3051
+ $('input', this).each(function(){
3052
+ correctValue(this);
3053
+ });
3054
+ return formCheckValidityDesc.prop._supvalue.apply(this, arguments);
3055
+ }
3056
+ }
3057
+ });
3058
+
3059
+ inputValueDesc = webshims.defineNodeNameProperty('input', 'value', {
3060
+ prop: {
3061
+ set: function(){
3062
+ return inputValueDesc.prop._supset.apply(this, arguments);
3063
+ },
3064
+ get: function(){
3065
+ return correctValue(this) || inputValueDesc.prop._supget.apply(this, arguments);
3066
+ }
3067
+ }
3068
+ });
3069
+
3070
+ inputValidityDesc = webshims.defineNodeNameProperty('input', 'validity', {
3071
+ prop: {
3072
+ writeable: false,
3073
+ get: function(){
3074
+ correctValue(this);
3075
+ return inputValidityDesc.prop._supget.apply(this, arguments);
3076
+ }
3077
+ }
3078
+ });
3079
+
3080
+ $(document).on('change', function(e){
3081
+ correctValue(e.target);
3082
+ });
3083
+
3084
+ })();
3085
+
3086
+ $(document)
3087
+ .on('focusin', function(e){
3088
+ if( e.target && fixInputTypes[e.target.type] && !e.target.readOnly && !e.target.disabled ){
3089
+ observe($(e.target));
3090
+ }
3091
+ })
3092
+ ;
3093
+
3094
+
3095
+ })();
3096
+ }
3097
+
3098
+ webshims.addReady(function(context, contextElem){
3099
+ //start constrain-validation
3100
+ var focusElem;
3101
+ $('form', context)
3102
+ .add(contextElem.filter('form'))
3103
+ .bind('invalid', $.noop)
3104
+ ;
3105
+
3106
+ try {
3107
+ if(context == document && !('form' in (document.activeElement || {}))) {
3108
+ focusElem = $('input[autofocus], select[autofocus], textarea[autofocus]', context).eq(0).getShadowFocusElement()[0];
3109
+ if (focusElem && focusElem.offsetHeight && focusElem.offsetWidth) {
3110
+ focusElem.focus();
3111
+ }
3112
+ }
3113
+ }
3114
+ catch (er) {}
3115
+
3116
+ });
3117
+
3118
+ if(!Modernizr.formattribute || !Modernizr.fieldsetdisabled){
3119
+ (function(){
3120
+ (function(prop, undefined){
3121
+ $.prop = function(elem, name, value){
3122
+ var ret;
3123
+ if(elem && elem.nodeType == 1 && value === undefined && $.nodeName(elem, 'form') && elem.id){
3124
+ ret = document.getElementsByName(name);
3125
+ if(!ret || !ret.length){
3126
+ ret = document.getElementById(name);
3127
+ }
3128
+ if(ret){
3129
+ ret = $(ret).filter(function(){
3130
+ return $.prop(this, 'form') == elem;
3131
+ }).get();
3132
+ if(ret.length){
3133
+ return ret.length == 1 ? ret[0] : ret;
3134
+ }
3135
+ }
3136
+ }
3137
+ return prop.apply(this, arguments);
3138
+ };
3139
+ })($.prop, undefined);
3140
+ var removeAddedElements = function(form){
3141
+ var elements = $.data(form, 'webshimsAddedElements');
3142
+ if(elements){
3143
+ elements.remove();
3144
+ $.removeData(form, 'webshimsAddedElements');
3145
+ }
3146
+ };
3147
+
3148
+
3149
+ if(!Modernizr.formattribute){
3150
+ webshims.defineNodeNamesProperty(['input', 'textarea', 'select', 'button', 'fieldset'], 'form', {
3151
+ prop: {
3152
+ get: function(){
3153
+ var form = webshims.contentAttr(this, 'form');
3154
+ if(form){
3155
+ form = document.getElementById(form);
3156
+ if(form && !$.nodeName(form, 'form')){
3157
+ form = null;
3158
+ }
3159
+ }
3160
+ return form || this.form;
3161
+ },
3162
+ writeable: false
3163
+ }
3164
+ });
3165
+
3166
+
3167
+ webshims.defineNodeNamesProperty(['form'], 'elements', {
3168
+ prop: {
3169
+ get: function(){
3170
+ var id = this.id;
3171
+ var elements = $.makeArray(this.elements);
3172
+ if(id){
3173
+ elements = $(elements).add('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"], button[form="'+ id +'"], fieldset[form="'+ id +'"]').not('.webshims-visual-hide > *').get();
3174
+ }
3175
+ return elements;
3176
+ },
3177
+ writeable: false
3178
+ }
3179
+ });
3180
+
3181
+
3182
+
3183
+ $(function(){
3184
+ var stopPropagation = function(e){
3185
+ e.stopPropagation();
3186
+ };
3187
+ $(document).on('submit', function(e){
3188
+
3189
+ if(!e.isDefaultPrevented()){
3190
+ var form = e.target;
3191
+ var id = form.id;
3192
+ var elements;
3193
+
3194
+
3195
+ if(id){
3196
+ removeAddedElements(form);
3197
+
3198
+ elements = $('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"]')
3199
+ .filter(function(){
3200
+ return !this.disabled && this.name && this.form != form;
3201
+ })
3202
+ .clone()
3203
+ ;
3204
+ if(elements.length){
3205
+ $.data(form, 'webshimsAddedElements', $('<div class="webshims-visual-hide" />').append(elements).appendTo(form));
3206
+ setTimeout(function(){
3207
+ removeAddedElements(form);
3208
+ }, 9);
3209
+ }
3210
+ elements = null;
3211
+ }
3212
+ }
3213
+ });
3214
+
3215
+ $(document).on('click', function(e){
3216
+ if(!e.isDefaultPrevented() && $(e.target).is('input[type="submit"][form], button[form], input[type="button"][form], input[type="image"][form], input[type="reset"][form]')){
3217
+ var trueForm = $.prop(e.target, 'form');
3218
+ var formIn = e.target.form;
3219
+ var clone;
3220
+ if(trueForm && trueForm != formIn){
3221
+ clone = $(e.target)
3222
+ .clone()
3223
+ .removeAttr('form')
3224
+ .addClass('webshims-visual-hide')
3225
+ .on('click', stopPropagation)
3226
+ .appendTo(trueForm)
3227
+ ;
3228
+ if(formIn){
3229
+ e.preventDefault();
3230
+ }
3231
+ addSubmitBubbles(trueForm);
3232
+ clone.trigger('click');
3233
+ setTimeout(function(){
3234
+ clone.remove();
3235
+ clone = null;
3236
+ }, 9);
3237
+ }
3238
+ }
3239
+ });
3240
+ });
3241
+ }
3242
+
3243
+ if(!Modernizr.fieldsetdisabled){
3244
+ webshims.defineNodeNamesProperty(['fieldset'], 'elements', {
3245
+ prop: {
3246
+ get: function(){
3247
+ //add listed elements without keygen, object, output
3248
+ return $('input, select, textarea, button, fieldset', this).get() || [];
3249
+ },
3250
+ writeable: false
3251
+ }
3252
+ });
3253
+ }
3254
+
3255
+ if(!$.fn.finish && parseFloat($.fn.jquery, 10) < 1.9){
3256
+ var rCRLF = /\r?\n/g,
3257
+ rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
3258
+ rselectTextarea = /^(?:select|textarea)/i;
3259
+ $.fn.serializeArray = function() {
3260
+ return this.map(function(){
3261
+ var elements = $.prop(this, 'elements');
3262
+ return elements ? $.makeArray( elements ) : this;
3263
+ })
3264
+ .filter(function(){
3265
+ return this.name && !this.disabled &&
3266
+ ( this.checked || rselectTextarea.test( this.nodeName ) ||
3267
+ rinput.test( this.type ) );
3268
+ })
3269
+ .map(function( i, elem ){
3270
+ var val = $( this ).val();
3271
+
3272
+ return val == null ?
3273
+ null :
3274
+ $.isArray( val ) ?
3275
+ $.map( val, function( val, i ){
3276
+ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
3277
+ }) :
3278
+ { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
3279
+ }).get();
3280
+ };
3281
+ }
3282
+
3283
+ })();
3284
+ }
3285
+
3286
+ if($('<input />').prop('labels') == null){
3287
+ webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
3288
+ prop: {
3289
+ get: function(){
3290
+ if(this.type == 'hidden'){return null;}
3291
+ var id = this.id;
3292
+ var labels = $(this)
3293
+ .closest('label')
3294
+ .filter(function(){
3295
+ var hFor = (this.attributes['for'] || {});
3296
+ return (!hFor.specified || hFor.value == id);
3297
+ })
3298
+ ;
3299
+
3300
+ if(id) {
3301
+ labels = labels.add('label[for="'+ id +'"]');
3302
+ }
3303
+ return labels.get();
3304
+ },
3305
+ writeable: false
3306
+ }
3307
+ });
3308
+ }
3309
+
3310
+ if(!('value' in document.createElement('progress'))){
3311
+ (function(){
3312
+
3313
+ var nan = parseInt('NaN', 10);
3314
+
3315
+ var updateProgress = function(progress){
3316
+ var position;
3317
+
3318
+
3319
+ position = $.prop(progress, 'position');
3320
+
3321
+ $.attr(progress, 'data-position', position);
3322
+ $('> span', progress).css({width: (position < 0 ? 100 : position * 100) +'%'});
3323
+ };
3324
+ var desc = {
3325
+ position: {
3326
+ prop: {
3327
+ get: function(){
3328
+ var max;
3329
+ //jQuery 1.8.x try's to normalize "0" to 0
3330
+ var val = this.getAttribute('value');
3331
+ var ret = -1;
3332
+
3333
+ val = val ? (val * 1) : nan;
3334
+ if(!isNaN(val)){
3335
+ max = $.prop(this, 'max');
3336
+ ret = Math.max(Math.min(val / max, 1), 0);
3337
+ if(updateProgress.isInChange){
3338
+ $.attr(this, 'aria-valuenow', ret * 100);
3339
+ if(updateProgress.isInChange == 'max'){
3340
+ $.attr(this, 'aria-valuemax', max);
3341
+ }
3342
+ }
3343
+ } else if(updateProgress.isInChange) {
3344
+ $(this).removeAttr('aria-valuenow');
3345
+ }
3346
+ return ret;
3347
+ },
3348
+ writeable: false
3349
+ }
3350
+ }
3351
+ };
3352
+
3353
+ $.each({value: 0, max: 1}, function(name, defValue){
3354
+ var removeProp = (name == 'value' && !$.fn.finish);
3355
+ desc[name] = {
3356
+ attr: {
3357
+ set: function(value){
3358
+ var ret = desc[name].attr._supset.call(this, value);
3359
+ updateProgress.isInChange = name;
3360
+ updateProgress(this);
3361
+ updateProgress.isInChange = false;
3362
+ return ret;
3363
+ }
3364
+ },
3365
+ removeAttr: {
3366
+ value: function(){
3367
+ this.removeAttribute(name);
3368
+ if(removeProp){
3369
+ delete this.value;
3370
+ }
3371
+ updateProgress.isInChange = name;
3372
+ updateProgress(this);
3373
+ updateProgress.isInChange = false;
3374
+ }
3375
+ },
3376
+ prop: {
3377
+ get: function(){
3378
+ var max;
3379
+ var ret = (desc[name].attr.get.call(this) * 1);
3380
+ if(ret < 0 || isNaN(ret)){
3381
+ ret = defValue;
3382
+ } else if(name == 'value'){
3383
+ ret = Math.min(ret, $.prop(this, 'max'));
3384
+ } else if(ret === 0){
3385
+ ret = defValue;
3386
+ }
3387
+ return ret;
3388
+ },
3389
+ set: function(value){
3390
+ value = value * 1;
3391
+ if(isNaN(value)){
3392
+ webshims.error('Floating-point value is not finite.');
3393
+ }
3394
+ return desc[name].attr.set.call(this, value);
3395
+ }
3396
+ }
3397
+ };
3398
+ });
3399
+
3400
+ webshims.createElement(
3401
+ 'progress',
3402
+ function(){
3403
+ var labels = $(this)
3404
+ .attr({role: 'progressbar', 'aria-valuemin': '0'})
3405
+ .html('<span class="progress-value" />')
3406
+ .jProp('labels')
3407
+ .map(function(){
3408
+ return webshims.getID(this);
3409
+ })
3410
+ .get()
3411
+ ;
3412
+ if(labels.length){
3413
+ $.attr(this, 'aria-labelledby', labels.join(' '));
3414
+ } else {
3415
+ webshims.info("you should use label elements for your prgogress elements");
3416
+ }
3417
+
3418
+ updateProgress.isInChange = 'max';
3419
+ updateProgress(this);
3420
+ updateProgress.isInChange = false;
3421
+ },
3422
+ desc
3423
+ );
3424
+
3425
+ })();
3426
+ }
3427
+
3428
+ try {
3429
+ document.querySelector(':checked');
3430
+ } catch(er){
3431
+ (function(){
3432
+ $('html').addClass('no-csschecked');
3433
+ var checkInputs = {
3434
+ radio: 1,
3435
+ checkbox: 1
3436
+ };
3437
+ var selectChange = function(){
3438
+ var options = this.options || [];
3439
+ var i, len, option;
3440
+ for(i = 0, len = options.length; i < len; i++){
3441
+ option = $(options[i]);
3442
+ option[$.prop(options[i], 'selected') ? 'addClass' : 'removeClass']('prop-checked');
3443
+ }
3444
+ };
3445
+ var checkChange = function(){
3446
+ var fn = $.prop(this, 'checked') ? 'addClass' : 'removeClass';
3447
+ var className = this.className || '';
3448
+ var parent;
3449
+
3450
+ //IE8- has problems to update styles, we help
3451
+ if( (className.indexOf('prop-checked') == -1) == (fn == 'addClass')){
3452
+ $(this)[fn]('prop-checked');
3453
+ if((parent = this.parentNode)){
3454
+ parent.className = parent.className;
3455
+ }
3456
+ }
3457
+ };
3458
+
3459
+
3460
+ webshims.onNodeNamesPropertyModify('select', 'value', selectChange);
3461
+ webshims.onNodeNamesPropertyModify('select', 'selectedIndex', selectChange);
3462
+ webshims.onNodeNamesPropertyModify('option', 'selected', function(){
3463
+ $(this).closest('select').each(selectChange);
3464
+ });
3465
+ webshims.onNodeNamesPropertyModify('input', 'checked', function(value, boolVal){
3466
+ var type = this.type;
3467
+ if(type == 'radio' && boolVal){
3468
+ webshims.modules["form-core"].getGroupElements(this).each(checkChange);
3469
+ } else if(checkInputs[type]) {
3470
+ $(this).each(checkChange);
3471
+ }
3472
+ });
3473
+
3474
+ $(document).on('change', function(e){
3475
+
3476
+ if(checkInputs[e.target.type]){
3477
+ if(e.target.type == 'radio'){
3478
+ webshims.modules["form-core"].getGroupElements(e.target).each(checkChange);
3479
+ } else {
3480
+ $(e.target)[$.prop(e.target, 'checked') ? 'addClass' : 'removeClass']('prop-checked');
3481
+ }
3482
+ } else if(e.target.nodeName.toLowerCase() == 'select'){
3483
+ $(e.target).each(selectChange);
3484
+ }
3485
+ });
3486
+
3487
+ webshims.addReady(function(context, contextElem){
3488
+ $('option, input', context)
3489
+ .add(contextElem.filter('option, input'))
3490
+ .each(function(){
3491
+ var prop;
3492
+ if(checkInputs[this.type]){
3493
+ prop = 'checked';
3494
+ } else if(this.nodeName.toLowerCase() == 'option'){
3495
+ prop = 'selected';
3496
+ }
3497
+ if(prop){
3498
+ $(this)[$.prop(this, prop) ? 'addClass' : 'removeClass']('prop-checked');
3499
+ }
3500
+
3501
+ })
3502
+ ;
3503
+ });
3504
+ })();
3505
+ }
3506
+
3507
+ (function(){
3508
+ Modernizr.textareaPlaceholder = !!('placeholder' in $('<textarea />')[0]);
3509
+ if(Modernizr.input.placeholder && Modernizr.textareaPlaceholder){return;}
3510
+
3511
+ var isOver = (webshims.cfg.forms.placeholderType == 'over');
3512
+ var isResponsive = (webshims.cfg.forms.responsivePlaceholder);
3513
+ var polyfillElements = ['textarea'];
3514
+ if(!Modernizr.input.placeholder){
3515
+ polyfillElements.push('input');
3516
+ }
3517
+
3518
+ var setSelection = function(elem){
3519
+ try {
3520
+ if(elem.setSelectionRange){
3521
+ elem.setSelectionRange(0, 0);
3522
+ return true;
3523
+ } else if(elem.createTextRange){
3524
+ var range = elem.createTextRange();
3525
+ range.collapse(true);
3526
+ range.moveEnd('character', 0);
3527
+ range.moveStart('character', 0);
3528
+ range.select();
3529
+ return true;
3530
+ }
3531
+ } catch(er){}
3532
+ };
3533
+
3534
+ var hidePlaceholder = function(elem, data, value, _onFocus){
3535
+ if(value === false){
3536
+ value = $.prop(elem, 'value');
3537
+ }
3538
+
3539
+ if(!isOver && elem.type != 'password'){
3540
+ if(!value && _onFocus && setSelection(elem)){
3541
+ var selectTimer = setTimeout(function(){
3542
+ setSelection(elem);
3543
+ }, 9);
3544
+ $(elem)
3545
+ .off('.placeholderremove')
3546
+ .on({
3547
+ 'keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove': function(e){
3548
+ if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
3549
+ elem.value = $.prop(elem, 'value');
3550
+ data.box.removeClass('placeholder-visible');
3551
+ clearTimeout(selectTimer);
3552
+ $(elem).unbind('.placeholderremove');
3553
+ },
3554
+ 'mousedown.placeholderremove drag.placeholderremove select.placeholderremove': function(e){
3555
+ setSelection(elem);
3556
+ clearTimeout(selectTimer);
3557
+ selectTimer = setTimeout(function(){
3558
+ setSelection(elem);
3559
+ }, 9);
3560
+ },
3561
+ 'blur.placeholderremove': function(){
3562
+ clearTimeout(selectTimer);
3563
+ $(elem).unbind('.placeholderremove');
3564
+ }
3565
+ })
3566
+ ;
3567
+ return;
3568
+ } else if(!_onFocus && !value && elem.value){ //especially on submit
3569
+ elem.value = value;
3570
+ }
3571
+ } else if(!value && _onFocus){
3572
+ $(elem)
3573
+ .off('.placeholderremove')
3574
+ .on({
3575
+ 'keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove': function(e){
3576
+ if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
3577
+ data.box.removeClass('placeholder-visible');
3578
+ $(elem).unbind('.placeholderremove');
3579
+ },
3580
+ 'blur.placeholderremove': function(){
3581
+ $(elem).unbind('.placeholderremove');
3582
+ }
3583
+ })
3584
+ ;
3585
+ return;
3586
+ }
3587
+ data.box.removeClass('placeholder-visible');
3588
+ },
3589
+ showPlaceholder = function(elem, data, placeholderTxt){
3590
+ if(placeholderTxt === false){
3591
+ placeholderTxt = $.prop(elem, 'placeholder');
3592
+ }
3593
+
3594
+ if(!isOver && elem.type != 'password'){
3595
+ elem.value = placeholderTxt;
3596
+ }
3597
+ data.box.addClass('placeholder-visible');
3598
+ },
3599
+ changePlaceholderVisibility = function(elem, value, placeholderTxt, data, type){
3600
+ if(!data){
3601
+ data = $.data(elem, 'placeHolder');
3602
+ if(!data){return;}
3603
+ }
3604
+ $(elem).unbind('.placeholderremove');
3605
+
3606
+ if(value === false){
3607
+ value = $.prop(elem, 'value');
3608
+ }
3609
+
3610
+ if(!value && (type == 'focus' || (!type && $(elem).is(':focus')))){
3611
+ if(elem.type == 'password' || isOver || $(elem).hasClass('placeholder-visible')){
3612
+ hidePlaceholder(elem, data, '', true);
3613
+ }
3614
+ return;
3615
+ }
3616
+
3617
+ if(value){
3618
+ hidePlaceholder(elem, data, value);
3619
+ return;
3620
+ }
3621
+ if(placeholderTxt === false){
3622
+ placeholderTxt = $.attr(elem, 'placeholder') || '';
3623
+ }
3624
+ if(placeholderTxt && !value){
3625
+ showPlaceholder(elem, data, placeholderTxt);
3626
+ } else {
3627
+ hidePlaceholder(elem, data, value);
3628
+ }
3629
+ },
3630
+ hasLabel = function(elem){
3631
+ elem = $(elem);
3632
+ return !!(elem.prop('title') || elem.attr('aria-labelledby') || elem.attr('aria-label') || elem.jProp('labels').length);
3633
+ },
3634
+ createPlaceholder = function(elem){
3635
+ elem = $(elem);
3636
+ return $( hasLabel(elem) ? '<span class="placeholder-text"></span>' : '<label for="'+ elem.prop('id') +'" class="placeholder-text"></label>');
3637
+ },
3638
+ pHolder = (function(){
3639
+ var delReg = /\n|\r|\f|\t/g,
3640
+ allowedPlaceholder = {
3641
+ text: 1,
3642
+ search: 1,
3643
+ url: 1,
3644
+ email: 1,
3645
+ password: 1,
3646
+ tel: 1,
3647
+ number: 1
3648
+ }
3649
+ ;
3650
+
3651
+ if(webshims.modules["form-number-date-ui"].loaded){
3652
+ delete allowedPlaceholder.number;
3653
+ }
3654
+
3655
+ return {
3656
+ create: function(elem){
3657
+ var data = $.data(elem, 'placeHolder');
3658
+ var form;
3659
+ var responsiveElem;
3660
+ if(data){return data;}
3661
+ data = $.data(elem, 'placeHolder', {});
3662
+
3663
+ $(elem).on('focus.placeholder blur.placeholder', function(e){
3664
+ changePlaceholderVisibility(this, false, false, data, e.type );
3665
+ data.box[e.type == 'focus' ? 'addClass' : 'removeClass']('placeholder-focused');
3666
+ });
3667
+
3668
+ if((form = $.prop(elem, 'form'))){
3669
+ $(form).on('reset.placeholder', function(e){
3670
+ setTimeout(function(){
3671
+ changePlaceholderVisibility(elem, false, false, data, e.type );
3672
+ }, 0);
3673
+ });
3674
+ }
3675
+
3676
+ if(elem.type == 'password' || isOver){
3677
+ data.text = createPlaceholder(elem);
3678
+ if(isResponsive || $(elem).is('.responsive-width') || (elem.currentStyle || {width: ''}).width.indexOf('%') != -1){
3679
+ responsiveElem = true;
3680
+ data.box = data.text;
3681
+ } else {
3682
+ data.box = $(elem)
3683
+ .wrap('<span class="placeholder-box placeholder-box-'+ (elem.nodeName || '').toLowerCase() +' placeholder-box-'+$.css(elem, 'float')+'" />')
3684
+ .parent()
3685
+ ;
3686
+ }
3687
+ data.text
3688
+ .insertAfter(elem)
3689
+ .on('mousedown.placeholder', function(){
3690
+ changePlaceholderVisibility(this, false, false, data, 'focus');
3691
+ try {
3692
+ setTimeout(function(){
3693
+ elem.focus();
3694
+ }, 0);
3695
+ } catch(e){}
3696
+ return false;
3697
+ })
3698
+ ;
3699
+
3700
+
3701
+ $.each(['lineHeight', 'fontSize', 'fontFamily', 'fontWeight'], function(i, style){
3702
+ var prop = $.css(elem, style);
3703
+ if(data.text.css(style) != prop){
3704
+ data.text.css(style, prop);
3705
+ }
3706
+ });
3707
+ $.each(['Left', 'Top'], function(i, side){
3708
+ var size = (parseInt($.css(elem, 'padding'+ side), 10) || 0) + Math.max((parseInt($.css(elem, 'margin'+ side), 10) || 0), 0) + (parseInt($.css(elem, 'border'+ side +'Width'), 10) || 0);
3709
+ data.text.css('padding'+ side, size);
3710
+ });
3711
+
3712
+ $(document)
3713
+ .onTrigger('updateshadowdom', function(){
3714
+ var height, width;
3715
+ if((width = elem.offsetWidth) || (height = elem.offsetHeight)){
3716
+ data.text
3717
+ .css({
3718
+ width: width,
3719
+ height: height
3720
+ })
3721
+ .css($(elem).position())
3722
+ ;
3723
+ }
3724
+ })
3725
+ ;
3726
+
3727
+ } else {
3728
+ var reset = function(e){
3729
+ if($(elem).hasClass('placeholder-visible')){
3730
+ hidePlaceholder(elem, data, '');
3731
+ if(e && e.type == 'submit'){
3732
+ setTimeout(function(){
3733
+ if(e.isDefaultPrevented()){
3734
+ changePlaceholderVisibility(elem, false, false, data );
3735
+ }
3736
+ }, 9);
3737
+ }
3738
+ }
3739
+ };
3740
+
3741
+ $(window).on('beforeunload', reset);
3742
+ data.box = $(elem);
3743
+ if(form){
3744
+ $(form).submit(reset);
3745
+ }
3746
+ }
3747
+
3748
+ return data;
3749
+ },
3750
+ update: function(elem, val){
3751
+ var type = ($.attr(elem, 'type') || $.prop(elem, 'type') || '').toLowerCase();
3752
+ if(!allowedPlaceholder[type] && !$.nodeName(elem, 'textarea')){
3753
+ webshims.warn('placeholder not allowed on input[type="'+type+'"], but it is a good fallback :-)');
3754
+ return;
3755
+ }
3756
+
3757
+
3758
+ var data = pHolder.create(elem);
3759
+ if(data.text){
3760
+ data.text.text(val);
3761
+ }
3762
+
3763
+ changePlaceholderVisibility(elem, false, val, data);
3764
+ }
3765
+ };
3766
+ })()
3767
+ ;
1175
3768
 
1176
- ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
1177
- $.expr[":"][name] = $.expr.filters[name+"-element"];
3769
+ $.webshims.publicMethods = {
3770
+ pHolder: pHolder
3771
+ };
3772
+ polyfillElements.forEach(function(nodeName){
3773
+ var desc = webshims.defineNodeNameProperty(nodeName, 'placeholder', {
3774
+ attr: {
3775
+ set: function(val){
3776
+ var elem = this;
3777
+ webshims.contentAttr(elem, 'placeholder', val);
3778
+ pHolder.update(elem, val);
3779
+ },
3780
+ get: function(){
3781
+ return webshims.contentAttr(this, 'placeholder');
3782
+ }
3783
+ },
3784
+ reflect: true,
3785
+ initAttr: true
3786
+ });
1178
3787
  });
1179
3788
 
1180
3789
 
1181
- $.expr[":"].focus = function( elem ) {
1182
- try {
1183
- var doc = elem.ownerDocument;
1184
- return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus());
1185
- } catch(e){}
1186
- return false;
1187
- };
3790
+ polyfillElements.forEach(function(name){
3791
+ var placeholderValueDesc = {};
3792
+ var desc;
3793
+ ['attr', 'prop'].forEach(function(propType){
3794
+ placeholderValueDesc[propType] = {
3795
+ set: function(val){
3796
+ var elem = this;
3797
+ var placeholder;
3798
+
3799
+ if(!placeholder){
3800
+ placeholder = webshims.contentAttr(elem, 'placeholder');
3801
+ }
3802
+ $.removeData(elem, 'cachedValidity');
3803
+ var ret = desc[propType]._supset.call(elem, val);
3804
+ if(placeholder && 'value' in elem){
3805
+ changePlaceholderVisibility(elem, val, placeholder);
3806
+ }
3807
+ return ret;
3808
+ },
3809
+ get: function(){
3810
+ var elem = this;
3811
+ return $(elem).hasClass('placeholder-visible') ? '' : desc[propType]._supget.call(elem);
3812
+ }
3813
+ };
3814
+ });
3815
+ desc = webshims.defineNodeNameProperty(name, 'value', placeholderValueDesc);
3816
+ });
1188
3817
 
1189
- if(Modernizr.formvalidation && isWebkit && !webshims.bugs.bustedValidity){
1190
- (function(){
1191
- var retriggerRadioValidity = function(){
1192
- var validity;
1193
- if((validity = this.validity) && !validity.customError){
1194
- this.setCustomValidity('');
3818
+ })();
3819
+
3820
+ (function(){
3821
+ var doc = document;
3822
+ if( 'value' in document.createElement('output') ){return;}
3823
+
3824
+ webshims.defineNodeNameProperty('output', 'value', {
3825
+ prop: {
3826
+ set: function(value){
3827
+ var setVal = $.data(this, 'outputShim');
3828
+ if(!setVal){
3829
+ setVal = outputCreate(this);
3830
+ }
3831
+ setVal(value);
3832
+ },
3833
+ get: function(){
3834
+ return webshims.contentAttr(this, 'value') || $(this).text() || '';
1195
3835
  }
3836
+ }
3837
+ });
3838
+
3839
+
3840
+ webshims.onNodeNamesPropertyModify('input', 'value', function(value, boolVal, type){
3841
+ if(type == 'removeAttr'){return;}
3842
+ var setVal = $.data(this, 'outputShim');
3843
+ if(setVal){
3844
+ setVal(value);
3845
+ }
3846
+ });
3847
+
3848
+ var outputCreate = function(elem){
3849
+ if(elem.getAttribute('aria-live')){return;}
3850
+ elem = $(elem);
3851
+ var value = (elem.text() || '').trim();
3852
+ var id = elem.prop('id');
3853
+ var htmlFor = elem.attr('for');
3854
+ var shim = $('<input class="output-shim" type="text" disabled name="'+ (elem.attr('name') || '')+'" value="'+value+'" style="display: none !important;" />').insertAfter(elem);
3855
+ var form = shim[0].form || doc;
3856
+ var setValue = function(val){
3857
+ shim[0].value = val;
3858
+ val = shim[0].value;
3859
+ elem.text(val);
3860
+ webshims.contentAttr(elem[0], 'value', val);
1196
3861
  };
1197
3862
 
1198
- webshims.addReady(function(context, insertedElement){
1199
- if(context !== document){
1200
- $('input[type="radio"]:invalid', context)
1201
- .add(insertedElement.filter('input[type="radio"]:invalid'))
1202
- .each(retriggerRadioValidity)
3863
+ elem[0].defaultValue = value;
3864
+ webshims.contentAttr(elem[0], 'value', value);
3865
+
3866
+ elem.attr({'aria-live': 'polite'});
3867
+ if(id){
3868
+ shim.attr('id', id);
3869
+ elem.attr('aria-labelledby', elem.jProp('labels').map(function(){
3870
+ return webshims.getID(this);
3871
+ }).get().join(' '));
3872
+ }
3873
+ if(htmlFor){
3874
+ id = webshims.getID(elem);
3875
+ htmlFor.split(' ').forEach(function(control){
3876
+ control = document.getElementById(control);
3877
+ if(control){
3878
+ control.setAttribute('aria-controls', id);
3879
+ }
3880
+ });
3881
+ }
3882
+ elem.data('outputShim', setValue );
3883
+ shim.data('outputShim', setValue );
3884
+ return setValue;
3885
+ };
3886
+
3887
+ webshims.addReady(function(context, contextElem){
3888
+ $('output', context).add(contextElem.filter('output')).each(function(){
3889
+ outputCreate(this);
3890
+ });
3891
+ });
3892
+
3893
+ /*
3894
+ * Implements input event in all browsers
3895
+ */
3896
+ (function(){
3897
+ var noInputTriggerEvts = {updateInput: 1, input: 1},
3898
+ noInputTypes = {
3899
+ radio: 1,
3900
+ checkbox: 1,
3901
+ submit: 1,
3902
+ button: 1,
3903
+ image: 1,
3904
+ reset: 1,
3905
+ file: 1
3906
+
3907
+ //pro forma
3908
+ ,color: 1
3909
+ //,range: 1
3910
+ },
3911
+ observe = function(input){
3912
+ var timer,
3913
+ lastVal = input.prop('value'),
3914
+ trigger = function(e){
3915
+ //input === null
3916
+ if(!input){return;}
3917
+ var newVal = input.prop('value');
3918
+ if(newVal !== lastVal){
3919
+ lastVal = newVal;
3920
+ if(!e || !noInputTriggerEvts[e.type]){
3921
+ webshims.triggerInlineForm && webshims.triggerInlineForm(input[0], 'input');
3922
+ }
3923
+ }
3924
+ },
3925
+ extraTimer,
3926
+ extraTest = function(){
3927
+ clearTimeout(extraTimer);
3928
+ extraTimer = setTimeout(trigger, 9);
3929
+ },
3930
+ unbind = function(){
3931
+ input.unbind('focusout', unbind).unbind('keyup keypress keydown paste cut', extraTest).unbind('input change updateInput', trigger);
3932
+ clearInterval(timer);
3933
+ setTimeout(function(){
3934
+ trigger();
3935
+ input = null;
3936
+ }, 1);
3937
+
3938
+ }
1203
3939
  ;
3940
+
3941
+ clearInterval(timer);
3942
+ timer = setInterval(trigger, 200);
3943
+ extraTest();
3944
+ input.on({
3945
+ 'keyup keypress keydown paste cut': extraTest,
3946
+ focusout: unbind,
3947
+ 'input updateInput change': trigger
3948
+ });
1204
3949
  }
1205
- });
3950
+ ;
3951
+ if($.event.customEvent){
3952
+ $.event.customEvent.updateInput = true;
3953
+ }
3954
+
3955
+ $(doc)
3956
+ .on('focusin', function(e){
3957
+ if( e.target && !e.target.readOnly && !e.target.disabled && (e.target.nodeName || '').toLowerCase() == 'input' && !noInputTypes[e.target.type] && !(webshims.data(e.target, 'implemented') || {}).inputwidgets){
3958
+ observe($(e.target));
3959
+ }
3960
+ })
3961
+ ;
1206
3962
  })();
3963
+ })();
3964
+
3965
+ }); //webshims.ready end
3966
+ }//end formvalidation
3967
+
3968
+ jQuery.webshims.register('form-message', function($, webshims, window, document, undefined, options){
3969
+ "use strict";
3970
+ var validityMessages = webshims.validityMessages;
3971
+
3972
+ var implementProperties = (options.overrideMessages || options.customMessages) ? ['customValidationMessage'] : [];
3973
+
3974
+ validityMessages.en = $.extend(true, {
3975
+ typeMismatch: {
3976
+ defaultMessage: 'Please enter a valid value.',
3977
+ email: 'Please enter an email address.',
3978
+ url: 'Please enter a URL.',
3979
+ number: 'Please enter a number.',
3980
+ date: 'Please enter a date.',
3981
+ time: 'Please enter a time.',
3982
+ range: 'Invalid input.',
3983
+ month: 'Please enter a valid value.',
3984
+ "datetime-local": 'Please enter a datetime.'
3985
+ },
3986
+ rangeUnderflow: {
3987
+ defaultMessage: 'Value must be greater than or equal to {%min}.'
3988
+ },
3989
+ rangeOverflow: {
3990
+ defaultMessage: 'Value must be less than or equal to {%max}.'
3991
+ },
3992
+ stepMismatch: 'Invalid input.',
3993
+ tooLong: 'Please enter at most {%maxlength} character(s). You entered {%valueLen}.',
3994
+ patternMismatch: 'Invalid input. {%title}',
3995
+ valueMissing: {
3996
+ defaultMessage: 'Please fill out this field.',
3997
+ checkbox: 'Please check this box if you want to proceed.'
3998
+ }
3999
+ }, (validityMessages.en || validityMessages['en-US'] || {}));
4000
+
4001
+ if(typeof validityMessages['en'].valueMissing == 'object'){
4002
+ ['select', 'radio'].forEach(function(type){
4003
+ validityMessages.en.valueMissing[type] = 'Please select an option.';
4004
+ });
4005
+ }
4006
+ if(typeof validityMessages.en.rangeUnderflow == 'object'){
4007
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
4008
+ validityMessages.en.rangeUnderflow[type] = 'Value must be at or after {%min}.';
4009
+ });
4010
+ }
4011
+ if(typeof validityMessages.en.rangeOverflow == 'object'){
4012
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
4013
+ validityMessages.en.rangeOverflow[type] = 'Value must be at or before {%max}.';
4014
+ });
4015
+ }
4016
+
4017
+ validityMessages['en-US'] = validityMessages['en-US'] || validityMessages.en;
4018
+ validityMessages[''] = validityMessages[''] || validityMessages['en-US'];
4019
+
4020
+ validityMessages.de = $.extend(true, {
4021
+ typeMismatch: {
4022
+ defaultMessage: '{%value} ist in diesem Feld nicht zulässig.',
4023
+ email: '{%value} ist keine gültige E-Mail-Adresse.',
4024
+ url: '{%value} ist kein(e) gültige(r) Webadresse/Pfad.',
4025
+ number: '{%value} ist keine Nummer.',
4026
+ date: '{%value} ist kein Datum.',
4027
+ time: '{%value} ist keine Uhrzeit.',
4028
+ month: '{%value} ist in diesem Feld nicht zulässig.',
4029
+ range: '{%value} ist keine Nummer.',
4030
+ "datetime-local": '{%value} ist kein Datum-Uhrzeit Format.'
4031
+ },
4032
+ rangeUnderflow: {
4033
+ defaultMessage: '{%value} ist zu niedrig. {%min} ist der unterste Wert, den Sie benutzen können.'
4034
+ },
4035
+ rangeOverflow: {
4036
+ defaultMessage: '{%value} ist zu hoch. {%max} ist der oberste Wert, den Sie benutzen können.'
4037
+ },
4038
+ stepMismatch: 'Der Wert {%value} ist in diesem Feld nicht zulässig. Hier sind nur bestimmte Werte zulässig. {%title}',
4039
+ tooLong: 'Der eingegebene Text ist zu lang! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%maxlength} das Maximum.',
4040
+ patternMismatch: '{%value} hat für dieses Eingabefeld ein falsches Format. {%title}',
4041
+ valueMissing: {
4042
+ defaultMessage: 'Bitte geben Sie einen Wert ein.',
4043
+ checkbox: 'Bitte aktivieren Sie das Kästchen.'
4044
+ }
4045
+ }, (validityMessages.de || {}));
4046
+
4047
+ if(typeof validityMessages.de.valueMissing == 'object'){
4048
+ ['select', 'radio'].forEach(function(type){
4049
+ validityMessages.de.valueMissing[type] = 'Bitte wählen Sie eine Option aus.';
4050
+ });
4051
+ }
4052
+ if(typeof validityMessages.de.rangeUnderflow == 'object'){
4053
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
4054
+ validityMessages.de.rangeUnderflow[type] = '{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.';
4055
+ });
4056
+ }
4057
+ if(typeof validityMessages.de.rangeOverflow == 'object'){
4058
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
4059
+ validityMessages.de.rangeOverflow[type] = '{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.';
4060
+ });
1207
4061
  }
1208
4062
 
1209
- var customEvents = $.event.customEvent || {};
1210
- var isValid = function(elem){
1211
- return ($.prop(elem, 'validity') || {valid: 1}).valid;
4063
+ var currentValidationMessage = validityMessages[''];
4064
+ var getMessageFromObj = function(message, elem){
4065
+ if(message && typeof message !== 'string'){
4066
+ message = message[ $.prop(elem, 'type') ] || message[ (elem.nodeName || '').toLowerCase() ] || message[ 'defaultMessage' ];
4067
+ }
4068
+ return message || '';
4069
+ };
4070
+ var valueVals = {
4071
+ value: 1,
4072
+ min: 1,
4073
+ max: 1
1212
4074
  };
1213
4075
 
1214
- if (bugs.bustedValidity || bugs.findRequired) {
1215
- (function(){
1216
- var find = $.find;
1217
- var matchesSelector = $.find.matchesSelector;
1218
-
1219
- var regExp = /(\:valid|\:invalid|\:optional|\:required|\:in-range|\:out-of-range)(?=[\s\[\~\.\+\>\:\#*]|$)/ig;
1220
- var regFn = function(sel){
1221
- return sel + '-element';
1222
- };
1223
-
1224
- $.find = (function(){
1225
- var slice = Array.prototype.slice;
1226
- var fn = function(sel){
1227
- var ar = arguments;
1228
- ar = slice.call(ar, 1, ar.length);
1229
- ar.unshift(sel.replace(regExp, regFn));
1230
- return find.apply(this, ar);
1231
- };
1232
- for (var i in find) {
1233
- if(find.hasOwnProperty(i)){
1234
- fn[i] = find[i];
4076
+ webshims.createValidationMessage = function(elem, name){
4077
+ var spinner;
4078
+ var message = getMessageFromObj(currentValidationMessage[name], elem);
4079
+
4080
+ if(!message){
4081
+ message = getMessageFromObj(validityMessages[''][name], elem) || 'invalid value';
4082
+ webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+$.webshims.activeLang());
4083
+ }
4084
+ if(message){
4085
+ ['value', 'min', 'max', 'title', 'maxlength', 'label'].forEach(function(attr){
4086
+ if(message.indexOf('{%'+attr) === -1){return;}
4087
+ var val = ((attr == 'label') ? $.trim($('label[for="'+ elem.id +'"]', elem.form).text()).replace(/\*$|:$/, '') : $.prop(elem, attr)) || '';
4088
+ if(name == 'patternMismatch' && attr == 'title' && !val){
4089
+ webshims.error('no title for patternMismatch provided. Always add a title attribute.');
4090
+ }
4091
+ if(valueVals[attr]){
4092
+ if(!spinner){
4093
+ spinner = $(elem).getShadowElement().data('wsspinner');
4094
+ }
4095
+ if(spinner && spinner.formatValue){
4096
+ val = spinner.formatValue(val, false);
1235
4097
  }
1236
4098
  }
1237
- return fn;
1238
- })();
1239
- if(!Modernizr.prefixed || Modernizr.prefixed("matchesSelector", document.documentElement)){
1240
- $.find.matchesSelector = function(node, expr){
1241
- expr = expr.replace(regExp, regFn);
1242
- return matchesSelector.call(this, node, expr);
1243
- };
1244
- }
1245
-
1246
- })();
1247
- }
1248
-
1249
- //ToDo needs testing
1250
- var oldAttr = $.prop;
1251
- var changeVals = {selectedIndex: 1, value: 1, checked: 1, disabled: 1, readonly: 1};
1252
- $.prop = function(elem, name, val){
1253
- var ret = oldAttr.apply(this, arguments);
1254
- if(elem && 'form' in elem && changeVals[name] && val !== undefined && $(elem).hasClass(invalidClass)){
1255
- if(isValid(elem)){
1256
- $(elem).getShadowElement().removeClass(invalidClasses);
1257
- if(name == 'checked' && val) {
1258
- getGroupElements(elem).not(elem).removeClass(invalidClasses).removeAttr('aria-invalid');
4099
+ message = message.replace('{%'+ attr +'}', val);
4100
+ if('value' == attr){
4101
+ message = message.replace('{%valueLen}', val.length);
1259
4102
  }
1260
- }
4103
+
4104
+ });
1261
4105
  }
1262
- return ret;
4106
+
4107
+ return message || '';
1263
4108
  };
1264
4109
 
1265
- var returnValidityCause = function(validity, elem){
1266
- var ret;
1267
- $.each(validity, function(name, value){
1268
- if(value){
1269
- ret = (name == 'customError') ? $.prop(elem, 'validationMessage') : name;
1270
- return false;
4110
+
4111
+ if(webshims.bugs.validationMessage || !Modernizr.formvalidation || webshims.bugs.bustedValidity){
4112
+ implementProperties.push('validationMessage');
4113
+ }
4114
+
4115
+ webshims.activeLang({
4116
+ langObj: validityMessages,
4117
+ module: 'form-core',
4118
+ callback: function(langObj){
4119
+
4120
+ currentValidationMessage = langObj;
4121
+ }
4122
+ });
4123
+
4124
+ implementProperties.forEach(function(messageProp){
4125
+ webshims.defineNodeNamesProperty(['fieldset', 'output', 'button'], messageProp, {
4126
+ prop: {
4127
+ value: '',
4128
+ writeable: false
1271
4129
  }
1272
4130
  });
1273
- return ret;
1274
- };
1275
-
1276
- var isInGroup = function(name){
1277
- var ret;
1278
- try {
1279
- ret = document.activeElement.name === name;
1280
- } catch(e){}
1281
- return ret;
1282
- };
1283
- /* form-ui-invalid/form-ui-valid are deprecated. use user-error/user-success instead */
1284
- var invalidClass = 'user-error';
1285
- var invalidClasses = 'user-error form-ui-invalid';
1286
- var validClass = 'user-success';
1287
- var validClasses = 'user-success form-ui-valid';
1288
- var switchValidityClass = function(e){
1289
- var elem, timer;
1290
- if(!e.target){return;}
1291
- elem = $(e.target).getNativeElement()[0];
1292
- if(elem.type == 'submit' || !$.prop(elem, 'willValidate')){return;}
1293
- timer = $.data(elem, 'webshimsswitchvalidityclass');
1294
- var switchClass = function(){
1295
- if(e.type == 'focusout' && elem.type == 'radio' && isInGroup(elem.name)){return;}
1296
- var validity = $.prop(elem, 'validity');
1297
- var shadowElem = $(elem).getShadowElement();
1298
- var addClass, removeClass, trigger, generaltrigger, validityCause;
1299
-
1300
- $(elem).trigger('refreshCustomValidityRules');
1301
- if(validity.valid){
1302
- if(!shadowElem.hasClass(validClass)){
1303
- addClass = validClasses;
1304
- removeClass = invalidClasses;
1305
- generaltrigger = 'changedvaliditystate';
1306
- trigger = 'changedvalid';
1307
- if(checkTypes[elem.type] && elem.checked){
1308
- getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass).removeAttr('aria-invalid');
1309
- }
1310
- $.removeData(elem, 'webshimsinvalidcause');
1311
- }
1312
- } else {
1313
- validityCause = returnValidityCause(validity, elem);
1314
- if($.data(elem, 'webshimsinvalidcause') != validityCause){
1315
- $.data(elem, 'webshimsinvalidcause', validityCause);
1316
- generaltrigger = 'changedvaliditystate';
4131
+ ['input', 'select', 'textarea'].forEach(function(nodeName){
4132
+ var desc = webshims.defineNodeNameProperty(nodeName, messageProp, {
4133
+ prop: {
4134
+ get: function(){
4135
+ var elem = this;
4136
+ var message = '';
4137
+ if(!$.prop(elem, 'willValidate')){
4138
+ return message;
4139
+ }
4140
+
4141
+ var validity = $.prop(elem, 'validity') || {valid: 1};
4142
+
4143
+ if(validity.valid){return message;}
4144
+ message = webshims.getContentValidationMessage(elem, validity);
4145
+
4146
+ if(message){return message;}
4147
+
4148
+ if(validity.customError && elem.nodeName){
4149
+ message = (Modernizr.formvalidation && !webshims.bugs.bustedValidity && desc.prop._supget) ? desc.prop._supget.call(elem) : webshims.data(elem, 'customvalidationMessage');
4150
+ if(message){return message;}
4151
+ }
4152
+ $.each(validity, function(name, prop){
4153
+ if(name == 'valid' || !prop){return;}
4154
+
4155
+ message = webshims.createValidationMessage(elem, name);
4156
+ if(message){
4157
+ return false;
4158
+ }
4159
+ });
4160
+ return message || '';
4161
+ },
4162
+ writeable: false
1317
4163
  }
1318
- if(!shadowElem.hasClass(invalidClass)){
1319
- addClass = invalidClasses;
1320
- removeClass = validClasses;
1321
- if (checkTypes[elem.type] && !elem.checked) {
1322
- getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass);
4164
+ });
4165
+ });
4166
+
4167
+ });
4168
+ });
4169
+ jQuery.webshims.register('form-datalist', function($, webshims, window, document, undefined, options){
4170
+ "use strict";
4171
+ var doc = document;
4172
+
4173
+ /*
4174
+ * implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
4175
+ */
4176
+ webshims.propTypes.element = function(descs){
4177
+ webshims.createPropDefault(descs, 'attr');
4178
+ if(descs.prop){return;}
4179
+ descs.prop = {
4180
+ get: function(){
4181
+ var elem = $.attr(this, 'list');
4182
+ if(elem){
4183
+ elem = document.getElementById(elem);
4184
+ if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
4185
+ elem = null;
1323
4186
  }
1324
- trigger = 'changedinvalid';
1325
4187
  }
4188
+ return elem || null;
4189
+ },
4190
+ writeable: false
4191
+ };
4192
+ };
4193
+
4194
+
4195
+ /*
4196
+ * Implements datalist element and list attribute
4197
+ */
4198
+
4199
+ (function(){
4200
+ var formsCFG = $.webshims.cfg.forms;
4201
+ var listSupport = Modernizr.input.list;
4202
+ if(listSupport && !formsCFG.customDatalist){return;}
4203
+
4204
+ var initializeDatalist = function(){
4205
+
4206
+
4207
+ if(!listSupport){
4208
+ webshims.defineNodeNameProperty('datalist', 'options', {
4209
+ prop: {
4210
+ writeable: false,
4211
+ get: function(){
4212
+ var elem = this;
4213
+ var select = $('select', elem);
4214
+ var options;
4215
+ if(select[0]){
4216
+ options = select[0].options;
4217
+ } else {
4218
+ options = $('option', elem).get();
4219
+ if(options.length){
4220
+ webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
4221
+ }
4222
+ }
4223
+ return options;
4224
+ }
4225
+ }
4226
+ });
1326
4227
  }
1327
- if(addClass){
1328
- shadowElem.addClass(addClass).removeClass(removeClass);
1329
- //jQuery 1.6.1 IE9 bug (doubble trigger bug)
1330
- setTimeout(function(){
1331
- $(elem).trigger(trigger);
1332
- }, 0);
4228
+
4229
+ var inputListProto = {
4230
+ //override autocomplete
4231
+ autocomplete: {
4232
+ attr: {
4233
+ get: function(){
4234
+ var elem = this;
4235
+ var data = $.data(elem, 'datalistWidget');
4236
+ if(data){
4237
+ return data._autocomplete;
4238
+ }
4239
+ return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
4240
+ },
4241
+ set: function(value){
4242
+ var elem = this;
4243
+ var data = $.data(elem, 'datalistWidget');
4244
+ if(data){
4245
+ data._autocomplete = value;
4246
+ if(value == 'off'){
4247
+ data.hideList();
4248
+ }
4249
+ } else {
4250
+ if('autocomplete' in elem){
4251
+ elem.autocomplete = value;
4252
+ } else {
4253
+ elem.setAttribute('autocomplete', value);
4254
+ }
4255
+ }
4256
+ }
4257
+ }
4258
+ }
4259
+ };
4260
+
4261
+ if(formsCFG.customDatalist && (!listSupport || !('selectedOption' in $('<input />')[0]))){
4262
+ //currently not supported x-browser (FF4 has not implemented and is not polyfilled )
4263
+ inputListProto.selectedOption = {
4264
+ prop: {
4265
+ writeable: false,
4266
+ get: function(){
4267
+ var elem = this;
4268
+ var list = $.prop(elem, 'list');
4269
+ var ret = null;
4270
+ var value, options;
4271
+ if(!list){return ret;}
4272
+ value = $.prop(elem, 'value');
4273
+ if(!value){return ret;}
4274
+ options = $.prop(list, 'options');
4275
+ if(!options.length){return ret;}
4276
+ $.each(options, function(i, option){
4277
+ if(value == $.prop(option, 'value')){
4278
+ ret = option;
4279
+ return false;
4280
+ }
4281
+ });
4282
+ return ret;
4283
+ }
4284
+ }
4285
+ };
1333
4286
  }
1334
- if(generaltrigger){
1335
- setTimeout(function(){
1336
- $(elem).trigger(generaltrigger);
1337
- }, 0);
4287
+
4288
+ if(!listSupport){
4289
+
4290
+ inputListProto['list'] = {
4291
+ attr: {
4292
+ get: function(){
4293
+ var val = webshims.contentAttr(this, 'list');
4294
+ return (val == null) ? undefined : val;
4295
+ },
4296
+ set: function(value){
4297
+ var elem = this;
4298
+ webshims.contentAttr(elem, 'list', value);
4299
+ webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
4300
+ $(elem).triggerHandler('listdatalistchange');
4301
+ }
4302
+ },
4303
+ initAttr: true,
4304
+ reflect: true,
4305
+ propType: 'element',
4306
+ propNodeName: 'datalist'
4307
+ };
4308
+ } else {
4309
+ //options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
4310
+ if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
4311
+ webshims.defineNodeNameProperty('datalist', 'options', {
4312
+ prop: {
4313
+ writeable: false,
4314
+ get: function(){
4315
+ var options = this.options || [];
4316
+ if(!options.length){
4317
+ var elem = this;
4318
+ var select = $('select', elem);
4319
+ if(select[0] && select[0].options && select[0].options.length){
4320
+ options = select[0].options;
4321
+ }
4322
+ }
4323
+ return options;
4324
+ }
4325
+ }
4326
+ });
4327
+ }
4328
+ inputListProto['list'] = {
4329
+ attr: {
4330
+ get: function(){
4331
+ var val = webshims.contentAttr(this, 'list');
4332
+ if(val != null){
4333
+ $.data(this, 'datalistListAttr', val);
4334
+ this.removeAttribute('list');
4335
+ } else {
4336
+ val = $.data(this, 'datalistListAttr');
4337
+ }
4338
+
4339
+ return (val == null) ? undefined : val;
4340
+ },
4341
+ set: function(value){
4342
+ var elem = this;
4343
+ $.data(elem, 'datalistListAttr', value);
4344
+ webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
4345
+ $(elem).triggerHandler('listdatalistchange');
4346
+ }
4347
+ },
4348
+ initAttr: true,
4349
+ reflect: true,
4350
+ propType: 'element',
4351
+ propNodeName: 'datalist'
4352
+ };
1338
4353
  }
1339
- $.removeData(e.target, 'webshimsswitchvalidityclass');
4354
+
4355
+ webshims.defineNodeNameProperties('input', inputListProto);
4356
+
4357
+ webshims.addReady(function(context, contextElem){
4358
+ contextElem
4359
+ .filter('datalist > select, datalist, datalist > option, datalist > select > option')
4360
+ .closest('datalist')
4361
+ .each(function(){
4362
+ $(this).triggerHandler('updateDatalist');
4363
+ })
4364
+
4365
+ ;
4366
+
4367
+ });
4368
+
4369
+
1340
4370
  };
1341
4371
 
1342
- if(timer){
1343
- clearTimeout(timer);
1344
- }
1345
- if(e.type == 'refreshvalidityui'){
1346
- switchClass();
1347
- } else {
1348
- $.data(elem, 'webshimsswitchvalidityclass', setTimeout(switchClass, 9));
1349
- }
1350
- };
1351
-
1352
- $(document).on(options.validityUIEvents || 'focusout change refreshvalidityui', switchValidityClass);
1353
- customEvents.changedvaliditystate = true;
1354
- customEvents.refreshCustomValidityRules = true;
1355
- customEvents.changedvalid = true;
1356
- customEvents.changedinvalid = true;
1357
- customEvents.refreshvalidityui = true;
1358
-
1359
-
1360
- webshims.triggerInlineForm = function(elem, event){
1361
- $(elem).trigger(event);
1362
- };
1363
-
1364
- webshims.modules["form-core"].getGroupElements = getGroupElements;
1365
-
1366
-
1367
- var setRoot = function(){
1368
- webshims.scrollRoot = (isWebkit || document.compatMode == 'BackCompat') ?
1369
- $(document.body) :
1370
- $(document.documentElement)
1371
- ;
1372
- };
1373
- setRoot();
1374
- webshims.ready('DOM', setRoot);
1375
-
1376
- webshims.getRelOffset = function(posElem, relElem){
1377
- posElem = $(posElem);
1378
- var offset = $(relElem).offset();
1379
- var bodyOffset;
1380
- $.swap($(posElem)[0], {visibility: 'hidden', display: 'inline-block', left: 0, top: 0}, function(){
1381
- bodyOffset = posElem.offset();
1382
- });
1383
- offset.top -= bodyOffset.top;
1384
- offset.left -= bodyOffset.left;
1385
- return offset;
1386
- };
1387
-
1388
- /* some extra validation UI */
1389
- webshims.validityAlert = (function(){
1390
- var alertElem = 'span';
1391
- var errorBubble;
1392
- var hideTimer = false;
1393
- var focusTimer = false;
1394
- var resizeTimer = false;
1395
- var boundHide;
1396
4372
 
1397
- var api = {
1398
- hideDelay: 5000,
4373
+ /*
4374
+ * ShadowList
4375
+ */
4376
+ var listidIndex = 0;
4377
+ var noDatalistSupport = {
4378
+ submit: 1,
4379
+ button: 1,
4380
+ reset: 1,
4381
+ hidden: 1,
1399
4382
 
1400
- showFor: function(elem, message, noFocusElem, noBubble){
1401
- api._create();
1402
- elem = $(elem);
1403
- var visual = $(elem).getShadowElement();
1404
- var offset = api.getOffsetFromBody(visual);
1405
- api.clear();
1406
- if(noBubble){
1407
- this.hide();
1408
- } else {
4383
+ range: 1,
4384
+ date: 1,
4385
+ month: 1
4386
+ };
4387
+ if(webshims.modules["form-number-date-ui"].loaded){
4388
+ $.extend(noDatalistSupport, {
4389
+ number: 1,
4390
+ time: 1
4391
+ });
4392
+ }
4393
+
4394
+ var globStoredOptions = {};
4395
+ var getStoredOptions = function(name){
4396
+ if(!name){return [];}
4397
+ if(globStoredOptions[name]){
4398
+ return globStoredOptions[name];
4399
+ }
4400
+ var data;
4401
+ try {
4402
+ data = JSON.parse(localStorage.getItem('storedDatalistOptions'+name));
4403
+ } catch(e){}
4404
+ globStoredOptions[name] = data || [];
4405
+ return data || [];
4406
+ };
4407
+ var storeOptions = function(name, val){
4408
+ if(!name){return;}
4409
+ val = val || [];
4410
+ try {
4411
+ localStorage.setItem( 'storedDatalistOptions'+name, JSON.stringify(val) );
4412
+ } catch(e){}
4413
+ };
4414
+
4415
+ var getText = function(elem){
4416
+ return (elem.textContent || elem.innerText || $.text([ elem ]) || '');
4417
+ };
4418
+ var lReg = /</g;
4419
+ var gReg = />/g;
4420
+
4421
+ var shadowListProto = {
4422
+ _create: function(opts){
4423
+
4424
+ if(noDatalistSupport[$.prop(opts.input, 'type')] || noDatalistSupport[$.attr(opts.input, 'type')]){return;}
4425
+ var datalist = opts.datalist;
4426
+ var data = $.data(opts.input, 'datalistWidget');
4427
+ if(datalist && data && data.datalist !== datalist){
4428
+ data.datalist = datalist;
4429
+ data.id = opts.id;
1409
4430
 
1410
- this.getMessage(elem, message);
1411
- this.position(visual, offset);
1412
4431
 
1413
- this.show();
1414
- if(this.hideDelay){
1415
- hideTimer = setTimeout(boundHide, this.hideDelay);
1416
- }
1417
- $(window)
1418
- .on('resize.validityalert reposoverlay.validityalert', function(){
1419
- clearTimeout(resizeTimer);
1420
- resizeTimer = setTimeout(function(){
1421
- api.position(visual);
1422
- }, 9);
1423
- })
4432
+ $(data.datalist)
4433
+ .off('updateDatalist.datalistWidget')
4434
+ .on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
1424
4435
  ;
4436
+
4437
+ data._resetListCached();
4438
+ return;
4439
+ } else if(!datalist){
4440
+ if(data){
4441
+ data.destroy();
4442
+ }
4443
+ return;
4444
+ } else if(data && data.datalist === datalist){
4445
+ return;
1425
4446
  }
4447
+ listidIndex++;
4448
+ var that = this;
4449
+ this.hideList = $.proxy(that, 'hideList');
4450
+
4451
+ this.datalist = datalist;
4452
+ this.id = opts.id;
4453
+ this.hasViewableData = true;
4454
+ this._autocomplete = $.attr(opts.input, 'autocomplete');
4455
+ $.data(opts.input, 'datalistWidget', this);
4456
+
4457
+ this.popover = webshims.objectCreate(webshims.wsPopover, {}, options.datalistPopover);
4458
+ this.shadowList = this.popover.element.addClass('datalist-polyfill');
4459
+
4460
+
4461
+ this.index = -1;
4462
+ this.input = opts.input;
4463
+ this.arrayOptions = [];
4464
+
4465
+ this.shadowList
4466
+ .delegate('li', 'mouseenter.datalistWidget mousedown.datalistWidget click.datalistWidget', function(e){
4467
+ var items = $('li:not(.hidden-item)', that.shadowList);
4468
+ var select = (e.type == 'mousedown' || e.type == 'click');
4469
+ that.markItem(items.index(e.currentTarget), select, items);
4470
+ if(e.type == 'click'){
4471
+ that.hideList();
4472
+ if(formsCFG.customDatalist){
4473
+ $(opts.input).getNativeElement().trigger('datalistselect');
4474
+ }
4475
+ }
4476
+ return (e.type != 'mousedown');
4477
+ })
4478
+ ;
4479
+
4480
+ opts.input.setAttribute('autocomplete', 'off');
4481
+
4482
+ $(opts.input)
4483
+ .attr({
4484
+ //role: 'combobox',
4485
+ 'aria-haspopup': 'true'
4486
+ })
4487
+ .on({
4488
+ 'input.datalistWidget': function(){
4489
+ if(!that.triggeredByDatalist){
4490
+ that.changedValue = false;
4491
+ that.showHideOptions();
4492
+ }
4493
+ },
4494
+ 'keydown.datalistWidget': function(e){
4495
+ var keyCode = e.keyCode;
4496
+ var activeItem;
4497
+ var items;
4498
+ if(keyCode == 40 && !that.showList()){
4499
+ that.markItem(that.index + 1, true);
4500
+ return false;
4501
+ }
4502
+
4503
+ if(!that.popover.isVisible){return;}
4504
+
4505
+
4506
+ if(keyCode == 38){
4507
+ that.markItem(that.index - 1, true);
4508
+ return false;
4509
+ }
4510
+ if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
4511
+ that.markItem(0, true);
4512
+ return false;
4513
+ }
4514
+ if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
4515
+ items = $('li:not(.hidden-item)', that.shadowList);
4516
+ that.markItem(items.length - 1, true, items);
4517
+ return false;
4518
+ }
4519
+ if(keyCode == 13 || keyCode == 27){
4520
+ if (keyCode == 13){
4521
+ activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
4522
+ that.changeValue( $('li.active-item:not(.hidden-item)', that.shadowList) );
4523
+ }
4524
+ that.hideList();
4525
+ if(formsCFG.customDatalist && activeItem && activeItem[0]){
4526
+ $(opts.input).getNativeElement().trigger('datalistselect');
4527
+ }
4528
+ return false;
4529
+ }
4530
+ },
4531
+ 'focus.datalistWidget': function(){
4532
+ if($(this).hasClass('list-focus')){
4533
+ that.showList();
4534
+ }
4535
+ },
4536
+ 'mousedown.datalistWidget': function(){
4537
+ if($(this).is(':focus')){
4538
+ that.showList();
4539
+ }
4540
+ }
4541
+ })
4542
+ ;
4543
+
4544
+
4545
+ $(this.datalist)
4546
+ .off('updateDatalist.datalistWidget')
4547
+ .on('updateDatalist.datalistWidget', $.proxy(this, '_resetListCached'))
4548
+ ;
1426
4549
 
1427
- if(!noFocusElem){
1428
- this.setFocus(visual, offset);
4550
+ this._resetListCached();
4551
+
4552
+ if(opts.input.form && (opts.input.name || opts.input.id)){
4553
+ $(opts.input.form).on('submit.datalistWidget'+opts.input.id, function(){
4554
+ if(!$(opts.input).hasClass('no-datalist-cache') && that._autocomplete != 'off'){
4555
+ var val = $.prop(opts.input, 'value');
4556
+ var name = (opts.input.name || opts.input.id) + $.prop(opts.input, 'type');
4557
+ if(!that.storedOptions){
4558
+ that.storedOptions = getStoredOptions( name );
4559
+ }
4560
+ if(val && that.storedOptions.indexOf(val) == -1){
4561
+ that.storedOptions.push(val);
4562
+ storeOptions(name, that.storedOptions );
4563
+ }
4564
+ }
4565
+ });
4566
+ }
4567
+ $(window).on('unload.datalist'+this.id+' beforeunload.datalist'+this.id, function(){
4568
+ that.destroy();
4569
+ });
4570
+ },
4571
+ destroy: function(){
4572
+ var autocomplete = $.attr(this.input, 'autocomplete');
4573
+ $(this.input)
4574
+ .off('.datalistWidget')
4575
+ .removeData('datalistWidget')
4576
+ ;
4577
+ this.shadowList.remove();
4578
+ $(document).off('.datalist'+this.id);
4579
+ $(window).off('.datalist'+this.id);
4580
+ if(this.input.form && this.input.id){
4581
+ $(this.input.form).off('submit.datalistWidget'+this.input.id);
4582
+ }
4583
+ this.input.removeAttribute('aria-haspopup');
4584
+ if(autocomplete === undefined){
4585
+ this.input.removeAttribute('autocomplete');
4586
+ } else {
4587
+ $(this.input).attr('autocomplete', autocomplete);
1429
4588
  }
1430
4589
  },
1431
- getOffsetFromBody: function(elem){
1432
- return webshims.getRelOffset(errorBubble, elem);
4590
+ _resetListCached: function(e){
4591
+ var that = this;
4592
+ var forceShow;
4593
+ this.needsUpdate = true;
4594
+ this.lastUpdatedValue = false;
4595
+ this.lastUnfoundValue = '';
4596
+
4597
+ if(!this.updateTimer){
4598
+ if(window.QUnit || (forceShow = ($(that.input).is(':focus') && ($(that.input).hasClass('list-focus') || $.prop(that.input, 'value'))) )){
4599
+ that.updateListOptions(forceShow);
4600
+ } else {
4601
+ webshims.ready('WINDOWLOAD', function(){
4602
+ that.updateTimer = setTimeout(function(){
4603
+ that.updateListOptions();
4604
+ that = null;
4605
+ listidIndex = 1;
4606
+ }, 200 + (100 * listidIndex));
4607
+ });
4608
+ }
4609
+ }
1433
4610
  },
1434
- setFocus: function(visual, offset){
1435
- var focusElem = $(visual).getShadowFocusElement();
1436
- var scrollTop = webshims.scrollRoot.scrollTop();
1437
- var elemTop = ((offset || focusElem.offset()).top) - 30;
1438
- var smooth;
4611
+ updateListOptions: function(_forceShow){
4612
+ this.needsUpdate = false;
4613
+ clearTimeout(this.updateTimer);
4614
+ this.updateTimer = false;
1439
4615
 
1440
- if(webshims.getID && alertElem == 'label'){
1441
- errorBubble.attr('for', webshims.getID(focusElem));
1442
- }
4616
+ this.searchStart = formsCFG.customDatalist && $(this.input).hasClass('search-start');
4617
+ this.addMarkElement = options.addMark || $(this.input).hasClass('mark-option-text');
1443
4618
 
1444
- if(scrollTop > elemTop){
1445
- webshims.scrollRoot.animate(
1446
- {scrollTop: elemTop - 5},
1447
- {
1448
- queue: false,
1449
- duration: Math.max( Math.min( 600, (scrollTop - elemTop) * 1.5 ), 80 )
4619
+ var list = [];
4620
+
4621
+ var values = [];
4622
+ var allOptions = [];
4623
+ var rElem, rItem, rOptions, rI, rLen, item, value;
4624
+ for(rOptions = $.prop(this.datalist, 'options'), rI = 0, rLen = rOptions.length; rI < rLen; rI++){
4625
+ rElem = rOptions[rI];
4626
+ if(!rElem.disabled && (value = $(rElem).val())){
4627
+ rItem = {
4628
+ value: value.replace(lReg, '&lt;').replace(gReg, '&gt;'),
4629
+ label: $.trim($.attr(rElem, 'label') || getText(rElem)).replace(lReg, '&lt;').replace(gReg, '&gt;'),
4630
+ className: rElem.className || ''
4631
+ };
4632
+
4633
+ if(rItem.label){
4634
+ rItem.className += ' has-option-label';
1450
4635
  }
1451
- );
1452
- smooth = true;
4636
+ values.push(rItem.value);
4637
+ allOptions.push(rItem);
4638
+ }
1453
4639
  }
1454
- try {
1455
- focusElem[0].focus();
1456
- } catch(e){}
1457
- if(smooth){
1458
- webshims.scrollRoot.scrollTop(scrollTop);
1459
- setTimeout(function(){
1460
- webshims.scrollRoot.scrollTop(scrollTop);
1461
- }, 0);
4640
+
4641
+ if(!this.storedOptions){
4642
+ this.storedOptions = ($(this.input).hasClass('no-datalist-cache') || this._autocomplete == 'off') ? [] : getStoredOptions((this.input.name || this.input.id) + $.prop(this.input, 'type'));
4643
+ }
4644
+
4645
+ this.storedOptions.forEach(function(val, i){
4646
+ if(values.indexOf(val) == -1){
4647
+ allOptions.push({value: val, label: '', className: 'stored-suggest', style: ''});
4648
+ }
4649
+ });
4650
+
4651
+ for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
4652
+ item = allOptions[rI];
4653
+ list[rI] = '<li class="'+ item.className +'" tabindex="-1" role="listitem">'+ this.getOptionContent(item) +'</li>';
4654
+ }
4655
+
4656
+ this.arrayOptions = allOptions;
4657
+ this.popover.contentElement.html('<div class="datalist-box"><ul role="list">'+ list.join("\n") +'</ul></div>');
4658
+
4659
+
4660
+ if(_forceShow || this.popover.isVisible){
4661
+ this.showHideOptions();
1462
4662
  }
1463
- setTimeout(function(){
1464
- $(document).on('focusout.validityalert', boundHide);
1465
- }, 10);
1466
- $(window).triggerHandler('reposoverlay');
1467
4663
  },
1468
- getMessage: function(elem, message){
1469
- if (!message) {
1470
- message = getContentValidationMessage(elem[0]) || elem.prop('customValidationMessage') || elem.prop('validationMessage');
4664
+ getOptionContent: function(item){
4665
+ var content = '';
4666
+ if(options.getOptionContent){
4667
+ content = options.apply(this, arguments) || '';
4668
+ } else {
4669
+ content = '<span class="option-value">'+ item.value +'</span>';
4670
+ if(item.label){
4671
+ content += ' <span class="option-label">'+ item.label +'</span>';
4672
+ }
1471
4673
  }
1472
- if (message) {
1473
- $('span.va-box', errorBubble).text(message);
4674
+ return content;
4675
+ },
4676
+ showHideOptions: function(_fromShowList){
4677
+ var value = $.prop(this.input, 'value').toLowerCase();
4678
+
4679
+ //first check prevent infinite loop, second creates simple lazy optimization
4680
+ if(value === this.lastUpdatedValue){
4681
+ return;
4682
+ }
4683
+ if(this.lastUnfoundValue && value.indexOf(this.lastUnfoundValue) === 0){
4684
+ this.hideList();
4685
+ return;
1474
4686
  }
1475
- else {
1476
- this.hide();
4687
+
4688
+
4689
+ this.lastUpdatedValue = value;
4690
+ var found = false;
4691
+ var startSearch = this.searchStart;
4692
+ var lis = $('li', this.shadowList);
4693
+ var that = this;
4694
+ if(value){
4695
+
4696
+ this.arrayOptions.forEach(function(item, i){
4697
+ var search, searchIndex, foundName;
4698
+ if(!('lowerValue' in item)){
4699
+ item.lowerValue = item.value.toLowerCase();
4700
+ if(item.label && item.label != item.value ){
4701
+ item.lowerLabel = item.label.toLowerCase();
4702
+ }
4703
+ }
4704
+
4705
+ if(value != item.lowerValue && item.lowerLabel != value){
4706
+ searchIndex = item.lowerValue.indexOf(value);
4707
+ search = startSearch ? !searchIndex : searchIndex !== -1;
4708
+ if(search){
4709
+ foundName = 'value';
4710
+ } else if(item.lowerLabel){
4711
+ searchIndex = item.lowerLabel.indexOf(value);
4712
+ search = startSearch ? !searchIndex : searchIndex !== -1;
4713
+ foundName = 'label';
4714
+ }
4715
+ }
4716
+
4717
+ if(search){
4718
+ that.addMark($(lis[i]).removeClass('hidden-item'), item, foundName, searchIndex, value.length);
4719
+ found = true;
4720
+ } else {
4721
+ $(lis[i]).addClass('hidden-item');
4722
+ }
4723
+ });
4724
+ } else if(lis.length) {
4725
+ this.removeMark(lis.removeClass('hidden-item'));
4726
+ found = true;
4727
+ }
4728
+
4729
+ this.hasViewableData = found;
4730
+ if(!_fromShowList && found){
4731
+ this.showList();
4732
+ }
4733
+
4734
+ if(!found){
4735
+ this.lastUnfoundValue = value;
4736
+ this.hideList();
4737
+ } else {
4738
+ this.lastUnfoundValue = false;
1477
4739
  }
1478
4740
  },
1479
- position: function(elem, offset){
1480
- offset = offset ? $.extend({}, offset) : api.getOffsetFromBody(elem);
1481
- offset.top += elem.outerHeight();
1482
- errorBubble.css(offset);
4741
+ otherType: {
4742
+ value: 'label',
4743
+ label: 'value'
1483
4744
  },
1484
- show: function(){
1485
- if(errorBubble.css('display') === 'none'){
1486
- errorBubble.css({opacity: 0}).show();
4745
+ addMark: function(elem, item, prop, start, length){
4746
+ if(this.addMarkElement){
4747
+ var text = item[prop].substr(start, length);
4748
+ text = item[prop].replace(text ,'<mark>'+ text +'</mark>');
4749
+ $('.option-'+ this.otherType[prop] +' > mark', elem).each(this._replaceMark);
4750
+ $('.option-'+prop, elem).html(text);
4751
+
1487
4752
  }
1488
- errorBubble.addClass('va-visible').fadeTo(400, 1);
1489
4753
  },
1490
- hide: function(){
1491
- errorBubble.removeClass('va-visible').fadeOut();
4754
+ _replaceMark: function(){
4755
+ var content = $(this).html();
4756
+ $(this).replaceWith(content);
1492
4757
  },
1493
- clear: function(){
1494
- clearTimeout(focusTimer);
1495
- clearTimeout(hideTimer);
1496
- $(document).unbind('.validityalert');
1497
- $(window).unbind('.validityalert');
1498
- errorBubble.stop().removeAttr('for');
4758
+ removeMark: function(lis){
4759
+ if(this.addMarkElement){
4760
+ $('mark', lis).each(this._replaceMark);
4761
+ }
1499
4762
  },
1500
- _create: function(){
1501
- if(errorBubble){return;}
1502
- errorBubble = api.errorBubble = $('<'+alertElem+' class="validity-alert-wrapper" role="alert"><span class="validity-alert"><span class="va-arrow"><span class="va-arrow-box"></span></span><span class="va-box"></span></span></'+alertElem+'>').css({position: 'absolute', display: 'none'});
1503
- webshims.ready('DOM', function(){
1504
- errorBubble.appendTo('body');
1505
- if($.fn.bgIframe){
1506
- errorBubble.bgIframe();
4763
+ showList: function(){
4764
+ if(this.popover.isVisible){return false;}
4765
+ if(this.needsUpdate){
4766
+ this.updateListOptions();
4767
+ }
4768
+ this.showHideOptions(true);
4769
+ if(!this.hasViewableData){return false;}
4770
+ var that = this;
4771
+
4772
+ that.shadowList.find('li.active-item').removeClass('active-item');
4773
+ that.popover.show(this.input);
4774
+
4775
+
4776
+ return true;
4777
+ },
4778
+ hideList: function(){
4779
+ if(!this.popover.isVisible){return false;}
4780
+ var that = this;
4781
+
4782
+
4783
+ this.popover.hide();
4784
+ that.shadowList.removeClass('datalist-visible list-item-active');
4785
+ that.index = -1;
4786
+ if(that.changedValue){
4787
+ that.triggeredByDatalist = true;
4788
+ $(that.input).trigger('input').trigger('change');
4789
+ that.changedValue = false;
4790
+ that.triggeredByDatalist = false;
4791
+ }
4792
+
4793
+ return true;
4794
+ },
4795
+ scrollIntoView: function(elem){
4796
+ var ul = $('ul', this.shadowList);
4797
+ var div = $('div.datalist-box', this.shadowList);
4798
+ var elemPos = elem.position();
4799
+ var containerHeight;
4800
+ elemPos.top -= (parseInt(ul.css('paddingTop'), 10) || 0) + (parseInt(ul.css('marginTop'), 10) || 0) + (parseInt(ul.css('borderTopWidth'), 10) || 0);
4801
+ if(elemPos.top < 0){
4802
+ div.scrollTop( div.scrollTop() + elemPos.top - 2);
4803
+ return;
4804
+ }
4805
+ elemPos.top += elem.outerHeight();
4806
+ containerHeight = div.height();
4807
+ if(elemPos.top > containerHeight){
4808
+ div.scrollTop( div.scrollTop() + (elemPos.top - containerHeight) + 2);
4809
+ }
4810
+ },
4811
+ changeValue: function(activeItem){
4812
+ if(!activeItem[0]){return;}
4813
+ var spinner;
4814
+ var newValue = $('span.option-value', activeItem).text();
4815
+ var oldValue = $.prop(this.input, 'value');
4816
+ if(newValue != oldValue){
4817
+
4818
+ $(this.input)
4819
+ .prop('value', newValue)
4820
+ .triggerHandler('updateInput')
4821
+ ;
4822
+ this.changedValue = true;
4823
+ if((spinner = $.data(this.input, 'wsspinner')) && spinner.setInput){
4824
+ spinner.setInput(newValue);
1507
4825
  }
1508
- });
4826
+ }
4827
+ },
4828
+ markItem: function(index, doValue, items){
4829
+ var activeItem;
4830
+ var goesUp;
4831
+
4832
+ items = items || $('li:not(.hidden-item)', this.shadowList);
4833
+ if(!items.length){return;}
4834
+ if(index < 0){
4835
+ index = items.length - 1;
4836
+ } else if(index >= items.length){
4837
+ index = 0;
4838
+ }
4839
+ items.removeClass('active-item');
4840
+ this.shadowList.addClass('list-item-active');
4841
+ activeItem = items.filter(':eq('+ index +')').addClass('active-item');
4842
+
4843
+ if(doValue){
4844
+ this.changeValue(activeItem);
4845
+ this.scrollIntoView(activeItem);
4846
+ }
4847
+ this.index = index;
1509
4848
  }
1510
4849
  };
1511
4850
 
1512
-
1513
- boundHide = $.proxy(api, 'hide');
1514
-
1515
- return api;
1516
- })();
1517
-
1518
-
1519
- /* extension, but also used to fix native implementation workaround/bugfixes */
1520
- (function(){
1521
- var firstEvent,
1522
- invalids = [],
1523
- stopSubmitTimer,
1524
- form
1525
- ;
1526
-
1527
- $(document).on('invalid', function(e){
1528
- if(e.wrongWebkitInvalid){return;}
1529
- var jElm = $(e.target);
1530
- var shadowElem = jElm.getShadowElement();
1531
- if(!shadowElem.hasClass(invalidClass)){
1532
- shadowElem.addClass(invalidClasses).removeClass(validClasses);
1533
- setTimeout(function(){
1534
- $(e.target).trigger('changedinvalid').trigger('changedvaliditystate');
1535
- }, 0);
1536
- }
1537
-
1538
- if(!firstEvent){
1539
- //trigger firstinvalid
1540
- firstEvent = $.Event('firstinvalid');
1541
- firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
1542
- var firstSystemInvalid = $.Event('firstinvalidsystem');
1543
- $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
1544
- jElm.trigger(firstEvent);
1545
- }
1546
-
1547
- //if firstinvalid was prevented all invalids will be also prevented
1548
- if( firstEvent && firstEvent.isDefaultPrevented() ){
1549
- e.preventDefault();
1550
- }
1551
- invalids.push(e.target);
1552
- e.extraData = 'fix';
1553
- clearTimeout(stopSubmitTimer);
1554
- stopSubmitTimer = setTimeout(function(){
1555
- var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
1556
- //reset firstinvalid
1557
- firstEvent = false;
1558
- invalids = [];
1559
- $(e.target).trigger(lastEvent, lastEvent);
1560
- }, 9);
1561
- jElm = null;
1562
- shadowElem = null;
1563
- });
4851
+ //init datalist update
4852
+ initializeDatalist();
1564
4853
  })();
1565
4854
 
1566
- $.fn.getErrorMessage = function(){
1567
- var message = '';
1568
- var elem = this[0];
1569
- if(elem){
1570
- message = getContentValidationMessage(elem) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
1571
- }
1572
- return message;
1573
- };
1574
-
1575
- if(options.replaceValidationUI){
1576
- webshims.ready('DOM forms', function(){
1577
- $(document).on('firstinvalid', function(e){
1578
- if(!e.isInvalidUIPrevented()){
1579
- e.preventDefault();
1580
- $.webshims.validityAlert.showFor( e.target );
1581
- }
1582
- });
1583
- });
1584
- }
1585
4855
  });
1586
-
1587
- })(jQuery);
1588
4856
  (function($, Modernizr, webshims){
1589
4857
  "use strict";
1590
4858
  var hasNative = Modernizr.audio && Modernizr.video;
@@ -1600,7 +4868,7 @@ jQuery.webshims.register('form-core', function($, webshims, window, document, un
1600
4868
  });
1601
4869
  };
1602
4870
  var options = webshims.cfg.mediaelement;
1603
- var swfType = options && options.player == 'jwplayer' ? 'mediaelement-swf' : 'mediaelement-jaris';
4871
+ var swfType = 'mediaelement-jaris';
1604
4872
  var hasSwf;
1605
4873
  if(!options){
1606
4874
  webshims.error("mediaelement wasn't implemented but loaded");
@@ -1625,34 +4893,44 @@ jQuery.webshims.register('form-core', function($, webshims, window, document, un
1625
4893
  }
1626
4894
 
1627
4895
  if(hasNative && !options.preferFlash){
4896
+ var noSwitch = {
4897
+ 1: 1,
4898
+ 2: 1
4899
+ };
1628
4900
  var switchOptions = function(e){
4901
+ var media;
1629
4902
  var parent = e.target.parentNode;
1630
- if(!options.preferFlash && ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) ){
1631
- webshims.ready('DOM mediaelement', function(){
1632
- if(hasSwf){
4903
+ if(!options.preferFlash &&
4904
+ ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) &&
4905
+ (media = $(e.target).closest('audio, video')) && !noSwitch[media.prop('error')]
4906
+ ){
4907
+ $(function(){
4908
+ if(hasSwf && !options.preferFlash){
1633
4909
  loadSwf();
4910
+ webshims.ready('WINDOWLOAD '+swfType, function(){
4911
+ setTimeout(function(){
4912
+ if(!options.preferFlash && webshims.mediaelement.createSWF && !media.is('.nonnative-api-active')){
4913
+ options.preferFlash = true;
4914
+ document.removeEventListener('error', switchOptions, true);
4915
+ $('audio, video').each(function(){
4916
+ webshims.mediaelement.selectSource(this);
4917
+ });
4918
+ webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src+" Mediaerror: "+ media.prop('error'));
4919
+ }
4920
+ }, 9);
4921
+ });
4922
+ } else{
4923
+ document.removeEventListener('error', switchOptions, true);
1634
4924
  }
1635
- webshims.ready('WINDOWLOAD '+swfType, function(){
1636
- setTimeout(function(){
1637
- if(hasSwf && !options.preferFlash && webshims.mediaelement.createSWF && !$(e.target).closest('audio, video').is('.nonnative-api-active')){
1638
- options.preferFlash = true;
1639
- document.removeEventListener('error', switchOptions, true);
1640
- $('audio, video').each(function(){
1641
- webshims.mediaelement.selectSource(this);
1642
- });
1643
- webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src);
1644
- } else if(!hasSwf){
1645
- document.removeEventListener('error', switchOptions, true);
1646
- }
1647
- }, 20);
1648
- });
1649
4925
  });
1650
4926
  }
1651
4927
  };
1652
4928
  document.addEventListener('error', switchOptions, true);
1653
4929
  $('audio, video').each(function(){
1654
- if(this.error){
4930
+ var error = $.prop(this, 'error');
4931
+ if(error && !noSwitch[error]){
1655
4932
  switchOptions({target: this});
4933
+ return false;
1656
4934
  }
1657
4935
  });
1658
4936
  }
@@ -1687,6 +4965,7 @@ jQuery.webshims.register('form-core', function($, webshims, window, document, un
1687
4965
  } else {
1688
4966
  webshims.info("track support was overwritten. due to bad browser support");
1689
4967
  }
4968
+ return false;
1690
4969
  }
1691
4970
  };
1692
4971
  var detectTrackError = function(){
@@ -1710,7 +4989,7 @@ jQuery.webshims.register('form-core', function($, webshims, window, document, un
1710
4989
  }
1711
4990
 
1712
4991
  webshims.register('mediaelement-core', function($, webshims, window, document, undefined){
1713
- hasSwf = swfobject.hasFlashPlayerVersion('9.0.115');
4992
+ hasSwf = swfmini.hasFlashPlayerVersion('9.0.115');
1714
4993
  $('html').addClass(hasSwf ? 'swf' : 'no-swf');
1715
4994
  var mediaelement = webshims.mediaelement;
1716
4995
  mediaelement.parseRtmp = function(data){
@@ -1803,7 +5082,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
1803
5082
  loaded = true;
1804
5083
  webshims.loader.loadScript("https://www.youtube.com/player_api");
1805
5084
  $(function(){
1806
- webshims.polyfill("mediaelement-yt");
5085
+ webshims._polyfill(["mediaelement-yt"]);
1807
5086
  });
1808
5087
  };
1809
5088
  })();
@@ -1927,7 +5206,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
1927
5206
  });
1928
5207
  };
1929
5208
 
1930
- mediaelement.swfMimeTypes = ['video/3gpp', 'video/x-msvideo', 'video/quicktime', 'video/x-m4v', 'video/mp4', 'video/m4p', 'video/x-flv', 'video/flv', 'audio/mpeg', 'audio/aac', 'audio/mp4', 'audio/x-m4a', 'audio/m4a', 'audio/mp3', 'audio/x-fla', 'audio/fla', 'youtube/flv', 'jwplayer/jwplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
5209
+ 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'];
1931
5210
 
1932
5211
  mediaelement.canThirdPlaySrces = function(mediaElem, srces){
1933
5212
  var ret = '';
@@ -1952,11 +5231,12 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
1952
5231
  if(hasNative){
1953
5232
  mediaElem = $(mediaElem);
1954
5233
  var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
1955
- if(!nativeCanPlayType[nodeName]){return ret;}
5234
+ var nativeCanPlay = (nativeCanPlayType[nodeName] || {prop: {_supvalue: false}}).prop._supvalue || mediaElem[0].canPlayType;
5235
+ if(!nativeCanPlay){return ret;}
1956
5236
  srces = srces || mediaelement.srces(mediaElem);
1957
5237
 
1958
5238
  $.each(srces, function(i, src){
1959
- if(src.type && nativeCanPlayType[nodeName].prop._supvalue.call(mediaElem[0], src.type) ){
5239
+ if(src.type && nativeCanPlay.call(mediaElem[0], src.type) ){
1960
5240
  ret = src;
1961
5241
  return false;
1962
5242
  }
@@ -1971,7 +5251,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
1971
5251
  }
1972
5252
 
1973
5253
  $(elem).pause().data('mediaerror', message);
1974
- webshims.warn('mediaelementError: '+ message);
5254
+ webshims.error('mediaelementError: '+ message);
1975
5255
  setTimeout(function(){
1976
5256
  if($(elem).data('mediaerror')){
1977
5257
  $(elem).trigger('mediaerror');
@@ -2045,6 +5325,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
2045
5325
  };
2046
5326
  mediaelement.selectSource = selectSource;
2047
5327
 
5328
+
2048
5329
  $(document).on('ended', function(e){
2049
5330
  var data = webshims.data(e.target, 'mediaelement');
2050
5331
  if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
@@ -2054,121 +5335,141 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
2054
5335
  }, 1);
2055
5336
 
2056
5337
  });
2057
- if(!supportsLoop){
2058
- webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
2059
- }
2060
5338
 
2061
- ['audio', 'video'].forEach(function(nodeName){
2062
- var supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
2063
- prop: {
2064
- value: function(){
2065
- var data = webshims.data(this, 'mediaelement');
2066
- selectSource(this, data);
2067
- if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
2068
- supLoad.prop._supvalue.apply(this, arguments);
5339
+ webshims.ready('dom-support', function(){
5340
+ if(!supportsLoop){
5341
+ webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
5342
+ }
5343
+
5344
+ ['audio', 'video'].forEach(function(nodeName){
5345
+ var supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
5346
+ prop: {
5347
+ value: function(){
5348
+ var data = webshims.data(this, 'mediaelement');
5349
+ selectSource(this, data);
5350
+ if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
5351
+ supLoad.prop._supvalue.apply(this, arguments);
5352
+ }
2069
5353
  }
2070
5354
  }
2071
- }
2072
- });
2073
- nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
2074
- prop: {
2075
- value: function(type){
2076
- var ret = '';
2077
- if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
2078
- ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
2079
- if(ret == 'no'){
2080
- ret = '';
5355
+ });
5356
+ nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
5357
+ prop: {
5358
+ value: function(type){
5359
+ var ret = '';
5360
+ if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
5361
+ ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
5362
+ if(ret == 'no'){
5363
+ ret = '';
5364
+ }
2081
5365
  }
2082
- }
2083
- if(!ret && hasSwf){
2084
- type = $.trim((type || '').split(';')[0]);
2085
- if(mediaelement.swfMimeTypes.indexOf(type) != -1){
2086
- ret = 'maybe';
5366
+ if(!ret && hasSwf){
5367
+ type = $.trim((type || '').split(';')[0]);
5368
+ if(mediaelement.swfMimeTypes.indexOf(type) != -1){
5369
+ ret = 'maybe';
5370
+ }
2087
5371
  }
5372
+ return ret;
2088
5373
  }
2089
- return ret;
2090
5374
  }
5375
+ });
5376
+ });
5377
+ webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
5378
+ set: function(){
5379
+ var elem = this;
5380
+ var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
5381
+ clearTimeout(baseData.loadTimer);
5382
+ baseData.loadTimer = setTimeout(function(){
5383
+ selectSource(elem);
5384
+ elem = null;
5385
+ }, 9);
2091
5386
  }
2092
5387
  });
2093
5388
  });
2094
- webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
2095
- set: function(){
2096
- var elem = this;
2097
- var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
2098
- clearTimeout(baseData.loadTimer);
2099
- baseData.loadTimer = setTimeout(function(){
2100
- selectSource(elem);
2101
- elem = null;
2102
- }, 9);
2103
- }
2104
- });
2105
5389
 
2106
5390
  var initMediaElements = function(){
2107
-
2108
- webshims.addReady(function(context, insertedElement){
2109
- var media = $('video, audio', context)
2110
- .add(insertedElement.filter('video, audio'))
2111
- .each(function(){
2112
- var data = webshims.data(this, 'mediaelement');
2113
-
2114
- if(hasNative && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay])') && (!data || data.isActive == 'html5')){
2115
- //IE controls not visible bug
2116
- $(this).prop('preload', 'metadata').mediaLoad();
2117
- } else {
2118
- selectSource(this, data);
2119
- }
5391
+ var testFixMedia = function(){
5392
+ if(webshims.implement(this, 'mediaelement')){
5393
+ selectSource(this);
5394
+
5395
+ if(hasNative){
5396
+ var bufferTimer;
5397
+ var lastBuffered;
5398
+ var elem = this;
5399
+ var getBufferedString = function(){
5400
+ var buffered = $.prop(elem, 'buffered');
5401
+ if(!buffered){return;}
5402
+ var bufferString = "";
5403
+ for(var i = 0, len = buffered.length; i < len;i++){
5404
+ bufferString += buffered.end(i);
5405
+ }
5406
+ return bufferString;
5407
+ };
5408
+ var testBuffer = function(){
5409
+ var buffered = getBufferedString();
5410
+ if(buffered != lastBuffered){
5411
+ lastBuffered = buffered;
5412
+ $(elem).triggerHandler('progress');
5413
+ }
5414
+ };
2120
5415
 
2121
- if(hasNative){
2122
-
2123
- //FF progress bug
2124
- (function(){
2125
- var bufferTimer;
2126
- var lastBuffered;
2127
- var elem = this;
2128
- var getBufferedString = function(){
2129
- var buffered = $.prop(elem, 'buffered');
2130
- if(!buffered){return;}
2131
- var bufferString = "";
2132
- for(var i = 0, len = buffered.length; i < len;i++){
2133
- bufferString += buffered.end(i);
5416
+ $(this)
5417
+ .on({
5418
+ 'play loadstart progress': function(e){
5419
+ if(e.type == 'progress'){
5420
+ lastBuffered = getBufferedString();
2134
5421
  }
2135
- return bufferString;
2136
- };
2137
- var testBuffer = function(){
2138
- var buffered = getBufferedString();
2139
- if(buffered != lastBuffered){
2140
- lastBuffered = buffered;
2141
- $(elem).triggerHandler('progress');
5422
+ clearTimeout(bufferTimer);
5423
+ bufferTimer = setTimeout(testBuffer, 999);
5424
+ },
5425
+ 'emptied stalled mediaerror abort suspend': function(e){
5426
+ if(e.type == 'emptied'){
5427
+ lastBuffered = false;
2142
5428
  }
2143
- };
2144
-
2145
- $(this)
2146
- .on({
2147
- 'play loadstart progress': function(e){
2148
- if(e.type == 'progress'){
2149
- lastBuffered = getBufferedString();
2150
- }
2151
- clearTimeout(bufferTimer);
2152
- bufferTimer = setTimeout(testBuffer, 999);
2153
- },
2154
- 'emptied stalled mediaerror abort suspend': function(e){
2155
- if(e.type == 'emptied'){
2156
- lastBuffered = false;
2157
- }
2158
- clearTimeout(bufferTimer);
2159
- }
2160
- })
2161
- ;
2162
- })();
5429
+ clearTimeout(bufferTimer);
5430
+ }
5431
+ })
5432
+ ;
5433
+ if('ActiveXObject' in window && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay],.nonnative-api-active)')){
5434
+ $(this).prop('preload', 'metadata').mediaLoad();
2163
5435
  }
2164
-
2165
- })
2166
- ;
2167
- if(!loadTrackUi.loaded && $('track', media).length){
2168
- loadTrackUi();
5436
+ }
2169
5437
  }
2170
- media = null;
5438
+
5439
+ };
5440
+ var handleMedia = false;
5441
+
5442
+
5443
+ webshims.ready('dom-support', function(){
5444
+ handleMedia = true;
5445
+ webshims.addReady(function(context, insertedElement){
5446
+ var media = $('video, audio', context)
5447
+ .add(insertedElement.filter('video, audio'))
5448
+ .each(testFixMedia)
5449
+ ;
5450
+ if(!loadTrackUi.loaded && $('track', media).length){
5451
+ loadTrackUi();
5452
+ }
5453
+ media = null;
5454
+ });
2171
5455
  });
5456
+
5457
+ if(hasNative && !handleMedia){
5458
+ webshims.addReady(function(context, insertedElement){
5459
+ if(!handleMedia){
5460
+ $('video, audio', context)
5461
+ .add(insertedElement.filter('video, audio'))
5462
+ .each(function(){
5463
+ if(!mediaelement.canNativePlaySrces(this) || (!loadTrackUi.loaded && $('track', this).length)){
5464
+ loadThird();
5465
+ handleMedia = true;
5466
+ return false;
5467
+ }
5468
+ })
5469
+ ;
5470
+ }
5471
+ });
5472
+ }
2172
5473
  };
2173
5474
 
2174
5475
  if(Modernizr.track && !bugs.track){