webshims-rails 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/lib/webshims-rails/version.rb +2 -2
  2. data/vendor/assets/javascripts/webshims/extras/custom-validity.js +261 -261
  3. data/vendor/assets/javascripts/webshims/extras/modernizr-custom.js +534 -534
  4. data/vendor/assets/javascripts/webshims/extras/mousepress.js +60 -60
  5. data/vendor/assets/javascripts/webshims/minified/extras/custom-validity.js +1 -1
  6. data/vendor/assets/javascripts/webshims/minified/polyfiller.js +24 -24
  7. data/vendor/assets/javascripts/webshims/minified/shims/FlashCanvasPro/README +82 -82
  8. data/vendor/assets/javascripts/webshims/minified/shims/combos/1.js +35 -34
  9. data/vendor/assets/javascripts/webshims/minified/shims/combos/10.js +79 -82
  10. data/vendor/assets/javascripts/webshims/minified/shims/combos/11.js +45 -44
  11. data/vendor/assets/javascripts/webshims/minified/shims/combos/12.js +43 -42
  12. data/vendor/assets/javascripts/webshims/minified/shims/combos/13.js +28 -27
  13. data/vendor/assets/javascripts/webshims/minified/shims/combos/15.js +4 -4
  14. data/vendor/assets/javascripts/webshims/minified/shims/combos/16.js +57 -59
  15. data/vendor/assets/javascripts/webshims/minified/shims/combos/17.js +64 -66
  16. data/vendor/assets/javascripts/webshims/minified/shims/combos/18.js +53 -54
  17. data/vendor/assets/javascripts/webshims/minified/shims/combos/19.js +64 -66
  18. data/vendor/assets/javascripts/webshims/minified/shims/combos/2.js +72 -73
  19. data/vendor/assets/javascripts/webshims/minified/shims/combos/20.js +42 -46
  20. data/vendor/assets/javascripts/webshims/minified/shims/combos/21.js +52 -50
  21. data/vendor/assets/javascripts/webshims/minified/shims/combos/22.js +55 -59
  22. data/vendor/assets/javascripts/webshims/minified/shims/combos/23.js +66 -64
  23. data/vendor/assets/javascripts/webshims/minified/shims/combos/24.js +80 -82
  24. data/vendor/assets/javascripts/webshims/minified/shims/combos/25.js +60 -59
  25. data/vendor/assets/javascripts/webshims/minified/shims/combos/26.js +79 -81
  26. data/vendor/assets/javascripts/webshims/minified/shims/combos/27.js +101 -104
  27. data/vendor/assets/javascripts/webshims/minified/shims/combos/3.js +94 -95
  28. data/vendor/assets/javascripts/webshims/minified/shims/combos/4.js +26 -29
  29. data/vendor/assets/javascripts/webshims/minified/shims/combos/5.js +33 -36
  30. data/vendor/assets/javascripts/webshims/minified/shims/combos/59.js +51 -54
  31. data/vendor/assets/javascripts/webshims/minified/shims/combos/6.js +27 -28
  32. data/vendor/assets/javascripts/webshims/minified/shims/combos/7.js +27 -28
  33. data/vendor/assets/javascripts/webshims/minified/shims/combos/8.js +39 -38
  34. data/vendor/assets/javascripts/webshims/minified/shims/combos/9.js +65 -68
  35. data/vendor/assets/javascripts/webshims/minified/shims/details.js +4 -4
  36. data/vendor/assets/javascripts/webshims/minified/shims/dom-extend.js +23 -22
  37. data/vendor/assets/javascripts/webshims/minified/shims/form-core.js +19 -22
  38. data/vendor/assets/javascripts/webshims/minified/shims/form-datalist.js +14 -14
  39. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-api.js +9 -9
  40. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-ui.js +18 -19
  41. data/vendor/assets/javascripts/webshims/minified/shims/form-shim-extend.js +45 -43
  42. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-de.txt +33 -33
  43. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-en.txt +34 -34
  44. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-core.js +12 -12
  45. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-jaris.js +23 -0
  46. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-native-fix.js +1 -1
  47. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-swf.js +26 -30
  48. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-yt.js +3 -3
  49. data/vendor/assets/javascripts/webshims/minified/shims/styles/shim.css +689 -686
  50. data/vendor/assets/javascripts/webshims/minified/shims/swf/JarisFLVPlayer.swf +0 -0
  51. data/vendor/assets/javascripts/webshims/minified/shims/track-ui.js +9 -9
  52. data/vendor/assets/javascripts/webshims/minified/shims/track.js +21 -21
  53. data/vendor/assets/javascripts/webshims/polyfiller.js +1191 -1175
  54. data/vendor/assets/javascripts/webshims/shims/combos/1.js +1754 -1714
  55. data/vendor/assets/javascripts/webshims/shims/combos/10.js +3247 -3320
  56. data/vendor/assets/javascripts/webshims/shims/combos/11.js +1633 -1588
  57. data/vendor/assets/javascripts/webshims/shims/combos/12.js +1636 -1591
  58. data/vendor/assets/javascripts/webshims/shims/combos/13.js +1100 -1058
  59. data/vendor/assets/javascripts/webshims/shims/combos/14.js +476 -476
  60. data/vendor/assets/javascripts/webshims/shims/combos/15.js +316 -314
  61. data/vendor/assets/javascripts/webshims/shims/combos/16.js +2094 -2104
  62. data/vendor/assets/javascripts/webshims/shims/combos/17.js +2258 -2267
  63. data/vendor/assets/javascripts/webshims/shims/combos/18.js +1380 -1364
  64. data/vendor/assets/javascripts/webshims/shims/combos/19.js +2239 -2247
  65. data/vendor/assets/javascripts/webshims/shims/combos/2.js +2339 -2294
  66. data/vendor/assets/javascripts/webshims/shims/combos/20.js +1493 -1606
  67. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1733 -1635
  68. data/vendor/assets/javascripts/webshims/shims/combos/22.js +2295 -2408
  69. data/vendor/assets/javascripts/webshims/shims/combos/23.js +2269 -2168
  70. data/vendor/assets/javascripts/webshims/shims/combos/24.js +2775 -2780
  71. data/vendor/assets/javascripts/webshims/shims/combos/25.js +1505 -1456
  72. data/vendor/assets/javascripts/webshims/shims/combos/26.js +2111 -2115
  73. data/vendor/assets/javascripts/webshims/shims/combos/27.js +3264 -3331
  74. data/vendor/assets/javascripts/webshims/shims/combos/3.js +3020 -2970
  75. data/vendor/assets/javascripts/webshims/shims/combos/4.js +770 -822
  76. data/vendor/assets/javascripts/webshims/shims/combos/5.js +1025 -1077
  77. data/vendor/assets/javascripts/webshims/shims/combos/59.js +1706 -1753
  78. data/vendor/assets/javascripts/webshims/shims/combos/6.js +444 -433
  79. data/vendor/assets/javascripts/webshims/shims/combos/7.js +699 -688
  80. data/vendor/assets/javascripts/webshims/shims/combos/8.js +1488 -1445
  81. data/vendor/assets/javascripts/webshims/shims/combos/9.js +2445 -2518
  82. data/vendor/assets/javascripts/webshims/shims/details.js +148 -146
  83. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +952 -912
  84. data/vendor/assets/javascripts/webshims/shims/es5.js +802 -802
  85. data/vendor/assets/javascripts/webshims/shims/excanvas.js +924 -924
  86. data/vendor/assets/javascripts/webshims/shims/form-core.js +606 -659
  87. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +681 -676
  88. data/vendor/assets/javascripts/webshims/shims/form-message.js +164 -163
  89. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +255 -255
  90. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +383 -383
  91. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +61 -50
  92. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +1569 -1472
  93. data/vendor/assets/javascripts/webshims/shims/geolocation.js +168 -168
  94. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ar.js +32 -32
  95. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ch-ZN.js +32 -32
  96. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-de.txt +33 -33
  97. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-el.js +32 -32
  98. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-en.txt +34 -34
  99. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-es.js +31 -31
  100. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-fr.js +32 -32
  101. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-he.js +32 -32
  102. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hi.js +32 -32
  103. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hu.js +32 -32
  104. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-it.js +32 -32
  105. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ja.js +32 -32
  106. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-nl.js +32 -32
  107. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-pt-PT.js +32 -32
  108. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ru.js +31 -31
  109. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-sv.js +32 -32
  110. data/vendor/assets/javascripts/webshims/shims/json-storage.js +308 -308
  111. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +536 -533
  112. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +861 -0
  113. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +98 -98
  114. data/vendor/assets/javascripts/webshims/shims/mediaelement-swf.js +957 -1073
  115. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +543 -543
  116. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +689 -686
  117. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  118. data/vendor/assets/javascripts/webshims/shims/track-ui.js +9 -8
  119. data/vendor/assets/javascripts/webshims/shims/track.js +17 -11
  120. metadata +6 -6
  121. data/vendor/assets/javascripts/webshims/minified/shims/form-native-fix.js +0 -7
  122. data/vendor/assets/javascripts/webshims/shims/FlashCanvas/README +0 -62
  123. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/README +0 -82
  124. data/vendor/assets/javascripts/webshims/shims/form-native-fix.js +0 -261
