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,317 +1,4357 @@
1
- (function($){
2
- if(navigator.geolocation){return;}
3
- var domWrite = function(){
4
- setTimeout(function(){
5
- throw('document.write is overwritten by geolocation shim. This method is incompatible with this plugin');
6
- }, 1);
7
- },
8
- id = 0
9
- ;
10
- var geoOpts = $.webshims.cfg.geolocation || {};
11
- navigator.geolocation = (function(){
12
- var pos;
13
- var api = {
14
- getCurrentPosition: function(success, error, opts){
15
- var locationAPIs = 2,
16
- errorTimer,
17
- googleTimer,
18
- calledEnd,
19
- endCallback = function(){
20
- if(calledEnd){return;}
21
- if(pos){
22
- calledEnd = true;
23
- success($.extend({timestamp: new Date().getTime()}, pos));
24
- resetCallback();
25
- if(window.JSON && window.sessionStorage){
26
- try{
27
- sessionStorage.setItem('storedGeolocationData654321', JSON.stringify(pos));
28
- } catch(e){}
29
- }
30
- } else if(error && !locationAPIs) {
31
- calledEnd = true;
32
- resetCallback();
33
- error({ code: 2, message: "POSITION_UNAVAILABLE"});
34
- }
35
- },
36
- googleCallback = function(){
37
- locationAPIs--;
38
- getGoogleCoords();
39
- endCallback();
40
- },
41
- resetCallback = function(){
42
- $(document).unbind('google-loader', resetCallback);
43
- clearTimeout(googleTimer);
44
- clearTimeout(errorTimer);
45
- },
46
- getGoogleCoords = function(){
47
- if(pos || !window.google || !google.loader || !google.loader.ClientLocation){return false;}
48
- var cl = google.loader.ClientLocation;
49
- pos = {
50
- coords: {
51
- latitude: cl.latitude,
52
- longitude: cl.longitude,
53
- altitude: null,
54
- accuracy: 43000,
55
- altitudeAccuracy: null,
56
- heading: parseInt('NaN', 10),
57
- velocity: null
58
- },
59
- //extension similiar to FF implementation
60
- address: $.extend({streetNumber: '', street: '', premises: '', county: '', postalCode: ''}, cl.address)
61
- };
62
- return true;
63
- },
64
- getInitCoords = function(){
65
- if(pos){return;}
66
- getGoogleCoords();
67
- if(pos || !window.JSON || !window.sessionStorage){return;}
68
- try{
69
- pos = sessionStorage.getItem('storedGeolocationData654321');
70
- pos = (pos) ? JSON.parse(pos) : false;
71
- if(!pos.coords){pos = false;}
72
- } catch(e){
73
- pos = false;
74
- }
1
+ //DOM-Extension helper
2
+ jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
3
+ "use strict";
4
+
5
+ webshims.assumeARIA = Modernizr.localstorage || Modernizr.video || Modernizr.boxsizing;
6
+
7
+ if($('<input type="email" />').attr('type') == 'text' || $('<form />').attr('novalidate') === "" || ('required' in $('<input />')[0].attributes)){
8
+ 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");
9
+ }
10
+
11
+ if(!$.parseHTML){
12
+ webshims.error("Webshims needs jQuery 1.8+ to work properly. Please update your jQuery version or downgrade webshims.");
13
+ }
14
+
15
+ //shortcus
16
+ var modules = webshims.modules;
17
+ var listReg = /\s*,\s*/;
18
+
19
+ //proxying attribute
20
+ var olds = {};
21
+ var havePolyfill = {};
22
+ var extendedProps = {};
23
+ var extendQ = {};
24
+ var modifyProps = {};
25
+
26
+ var oldVal = $.fn.val;
27
+ var singleVal = function(elem, name, val, pass, _argless){
28
+ return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
29
+ };
30
+
31
+
32
+ $.fn.val = function(val){
33
+ var elem = this[0];
34
+ if(arguments.length && val == null){
35
+ val = '';
36
+ }
37
+ if(!arguments.length){
38
+ if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
39
+ return $.prop(elem, 'value', val, 'val', true);
40
+ }
41
+ if($.isArray(val)){
42
+ return oldVal.apply(this, arguments);
43
+ }
44
+ var isFunction = $.isFunction(val);
45
+ return this.each(function(i){
46
+ elem = this;
47
+ if(elem.nodeType === 1){
48
+ if(isFunction){
49
+ var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
50
+ if(genVal == null){
51
+ genVal = '';
75
52
  }
76
- ;
77
-
78
- getInitCoords();
53
+ $.prop(elem, 'value', genVal, 'val') ;
54
+ } else {
55
+ $.prop(elem, 'value', val, 'val');
56
+ }
57
+ }
58
+ });
59
+ };
60
+ $.fn.onTrigger = function(evt, fn){
61
+ return this.on(evt, fn).each(fn);
62
+ };
63
+
64
+ var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
65
+ var elementData = function(elem, key, val){
66
+ elem = elem.jquery ? elem[0] : elem;
67
+ if(!elem){return val || {};}
68
+ var data = $.data(elem, dataID);
69
+ if(val !== undefined){
70
+ if(!data){
71
+ data = $.data(elem, dataID, {});
72
+ }
73
+ if(key){
74
+ data[key] = val;
75
+ }
76
+ }
77
+
78
+ return key ? data && data[key] : data;
79
+ };
80
+
81
+
82
+ [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
83
+ $.fn[data.name] = function(){
84
+ var elems = [];
85
+ this.each(function(){
86
+ var shadowData = elementData(this, 'shadowData');
87
+ var elem = shadowData && shadowData[data.prop] || this;
88
+ if($.inArray(elem, elems) == -1){
89
+ elems.push(elem);
90
+ }
91
+ });
92
+ return this.pushStack(elems);
93
+ };
94
+ });
95
+
96
+ if($.Tween.propHooks._default && $.css){
97
+ (function(){
98
+ var isjQ8 = false;
99
+ try {
100
+ isjQ8 = $.css($('<b style="width: 10px" />')[0], 'width', '') == '10px';
101
+ } catch(er){
102
+ webshims.error(er);
103
+ }
104
+ var css = isjQ8 ?
105
+ function(elem, prop){
106
+ return $.css( elem, prop, false, "" );
107
+ } :
108
+ function(elem, prop){
109
+ return $.css( elem, prop, "" );
110
+ }
111
+ ;
79
112
 
80
- if(!pos){
81
- if(geoOpts.confirmText && !confirm(geoOpts.confirmText.replace('{location}', location.hostname))){
82
- if(error){
83
- error({ code: 1, message: "PERMISSION_DENIED"});
84
- }
85
- return;
113
+ $.extend($.Tween.propHooks._default, {
114
+ get: function( tween ) {
115
+ var result;
116
+
117
+ if ( (tween.elem[ tween.prop ] != null || havePolyfill[ tween.prop ]) &&
118
+ (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
119
+ return havePolyfill[ tween.prop ] ? $.prop(tween.elem, tween.prop) : tween.elem[ tween.prop ];
86
120
  }
87
- $.ajax({
88
- url: 'http://freegeoip.net/json/',
89
- dataType: 'jsonp',
90
- cache: true,
91
- jsonp: 'callback',
92
- success: function(data){
93
- locationAPIs--;
94
- if(!data){return;}
95
- pos = pos || {
96
- coords: {
97
- latitude: data.latitude,
98
- longitude: data.longitude,
99
- altitude: null,
100
- accuracy: 43000,
101
- altitudeAccuracy: null,
102
- heading: parseInt('NaN', 10),
103
- velocity: null
104
- },
105
- //extension similiar to FF implementation
106
- address: {
107
- city: data.city,
108
- country: data.country_name,
109
- countryCode: data.country_code,
110
- county: "",
111
- postalCode: data.zipcode,
112
- premises: "",
113
- region: data.region_name,
114
- street: "",
115
- streetNumber: ""
116
- }
117
- };
118
- endCallback();
119
- },
120
- error: function(){
121
- locationAPIs--;
122
- endCallback();
123
- }
124
- });
125
- clearTimeout(googleTimer);
126
- if (!window.google || !window.google.loader) {
127
- googleTimer = setTimeout(function(){
128
- //destroys document.write!!!
129
- if (geoOpts.destroyWrite) {
130
- document.write = domWrite;
131
- document.writeln = domWrite;
132
- }
133
- $(document).one('google-loader', googleCallback);
134
- $.webshims.loader.loadScript('http://www.google.com/jsapi', false, 'google-loader');
135
- }, 800);
121
+
122
+ // passing an empty string as a 3rd parameter to .css will automatically
123
+ // attempt a parseFloat and fallback to a string if the parse fails
124
+ // so, simple values such as "10px" are parsed to Float.
125
+ // complex values such as "rotate(1rad)" are returned as is.
126
+ result = css( tween.elem, tween.prop );
127
+ // Empty strings, null, undefined and "auto" are converted to 0.
128
+ return !result || result === "auto" ? 0 : result;
129
+ },
130
+ set: function( tween ) {
131
+ // use step hook for back compat - use cssHook if its there - use .style if its
132
+ // available and use plain properties where available
133
+ if ( jQuery.fx.step[ tween.prop ] ) {
134
+ jQuery.fx.step[ tween.prop ]( tween );
135
+ } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
136
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
137
+ } else if( !havePolyfill[ tween.prop ] ) {
138
+ tween.elem[ tween.prop ] = tween.now;
136
139
  } else {
137
- locationAPIs--;
140
+ $.prop(tween.elem, tween.prop, tween.now);
141
+ }
142
+ }
143
+ });
144
+ })();
145
+ }
146
+
147
+
148
+ ['removeAttr', 'prop', 'attr'].forEach(function(type){
149
+ olds[type] = $[type];
150
+ $[type] = function(elem, name, value, pass, _argless){
151
+ var isVal = (pass == 'val');
152
+ var oldMethod = !isVal ? olds[type] : singleVal;
153
+ if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
154
+ return oldMethod(elem, name, value, pass, _argless);
155
+ }
156
+
157
+ var nodeName = (elem.nodeName || '').toLowerCase();
158
+ var desc = extendedProps[nodeName];
159
+ var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
160
+ var propMethod;
161
+ var oldValMethod;
162
+ var ret;
163
+
164
+
165
+ if(!desc){
166
+ desc = extendedProps['*'];
167
+ }
168
+ if(desc){
169
+ desc = desc[name];
170
+ }
171
+
172
+ if(desc){
173
+ propMethod = desc[curType];
174
+ }
175
+
176
+ if(propMethod){
177
+ if(name == 'value'){
178
+ oldValMethod = propMethod.isVal;
179
+ propMethod.isVal = isVal;
180
+ }
181
+ if(curType === 'removeAttr'){
182
+ return propMethod.value.call(elem);
183
+ } else if(value === undefined){
184
+ return (propMethod.get) ?
185
+ propMethod.get.call(elem) :
186
+ propMethod.value
187
+ ;
188
+ } else if(propMethod.set) {
189
+ if(type == 'attr' && value === true){
190
+ value = name;
138
191
  }
192
+
193
+ ret = propMethod.set.call(elem, value);
194
+ }
195
+ if(name == 'value'){
196
+ propMethod.isVal = oldValMethod;
197
+ }
198
+ } else {
199
+ ret = oldMethod(elem, name, value, pass, _argless);
200
+ }
201
+ if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
202
+
203
+ var boolValue;
204
+ if(curType == 'removeAttr'){
205
+ boolValue = false;
206
+ } else if(curType == 'prop'){
207
+ boolValue = !!(value);
139
208
  } else {
140
- setTimeout(endCallback, 1);
209
+ boolValue = true;
210
+ }
211
+
212
+ modifyProps[nodeName][name].forEach(function(fn){
213
+ if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
214
+ fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
215
+ }
216
+ });
217
+ }
218
+ return ret;
219
+ };
220
+
221
+ extendQ[type] = function(nodeName, prop, desc){
222
+
223
+ if(!extendedProps[nodeName]){
224
+ extendedProps[nodeName] = {};
225
+ }
226
+ if(!extendedProps[nodeName][prop]){
227
+ extendedProps[nodeName][prop] = {};
228
+ }
229
+ var oldDesc = extendedProps[nodeName][prop][type];
230
+ var getSup = function(propType, descriptor, oDesc){
231
+ if(descriptor && descriptor[propType]){
232
+ return descriptor[propType];
233
+ }
234
+ if(oDesc && oDesc[propType]){
235
+ return oDesc[propType];
236
+ }
237
+ if(type == 'prop' && prop == 'value'){
238
+ return function(value){
239
+ var elem = this;
240
+ return (desc.isVal) ?
241
+ singleVal(elem, prop, value, false, (arguments.length === 0)) :
242
+ olds[type](elem, prop, value)
243
+ ;
244
+ };
245
+ }
246
+ if(type == 'prop' && propType == 'value' && desc.value.apply){
247
+ return function(value){
248
+ var sup = olds[type](this, prop);
249
+ if(sup && sup.apply){
250
+ sup = sup.apply(this, arguments);
251
+ }
252
+ return sup;
253
+ };
254
+ }
255
+ return function(value){
256
+ return olds[type](this, prop, value);
257
+ };
258
+ };
259
+ extendedProps[nodeName][prop][type] = desc;
260
+ if(desc.value === undefined){
261
+ if(!desc.set){
262
+ desc.set = desc.writeable ?
263
+ getSup('set', desc, oldDesc) :
264
+ (webshims.cfg.useStrict && prop == 'prop') ?
265
+ function(){throw(prop +' is readonly on '+ nodeName);} :
266
+ function(){webshims.info(prop +' is readonly on '+ nodeName);}
267
+ ;
268
+ }
269
+ if(!desc.get){
270
+ desc.get = getSup('get', desc, oldDesc);
271
+ }
272
+
273
+ }
274
+
275
+ ['value', 'get', 'set'].forEach(function(descProp){
276
+ if(desc[descProp]){
277
+ desc['_sup'+descProp] = getSup(descProp, oldDesc);
278
+ }
279
+ });
280
+ };
281
+
282
+ });
283
+
284
+ var extendNativeValue = (function(){
285
+ var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
286
+ var has = Object.prototype.hasOwnProperty;
287
+ //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
288
+ var isExtendNativeSave = Modernizr.advancedObjectProperties && Modernizr.objectAccessor;
289
+ return function(nodeName, prop, desc){
290
+ var elem , elemProto;
291
+ if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
292
+ var sup = elem[prop];
293
+ desc._supvalue = function(){
294
+ if(sup && sup.apply){
295
+ return sup.apply(this, arguments);
296
+ }
297
+ return sup;
298
+ };
299
+ elemProto[prop] = desc.value;
300
+ } else {
301
+ desc._supvalue = function(){
302
+ var data = elementData(this, 'propValue');
303
+ if(data && data[prop] && data[prop].apply){
304
+ return data[prop].apply(this, arguments);
305
+ }
306
+ return data && data[prop];
307
+ };
308
+ initProp.extendValue(nodeName, prop, desc.value);
309
+ }
310
+ desc.value._supvalue = desc._supvalue;
311
+ };
312
+ })();
313
+
314
+ var initProp = (function(){
315
+
316
+ var initProps = {};
317
+
318
+ webshims.addReady(function(context, contextElem){
319
+ var nodeNameCache = {};
320
+ var getElementsByName = function(name){
321
+ if(!nodeNameCache[name]){
322
+ nodeNameCache[name] = $(context.getElementsByTagName(name));
323
+ if(contextElem[0] && $.nodeName(contextElem[0], name)){
324
+ nodeNameCache[name] = nodeNameCache[name].add(contextElem);
325
+ }
326
+ }
327
+ };
328
+
329
+
330
+ $.each(initProps, function(name, fns){
331
+ getElementsByName(name);
332
+ if(!fns || !fns.forEach){
333
+ webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
141
334
  return;
142
335
  }
143
- if(opts && opts.timeout){
144
- errorTimer = setTimeout(function(){
145
- resetCallback();
146
- if(error) {
147
- error({ code: 3, message: "TIMEOUT"});
148
- }
149
- }, opts.timeout);
150
- } else {
151
- errorTimer = setTimeout(function(){
152
- locationAPIs = 0;
153
- endCallback();
154
- }, 10000);
336
+ fns.forEach(function(fn){
337
+ nodeNameCache[name].each(fn);
338
+ });
339
+ });
340
+ nodeNameCache = null;
341
+ });
342
+
343
+ var tempCache;
344
+ var emptyQ = $([]);
345
+ var createNodeNameInit = function(nodeName, fn){
346
+ if(!initProps[nodeName]){
347
+ initProps[nodeName] = [fn];
348
+ } else {
349
+ initProps[nodeName].push(fn);
350
+ }
351
+ if($.isDOMReady){
352
+ (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
353
+ }
354
+ };
355
+
356
+ var elementExtends = {};
357
+ return {
358
+ createTmpCache: function(nodeName){
359
+ if($.isDOMReady){
360
+ tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
155
361
  }
362
+ return tempCache || emptyQ;
156
363
  },
157
- clearWatch: $.noop
158
- };
159
- api.watchPosition = function(a, b, c){
160
- api.getCurrentPosition(a, b, c);
161
- id++;
162
- return id;
364
+ flushTmpCache: function(){
365
+ tempCache = null;
366
+ },
367
+ content: function(nodeName, prop){
368
+ createNodeNameInit(nodeName, function(){
369
+ var val = $.attr(this, prop);
370
+ if(val != null){
371
+ $.attr(this, prop, val);
372
+ }
373
+ });
374
+ },
375
+ createElement: function(nodeName, fn){
376
+ createNodeNameInit(nodeName, fn);
377
+ },
378
+ extendValue: function(nodeName, prop, value){
379
+ createNodeNameInit(nodeName, function(){
380
+ $(this).each(function(){
381
+ var data = elementData(this, 'propValue', {});
382
+ data[prop] = this[prop];
383
+ this[prop] = value;
384
+ });
385
+ });
386
+ }
163
387
  };
164
- return api;
165
388
  })();
166
-
167
- $.webshims.isReady('geolocation', true);
168
- })(jQuery);
169
-
170
- jQuery.webshims.register('details', function($, webshims, window, doc, undefined, options){
171
- var isInterActiveSummary = function(summary){
172
- var details = $(summary).parent('details');
173
- if(details[0] && details.children(':first').get(0) === summary){
174
- return details;
389
+
390
+ var createPropDefault = function(descs, removeType){
391
+ if(descs.defaultValue === undefined){
392
+ descs.defaultValue = '';
175
393
  }
176
- };
177
-
178
- var bindDetailsSummary = function(summary, details){
179
- summary = $(summary);
180
- details = $(details);
181
- var oldSummary = $.data(details[0], 'summaryElement');
182
- $.data(summary[0], 'detailsElement', details);
183
- if(!oldSummary || summary[0] !== oldSummary[0]){
184
- if(oldSummary){
185
- if(oldSummary.hasClass('fallback-summary')){
186
- oldSummary.remove();
187
- } else {
188
- oldSummary
189
- .unbind('.summaryPolyfill')
190
- .removeData('detailsElement')
191
- .removeAttr('role')
192
- .removeAttr('tabindex')
193
- .removeAttr('aria-expanded')
194
- .removeClass('summary-button')
195
- .find('span.details-open-indicator')
196
- .remove()
197
- ;
394
+ if(!descs.removeAttr){
395
+ descs.removeAttr = {
396
+ value: function(){
397
+ descs[removeType || 'prop'].set.call(this, descs.defaultValue);
398
+ descs.removeAttr._supvalue.call(this);
198
399
  }
199
- }
200
- $.data(details[0], 'summaryElement', summary);
201
- details.prop('open', details.prop('open'));
400
+ };
202
401
  }
203
- };
204
- var getSummary = function(details){
205
- var summary = $.data(details, 'summaryElement');
206
- if(!summary){
207
- summary = $('> summary:first-child', details);
208
- if(!summary[0]){
209
- $(details).prependPolyfill('<summary class="fallback-summary">'+ options.text +'</summary>');
210
- summary = $.data(details, 'summaryElement');
211
- } else {
212
- bindDetailsSummary(summary, details);
213
- }
402
+ if(!descs.attr){
403
+ descs.attr = {};
214
404
  }
215
- return summary;
216
405
  };
217
406
 
218
- // var isOriginalPrevented = function(e){
219
- // var src = e.originalEvent;
220
- // if(!src){return e.isDefaultPrevented();}
221
- //
222
- // return src.defaultPrevented || src.returnValue === false ||
223
- // src.getPreventDefault && src.getPreventDefault();
224
- // };
225
-
226
- webshims.createElement('summary', function(){
227
- var details = isInterActiveSummary(this);
228
- if(!details || $.data(this, 'detailsElement')){return;}
229
- var timer;
230
- var stopNativeClickTest;
231
- var tabindex = $.attr(this, 'tabIndex') || '0';
232
- bindDetailsSummary(this, details);
233
- $(this)
234
- .on({
235
- 'focus.summaryPolyfill': function(){
236
- $(this).addClass('summary-has-focus');
237
- },
238
- 'blur.summaryPolyfill': function(){
239
- $(this).removeClass('summary-has-focus');
407
+ $.extend(webshims, {
408
+
409
+ getID: (function(){
410
+ var ID = new Date().getTime();
411
+ return function(elem){
412
+ elem = $(elem);
413
+ var id = elem.prop('id');
414
+ if(!id){
415
+ ID++;
416
+ id = 'ID-'+ ID;
417
+ elem.eq(0).prop('id', id);
418
+ }
419
+ return id;
420
+ };
421
+ })(),
422
+ implement: function(elem, type){
423
+ var data = elementData(elem, 'implemented') || elementData(elem, 'implemented', {});
424
+ if(data[type]){
425
+ webshims.info(type +' already implemented for element #'+elem.id);
426
+ return false;
427
+ }
428
+ data[type] = true;
429
+ return true;
430
+ },
431
+ extendUNDEFProp: function(obj, props){
432
+ $.each(props, function(name, prop){
433
+ if( !(name in obj) ){
434
+ obj[name] = prop;
435
+ }
436
+ });
437
+ },
438
+ //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
439
+ createPropDefault: createPropDefault,
440
+ data: elementData,
441
+ moveToFirstEvent: function(elem, eventType, bindType){
442
+ var events = ($._data(elem, 'events') || {})[eventType];
443
+ var fn;
444
+
445
+ if(events && events.length > 1){
446
+ fn = events.pop();
447
+ if(!bindType){
448
+ bindType = 'bind';
449
+ }
450
+ if(bindType == 'bind' && events.delegateCount){
451
+ events.splice( events.delegateCount, 0, fn);
452
+ } else {
453
+ events.unshift( fn );
454
+ }
455
+
456
+
457
+ }
458
+ elem = null;
459
+ },
460
+ addShadowDom: (function(){
461
+ var resizeTimer;
462
+ var lastHeight;
463
+ var lastWidth;
464
+
465
+ var docObserve = {
466
+ init: false,
467
+ runs: 0,
468
+ test: function(){
469
+ var height = docObserve.getHeight();
470
+ var width = docObserve.getWidth();
471
+
472
+ if(height != docObserve.height || width != docObserve.width){
473
+ docObserve.height = height;
474
+ docObserve.width = width;
475
+ docObserve.handler({type: 'docresize'});
476
+ docObserve.runs++;
477
+ if(docObserve.runs < 9){
478
+ setTimeout(docObserve.test, 90);
479
+ }
480
+ } else {
481
+ docObserve.runs = 0;
482
+ }
240
483
  },
241
- 'mouseenter.summaryPolyfill': function(){
242
- $(this).addClass('summary-has-hover');
484
+ handler: function(e){
485
+ clearTimeout(resizeTimer);
486
+ resizeTimer = setTimeout(function(){
487
+ if(e.type == 'resize'){
488
+ var width = $(window).width();
489
+ var height = $(window).width();
490
+ if(height == lastHeight && width == lastWidth){
491
+ return;
492
+ }
493
+ lastHeight = height;
494
+ lastWidth = width;
495
+
496
+ docObserve.height = docObserve.getHeight();
497
+ docObserve.width = docObserve.getWidth();
498
+
499
+ }
500
+ $(document).triggerHandler('updateshadowdom');
501
+ }, (e.type == 'resize') ? 50 : 9);
243
502
  },
244
- 'mouseleave.summaryPolyfill': function(){
245
- $(this).removeClass('summary-has-hover');
503
+ _create: function(){
504
+ $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
505
+ var body = document.body;
506
+ var doc = document.documentElement;
507
+ docObserve[type] = function(){
508
+ return Math.max(
509
+ body[ "scroll" + name ], doc[ "scroll" + name ],
510
+ body[ "offset" + name ], doc[ "offset" + name ],
511
+ doc[ "client" + name ]
512
+ );
513
+ };
514
+ });
246
515
  },
247
- 'click.summaryPolyfill': function(e){
248
- var details = isInterActiveSummary(this);
249
- if(details){
250
- if(!stopNativeClickTest && e.originalEvent){
251
- stopNativeClickTest = true;
252
- e.stopImmediatePropagation();
253
- e.preventDefault();
254
- $(this).trigger('click');
255
- stopNativeClickTest = false;
256
- return false;
516
+ start: function(){
517
+ if(!this.init && document.body){
518
+ this.init = true;
519
+ this._create();
520
+ this.height = docObserve.getHeight();
521
+ this.width = docObserve.getWidth();
522
+ setInterval(this.test, 600);
523
+ $(this.test);
524
+ webshims.ready('WINDOWLOAD', this.test);
525
+ $(window).bind('resize', this.handler);
526
+ (function(){
527
+ var oldAnimate = $.fn.animate;
528
+ var animationTimer;
529
+
530
+ $.fn.animate = function(){
531
+ clearTimeout(animationTimer);
532
+ animationTimer = setTimeout(function(){
533
+ docObserve.test();
534
+ }, 99);
535
+
536
+ return oldAnimate.apply(this, arguments);
537
+ };
538
+ })();
539
+ }
540
+ }
541
+ };
542
+
543
+
544
+ webshims.docObserve = function(){
545
+ webshims.ready('DOM', function(){
546
+ docObserve.start();
547
+ });
548
+ };
549
+ return function(nativeElem, shadowElem, opts){
550
+ opts = opts || {};
551
+ if(nativeElem.jquery){
552
+ nativeElem = nativeElem[0];
553
+ }
554
+ if(shadowElem.jquery){
555
+ shadowElem = shadowElem[0];
556
+ }
557
+ var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
558
+ var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
559
+ var shadowFocusElementData = {};
560
+ if(!opts.shadowFocusElement){
561
+ opts.shadowFocusElement = shadowElem;
562
+ } else if(opts.shadowFocusElement){
563
+ if(opts.shadowFocusElement.jquery){
564
+ opts.shadowFocusElement = opts.shadowFocusElement[0];
565
+ }
566
+ shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
567
+ }
568
+
569
+ nativeData.hasShadow = shadowElem;
570
+ shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
571
+ shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
572
+ nativeElement: nativeElem,
573
+ shadowElement: shadowElem,
574
+ shadowFocusElement: opts.shadowFocusElement
575
+ };
576
+ if(opts.shadowChilds){
577
+ opts.shadowChilds.each(function(){
578
+ elementData(this, 'shadowData', shadowData.shadowData);
579
+ });
580
+ }
581
+
582
+ if(opts.data){
583
+ shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
584
+ }
585
+ opts = null;
586
+ webshims.docObserve();
587
+ };
588
+ })(),
589
+ propTypes: {
590
+ standard: function(descs, name){
591
+ createPropDefault(descs);
592
+ if(descs.prop){return;}
593
+ descs.prop = {
594
+ set: function(val){
595
+ descs.attr.set.call(this, ''+val);
596
+ },
597
+ get: function(){
598
+ return descs.attr.get.call(this) || descs.defaultValue;
599
+ }
600
+ };
601
+
602
+ },
603
+ "boolean": function(descs, name){
604
+
605
+ createPropDefault(descs);
606
+ if(descs.prop){return;}
607
+ descs.prop = {
608
+ set: function(val){
609
+ if(val){
610
+ descs.attr.set.call(this, "");
257
611
  } else {
258
- clearTimeout(timer);
612
+ descs.removeAttr.value.call(this);
613
+ }
614
+ },
615
+ get: function(){
616
+ return descs.attr.get.call(this) != null;
617
+ }
618
+ };
619
+ },
620
+ "src": (function(){
621
+ var anchor = document.createElement('a');
622
+ anchor.style.display = "none";
623
+ return function(descs, name){
624
+
625
+ createPropDefault(descs);
626
+ if(descs.prop){return;}
627
+ descs.prop = {
628
+ set: function(val){
629
+ descs.attr.set.call(this, val);
630
+ },
631
+ get: function(){
632
+ var href = this.getAttribute(name);
633
+ var ret;
634
+ if(href == null){return '';}
259
635
 
260
- timer = setTimeout(function(){
261
- if(!e.isDefaultPrevented()){
262
- details.prop('open', !details.prop('open'));
636
+ anchor.setAttribute('href', href+'' );
637
+
638
+ if(!$.support.hrefNormalized){
639
+ try {
640
+ $(anchor).insertAfter(this);
641
+ ret = anchor.getAttribute('href', 4);
642
+ } catch(er){
643
+ ret = anchor.getAttribute('href', 4);
263
644
  }
264
- }, 0);
645
+ $(anchor).detach();
646
+ }
647
+ return ret || anchor.href;
648
+ }
649
+ };
650
+ };
651
+ })(),
652
+ enumarated: function(descs, name){
653
+
654
+ createPropDefault(descs);
655
+ if(descs.prop){return;}
656
+ descs.prop = {
657
+ set: function(val){
658
+ descs.attr.set.call(this, val);
659
+ },
660
+ get: function(){
661
+ var val = (descs.attr.get.call(this) || '').toLowerCase();
662
+ if(!val || descs.limitedTo.indexOf(val) == -1){
663
+ val = descs.defaultValue;
664
+ }
665
+ return val;
666
+ }
667
+ };
668
+ }
669
+
670
+ // ,unsignedLong: $.noop
671
+ // ,"doubble": $.noop
672
+ // ,"long": $.noop
673
+ // ,tokenlist: $.noop
674
+ // ,settableTokenlist: $.noop
675
+ },
676
+ reflectProperties: function(nodeNames, props){
677
+ if(typeof props == 'string'){
678
+ props = props.split(listReg);
679
+ }
680
+ props.forEach(function(prop){
681
+ webshims.defineNodeNamesProperty(nodeNames, prop, {
682
+ prop: {
683
+ set: function(val){
684
+ $.attr(this, prop, val);
685
+ },
686
+ get: function(){
687
+ return $.attr(this, prop) || '';
265
688
  }
266
689
  }
267
- },
268
- 'keydown.summaryPolyfill': function(e){
269
- if( (e.keyCode == 13 || e.keyCode == 32) && !e.isDefaultPrevented()){
270
- stopNativeClickTest = true;
271
- e.preventDefault();
272
- $(this).trigger('click');
273
- stopNativeClickTest = false;
690
+ });
691
+ });
692
+ },
693
+ defineNodeNameProperty: function(nodeName, prop, descs){
694
+ havePolyfill[prop] = true;
695
+
696
+ if(descs.reflect){
697
+ webshims.propTypes[descs.propType || 'standard'](descs, prop);
698
+ }
699
+
700
+ ['prop', 'attr', 'removeAttr'].forEach(function(type){
701
+ var desc = descs[type];
702
+ if(desc){
703
+ if(type === 'prop'){
704
+ desc = $.extend({writeable: true}, desc);
705
+ } else {
706
+ desc = $.extend({}, desc, {writeable: true});
274
707
  }
275
- }
276
- })
277
- .attr({tabindex: tabindex, role: 'button'})
278
- .prepend('<span class="details-open-indicator" />')
279
- ;
280
- webshims.moveToFirstEvent(this, 'click');
281
- });
282
-
283
- var initDetails;
284
- webshims.defineNodeNamesBooleanProperty('details', 'open', function(val){
285
- var summary = $($.data(this, 'summaryElement'));
286
- if(!summary){return;}
287
- var action = (val) ? 'removeClass' : 'addClass';
288
- var details = $(this);
289
- if (!initDetails && options.animate){
290
- details.stop().css({width: '', height: ''});
291
- var start = {
292
- width: details.width(),
293
- height: details.height()
294
- };
295
- }
296
- summary.attr('aria-expanded', ''+val);
297
- details[action]('closed-details-summary').children().not(summary[0])[action]('closed-details-child');
298
- if(!initDetails && options.animate){
299
- var end = {
300
- width: details.width(),
301
- height: details.height()
302
- };
303
- details.css(start).animate(end, {
304
- complete: function(){
305
- $(this).css({width: '', height: ''});
708
+
709
+ extendQ[type](nodeName, prop, desc);
710
+ if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
711
+ extendNativeValue(nodeName, prop, desc);
712
+ }
713
+ descs[type] = desc;
306
714
  }
307
715
  });
308
- }
716
+ if(descs.initAttr){
717
+ initProp.content(nodeName, prop);
718
+ }
719
+ return descs;
720
+ },
309
721
 
310
- });
311
- webshims.createElement('details', function(){
312
- initDetails = true;
313
- var summary = getSummary(this);
314
- $.prop(this, 'open', $.prop(this, 'open'));
315
- initDetails = false;
316
- });
317
- });
722
+ defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
723
+ var olddesc;
724
+ for(var prop in descs){
725
+ if(!_noTmpCache && descs[prop].initAttr){
726
+ initProp.createTmpCache(name);
727
+ }
728
+ if(propType){
729
+ if(descs[prop][propType]){
730
+ //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
731
+ } else {
732
+ descs[prop][propType] = {};
733
+ ['value', 'set', 'get'].forEach(function(copyProp){
734
+ if(copyProp in descs[prop]){
735
+ descs[prop][propType][copyProp] = descs[prop][copyProp];
736
+ delete descs[prop][copyProp];
737
+ }
738
+ });
739
+ }
740
+ }
741
+ descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
742
+ }
743
+ if(!_noTmpCache){
744
+ initProp.flushTmpCache();
745
+ }
746
+ return descs;
747
+ },
748
+
749
+ createElement: function(nodeName, create, descs){
750
+ var ret;
751
+ if($.isFunction(create)){
752
+ create = {
753
+ after: create
754
+ };
755
+ }
756
+ initProp.createTmpCache(nodeName);
757
+ if(create.before){
758
+ initProp.createElement(nodeName, create.before);
759
+ }
760
+ if(descs){
761
+ ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
762
+ }
763
+ if(create.after){
764
+ initProp.createElement(nodeName, create.after);
765
+ }
766
+ initProp.flushTmpCache();
767
+ return ret;
768
+ },
769
+ onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
770
+ if(typeof nodeNames == 'string'){
771
+ nodeNames = nodeNames.split(listReg);
772
+ }
773
+ if($.isFunction(desc)){
774
+ desc = {set: desc};
775
+ }
776
+
777
+ nodeNames.forEach(function(name){
778
+ if(!modifyProps[name]){
779
+ modifyProps[name] = {};
780
+ }
781
+ if(typeof props == 'string'){
782
+ props = props.split(listReg);
783
+ }
784
+ if(desc.initAttr){
785
+ initProp.createTmpCache(name);
786
+ }
787
+ props.forEach(function(prop){
788
+ if(!modifyProps[name][prop]){
789
+ modifyProps[name][prop] = [];
790
+ havePolyfill[prop] = true;
791
+ }
792
+ if(desc.set){
793
+ if(only){
794
+ desc.set.only = only;
795
+ }
796
+ modifyProps[name][prop].push(desc.set);
797
+ }
798
+
799
+ if(desc.initAttr){
800
+ initProp.content(name, prop);
801
+ }
802
+ });
803
+ initProp.flushTmpCache();
804
+
805
+ });
806
+ },
807
+ defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
808
+ if(!descs){
809
+ descs = {};
810
+ }
811
+ if($.isFunction(descs)){
812
+ descs.set = descs;
813
+ }
814
+ webshims.defineNodeNamesProperty(elementNames, prop, {
815
+ attr: {
816
+ set: function(val){
817
+ this.setAttribute(prop, val);
818
+ if(descs.set){
819
+ descs.set.call(this, true);
820
+ }
821
+ },
822
+ get: function(){
823
+ var ret = this.getAttribute(prop);
824
+ return (ret == null) ? undefined : prop;
825
+ }
826
+ },
827
+ removeAttr: {
828
+ value: function(){
829
+ this.removeAttribute(prop);
830
+ if(descs.set){
831
+ descs.set.call(this, false);
832
+ }
833
+ }
834
+ },
835
+ reflect: true,
836
+ propType: 'boolean',
837
+ initAttr: descs.initAttr || false
838
+ });
839
+ },
840
+ contentAttr: function(elem, name, val){
841
+ if(!elem.nodeName){return;}
842
+ var attr;
843
+ if(val === undefined){
844
+ attr = (elem.attributes[name] || {});
845
+ val = attr.specified ? attr.value : null;
846
+ return (val == null) ? undefined : val;
847
+ }
848
+
849
+ if(typeof val == 'boolean'){
850
+ if(!val){
851
+ elem.removeAttribute(name);
852
+ } else {
853
+ elem.setAttribute(name, name);
854
+ }
855
+ } else {
856
+ elem.setAttribute(name, val);
857
+ }
858
+ },
859
+
860
+ // set current Lang:
861
+ // - webshims.activeLang(lang:string);
862
+ // get current lang
863
+ // - webshims.activeLang();
864
+ // get current lang
865
+ // webshims.activeLang({
866
+ // register: moduleName:string,
867
+ // callback: callback:function
868
+ // });
869
+ // get/set including removeLang
870
+ // - webshims.activeLang({
871
+ // module: moduleName:string,
872
+ // callback: callback:function,
873
+ // langObj: languageObj:array/object
874
+ // });
875
+ activeLang: (function(){
876
+ var callbacks = [];
877
+ var registeredCallbacks = {};
878
+ var currentLang;
879
+ var shortLang;
880
+ var notLocal = /:\/\/|^\.*\//;
881
+ var loadRemoteLang = function(data, lang, options){
882
+ var langSrc;
883
+ if(lang && options && $.inArray(lang, options.availabeLangs || []) !== -1){
884
+ data.loading = true;
885
+ langSrc = options.langSrc;
886
+ if(!notLocal.test(langSrc)){
887
+ langSrc = webshims.cfg.basePath+langSrc;
888
+ }
889
+ webshims.loader.loadScript(langSrc+lang+'.js', function(){
890
+ if(data.langObj[lang]){
891
+ data.loading = false;
892
+ callLang(data, true);
893
+ } else {
894
+ $(function(){
895
+ if(data.langObj[lang]){
896
+ callLang(data, true);
897
+ }
898
+ data.loading = false;
899
+ });
900
+ }
901
+ });
902
+ return true;
903
+ }
904
+ return false;
905
+ };
906
+ var callRegister = function(module){
907
+ if(registeredCallbacks[module]){
908
+ registeredCallbacks[module].forEach(function(data){
909
+ data.callback(currentLang, shortLang, '');
910
+ });
911
+ }
912
+ };
913
+ var callLang = function(data, _noLoop){
914
+ if(data.activeLang != currentLang && data.activeLang !== shortLang){
915
+ var options = modules[data.module].options;
916
+ if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
917
+ data.activeLang = currentLang;
918
+ data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
919
+ callRegister(data.module);
920
+ } else if( !_noLoop &&
921
+ !loadRemoteLang(data, currentLang, options) &&
922
+ !loadRemoteLang(data, shortLang, options) &&
923
+ data.langObj[''] && data.activeLang !== '' ) {
924
+ data.activeLang = '';
925
+ data.callback(data.langObj[''], currentLang);
926
+ callRegister(data.module);
927
+ }
928
+ }
929
+ };
930
+
931
+
932
+ var activeLang = function(lang){
933
+
934
+ if(typeof lang == 'string' && lang !== currentLang){
935
+ currentLang = lang;
936
+ shortLang = currentLang.split('-')[0];
937
+ if(currentLang == shortLang){
938
+ shortLang = false;
939
+ }
940
+ $.each(callbacks, function(i, data){
941
+ callLang(data);
942
+ });
943
+ } else if(typeof lang == 'object'){
944
+
945
+ if(lang.register){
946
+ if(!registeredCallbacks[lang.register]){
947
+ registeredCallbacks[lang.register] = [];
948
+ }
949
+ registeredCallbacks[lang.register].push(lang);
950
+ lang.callback(currentLang, shortLang, '');
951
+ } else {
952
+ if(!lang.activeLang){
953
+ lang.activeLang = '';
954
+ }
955
+ callbacks.push(lang);
956
+ callLang(lang);
957
+ }
958
+ }
959
+ return currentLang;
960
+ };
961
+
962
+ return activeLang;
963
+ })()
964
+ });
965
+
966
+ $.each({
967
+ defineNodeNamesProperty: 'defineNodeNameProperty',
968
+ defineNodeNamesProperties: 'defineNodeNameProperties',
969
+ createElements: 'createElement'
970
+ }, function(name, baseMethod){
971
+ webshims[name] = function(names, a, b, c){
972
+ if(typeof names == 'string'){
973
+ names = names.split(listReg);
974
+ }
975
+ var retDesc = {};
976
+ names.forEach(function(nodeName){
977
+ retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
978
+ });
979
+ return retDesc;
980
+ };
981
+ });
982
+
983
+ webshims.isReady('webshimLocalization', true);
984
+ });
985
+ //html5a11y
986
+ (function($, document){
987
+ if(!$.webshims.assumeARIA || ('content' in document.createElement('template'))){return;}
988
+
989
+ $(function(){
990
+ var main = $('main').attr({role: 'main'});
991
+ if(main.length > 1){
992
+ webshims.error('only one main element allowed in document');
993
+ } else if(main.is('article *, section *')) {
994
+ webshims.error('main not allowed inside of article/section elements');
995
+ }
996
+ });
997
+
998
+ if(('hidden' in document.createElement('a'))){
999
+ return;
1000
+ }
1001
+
1002
+ var elemMappings = {
1003
+ article: "article",
1004
+ aside: "complementary",
1005
+ section: "region",
1006
+ nav: "navigation",
1007
+ address: "contentinfo"
1008
+ };
1009
+ var addRole = function(elem, role){
1010
+ var hasRole = elem.getAttribute('role');
1011
+ if (!hasRole) {
1012
+ elem.setAttribute('role', role);
1013
+ }
1014
+ };
1015
+
1016
+
1017
+ $.webshims.addReady(function(context, contextElem){
1018
+ $.each(elemMappings, function(name, role){
1019
+ var elems = $(name, context).add(contextElem.filter(name));
1020
+ for (var i = 0, len = elems.length; i < len; i++) {
1021
+ addRole(elems[i], role);
1022
+ }
1023
+ });
1024
+ if (context === document) {
1025
+ var header = document.getElementsByTagName('header')[0];
1026
+ var footers = document.getElementsByTagName('footer');
1027
+ var footerLen = footers.length;
1028
+
1029
+ if (header && !$(header).closest('section, article')[0]) {
1030
+ addRole(header, 'banner');
1031
+ }
1032
+ if (!footerLen) {
1033
+ return;
1034
+ }
1035
+ var footer = footers[footerLen - 1];
1036
+ if (!$(footer).closest('section, article')[0]) {
1037
+ addRole(footer, 'contentinfo');
1038
+ }
1039
+ }
1040
+ });
1041
+
1042
+ })(jQuery, document);
1043
+
1044
+ //additional tests for partial implementation of forms features
1045
+ (function($){
1046
+ "use strict";
1047
+ var isWebkit = 'webkitURL' in window;
1048
+ var Modernizr = window.Modernizr;
1049
+ var webshims = $.webshims;
1050
+ var bugs = webshims.bugs;
1051
+ var form = $('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /><input required="" name="a" /></form>');
1052
+ var testRequiredFind = function(){
1053
+ if(form[0].querySelector){
1054
+ try {
1055
+ bugs.findRequired = !(form[0].querySelector('select:required'));
1056
+ } catch(er){
1057
+ bugs.findRequired = false;
1058
+ }
1059
+ }
1060
+ };
1061
+ var inputElem = $('input', form).eq(0);
1062
+ var onDomextend = function(fn){
1063
+ webshims.loader.loadList(['dom-extend']);
1064
+ webshims.ready('dom-extend', fn);
1065
+ };
1066
+
1067
+ bugs.findRequired = false;
1068
+ bugs.validationMessage = false;
1069
+
1070
+ webshims.capturingEventPrevented = function(e){
1071
+ if(!e._isPolyfilled){
1072
+ var isDefaultPrevented = e.isDefaultPrevented;
1073
+ var preventDefault = e.preventDefault;
1074
+ e.preventDefault = function(){
1075
+ clearTimeout($.data(e.target, e.type + 'DefaultPrevented'));
1076
+ $.data(e.target, e.type + 'DefaultPrevented', setTimeout(function(){
1077
+ $.removeData(e.target, e.type + 'DefaultPrevented');
1078
+ }, 30));
1079
+ return preventDefault.apply(this, arguments);
1080
+ };
1081
+ e.isDefaultPrevented = function(){
1082
+ return !!(isDefaultPrevented.apply(this, arguments) || $.data(e.target, e.type + 'DefaultPrevented') || false);
1083
+ };
1084
+ e._isPolyfilled = true;
1085
+ }
1086
+ };
1087
+
1088
+ if(!Modernizr.formvalidation || bugs.bustedValidity){
1089
+ testRequiredFind();
1090
+ } else {
1091
+ //create delegatable events
1092
+ webshims.capturingEvents(['invalid'], true);
1093
+
1094
+ if(window.opera || window.testGoodWithFix){
1095
+
1096
+ form.appendTo('head');
1097
+
1098
+ testRequiredFind();
1099
+ bugs.validationMessage = !(inputElem.prop('validationMessage'));
1100
+
1101
+ webshims.reTest(['form-native-extend', 'form-message']);
1102
+
1103
+ form.remove();
1104
+
1105
+ $(function(){
1106
+ onDomextend(function(){
1107
+
1108
+ //Opera shows native validation bubbles in case of input.checkValidity()
1109
+ // Opera 11.6/12 hasn't fixed this issue right, it's buggy
1110
+ var preventDefault = function(e){
1111
+ e.preventDefault();
1112
+ };
1113
+
1114
+ ['form', 'input', 'textarea', 'select'].forEach(function(name){
1115
+ var desc = webshims.defineNodeNameProperty(name, 'checkValidity', {
1116
+ prop: {
1117
+ value: function(){
1118
+ if (!webshims.fromSubmit) {
1119
+ $(this).on('invalid.checkvalidity', preventDefault);
1120
+ }
1121
+
1122
+ webshims.fromCheckValidity = true;
1123
+ var ret = desc.prop._supvalue.apply(this, arguments);
1124
+ if (!webshims.fromSubmit) {
1125
+ $(this).unbind('invalid.checkvalidity', preventDefault);
1126
+ }
1127
+ webshims.fromCheckValidity = false;
1128
+ return ret;
1129
+ }
1130
+ }
1131
+ });
1132
+ });
1133
+
1134
+ });
1135
+ });
1136
+ }
1137
+
1138
+ if(isWebkit && !webshims.bugs.bustedValidity){
1139
+ (function(){
1140
+ var elems = /^(?:textarea|input)$/i;
1141
+ var form = false;
1142
+
1143
+ document.addEventListener('contextmenu', function(e){
1144
+ if(elems.test( e.target.nodeName || '') && (form = e.target.form)){
1145
+ setTimeout(function(){
1146
+ form = false;
1147
+ }, 1);
1148
+ }
1149
+ }, false);
1150
+
1151
+ $(window).on('invalid', function(e){
1152
+ if(e.originalEvent && form && form == e.target.form){
1153
+ e.wrongWebkitInvalid = true;
1154
+ e.stopImmediatePropagation();
1155
+ }
1156
+ });
1157
+
1158
+ })();
1159
+ }
1160
+ }
1161
+
1162
+ $.webshims.register('form-core', function($, webshims, window, document, undefined, options){
1163
+
1164
+ var checkTypes = {checkbox: 1, radio: 1};
1165
+ var emptyJ = $([]);
1166
+ var bugs = webshims.bugs;
1167
+ var getGroupElements = function(elem){
1168
+ elem = $(elem);
1169
+ var name;
1170
+ var form;
1171
+ var ret = emptyJ;
1172
+ if(elem[0].type == 'radio'){
1173
+ form = elem.prop('form');
1174
+ name = elem[0].name;
1175
+ if(!name){
1176
+ ret = elem;
1177
+ } else if(form){
1178
+ ret = $(form[name]);
1179
+ } else {
1180
+ ret = $(document.getElementsByName(name)).filter(function(){
1181
+ return !$.prop(this, 'form');
1182
+ });
1183
+ }
1184
+ ret = ret.filter('[type="radio"]');
1185
+ }
1186
+ return ret;
1187
+ };
1188
+
1189
+ var getContentValidationMessage = webshims.getContentValidationMessage = function(elem, validity, key){
1190
+ var message = $(elem).data('errormessage') || elem.getAttribute('x-moz-errormessage') || '';
1191
+ if(key && message[key]){
1192
+ message = message[key];
1193
+ }
1194
+ if(typeof message == 'object'){
1195
+ validity = validity || $.prop(elem, 'validity') || {valid: 1};
1196
+ if(!validity.valid){
1197
+ $.each(validity, function(name, prop){
1198
+ if(prop && name != 'valid' && message[name]){
1199
+ message = message[name];
1200
+ return false;
1201
+ }
1202
+ });
1203
+ }
1204
+ }
1205
+
1206
+ if(typeof message == 'object'){
1207
+ message = message.defaultMessage;
1208
+ }
1209
+ return message || '';
1210
+ };
1211
+
1212
+ /*
1213
+ * Selectors for all browsers
1214
+ */
1215
+ var rangeTypes = {number: 1, range: 1, date: 1/*, time: 1, 'datetime-local': 1, datetime: 1, month: 1, week: 1*/};
1216
+ var hasInvalid = function(elem){
1217
+ var ret = false;
1218
+ $($.prop(elem, 'elements')).each(function(){
1219
+ ret = $(this).is(':invalid');
1220
+ if(ret){
1221
+ return false;
1222
+ }
1223
+ });
1224
+ return ret;
1225
+ };
1226
+ $.extend($.expr[":"], {
1227
+ "valid-element": function(elem){
1228
+ return $.nodeName(elem, 'form') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
1229
+ },
1230
+ "invalid-element": function(elem){
1231
+ return $.nodeName(elem, 'form') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
1232
+ },
1233
+ "required-element": function(elem){
1234
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
1235
+ },
1236
+ "user-error": function(elem){
1237
+ return ($.prop(elem, 'willValidate') && $(elem).hasClass('user-error'));
1238
+ },
1239
+ "optional-element": function(elem){
1240
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
1241
+ },
1242
+ "in-range": function(elem){
1243
+ if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1244
+ return false;
1245
+ }
1246
+ var val = $.prop(elem, 'validity');
1247
+ return !!(val && !val.rangeOverflow && !val.rangeUnderflow);
1248
+ },
1249
+ "out-of-range": function(elem){
1250
+ if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1251
+ return false;
1252
+ }
1253
+ var val = $.prop(elem, 'validity');
1254
+ return !!(val && (val.rangeOverflow || val.rangeUnderflow));
1255
+ }
1256
+
1257
+ });
1258
+
1259
+ ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
1260
+ $.expr[":"][name] = $.expr.filters[name+"-element"];
1261
+ });
1262
+
1263
+
1264
+ $.expr[":"].focus = function( elem ) {
1265
+ try {
1266
+ var doc = elem.ownerDocument;
1267
+ return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus());
1268
+ } catch(e){}
1269
+ return false;
1270
+ };
1271
+
1272
+
1273
+ var customEvents = $.event.customEvent || {};
1274
+ var isValid = function(elem){
1275
+ return ($.prop(elem, 'validity') || {valid: 1}).valid;
1276
+ };
1277
+
1278
+ if (bugs.bustedValidity || bugs.findRequired) {
1279
+ (function(){
1280
+ var find = $.find;
1281
+ var matchesSelector = $.find.matchesSelector;
1282
+
1283
+ var regExp = /(\:valid|\:invalid|\:optional|\:required|\:in-range|\:out-of-range)(?=[\s\[\~\.\+\>\:\#*]|$)/ig;
1284
+ var regFn = function(sel){
1285
+ return sel + '-element';
1286
+ };
1287
+
1288
+ $.find = (function(){
1289
+ var slice = Array.prototype.slice;
1290
+ var fn = function(sel){
1291
+ var ar = arguments;
1292
+ ar = slice.call(ar, 1, ar.length);
1293
+ ar.unshift(sel.replace(regExp, regFn));
1294
+ return find.apply(this, ar);
1295
+ };
1296
+ for (var i in find) {
1297
+ if(find.hasOwnProperty(i)){
1298
+ fn[i] = find[i];
1299
+ }
1300
+ }
1301
+ return fn;
1302
+ })();
1303
+ if(!Modernizr.prefixed || Modernizr.prefixed("matchesSelector", document.documentElement)){
1304
+ $.find.matchesSelector = function(node, expr){
1305
+ expr = expr.replace(regExp, regFn);
1306
+ return matchesSelector.call(this, node, expr);
1307
+ };
1308
+ }
1309
+
1310
+ })();
1311
+ }
1312
+
1313
+ //ToDo needs testing
1314
+ var oldAttr = $.prop;
1315
+ var changeVals = {selectedIndex: 1, value: 1, checked: 1, disabled: 1, readonly: 1};
1316
+ $.prop = function(elem, name, val){
1317
+ var ret = oldAttr.apply(this, arguments);
1318
+ if(elem && 'form' in elem && changeVals[name] && val !== undefined && $(elem).hasClass(invalidClass)){
1319
+ if(isValid(elem)){
1320
+ $(elem).getShadowElement().removeClass(invalidClass);
1321
+ if(name == 'checked' && val) {
1322
+ getGroupElements(elem).not(elem).removeClass(invalidClass).removeAttr('aria-invalid');
1323
+ }
1324
+ }
1325
+ }
1326
+ return ret;
1327
+ };
1328
+
1329
+ var returnValidityCause = function(validity, elem){
1330
+ var ret;
1331
+ $.each(validity, function(name, value){
1332
+ if(value){
1333
+ ret = (name == 'customError') ? $.prop(elem, 'validationMessage') : name;
1334
+ return false;
1335
+ }
1336
+ });
1337
+ return ret;
1338
+ };
1339
+
1340
+ var isInGroup = function(name){
1341
+ var ret;
1342
+ try {
1343
+ ret = document.activeElement.name === name;
1344
+ } catch(e){}
1345
+ return ret;
1346
+ };
1347
+ /* form-ui-invalid/form-ui-valid are deprecated. use user-error/user-success instead */
1348
+ var invalidClass = 'user-error';
1349
+ var validClass = 'user-success';
1350
+ var stopChangeTypes = {
1351
+ time: 1,
1352
+ date: 1,
1353
+ month: 1,
1354
+ datetime: 1,
1355
+ week: 1,
1356
+ 'datetime-local': 1
1357
+ };
1358
+ var switchValidityClass = function(e){
1359
+ var elem, timer;
1360
+ if(!e.target){return;}
1361
+ elem = $(e.target).getNativeElement()[0];
1362
+ if(elem.type == 'submit' || !$.prop(elem, 'willValidate')){return;}
1363
+ timer = $.data(elem, 'webshimsswitchvalidityclass');
1364
+ var switchClass = function(){
1365
+ if(e.type == 'focusout' && elem.type == 'radio' && isInGroup(elem.name)){return;}
1366
+ var validity = $.prop(elem, 'validity');
1367
+ var shadowElem = $(elem).getShadowElement();
1368
+ var addClass, removeClass, trigger, generaltrigger, validityCause;
1369
+
1370
+ if(isWebkit && e.type == 'change' && !bugs.bustedValidity && stopChangeTypes[shadowElem.prop('type')] && shadowElem.is(':focus')){return;}
1371
+
1372
+ $(elem).trigger('refreshCustomValidityRules');
1373
+
1374
+ if(validity.valid){
1375
+ if(!shadowElem.hasClass(validClass)){
1376
+ addClass = validClass;
1377
+ removeClass = invalidClass;
1378
+ generaltrigger = 'changedvaliditystate';
1379
+ trigger = 'changedvalid';
1380
+ if(checkTypes[elem.type] && elem.checked){
1381
+ getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass).removeAttr('aria-invalid');
1382
+ }
1383
+ $.removeData(elem, 'webshimsinvalidcause');
1384
+ }
1385
+ } else {
1386
+ validityCause = returnValidityCause(validity, elem);
1387
+ if($.data(elem, 'webshimsinvalidcause') != validityCause){
1388
+ $.data(elem, 'webshimsinvalidcause', validityCause);
1389
+ generaltrigger = 'changedvaliditystate';
1390
+ }
1391
+ if(!shadowElem.hasClass(invalidClass)){
1392
+ addClass = invalidClass;
1393
+ removeClass = validClass;
1394
+ if (checkTypes[elem.type] && !elem.checked) {
1395
+ getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass);
1396
+ }
1397
+ trigger = 'changedinvalid';
1398
+ }
1399
+ }
1400
+
1401
+ if(addClass){
1402
+ shadowElem.addClass(addClass).removeClass(removeClass);
1403
+ //jQuery 1.6.1 IE9 bug (doubble trigger bug)
1404
+ setTimeout(function(){
1405
+ $(elem).trigger(trigger);
1406
+ }, 0);
1407
+ }
1408
+ if(generaltrigger){
1409
+ setTimeout(function(){
1410
+ $(elem).trigger(generaltrigger);
1411
+ }, 0);
1412
+ }
1413
+
1414
+ $.removeData(elem, 'webshimsswitchvalidityclass');
1415
+ };
1416
+
1417
+ if(timer){
1418
+ clearTimeout(timer);
1419
+ }
1420
+ if(e.type == 'refreshvalidityui'){
1421
+ switchClass();
1422
+ } else {
1423
+ $.data(elem, 'webshimsswitchvalidityclass', setTimeout(switchClass, 9));
1424
+ }
1425
+ };
1426
+
1427
+ $(document).on(options.validityUIEvents || 'focusout change refreshvalidityui', switchValidityClass);
1428
+ customEvents.changedvaliditystate = true;
1429
+ customEvents.refreshCustomValidityRules = true;
1430
+ customEvents.changedvalid = true;
1431
+ customEvents.changedinvalid = true;
1432
+ customEvents.refreshvalidityui = true;
1433
+
1434
+
1435
+ webshims.triggerInlineForm = function(elem, event){
1436
+ $(elem).trigger(event);
1437
+ };
1438
+
1439
+ webshims.modules["form-core"].getGroupElements = getGroupElements;
1440
+
1441
+
1442
+ var setRoot = function(){
1443
+ webshims.scrollRoot = (isWebkit || document.compatMode == 'BackCompat') ?
1444
+ $(document.body) :
1445
+ $(document.documentElement)
1446
+ ;
1447
+ };
1448
+ var minWidth = (Modernizr.boxSizing || Modernizr['display-table'] || $.support.getSetAttribute) ?
1449
+ 'minWidth' :
1450
+ 'width'
1451
+ ;
1452
+ setRoot();
1453
+ webshims.ready('DOM', setRoot);
1454
+
1455
+ webshims.getRelOffset = function(posElem, relElem){
1456
+ posElem = $(posElem);
1457
+ var offset = $(relElem).offset();
1458
+ var bodyOffset;
1459
+ $.swap($(posElem)[0], {visibility: 'hidden', display: 'inline-block', left: 0, top: 0}, function(){
1460
+ bodyOffset = posElem.offset();
1461
+ });
1462
+ offset.top -= bodyOffset.top;
1463
+ offset.left -= bodyOffset.left;
1464
+ return offset;
1465
+ };
1466
+
1467
+ webshims.wsPopover = {
1468
+ _create: function(){
1469
+ this.options = $.extend({}, webshims.cfg.wspopover, this.options);
1470
+ this.id = webshims.wsPopover.id++;
1471
+ this.eventns = '.wsoverlay'+this.id;
1472
+ this.timers = {};
1473
+ 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>');
1474
+ this.contentElement = $('.ws-po-box', this.element);
1475
+ this.lastElement = $([]);
1476
+ this.bindElement();
1477
+
1478
+ this.element.data('wspopover', this);
1479
+
1480
+ },
1481
+ options: {},
1482
+ content: function(html){
1483
+ this.contentElement.html(html);
1484
+ },
1485
+ bindElement: function(){
1486
+ var that = this;
1487
+ var stopBlur = function(){
1488
+ that.stopBlur = false;
1489
+ };
1490
+ this.preventBlur = function(e){
1491
+ that.stopBlur = true;
1492
+ clearTimeout(that.timers.stopBlur);
1493
+ that.timers.stopBlur = setTimeout(stopBlur, 9);
1494
+ };
1495
+ this.element.on({
1496
+ 'mousedown': this.preventBlur
1497
+ });
1498
+ },
1499
+
1500
+ isInElement: function(container, contained){
1501
+ return container == contained || $.contains(container, contained);
1502
+ },
1503
+ show: function(element){
1504
+ var e = $.Event('wspopoverbeforeshow');
1505
+ this.element.trigger(e);
1506
+ if(e.isDefaultPrevented() || this.isVisible){return;}
1507
+ this.isVisible = true;
1508
+ element = $(element || this.options.prepareFor).getNativeElement() ;
1509
+
1510
+ var that = this;
1511
+ var visual = $(element).getShadowElement();
1512
+
1513
+ this.clear();
1514
+ this.element.removeClass('ws-po-visible').css('display', 'none');
1515
+
1516
+ this.prepareFor(element, visual);
1517
+
1518
+ this.position(visual);
1519
+ that.timers.show = setTimeout(function(){
1520
+ that.element.css('display', '');
1521
+ that.timers.show = setTimeout(function(){
1522
+ that.element.addClass('ws-po-visible').trigger('wspopovershow');
1523
+ }, 9);
1524
+ }, 9);
1525
+ $(document).on('focusin'+this.eventns+' mousedown'+this.eventns, function(e){
1526
+ 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)){
1527
+ that.hide();
1528
+ }
1529
+ });
1530
+ $(window).on('resize'+this.eventns + ' pospopover'+this.eventns, function(){
1531
+ clearTimeout(that.timers.repos);
1532
+ that.timers.repos = setTimeout(function(){
1533
+ that.position(visual);
1534
+ }, 900);
1535
+ });
1536
+ },
1537
+ prepareFor: function(element, visual){
1538
+ var onBlur;
1539
+ var opts = $.extend({}, this.options, $(element.prop('form') || []).data('wspopover') || {}, element.data('wspopover'));
1540
+ var that = this;
1541
+ var css = {};
1542
+ this.lastElement = $(element).getShadowFocusElement();
1543
+ if(opts.appendTo == 'element'){
1544
+ this.element.insertAfter(element);
1545
+ } else {
1546
+ this.element.appendTo(opts.appendTo);
1547
+ }
1548
+
1549
+ this.element.attr({
1550
+ 'data-class': element.prop('className'),
1551
+ 'data-id': element.prop('id')
1552
+ });
1553
+
1554
+ css[minWidth] = opts.constrainWidth ? visual.outerWidth() : '';
1555
+
1556
+ this.element.css(css);
1557
+
1558
+ if(opts.hideOnBlur){
1559
+ onBlur = function(e){
1560
+ if(that.stopBlur){
1561
+ e.stopImmediatePropagation();
1562
+ } else {
1563
+ that.hide();
1564
+ }
1565
+ };
1566
+
1567
+ that.timers.bindBlur = setTimeout(function(){
1568
+ that.lastElement.off(that.eventns).on('focusout'+that.eventns + ' blur'+that.eventns, onBlur);
1569
+ that.lastElement.getNativeElement().off(that.eventns);
1570
+ }, 10);
1571
+
1572
+
1573
+ }
1574
+
1575
+ if(!this.prepared){
1576
+
1577
+ if($.fn.bgIframe){
1578
+ this.element.bgIframe();
1579
+ }
1580
+ }
1581
+ this.prepared = true;
1582
+ },
1583
+ clear: function(){
1584
+ $(window).off(this.eventns);
1585
+ $(document).off(this.eventns);
1586
+
1587
+ this.stopBlur = false;
1588
+ $.each(this.timers, function(timerName, val){
1589
+ clearTimeout(val);
1590
+ });
1591
+ },
1592
+ hide: function(){
1593
+ var e = $.Event('wspopoverbeforehide');
1594
+ this.element.trigger(e);
1595
+ if(e.isDefaultPrevented() || !this.isVisible){return;}
1596
+ this.isVisible = false;
1597
+ var that = this;
1598
+ var forceHide = function(){
1599
+ that.element.css('display', 'none').attr({'data-id': '', 'data-class': '', 'hidden': 'hidden'});
1600
+ clearTimeout(that.timers.forcehide);
1601
+ };
1602
+ this.clear();
1603
+ this.element.removeClass('ws-po-visible').trigger('wspopoverhide');
1604
+ $(window).on('resize'+this.eventns, forceHide);
1605
+ that.timers.forcehide = setTimeout(forceHide, 999);
1606
+ },
1607
+ position: function(element){
1608
+ var offset = webshims.getRelOffset(this.element.css({marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0}).removeAttr('hidden'), element);
1609
+ offset.top += element.outerHeight();
1610
+ this.element.css({marginTop: '', marginLeft: '', marginRight: '', marginBottom: ''}).css(offset);
1611
+ }
1612
+ };
1613
+
1614
+ webshims.wsPopover.id = 0;
1615
+
1616
+ /* some extra validation UI */
1617
+ webshims.validityAlert = (function(){
1618
+
1619
+
1620
+ var focusTimer = false;
1621
+
1622
+ var api = webshims.objectCreate(webshims.wsPopover, {}, options.messagePopover);
1623
+ var boundHide = api.hide.bind(api);
1624
+
1625
+ api.element.addClass('validity-alert').attr({role: 'alert'});
1626
+ $.extend(api, {
1627
+ hideDelay: 5000,
1628
+ showFor: function(elem, message, noFocusElem, noBubble){
1629
+
1630
+ elem = $(elem).getNativeElement();
1631
+ this.clear();
1632
+ this.hide();
1633
+ if(!noBubble){
1634
+ this.getMessage(elem, message);
1635
+
1636
+ this.show(elem);
1637
+ if(this.hideDelay){
1638
+ this.timers.delayedHide = setTimeout(boundHide, this.hideDelay);
1639
+ }
1640
+
1641
+ }
1642
+
1643
+ if(!noFocusElem){
1644
+ this.setFocus(elem);
1645
+ }
1646
+ },
1647
+ setFocus: function(element){
1648
+ var focusElem = $(element).getShadowFocusElement();
1649
+ var scrollTop = webshims.scrollRoot.scrollTop();
1650
+ var elemTop = focusElem.offset().top - 30;
1651
+ var smooth;
1652
+
1653
+ if(scrollTop > elemTop){
1654
+ webshims.scrollRoot.animate(
1655
+ {scrollTop: elemTop - 5},
1656
+ {
1657
+ queue: false,
1658
+ duration: Math.max( Math.min( 600, (scrollTop - elemTop) * 1.5 ), 80 )
1659
+ }
1660
+ );
1661
+ smooth = true;
1662
+ }
1663
+ try {
1664
+ focusElem[0].focus();
1665
+ } catch(e){}
1666
+ if(smooth){
1667
+ webshims.scrollRoot.scrollTop(scrollTop);
1668
+ setTimeout(function(){
1669
+ webshims.scrollRoot.scrollTop(scrollTop);
1670
+ }, 0);
1671
+ }
1672
+
1673
+ $(window).triggerHandler('pospopover'+this.eventns);
1674
+ },
1675
+ getMessage: function(elem, message){
1676
+ if (!message) {
1677
+ message = getContentValidationMessage(elem[0]) || elem.prop('customValidationMessage') || elem.prop('validationMessage');
1678
+ }
1679
+ if (message) {
1680
+ api.contentElement.text(message);
1681
+ } else {
1682
+ this.hide();
1683
+ }
1684
+ }
1685
+ });
1686
+
1687
+
1688
+ return api;
1689
+ })();
1690
+
1691
+
1692
+ /* extension, but also used to fix native implementation workaround/bugfixes */
1693
+ (function(){
1694
+ var firstEvent,
1695
+ invalids = [],
1696
+ stopSubmitTimer,
1697
+ form
1698
+ ;
1699
+
1700
+ $(document).on('invalid', function(e){
1701
+ if(e.wrongWebkitInvalid){return;}
1702
+ var jElm = $(e.target);
1703
+ var shadowElem = jElm.getShadowElement();
1704
+ if(!shadowElem.hasClass(invalidClass)){
1705
+ shadowElem.addClass(invalidClass).removeClass(validClass);
1706
+ setTimeout(function(){
1707
+ $(e.target).trigger('changedinvalid').trigger('changedvaliditystate');
1708
+ }, 0);
1709
+ }
1710
+
1711
+ if(!firstEvent){
1712
+ //trigger firstinvalid
1713
+ firstEvent = $.Event('firstinvalid');
1714
+ firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
1715
+ var firstSystemInvalid = $.Event('firstinvalidsystem');
1716
+ $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
1717
+ jElm.trigger(firstEvent);
1718
+ }
1719
+
1720
+ //if firstinvalid was prevented all invalids will be also prevented
1721
+ if( firstEvent && firstEvent.isDefaultPrevented() ){
1722
+ e.preventDefault();
1723
+ }
1724
+ invalids.push(e.target);
1725
+ e.extraData = 'fix';
1726
+ clearTimeout(stopSubmitTimer);
1727
+ stopSubmitTimer = setTimeout(function(){
1728
+ var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
1729
+ //reset firstinvalid
1730
+ firstEvent = false;
1731
+ invalids = [];
1732
+ $(e.target).trigger(lastEvent, lastEvent);
1733
+ }, 9);
1734
+ jElm = null;
1735
+ shadowElem = null;
1736
+ });
1737
+ })();
1738
+
1739
+ $.fn.getErrorMessage = function(){
1740
+ var message = '';
1741
+ var elem = this[0];
1742
+ if(elem){
1743
+ message = getContentValidationMessage(elem) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
1744
+ }
1745
+ return message;
1746
+ };
1747
+
1748
+ if(options.replaceValidationUI){
1749
+ if(options.overrideMessages && (options.customMessages || options.customMessages == null)){
1750
+ options.customMessages = true;
1751
+ options.overrideMessages = false;
1752
+ webshims.info("set overrideMessages to false. Use customMessages instead");
1753
+ }
1754
+ webshims.ready('DOM forms', function(){
1755
+ $(document).on('firstinvalid', function(e){
1756
+ if(!e.isInvalidUIPrevented()){
1757
+ e.preventDefault();
1758
+ $.webshims.validityAlert.showFor( e.target );
1759
+ }
1760
+ });
1761
+ });
1762
+ }
1763
+ });
1764
+
1765
+ })(jQuery);
1766
+ if(!Modernizr.formvalidation || jQuery.webshims.bugs.bustedValidity){
1767
+ jQuery.webshims.register('form-shim-extend', function($, webshims, window, document){
1768
+ "use strict";
1769
+ webshims.inputTypes = webshims.inputTypes || {};
1770
+ //some helper-functions
1771
+ var cfg = webshims.cfg.forms;
1772
+ var isSubmit;
1773
+
1774
+ var isNumber = function(string){
1775
+ return (typeof string == 'number' || (string && string == string * 1));
1776
+ },
1777
+ typeModels = webshims.inputTypes,
1778
+ checkTypes = {
1779
+ radio: 1,
1780
+ checkbox: 1
1781
+ },
1782
+ getType = function(elem){
1783
+ return (elem.getAttribute('type') || elem.type || '').toLowerCase();
1784
+ }
1785
+ ;
1786
+
1787
+ //API to add new input types
1788
+ webshims.addInputType = function(type, obj){
1789
+ typeModels[type] = obj;
1790
+ };
1791
+
1792
+ //contsrain-validation-api
1793
+ var validityPrototype = {
1794
+ customError: false,
1795
+
1796
+ typeMismatch: false,
1797
+ rangeUnderflow: false,
1798
+ rangeOverflow: false,
1799
+ stepMismatch: false,
1800
+ tooLong: false,
1801
+ patternMismatch: false,
1802
+ valueMissing: false,
1803
+
1804
+ valid: true
1805
+ };
1806
+
1807
+ var isPlaceholderOptionSelected = function(select){
1808
+ if(select.type == 'select-one' && select.size < 2){
1809
+ var option = $('> option:first-child', select);
1810
+ return !!option.prop('selected');
1811
+ }
1812
+ return false;
1813
+ };
1814
+
1815
+ var validityRules = {
1816
+ valueMissing: function(input, val, cache){
1817
+ if(!input.prop('required')){return false;}
1818
+ var ret = false;
1819
+ if(!('type' in cache)){
1820
+ cache.type = getType(input[0]);
1821
+ }
1822
+ if(cache.nodeName == 'select'){
1823
+ ret = (!val && (input[0].selectedIndex < 0 || isPlaceholderOptionSelected(input[0]) ));
1824
+ } else if(checkTypes[cache.type]){
1825
+ ret = (cache.type == 'checkbox') ? !input.is(':checked') : !webshims.modules["form-core"].getGroupElements(input).filter(':checked')[0];
1826
+ } else {
1827
+ ret = !(val);
1828
+ }
1829
+ return ret;
1830
+ },
1831
+ tooLong: function(){
1832
+ return false;
1833
+ },
1834
+ typeMismatch: function (input, val, cache){
1835
+ if(val === '' || cache.nodeName == 'select'){return false;}
1836
+ var ret = false;
1837
+ if(!('type' in cache)){
1838
+ cache.type = getType(input[0]);
1839
+ }
1840
+
1841
+ if(typeModels[cache.type] && typeModels[cache.type].mismatch){
1842
+ ret = typeModels[cache.type].mismatch(val, input);
1843
+ } else if('validity' in input[0]){
1844
+ ret = input[0].validity.typeMismatch;
1845
+ }
1846
+ return ret;
1847
+ },
1848
+ patternMismatch: function(input, val, cache) {
1849
+ if(val === '' || cache.nodeName == 'select'){return false;}
1850
+ var pattern = input.attr('pattern');
1851
+ if(!pattern){return false;}
1852
+ try {
1853
+ pattern = new RegExp('^(?:' + pattern + ')$');
1854
+ } catch(er){
1855
+ webshims.error('invalid pattern value: "'+ pattern +'" | '+ er);
1856
+ pattern = false;
1857
+ }
1858
+ if(!pattern){return false;}
1859
+ return !(pattern.test(val));
1860
+ }
1861
+ }
1862
+ ;
1863
+
1864
+ webshims.addValidityRule = function(type, fn){
1865
+ validityRules[type] = fn;
1866
+ };
1867
+
1868
+ $.event.special.invalid = {
1869
+ add: function(){
1870
+ $.event.special.invalid.setup.call(this.form || this);
1871
+ },
1872
+ setup: function(){
1873
+ var form = this.form || this;
1874
+ if( $.data(form, 'invalidEventShim') ){
1875
+ form = null;
1876
+ return;
1877
+ }
1878
+ $(form)
1879
+ .data('invalidEventShim', true)
1880
+ .on('submit', $.event.special.invalid.handler)
1881
+ ;
1882
+ webshims.moveToFirstEvent(form, 'submit');
1883
+ if(webshims.bugs.bustedValidity && $.nodeName(form, 'form')){
1884
+ (function(){
1885
+ var noValidate = form.getAttribute('novalidate');
1886
+ form.setAttribute('novalidate', 'novalidate');
1887
+ webshims.data(form, 'bustedNoValidate', (noValidate == null) ? null : noValidate);
1888
+ })();
1889
+ }
1890
+ form = null;
1891
+ },
1892
+ teardown: $.noop,
1893
+ handler: function(e, d){
1894
+
1895
+ if( e.type != 'submit' || e.testedValidity || !e.originalEvent || !$.nodeName(e.target, 'form') || $.prop(e.target, 'noValidate') ){return;}
1896
+
1897
+ isSubmit = true;
1898
+ e.testedValidity = true;
1899
+ var notValid = !($(e.target).checkValidity());
1900
+ if(notValid){
1901
+ e.stopImmediatePropagation();
1902
+ isSubmit = false;
1903
+ return false;
1904
+ }
1905
+ isSubmit = false;
1906
+ }
1907
+ };
1908
+
1909
+ var addSubmitBubbles = function(form){
1910
+ if (!$.support.submitBubbles && form && typeof form == 'object' && !form._submit_attached ) {
1911
+
1912
+ $.event.add( form, 'submit._submit', function( event ) {
1913
+ event._submit_bubble = true;
1914
+ });
1915
+
1916
+ form._submit_attached = true;
1917
+ }
1918
+ };
1919
+ if(!$.support.submitBubbles && $.event.special.submit){
1920
+ $.event.special.submit.setup = function() {
1921
+ // Only need this for delegated form submit events
1922
+ if ( $.nodeName( this, "form" ) ) {
1923
+ return false;
1924
+ }
1925
+
1926
+ // Lazy-add a submit handler when a descendant form may potentially be submitted
1927
+ $.event.add( this, "click._submit keypress._submit", function( e ) {
1928
+ // Node name check avoids a VML-related crash in IE (#9807)
1929
+ var elem = e.target,
1930
+ form = $.nodeName( elem, 'input' ) || $.nodeName( elem, 'button' ) ? $.prop(elem, 'form') : undefined;
1931
+ addSubmitBubbles(form);
1932
+
1933
+ });
1934
+ // return undefined since we don't need an event listener
1935
+ };
1936
+ }
1937
+
1938
+ $.event.special.submit = $.event.special.submit || {setup: function(){return false;}};
1939
+ var submitSetup = $.event.special.submit.setup;
1940
+ $.extend($.event.special.submit, {
1941
+ setup: function(){
1942
+ if($.nodeName(this, 'form')){
1943
+ $(this).on('invalid', $.noop);
1944
+ } else {
1945
+ $('form', this).on('invalid', $.noop);
1946
+ }
1947
+ return submitSetup.apply(this, arguments);
1948
+ }
1949
+ });
1950
+
1951
+ $(window).on('invalid', $.noop);
1952
+
1953
+
1954
+ webshims.addInputType('email', {
1955
+ mismatch: (function(){
1956
+ //taken from http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
1957
+ var test = cfg.emailReg || /^[a-zA-Z0-9.!#$%&'*+-\/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
1958
+ return function(val){
1959
+ return !test.test(val);
1960
+ };
1961
+ })()
1962
+ });
1963
+
1964
+ webshims.addInputType('url', {
1965
+ mismatch: (function(){
1966
+ //taken from scott gonzales
1967
+ 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;
1968
+ return function(val){
1969
+ return !test.test(val);
1970
+ };
1971
+ })()
1972
+ });
1973
+
1974
+ webshims.defineNodeNameProperty('input', 'type', {
1975
+ prop: {
1976
+ get: function(){
1977
+ var elem = this;
1978
+ var type = (elem.getAttribute('type') || '').toLowerCase();
1979
+ return (webshims.inputTypes[type]) ? type : elem.type;
1980
+ }
1981
+ }
1982
+ });
1983
+
1984
+ // IDLs for constrain validation API
1985
+ //ToDo: add object to this list
1986
+ webshims.defineNodeNamesProperties(['button', 'fieldset', 'output'], {
1987
+ checkValidity: {
1988
+ value: function(){return true;}
1989
+ },
1990
+ willValidate: {
1991
+ value: false
1992
+ },
1993
+ setCustomValidity: {
1994
+ value: $.noop
1995
+ },
1996
+ validity: {
1997
+ writeable: false,
1998
+ get: function(){
1999
+ return $.extend({}, validityPrototype);
2000
+ }
2001
+ }
2002
+ }, 'prop');
2003
+
2004
+ var baseCheckValidity = function(elem){
2005
+ var e,
2006
+ v = $.prop(elem, 'validity')
2007
+ ;
2008
+ if(v){
2009
+ $.data(elem, 'cachedValidity', v);
2010
+ } else {
2011
+ return true;
2012
+ }
2013
+ if( !v.valid ){
2014
+ e = $.Event('invalid');
2015
+ var jElm = $(elem).trigger(e);
2016
+ if(isSubmit && !baseCheckValidity.unhandledInvalids && !e.isDefaultPrevented()){
2017
+ webshims.validityAlert.showFor(jElm);
2018
+ baseCheckValidity.unhandledInvalids = true;
2019
+ }
2020
+ }
2021
+ $.removeData(elem, 'cachedValidity');
2022
+ return v.valid;
2023
+ };
2024
+ var rsubmittable = /^(?:select|textarea|input)/i;
2025
+ webshims.defineNodeNameProperty('form', 'checkValidity', {
2026
+ prop: {
2027
+ value: function(){
2028
+
2029
+ var ret = true,
2030
+ elems = $($.prop(this, 'elements')).filter(function(){
2031
+ if(!rsubmittable.test(this.nodeName)){return false;}
2032
+ var shadowData = webshims.data(this, 'shadowData');
2033
+ return !shadowData || !shadowData.nativeElement || shadowData.nativeElement === this;
2034
+ })
2035
+ ;
2036
+
2037
+ baseCheckValidity.unhandledInvalids = false;
2038
+ for(var i = 0, len = elems.length; i < len; i++){
2039
+ if( !baseCheckValidity(elems[i]) ){
2040
+ ret = false;
2041
+ }
2042
+ }
2043
+ return ret;
2044
+ }
2045
+ }
2046
+ });
2047
+
2048
+ webshims.defineNodeNamesProperties(['input', 'textarea', 'select'], {
2049
+ checkValidity: {
2050
+ value: function(){
2051
+ baseCheckValidity.unhandledInvalids = false;
2052
+ return baseCheckValidity($(this).getNativeElement()[0]);
2053
+ }
2054
+ },
2055
+ setCustomValidity: {
2056
+ value: function(error){
2057
+ $.removeData(this, 'cachedValidity');
2058
+ webshims.data(this, 'customvalidationMessage', ''+error);
2059
+ }
2060
+ },
2061
+ willValidate: {
2062
+ writeable: false,
2063
+ get: (function(){
2064
+ var types = {
2065
+ button: 1,
2066
+ reset: 1,
2067
+ hidden: 1,
2068
+ image: 1
2069
+ }
2070
+ ;
2071
+ return function(){
2072
+ var elem = $(this).getNativeElement()[0];
2073
+ //elem.name && <- we don't use to make it easier for developers
2074
+ return !!(!elem.disabled && !elem.readOnly && !types[elem.type] );
2075
+ };
2076
+ })()
2077
+ },
2078
+ validity: {
2079
+ writeable: false,
2080
+ get: function(){
2081
+ var jElm = $(this).getNativeElement();
2082
+ var elem = jElm[0];
2083
+ var validityState = $.data(elem, 'cachedValidity');
2084
+ if(validityState){
2085
+ return validityState;
2086
+ }
2087
+ validityState = $.extend({}, validityPrototype);
2088
+
2089
+ if( !$.prop(elem, 'willValidate') || elem.type == 'submit' ){
2090
+ return validityState;
2091
+ }
2092
+ var val = jElm.val(),
2093
+ cache = {nodeName: elem.nodeName.toLowerCase()}
2094
+ ;
2095
+
2096
+ validityState.customError = !!(webshims.data(elem, 'customvalidationMessage'));
2097
+ if( validityState.customError ){
2098
+ validityState.valid = false;
2099
+ }
2100
+
2101
+ $.each(validityRules, function(rule, fn){
2102
+ if (fn(jElm, val, cache)) {
2103
+ validityState[rule] = true;
2104
+ validityState.valid = false;
2105
+ }
2106
+ });
2107
+ $(this).getShadowFocusElement().attr('aria-invalid', validityState.valid ? 'false' : 'true');
2108
+ jElm = null;
2109
+ elem = null;
2110
+ return validityState;
2111
+ }
2112
+ }
2113
+ }, 'prop');
2114
+
2115
+ webshims.defineNodeNamesBooleanProperty(['input', 'textarea', 'select'], 'required', {
2116
+ set: function(value){
2117
+ $(this).getShadowFocusElement().attr('aria-required', !!(value)+'');
2118
+ },
2119
+ initAttr: Modernizr.localstorage //only if we have aria-support
2120
+ });
2121
+
2122
+ webshims.reflectProperties(['input'], ['pattern']);
2123
+
2124
+
2125
+ if( !('maxLength' in document.createElement('textarea')) ){
2126
+ var constrainMaxLength = (function(){
2127
+ var timer;
2128
+ var curLength = 0;
2129
+ var lastElement = $([]);
2130
+ var max = 1e9;
2131
+ var constrainLength = function(){
2132
+ var nowValue = lastElement.prop('value');
2133
+ var nowLen = nowValue.length;
2134
+ if(nowLen > curLength && nowLen > max){
2135
+ nowLen = Math.max(curLength, max);
2136
+ lastElement.prop('value', nowValue.substr(0, nowLen ));
2137
+ }
2138
+ curLength = nowLen;
2139
+ };
2140
+ var remove = function(){
2141
+ clearTimeout(timer);
2142
+ lastElement.unbind('.maxlengthconstraint');
2143
+ };
2144
+ return function(element, maxLength){
2145
+ remove();
2146
+ if(maxLength > -1){
2147
+ max = maxLength;
2148
+ curLength = $.prop(element, 'value').length;
2149
+ lastElement = $(element);
2150
+ lastElement.on({
2151
+ 'keydown.maxlengthconstraint keypress.maxlengthconstraint paste.maxlengthconstraint cut.maxlengthconstraint': function(e){
2152
+ setTimeout(constrainLength, 0);
2153
+ },
2154
+ 'keyup.maxlengthconstraint': constrainLength,
2155
+ 'blur.maxlengthconstraint': remove
2156
+ });
2157
+ timer = setInterval(constrainLength, 200);
2158
+ }
2159
+ };
2160
+ })();
2161
+
2162
+ constrainMaxLength.update = function(element, maxLength){
2163
+ if($(element).is(':focus')){
2164
+ if(!maxLength){
2165
+ maxLength = $.prop(element, 'maxlength');
2166
+ }
2167
+ constrainMaxLength(element, maxLength);
2168
+ }
2169
+ };
2170
+
2171
+ $(document).on('focusin', function(e){
2172
+ var maxLength;
2173
+ if(e.target.nodeName == "TEXTAREA" && (maxLength = $.prop(e.target, 'maxlength')) > -1){
2174
+ constrainMaxLength(e.target, maxLength);
2175
+ }
2176
+ });
2177
+
2178
+ webshims.defineNodeNameProperty('textarea', 'maxlength', {
2179
+ attr: {
2180
+ set: function(val){
2181
+ this.setAttribute('maxlength', ''+val);
2182
+ constrainMaxLength.update(this);
2183
+ },
2184
+ get: function(){
2185
+ var ret = this.getAttribute('maxlength');
2186
+ return ret == null ? undefined : ret;
2187
+ }
2188
+ },
2189
+ prop: {
2190
+ set: function(val){
2191
+ if(isNumber(val)){
2192
+ if(val < 0){
2193
+ throw('INDEX_SIZE_ERR');
2194
+ }
2195
+ val = parseInt(val, 10);
2196
+ this.setAttribute('maxlength', val);
2197
+ constrainMaxLength.update(this, val);
2198
+ return;
2199
+ }
2200
+ this.setAttribute('maxlength', '0');
2201
+ constrainMaxLength.update(this, 0);
2202
+ },
2203
+ get: function(){
2204
+ var val = this.getAttribute('maxlength');
2205
+ return (isNumber(val) && val >= 0) ? parseInt(val, 10) : -1;
2206
+
2207
+ }
2208
+ }
2209
+ });
2210
+ webshims.defineNodeNameProperty('textarea', 'maxLength', {
2211
+ prop: {
2212
+ set: function(val){
2213
+ $.prop(this, 'maxlength', val);
2214
+ },
2215
+ get: function(){
2216
+ return $.prop(this, 'maxlength');
2217
+ }
2218
+ }
2219
+ });
2220
+ }
2221
+
2222
+
2223
+
2224
+ var submitterTypes = {submit: 1, button: 1, image: 1};
2225
+ var formSubmitterDescriptors = {};
2226
+ [
2227
+ {
2228
+ name: "enctype",
2229
+ limitedTo: {
2230
+ "application/x-www-form-urlencoded": 1,
2231
+ "multipart/form-data": 1,
2232
+ "text/plain": 1
2233
+ },
2234
+ defaultProp: "application/x-www-form-urlencoded",
2235
+ proptype: "enum"
2236
+ },
2237
+ {
2238
+ name: "method",
2239
+ limitedTo: {
2240
+ "get": 1,
2241
+ "post": 1
2242
+ },
2243
+ defaultProp: "get",
2244
+ proptype: "enum"
2245
+ },
2246
+ {
2247
+ name: "action",
2248
+ proptype: "url"
2249
+ },
2250
+ {
2251
+ name: "target"
2252
+ },
2253
+ {
2254
+ name: "novalidate",
2255
+ propName: "noValidate",
2256
+ proptype: "boolean"
2257
+ }
2258
+ ].forEach(function(desc){
2259
+ var propName = 'form'+ (desc.propName || desc.name).replace(/^[a-z]/, function(f){
2260
+ return f.toUpperCase();
2261
+ });
2262
+ var attrName = 'form'+ desc.name;
2263
+ var formName = desc.name;
2264
+ var eventName = 'click.webshimssubmittermutate'+formName;
2265
+
2266
+ var changeSubmitter = function(){
2267
+ var elem = this;
2268
+ if( !('form' in elem) || !submitterTypes[elem.type] ){return;}
2269
+ var form = $.prop(elem, 'form');
2270
+ if(!form){return;}
2271
+ var attr = $.attr(elem, attrName);
2272
+ if(attr != null && ( !desc.limitedTo || attr.toLowerCase() === $.prop(elem, propName))){
2273
+
2274
+ var oldAttr = $.attr(form, formName);
2275
+
2276
+ $.attr(form, formName, attr);
2277
+ setTimeout(function(){
2278
+ if(oldAttr != null){
2279
+ $.attr(form, formName, oldAttr);
2280
+ } else {
2281
+ try {
2282
+ $(form).removeAttr(formName);
2283
+ } catch(er){
2284
+ form.removeAttribute(formName);
2285
+ }
2286
+ }
2287
+ }, 9);
2288
+ }
2289
+ };
2290
+
2291
+
2292
+
2293
+ switch(desc.proptype) {
2294
+ case "url":
2295
+ var urlForm = document.createElement('form');
2296
+ formSubmitterDescriptors[propName] = {
2297
+ prop: {
2298
+ set: function(value){
2299
+ $.attr(this, attrName, value);
2300
+ },
2301
+ get: function(){
2302
+ var value = $.attr(this, attrName);
2303
+ if(value == null){return '';}
2304
+ urlForm.setAttribute('action', value);
2305
+ return urlForm.action;
2306
+ }
2307
+ }
2308
+ };
2309
+ break;
2310
+ case "boolean":
2311
+ formSubmitterDescriptors[propName] = {
2312
+ prop: {
2313
+ set: function(val){
2314
+ val = !!val;
2315
+ if(val){
2316
+ $.attr(this, 'formnovalidate', 'formnovalidate');
2317
+ } else {
2318
+ $(this).removeAttr('formnovalidate');
2319
+ }
2320
+ },
2321
+ get: function(){
2322
+ return $.attr(this, 'formnovalidate') != null;
2323
+ }
2324
+ }
2325
+ };
2326
+ break;
2327
+ case "enum":
2328
+ formSubmitterDescriptors[propName] = {
2329
+ prop: {
2330
+ set: function(value){
2331
+ $.attr(this, attrName, value);
2332
+ },
2333
+ get: function(){
2334
+ var value = $.attr(this, attrName);
2335
+ return (!value || ( (value = value.toLowerCase()) && !desc.limitedTo[value] )) ? desc.defaultProp : value;
2336
+ }
2337
+ }
2338
+ };
2339
+ break;
2340
+ default:
2341
+ formSubmitterDescriptors[propName] = {
2342
+ prop: {
2343
+ set: function(value){
2344
+ $.attr(this, attrName, value);
2345
+ },
2346
+ get: function(){
2347
+ var value = $.attr(this, attrName);
2348
+ return (value != null) ? value : "";
2349
+ }
2350
+ }
2351
+ };
2352
+ }
2353
+
2354
+
2355
+ if(!formSubmitterDescriptors[attrName]){
2356
+ formSubmitterDescriptors[attrName] = {};
2357
+ }
2358
+ formSubmitterDescriptors[attrName].attr = {
2359
+ set: function(value){
2360
+ formSubmitterDescriptors[attrName].attr._supset.call(this, value);
2361
+ $(this).unbind(eventName).on(eventName, changeSubmitter);
2362
+ },
2363
+ get: function(){
2364
+ return formSubmitterDescriptors[attrName].attr._supget.call(this);
2365
+ }
2366
+ };
2367
+ formSubmitterDescriptors[attrName].initAttr = true;
2368
+ formSubmitterDescriptors[attrName].removeAttr = {
2369
+ value: function(){
2370
+ $(this).unbind(eventName);
2371
+ formSubmitterDescriptors[attrName].removeAttr._supvalue.call(this);
2372
+ }
2373
+ };
2374
+ });
2375
+
2376
+ webshims.defineNodeNamesProperties(['input', 'button'], formSubmitterDescriptors);
2377
+
2378
+
2379
+ if(!$.support.getSetAttribute && $('<form novalidate></form>').attr('novalidate') == null){
2380
+ webshims.defineNodeNameProperty('form', 'novalidate', {
2381
+ attr: {
2382
+ set: function(val){
2383
+ this.setAttribute('novalidate', ''+val);
2384
+ },
2385
+ get: function(){
2386
+ var ret = this.getAttribute('novalidate');
2387
+ return ret == null ? undefined : ret;
2388
+ }
2389
+ }
2390
+ });
2391
+ } else if(webshims.bugs.bustedValidity){
2392
+
2393
+ webshims.defineNodeNameProperty('form', 'novalidate', {
2394
+ attr: {
2395
+ set: function(val){
2396
+ webshims.data(this, 'bustedNoValidate', ''+val);
2397
+ },
2398
+ get: function(){
2399
+ var ret = webshims.data(this, 'bustedNoValidate');
2400
+ return ret == null ? undefined : ret;
2401
+ }
2402
+ },
2403
+ removeAttr: {
2404
+ value: function(){
2405
+ webshims.data(this, 'bustedNoValidate', null);
2406
+ }
2407
+ }
2408
+ });
2409
+
2410
+ $.each(['rangeUnderflow', 'rangeOverflow', 'stepMismatch'], function(i, name){
2411
+ validityRules[name] = function(elem){
2412
+ return (elem[0].validity || {})[name] || false;
2413
+ };
2414
+ });
2415
+
2416
+ }
2417
+
2418
+ webshims.defineNodeNameProperty('form', 'noValidate', {
2419
+ prop: {
2420
+ set: function(val){
2421
+ val = !!val;
2422
+ if(val){
2423
+ $.attr(this, 'novalidate', 'novalidate');
2424
+ } else {
2425
+ $(this).removeAttr('novalidate');
2426
+ }
2427
+ },
2428
+ get: function(){
2429
+ return $.attr(this, 'novalidate') != null;
2430
+ }
2431
+ }
2432
+ });
2433
+
2434
+ if(Modernizr.inputtypes.date && /webkit/i.test(navigator.userAgent)){
2435
+ (function(){
2436
+
2437
+ var noInputTriggerEvts = {updateInput: 1, input: 1},
2438
+ fixInputTypes = {
2439
+ date: 1,
2440
+ time: 1,
2441
+ "datetime-local": 1
2442
+ },
2443
+ noFocusEvents = {
2444
+ focusout: 1,
2445
+ blur: 1
2446
+ },
2447
+ changeEvts = {
2448
+ updateInput: 1,
2449
+ change: 1
2450
+ },
2451
+ observe = function(input){
2452
+ var timer,
2453
+ focusedin = true,
2454
+ lastInputVal = input.prop('value'),
2455
+ lastChangeVal = lastInputVal,
2456
+ trigger = function(e){
2457
+ //input === null
2458
+ if(!input){return;}
2459
+ var newVal = input.prop('value');
2460
+
2461
+ if(newVal !== lastInputVal){
2462
+ lastInputVal = newVal;
2463
+ if(!e || !noInputTriggerEvts[e.type]){
2464
+ input.trigger('input');
2465
+ }
2466
+ }
2467
+ if(e && changeEvts[e.type]){
2468
+ lastChangeVal = newVal;
2469
+ }
2470
+ if(!focusedin && newVal !== lastChangeVal){
2471
+ input.trigger('change');
2472
+ }
2473
+ },
2474
+ extraTimer,
2475
+ extraTest = function(){
2476
+ clearTimeout(extraTimer);
2477
+ extraTimer = setTimeout(trigger, 9);
2478
+ },
2479
+ unbind = function(e){
2480
+ clearInterval(timer);
2481
+ setTimeout(function(){
2482
+ if(e && noFocusEvents[e.type]){
2483
+ focusedin = false;
2484
+ }
2485
+ if(input){
2486
+ input.unbind('focusout blur', unbind).unbind('input change updateInput', trigger);
2487
+ trigger();
2488
+ }
2489
+ input = null;
2490
+ }, 1);
2491
+
2492
+ }
2493
+ ;
2494
+
2495
+ clearInterval(timer);
2496
+ timer = setInterval(trigger, 160);
2497
+ extraTest();
2498
+ input
2499
+ .off({
2500
+ 'focusout blur': unbind,
2501
+ 'input change updateInput': trigger
2502
+ })
2503
+ .on({
2504
+ 'focusout blur': unbind,
2505
+ 'input updateInput change': trigger
2506
+ })
2507
+ ;
2508
+ }
2509
+ ;
2510
+ if($.event.customEvent){
2511
+ $.event.customEvent.updateInput = true;
2512
+ }
2513
+
2514
+ (function(){
2515
+
2516
+ var correctValue = function(elem){
2517
+ var i = 1;
2518
+ var len = 3;
2519
+ var abort, val;
2520
+ if(elem.type == 'date' && (isSubmit || !$(elem).is(':focus'))){
2521
+ val = elem.value;
2522
+ if(val && val.length < 10 && (val = val.split('-')) && val.length == len){
2523
+ for(; i < len; i++){
2524
+ if(val[i].length == 1){
2525
+ val[i] = '0'+val[i];
2526
+ } else if(val[i].length != 2){
2527
+ abort = true;
2528
+ break;
2529
+ }
2530
+ }
2531
+ if(!abort){
2532
+ val = val.join('-');
2533
+ $.prop(elem, 'value', val);
2534
+ return val;
2535
+ }
2536
+ }
2537
+ }
2538
+ };
2539
+ var inputCheckValidityDesc, formCheckValidityDesc, inputValueDesc, inputValidityDesc;
2540
+
2541
+ inputCheckValidityDesc = webshims.defineNodeNameProperty('input', 'checkValidity', {
2542
+ prop: {
2543
+ value: function(){
2544
+ correctValue(this);
2545
+ return inputCheckValidityDesc.prop._supvalue.apply(this, arguments);
2546
+ }
2547
+ }
2548
+ });
2549
+
2550
+ formCheckValidityDesc = webshims.defineNodeNameProperty('form', 'checkValidity', {
2551
+ prop: {
2552
+ value: function(){
2553
+ $('input', this).each(function(){
2554
+ correctValue(this);
2555
+ });
2556
+ return formCheckValidityDesc.prop._supvalue.apply(this, arguments);
2557
+ }
2558
+ }
2559
+ });
2560
+
2561
+ inputValueDesc = webshims.defineNodeNameProperty('input', 'value', {
2562
+ prop: {
2563
+ set: function(){
2564
+ return inputValueDesc.prop._supset.apply(this, arguments);
2565
+ },
2566
+ get: function(){
2567
+ return correctValue(this) || inputValueDesc.prop._supget.apply(this, arguments);
2568
+ }
2569
+ }
2570
+ });
2571
+
2572
+ inputValidityDesc = webshims.defineNodeNameProperty('input', 'validity', {
2573
+ prop: {
2574
+ writeable: false,
2575
+ get: function(){
2576
+ correctValue(this);
2577
+ return inputValidityDesc.prop._supget.apply(this, arguments);
2578
+ }
2579
+ }
2580
+ });
2581
+
2582
+ $(document).on('change', function(e){
2583
+ correctValue(e.target);
2584
+ });
2585
+
2586
+ })();
2587
+
2588
+ $(document)
2589
+ .on('focusin', function(e){
2590
+ if( e.target && fixInputTypes[e.target.type] && !e.target.readOnly && !e.target.disabled ){
2591
+ observe($(e.target));
2592
+ }
2593
+ })
2594
+ ;
2595
+
2596
+
2597
+ })();
2598
+ }
2599
+
2600
+ webshims.addReady(function(context, contextElem){
2601
+ //start constrain-validation
2602
+ var focusElem;
2603
+ $('form', context)
2604
+ .add(contextElem.filter('form'))
2605
+ .bind('invalid', $.noop)
2606
+ ;
2607
+
2608
+ try {
2609
+ if(context == document && !('form' in (document.activeElement || {}))) {
2610
+ focusElem = $('input[autofocus], select[autofocus], textarea[autofocus]', context).eq(0).getShadowFocusElement()[0];
2611
+ if (focusElem && focusElem.offsetHeight && focusElem.offsetWidth) {
2612
+ focusElem.focus();
2613
+ }
2614
+ }
2615
+ }
2616
+ catch (er) {}
2617
+
2618
+ });
2619
+
2620
+ if(!Modernizr.formattribute || !Modernizr.fieldsetdisabled){
2621
+ (function(){
2622
+ (function(prop, undefined){
2623
+ $.prop = function(elem, name, value){
2624
+ var ret;
2625
+ if(elem && elem.nodeType == 1 && value === undefined && $.nodeName(elem, 'form') && elem.id){
2626
+ ret = document.getElementsByName(name);
2627
+ if(!ret || !ret.length){
2628
+ ret = document.getElementById(name);
2629
+ }
2630
+ if(ret){
2631
+ ret = $(ret).filter(function(){
2632
+ return $.prop(this, 'form') == elem;
2633
+ }).get();
2634
+ if(ret.length){
2635
+ return ret.length == 1 ? ret[0] : ret;
2636
+ }
2637
+ }
2638
+ }
2639
+ return prop.apply(this, arguments);
2640
+ };
2641
+ })($.prop, undefined);
2642
+ var removeAddedElements = function(form){
2643
+ var elements = $.data(form, 'webshimsAddedElements');
2644
+ if(elements){
2645
+ elements.remove();
2646
+ $.removeData(form, 'webshimsAddedElements');
2647
+ }
2648
+ };
2649
+
2650
+
2651
+ if(!Modernizr.formattribute){
2652
+ webshims.defineNodeNamesProperty(['input', 'textarea', 'select', 'button', 'fieldset'], 'form', {
2653
+ prop: {
2654
+ get: function(){
2655
+ var form = webshims.contentAttr(this, 'form');
2656
+ if(form){
2657
+ form = document.getElementById(form);
2658
+ if(form && !$.nodeName(form, 'form')){
2659
+ form = null;
2660
+ }
2661
+ }
2662
+ return form || this.form;
2663
+ },
2664
+ writeable: false
2665
+ }
2666
+ });
2667
+
2668
+
2669
+ webshims.defineNodeNamesProperty(['form'], 'elements', {
2670
+ prop: {
2671
+ get: function(){
2672
+ var id = this.id;
2673
+ var elements = $.makeArray(this.elements);
2674
+ if(id){
2675
+ elements = $(elements).add('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"], button[form="'+ id +'"], fieldset[form="'+ id +'"]').not('.webshims-visual-hide > *').get();
2676
+ }
2677
+ return elements;
2678
+ },
2679
+ writeable: false
2680
+ }
2681
+ });
2682
+
2683
+
2684
+
2685
+ $(function(){
2686
+ var stopPropagation = function(e){
2687
+ e.stopPropagation();
2688
+ };
2689
+ $(document).on('submit', function(e){
2690
+
2691
+ if(!e.isDefaultPrevented()){
2692
+ var form = e.target;
2693
+ var id = form.id;
2694
+ var elements;
2695
+
2696
+
2697
+ if(id){
2698
+ removeAddedElements(form);
2699
+
2700
+ elements = $('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"]')
2701
+ .filter(function(){
2702
+ return !this.disabled && this.name && this.form != form;
2703
+ })
2704
+ .clone()
2705
+ ;
2706
+ if(elements.length){
2707
+ $.data(form, 'webshimsAddedElements', $('<div class="webshims-visual-hide" />').append(elements).appendTo(form));
2708
+ setTimeout(function(){
2709
+ removeAddedElements(form);
2710
+ }, 9);
2711
+ }
2712
+ elements = null;
2713
+ }
2714
+ }
2715
+ });
2716
+
2717
+ $(document).on('click', function(e){
2718
+ if(!e.isDefaultPrevented() && $(e.target).is('input[type="submit"][form], button[form], input[type="button"][form], input[type="image"][form], input[type="reset"][form]')){
2719
+ var trueForm = $.prop(e.target, 'form');
2720
+ var formIn = e.target.form;
2721
+ var clone;
2722
+ if(trueForm && trueForm != formIn){
2723
+ clone = $(e.target)
2724
+ .clone()
2725
+ .removeAttr('form')
2726
+ .addClass('webshims-visual-hide')
2727
+ .on('click', stopPropagation)
2728
+ .appendTo(trueForm)
2729
+ ;
2730
+ if(formIn){
2731
+ e.preventDefault();
2732
+ }
2733
+ addSubmitBubbles(trueForm);
2734
+ clone.trigger('click');
2735
+ setTimeout(function(){
2736
+ clone.remove();
2737
+ clone = null;
2738
+ }, 9);
2739
+ }
2740
+ }
2741
+ });
2742
+ });
2743
+ }
2744
+
2745
+ if(!Modernizr.fieldsetdisabled){
2746
+ webshims.defineNodeNamesProperty(['fieldset'], 'elements', {
2747
+ prop: {
2748
+ get: function(){
2749
+ //add listed elements without keygen, object, output
2750
+ return $('input, select, textarea, button, fieldset', this).get() || [];
2751
+ },
2752
+ writeable: false
2753
+ }
2754
+ });
2755
+ }
2756
+
2757
+ if(!$.fn.finish && parseFloat($.fn.jquery, 10) < 1.9){
2758
+ var rCRLF = /\r?\n/g,
2759
+ rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
2760
+ rselectTextarea = /^(?:select|textarea)/i;
2761
+ $.fn.serializeArray = function() {
2762
+ return this.map(function(){
2763
+ var elements = $.prop(this, 'elements');
2764
+ return elements ? $.makeArray( elements ) : this;
2765
+ })
2766
+ .filter(function(){
2767
+ return this.name && !this.disabled &&
2768
+ ( this.checked || rselectTextarea.test( this.nodeName ) ||
2769
+ rinput.test( this.type ) );
2770
+ })
2771
+ .map(function( i, elem ){
2772
+ var val = $( this ).val();
2773
+
2774
+ return val == null ?
2775
+ null :
2776
+ $.isArray( val ) ?
2777
+ $.map( val, function( val, i ){
2778
+ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
2779
+ }) :
2780
+ { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
2781
+ }).get();
2782
+ };
2783
+ }
2784
+
2785
+ })();
2786
+ }
2787
+
2788
+ if($('<input />').prop('labels') == null){
2789
+ webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
2790
+ prop: {
2791
+ get: function(){
2792
+ if(this.type == 'hidden'){return null;}
2793
+ var id = this.id;
2794
+ var labels = $(this)
2795
+ .closest('label')
2796
+ .filter(function(){
2797
+ var hFor = (this.attributes['for'] || {});
2798
+ return (!hFor.specified || hFor.value == id);
2799
+ })
2800
+ ;
2801
+
2802
+ if(id) {
2803
+ labels = labels.add('label[for="'+ id +'"]');
2804
+ }
2805
+ return labels.get();
2806
+ },
2807
+ writeable: false
2808
+ }
2809
+ });
2810
+ }
2811
+
2812
+ if(!('value' in document.createElement('progress'))){
2813
+ (function(){
2814
+
2815
+ var nan = parseInt('NaN', 10);
2816
+
2817
+ var updateProgress = function(progress){
2818
+ var position;
2819
+
2820
+
2821
+ position = $.prop(progress, 'position');
2822
+
2823
+ $.attr(progress, 'data-position', position);
2824
+ $('> span', progress).css({width: (position < 0 ? 100 : position * 100) +'%'});
2825
+ };
2826
+ var desc = {
2827
+ position: {
2828
+ prop: {
2829
+ get: function(){
2830
+ var max;
2831
+ //jQuery 1.8.x try's to normalize "0" to 0
2832
+ var val = this.getAttribute('value');
2833
+ var ret = -1;
2834
+
2835
+ val = val ? (val * 1) : nan;
2836
+ if(!isNaN(val)){
2837
+ max = $.prop(this, 'max');
2838
+ ret = Math.max(Math.min(val / max, 1), 0);
2839
+ if(updateProgress.isInChange){
2840
+ $.attr(this, 'aria-valuenow', ret * 100);
2841
+ if(updateProgress.isInChange == 'max'){
2842
+ $.attr(this, 'aria-valuemax', max);
2843
+ }
2844
+ }
2845
+ } else if(updateProgress.isInChange) {
2846
+ $(this).removeAttr('aria-valuenow');
2847
+ }
2848
+ return ret;
2849
+ },
2850
+ writeable: false
2851
+ }
2852
+ }
2853
+ };
2854
+
2855
+ $.each({value: 0, max: 1}, function(name, defValue){
2856
+ var removeProp = (name == 'value' && !$.fn.finish);
2857
+ desc[name] = {
2858
+ attr: {
2859
+ set: function(value){
2860
+ var ret = desc[name].attr._supset.call(this, value);
2861
+ updateProgress.isInChange = name;
2862
+ updateProgress(this);
2863
+ updateProgress.isInChange = false;
2864
+ return ret;
2865
+ }
2866
+ },
2867
+ removeAttr: {
2868
+ value: function(){
2869
+ this.removeAttribute(name);
2870
+ if(removeProp){
2871
+ delete this.value;
2872
+ }
2873
+ updateProgress.isInChange = name;
2874
+ updateProgress(this);
2875
+ updateProgress.isInChange = false;
2876
+ }
2877
+ },
2878
+ prop: {
2879
+ get: function(){
2880
+ var max;
2881
+ var ret = (desc[name].attr.get.call(this) * 1);
2882
+ if(ret < 0 || isNaN(ret)){
2883
+ ret = defValue;
2884
+ } else if(name == 'value'){
2885
+ ret = Math.min(ret, $.prop(this, 'max'));
2886
+ } else if(ret === 0){
2887
+ ret = defValue;
2888
+ }
2889
+ return ret;
2890
+ },
2891
+ set: function(value){
2892
+ value = value * 1;
2893
+ if(isNaN(value)){
2894
+ webshims.error('Floating-point value is not finite.');
2895
+ }
2896
+ return desc[name].attr.set.call(this, value);
2897
+ }
2898
+ }
2899
+ };
2900
+ });
2901
+
2902
+ webshims.createElement(
2903
+ 'progress',
2904
+ function(){
2905
+ var labels = $(this)
2906
+ .attr({role: 'progressbar', 'aria-valuemin': '0'})
2907
+ .html('<span class="progress-value" />')
2908
+ .jProp('labels')
2909
+ .map(function(){
2910
+ return webshims.getID(this);
2911
+ })
2912
+ .get()
2913
+ ;
2914
+ if(labels.length){
2915
+ $.attr(this, 'aria-labelledby', labels.join(' '));
2916
+ } else {
2917
+ webshims.info("you should use label elements for your prgogress elements");
2918
+ }
2919
+
2920
+ updateProgress.isInChange = 'max';
2921
+ updateProgress(this);
2922
+ updateProgress.isInChange = false;
2923
+ },
2924
+ desc
2925
+ );
2926
+
2927
+ })();
2928
+ }
2929
+
2930
+ try {
2931
+ document.querySelector(':checked');
2932
+ } catch(er){
2933
+ (function(){
2934
+ $('html').addClass('no-csschecked');
2935
+ var checkInputs = {
2936
+ radio: 1,
2937
+ checkbox: 1
2938
+ };
2939
+ var selectChange = function(){
2940
+ var options = this.options || [];
2941
+ var i, len, option;
2942
+ for(i = 0, len = options.length; i < len; i++){
2943
+ option = $(options[i]);
2944
+ option[$.prop(options[i], 'selected') ? 'addClass' : 'removeClass']('prop-checked');
2945
+ }
2946
+ };
2947
+ var checkChange = function(){
2948
+ var fn = $.prop(this, 'checked') ? 'addClass' : 'removeClass';
2949
+ var className = this.className || '';
2950
+ var parent;
2951
+
2952
+ //IE8- has problems to update styles, we help
2953
+ if( (className.indexOf('prop-checked') == -1) == (fn == 'addClass')){
2954
+ $(this)[fn]('prop-checked');
2955
+ if((parent = this.parentNode)){
2956
+ parent.className = parent.className;
2957
+ }
2958
+ }
2959
+ };
2960
+
2961
+
2962
+ webshims.onNodeNamesPropertyModify('select', 'value', selectChange);
2963
+ webshims.onNodeNamesPropertyModify('select', 'selectedIndex', selectChange);
2964
+ webshims.onNodeNamesPropertyModify('option', 'selected', function(){
2965
+ $(this).closest('select').each(selectChange);
2966
+ });
2967
+ webshims.onNodeNamesPropertyModify('input', 'checked', function(value, boolVal){
2968
+ var type = this.type;
2969
+ if(type == 'radio' && boolVal){
2970
+ webshims.modules["form-core"].getGroupElements(this).each(checkChange);
2971
+ } else if(checkInputs[type]) {
2972
+ $(this).each(checkChange);
2973
+ }
2974
+ });
2975
+
2976
+ $(document).on('change', function(e){
2977
+
2978
+ if(checkInputs[e.target.type]){
2979
+ if(e.target.type == 'radio'){
2980
+ webshims.modules["form-core"].getGroupElements(e.target).each(checkChange);
2981
+ } else {
2982
+ $(e.target)[$.prop(e.target, 'checked') ? 'addClass' : 'removeClass']('prop-checked');
2983
+ }
2984
+ } else if(e.target.nodeName.toLowerCase() == 'select'){
2985
+ $(e.target).each(selectChange);
2986
+ }
2987
+ });
2988
+
2989
+ webshims.addReady(function(context, contextElem){
2990
+ $('option, input', context)
2991
+ .add(contextElem.filter('option, input'))
2992
+ .each(function(){
2993
+ var prop;
2994
+ if(checkInputs[this.type]){
2995
+ prop = 'checked';
2996
+ } else if(this.nodeName.toLowerCase() == 'option'){
2997
+ prop = 'selected';
2998
+ }
2999
+ if(prop){
3000
+ $(this)[$.prop(this, prop) ? 'addClass' : 'removeClass']('prop-checked');
3001
+ }
3002
+
3003
+ })
3004
+ ;
3005
+ });
3006
+ })();
3007
+ }
3008
+
3009
+ (function(){
3010
+ Modernizr.textareaPlaceholder = !!('placeholder' in $('<textarea />')[0]);
3011
+ if(Modernizr.input.placeholder && Modernizr.textareaPlaceholder){return;}
3012
+
3013
+ var isOver = (webshims.cfg.forms.placeholderType == 'over');
3014
+ var isResponsive = (webshims.cfg.forms.responsivePlaceholder);
3015
+ var polyfillElements = ['textarea'];
3016
+ if(!Modernizr.input.placeholder){
3017
+ polyfillElements.push('input');
3018
+ }
3019
+
3020
+ var setSelection = function(elem){
3021
+ try {
3022
+ if(elem.setSelectionRange){
3023
+ elem.setSelectionRange(0, 0);
3024
+ return true;
3025
+ } else if(elem.createTextRange){
3026
+ var range = elem.createTextRange();
3027
+ range.collapse(true);
3028
+ range.moveEnd('character', 0);
3029
+ range.moveStart('character', 0);
3030
+ range.select();
3031
+ return true;
3032
+ }
3033
+ } catch(er){}
3034
+ };
3035
+
3036
+ var hidePlaceholder = function(elem, data, value, _onFocus){
3037
+ if(value === false){
3038
+ value = $.prop(elem, 'value');
3039
+ }
3040
+
3041
+ if(!isOver && elem.type != 'password'){
3042
+ if(!value && _onFocus && setSelection(elem)){
3043
+ var selectTimer = setTimeout(function(){
3044
+ setSelection(elem);
3045
+ }, 9);
3046
+ $(elem)
3047
+ .off('.placeholderremove')
3048
+ .on({
3049
+ 'keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove': function(e){
3050
+ if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
3051
+ elem.value = $.prop(elem, 'value');
3052
+ data.box.removeClass('placeholder-visible');
3053
+ clearTimeout(selectTimer);
3054
+ $(elem).unbind('.placeholderremove');
3055
+ },
3056
+ 'mousedown.placeholderremove drag.placeholderremove select.placeholderremove': function(e){
3057
+ setSelection(elem);
3058
+ clearTimeout(selectTimer);
3059
+ selectTimer = setTimeout(function(){
3060
+ setSelection(elem);
3061
+ }, 9);
3062
+ },
3063
+ 'blur.placeholderremove': function(){
3064
+ clearTimeout(selectTimer);
3065
+ $(elem).unbind('.placeholderremove');
3066
+ }
3067
+ })
3068
+ ;
3069
+ return;
3070
+ } else if(!_onFocus && !value && elem.value){ //especially on submit
3071
+ elem.value = value;
3072
+ }
3073
+ } else if(!value && _onFocus){
3074
+ $(elem)
3075
+ .off('.placeholderremove')
3076
+ .on({
3077
+ 'keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove': function(e){
3078
+ if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
3079
+ data.box.removeClass('placeholder-visible');
3080
+ $(elem).unbind('.placeholderremove');
3081
+ },
3082
+ 'blur.placeholderremove': function(){
3083
+ $(elem).unbind('.placeholderremove');
3084
+ }
3085
+ })
3086
+ ;
3087
+ return;
3088
+ }
3089
+ data.box.removeClass('placeholder-visible');
3090
+ },
3091
+ showPlaceholder = function(elem, data, placeholderTxt){
3092
+ if(placeholderTxt === false){
3093
+ placeholderTxt = $.prop(elem, 'placeholder');
3094
+ }
3095
+
3096
+ if(!isOver && elem.type != 'password'){
3097
+ elem.value = placeholderTxt;
3098
+ }
3099
+ data.box.addClass('placeholder-visible');
3100
+ },
3101
+ changePlaceholderVisibility = function(elem, value, placeholderTxt, data, type){
3102
+ if(!data){
3103
+ data = $.data(elem, 'placeHolder');
3104
+ if(!data){return;}
3105
+ }
3106
+ $(elem).unbind('.placeholderremove');
3107
+
3108
+ if(value === false){
3109
+ value = $.prop(elem, 'value');
3110
+ }
3111
+
3112
+ if(!value && (type == 'focus' || (!type && $(elem).is(':focus')))){
3113
+ if(elem.type == 'password' || isOver || $(elem).hasClass('placeholder-visible')){
3114
+ hidePlaceholder(elem, data, '', true);
3115
+ }
3116
+ return;
3117
+ }
3118
+
3119
+ if(value){
3120
+ hidePlaceholder(elem, data, value);
3121
+ return;
3122
+ }
3123
+ if(placeholderTxt === false){
3124
+ placeholderTxt = $.attr(elem, 'placeholder') || '';
3125
+ }
3126
+ if(placeholderTxt && !value){
3127
+ showPlaceholder(elem, data, placeholderTxt);
3128
+ } else {
3129
+ hidePlaceholder(elem, data, value);
3130
+ }
3131
+ },
3132
+ hasLabel = function(elem){
3133
+ elem = $(elem);
3134
+ return !!(elem.prop('title') || elem.attr('aria-labelledby') || elem.attr('aria-label') || elem.jProp('labels').length);
3135
+ },
3136
+ createPlaceholder = function(elem){
3137
+ elem = $(elem);
3138
+ return $( hasLabel(elem) ? '<span class="placeholder-text"></span>' : '<label for="'+ elem.prop('id') +'" class="placeholder-text"></label>');
3139
+ },
3140
+ pHolder = (function(){
3141
+ var delReg = /\n|\r|\f|\t/g,
3142
+ allowedPlaceholder = {
3143
+ text: 1,
3144
+ search: 1,
3145
+ url: 1,
3146
+ email: 1,
3147
+ password: 1,
3148
+ tel: 1,
3149
+ number: 1
3150
+ }
3151
+ ;
3152
+
3153
+ if(webshims.modules["form-number-date-ui"].loaded){
3154
+ delete allowedPlaceholder.number;
3155
+ }
3156
+
3157
+ return {
3158
+ create: function(elem){
3159
+ var data = $.data(elem, 'placeHolder');
3160
+ var form;
3161
+ var responsiveElem;
3162
+ if(data){return data;}
3163
+ data = $.data(elem, 'placeHolder', {});
3164
+
3165
+ $(elem).on('focus.placeholder blur.placeholder', function(e){
3166
+ changePlaceholderVisibility(this, false, false, data, e.type );
3167
+ data.box[e.type == 'focus' ? 'addClass' : 'removeClass']('placeholder-focused');
3168
+ });
3169
+
3170
+ if((form = $.prop(elem, 'form'))){
3171
+ $(form).on('reset.placeholder', function(e){
3172
+ setTimeout(function(){
3173
+ changePlaceholderVisibility(elem, false, false, data, e.type );
3174
+ }, 0);
3175
+ });
3176
+ }
3177
+
3178
+ if(elem.type == 'password' || isOver){
3179
+ data.text = createPlaceholder(elem);
3180
+ if(isResponsive || $(elem).is('.responsive-width') || (elem.currentStyle || {width: ''}).width.indexOf('%') != -1){
3181
+ responsiveElem = true;
3182
+ data.box = data.text;
3183
+ } else {
3184
+ data.box = $(elem)
3185
+ .wrap('<span class="placeholder-box placeholder-box-'+ (elem.nodeName || '').toLowerCase() +' placeholder-box-'+$.css(elem, 'float')+'" />')
3186
+ .parent()
3187
+ ;
3188
+ }
3189
+ data.text
3190
+ .insertAfter(elem)
3191
+ .on('mousedown.placeholder', function(){
3192
+ changePlaceholderVisibility(this, false, false, data, 'focus');
3193
+ try {
3194
+ setTimeout(function(){
3195
+ elem.focus();
3196
+ }, 0);
3197
+ } catch(e){}
3198
+ return false;
3199
+ })
3200
+ ;
3201
+
3202
+
3203
+ $.each(['lineHeight', 'fontSize', 'fontFamily', 'fontWeight'], function(i, style){
3204
+ var prop = $.css(elem, style);
3205
+ if(data.text.css(style) != prop){
3206
+ data.text.css(style, prop);
3207
+ }
3208
+ });
3209
+ $.each(['Left', 'Top'], function(i, side){
3210
+ 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);
3211
+ data.text.css('padding'+ side, size);
3212
+ });
3213
+
3214
+ $(document)
3215
+ .onTrigger('updateshadowdom', function(){
3216
+ var height, width;
3217
+ if((width = elem.offsetWidth) || (height = elem.offsetHeight)){
3218
+ data.text
3219
+ .css({
3220
+ width: width,
3221
+ height: height
3222
+ })
3223
+ .css($(elem).position())
3224
+ ;
3225
+ }
3226
+ })
3227
+ ;
3228
+
3229
+ } else {
3230
+ var reset = function(e){
3231
+ if($(elem).hasClass('placeholder-visible')){
3232
+ hidePlaceholder(elem, data, '');
3233
+ if(e && e.type == 'submit'){
3234
+ setTimeout(function(){
3235
+ if(e.isDefaultPrevented()){
3236
+ changePlaceholderVisibility(elem, false, false, data );
3237
+ }
3238
+ }, 9);
3239
+ }
3240
+ }
3241
+ };
3242
+
3243
+ $(window).on('beforeunload', reset);
3244
+ data.box = $(elem);
3245
+ if(form){
3246
+ $(form).submit(reset);
3247
+ }
3248
+ }
3249
+
3250
+ return data;
3251
+ },
3252
+ update: function(elem, val){
3253
+ var type = ($.attr(elem, 'type') || $.prop(elem, 'type') || '').toLowerCase();
3254
+ if(!allowedPlaceholder[type] && !$.nodeName(elem, 'textarea')){
3255
+ webshims.warn('placeholder not allowed on input[type="'+type+'"], but it is a good fallback :-)');
3256
+ return;
3257
+ }
3258
+
3259
+
3260
+ var data = pHolder.create(elem);
3261
+ if(data.text){
3262
+ data.text.text(val);
3263
+ }
3264
+
3265
+ changePlaceholderVisibility(elem, false, val, data);
3266
+ }
3267
+ };
3268
+ })()
3269
+ ;
3270
+
3271
+ $.webshims.publicMethods = {
3272
+ pHolder: pHolder
3273
+ };
3274
+ polyfillElements.forEach(function(nodeName){
3275
+ var desc = webshims.defineNodeNameProperty(nodeName, 'placeholder', {
3276
+ attr: {
3277
+ set: function(val){
3278
+ var elem = this;
3279
+ webshims.contentAttr(elem, 'placeholder', val);
3280
+ pHolder.update(elem, val);
3281
+ },
3282
+ get: function(){
3283
+ return webshims.contentAttr(this, 'placeholder');
3284
+ }
3285
+ },
3286
+ reflect: true,
3287
+ initAttr: true
3288
+ });
3289
+ });
3290
+
3291
+
3292
+ polyfillElements.forEach(function(name){
3293
+ var placeholderValueDesc = {};
3294
+ var desc;
3295
+ ['attr', 'prop'].forEach(function(propType){
3296
+ placeholderValueDesc[propType] = {
3297
+ set: function(val){
3298
+ var elem = this;
3299
+ var placeholder;
3300
+
3301
+ if(!placeholder){
3302
+ placeholder = webshims.contentAttr(elem, 'placeholder');
3303
+ }
3304
+ $.removeData(elem, 'cachedValidity');
3305
+ var ret = desc[propType]._supset.call(elem, val);
3306
+ if(placeholder && 'value' in elem){
3307
+ changePlaceholderVisibility(elem, val, placeholder);
3308
+ }
3309
+ return ret;
3310
+ },
3311
+ get: function(){
3312
+ var elem = this;
3313
+ return $(elem).hasClass('placeholder-visible') ? '' : desc[propType]._supget.call(elem);
3314
+ }
3315
+ };
3316
+ });
3317
+ desc = webshims.defineNodeNameProperty(name, 'value', placeholderValueDesc);
3318
+ });
3319
+
3320
+ })();
3321
+
3322
+ (function(){
3323
+ var doc = document;
3324
+ if( 'value' in document.createElement('output') ){return;}
3325
+
3326
+ webshims.defineNodeNameProperty('output', 'value', {
3327
+ prop: {
3328
+ set: function(value){
3329
+ var setVal = $.data(this, 'outputShim');
3330
+ if(!setVal){
3331
+ setVal = outputCreate(this);
3332
+ }
3333
+ setVal(value);
3334
+ },
3335
+ get: function(){
3336
+ return webshims.contentAttr(this, 'value') || $(this).text() || '';
3337
+ }
3338
+ }
3339
+ });
3340
+
3341
+
3342
+ webshims.onNodeNamesPropertyModify('input', 'value', function(value, boolVal, type){
3343
+ if(type == 'removeAttr'){return;}
3344
+ var setVal = $.data(this, 'outputShim');
3345
+ if(setVal){
3346
+ setVal(value);
3347
+ }
3348
+ });
3349
+
3350
+ var outputCreate = function(elem){
3351
+ if(elem.getAttribute('aria-live')){return;}
3352
+ elem = $(elem);
3353
+ var value = (elem.text() || '').trim();
3354
+ var id = elem.prop('id');
3355
+ var htmlFor = elem.attr('for');
3356
+ var shim = $('<input class="output-shim" type="text" disabled name="'+ (elem.attr('name') || '')+'" value="'+value+'" style="display: none !important;" />').insertAfter(elem);
3357
+ var form = shim[0].form || doc;
3358
+ var setValue = function(val){
3359
+ shim[0].value = val;
3360
+ val = shim[0].value;
3361
+ elem.text(val);
3362
+ webshims.contentAttr(elem[0], 'value', val);
3363
+ };
3364
+
3365
+ elem[0].defaultValue = value;
3366
+ webshims.contentAttr(elem[0], 'value', value);
3367
+
3368
+ elem.attr({'aria-live': 'polite'});
3369
+ if(id){
3370
+ shim.attr('id', id);
3371
+ elem.attr('aria-labelledby', elem.jProp('labels').map(function(){
3372
+ return webshims.getID(this);
3373
+ }).get().join(' '));
3374
+ }
3375
+ if(htmlFor){
3376
+ id = webshims.getID(elem);
3377
+ htmlFor.split(' ').forEach(function(control){
3378
+ control = document.getElementById(control);
3379
+ if(control){
3380
+ control.setAttribute('aria-controls', id);
3381
+ }
3382
+ });
3383
+ }
3384
+ elem.data('outputShim', setValue );
3385
+ shim.data('outputShim', setValue );
3386
+ return setValue;
3387
+ };
3388
+
3389
+ webshims.addReady(function(context, contextElem){
3390
+ $('output', context).add(contextElem.filter('output')).each(function(){
3391
+ outputCreate(this);
3392
+ });
3393
+ });
3394
+
3395
+ /*
3396
+ * Implements input event in all browsers
3397
+ */
3398
+ (function(){
3399
+ var noInputTriggerEvts = {updateInput: 1, input: 1},
3400
+ noInputTypes = {
3401
+ radio: 1,
3402
+ checkbox: 1,
3403
+ submit: 1,
3404
+ button: 1,
3405
+ image: 1,
3406
+ reset: 1,
3407
+ file: 1
3408
+
3409
+ //pro forma
3410
+ ,color: 1
3411
+ //,range: 1
3412
+ },
3413
+ observe = function(input){
3414
+ var timer,
3415
+ lastVal = input.prop('value'),
3416
+ trigger = function(e){
3417
+ //input === null
3418
+ if(!input){return;}
3419
+ var newVal = input.prop('value');
3420
+ if(newVal !== lastVal){
3421
+ lastVal = newVal;
3422
+ if(!e || !noInputTriggerEvts[e.type]){
3423
+ webshims.triggerInlineForm && webshims.triggerInlineForm(input[0], 'input');
3424
+ }
3425
+ }
3426
+ },
3427
+ extraTimer,
3428
+ extraTest = function(){
3429
+ clearTimeout(extraTimer);
3430
+ extraTimer = setTimeout(trigger, 9);
3431
+ },
3432
+ unbind = function(){
3433
+ input.unbind('focusout', unbind).unbind('keyup keypress keydown paste cut', extraTest).unbind('input change updateInput', trigger);
3434
+ clearInterval(timer);
3435
+ setTimeout(function(){
3436
+ trigger();
3437
+ input = null;
3438
+ }, 1);
3439
+
3440
+ }
3441
+ ;
3442
+
3443
+ clearInterval(timer);
3444
+ timer = setInterval(trigger, 200);
3445
+ extraTest();
3446
+ input.on({
3447
+ 'keyup keypress keydown paste cut': extraTest,
3448
+ focusout: unbind,
3449
+ 'input updateInput change': trigger
3450
+ });
3451
+ }
3452
+ ;
3453
+ if($.event.customEvent){
3454
+ $.event.customEvent.updateInput = true;
3455
+ }
3456
+
3457
+ $(doc)
3458
+ .on('focusin', function(e){
3459
+ if( e.target && !e.target.readOnly && !e.target.disabled && (e.target.nodeName || '').toLowerCase() == 'input' && !noInputTypes[e.target.type] && !(webshims.data(e.target, 'implemented') || {}).inputwidgets){
3460
+ observe($(e.target));
3461
+ }
3462
+ })
3463
+ ;
3464
+ })();
3465
+ })();
3466
+
3467
+ }); //webshims.ready end
3468
+ }//end formvalidation
3469
+
3470
+ jQuery.webshims.register('form-message', function($, webshims, window, document, undefined, options){
3471
+ "use strict";
3472
+ var validityMessages = webshims.validityMessages;
3473
+
3474
+ var implementProperties = (options.overrideMessages || options.customMessages) ? ['customValidationMessage'] : [];
3475
+
3476
+ validityMessages.en = $.extend(true, {
3477
+ typeMismatch: {
3478
+ defaultMessage: 'Please enter a valid value.',
3479
+ email: 'Please enter an email address.',
3480
+ url: 'Please enter a URL.',
3481
+ number: 'Please enter a number.',
3482
+ date: 'Please enter a date.',
3483
+ time: 'Please enter a time.',
3484
+ range: 'Invalid input.',
3485
+ month: 'Please enter a valid value.',
3486
+ "datetime-local": 'Please enter a datetime.'
3487
+ },
3488
+ rangeUnderflow: {
3489
+ defaultMessage: 'Value must be greater than or equal to {%min}.'
3490
+ },
3491
+ rangeOverflow: {
3492
+ defaultMessage: 'Value must be less than or equal to {%max}.'
3493
+ },
3494
+ stepMismatch: 'Invalid input.',
3495
+ tooLong: 'Please enter at most {%maxlength} character(s). You entered {%valueLen}.',
3496
+ patternMismatch: 'Invalid input. {%title}',
3497
+ valueMissing: {
3498
+ defaultMessage: 'Please fill out this field.',
3499
+ checkbox: 'Please check this box if you want to proceed.'
3500
+ }
3501
+ }, (validityMessages.en || validityMessages['en-US'] || {}));
3502
+
3503
+ if(typeof validityMessages['en'].valueMissing == 'object'){
3504
+ ['select', 'radio'].forEach(function(type){
3505
+ validityMessages.en.valueMissing[type] = 'Please select an option.';
3506
+ });
3507
+ }
3508
+ if(typeof validityMessages.en.rangeUnderflow == 'object'){
3509
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
3510
+ validityMessages.en.rangeUnderflow[type] = 'Value must be at or after {%min}.';
3511
+ });
3512
+ }
3513
+ if(typeof validityMessages.en.rangeOverflow == 'object'){
3514
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
3515
+ validityMessages.en.rangeOverflow[type] = 'Value must be at or before {%max}.';
3516
+ });
3517
+ }
3518
+
3519
+ validityMessages['en-US'] = validityMessages['en-US'] || validityMessages.en;
3520
+ validityMessages[''] = validityMessages[''] || validityMessages['en-US'];
3521
+
3522
+ validityMessages.de = $.extend(true, {
3523
+ typeMismatch: {
3524
+ defaultMessage: '{%value} ist in diesem Feld nicht zulässig.',
3525
+ email: '{%value} ist keine gültige E-Mail-Adresse.',
3526
+ url: '{%value} ist kein(e) gültige(r) Webadresse/Pfad.',
3527
+ number: '{%value} ist keine Nummer.',
3528
+ date: '{%value} ist kein Datum.',
3529
+ time: '{%value} ist keine Uhrzeit.',
3530
+ month: '{%value} ist in diesem Feld nicht zulässig.',
3531
+ range: '{%value} ist keine Nummer.',
3532
+ "datetime-local": '{%value} ist kein Datum-Uhrzeit Format.'
3533
+ },
3534
+ rangeUnderflow: {
3535
+ defaultMessage: '{%value} ist zu niedrig. {%min} ist der unterste Wert, den Sie benutzen können.'
3536
+ },
3537
+ rangeOverflow: {
3538
+ defaultMessage: '{%value} ist zu hoch. {%max} ist der oberste Wert, den Sie benutzen können.'
3539
+ },
3540
+ stepMismatch: 'Der Wert {%value} ist in diesem Feld nicht zulässig. Hier sind nur bestimmte Werte zulässig. {%title}',
3541
+ tooLong: 'Der eingegebene Text ist zu lang! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%maxlength} das Maximum.',
3542
+ patternMismatch: '{%value} hat für dieses Eingabefeld ein falsches Format. {%title}',
3543
+ valueMissing: {
3544
+ defaultMessage: 'Bitte geben Sie einen Wert ein.',
3545
+ checkbox: 'Bitte aktivieren Sie das Kästchen.'
3546
+ }
3547
+ }, (validityMessages.de || {}));
3548
+
3549
+ if(typeof validityMessages.de.valueMissing == 'object'){
3550
+ ['select', 'radio'].forEach(function(type){
3551
+ validityMessages.de.valueMissing[type] = 'Bitte wählen Sie eine Option aus.';
3552
+ });
3553
+ }
3554
+ if(typeof validityMessages.de.rangeUnderflow == 'object'){
3555
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
3556
+ validityMessages.de.rangeUnderflow[type] = '{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.';
3557
+ });
3558
+ }
3559
+ if(typeof validityMessages.de.rangeOverflow == 'object'){
3560
+ ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
3561
+ validityMessages.de.rangeOverflow[type] = '{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.';
3562
+ });
3563
+ }
3564
+
3565
+ var currentValidationMessage = validityMessages[''];
3566
+ var getMessageFromObj = function(message, elem){
3567
+ if(message && typeof message !== 'string'){
3568
+ message = message[ $.prop(elem, 'type') ] || message[ (elem.nodeName || '').toLowerCase() ] || message[ 'defaultMessage' ];
3569
+ }
3570
+ return message || '';
3571
+ };
3572
+ var valueVals = {
3573
+ value: 1,
3574
+ min: 1,
3575
+ max: 1
3576
+ };
3577
+
3578
+ webshims.createValidationMessage = function(elem, name){
3579
+ var spinner;
3580
+ var message = getMessageFromObj(currentValidationMessage[name], elem);
3581
+
3582
+ if(!message){
3583
+ message = getMessageFromObj(validityMessages[''][name], elem) || 'invalid value';
3584
+ webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+$.webshims.activeLang());
3585
+ }
3586
+ if(message){
3587
+ ['value', 'min', 'max', 'title', 'maxlength', 'label'].forEach(function(attr){
3588
+ if(message.indexOf('{%'+attr) === -1){return;}
3589
+ var val = ((attr == 'label') ? $.trim($('label[for="'+ elem.id +'"]', elem.form).text()).replace(/\*$|:$/, '') : $.prop(elem, attr)) || '';
3590
+ if(name == 'patternMismatch' && attr == 'title' && !val){
3591
+ webshims.error('no title for patternMismatch provided. Always add a title attribute.');
3592
+ }
3593
+ if(valueVals[attr]){
3594
+ if(!spinner){
3595
+ spinner = $(elem).getShadowElement().data('wsspinner');
3596
+ }
3597
+ if(spinner && spinner.formatValue){
3598
+ val = spinner.formatValue(val, false);
3599
+ }
3600
+ }
3601
+ message = message.replace('{%'+ attr +'}', val);
3602
+ if('value' == attr){
3603
+ message = message.replace('{%valueLen}', val.length);
3604
+ }
3605
+
3606
+ });
3607
+ }
3608
+
3609
+ return message || '';
3610
+ };
3611
+
3612
+
3613
+ if(webshims.bugs.validationMessage || !Modernizr.formvalidation || webshims.bugs.bustedValidity){
3614
+ implementProperties.push('validationMessage');
3615
+ }
3616
+
3617
+ webshims.activeLang({
3618
+ langObj: validityMessages,
3619
+ module: 'form-core',
3620
+ callback: function(langObj){
3621
+
3622
+ currentValidationMessage = langObj;
3623
+ }
3624
+ });
3625
+
3626
+ implementProperties.forEach(function(messageProp){
3627
+ webshims.defineNodeNamesProperty(['fieldset', 'output', 'button'], messageProp, {
3628
+ prop: {
3629
+ value: '',
3630
+ writeable: false
3631
+ }
3632
+ });
3633
+ ['input', 'select', 'textarea'].forEach(function(nodeName){
3634
+ var desc = webshims.defineNodeNameProperty(nodeName, messageProp, {
3635
+ prop: {
3636
+ get: function(){
3637
+ var elem = this;
3638
+ var message = '';
3639
+ if(!$.prop(elem, 'willValidate')){
3640
+ return message;
3641
+ }
3642
+
3643
+ var validity = $.prop(elem, 'validity') || {valid: 1};
3644
+
3645
+ if(validity.valid){return message;}
3646
+ message = webshims.getContentValidationMessage(elem, validity);
3647
+
3648
+ if(message){return message;}
3649
+
3650
+ if(validity.customError && elem.nodeName){
3651
+ message = (Modernizr.formvalidation && !webshims.bugs.bustedValidity && desc.prop._supget) ? desc.prop._supget.call(elem) : webshims.data(elem, 'customvalidationMessage');
3652
+ if(message){return message;}
3653
+ }
3654
+ $.each(validity, function(name, prop){
3655
+ if(name == 'valid' || !prop){return;}
3656
+
3657
+ message = webshims.createValidationMessage(elem, name);
3658
+ if(message){
3659
+ return false;
3660
+ }
3661
+ });
3662
+ return message || '';
3663
+ },
3664
+ writeable: false
3665
+ }
3666
+ });
3667
+ });
3668
+
3669
+ });
3670
+ });
3671
+ jQuery.webshims.register('form-datalist', function($, webshims, window, document, undefined, options){
3672
+ "use strict";
3673
+ var doc = document;
3674
+
3675
+ /*
3676
+ * implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
3677
+ */
3678
+ webshims.propTypes.element = function(descs){
3679
+ webshims.createPropDefault(descs, 'attr');
3680
+ if(descs.prop){return;}
3681
+ descs.prop = {
3682
+ get: function(){
3683
+ var elem = $.attr(this, 'list');
3684
+ if(elem){
3685
+ elem = document.getElementById(elem);
3686
+ if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
3687
+ elem = null;
3688
+ }
3689
+ }
3690
+ return elem || null;
3691
+ },
3692
+ writeable: false
3693
+ };
3694
+ };
3695
+
3696
+
3697
+ /*
3698
+ * Implements datalist element and list attribute
3699
+ */
3700
+
3701
+ (function(){
3702
+ var formsCFG = $.webshims.cfg.forms;
3703
+ var listSupport = Modernizr.input.list;
3704
+ if(listSupport && !formsCFG.customDatalist){return;}
3705
+
3706
+ var initializeDatalist = function(){
3707
+
3708
+
3709
+ if(!listSupport){
3710
+ webshims.defineNodeNameProperty('datalist', 'options', {
3711
+ prop: {
3712
+ writeable: false,
3713
+ get: function(){
3714
+ var elem = this;
3715
+ var select = $('select', elem);
3716
+ var options;
3717
+ if(select[0]){
3718
+ options = select[0].options;
3719
+ } else {
3720
+ options = $('option', elem).get();
3721
+ if(options.length){
3722
+ webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
3723
+ }
3724
+ }
3725
+ return options;
3726
+ }
3727
+ }
3728
+ });
3729
+ }
3730
+
3731
+ var inputListProto = {
3732
+ //override autocomplete
3733
+ autocomplete: {
3734
+ attr: {
3735
+ get: function(){
3736
+ var elem = this;
3737
+ var data = $.data(elem, 'datalistWidget');
3738
+ if(data){
3739
+ return data._autocomplete;
3740
+ }
3741
+ return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
3742
+ },
3743
+ set: function(value){
3744
+ var elem = this;
3745
+ var data = $.data(elem, 'datalistWidget');
3746
+ if(data){
3747
+ data._autocomplete = value;
3748
+ if(value == 'off'){
3749
+ data.hideList();
3750
+ }
3751
+ } else {
3752
+ if('autocomplete' in elem){
3753
+ elem.autocomplete = value;
3754
+ } else {
3755
+ elem.setAttribute('autocomplete', value);
3756
+ }
3757
+ }
3758
+ }
3759
+ }
3760
+ }
3761
+ };
3762
+
3763
+ if(formsCFG.customDatalist && (!listSupport || !('selectedOption' in $('<input />')[0]))){
3764
+ //currently not supported x-browser (FF4 has not implemented and is not polyfilled )
3765
+ inputListProto.selectedOption = {
3766
+ prop: {
3767
+ writeable: false,
3768
+ get: function(){
3769
+ var elem = this;
3770
+ var list = $.prop(elem, 'list');
3771
+ var ret = null;
3772
+ var value, options;
3773
+ if(!list){return ret;}
3774
+ value = $.prop(elem, 'value');
3775
+ if(!value){return ret;}
3776
+ options = $.prop(list, 'options');
3777
+ if(!options.length){return ret;}
3778
+ $.each(options, function(i, option){
3779
+ if(value == $.prop(option, 'value')){
3780
+ ret = option;
3781
+ return false;
3782
+ }
3783
+ });
3784
+ return ret;
3785
+ }
3786
+ }
3787
+ };
3788
+ }
3789
+
3790
+ if(!listSupport){
3791
+
3792
+ inputListProto['list'] = {
3793
+ attr: {
3794
+ get: function(){
3795
+ var val = webshims.contentAttr(this, 'list');
3796
+ return (val == null) ? undefined : val;
3797
+ },
3798
+ set: function(value){
3799
+ var elem = this;
3800
+ webshims.contentAttr(elem, 'list', value);
3801
+ webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
3802
+ $(elem).triggerHandler('listdatalistchange');
3803
+ }
3804
+ },
3805
+ initAttr: true,
3806
+ reflect: true,
3807
+ propType: 'element',
3808
+ propNodeName: 'datalist'
3809
+ };
3810
+ } else {
3811
+ //options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
3812
+ if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
3813
+ webshims.defineNodeNameProperty('datalist', 'options', {
3814
+ prop: {
3815
+ writeable: false,
3816
+ get: function(){
3817
+ var options = this.options || [];
3818
+ if(!options.length){
3819
+ var elem = this;
3820
+ var select = $('select', elem);
3821
+ if(select[0] && select[0].options && select[0].options.length){
3822
+ options = select[0].options;
3823
+ }
3824
+ }
3825
+ return options;
3826
+ }
3827
+ }
3828
+ });
3829
+ }
3830
+ inputListProto['list'] = {
3831
+ attr: {
3832
+ get: function(){
3833
+ var val = webshims.contentAttr(this, 'list');
3834
+ if(val != null){
3835
+ $.data(this, 'datalistListAttr', val);
3836
+ this.removeAttribute('list');
3837
+ } else {
3838
+ val = $.data(this, 'datalistListAttr');
3839
+ }
3840
+
3841
+ return (val == null) ? undefined : val;
3842
+ },
3843
+ set: function(value){
3844
+ var elem = this;
3845
+ $.data(elem, 'datalistListAttr', value);
3846
+ webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
3847
+ $(elem).triggerHandler('listdatalistchange');
3848
+ }
3849
+ },
3850
+ initAttr: true,
3851
+ reflect: true,
3852
+ propType: 'element',
3853
+ propNodeName: 'datalist'
3854
+ };
3855
+ }
3856
+
3857
+ webshims.defineNodeNameProperties('input', inputListProto);
3858
+
3859
+ webshims.addReady(function(context, contextElem){
3860
+ contextElem
3861
+ .filter('datalist > select, datalist, datalist > option, datalist > select > option')
3862
+ .closest('datalist')
3863
+ .each(function(){
3864
+ $(this).triggerHandler('updateDatalist');
3865
+ })
3866
+
3867
+ ;
3868
+
3869
+ });
3870
+
3871
+
3872
+ };
3873
+
3874
+
3875
+ /*
3876
+ * ShadowList
3877
+ */
3878
+ var listidIndex = 0;
3879
+ var noDatalistSupport = {
3880
+ submit: 1,
3881
+ button: 1,
3882
+ reset: 1,
3883
+ hidden: 1,
3884
+
3885
+ range: 1,
3886
+ date: 1,
3887
+ month: 1
3888
+ };
3889
+ if(webshims.modules["form-number-date-ui"].loaded){
3890
+ $.extend(noDatalistSupport, {
3891
+ number: 1,
3892
+ time: 1
3893
+ });
3894
+ }
3895
+
3896
+ var globStoredOptions = {};
3897
+ var getStoredOptions = function(name){
3898
+ if(!name){return [];}
3899
+ if(globStoredOptions[name]){
3900
+ return globStoredOptions[name];
3901
+ }
3902
+ var data;
3903
+ try {
3904
+ data = JSON.parse(localStorage.getItem('storedDatalistOptions'+name));
3905
+ } catch(e){}
3906
+ globStoredOptions[name] = data || [];
3907
+ return data || [];
3908
+ };
3909
+ var storeOptions = function(name, val){
3910
+ if(!name){return;}
3911
+ val = val || [];
3912
+ try {
3913
+ localStorage.setItem( 'storedDatalistOptions'+name, JSON.stringify(val) );
3914
+ } catch(e){}
3915
+ };
3916
+
3917
+ var getText = function(elem){
3918
+ return (elem.textContent || elem.innerText || $.text([ elem ]) || '');
3919
+ };
3920
+ var lReg = /</g;
3921
+ var gReg = />/g;
3922
+
3923
+ var shadowListProto = {
3924
+ _create: function(opts){
3925
+
3926
+ if(noDatalistSupport[$.prop(opts.input, 'type')] || noDatalistSupport[$.attr(opts.input, 'type')]){return;}
3927
+ var datalist = opts.datalist;
3928
+ var data = $.data(opts.input, 'datalistWidget');
3929
+ if(datalist && data && data.datalist !== datalist){
3930
+ data.datalist = datalist;
3931
+ data.id = opts.id;
3932
+
3933
+
3934
+ $(data.datalist)
3935
+ .off('updateDatalist.datalistWidget')
3936
+ .on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
3937
+ ;
3938
+
3939
+ data._resetListCached();
3940
+ return;
3941
+ } else if(!datalist){
3942
+ if(data){
3943
+ data.destroy();
3944
+ }
3945
+ return;
3946
+ } else if(data && data.datalist === datalist){
3947
+ return;
3948
+ }
3949
+ listidIndex++;
3950
+ var that = this;
3951
+ this.hideList = $.proxy(that, 'hideList');
3952
+
3953
+ this.datalist = datalist;
3954
+ this.id = opts.id;
3955
+ this.hasViewableData = true;
3956
+ this._autocomplete = $.attr(opts.input, 'autocomplete');
3957
+ $.data(opts.input, 'datalistWidget', this);
3958
+
3959
+ this.popover = webshims.objectCreate(webshims.wsPopover, {}, options.datalistPopover);
3960
+ this.shadowList = this.popover.element.addClass('datalist-polyfill');
3961
+
3962
+
3963
+ this.index = -1;
3964
+ this.input = opts.input;
3965
+ this.arrayOptions = [];
3966
+
3967
+ this.shadowList
3968
+ .delegate('li', 'mouseenter.datalistWidget mousedown.datalistWidget click.datalistWidget', function(e){
3969
+ var items = $('li:not(.hidden-item)', that.shadowList);
3970
+ var select = (e.type == 'mousedown' || e.type == 'click');
3971
+ that.markItem(items.index(e.currentTarget), select, items);
3972
+ if(e.type == 'click'){
3973
+ that.hideList();
3974
+ if(formsCFG.customDatalist){
3975
+ $(opts.input).getNativeElement().trigger('datalistselect');
3976
+ }
3977
+ }
3978
+ return (e.type != 'mousedown');
3979
+ })
3980
+ ;
3981
+
3982
+ opts.input.setAttribute('autocomplete', 'off');
3983
+
3984
+ $(opts.input)
3985
+ .attr({
3986
+ //role: 'combobox',
3987
+ 'aria-haspopup': 'true'
3988
+ })
3989
+ .on({
3990
+ 'input.datalistWidget': function(){
3991
+ if(!that.triggeredByDatalist){
3992
+ that.changedValue = false;
3993
+ that.showHideOptions();
3994
+ }
3995
+ },
3996
+ 'keydown.datalistWidget': function(e){
3997
+ var keyCode = e.keyCode;
3998
+ var activeItem;
3999
+ var items;
4000
+ if(keyCode == 40 && !that.showList()){
4001
+ that.markItem(that.index + 1, true);
4002
+ return false;
4003
+ }
4004
+
4005
+ if(!that.popover.isVisible){return;}
4006
+
4007
+
4008
+ if(keyCode == 38){
4009
+ that.markItem(that.index - 1, true);
4010
+ return false;
4011
+ }
4012
+ if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
4013
+ that.markItem(0, true);
4014
+ return false;
4015
+ }
4016
+ if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
4017
+ items = $('li:not(.hidden-item)', that.shadowList);
4018
+ that.markItem(items.length - 1, true, items);
4019
+ return false;
4020
+ }
4021
+ if(keyCode == 13 || keyCode == 27){
4022
+ if (keyCode == 13){
4023
+ activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
4024
+ that.changeValue( $('li.active-item:not(.hidden-item)', that.shadowList) );
4025
+ }
4026
+ that.hideList();
4027
+ if(formsCFG.customDatalist && activeItem && activeItem[0]){
4028
+ $(opts.input).getNativeElement().trigger('datalistselect');
4029
+ }
4030
+ return false;
4031
+ }
4032
+ },
4033
+ 'focus.datalistWidget': function(){
4034
+ if($(this).hasClass('list-focus')){
4035
+ that.showList();
4036
+ }
4037
+ },
4038
+ 'mousedown.datalistWidget': function(){
4039
+ if($(this).is(':focus')){
4040
+ that.showList();
4041
+ }
4042
+ }
4043
+ })
4044
+ ;
4045
+
4046
+
4047
+ $(this.datalist)
4048
+ .off('updateDatalist.datalistWidget')
4049
+ .on('updateDatalist.datalistWidget', $.proxy(this, '_resetListCached'))
4050
+ ;
4051
+
4052
+ this._resetListCached();
4053
+
4054
+ if(opts.input.form && (opts.input.name || opts.input.id)){
4055
+ $(opts.input.form).on('submit.datalistWidget'+opts.input.id, function(){
4056
+ if(!$(opts.input).hasClass('no-datalist-cache') && that._autocomplete != 'off'){
4057
+ var val = $.prop(opts.input, 'value');
4058
+ var name = (opts.input.name || opts.input.id) + $.prop(opts.input, 'type');
4059
+ if(!that.storedOptions){
4060
+ that.storedOptions = getStoredOptions( name );
4061
+ }
4062
+ if(val && that.storedOptions.indexOf(val) == -1){
4063
+ that.storedOptions.push(val);
4064
+ storeOptions(name, that.storedOptions );
4065
+ }
4066
+ }
4067
+ });
4068
+ }
4069
+ $(window).on('unload.datalist'+this.id+' beforeunload.datalist'+this.id, function(){
4070
+ that.destroy();
4071
+ });
4072
+ },
4073
+ destroy: function(){
4074
+ var autocomplete = $.attr(this.input, 'autocomplete');
4075
+ $(this.input)
4076
+ .off('.datalistWidget')
4077
+ .removeData('datalistWidget')
4078
+ ;
4079
+ this.shadowList.remove();
4080
+ $(document).off('.datalist'+this.id);
4081
+ $(window).off('.datalist'+this.id);
4082
+ if(this.input.form && this.input.id){
4083
+ $(this.input.form).off('submit.datalistWidget'+this.input.id);
4084
+ }
4085
+ this.input.removeAttribute('aria-haspopup');
4086
+ if(autocomplete === undefined){
4087
+ this.input.removeAttribute('autocomplete');
4088
+ } else {
4089
+ $(this.input).attr('autocomplete', autocomplete);
4090
+ }
4091
+ },
4092
+ _resetListCached: function(e){
4093
+ var that = this;
4094
+ var forceShow;
4095
+ this.needsUpdate = true;
4096
+ this.lastUpdatedValue = false;
4097
+ this.lastUnfoundValue = '';
4098
+
4099
+ if(!this.updateTimer){
4100
+ if(window.QUnit || (forceShow = ($(that.input).is(':focus') && ($(that.input).hasClass('list-focus') || $.prop(that.input, 'value'))) )){
4101
+ that.updateListOptions(forceShow);
4102
+ } else {
4103
+ webshims.ready('WINDOWLOAD', function(){
4104
+ that.updateTimer = setTimeout(function(){
4105
+ that.updateListOptions();
4106
+ that = null;
4107
+ listidIndex = 1;
4108
+ }, 200 + (100 * listidIndex));
4109
+ });
4110
+ }
4111
+ }
4112
+ },
4113
+ updateListOptions: function(_forceShow){
4114
+ this.needsUpdate = false;
4115
+ clearTimeout(this.updateTimer);
4116
+ this.updateTimer = false;
4117
+
4118
+ this.searchStart = formsCFG.customDatalist && $(this.input).hasClass('search-start');
4119
+ this.addMarkElement = options.addMark || $(this.input).hasClass('mark-option-text');
4120
+
4121
+ var list = [];
4122
+
4123
+ var values = [];
4124
+ var allOptions = [];
4125
+ var rElem, rItem, rOptions, rI, rLen, item, value;
4126
+ for(rOptions = $.prop(this.datalist, 'options'), rI = 0, rLen = rOptions.length; rI < rLen; rI++){
4127
+ rElem = rOptions[rI];
4128
+ if(!rElem.disabled && (value = $(rElem).val())){
4129
+ rItem = {
4130
+ value: value.replace(lReg, '&lt;').replace(gReg, '&gt;'),
4131
+ label: $.trim($.attr(rElem, 'label') || getText(rElem)).replace(lReg, '&lt;').replace(gReg, '&gt;'),
4132
+ className: rElem.className || ''
4133
+ };
4134
+
4135
+ if(rItem.label){
4136
+ rItem.className += ' has-option-label';
4137
+ }
4138
+ values.push(rItem.value);
4139
+ allOptions.push(rItem);
4140
+ }
4141
+ }
4142
+
4143
+ if(!this.storedOptions){
4144
+ this.storedOptions = ($(this.input).hasClass('no-datalist-cache') || this._autocomplete == 'off') ? [] : getStoredOptions((this.input.name || this.input.id) + $.prop(this.input, 'type'));
4145
+ }
4146
+
4147
+ this.storedOptions.forEach(function(val, i){
4148
+ if(values.indexOf(val) == -1){
4149
+ allOptions.push({value: val, label: '', className: 'stored-suggest', style: ''});
4150
+ }
4151
+ });
4152
+
4153
+ for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
4154
+ item = allOptions[rI];
4155
+ list[rI] = '<li class="'+ item.className +'" tabindex="-1" role="listitem">'+ this.getOptionContent(item) +'</li>';
4156
+ }
4157
+
4158
+ this.arrayOptions = allOptions;
4159
+ this.popover.contentElement.html('<div class="datalist-box"><ul role="list">'+ list.join("\n") +'</ul></div>');
4160
+
4161
+
4162
+ if(_forceShow || this.popover.isVisible){
4163
+ this.showHideOptions();
4164
+ }
4165
+ },
4166
+ getOptionContent: function(item){
4167
+ var content = '';
4168
+ if(options.getOptionContent){
4169
+ content = options.apply(this, arguments) || '';
4170
+ } else {
4171
+ content = '<span class="option-value">'+ item.value +'</span>';
4172
+ if(item.label){
4173
+ content += ' <span class="option-label">'+ item.label +'</span>';
4174
+ }
4175
+ }
4176
+ return content;
4177
+ },
4178
+ showHideOptions: function(_fromShowList){
4179
+ var value = $.prop(this.input, 'value').toLowerCase();
4180
+
4181
+ //first check prevent infinite loop, second creates simple lazy optimization
4182
+ if(value === this.lastUpdatedValue){
4183
+ return;
4184
+ }
4185
+ if(this.lastUnfoundValue && value.indexOf(this.lastUnfoundValue) === 0){
4186
+ this.hideList();
4187
+ return;
4188
+ }
4189
+
4190
+
4191
+ this.lastUpdatedValue = value;
4192
+ var found = false;
4193
+ var startSearch = this.searchStart;
4194
+ var lis = $('li', this.shadowList);
4195
+ var that = this;
4196
+ if(value){
4197
+
4198
+ this.arrayOptions.forEach(function(item, i){
4199
+ var search, searchIndex, foundName;
4200
+ if(!('lowerValue' in item)){
4201
+ item.lowerValue = item.value.toLowerCase();
4202
+ if(item.label && item.label != item.value ){
4203
+ item.lowerLabel = item.label.toLowerCase();
4204
+ }
4205
+ }
4206
+
4207
+ if(value != item.lowerValue && item.lowerLabel != value){
4208
+ searchIndex = item.lowerValue.indexOf(value);
4209
+ search = startSearch ? !searchIndex : searchIndex !== -1;
4210
+ if(search){
4211
+ foundName = 'value';
4212
+ } else if(item.lowerLabel){
4213
+ searchIndex = item.lowerLabel.indexOf(value);
4214
+ search = startSearch ? !searchIndex : searchIndex !== -1;
4215
+ foundName = 'label';
4216
+ }
4217
+ }
4218
+
4219
+ if(search){
4220
+ that.addMark($(lis[i]).removeClass('hidden-item'), item, foundName, searchIndex, value.length);
4221
+ found = true;
4222
+ } else {
4223
+ $(lis[i]).addClass('hidden-item');
4224
+ }
4225
+ });
4226
+ } else if(lis.length) {
4227
+ this.removeMark(lis.removeClass('hidden-item'));
4228
+ found = true;
4229
+ }
4230
+
4231
+ this.hasViewableData = found;
4232
+ if(!_fromShowList && found){
4233
+ this.showList();
4234
+ }
4235
+
4236
+ if(!found){
4237
+ this.lastUnfoundValue = value;
4238
+ this.hideList();
4239
+ } else {
4240
+ this.lastUnfoundValue = false;
4241
+ }
4242
+ },
4243
+ otherType: {
4244
+ value: 'label',
4245
+ label: 'value'
4246
+ },
4247
+ addMark: function(elem, item, prop, start, length){
4248
+ if(this.addMarkElement){
4249
+ var text = item[prop].substr(start, length);
4250
+ text = item[prop].replace(text ,'<mark>'+ text +'</mark>');
4251
+ $('.option-'+ this.otherType[prop] +' > mark', elem).each(this._replaceMark);
4252
+ $('.option-'+prop, elem).html(text);
4253
+
4254
+ }
4255
+ },
4256
+ _replaceMark: function(){
4257
+ var content = $(this).html();
4258
+ $(this).replaceWith(content);
4259
+ },
4260
+ removeMark: function(lis){
4261
+ if(this.addMarkElement){
4262
+ $('mark', lis).each(this._replaceMark);
4263
+ }
4264
+ },
4265
+ showList: function(){
4266
+ if(this.popover.isVisible){return false;}
4267
+ if(this.needsUpdate){
4268
+ this.updateListOptions();
4269
+ }
4270
+ this.showHideOptions(true);
4271
+ if(!this.hasViewableData){return false;}
4272
+ var that = this;
4273
+
4274
+ that.shadowList.find('li.active-item').removeClass('active-item');
4275
+ that.popover.show(this.input);
4276
+
4277
+
4278
+ return true;
4279
+ },
4280
+ hideList: function(){
4281
+ if(!this.popover.isVisible){return false;}
4282
+ var that = this;
4283
+
4284
+
4285
+ this.popover.hide();
4286
+ that.shadowList.removeClass('datalist-visible list-item-active');
4287
+ that.index = -1;
4288
+ if(that.changedValue){
4289
+ that.triggeredByDatalist = true;
4290
+ $(that.input).trigger('input').trigger('change');
4291
+ that.changedValue = false;
4292
+ that.triggeredByDatalist = false;
4293
+ }
4294
+
4295
+ return true;
4296
+ },
4297
+ scrollIntoView: function(elem){
4298
+ var ul = $('ul', this.shadowList);
4299
+ var div = $('div.datalist-box', this.shadowList);
4300
+ var elemPos = elem.position();
4301
+ var containerHeight;
4302
+ elemPos.top -= (parseInt(ul.css('paddingTop'), 10) || 0) + (parseInt(ul.css('marginTop'), 10) || 0) + (parseInt(ul.css('borderTopWidth'), 10) || 0);
4303
+ if(elemPos.top < 0){
4304
+ div.scrollTop( div.scrollTop() + elemPos.top - 2);
4305
+ return;
4306
+ }
4307
+ elemPos.top += elem.outerHeight();
4308
+ containerHeight = div.height();
4309
+ if(elemPos.top > containerHeight){
4310
+ div.scrollTop( div.scrollTop() + (elemPos.top - containerHeight) + 2);
4311
+ }
4312
+ },
4313
+ changeValue: function(activeItem){
4314
+ if(!activeItem[0]){return;}
4315
+ var spinner;
4316
+ var newValue = $('span.option-value', activeItem).text();
4317
+ var oldValue = $.prop(this.input, 'value');
4318
+ if(newValue != oldValue){
4319
+
4320
+ $(this.input)
4321
+ .prop('value', newValue)
4322
+ .triggerHandler('updateInput')
4323
+ ;
4324
+ this.changedValue = true;
4325
+ if((spinner = $.data(this.input, 'wsspinner')) && spinner.setInput){
4326
+ spinner.setInput(newValue);
4327
+ }
4328
+ }
4329
+ },
4330
+ markItem: function(index, doValue, items){
4331
+ var activeItem;
4332
+ var goesUp;
4333
+
4334
+ items = items || $('li:not(.hidden-item)', this.shadowList);
4335
+ if(!items.length){return;}
4336
+ if(index < 0){
4337
+ index = items.length - 1;
4338
+ } else if(index >= items.length){
4339
+ index = 0;
4340
+ }
4341
+ items.removeClass('active-item');
4342
+ this.shadowList.addClass('list-item-active');
4343
+ activeItem = items.filter(':eq('+ index +')').addClass('active-item');
4344
+
4345
+ if(doValue){
4346
+ this.changeValue(activeItem);
4347
+ this.scrollIntoView(activeItem);
4348
+ }
4349
+ this.index = index;
4350
+ }
4351
+ };
4352
+
4353
+ //init datalist update
4354
+ initializeDatalist();
4355
+ })();
4356
+
4357
+ });