@@ -1,1635 +1,1733 @@
1
- jQuery.webshims.register('form-message', function($, webshims, window, document, undefined, options){
2
- var validityMessages = webshims.validityMessages;
3
-
4
- var implementProperties = (options.overrideMessages || options.customMessages) ? ['customValidationMessage'] : [];
5
-
6
- validityMessages['en'] = $.extend(true, {
7
- typeMismatch: {
8
- email: 'Please enter an email address.',
9
- url: 'Please enter a URL.',
10
- number: 'Please enter a number.',
11
- date: 'Please enter a date.',
12
- time: 'Please enter a time.',
13
- range: 'Invalid input.',
14
- "datetime-local": 'Please enter a datetime.'
15
- },
16
- rangeUnderflow: {
17
- defaultMessage: 'Value must be greater than or equal to {%min}.'
18
- },
19
- rangeOverflow: {
20
- defaultMessage: 'Value must be less than or equal to {%max}.'
21
- },
22
- stepMismatch: 'Invalid input.',
23
- tooLong: 'Please enter at most {%maxlength} character(s). You entered {%valueLen}.',
24
-
25
- patternMismatch: 'Invalid input. {%title}',
26
- valueMissing: {
27
- defaultMessage: 'Please fill out this field.',
28
- checkbox: 'Please check this box if you want to proceed.'
29
- }
30
- }, (validityMessages['en'] || validityMessages['en-US'] || {}));
31
-
32
-
33
- ['select', 'radio'].forEach(function(type){
34
- validityMessages['en'].valueMissing[type] = 'Please select an option.';
35
- });
36
-
37
- ['date', 'time', 'datetime-local'].forEach(function(type){
38
- validityMessages.en.rangeUnderflow[type] = 'Value must be at or after {%min}.';
39
- });
40
- ['date', 'time', 'datetime-local'].forEach(function(type){
41
- validityMessages.en.rangeOverflow[type] = 'Value must be at or before {%max}.';
42
- });
43
-
44
- validityMessages['en-US'] = validityMessages['en-US'] || validityMessages['en'];
45
- validityMessages[''] = validityMessages[''] || validityMessages['en-US'];
46
-
47
- validityMessages['de'] = $.extend(true, {
48
- typeMismatch: {
49
- email: '{%value} ist keine zulässige E-Mail-Adresse',
50
- url: '{%value} ist keine zulässige Webadresse',
51
- number: '{%value} ist keine Nummer!',
52
- date: '{%value} ist kein Datum',
53
- time: '{%value} ist keine Uhrzeit',
54
- range: '{%value} ist keine Nummer!',
55
- "datetime-local": '{%value} ist kein Datum-Uhrzeit Format.'
56
- },
57
- rangeUnderflow: {
58
- defaultMessage: '{%value} ist zu niedrig. {%min} ist der unterste Wert, den Sie benutzen können.'
59
- },
60
- rangeOverflow: {
61
- defaultMessage: '{%value} ist zu hoch. {%max} ist der oberste Wert, den Sie benutzen können.'
62
- },
63
- stepMismatch: 'Der Wert {%value} ist in diesem Feld nicht zulässig. Hier sind nur bestimmte Werte zulässig. {%title}',
64
- tooLong: 'Der eingegebene Text ist zu lang! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%maxlength} das Maximum.',
65
- patternMismatch: '{%value} hat für dieses Eingabefeld ein falsches Format! {%title}',
66
- valueMissing: {
67
- defaultMessage: 'Bitte geben Sie einen Wert ein',
68
- checkbox: 'Bitte aktivieren Sie das Kästchen'
69
- }
70
- }, (validityMessages['de'] || {}));
71
-
72
- ['select', 'radio'].forEach(function(type){
73
- validityMessages['de'].valueMissing[type] = 'Bitte wählen Sie eine Option aus';
74
- });
75
-
76
- ['date', 'time', 'datetime-local'].forEach(function(type){
77
- validityMessages.de.rangeUnderflow[type] = '{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.';
78
- });
79
- ['date', 'time', 'datetime-local'].forEach(function(type){
80
- validityMessages.de.rangeOverflow[type] = '{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.';
81
- });
82
-
83
- var currentValidationMessage = validityMessages[''];
84
-
85
-
86
- webshims.createValidationMessage = function(elem, name){
87
- var message = currentValidationMessage[name];
88
- if(message && typeof message !== 'string'){
89
- message = message[ $.prop(elem, 'type') ] || message[ (elem.nodeName || '').toLowerCase() ] || message[ 'defaultMessage' ];
90
- }
91
- if(message){
92
- ['value', 'min', 'max', 'title', 'maxlength', 'label'].forEach(function(attr){
93
- if(message.indexOf('{%'+attr) === -1){return;}
94
- var val = ((attr == 'label') ? $.trim($('label[for="'+ elem.id +'"]', elem.form).text()).replace(/\*$|:$/, '') : $.attr(elem, attr)) || '';
95
- if(name == 'patternMismatch' && attr == 'title' && !val){
96
- webshims.error('no title for patternMismatch provided. Always add a title attribute.');
97
- }
98
- message = message.replace('{%'+ attr +'}', val);
99
- if('value' == attr){
100
- message = message.replace('{%valueLen}', val.length);
101
- }
102
- });
103
- }
104
- return message || '';
105
- };
106
-
107
-
108
- if(webshims.bugs.validationMessage || !Modernizr.formvalidation || webshims.bugs.bustedValidity){
109
- implementProperties.push('validationMessage');
110
- }
111
-
112
- webshims.activeLang({
113
- langObj: validityMessages,
114
- module: 'form-core',
115
- callback: function(langObj){
116
- currentValidationMessage = langObj;
117
- }
118
- });
119
-
120
- implementProperties.forEach(function(messageProp){
121
- webshims.defineNodeNamesProperty(['fieldset', 'output', 'button'], messageProp, {
122
- prop: {
123
- value: '',
124
- writeable: false
125
- }
126
- });
127
- ['input', 'select', 'textarea'].forEach(function(nodeName){
128
- var desc = webshims.defineNodeNameProperty(nodeName, messageProp, {
129
- prop: {
130
- get: function(){
131
- var elem = this;
132
- var message = '';
133
- if(!$.prop(elem, 'willValidate')){
134
- return message;
135
- }
136
-
137
- var validity = $.prop(elem, 'validity') || {valid: 1};
138
-
139
- if(validity.valid){return message;}
140
- message = webshims.getContentValidationMessage(elem, validity);
141
-
142
- if(message){return message;}
143
-
144
- if(validity.customError && elem.nodeName){
145
- message = (Modernizr.formvalidation && !webshims.bugs.bustedValidity && desc.prop._supget) ? desc.prop._supget.call(elem) : webshims.data(elem, 'customvalidationMessage');
146
- if(message){return message;}
147
- }
148
- $.each(validity, function(name, prop){
149
- if(name == 'valid' || !prop){return;}
150
-
151
- message = webshims.createValidationMessage(elem, name);
152
- if(message){
153
- return false;
154
- }
155
- });
156
- return message || '';
157
- },
158
- writeable: false
159
- }
160
- });
161
- });
162
-
163
- });
164
- });if(!Modernizr.formvalidation || jQuery.webshims.bugs.bustedValidity){
165
- jQuery.webshims.register('form-extend', function($, webshims, window, document){
166
- webshims.inputTypes = webshims.inputTypes || {};
167
- //some helper-functions
168
- var cfg = webshims.cfg.forms;
169
- var isSubmit;
170
-
171
- var isNumber = function(string){
172
- return (typeof string == 'number' || (string && string == string * 1));
173
- },
174
- typeModels = webshims.inputTypes,
175
- checkTypes = {
176
- radio: 1,
177
- checkbox: 1
178
- },
179
- getType = function(elem){
180
- return (elem.getAttribute('type') || elem.type || '').toLowerCase();
181
- }
182
- ;
183
-
184
- //API to add new input types
185
- webshims.addInputType = function(type, obj){
186
- typeModels[type] = obj;
187
- };
188
-
189
- //contsrain-validation-api
190
- var validityPrototype = {
191
- customError: false,
192
-
193
- typeMismatch: false,
194
- rangeUnderflow: false,
195
- rangeOverflow: false,
196
- stepMismatch: false,
197
- tooLong: false,
198
- patternMismatch: false,
199
- valueMissing: false,
200
-
201
- valid: true
202
- };
203
-
204
- var isPlaceholderOptionSelected = function(select){
205
- if(select.type == 'select-one' && select.size < 2){
206
- var option = $('> option:first-child', select);
207
- return !!option.prop('selected');
208
- }
209
- return false;
210
- };
211
-
212
- var validityRules = {
213
- valueMissing: function(input, val, cache){
214
- if(!input.prop('required')){return false;}
215
- var ret = false;
216
- if(!('type' in cache)){
217
- cache.type = getType(input[0]);
218
- }
219
- if(cache.nodeName == 'select'){
220
- ret = (!val && (input[0].selectedIndex < 0 || isPlaceholderOptionSelected(input[0]) ));
221
- } else if(checkTypes[cache.type]){
222
- ret = (cache.type == 'checkbox') ? !input.is(':checked') : !webshims.modules["form-core"].getGroupElements(input).filter(':checked')[0];
223
- } else {
224
- ret = !(val);
225
- }
226
- return ret;
227
- },
228
- tooLong: function(input, val, cache){
229
- return false;
230
- },
231
- typeMismatch: function (input, val, cache){
232
- if(val === '' || cache.nodeName == 'select'){return false;}
233
- var ret = false;
234
- if(!('type' in cache)){
235
- cache.type = getType(input[0]);
236
- }
237
-
238
- if(typeModels[cache.type] && typeModels[cache.type].mismatch){
239
- ret = typeModels[cache.type].mismatch(val, input);
240
- } else if('validity' in input[0]){
241
- ret = input[0].validity.typeMismatch;
242
- }
243
- return ret;
244
- },
245
- patternMismatch: function(input, val, cache) {
246
- if(val === '' || cache.nodeName == 'select'){return false;}
247
- var pattern = input.attr('pattern');
248
- if(!pattern){return false;}
249
- try {
250
- pattern = new RegExp('^(?:' + pattern + ')$');
251
- } catch(er){
252
- webshims.error('invalid pattern value: "'+ pattern +'" | '+ er);
253
- pattern = false;
254
- }
255
- if(!pattern){return false;}
256
- return !(pattern.test(val));
257
- }
258
- }
259
- ;
260
-
261
- webshims.addValidityRule = function(type, fn){
262
- validityRules[type] = fn;
263
- };
264
-
265
- $.event.special.invalid = {
266
- add: function(){
267
- $.event.special.invalid.setup.call(this.form || this);
268
- },
269
- setup: function(){
270
- var form = this.form || this;
271
- if( $.data(form, 'invalidEventShim') ){
272
- form = null;
273
- return;
274
- }
275
- $(form)
276
- .data('invalidEventShim', true)
277
- .bind('submit', $.event.special.invalid.handler)
278
- ;
279
- webshims.moveToFirstEvent(form, 'submit');
280
- if(webshims.bugs.bustedValidity && $.nodeName(form, 'form')){
281
- (function(){
282
- var noValidate = form.getAttribute('novalidate');
283
- form.setAttribute('novalidate', 'novalidate');
284
- webshims.data(form, 'bustedNoValidate', (noValidate == null) ? null : noValidate);
285
- })();
286
- }
287
- form = null;
288
- },
289
- teardown: $.noop,
290
- handler: function(e, d){
291
-
292
- if( e.type != 'submit' || e.testedValidity || !e.originalEvent || !$.nodeName(e.target, 'form') || $.prop(e.target, 'noValidate') ){return;}
293
-
294
- isSubmit = true;
295
- e.testedValidity = true;
296
- var notValid = !($(e.target).checkValidity());
297
- if(notValid){
298
- e.stopImmediatePropagation();
299
- isSubmit = false;
300
- return false;
301
- }
302
- isSubmit = false;
303
- }
304
- };
305
-
306
- var addSubmitBubbles = function(form){
307
- if (!$.support.submitBubbles && form && typeof form == 'object' && !form._submit_attached ) {
308
-
309
- $.event.add( form, 'submit._submit', function( event ) {
310
- event._submit_bubble = true;
311
- });
312
-
313
- form._submit_attached = true;
314
- }
315
- };
316
- if(!$.support.submitBubbles && $.event.special.submit){
317
- $.event.special.submit.setup = function() {
318
- // Only need this for delegated form submit events
319
- if ( $.nodeName( this, "form" ) ) {
320
- return false;
321
- }
322
-
323
- // Lazy-add a submit handler when a descendant form may potentially be submitted
324
- $.event.add( this, "click._submit keypress._submit", function( e ) {
325
- // Node name check avoids a VML-related crash in IE (#9807)
326
- var elem = e.target,
327
- form = $.nodeName( elem, 'input' ) || $.nodeName( elem, 'button' ) ? $.prop(elem, 'form') : undefined;
328
- addSubmitBubbles(form);
329
-
330
- });
331
- // return undefined since we don't need an event listener
332
- };
333
- }
334
-
335
- $.event.special.submit = $.event.special.submit || {setup: function(){return false;}};
336
- var submitSetup = $.event.special.submit.setup;
337
- $.extend($.event.special.submit, {
338
- setup: function(){
339
- if($.nodeName(this, 'form')){
340
- $(this).bind('invalid', $.noop);
341
- } else {
342
- $('form', this).bind('invalid', $.noop);
343
- }
344
- return submitSetup.apply(this, arguments);
345
- }
346
- });
347
-
348
- $(window).bind('invalid', $.noop);
349
-
350
-
351
- webshims.addInputType('email', {
352
- mismatch: (function(){
353
- //taken from http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
354
- var test = cfg.emailReg || /^[a-zA-Z0-9.!#$%&'*+-\/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
355
- return function(val){
356
- return !test.test(val);
357
- };
358
- })()
359
- });
360
-
361
- webshims.addInputType('url', {
362
- mismatch: (function(){
363
- //taken from scott gonzales
364
- 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;
365
- return function(val){
366
- return !test.test(val);
367
- };
368
- })()
369
- });
370
-
371
- webshims.defineNodeNameProperty('input', 'type', {
372
- prop: {
373
- get: function(){
374
- var elem = this;
375
- var type = (elem.getAttribute('type') || '').toLowerCase();
376
- return (webshims.inputTypes[type]) ? type : elem.type;
377
- }
378
- }
379
- });
380
-
381
- // IDLs for constrain validation API
382
- //ToDo: add object to this list
383
- webshims.defineNodeNamesProperties(['button', 'fieldset', 'output'], {
384
- checkValidity: {
385
- value: function(){return true;}
386
- },
387
- willValidate: {
388
- value: false
389
- },
390
- setCustomValidity: {
391
- value: $.noop
392
- },
393
- validity: {
394
- writeable: false,
395
- get: function(){
396
- return $.extend({}, validityPrototype);
397
- }
398
- }
399
- }, 'prop');
400
-
401
- var baseCheckValidity = function(elem){
402
- var e,
403
- v = $.prop(elem, 'validity')
404
- ;
405
- if(v){
406
- $.data(elem, 'cachedValidity', v);
407
- } else {
408
- return true;
409
- }
410
- if( !v.valid ){
411
- e = $.Event('invalid');
412
- var jElm = $(elem).trigger(e);
413
- if(isSubmit && !baseCheckValidity.unhandledInvalids && !e.isDefaultPrevented()){
414
- webshims.validityAlert.showFor(jElm);
415
- baseCheckValidity.unhandledInvalids = true;
416
- }
417
- }
418
- $.removeData(elem, 'cachedValidity');
419
- return v.valid;
420
- };
421
- var rsubmittable = /^(?:select|textarea|input)/i;
422
- webshims.defineNodeNameProperty('form', 'checkValidity', {
423
- prop: {
424
- value: function(){
425
-
426
- var ret = true,
427
- elems = $($.prop(this, 'elements')).filter(function(){
428
- if(!rsubmittable.test(this.nodeName)){return false;}
429
- var shadowData = webshims.data(this, 'shadowData');
430
- return !shadowData || !shadowData.nativeElement || shadowData.nativeElement === this;
431
- })
432
- ;
433
-
434
- baseCheckValidity.unhandledInvalids = false;
435
- for(var i = 0, len = elems.length; i < len; i++){
436
- if( !baseCheckValidity(elems[i]) ){
437
- ret = false;
438
- }
439
- }
440
- return ret;
441
- }
442
- }
443
- });
444
-
445
- webshims.defineNodeNamesProperties(['input', 'textarea', 'select'], {
446
- checkValidity: {
447
- value: function(){
448
- baseCheckValidity.unhandledInvalids = false;
449
- return baseCheckValidity($(this).getNativeElement()[0]);
450
- }
451
- },
452
- setCustomValidity: {
453
- value: function(error){
454
- $.removeData(this, 'cachedValidity');
455
- webshims.data(this, 'customvalidationMessage', ''+error);
456
- }
457
- },
458
- willValidate: {
459
- writeable: false,
460
- get: (function(){
461
- var types = {
462
- button: 1,
463
- reset: 1,
464
- hidden: 1,
465
- image: 1
466
- }
467
- ;
468
- return function(){
469
- var elem = $(this).getNativeElement()[0];
470
- //elem.name && <- we don't use to make it easier for developers
471
- return !!(!elem.disabled && !elem.readOnly && !types[elem.type] );
472
- };
473
- })()
474
- },
475
- validity: {
476
- writeable: false,
477
- get: function(){
478
- var jElm = $(this).getNativeElement();
479
- var elem = jElm[0];
480
- var validityState = $.data(elem, 'cachedValidity');
481
- if(validityState){
482
- return validityState;
483
- }
484
- validityState = $.extend({}, validityPrototype);
485
-
486
- if( !$.prop(elem, 'willValidate') || elem.type == 'submit' ){
487
- return validityState;
488
- }
489
- var val = jElm.val(),
490
- cache = {nodeName: elem.nodeName.toLowerCase()}
491
- ;
492
-
493
- validityState.customError = !!(webshims.data(elem, 'customvalidationMessage'));
494
- if( validityState.customError ){
495
- validityState.valid = false;
496
- }
497
-
498
- $.each(validityRules, function(rule, fn){
499
- if (fn(jElm, val, cache)) {
500
- validityState[rule] = true;
501
- validityState.valid = false;
502
- }
503
- });
504
- $(this).getShadowFocusElement().attr('aria-invalid', validityState.valid ? 'false' : 'true');
505
- jElm = null;
506
- elem = null;
507
- return validityState;
508
- }
509
- }
510
- }, 'prop');
511
-
512
- webshims.defineNodeNamesBooleanProperty(['input', 'textarea', 'select'], 'required', {
513
- set: function(value){
514
- $(this).getShadowFocusElement().attr('aria-required', !!(value)+'');
515
- },
516
- initAttr: (!$.browser.msie || webshims.browserVersion > 7)//only if we have aria-support
517
- });
518
-
519
- webshims.reflectProperties(['input'], ['pattern']);
520
-
521
-
522
- if( !('maxLength' in document.createElement('textarea')) ){
523
- var constrainMaxLength = (function(){
524
- var timer;
525
- var curLength = 0;
526
- var lastElement = $([]);
527
- var max = 1e9;
528
- var constrainLength = function(){
529
- var nowValue = lastElement.prop('value');
530
- var nowLen = nowValue.length;
531
- if(nowLen > curLength && nowLen > max){
532
- nowLen = Math.max(curLength, max);
533
- lastElement.prop('value', nowValue.substr(0, nowLen ));
534
- }
535
- curLength = nowLen;
536
- };
537
- var remove = function(){
538
- clearTimeout(timer);
539
- lastElement.unbind('.maxlengthconstraint');
540
- };
541
- return function(element, maxLength){
542
- remove();
543
- if(maxLength > -1){
544
- max = maxLength;
545
- curLength = $.prop(element, 'value').length;
546
- lastElement = $(element);
547
- lastElement.bind('keydown.maxlengthconstraint keypress.maxlengthconstraint paste.maxlengthconstraint cut.maxlengthconstraint', function(e){
548
- setTimeout(constrainLength, 0);
549
- });
550
- lastElement.bind('keyup.maxlengthconstraint', constrainLength);
551
- lastElement.bind('blur.maxlengthconstraint', remove);
552
- timer = setInterval(constrainLength, 200);
553
- }
554
- };
555
- })();
556
-
557
- constrainMaxLength.update = function(element, maxLength){
558
- if($(element).is(':focus')){
559
- if(maxLength == null){
560
- maxLength = $.prop(element, 'maxlength');
561
- }
562
- constrainMaxLength(e.target, maxLength);
563
- }
564
- };
565
-
566
- $(document).bind('focusin', function(e){
567
- var maxLength;
568
- if(e.target.nodeName == "TEXTAREA" && (maxLength = $.prop(e.target, 'maxlength')) > -1){
569
- constrainMaxLength(e.target, maxLength);
570
- }
571
- });
572
-
573
- webshims.defineNodeNameProperty('textarea', 'maxlength', {
574
- attr: {
575
- set: function(val){
576
- this.setAttribute('maxlength', ''+val);
577
- constrainMaxLength.update(this);
578
- },
579
- get: function(){
580
- var ret = this.getAttribute('maxlength');
581
- return ret == null ? undefined : ret;
582
- }
583
- },
584
- prop: {
585
- set: function(val){
586
- if(isNumber(val)){
587
- if(val < 0){
588
- throw('INDEX_SIZE_ERR');
589
- }
590
- val = parseInt(val, 10);
591
- this.setAttribute('maxlength', val);
592
- constrainMaxLength.update(this, val);
593
- return;
594
- }
595
- this.setAttribute('maxlength', ''+ 0);
596
- constrainMaxLength.update(this, 0);
597
- },
598
- get: function(){
599
- var val = this.getAttribute('maxlength');
600
- return (isNumber(val) && val >= 0) ? parseInt(val, 10) : -1;
601
-
602
- }
603
- }
604
- });
605
- webshims.defineNodeNameProperty('textarea', 'maxLength', {
606
- prop: {
607
- set: function(val){
608
- $.prop(this, 'maxlength', val);
609
- },
610
- get: function(){
611
- return $.prop(this, 'maxlength');
612
- }
613
- }
614
- });
615
- }
616
-
617
-
618
-
619
- var submitterTypes = {submit: 1, button: 1, image: 1};
620
- var formSubmitterDescriptors = {};
621
- [
622
- {
623
- name: "enctype",
624
- limitedTo: {
625
- "application/x-www-form-urlencoded": 1,
626
- "multipart/form-data": 1,
627
- "text/plain": 1
628
- },
629
- defaultProp: "application/x-www-form-urlencoded",
630
- proptype: "enum"
631
- },
632
- {
633
- name: "method",
634
- limitedTo: {
635
- "get": 1,
636
- "post": 1
637
- },
638
- defaultProp: "get",
639
- proptype: "enum"
640
- },
641
- {
642
- name: "action",
643
- proptype: "url"
644
- },
645
- {
646
- name: "target"
647
- },
648
- {
649
- name: "novalidate",
650
- propName: "noValidate",
651
- proptype: "boolean"
652
- }
653
- ].forEach(function(desc){
654
- var propName = 'form'+ (desc.propName || desc.name).replace(/^[a-z]/, function(f){
655
- return f.toUpperCase();
656
- });
657
- var attrName = 'form'+ desc.name;
658
- var formName = desc.name;
659
- var eventName = 'click.webshimssubmittermutate'+formName;
660
-
661
- var changeSubmitter = function(){
662
- var elem = this;
663
- if( !('form' in elem) || !submitterTypes[elem.type] ){return;}
664
- var form = $.prop(elem, 'form');
665
- if(!form){return;}
666
- var attr = $.attr(elem, attrName);
667
- if(attr != null && ( !desc.limitedTo || attr.toLowerCase() === $.prop(elem, propName))){
668
-
669
- var oldAttr = $.attr(form, formName);
670
-
671
- $.attr(form, formName, attr);
672
- setTimeout(function(){
673
- if(oldAttr != null){
674
- $.attr(form, formName, oldAttr);
675
- } else {
676
- try {
677
- $(form).removeAttr(formName);
678
- } catch(er){
679
- form.removeAttribute(formName);
680
- }
681
- }
682
- }, 9);
683
- }
684
- };
685
-
686
-
687
-
688
- switch(desc.proptype) {
689
- case "url":
690
- var urlForm = document.createElement('form');
691
- formSubmitterDescriptors[propName] = {
692
- prop: {
693
- set: function(value){
694
- $.attr(this, attrName, value);
695
- },
696
- get: function(){
697
- var value = $.attr(this, attrName);
698
- if(value == null){return '';}
699
- urlForm.setAttribute('action', value);
700
- return urlForm.action;
701
- }
702
- }
703
- };
704
- break;
705
- case "boolean":
706
- formSubmitterDescriptors[propName] = {
707
- prop: {
708
- set: function(val){
709
- val = !!val;
710
- if(val){
711
- $.attr(this, 'formnovalidate', 'formnovalidate');
712
- } else {
713
- $(this).removeAttr('formnovalidate');
714
- }
715
- },
716
- get: function(){
717
- return $.attr(this, 'formnovalidate') != null;
718
- }
719
- }
720
- };
721
- break;
722
- case "enum":
723
- formSubmitterDescriptors[propName] = {
724
- prop: {
725
- set: function(value){
726
- $.attr(this, attrName, value);
727
- },
728
- get: function(){
729
- var value = $.attr(this, attrName);
730
- return (!value || ( (value = value.toLowerCase()) && !desc.limitedTo[value] )) ? desc.defaultProp : value;
731
- }
732
- }
733
- };
734
- break;
735
- default:
736
- formSubmitterDescriptors[propName] = {
737
- prop: {
738
- set: function(value){
739
- $.attr(this, attrName, value);
740
- },
741
- get: function(){
742
- var value = $.attr(this, attrName);
743
- return (value != null) ? value : "";
744
- }
745
- }
746
- };
747
- }
748
-
749
-
750
- if(!formSubmitterDescriptors[attrName]){
751
- formSubmitterDescriptors[attrName] = {};
752
- }
753
- formSubmitterDescriptors[attrName].attr = {
754
- set: function(value){
755
- formSubmitterDescriptors[attrName].attr._supset.call(this, value);
756
- $(this).unbind(eventName).bind(eventName, changeSubmitter);
757
- },
758
- get: function(){
759
- return formSubmitterDescriptors[attrName].attr._supget.call(this);
760
- }
761
- };
762
- formSubmitterDescriptors[attrName].initAttr = true;
763
- formSubmitterDescriptors[attrName].removeAttr = {
764
- value: function(){
765
- $(this).unbind(eventName);
766
- formSubmitterDescriptors[attrName].removeAttr._supvalue.call(this);
767
- }
768
- };
769
- });
770
-
771
- webshims.defineNodeNamesProperties(['input', 'button'], formSubmitterDescriptors);
772
-
773
-
774
- if(!$.support.getSetAttribute && $('<form novalidate></form>').attr('novalidate') == null){
775
- webshims.defineNodeNameProperty('form', 'novalidate', {
776
- attr: {
777
- set: function(val){
778
- this.setAttribute('novalidate', ''+val);
779
- },
780
- get: function(){
781
- var ret = this.getAttribute('novalidate');
782
- return ret == null ? undefined : ret;
783
- }
784
- }
785
- });
786
- } else if(webshims.bugs.bustedValidity){
787
-
788
- webshims.defineNodeNameProperty('form', 'novalidate', {
789
- attr: {
790
- set: function(val){
791
- webshims.data(this, 'bustedNoValidate', ''+val);
792
- },
793
- get: function(){
794
- var ret = webshims.data(this, 'bustedNoValidate');
795
- return ret == null ? undefined : ret;
796
- }
797
- },
798
- removeAttr: {
799
- value: function(){
800
- webshims.data(this, 'bustedNoValidate', null);
801
- }
802
- }
803
- });
804
-
805
- $.each(['rangeUnderflow', 'rangeOverflow', 'stepMismatch'], function(i, name){
806
- validityRules[name] = function(elem){
807
- return (elem[0].validity || {})[name] || false;
808
- };
809
- });
810
-
811
- }
812
-
813
- webshims.defineNodeNameProperty('form', 'noValidate', {
814
- prop: {
815
- set: function(val){
816
- val = !!val;
817
- if(val){
818
- $.attr(this, 'novalidate', 'novalidate');
819
- } else {
820
- $(this).removeAttr('novalidate');
821
- }
822
- },
823
- get: function(){
824
- return $.attr(this, 'novalidate') != null;
825
- }
826
- }
827
- });
828
-
829
- if($.browser.webkit && Modernizr.inputtypes.date){
830
- (function(){
831
-
832
- var noInputTriggerEvts = {updateInput: 1, input: 1},
833
- fixInputTypes = {
834
- date: 1,
835
- time: 1,
836
- "datetime-local": 1
837
- },
838
- noFocusEvents = {
839
- focusout: 1,
840
- blur: 1
841
- },
842
- changeEvts = {
843
- updateInput: 1,
844
- change: 1
845
- },
846
- observe = function(input){
847
- var timer,
848
- focusedin = true,
849
- lastInputVal = input.prop('value'),
850
- lastChangeVal = lastInputVal,
851
- trigger = function(e){
852
- //input === null
853
- if(!input){return;}
854
- var newVal = input.prop('value');
855
-
856
- if(newVal !== lastInputVal){
857
- lastInputVal = newVal;
858
- if(!e || !noInputTriggerEvts[e.type]){
859
- input.trigger('input');
860
- }
861
- }
862
- if(e && changeEvts[e.type]){
863
- lastChangeVal = newVal;
864
- }
865
- if(!focusedin && newVal !== lastChangeVal){
866
- input.trigger('change');
867
- }
868
- },
869
- extraTimer,
870
- extraTest = function(){
871
- clearTimeout(extraTimer);
872
- extraTimer = setTimeout(trigger, 9);
873
- },
874
- unbind = function(e){
875
- clearInterval(timer);
876
- setTimeout(function(){
877
- if(e && noFocusEvents[e.type]){
878
- focusedin = false;
879
- }
880
- if(input){
881
- input.unbind('focusout blur', unbind).unbind('input change updateInput', trigger);
882
- trigger();
883
- }
884
- input = null;
885
- }, 1);
886
-
887
- }
888
- ;
889
-
890
- clearInterval(timer);
891
- timer = setInterval(trigger, 160);
892
- extraTest();
893
- input.unbind('focusout blur', unbind).unbind('input change updateInput', trigger);
894
- input.bind('focusout blur', unbind).bind('input updateInput change', trigger);
895
- }
896
- ;
897
- if($.event.customEvent){
898
- $.event.customEvent.updateInput = true;
899
- }
900
-
901
- (function(){
902
-
903
- var correctValue = function(elem){
904
- var i = 1;
905
- var len = 3;
906
- var abort, val;
907
- if(elem.type == 'date' && (isSubmit || !$(elem).is(':focus'))){
908
- val = elem.value;
909
- if(val && val.length < 10 && (val = val.split('-')) && val.length == len){
910
- for(; i < len; i++){
911
- if(val[i].length == 1){
912
- val[i] = '0'+val[i];
913
- } else if(val[i].length != 2){
914
- abort = true;
915
- break;
916
- }
917
- }
918
- if(!abort){
919
- val = val.join('-');
920
- $.prop(elem, 'value', val);
921
- return val;
922
- }
923
- }
924
- }
925
- };
926
- var inputCheckValidityDesc, formCheckValidityDesc, inputValueDesc, inputValidityDesc;
927
-
928
- inputCheckValidityDesc = webshims.defineNodeNameProperty('input', 'checkValidity', {
929
- prop: {
930
- value: function(){
931
- correctValue(this);
932
- return inputCheckValidityDesc.prop._supvalue.apply(this, arguments);
933
- }
934
- }
935
- });
936
-
937
- formCheckValidityDesc = webshims.defineNodeNameProperty('form', 'checkValidity', {
938
- prop: {
939
- value: function(){
940
- $('input', this).each(function(){
941
- correctValue(this);
942
- });
943
- return formCheckValidityDesc.prop._supvalue.apply(this, arguments);
944
- }
945
- }
946
- });
947
-
948
- inputValueDesc = webshims.defineNodeNameProperty('input', 'value', {
949
- prop: {
950
- set: function(){
951
- return inputValueDesc.prop._supset.apply(this, arguments);
952
- },
953
- get: function(){
954
- return correctValue(this) || inputValueDesc.prop._supget.apply(this, arguments);
955
- }
956
- }
957
- });
958
-
959
- inputValidityDesc = webshims.defineNodeNameProperty('input', 'validity', {
960
- prop: {
961
- writeable: false,
962
- get: function(){
963
- correctValue(this);
964
- return inputValidityDesc.prop._supget.apply(this, arguments);
965
- }
966
- }
967
- });
968
-
969
- $(document).bind('change', function(e){
970
- isChangeSubmit = true;
971
- correctValue(e.target);
972
- isChangeSubmit = false;
973
- });
974
-
975
- })();
976
-
977
- $(document)
978
- .bind('focusin', function(e){
979
- if( e.target && fixInputTypes[e.target.type] && !e.target.readOnly && !e.target.disabled ){
980
- observe($(e.target));
981
- }
982
- })
983
- ;
984
-
985
-
986
- })();
987
- }
988
-
989
- webshims.addReady(function(context, contextElem){
990
- //start constrain-validation
991
- var focusElem;
992
- $('form', context)
993
- .add(contextElem.filter('form'))
994
- .bind('invalid', $.noop)
995
- ;
996
-
997
- try {
998
- if(context == document && !('form' in (document.activeElement || {}))) {
999
- focusElem = $('input[autofocus], select[autofocus], textarea[autofocus]', context).eq(0).getShadowFocusElement()[0];
1000
- if (focusElem && focusElem.offsetHeight && focusElem.offsetWidth) {
1001
- focusElem.focus();
1002
- }
1003
- }
1004
- }
1005
- catch (er) {}
1006
-
1007
- });
1008
-
1009
- if(!Modernizr.formattribute || !Modernizr.fieldsetdisabled){
1010
- (function(){
1011
- (function(prop, undefined){
1012
- $.prop = function(elem, name, value){
1013
- var ret;
1014
- if(elem && elem.nodeType == 1 && value === undefined && $.nodeName(elem, 'form') && elem.id){
1015
- ret = document.getElementsByName(name);
1016
- if(!ret || !ret.length){
1017
- ret = document.getElementById(name);
1018
- }
1019
- if(ret){
1020
- ret = $(ret).filter(function(){
1021
- return $.prop(this, 'form') == elem;
1022
- }).get();
1023
- if(ret.length){
1024
- return ret.length == 1 ? ret[0] : ret;
1025
- }
1026
- }
1027
- }
1028
- return prop.apply(this, arguments);
1029
- };
1030
- })($.prop, undefined);
1031
- var removeAddedElements = function(form){
1032
- var elements = $.data(form, 'webshimsAddedElements');
1033
- if(elements){
1034
- elements.remove();
1035
- $.removeData(form, 'webshimsAddedElements');
1036
- }
1037
- };
1038
- var rCRLF = /\r?\n/g,
1039
- rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
1040
- rselectTextarea = /^(?:select|textarea)/i;
1041
-
1042
- if(!Modernizr.formattribute){
1043
- webshims.defineNodeNamesProperty(['input', 'textarea', 'select', 'button', 'fieldset'], 'form', {
1044
- prop: {
1045
- get: function(){
1046
- var form = webshims.contentAttr(this, 'form');
1047
- if(form){
1048
- form = document.getElementById(form);
1049
- if(form && !$.nodeName(form, 'form')){
1050
- form = null;
1051
- }
1052
- }
1053
- return form || this.form;
1054
- },
1055
- writeable: false
1056
- }
1057
- });
1058
-
1059
-
1060
- webshims.defineNodeNamesProperty(['form'], 'elements', {
1061
- prop: {
1062
- get: function(){
1063
- var id = this.id;
1064
- var elements = $.makeArray(this.elements);
1065
- if(id){
1066
- elements = $(elements).add('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"], button[form="'+ id +'"], fieldset[form="'+ id +'"]').not('.webshims-visual-hide > *').get();
1067
- }
1068
- return elements;
1069
- },
1070
- writeable: false
1071
- }
1072
- });
1073
-
1074
-
1075
-
1076
- $(function(){
1077
- var stopPropagation = function(e){
1078
- e.stopPropagation();
1079
- };
1080
- $(document).bind('submit', function(e){
1081
-
1082
- if(!e.isDefaultPrevented()){
1083
- var form = e.target;
1084
- var id = form.id;
1085
- var elements;
1086
-
1087
-
1088
- if(id){
1089
- removeAddedElements(form);
1090
-
1091
- elements = $('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"]')
1092
- .filter(function(){
1093
- return !this.disabled && this.name && this.form != form;
1094
- })
1095
- .clone()
1096
- ;
1097
- if(elements.length){
1098
- $.data(form, 'webshimsAddedElements', $('<div class="webshims-visual-hide" />').append(elements).appendTo(form));
1099
- setTimeout(function(){
1100
- removeAddedElements(form);
1101
- }, 9);
1102
- }
1103
- elements = null;
1104
- }
1105
- }
1106
- });
1107
-
1108
- $(document).bind('click', function(e){
1109
- if(!e.isDefaultPrevented() && $(e.target).is('input[type="submit"][form], button[form], input[type="button"][form], input[type="image"][form], input[type="reset"][form]')){
1110
- var trueForm = $.prop(e.target, 'form');
1111
- var formIn = e.target.form;
1112
- var clone;
1113
- if(trueForm && trueForm != formIn){
1114
- clone = $(e.target)
1115
- .clone()
1116
- .removeAttr('form')
1117
- .addClass('webshims-visual-hide')
1118
- .bind('click', stopPropagation)
1119
- .appendTo(trueForm)
1120
- ;
1121
- if(formIn){
1122
- e.preventDefault();
1123
- }
1124
- addSubmitBubbles(trueForm);
1125
- clone.trigger('click');
1126
- setTimeout(function(){
1127
- clone.remove();
1128
- clone = null;
1129
- }, 9);
1130
- }
1131
- }
1132
- });
1133
- });
1134
- }
1135
-
1136
- if(!Modernizr.fieldsetdisabled){
1137
- webshims.defineNodeNamesProperty(['fieldset'], 'elements', {
1138
- prop: {
1139
- get: function(){
1140
- //add listed elements without keygen, object, output
1141
- return $('input, select, textarea, button, fieldset', this).get() || [];
1142
- },
1143
- writeable: false
1144
- }
1145
- });
1146
- }
1147
-
1148
- $.fn.serializeArray = function() {
1149
- return this.map(function(){
1150
- var elements = $.prop(this, 'elements');
1151
- return elements ? $.makeArray( elements ) : this;
1152
- })
1153
- .filter(function(){
1154
- return this.name && !this.disabled &&
1155
- ( this.checked || rselectTextarea.test( this.nodeName ) ||
1156
- rinput.test( this.type ) );
1157
- })
1158
- .map(function( i, elem ){
1159
- var val = $( this ).val();
1160
-
1161
- return val == null ?
1162
- null :
1163
- $.isArray( val ) ?
1164
- $.map( val, function( val, i ){
1165
- return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
1166
- }) :
1167
- { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
1168
- }).get();
1169
- };
1170
-
1171
- })();
1172
- }
1173
-
1174
- (function(){
1175
- Modernizr.textareaPlaceholder = !!('placeholder' in $('<textarea />')[0]);
1176
- var bustedTextarea = $.browser.webkit && Modernizr.textareaPlaceholder && webshims.browserVersion < 535;
1177
- if(Modernizr.input.placeholder && Modernizr.textareaPlaceholder && !bustedTextarea){return;}
1178
-
1179
- var isOver = (webshims.cfg.forms.placeholderType == 'over');
1180
- var isResponsive = (webshims.cfg.forms.responsivePlaceholder);
1181
- var polyfillElements = ['textarea'];
1182
- if(!Modernizr.input.placeholder){
1183
- polyfillElements.push('input');
1184
- }
1185
-
1186
- var setSelection = function(elem){
1187
- try {
1188
- if(elem.setSelectionRange){
1189
- elem.setSelectionRange(0, 0);
1190
- return true;
1191
- } else if(elem.createTextRange){
1192
- var range = elem.createTextRange();
1193
- range.collapse(true);
1194
- range.moveEnd('character', 0);
1195
- range.moveStart('character', 0);
1196
- range.select();
1197
- return true;
1198
- }
1199
- } catch(er){}
1200
- };
1201
-
1202
- var hidePlaceholder = function(elem, data, value, _onFocus){
1203
- if(value === false){
1204
- value = $.prop(elem, 'value');
1205
- }
1206
- if(!isOver && elem.type != 'password'){
1207
- if(!value && _onFocus && setSelection(elem)){
1208
- var selectTimer = setTimeout(function(){
1209
- setSelection(elem);
1210
- }, 9);
1211
- $(elem)
1212
- .unbind('.placeholderremove')
1213
- .bind('keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove', function(e){
1214
- if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
1215
- elem.value = $.prop(elem, 'value');
1216
- data.box.removeClass('placeholder-visible');
1217
- clearTimeout(selectTimer);
1218
- $(elem).unbind('.placeholderremove');
1219
- })
1220
- .bind('mousedown.placeholderremove drag.placeholderremove select.placeholderremove', function(e){
1221
- setSelection(elem);
1222
- clearTimeout(selectTimer);
1223
- selectTimer = setTimeout(function(){
1224
- setSelection(elem);
1225
- }, 9);
1226
- })
1227
- .bind('blur.placeholderremove', function(){
1228
- clearTimeout(selectTimer);
1229
- $(elem).unbind('.placeholderremove');
1230
- })
1231
- ;
1232
- return;
1233
- }
1234
- elem.value = value;
1235
- } else if(!value && _onFocus){
1236
- $(elem)
1237
- .unbind('.placeholderremove')
1238
- .bind('keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove', function(e){
1239
- if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
1240
- data.box.removeClass('placeholder-visible');
1241
- $(elem).unbind('.placeholderremove');
1242
- })
1243
- .bind('blur.placeholderremove', function(){
1244
- $(elem).unbind('.placeholderremove');
1245
- })
1246
- ;
1247
- return;
1248
- }
1249
- data.box.removeClass('placeholder-visible');
1250
- },
1251
- showPlaceholder = function(elem, data, placeholderTxt){
1252
- if(placeholderTxt === false){
1253
- placeholderTxt = $.prop(elem, 'placeholder');
1254
- }
1255
-
1256
- if(!isOver && elem.type != 'password'){
1257
- elem.value = placeholderTxt;
1258
- }
1259
- data.box.addClass('placeholder-visible');
1260
- },
1261
- changePlaceholderVisibility = function(elem, value, placeholderTxt, data, type){
1262
- if(!data){
1263
- data = $.data(elem, 'placeHolder');
1264
- if(!data){return;}
1265
- }
1266
- $(elem).unbind('.placeholderremove');
1267
- if(type == 'focus' || (!type && $(elem).is(':focus'))){
1268
- if(elem.type == 'password' || isOver || $(elem).hasClass('placeholder-visible')){
1269
- hidePlaceholder(elem, data, '', true);
1270
- }
1271
- return;
1272
- }
1273
- if(value === false){
1274
- value = $.prop(elem, 'value');
1275
- }
1276
- if(value){
1277
- hidePlaceholder(elem, data, value);
1278
- return;
1279
- }
1280
- if(placeholderTxt === false){
1281
- placeholderTxt = $.attr(elem, 'placeholder') || '';
1282
- }
1283
- if(placeholderTxt && !value){
1284
- showPlaceholder(elem, data, placeholderTxt);
1285
- } else {
1286
- hidePlaceholder(elem, data, value);
1287
- }
1288
- },
1289
- createPlaceholder = function(elem){
1290
- elem = $(elem);
1291
- var id = elem.prop('id'),
1292
- hasLabel = !!(elem.prop('title') || elem.attr('aria-labelledby'))
1293
- ;
1294
- if(!hasLabel && id){
1295
- hasLabel = !!( $('label[for="'+ id +'"]', elem[0].form)[0] );
1296
- }
1297
- if(!hasLabel){
1298
- if(!id){
1299
- id = $.webshims.getID(elem);
1300
- }
1301
- hasLabel = !!($('label #'+ id)[0]);
1302
- }
1303
- return $( hasLabel ? '<span class="placeholder-text"></span>' : '<label for="'+ id +'" class="placeholder-text"></label>');
1304
- },
1305
- pHolder = (function(){
1306
- var delReg = /\n|\r|\f|\t/g,
1307
- allowedPlaceholder = {
1308
- text: 1,
1309
- search: 1,
1310
- url: 1,
1311
- email: 1,
1312
- password: 1,
1313
- tel: 1
1314
- }
1315
- ;
1316
-
1317
- return {
1318
- create: function(elem){
1319
- var data = $.data(elem, 'placeHolder');
1320
- var form;
1321
- var responsiveElem;
1322
- if(data){return data;}
1323
- data = $.data(elem, 'placeHolder', {});
1324
-
1325
- $(elem).bind('focus.placeholder blur.placeholder', function(e){
1326
- changePlaceholderVisibility(this, false, false, data, e.type );
1327
- data.box[e.type == 'focus' ? 'addClass' : 'removeClass']('placeholder-focused');
1328
- });
1329
-
1330
- if((form = $.prop(elem, 'form'))){
1331
- $(form).bind('reset.placeholder', function(e){
1332
- setTimeout(function(){
1333
- changePlaceholderVisibility(elem, false, false, data, e.type );
1334
- }, 0);
1335
- });
1336
- }
1337
-
1338
- if(elem.type == 'password' || isOver){
1339
- data.text = createPlaceholder(elem);
1340
- if(isResponsive || $(elem).is('.responsive-width') || (elem.currentStyle || {width: ''}).width.indexOf('%') != -1){
1341
- responsiveElem = true;
1342
- data.box = data.text;
1343
- } else {
1344
- data.box = $(elem)
1345
- .wrap('<span class="placeholder-box placeholder-box-'+ (elem.nodeName || '').toLowerCase() +' placeholder-box-'+$.css(elem, 'float')+'" />')
1346
- .parent()
1347
- ;
1348
- }
1349
- data.text
1350
- .insertAfter(elem)
1351
- .bind('mousedown.placeholder', function(){
1352
- changePlaceholderVisibility(this, false, false, data, 'focus');
1353
- try {
1354
- setTimeout(function(){
1355
- elem.focus();
1356
- }, 0);
1357
- } catch(e){}
1358
- return false;
1359
- })
1360
- ;
1361
-
1362
-
1363
- $.each(['lineHeight', 'fontSize', 'fontFamily', 'fontWeight'], function(i, style){
1364
- var prop = $.css(elem, style);
1365
- if(data.text.css(style) != prop){
1366
- data.text.css(style, prop);
1367
- }
1368
- });
1369
- $.each(['Left', 'Top'], function(i, side){
1370
- 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);
1371
- data.text.css('padding'+ side, size);
1372
- });
1373
-
1374
- $(elem)
1375
- .bind('updateshadowdom', function(){
1376
- var height, width;
1377
- if((width = elem.offsetWidth) || (height = elem.offsetHeight)){
1378
- data.text
1379
- .css({
1380
- width: width,
1381
- height: height
1382
- })
1383
- .css($(elem).position())
1384
- ;
1385
- }
1386
- })
1387
- .triggerHandler('updateshadowdom')
1388
- ;
1389
-
1390
- } else {
1391
- var reset = function(e){
1392
- if($(elem).hasClass('placeholder-visible')){
1393
- hidePlaceholder(elem, data, '');
1394
- if(e && e.type == 'submit'){
1395
- setTimeout(function(){
1396
- if(e.isDefaultPrevented()){
1397
- changePlaceholderVisibility(elem, false, false, data );
1398
- }
1399
- }, 9);
1400
- }
1401
- }
1402
- };
1403
-
1404
- $(window).bind('beforeunload', reset);
1405
- data.box = $(elem);
1406
- if(form){
1407
- $(form).submit(reset);
1408
- }
1409
- }
1410
-
1411
- return data;
1412
- },
1413
- update: function(elem, val){
1414
- var type = ($.attr(elem, 'type') || $.prop(elem, 'type') || '').toLowerCase();
1415
- if(!allowedPlaceholder[type] && !$.nodeName(elem, 'textarea')){
1416
- webshims.error('placeholder not allowed on input[type="'+type+'"]');
1417
- if(type == 'date'){
1418
- webshims.error('but you can use data-placeholder for input[type="date"]');
1419
- }
1420
- return;
1421
- }
1422
-
1423
-
1424
- var data = pHolder.create(elem);
1425
- if(data.text){
1426
- data.text.text(val);
1427
- }
1428
-
1429
- changePlaceholderVisibility(elem, false, val, data);
1430
- }
1431
- };
1432
- })()
1433
- ;
1434
-
1435
- $.webshims.publicMethods = {
1436
- pHolder: pHolder
1437
- };
1438
- polyfillElements.forEach(function(nodeName){
1439
- var desc = webshims.defineNodeNameProperty(nodeName, 'placeholder', {
1440
- attr: {
1441
- set: function(val){
1442
- var elem = this;
1443
- if(bustedTextarea){
1444
- webshims.data(elem, 'textareaPlaceholder', val);
1445
- elem.placeholder = '';
1446
- } else {
1447
- webshims.contentAttr(elem, 'placeholder', val);
1448
- }
1449
- pHolder.update(elem, val);
1450
- },
1451
- get: function(){
1452
- var ret = (bustedTextarea) ? webshims.data(this, 'textareaPlaceholder') : '';
1453
- return ret || webshims.contentAttr(this, 'placeholder');
1454
- }
1455
- },
1456
- reflect: true,
1457
- initAttr: true
1458
- });
1459
- });
1460
-
1461
-
1462
- polyfillElements.forEach(function(name){
1463
- var placeholderValueDesc = {};
1464
- var desc;
1465
- ['attr', 'prop'].forEach(function(propType){
1466
- placeholderValueDesc[propType] = {
1467
- set: function(val){
1468
- var elem = this;
1469
- var placeholder;
1470
- if(bustedTextarea){
1471
- placeholder = webshims.data(elem, 'textareaPlaceholder');
1472
- }
1473
- if(!placeholder){
1474
- placeholder = webshims.contentAttr(elem, 'placeholder');
1475
- }
1476
- $.removeData(elem, 'cachedValidity');
1477
- var ret = desc[propType]._supset.call(elem, val);
1478
- if(placeholder && 'value' in elem){
1479
- changePlaceholderVisibility(elem, val, placeholder);
1480
- }
1481
- return ret;
1482
- },
1483
- get: function(){
1484
- var elem = this;
1485
- return $(elem).hasClass('placeholder-visible') ? '' : desc[propType]._supget.call(elem);
1486
- }
1487
- };
1488
- });
1489
- desc = webshims.defineNodeNameProperty(name, 'value', placeholderValueDesc);
1490
- });
1491
-
1492
- })();
1493
-
1494
- (function(){
1495
- var doc = document;
1496
- if( 'value' in document.createElement('output') ){return;}
1497
-
1498
- webshims.defineNodeNameProperty('output', 'value', {
1499
- prop: {
1500
- set: function(value){
1501
- var setVal = $.data(this, 'outputShim');
1502
- if(!setVal){
1503
- setVal = outputCreate(this);
1504
- }
1505
- setVal(value);
1506
- },
1507
- get: function(){
1508
- return webshims.contentAttr(this, 'value') || $(this).text() || '';
1509
- }
1510
- }
1511
- });
1512
-
1513
-
1514
- webshims.onNodeNamesPropertyModify('input', 'value', function(value, boolVal, type){
1515
- if(type == 'removeAttr'){return;}
1516
- var setVal = $.data(this, 'outputShim');
1517
- if(setVal){
1518
- setVal(value);
1519
- }
1520
- });
1521
-
1522
- var outputCreate = function(elem){
1523
- if(elem.getAttribute('aria-live')){return;}
1524
- elem = $(elem);
1525
- var value = (elem.text() || '').trim();
1526
- var id = elem.attr('id');
1527
- var htmlFor = elem.attr('for');
1528
- var shim = $('<input class="output-shim" type="text" disabled name="'+ (elem.attr('name') || '')+'" value="'+value+'" style="display: none !important;" />').insertAfter(elem);
1529
- var form = shim[0].form || doc;
1530
- var setValue = function(val){
1531
- shim[0].value = val;
1532
- val = shim[0].value;
1533
- elem.text(val);
1534
- webshims.contentAttr(elem[0], 'value', val);
1535
- };
1536
-
1537
- elem[0].defaultValue = value;
1538
- webshims.contentAttr(elem[0], 'value', value);
1539
-
1540
- elem.attr({'aria-live': 'polite'});
1541
- if(id){
1542
- shim.attr('id', id);
1543
- elem.attr('aria-labelledby', webshims.getID($('label[for="'+id+'"]', form)));
1544
- }
1545
- if(htmlFor){
1546
- id = webshims.getID(elem);
1547
- htmlFor.split(' ').forEach(function(control){
1548
- control = document.getElementById(control);
1549
- if(control){
1550
- control.setAttribute('aria-controls', id);
1551
- }
1552
- });
1553
- }
1554
- elem.data('outputShim', setValue );
1555
- shim.data('outputShim', setValue );
1556
- return setValue;
1557
- };
1558
-
1559
- webshims.addReady(function(context, contextElem){
1560
- $('output', context).add(contextElem.filter('output')).each(function(){
1561
- outputCreate(this);
1562
- });
1563
- });
1564
-
1565
- /*
1566
- * Implements input event in all browsers
1567
- */
1568
- (function(){
1569
- var noInputTriggerEvts = {updateInput: 1, input: 1},
1570
- noInputTypes = {
1571
- radio: 1,
1572
- checkbox: 1,
1573
- submit: 1,
1574
- button: 1,
1575
- image: 1,
1576
- reset: 1,
1577
- file: 1
1578
-
1579
- //pro forma
1580
- ,color: 1
1581
- //,range: 1
1582
- },
1583
- observe = function(input){
1584
- var timer,
1585
- lastVal = input.prop('value'),
1586
- trigger = function(e){
1587
- //input === null
1588
- if(!input){return;}
1589
- var newVal = input.prop('value');
1590
-
1591
- if(newVal !== lastVal){
1592
- lastVal = newVal;
1593
- if(!e || !noInputTriggerEvts[e.type]){
1594
- webshims.triggerInlineForm && webshims.triggerInlineForm(input[0], 'input');
1595
- }
1596
- }
1597
- },
1598
- extraTimer,
1599
- extraTest = function(){
1600
- clearTimeout(extraTimer);
1601
- extraTimer = setTimeout(trigger, 9);
1602
- },
1603
- unbind = function(){
1604
- input.unbind('focusout', unbind).unbind('keyup keypress keydown paste cut', extraTest).unbind('input change updateInput', trigger);
1605
- clearInterval(timer);
1606
- setTimeout(function(){
1607
- trigger();
1608
- input = null;
1609
- }, 1);
1610
-
1611
- }
1612
- ;
1613
-
1614
- clearInterval(timer);
1615
- timer = setInterval(trigger, 99);
1616
- extraTest();
1617
- input.bind('keyup keypress keydown paste cut', extraTest).bind('focusout', unbind).bind('input updateInput change', trigger);
1618
- }
1619
- ;
1620
- if($.event.customEvent){
1621
- $.event.customEvent.updateInput = true;
1622
- }
1623
-
1624
- $(doc)
1625
- .bind('focusin', function(e){
1626
- if( e.target && e.target.type && !e.target.readOnly && !e.target.disabled && (e.target.nodeName || '').toLowerCase() == 'input' && !noInputTypes[e.target.type] ){
1627
- observe($(e.target));
1628
- }
1629
- })
1630
- ;
1631
- })();
1632
- })();
1633
-
1634
- }); //webshims.ready end
1635
- }//end formvalidation
1
+ jQuery.webshims.register('form-message', function($, webshims, window, document, undefined, options){
2
+ "use strict";
3
+ var validityMessages = webshims.validityMessages;
4
+
5
+ var implementProperties = (options.overrideMessages || options.customMessages) ? ['customValidationMessage'] : [];
6
+
7
+ validityMessages['en'] = $.extend(true, {
8
+ typeMismatch: {
9
+ email: 'Please enter an email address.',
10
+ url: 'Please enter a URL.',
11
+ number: 'Please enter a number.',
12
+ date: 'Please enter a date.',
13
+ time: 'Please enter a time.',
14
+ range: 'Invalid input.',
15
+ "datetime-local": 'Please enter a datetime.'
16
+ },
17
+ rangeUnderflow: {
18
+ defaultMessage: 'Value must be greater than or equal to {%min}.'
19
+ },
20
+ rangeOverflow: {
21
+ defaultMessage: 'Value must be less than or equal to {%max}.'
22
+ },
23
+ stepMismatch: 'Invalid input.',
24
+ tooLong: 'Please enter at most {%maxlength} character(s). You entered {%valueLen}.',
25
+
26
+ patternMismatch: 'Invalid input. {%title}',
27
+ valueMissing: {
28
+ defaultMessage: 'Please fill out this field.',
29
+ checkbox: 'Please check this box if you want to proceed.'
30
+ }
31
+ }, (validityMessages['en'] || validityMessages['en-US'] || {}));
32
+
33
+
34
+ ['select', 'radio'].forEach(function(type){
35
+ validityMessages['en'].valueMissing[type] = 'Please select an option.';
36
+ });
37
+
38
+ ['date', 'time', 'datetime-local'].forEach(function(type){
39
+ validityMessages.en.rangeUnderflow[type] = 'Value must be at or after {%min}.';
40
+ });
41
+ ['date', 'time', 'datetime-local'].forEach(function(type){
42
+ validityMessages.en.rangeOverflow[type] = 'Value must be at or before {%max}.';
43
+ });
44
+
45
+ validityMessages['en-US'] = validityMessages['en-US'] || validityMessages['en'];
46
+ validityMessages[''] = validityMessages[''] || validityMessages['en-US'];
47
+
48
+ validityMessages['de'] = $.extend(true, {
49
+ typeMismatch: {
50
+ email: '{%value} ist keine zulässige E-Mail-Adresse',
51
+ url: '{%value} ist keine zulässige Webadresse',
52
+ number: '{%value} ist keine Nummer!',
53
+ date: '{%value} ist kein Datum',
54
+ time: '{%value} ist keine Uhrzeit',
55
+ range: '{%value} ist keine Nummer!',
56
+ "datetime-local": '{%value} ist kein Datum-Uhrzeit Format.'
57
+ },
58
+ rangeUnderflow: {
59
+ defaultMessage: '{%value} ist zu niedrig. {%min} ist der unterste Wert, den Sie benutzen können.'
60
+ },
61
+ rangeOverflow: {
62
+ defaultMessage: '{%value} ist zu hoch. {%max} ist der oberste Wert, den Sie benutzen können.'
63
+ },
64
+ stepMismatch: 'Der Wert {%value} ist in diesem Feld nicht zulässig. Hier sind nur bestimmte Werte zulässig. {%title}',
65
+ tooLong: 'Der eingegebene Text ist zu lang! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%maxlength} das Maximum.',
66
+ patternMismatch: '{%value} hat für dieses Eingabefeld ein falsches Format! {%title}',
67
+ valueMissing: {
68
+ defaultMessage: 'Bitte geben Sie einen Wert ein',
69
+ checkbox: 'Bitte aktivieren Sie das Kästchen'
70
+ }
71
+ }, (validityMessages['de'] || {}));
72
+
73
+ ['select', 'radio'].forEach(function(type){
74
+ validityMessages['de'].valueMissing[type] = 'Bitte wählen Sie eine Option aus';
75
+ });
76
+
77
+ ['date', 'time', 'datetime-local'].forEach(function(type){
78
+ validityMessages.de.rangeUnderflow[type] = '{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.';
79
+ });
80
+ ['date', 'time', 'datetime-local'].forEach(function(type){
81
+ validityMessages.de.rangeOverflow[type] = '{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.';
82
+ });
83
+
84
+ var currentValidationMessage = validityMessages[''];
85
+
86
+
87
+ webshims.createValidationMessage = function(elem, name){
88
+ var message = currentValidationMessage[name];
89
+ if(message && typeof message !== 'string'){
90
+ message = message[ $.prop(elem, 'type') ] || message[ (elem.nodeName || '').toLowerCase() ] || message[ 'defaultMessage' ];
91
+ }
92
+ if(message){
93
+ ['value', 'min', 'max', 'title', 'maxlength', 'label'].forEach(function(attr){
94
+ if(message.indexOf('{%'+attr) === -1){return;}
95
+ var val = ((attr == 'label') ? $.trim($('label[for="'+ elem.id +'"]', elem.form).text()).replace(/\*$|:$/, '') : $.attr(elem, attr)) || '';
96
+ if(name == 'patternMismatch' && attr == 'title' && !val){
97
+ webshims.error('no title for patternMismatch provided. Always add a title attribute.');
98
+ }
99
+ message = message.replace('{%'+ attr +'}', val);
100
+ if('value' == attr){
101
+ message = message.replace('{%valueLen}', val.length);
102
+ }
103
+ });
104
+ }
105
+ return message || '';
106
+ };
107
+
108
+
109
+ if(webshims.bugs.validationMessage || !Modernizr.formvalidation || webshims.bugs.bustedValidity){
110
+ implementProperties.push('validationMessage');
111
+ }
112
+
113
+ webshims.activeLang({
114
+ langObj: validityMessages,
115
+ module: 'form-core',
116
+ callback: function(langObj){
117
+ currentValidationMessage = langObj;
118
+ }
119
+ });
120
+
121
+ implementProperties.forEach(function(messageProp){
122
+ webshims.defineNodeNamesProperty(['fieldset', 'output', 'button'], messageProp, {
123
+ prop: {
124
+ value: '',
125
+ writeable: false
126
+ }
127
+ });
128
+ ['input', 'select', 'textarea'].forEach(function(nodeName){
129
+ var desc = webshims.defineNodeNameProperty(nodeName, messageProp, {
130
+ prop: {
131
+ get: function(){
132
+ var elem = this;
133
+ var message = '';
134
+ if(!$.prop(elem, 'willValidate')){
135
+ return message;
136
+ }
137
+
138
+ var validity = $.prop(elem, 'validity') || {valid: 1};
139
+
140
+ if(validity.valid){return message;}
141
+ message = webshims.getContentValidationMessage(elem, validity);
142
+
143
+ if(message){return message;}
144
+
145
+ if(validity.customError && elem.nodeName){
146
+ message = (Modernizr.formvalidation && !webshims.bugs.bustedValidity && desc.prop._supget) ? desc.prop._supget.call(elem) : webshims.data(elem, 'customvalidationMessage');
147
+ if(message){return message;}
148
+ }
149
+ $.each(validity, function(name, prop){
150
+ if(name == 'valid' || !prop){return;}
151
+
152
+ message = webshims.createValidationMessage(elem, name);
153
+ if(message){
154
+ return false;
155
+ }
156
+ });
157
+ return message || '';
158
+ },
159
+ writeable: false
160
+ }
161
+ });
162
+ });
163
+
164
+ });
165
+ });if(!Modernizr.formvalidation || jQuery.webshims.bugs.bustedValidity){
166
+ jQuery.webshims.register('form-extend', function($, webshims, window, document){
167
+ "use strict";
168
+ webshims.inputTypes = webshims.inputTypes || {};
169
+ //some helper-functions
170
+ var cfg = webshims.cfg.forms;
171
+ var isSubmit;
172
+
173
+ var isNumber = function(string){
174
+ return (typeof string == 'number' || (string && string == string * 1));
175
+ },
176
+ typeModels = webshims.inputTypes,
177
+ checkTypes = {
178
+ radio: 1,
179
+ checkbox: 1
180
+ },
181
+ getType = function(elem){
182
+ return (elem.getAttribute('type') || elem.type || '').toLowerCase();
183
+ }
184
+ ;
185
+
186
+ //API to add new input types
187
+ webshims.addInputType = function(type, obj){
188
+ typeModels[type] = obj;
189
+ };
190
+
191
+ //contsrain-validation-api
192
+ var validityPrototype = {
193
+ customError: false,
194
+
195
+ typeMismatch: false,
196
+ rangeUnderflow: false,
197
+ rangeOverflow: false,
198
+ stepMismatch: false,
199
+ tooLong: false,
200
+ patternMismatch: false,
201
+ valueMissing: false,
202
+
203
+ valid: true
204
+ };
205
+
206
+ var isPlaceholderOptionSelected = function(select){
207
+ if(select.type == 'select-one' && select.size < 2){
208
+ var option = $('> option:first-child', select);
209
+ return !!option.prop('selected');
210
+ }
211
+ return false;
212
+ };
213
+
214
+ var validityRules = {
215
+ valueMissing: function(input, val, cache){
216
+ if(!input.prop('required')){return false;}
217
+ var ret = false;
218
+ if(!('type' in cache)){
219
+ cache.type = getType(input[0]);
220
+ }
221
+ if(cache.nodeName == 'select'){
222
+ ret = (!val && (input[0].selectedIndex < 0 || isPlaceholderOptionSelected(input[0]) ));
223
+ } else if(checkTypes[cache.type]){
224
+ ret = (cache.type == 'checkbox') ? !input.is(':checked') : !webshims.modules["form-core"].getGroupElements(input).filter(':checked')[0];
225
+ } else {
226
+ ret = !(val);
227
+ }
228
+ return ret;
229
+ },
230
+ tooLong: function(){
231
+ return false;
232
+ },
233
+ typeMismatch: function (input, val, cache){
234
+ if(val === '' || cache.nodeName == 'select'){return false;}
235
+ var ret = false;
236
+ if(!('type' in cache)){
237
+ cache.type = getType(input[0]);
238
+ }
239
+
240
+ if(typeModels[cache.type] && typeModels[cache.type].mismatch){
241
+ ret = typeModels[cache.type].mismatch(val, input);
242
+ } else if('validity' in input[0]){
243
+ ret = input[0].validity.typeMismatch;
244
+ }
245
+ return ret;
246
+ },
247
+ patternMismatch: function(input, val, cache) {
248
+ if(val === '' || cache.nodeName == 'select'){return false;}
249
+ var pattern = input.attr('pattern');
250
+ if(!pattern){return false;}
251
+ try {
252
+ pattern = new RegExp('^(?:' + pattern + ')$');
253
+ } catch(er){
254
+ webshims.error('invalid pattern value: "'+ pattern +'" | '+ er);
255
+ pattern = false;
256
+ }
257
+ if(!pattern){return false;}
258
+ return !(pattern.test(val));
259
+ }
260
+ }
261
+ ;
262
+
263
+ webshims.addValidityRule = function(type, fn){
264
+ validityRules[type] = fn;
265
+ };
266
+
267
+ $.event.special.invalid = {
268
+ add: function(){
269
+ $.event.special.invalid.setup.call(this.form || this);
270
+ },
271
+ setup: function(){
272
+ var form = this.form || this;
273
+ if( $.data(form, 'invalidEventShim') ){
274
+ form = null;
275
+ return;
276
+ }
277
+ $(form)
278
+ .data('invalidEventShim', true)
279
+ .on('submit', $.event.special.invalid.handler)
280
+ ;
281
+ webshims.moveToFirstEvent(form, 'submit');
282
+ if(webshims.bugs.bustedValidity && $.nodeName(form, 'form')){
283
+ (function(){
284
+ var noValidate = form.getAttribute('novalidate');
285
+ form.setAttribute('novalidate', 'novalidate');
286
+ webshims.data(form, 'bustedNoValidate', (noValidate == null) ? null : noValidate);
287
+ })();
288
+ }
289
+ form = null;
290
+ },
291
+ teardown: $.noop,
292
+ handler: function(e, d){
293
+
294
+ if( e.type != 'submit' || e.testedValidity || !e.originalEvent || !$.nodeName(e.target, 'form') || $.prop(e.target, 'noValidate') ){return;}
295
+
296
+ isSubmit = true;
297
+ e.testedValidity = true;
298
+ var notValid = !($(e.target).checkValidity());
299
+ if(notValid){
300
+ e.stopImmediatePropagation();
301
+ isSubmit = false;
302
+ return false;
303
+ }
304
+ isSubmit = false;
305
+ }
306
+ };
307
+
308
+ var addSubmitBubbles = function(form){
309
+ if (!$.support.submitBubbles && form && typeof form == 'object' && !form._submit_attached ) {
310
+
311
+ $.event.add( form, 'submit._submit', function( event ) {
312
+ event._submit_bubble = true;
313
+ });
314
+
315
+ form._submit_attached = true;
316
+ }
317
+ };
318
+ if(!$.support.submitBubbles && $.event.special.submit){
319
+ $.event.special.submit.setup = function() {
320
+ // Only need this for delegated form submit events
321
+ if ( $.nodeName( this, "form" ) ) {
322
+ return false;
323
+ }
324
+
325
+ // Lazy-add a submit handler when a descendant form may potentially be submitted
326
+ $.event.add( this, "click._submit keypress._submit", function( e ) {
327
+ // Node name check avoids a VML-related crash in IE (#9807)
328
+ var elem = e.target,
329
+ form = $.nodeName( elem, 'input' ) || $.nodeName( elem, 'button' ) ? $.prop(elem, 'form') : undefined;
330
+ addSubmitBubbles(form);
331
+
332
+ });
333
+ // return undefined since we don't need an event listener
334
+ };
335
+ }
336
+
337
+ $.event.special.submit = $.event.special.submit || {setup: function(){return false;}};
338
+ var submitSetup = $.event.special.submit.setup;
339
+ $.extend($.event.special.submit, {
340
+ setup: function(){
341
+ if($.nodeName(this, 'form')){
342
+ $(this).on('invalid', $.noop);
343
+ } else {
344
+ $('form', this).on('invalid', $.noop);
345
+ }
346
+ return submitSetup.apply(this, arguments);
347
+ }
348
+ });
349
+
350
+ $(window).on('invalid', $.noop);
351
+
352
+
353
+ webshims.addInputType('email', {
354
+ mismatch: (function(){
355
+ //taken from http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
356
+ var test = cfg.emailReg || /^[a-zA-Z0-9.!#$%&'*+-\/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
357
+ return function(val){
358
+ return !test.test(val);
359
+ };
360
+ })()
361
+ });
362
+
363
+ webshims.addInputType('url', {
364
+ mismatch: (function(){
365
+ //taken from scott gonzales
366
+ 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;
367
+ return function(val){
368
+ return !test.test(val);
369
+ };
370
+ })()
371
+ });
372
+
373
+ webshims.defineNodeNameProperty('input', 'type', {
374
+ prop: {
375
+ get: function(){
376
+ var elem = this;
377
+ var type = (elem.getAttribute('type') || '').toLowerCase();
378
+ return (webshims.inputTypes[type]) ? type : elem.type;
379
+ }
380
+ }
381
+ });
382
+
383
+ // IDLs for constrain validation API
384
+ //ToDo: add object to this list
385
+ webshims.defineNodeNamesProperties(['button', 'fieldset', 'output'], {
386
+ checkValidity: {
387
+ value: function(){return true;}
388
+ },
389
+ willValidate: {
390
+ value: false
391
+ },
392
+ setCustomValidity: {
393
+ value: $.noop
394
+ },
395
+ validity: {
396
+ writeable: false,
397
+ get: function(){
398
+ return $.extend({}, validityPrototype);
399
+ }
400
+ }
401
+ }, 'prop');
402
+
403
+ var baseCheckValidity = function(elem){
404
+ var e,
405
+ v = $.prop(elem, 'validity')
406
+ ;
407
+ if(v){
408
+ $.data(elem, 'cachedValidity', v);
409
+ } else {
410
+ return true;
411
+ }
412
+ if( !v.valid ){
413
+ e = $.Event('invalid');
414
+ var jElm = $(elem).trigger(e);
415
+ if(isSubmit && !baseCheckValidity.unhandledInvalids && !e.isDefaultPrevented()){
416
+ webshims.validityAlert.showFor(jElm);
417
+ baseCheckValidity.unhandledInvalids = true;
418
+ }
419
+ }
420
+ $.removeData(elem, 'cachedValidity');
421
+ return v.valid;
422
+ };
423
+ var rsubmittable = /^(?:select|textarea|input)/i;
424
+ webshims.defineNodeNameProperty('form', 'checkValidity', {
425
+ prop: {
426
+ value: function(){
427
+
428
+ var ret = true,
429
+ elems = $($.prop(this, 'elements')).filter(function(){
430
+ if(!rsubmittable.test(this.nodeName)){return false;}
431
+ var shadowData = webshims.data(this, 'shadowData');
432
+ return !shadowData || !shadowData.nativeElement || shadowData.nativeElement === this;
433
+ })
434
+ ;
435
+
436
+ baseCheckValidity.unhandledInvalids = false;
437
+ for(var i = 0, len = elems.length; i < len; i++){
438
+ if( !baseCheckValidity(elems[i]) ){
439
+ ret = false;
440
+ }
441
+ }
442
+ return ret;
443
+ }
444
+ }
445
+ });
446
+
447
+ webshims.defineNodeNamesProperties(['input', 'textarea', 'select'], {
448
+ checkValidity: {
449
+ value: function(){
450
+ baseCheckValidity.unhandledInvalids = false;
451
+ return baseCheckValidity($(this).getNativeElement()[0]);
452
+ }
453
+ },
454
+ setCustomValidity: {
455
+ value: function(error){
456
+ $.removeData(this, 'cachedValidity');
457
+ webshims.data(this, 'customvalidationMessage', ''+error);
458
+ }
459
+ },
460
+ willValidate: {
461
+ writeable: false,
462
+ get: (function(){
463
+ var types = {
464
+ button: 1,
465
+ reset: 1,
466
+ hidden: 1,
467
+ image: 1
468
+ }
469
+ ;
470
+ return function(){
471
+ var elem = $(this).getNativeElement()[0];
472
+ //elem.name && <- we don't use to make it easier for developers
473
+ return !!(!elem.disabled && !elem.readOnly && !types[elem.type] );
474
+ };
475
+ })()
476
+ },
477
+ validity: {
478
+ writeable: false,
479
+ get: function(){
480
+ var jElm = $(this).getNativeElement();
481
+ var elem = jElm[0];
482
+ var validityState = $.data(elem, 'cachedValidity');
483
+ if(validityState){
484
+ return validityState;
485
+ }
486
+ validityState = $.extend({}, validityPrototype);
487
+
488
+ if( !$.prop(elem, 'willValidate') || elem.type == 'submit' ){
489
+ return validityState;
490
+ }
491
+ var val = jElm.val(),
492
+ cache = {nodeName: elem.nodeName.toLowerCase()}
493
+ ;
494
+
495
+ validityState.customError = !!(webshims.data(elem, 'customvalidationMessage'));
496
+ if( validityState.customError ){
497
+ validityState.valid = false;
498
+ }
499
+
500
+ $.each(validityRules, function(rule, fn){
501
+ if (fn(jElm, val, cache)) {
502
+ validityState[rule] = true;
503
+ validityState.valid = false;
504
+ }
505
+ });
506
+ $(this).getShadowFocusElement().attr('aria-invalid', validityState.valid ? 'false' : 'true');
507
+ jElm = null;
508
+ elem = null;
509
+ return validityState;
510
+ }
511
+ }
512
+ }, 'prop');
513
+
514
+ webshims.defineNodeNamesBooleanProperty(['input', 'textarea', 'select'], 'required', {
515
+ set: function(value){
516
+ $(this).getShadowFocusElement().attr('aria-required', !!(value)+'');
517
+ },
518
+ initAttr: (!$.browser.msie || webshims.browserVersion > 7)//only if we have aria-support
519
+ });
520
+
521
+ webshims.reflectProperties(['input'], ['pattern']);
522
+
523
+
524
+ if( !('maxLength' in document.createElement('textarea')) ){
525
+ var constrainMaxLength = (function(){
526
+ var timer;
527
+ var curLength = 0;
528
+ var lastElement = $([]);
529
+ var max = 1e9;
530
+ var constrainLength = function(){
531
+ var nowValue = lastElement.prop('value');
532
+ var nowLen = nowValue.length;
533
+ if(nowLen > curLength && nowLen > max){
534
+ nowLen = Math.max(curLength, max);
535
+ lastElement.prop('value', nowValue.substr(0, nowLen ));
536
+ }
537
+ curLength = nowLen;
538
+ };
539
+ var remove = function(){
540
+ clearTimeout(timer);
541
+ lastElement.unbind('.maxlengthconstraint');
542
+ };
543
+ return function(element, maxLength){
544
+ remove();
545
+ if(maxLength > -1){
546
+ max = maxLength;
547
+ curLength = $.prop(element, 'value').length;
548
+ lastElement = $(element);
549
+ lastElement.on({
550
+ 'keydown.maxlengthconstraint keypress.maxlengthconstraint paste.maxlengthconstraint cut.maxlengthconstraint': function(e){
551
+ setTimeout(constrainLength, 0);
552
+ },
553
+ 'keyup.maxlengthconstraint': constrainLength,
554
+ 'blur.maxlengthconstraint': remove
555
+ });
556
+ timer = setInterval(constrainLength, 200);
557
+ }
558
+ };
559
+ })();
560
+
561
+ constrainMaxLength.update = function(element, maxLength){
562
+ if($(element).is(':focus')){
563
+ if(!maxLength){
564
+ maxLength = $.prop(element, 'maxlength');
565
+ }
566
+ constrainMaxLength(element, maxLength);
567
+ }
568
+ };
569
+
570
+ $(document).on('focusin', function(e){
571
+ var maxLength;
572
+ if(e.target.nodeName == "TEXTAREA" && (maxLength = $.prop(e.target, 'maxlength')) > -1){
573
+ constrainMaxLength(e.target, maxLength);
574
+ }
575
+ });
576
+
577
+ webshims.defineNodeNameProperty('textarea', 'maxlength', {
578
+ attr: {
579
+ set: function(val){
580
+ this.setAttribute('maxlength', ''+val);
581
+ constrainMaxLength.update(this);
582
+ },
583
+ get: function(){
584
+ var ret = this.getAttribute('maxlength');
585
+ return ret == null ? undefined : ret;
586
+ }
587
+ },
588
+ prop: {
589
+ set: function(val){
590
+ if(isNumber(val)){
591
+ if(val < 0){
592
+ throw('INDEX_SIZE_ERR');
593
+ }
594
+ val = parseInt(val, 10);
595
+ this.setAttribute('maxlength', val);
596
+ constrainMaxLength.update(this, val);
597
+ return;
598
+ }
599
+ this.setAttribute('maxlength', '0');
600
+ constrainMaxLength.update(this, 0);
601
+ },
602
+ get: function(){
603
+ var val = this.getAttribute('maxlength');
604
+ return (isNumber(val) && val >= 0) ? parseInt(val, 10) : -1;
605
+
606
+ }
607
+ }
608
+ });
609
+ webshims.defineNodeNameProperty('textarea', 'maxLength', {
610
+ prop: {
611
+ set: function(val){
612
+ $.prop(this, 'maxlength', val);
613
+ },
614
+ get: function(){
615
+ return $.prop(this, 'maxlength');
616
+ }
617
+ }
618
+ });
619
+ }
620
+
621
+
622
+
623
+ var submitterTypes = {submit: 1, button: 1, image: 1};
624
+ var formSubmitterDescriptors = {};
625
+ [
626
+ {
627
+ name: "enctype",
628
+ limitedTo: {
629
+ "application/x-www-form-urlencoded": 1,
630
+ "multipart/form-data": 1,
631
+ "text/plain": 1
632
+ },
633
+ defaultProp: "application/x-www-form-urlencoded",
634
+ proptype: "enum"
635
+ },
636
+ {
637
+ name: "method",
638
+ limitedTo: {
639
+ "get": 1,
640
+ "post": 1
641
+ },
642
+ defaultProp: "get",
643
+ proptype: "enum"
644
+ },
645
+ {
646
+ name: "action",
647
+ proptype: "url"
648
+ },
649
+ {
650
+ name: "target"
651
+ },
652
+ {
653
+ name: "novalidate",
654
+ propName: "noValidate",
655
+ proptype: "boolean"
656
+ }
657
+ ].forEach(function(desc){
658
+ var propName = 'form'+ (desc.propName || desc.name).replace(/^[a-z]/, function(f){
659
+ return f.toUpperCase();
660
+ });
661
+ var attrName = 'form'+ desc.name;
662
+ var formName = desc.name;
663
+ var eventName = 'click.webshimssubmittermutate'+formName;
664
+
665
+ var changeSubmitter = function(){
666
+ var elem = this;
667
+ if( !('form' in elem) || !submitterTypes[elem.type] ){return;}
668
+ var form = $.prop(elem, 'form');
669
+ if(!form){return;}
670
+ var attr = $.attr(elem, attrName);
671
+ if(attr != null && ( !desc.limitedTo || attr.toLowerCase() === $.prop(elem, propName))){
672
+
673
+ var oldAttr = $.attr(form, formName);
674
+
675
+ $.attr(form, formName, attr);
676
+ setTimeout(function(){
677
+ if(oldAttr != null){
678
+ $.attr(form, formName, oldAttr);
679
+ } else {
680
+ try {
681
+ $(form).removeAttr(formName);
682
+ } catch(er){
683
+ form.removeAttribute(formName);
684
+ }
685
+ }
686
+ }, 9);
687
+ }
688
+ };
689
+
690
+
691
+
692
+ switch(desc.proptype) {
693
+ case "url":
694
+ var urlForm = document.createElement('form');
695
+ formSubmitterDescriptors[propName] = {
696
+ prop: {
697
+ set: function(value){
698
+ $.attr(this, attrName, value);
699
+ },
700
+ get: function(){
701
+ var value = $.attr(this, attrName);
702
+ if(value == null){return '';}
703
+ urlForm.setAttribute('action', value);
704
+ return urlForm.action;
705
+ }
706
+ }
707
+ };
708
+ break;
709
+ case "boolean":
710
+ formSubmitterDescriptors[propName] = {
711
+ prop: {
712
+ set: function(val){
713
+ val = !!val;
714
+ if(val){
715
+ $.attr(this, 'formnovalidate', 'formnovalidate');
716
+ } else {
717
+ $(this).removeAttr('formnovalidate');
718
+ }
719
+ },
720
+ get: function(){
721
+ return $.attr(this, 'formnovalidate') != null;
722
+ }
723
+ }
724
+ };
725
+ break;
726
+ case "enum":
727
+ formSubmitterDescriptors[propName] = {
728
+ prop: {
729
+ set: function(value){
730
+ $.attr(this, attrName, value);
731
+ },
732
+ get: function(){
733
+ var value = $.attr(this, attrName);
734
+ return (!value || ( (value = value.toLowerCase()) && !desc.limitedTo[value] )) ? desc.defaultProp : value;
735
+ }
736
+ }
737
+ };
738
+ break;
739
+ default:
740
+ formSubmitterDescriptors[propName] = {
741
+ prop: {
742
+ set: function(value){
743
+ $.attr(this, attrName, value);
744
+ },
745
+ get: function(){
746
+ var value = $.attr(this, attrName);
747
+ return (value != null) ? value : "";
748
+ }
749
+ }
750
+ };
751
+ }
752
+
753
+
754
+ if(!formSubmitterDescriptors[attrName]){
755
+ formSubmitterDescriptors[attrName] = {};
756
+ }
757
+ formSubmitterDescriptors[attrName].attr = {
758
+ set: function(value){
759
+ formSubmitterDescriptors[attrName].attr._supset.call(this, value);
760
+ $(this).unbind(eventName).on(eventName, changeSubmitter);
761
+ },
762
+ get: function(){
763
+ return formSubmitterDescriptors[attrName].attr._supget.call(this);
764
+ }
765
+ };
766
+ formSubmitterDescriptors[attrName].initAttr = true;
767
+ formSubmitterDescriptors[attrName].removeAttr = {
768
+ value: function(){
769
+ $(this).unbind(eventName);
770
+ formSubmitterDescriptors[attrName].removeAttr._supvalue.call(this);
771
+ }
772
+ };
773
+ });
774
+
775
+ webshims.defineNodeNamesProperties(['input', 'button'], formSubmitterDescriptors);
776
+
777
+
778
+ if(!$.support.getSetAttribute && $('<form novalidate></form>').attr('novalidate') == null){
779
+ webshims.defineNodeNameProperty('form', 'novalidate', {
780
+ attr: {
781
+ set: function(val){
782
+ this.setAttribute('novalidate', ''+val);
783
+ },
784
+ get: function(){
785
+ var ret = this.getAttribute('novalidate');
786
+ return ret == null ? undefined : ret;
787
+ }
788
+ }
789
+ });
790
+ } else if(webshims.bugs.bustedValidity){
791
+
792
+ webshims.defineNodeNameProperty('form', 'novalidate', {
793
+ attr: {
794
+ set: function(val){
795
+ webshims.data(this, 'bustedNoValidate', ''+val);
796
+ },
797
+ get: function(){
798
+ var ret = webshims.data(this, 'bustedNoValidate');
799
+ return ret == null ? undefined : ret;
800
+ }
801
+ },
802
+ removeAttr: {
803
+ value: function(){
804
+ webshims.data(this, 'bustedNoValidate', null);
805
+ }
806
+ }
807
+ });
808
+
809
+ $.each(['rangeUnderflow', 'rangeOverflow', 'stepMismatch'], function(i, name){
810
+ validityRules[name] = function(elem){
811
+ return (elem[0].validity || {})[name] || false;
812
+ };
813
+ });
814
+
815
+ }
816
+
817
+ webshims.defineNodeNameProperty('form', 'noValidate', {
818
+ prop: {
819
+ set: function(val){
820
+ val = !!val;
821
+ if(val){
822
+ $.attr(this, 'novalidate', 'novalidate');
823
+ } else {
824
+ $(this).removeAttr('novalidate');
825
+ }
826
+ },
827
+ get: function(){
828
+ return $.attr(this, 'novalidate') != null;
829
+ }
830
+ }
831
+ });
832
+
833
+ if($.browser.webkit && Modernizr.inputtypes.date){
834
+ (function(){
835
+
836
+ var noInputTriggerEvts = {updateInput: 1, input: 1},
837
+ fixInputTypes = {
838
+ date: 1,
839
+ time: 1,
840
+ "datetime-local": 1
841
+ },
842
+ noFocusEvents = {
843
+ focusout: 1,
844
+ blur: 1
845
+ },
846
+ changeEvts = {
847
+ updateInput: 1,
848
+ change: 1
849
+ },
850
+ observe = function(input){
851
+ var timer,
852
+ focusedin = true,
853
+ lastInputVal = input.prop('value'),
854
+ lastChangeVal = lastInputVal,
855
+ trigger = function(e){
856
+ //input === null
857
+ if(!input){return;}
858
+ var newVal = input.prop('value');
859
+
860
+ if(newVal !== lastInputVal){
861
+ lastInputVal = newVal;
862
+ if(!e || !noInputTriggerEvts[e.type]){
863
+ input.trigger('input');
864
+ }
865
+ }
866
+ if(e && changeEvts[e.type]){
867
+ lastChangeVal = newVal;
868
+ }
869
+ if(!focusedin && newVal !== lastChangeVal){
870
+ input.trigger('change');
871
+ }
872
+ },
873
+ extraTimer,
874
+ extraTest = function(){
875
+ clearTimeout(extraTimer);
876
+ extraTimer = setTimeout(trigger, 9);
877
+ },
878
+ unbind = function(e){
879
+ clearInterval(timer);
880
+ setTimeout(function(){
881
+ if(e && noFocusEvents[e.type]){
882
+ focusedin = false;
883
+ }
884
+ if(input){
885
+ input.unbind('focusout blur', unbind).unbind('input change updateInput', trigger);
886
+ trigger();
887
+ }
888
+ input = null;
889
+ }, 1);
890
+
891
+ }
892
+ ;
893
+
894
+ clearInterval(timer);
895
+ timer = setInterval(trigger, 160);
896
+ extraTest();
897
+ input
898
+ .off({
899
+ 'focusout blur': unbind,
900
+ 'input change updateInput': trigger
901
+ })
902
+ .on({
903
+ 'focusout blur': unbind,
904
+ 'input updateInput change': trigger
905
+ })
906
+ ;
907
+ }
908
+ ;
909
+ if($.event.customEvent){
910
+ $.event.customEvent.updateInput = true;
911
+ }
912
+
913
+ (function(){
914
+
915
+ var correctValue = function(elem){
916
+ var i = 1;
917
+ var len = 3;
918
+ var abort, val;
919
+ if(elem.type == 'date' && (isSubmit || !$(elem).is(':focus'))){
920
+ val = elem.value;
921
+ if(val && val.length < 10 && (val = val.split('-')) && val.length == len){
922
+ for(; i < len; i++){
923
+ if(val[i].length == 1){
924
+ val[i] = '0'+val[i];
925
+ } else if(val[i].length != 2){
926
+ abort = true;
927
+ break;
928
+ }
929
+ }
930
+ if(!abort){
931
+ val = val.join('-');
932
+ $.prop(elem, 'value', val);
933
+ return val;
934
+ }
935
+ }
936
+ }
937
+ };
938
+ var inputCheckValidityDesc, formCheckValidityDesc, inputValueDesc, inputValidityDesc;
939
+
940
+ inputCheckValidityDesc = webshims.defineNodeNameProperty('input', 'checkValidity', {
941
+ prop: {
942
+ value: function(){
943
+ correctValue(this);
944
+ return inputCheckValidityDesc.prop._supvalue.apply(this, arguments);
945
+ }
946
+ }
947
+ });
948
+
949
+ formCheckValidityDesc = webshims.defineNodeNameProperty('form', 'checkValidity', {
950
+ prop: {
951
+ value: function(){
952
+ $('input', this).each(function(){
953
+ correctValue(this);
954
+ });
955
+ return formCheckValidityDesc.prop._supvalue.apply(this, arguments);
956
+ }
957
+ }
958
+ });
959
+
960
+ inputValueDesc = webshims.defineNodeNameProperty('input', 'value', {
961
+ prop: {
962
+ set: function(){
963
+ return inputValueDesc.prop._supset.apply(this, arguments);
964
+ },
965
+ get: function(){
966
+ return correctValue(this) || inputValueDesc.prop._supget.apply(this, arguments);
967
+ }
968
+ }
969
+ });
970
+
971
+ inputValidityDesc = webshims.defineNodeNameProperty('input', 'validity', {
972
+ prop: {
973
+ writeable: false,
974
+ get: function(){
975
+ correctValue(this);
976
+ return inputValidityDesc.prop._supget.apply(this, arguments);
977
+ }
978
+ }
979
+ });
980
+
981
+ $(document).on('change', function(e){
982
+ isChangeSubmit = true;
983
+ correctValue(e.target);
984
+ isChangeSubmit = false;
985
+ });
986
+
987
+ })();
988
+
989
+ $(document)
990
+ .on('focusin', function(e){
991
+ if( e.target && fixInputTypes[e.target.type] && !e.target.readOnly && !e.target.disabled ){
992
+ observe($(e.target));
993
+ }
994
+ })
995
+ ;
996
+
997
+
998
+ })();
999
+ }
1000
+
1001
+ webshims.addReady(function(context, contextElem){
1002
+ //start constrain-validation
1003
+ var focusElem;
1004
+ $('form', context)
1005
+ .add(contextElem.filter('form'))
1006
+ .bind('invalid', $.noop)
1007
+ ;
1008
+
1009
+ try {
1010
+ if(context == document && !('form' in (document.activeElement || {}))) {
1011
+ focusElem = $('input[autofocus], select[autofocus], textarea[autofocus]', context).eq(0).getShadowFocusElement()[0];
1012
+ if (focusElem && focusElem.offsetHeight && focusElem.offsetWidth) {
1013
+ focusElem.focus();
1014
+ }
1015
+ }
1016
+ }
1017
+ catch (er) {}
1018
+
1019
+ });
1020
+
1021
+ if(!Modernizr.formattribute || !Modernizr.fieldsetdisabled){
1022
+ (function(){
1023
+ (function(prop, undefined){
1024
+ $.prop = function(elem, name, value){
1025
+ var ret;
1026
+ if(elem && elem.nodeType == 1 && value === undefined && $.nodeName(elem, 'form') && elem.id){
1027
+ ret = document.getElementsByName(name);
1028
+ if(!ret || !ret.length){
1029
+ ret = document.getElementById(name);
1030
+ }
1031
+ if(ret){
1032
+ ret = $(ret).filter(function(){
1033
+ return $.prop(this, 'form') == elem;
1034
+ }).get();
1035
+ if(ret.length){
1036
+ return ret.length == 1 ? ret[0] : ret;
1037
+ }
1038
+ }
1039
+ }
1040
+ return prop.apply(this, arguments);
1041
+ };
1042
+ })($.prop, undefined);
1043
+ var removeAddedElements = function(form){
1044
+ var elements = $.data(form, 'webshimsAddedElements');
1045
+ if(elements){
1046
+ elements.remove();
1047
+ $.removeData(form, 'webshimsAddedElements');
1048
+ }
1049
+ };
1050
+ var rCRLF = /\r?\n/g,
1051
+ rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
1052
+ rselectTextarea = /^(?:select|textarea)/i;
1053
+
1054
+ if(!Modernizr.formattribute){
1055
+ webshims.defineNodeNamesProperty(['input', 'textarea', 'select', 'button', 'fieldset'], 'form', {
1056
+ prop: {
1057
+ get: function(){
1058
+ var form = webshims.contentAttr(this, 'form');
1059
+ if(form){
1060
+ form = document.getElementById(form);
1061
+ if(form && !$.nodeName(form, 'form')){
1062
+ form = null;
1063
+ }
1064
+ }
1065
+ return form || this.form;
1066
+ },
1067
+ writeable: false
1068
+ }
1069
+ });
1070
+
1071
+
1072
+ webshims.defineNodeNamesProperty(['form'], 'elements', {
1073
+ prop: {
1074
+ get: function(){
1075
+ var id = this.id;
1076
+ var elements = $.makeArray(this.elements);
1077
+ if(id){
1078
+ elements = $(elements).add('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"], button[form="'+ id +'"], fieldset[form="'+ id +'"]').not('.webshims-visual-hide > *').get();
1079
+ }
1080
+ return elements;
1081
+ },
1082
+ writeable: false
1083
+ }
1084
+ });
1085
+
1086
+
1087
+
1088
+ $(function(){
1089
+ var stopPropagation = function(e){
1090
+ e.stopPropagation();
1091
+ };
1092
+ $(document).on('submit', function(e){
1093
+
1094
+ if(!e.isDefaultPrevented()){
1095
+ var form = e.target;
1096
+ var id = form.id;
1097
+ var elements;
1098
+
1099
+
1100
+ if(id){
1101
+ removeAddedElements(form);
1102
+
1103
+ elements = $('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"]')
1104
+ .filter(function(){
1105
+ return !this.disabled && this.name && this.form != form;
1106
+ })
1107
+ .clone()
1108
+ ;
1109
+ if(elements.length){
1110
+ $.data(form, 'webshimsAddedElements', $('<div class="webshims-visual-hide" />').append(elements).appendTo(form));
1111
+ setTimeout(function(){
1112
+ removeAddedElements(form);
1113
+ }, 9);
1114
+ }
1115
+ elements = null;
1116
+ }
1117
+ }
1118
+ });
1119
+
1120
+ $(document).on('click', function(e){
1121
+ if(!e.isDefaultPrevented() && $(e.target).is('input[type="submit"][form], button[form], input[type="button"][form], input[type="image"][form], input[type="reset"][form]')){
1122
+ var trueForm = $.prop(e.target, 'form');
1123
+ var formIn = e.target.form;
1124
+ var clone;
1125
+ if(trueForm && trueForm != formIn){
1126
+ clone = $(e.target)
1127
+ .clone()
1128
+ .removeAttr('form')
1129
+ .addClass('webshims-visual-hide')
1130
+ .on('click', stopPropagation)
1131
+ .appendTo(trueForm)
1132
+ ;
1133
+ if(formIn){
1134
+ e.preventDefault();
1135
+ }
1136
+ addSubmitBubbles(trueForm);
1137
+ clone.trigger('click');
1138
+ setTimeout(function(){
1139
+ clone.remove();
1140
+ clone = null;
1141
+ }, 9);
1142
+ }
1143
+ }
1144
+ });
1145
+ });
1146
+ }
1147
+
1148
+ if(!Modernizr.fieldsetdisabled){
1149
+ webshims.defineNodeNamesProperty(['fieldset'], 'elements', {
1150
+ prop: {
1151
+ get: function(){
1152
+ //add listed elements without keygen, object, output
1153
+ return $('input, select, textarea, button, fieldset', this).get() || [];
1154
+ },
1155
+ writeable: false
1156
+ }
1157
+ });
1158
+ }
1159
+
1160
+ $.fn.serializeArray = function() {
1161
+ return this.map(function(){
1162
+ var elements = $.prop(this, 'elements');
1163
+ return elements ? $.makeArray( elements ) : this;
1164
+ })
1165
+ .filter(function(){
1166
+ return this.name && !this.disabled &&
1167
+ ( this.checked || rselectTextarea.test( this.nodeName ) ||
1168
+ rinput.test( this.type ) );
1169
+ })
1170
+ .map(function( i, elem ){
1171
+ var val = $( this ).val();
1172
+
1173
+ return val == null ?
1174
+ null :
1175
+ $.isArray( val ) ?
1176
+ $.map( val, function( val, i ){
1177
+ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
1178
+ }) :
1179
+ { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
1180
+ }).get();
1181
+ };
1182
+
1183
+ })();
1184
+ }
1185
+
1186
+ try {
1187
+ document.querySelector(':checked');
1188
+ } catch(er){
1189
+ (function(){
1190
+ var checkInputs = {
1191
+ radio: 1,
1192
+ checkbox: 1
1193
+ };
1194
+ var selectChange = function(){
1195
+ var options = this.options || [];
1196
+ var i, len, option;
1197
+ for(i = 0, len = options.length; i < len; i++){
1198
+ option = $(options[i]);
1199
+ option[$.prop(options[i], 'selected') ? 'addClass' : 'removeClass']('prop-checked');
1200
+ }
1201
+ };
1202
+ var checkChange = function(){
1203
+ var fn = $.prop(this, 'checked') ? 'addClass' : 'removeClass';
1204
+ var className = this.className || '';
1205
+ var parent;
1206
+
1207
+ //IE8- has problems to update styles, we help
1208
+ if( (className.indexOf('prop-checked') == -1) == (fn == 'addClass')){
1209
+ $(this)[fn]('prop-checked');
1210
+ if((parent = this.parentNode)){
1211
+ parent.className = parent.className;
1212
+ }
1213
+ }
1214
+ };
1215
+
1216
+
1217
+ webshims.onNodeNamesPropertyModify('select', 'value', selectChange);
1218
+ webshims.onNodeNamesPropertyModify('select', 'selectedIndex', selectChange);
1219
+ webshims.onNodeNamesPropertyModify('option', 'selected', function(){
1220
+ $(this).closest('select').each(selectChange);
1221
+ });
1222
+ webshims.onNodeNamesPropertyModify('input', 'checked', function(value, boolVal){
1223
+ var type = this.type;
1224
+ if(type == 'radio' && boolVal){
1225
+ webshims.modules["form-core"].getGroupElements(this).each(checkChange);
1226
+ } else if(checkInputs[type]) {
1227
+ $(this).each(checkChange);
1228
+ }
1229
+ });
1230
+
1231
+ $(document).on('change', function(e){
1232
+
1233
+ if(checkInputs[e.target.type]){
1234
+ if(e.target.type == 'radio'){
1235
+ webshims.modules["form-core"].getGroupElements(e.target).each(checkChange);
1236
+ } else {
1237
+ $(e.target)[$.prop(e.target, 'checked') ? 'addClass' : 'removeClass']('prop-checked');
1238
+ }
1239
+ } else if(e.target.nodeName.toLowerCase() == 'select'){
1240
+ $(e.target).each(selectChange);
1241
+ }
1242
+ });
1243
+
1244
+ webshims.addReady(function(context, contextElem){
1245
+ $('option, input', context)
1246
+ .add(contextElem.filter('option, input'))
1247
+ .each(function(){
1248
+ var prop;
1249
+ if(checkInputs[this.type]){
1250
+ prop = 'checked';
1251
+ } else if(this.nodeName.toLowerCase() == 'option'){
1252
+ prop = 'selected';
1253
+ }
1254
+ if(prop){
1255
+ $(this)[$.prop(this, prop) ? 'addClass' : 'removeClass']('prop-checked');
1256
+ }
1257
+
1258
+ })
1259
+ ;
1260
+ });
1261
+ })();
1262
+ }
1263
+
1264
+ (function(){
1265
+ Modernizr.textareaPlaceholder = !!('placeholder' in $('<textarea />')[0]);
1266
+ var bustedTextarea = $.browser.webkit && Modernizr.textareaPlaceholder && webshims.browserVersion < 535;
1267
+ if(Modernizr.input.placeholder && Modernizr.textareaPlaceholder && !bustedTextarea){return;}
1268
+
1269
+ var isOver = (webshims.cfg.forms.placeholderType == 'over');
1270
+ var isResponsive = (webshims.cfg.forms.responsivePlaceholder);
1271
+ var polyfillElements = ['textarea'];
1272
+ if(!Modernizr.input.placeholder){
1273
+ polyfillElements.push('input');
1274
+ }
1275
+
1276
+ var setSelection = function(elem){
1277
+ try {
1278
+ if(elem.setSelectionRange){
1279
+ elem.setSelectionRange(0, 0);
1280
+ return true;
1281
+ } else if(elem.createTextRange){
1282
+ var range = elem.createTextRange();
1283
+ range.collapse(true);
1284
+ range.moveEnd('character', 0);
1285
+ range.moveStart('character', 0);
1286
+ range.select();
1287
+ return true;
1288
+ }
1289
+ } catch(er){}
1290
+ };
1291
+
1292
+ var hidePlaceholder = function(elem, data, value, _onFocus){
1293
+ if(value === false){
1294
+ value = $.prop(elem, 'value');
1295
+ }
1296
+ if(!isOver && elem.type != 'password'){
1297
+ if(!value && _onFocus && setSelection(elem)){
1298
+ var selectTimer = setTimeout(function(){
1299
+ setSelection(elem);
1300
+ }, 9);
1301
+ $(elem)
1302
+ .off('.placeholderremove')
1303
+ .on({
1304
+ 'keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove': function(e){
1305
+ if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
1306
+ elem.value = $.prop(elem, 'value');
1307
+ data.box.removeClass('placeholder-visible');
1308
+ clearTimeout(selectTimer);
1309
+ $(elem).unbind('.placeholderremove');
1310
+ },
1311
+ 'mousedown.placeholderremove drag.placeholderremove select.placeholderremove': function(e){
1312
+ setSelection(elem);
1313
+ clearTimeout(selectTimer);
1314
+ selectTimer = setTimeout(function(){
1315
+ setSelection(elem);
1316
+ }, 9);
1317
+ },
1318
+ 'blur.placeholderremove': function(){
1319
+ clearTimeout(selectTimer);
1320
+ $(elem).unbind('.placeholderremove');
1321
+ }
1322
+ })
1323
+ ;
1324
+ return;
1325
+ }
1326
+ elem.value = value;
1327
+ } else if(!value && _onFocus){
1328
+ $(elem)
1329
+ .off('.placeholderremove')
1330
+ .on({
1331
+ 'keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove': function(e){
1332
+ if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
1333
+ data.box.removeClass('placeholder-visible');
1334
+ $(elem).unbind('.placeholderremove');
1335
+ },
1336
+ 'blur.placeholderremove': function(){
1337
+ $(elem).unbind('.placeholderremove');
1338
+ }
1339
+ })
1340
+ ;
1341
+ return;
1342
+ }
1343
+ data.box.removeClass('placeholder-visible');
1344
+ },
1345
+ showPlaceholder = function(elem, data, placeholderTxt){
1346
+ if(placeholderTxt === false){
1347
+ placeholderTxt = $.prop(elem, 'placeholder');
1348
+ }
1349
+
1350
+ if(!isOver && elem.type != 'password'){
1351
+ elem.value = placeholderTxt;
1352
+ }
1353
+ data.box.addClass('placeholder-visible');
1354
+ },
1355
+ changePlaceholderVisibility = function(elem, value, placeholderTxt, data, type){
1356
+ if(!data){
1357
+ data = $.data(elem, 'placeHolder');
1358
+ if(!data){return;}
1359
+ }
1360
+ $(elem).unbind('.placeholderremove');
1361
+ if(type == 'focus' || (!type && $(elem).is(':focus'))){
1362
+ if(elem.type == 'password' || isOver || $(elem).hasClass('placeholder-visible')){
1363
+ hidePlaceholder(elem, data, '', true);
1364
+ }
1365
+ return;
1366
+ }
1367
+ if(value === false){
1368
+ value = $.prop(elem, 'value');
1369
+ }
1370
+ if(value){
1371
+ hidePlaceholder(elem, data, value);
1372
+ return;
1373
+ }
1374
+ if(placeholderTxt === false){
1375
+ placeholderTxt = $.attr(elem, 'placeholder') || '';
1376
+ }
1377
+ if(placeholderTxt && !value){
1378
+ showPlaceholder(elem, data, placeholderTxt);
1379
+ } else {
1380
+ hidePlaceholder(elem, data, value);
1381
+ }
1382
+ },
1383
+ createPlaceholder = function(elem){
1384
+ elem = $(elem);
1385
+ var id = elem.prop('id'),
1386
+ hasLabel = !!(elem.prop('title') || elem.attr('aria-labelledby'))
1387
+ ;
1388
+ if(!hasLabel && id){
1389
+ hasLabel = !!( $('label[for="'+ id +'"]', elem[0].form)[0] );
1390
+ }
1391
+ if(!hasLabel){
1392
+ if(!id){
1393
+ id = $.webshims.getID(elem);
1394
+ }
1395
+ hasLabel = !!($('label #'+ id)[0]);
1396
+ }
1397
+ return $( hasLabel ? '<span class="placeholder-text"></span>' : '<label for="'+ id +'" class="placeholder-text"></label>');
1398
+ },
1399
+ pHolder = (function(){
1400
+ var delReg = /\n|\r|\f|\t/g,
1401
+ allowedPlaceholder = {
1402
+ text: 1,
1403
+ search: 1,
1404
+ url: 1,
1405
+ email: 1,
1406
+ password: 1,
1407
+ tel: 1
1408
+ }
1409
+ ;
1410
+
1411
+ return {
1412
+ create: function(elem){
1413
+ var data = $.data(elem, 'placeHolder');
1414
+ var form;
1415
+ var responsiveElem;
1416
+ if(data){return data;}
1417
+ data = $.data(elem, 'placeHolder', {});
1418
+
1419
+ $(elem).on('focus.placeholder blur.placeholder', function(e){
1420
+ changePlaceholderVisibility(this, false, false, data, e.type );
1421
+ data.box[e.type == 'focus' ? 'addClass' : 'removeClass']('placeholder-focused');
1422
+ });
1423
+
1424
+ if((form = $.prop(elem, 'form'))){
1425
+ $(form).on('reset.placeholder', function(e){
1426
+ setTimeout(function(){
1427
+ changePlaceholderVisibility(elem, false, false, data, e.type );
1428
+ }, 0);
1429
+ });
1430
+ }
1431
+
1432
+ if(elem.type == 'password' || isOver){
1433
+ data.text = createPlaceholder(elem);
1434
+ if(isResponsive || $(elem).is('.responsive-width') || (elem.currentStyle || {width: ''}).width.indexOf('%') != -1){
1435
+ responsiveElem = true;
1436
+ data.box = data.text;
1437
+ } else {
1438
+ data.box = $(elem)
1439
+ .wrap('<span class="placeholder-box placeholder-box-'+ (elem.nodeName || '').toLowerCase() +' placeholder-box-'+$.css(elem, 'float')+'" />')
1440
+ .parent()
1441
+ ;
1442
+ }
1443
+ data.text
1444
+ .insertAfter(elem)
1445
+ .on('mousedown.placeholder', function(){
1446
+ changePlaceholderVisibility(this, false, false, data, 'focus');
1447
+ try {
1448
+ setTimeout(function(){
1449
+ elem.focus();
1450
+ }, 0);
1451
+ } catch(e){}
1452
+ return false;
1453
+ })
1454
+ ;
1455
+
1456
+
1457
+ $.each(['lineHeight', 'fontSize', 'fontFamily', 'fontWeight'], function(i, style){
1458
+ var prop = $.css(elem, style);
1459
+ if(data.text.css(style) != prop){
1460
+ data.text.css(style, prop);
1461
+ }
1462
+ });
1463
+ $.each(['Left', 'Top'], function(i, side){
1464
+ 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);
1465
+ data.text.css('padding'+ side, size);
1466
+ });
1467
+
1468
+ $(elem)
1469
+ .on('updateshadowdom', function(){
1470
+ var height, width;
1471
+ if((width = elem.offsetWidth) || (height = elem.offsetHeight)){
1472
+ data.text
1473
+ .css({
1474
+ width: width,
1475
+ height: height
1476
+ })
1477
+ .css($(elem).position())
1478
+ ;
1479
+ }
1480
+ })
1481
+ .triggerHandler('updateshadowdom')
1482
+ ;
1483
+
1484
+ } else {
1485
+ var reset = function(e){
1486
+ if($(elem).hasClass('placeholder-visible')){
1487
+ hidePlaceholder(elem, data, '');
1488
+ if(e && e.type == 'submit'){
1489
+ setTimeout(function(){
1490
+ if(e.isDefaultPrevented()){
1491
+ changePlaceholderVisibility(elem, false, false, data );
1492
+ }
1493
+ }, 9);
1494
+ }
1495
+ }
1496
+ };
1497
+
1498
+ $(window).on('beforeunload', reset);
1499
+ data.box = $(elem);
1500
+ if(form){
1501
+ $(form).submit(reset);
1502
+ }
1503
+ }
1504
+
1505
+ return data;
1506
+ },
1507
+ update: function(elem, val){
1508
+ var type = ($.attr(elem, 'type') || $.prop(elem, 'type') || '').toLowerCase();
1509
+ if(!allowedPlaceholder[type] && !$.nodeName(elem, 'textarea')){
1510
+ webshims.error('placeholder not allowed on input[type="'+type+'"]');
1511
+ if(type == 'date'){
1512
+ webshims.error('but you can use data-placeholder for input[type="date"]');
1513
+ }
1514
+ return;
1515
+ }
1516
+
1517
+
1518
+ var data = pHolder.create(elem);
1519
+ if(data.text){
1520
+ data.text.text(val);
1521
+ }
1522
+
1523
+ changePlaceholderVisibility(elem, false, val, data);
1524
+ }
1525
+ };
1526
+ })()
1527
+ ;
1528
+
1529
+ $.webshims.publicMethods = {
1530
+ pHolder: pHolder
1531
+ };
1532
+ polyfillElements.forEach(function(nodeName){
1533
+ var desc = webshims.defineNodeNameProperty(nodeName, 'placeholder', {
1534
+ attr: {
1535
+ set: function(val){
1536
+ var elem = this;
1537
+ if(bustedTextarea){
1538
+ webshims.data(elem, 'textareaPlaceholder', val);
1539
+ elem.placeholder = '';
1540
+ } else {
1541
+ webshims.contentAttr(elem, 'placeholder', val);
1542
+ }
1543
+ pHolder.update(elem, val);
1544
+ },
1545
+ get: function(){
1546
+ var ret = (bustedTextarea) ? webshims.data(this, 'textareaPlaceholder') : '';
1547
+ return ret || webshims.contentAttr(this, 'placeholder');
1548
+ }
1549
+ },
1550
+ reflect: true,
1551
+ initAttr: true
1552
+ });
1553
+ });
1554
+
1555
+
1556
+ polyfillElements.forEach(function(name){
1557
+ var placeholderValueDesc = {};
1558
+ var desc;
1559
+ ['attr', 'prop'].forEach(function(propType){
1560
+ placeholderValueDesc[propType] = {
1561
+ set: function(val){
1562
+ var elem = this;
1563
+ var placeholder;
1564
+ if(bustedTextarea){
1565
+ placeholder = webshims.data(elem, 'textareaPlaceholder');
1566
+ }
1567
+ if(!placeholder){
1568
+ placeholder = webshims.contentAttr(elem, 'placeholder');
1569
+ }
1570
+ $.removeData(elem, 'cachedValidity');
1571
+ var ret = desc[propType]._supset.call(elem, val);
1572
+ if(placeholder && 'value' in elem){
1573
+ changePlaceholderVisibility(elem, val, placeholder);
1574
+ }
1575
+ return ret;
1576
+ },
1577
+ get: function(){
1578
+ var elem = this;
1579
+ return $(elem).hasClass('placeholder-visible') ? '' : desc[propType]._supget.call(elem);
1580
+ }
1581
+ };
1582
+ });
1583
+ desc = webshims.defineNodeNameProperty(name, 'value', placeholderValueDesc);
1584
+ });
1585
+
1586
+ })();
1587
+
1588
+ (function(){
1589
+ var doc = document;
1590
+ if( 'value' in document.createElement('output') ){return;}
1591
+
1592
+ webshims.defineNodeNameProperty('output', 'value', {
1593
+ prop: {
1594
+ set: function(value){
1595
+ var setVal = $.data(this, 'outputShim');
1596
+ if(!setVal){
1597
+ setVal = outputCreate(this);
1598
+ }
1599
+ setVal(value);
1600
+ },
1601
+ get: function(){
1602
+ return webshims.contentAttr(this, 'value') || $(this).text() || '';
1603
+ }
1604
+ }
1605
+ });
1606
+
1607
+
1608
+ webshims.onNodeNamesPropertyModify('input', 'value', function(value, boolVal, type){
1609
+ if(type == 'removeAttr'){return;}
1610
+ var setVal = $.data(this, 'outputShim');
1611
+ if(setVal){
1612
+ setVal(value);
1613
+ }
1614
+ });
1615
+
1616
+ var outputCreate = function(elem){
1617
+ if(elem.getAttribute('aria-live')){return;}
1618
+ elem = $(elem);
1619
+ var value = (elem.text() || '').trim();
1620
+ var id = elem.attr('id');
1621
+ var htmlFor = elem.attr('for');
1622
+ var shim = $('<input class="output-shim" type="text" disabled name="'+ (elem.attr('name') || '')+'" value="'+value+'" style="display: none !important;" />').insertAfter(elem);
1623
+ var form = shim[0].form || doc;
1624
+ var setValue = function(val){
1625
+ shim[0].value = val;
1626
+ val = shim[0].value;
1627
+ elem.text(val);
1628
+ webshims.contentAttr(elem[0], 'value', val);
1629
+ };
1630
+
1631
+ elem[0].defaultValue = value;
1632
+ webshims.contentAttr(elem[0], 'value', value);
1633
+
1634
+ elem.attr({'aria-live': 'polite'});
1635
+ if(id){
1636
+ shim.attr('id', id);
1637
+ elem.attr('aria-labelledby', webshims.getID($('label[for="'+id+'"]', form)));
1638
+ }
1639
+ if(htmlFor){
1640
+ id = webshims.getID(elem);
1641
+ htmlFor.split(' ').forEach(function(control){
1642
+ control = document.getElementById(control);
1643
+ if(control){
1644
+ control.setAttribute('aria-controls', id);
1645
+ }
1646
+ });
1647
+ }
1648
+ elem.data('outputShim', setValue );
1649
+ shim.data('outputShim', setValue );
1650
+ return setValue;
1651
+ };
1652
+
1653
+ webshims.addReady(function(context, contextElem){
1654
+ $('output', context).add(contextElem.filter('output')).each(function(){
1655
+ outputCreate(this);
1656
+ });
1657
+ });
1658
+
1659
+ /*
1660
+ * Implements input event in all browsers
1661
+ */
1662
+ (function(){
1663
+ var noInputTriggerEvts = {updateInput: 1, input: 1},
1664
+ noInputTypes = {
1665
+ radio: 1,
1666
+ checkbox: 1,
1667
+ submit: 1,
1668
+ button: 1,
1669
+ image: 1,
1670
+ reset: 1,
1671
+ file: 1
1672
+
1673
+ //pro forma
1674
+ ,color: 1
1675
+ //,range: 1
1676
+ },
1677
+ observe = function(input){
1678
+ var timer,
1679
+ lastVal = input.prop('value'),
1680
+ trigger = function(e){
1681
+ //input === null
1682
+ if(!input){return;}
1683
+ var newVal = input.prop('value');
1684
+
1685
+ if(newVal !== lastVal){
1686
+ lastVal = newVal;
1687
+ if(!e || !noInputTriggerEvts[e.type]){
1688
+ webshims.triggerInlineForm && webshims.triggerInlineForm(input[0], 'input');
1689
+ }
1690
+ }
1691
+ },
1692
+ extraTimer,
1693
+ extraTest = function(){
1694
+ clearTimeout(extraTimer);
1695
+ extraTimer = setTimeout(trigger, 9);
1696
+ },
1697
+ unbind = function(){
1698
+ input.unbind('focusout', unbind).unbind('keyup keypress keydown paste cut', extraTest).unbind('input change updateInput', trigger);
1699
+ clearInterval(timer);
1700
+ setTimeout(function(){
1701
+ trigger();
1702
+ input = null;
1703
+ }, 1);
1704
+
1705
+ }
1706
+ ;
1707
+
1708
+ clearInterval(timer);
1709
+ timer = setInterval(trigger, 99);
1710
+ extraTest();
1711
+ input.on({
1712
+ 'keyup keypress keydown paste cut': extraTest,
1713
+ focusout: unbind,
1714
+ 'input updateInput change': trigger
1715
+ });
1716
+ }
1717
+ ;
1718
+ if($.event.customEvent){
1719
+ $.event.customEvent.updateInput = true;
1720
+ }
1721
+
1722
+ $(doc)
1723
+ .on('focusin', function(e){
1724
+ if( e.target && e.target.type && !e.target.readOnly && !e.target.disabled && (e.target.nodeName || '').toLowerCase() == 'input' && !noInputTypes[e.target.type] ){
1725
+ observe($(e.target));
1726
+ }
1727
+ })
1728
+ ;
1729
+ })();
1730
+ })();
1731
+
1732
+ }); //webshims.ready end
1733
+ }//end formvalidation