webshims-rails 1.12.5 → 1.12.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/polyfiller.js +111 -132
  4. data/vendor/assets/javascripts/webshims/shims/combos/1.js +40 -37
  5. data/vendor/assets/javascripts/webshims/shims/combos/10.js +217 -36
  6. data/vendor/assets/javascripts/webshims/shims/combos/11.js +151 -29
  7. data/vendor/assets/javascripts/webshims/shims/combos/12.js +70 -93
  8. data/vendor/assets/javascripts/webshims/shims/combos/13.js +70 -93
  9. data/vendor/assets/javascripts/webshims/shims/combos/14.js +90 -13
  10. data/vendor/assets/javascripts/webshims/shims/combos/15.js +202 -59
  11. data/vendor/assets/javascripts/webshims/shims/combos/16.js +208 -70
  12. data/vendor/assets/javascripts/webshims/shims/combos/17.js +151 -29
  13. data/vendor/assets/javascripts/webshims/shims/combos/18.js +155 -30
  14. data/vendor/assets/javascripts/webshims/shims/combos/19.js +79 -20
  15. data/vendor/assets/javascripts/webshims/shims/combos/2.js +109 -47
  16. data/vendor/assets/javascripts/webshims/shims/combos/20.js +79 -20
  17. data/vendor/assets/javascripts/webshims/shims/combos/21.js +80 -87
  18. data/vendor/assets/javascripts/webshims/shims/combos/22.js +66 -83
  19. data/vendor/assets/javascripts/webshims/shims/combos/23.js +4 -10
  20. data/vendor/assets/javascripts/webshims/shims/combos/25.js +79 -20
  21. data/vendor/assets/javascripts/webshims/shims/combos/26.js +66 -7
  22. data/vendor/assets/javascripts/webshims/shims/combos/28.js +100 -25
  23. data/vendor/assets/javascripts/webshims/shims/combos/3.js +192 -47
  24. data/vendor/assets/javascripts/webshims/shims/combos/30.js +193 -49
  25. data/vendor/assets/javascripts/webshims/shims/combos/31.js +103 -36
  26. data/vendor/assets/javascripts/webshims/shims/combos/32.js +5 -3
  27. data/vendor/assets/javascripts/webshims/shims/combos/33.js +1 -2
  28. data/vendor/assets/javascripts/webshims/shims/combos/34.js +2048 -0
  29. data/vendor/assets/javascripts/webshims/shims/combos/4.js +156 -20
  30. data/vendor/assets/javascripts/webshims/shims/combos/5.js +151 -29
  31. data/vendor/assets/javascripts/webshims/shims/combos/6.js +152 -31
  32. data/vendor/assets/javascripts/webshims/shims/combos/7.js +199 -60
  33. data/vendor/assets/javascripts/webshims/shims/combos/8.js +197 -58
  34. data/vendor/assets/javascripts/webshims/shims/combos/9.js +218 -38
  35. data/vendor/assets/javascripts/webshims/shims/combos/97.js +1004 -0
  36. data/vendor/assets/javascripts/webshims/shims/combos/98.js +1283 -0
  37. data/vendor/assets/javascripts/webshims/shims/combos/99.js +204 -1248
  38. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +66 -7
  39. data/vendor/assets/javascripts/webshims/shims/es5.js +4 -1
  40. data/vendor/assets/javascripts/webshims/shims/form-combat.js +3 -3
  41. data/vendor/assets/javascripts/webshims/shims/form-core.js +36 -27
  42. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +1 -2
  43. data/vendor/assets/javascripts/webshims/shims/form-fixrangechange.js +137 -0
  44. data/vendor/assets/javascripts/webshims/shims/form-message.js +90 -13
  45. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +129 -15
  46. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +9 -10
  47. data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +886 -985
  48. data/vendor/assets/javascripts/webshims/shims/form-validation.js +78 -174
  49. data/vendor/assets/javascripts/webshims/shims/form-validators.js +39 -26
  50. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +45 -17
  51. data/vendor/assets/javascripts/webshims/shims/geolocation.js +10 -3
  52. data/vendor/assets/javascripts/webshims/shims/jme/b.js +71 -246
  53. data/vendor/assets/javascripts/webshims/shims/jme/c.js +133 -1002
  54. data/vendor/assets/javascripts/webshims/shims/jme/controls.css +62 -23
  55. data/vendor/assets/javascripts/webshims/shims/jme/controls.scss +73 -10
  56. data/vendor/assets/javascripts/webshims/shims/jme/mediacontrols-lazy.js +1117 -0
  57. data/vendor/assets/javascripts/webshims/shims/jme/p.js +603 -0
  58. data/vendor/assets/javascripts/webshims/shims/jpicker/jpicker.css +5 -2
  59. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +4 -10
  60. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +4 -1
  61. data/vendor/assets/javascripts/webshims/shims/range-ui.js +22 -14
  62. data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +29 -344
  63. data/vendor/assets/javascripts/webshims/shims/styles/forms-picker.css +362 -0
  64. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +6 -483
  65. data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-picker.scss +488 -0
  66. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim-ext.scss +2 -0
  67. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +10 -2
  68. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +6 -2
  69. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  70. data/vendor/assets/javascripts/webshims/shims/track-ui.js +8 -1
  71. data/vendor/assets/javascripts/webshims/shims/track.js +66 -83
  72. metadata +12 -5
  73. data/vendor/assets/javascripts/webshims/shims/$ajax.js +0 -862
  74. data/vendor/assets/javascripts/webshims/shims/combos/24.js +0 -2087
@@ -1,2087 +0,0 @@
1
- webshims.register('form-shim-extend', function($, webshims, window, document, undefined, options){
2
- "use strict";
3
- webshims.inputTypes = webshims.inputTypes || {};
4
- //some helper-functions
5
- var cfg = webshims.cfg.forms;
6
- var bugs = webshims.bugs;
7
-
8
- var isNumber = function(string){
9
- return (typeof string == 'number' || (string && string == string * 1));
10
- },
11
- typeModels = webshims.inputTypes,
12
- checkTypes = {
13
- radio: 1,
14
- checkbox: 1
15
- },
16
- getType = function(elem){
17
- return (elem.getAttribute('type') || elem.type || '').toLowerCase();
18
- }
19
- ;
20
-
21
- (function(){
22
- if('querySelector' in document){
23
- try {
24
- bugs.findRequired = !($('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /></form>')[0].querySelector('select:required'));
25
- } catch(er){
26
- bugs.findRequired = false;
27
- }
28
-
29
- if (bugs.bustedValidity || bugs.findRequired) {
30
- (function(){
31
- var find = $.find;
32
- var matchesSelector = $.find.matchesSelector;
33
-
34
- var regExp = /(\:valid|\:invalid|\:optional|\:required|\:in-range|\:out-of-range)(?=[\s\[\~\.\+\>\:\#*]|$)/ig;
35
- var regFn = function(sel){
36
- return sel + '-element';
37
- };
38
-
39
- $.find = (function(){
40
- var slice = Array.prototype.slice;
41
- var fn = function(sel){
42
- var ar = arguments;
43
- ar = slice.call(ar, 1, ar.length);
44
- ar.unshift(sel.replace(regExp, regFn));
45
- return find.apply(this, ar);
46
- };
47
- for (var i in find) {
48
- if(find.hasOwnProperty(i)){
49
- fn[i] = find[i];
50
- }
51
- }
52
- return fn;
53
- })();
54
- if(!Modernizr.prefixed || Modernizr.prefixed("matchesSelector", document.documentElement)){
55
- $.find.matchesSelector = function(node, expr){
56
- expr = expr.replace(regExp, regFn);
57
- return matchesSelector.call(this, node, expr);
58
- };
59
- }
60
-
61
- })();
62
- }
63
- }
64
- })();
65
-
66
- //API to add new input types
67
- webshims.addInputType = function(type, obj){
68
- typeModels[type] = obj;
69
- };
70
-
71
- //contsrain-validation-api
72
- var validityPrototype = {
73
- customError: false,
74
-
75
- typeMismatch: false,
76
- badInput: false,
77
- rangeUnderflow: false,
78
- rangeOverflow: false,
79
- stepMismatch: false,
80
- tooLong: false,
81
- tooShort: false,
82
- patternMismatch: false,
83
- valueMissing: false,
84
-
85
- valid: true
86
- };
87
-
88
- var isPlaceholderOptionSelected = function(select){
89
- if(select.type == 'select-one' && select.size < 2){
90
- var option = $('> option:first-child', select);
91
- return !!option.prop('selected');
92
- }
93
- return false;
94
- };
95
-
96
- var emptyJ = $([]);
97
- var getGroupElements = function(elem){
98
- elem = $(elem);
99
- var name, form;
100
- var ret = emptyJ;
101
- if(elem[0].type == 'radio'){
102
- name = elem[0].name;
103
- if(!name){
104
- ret = elem;
105
- } else {
106
- form = elem.prop('form');
107
- ret = $(document.getElementsByName(name)).filter(function(){
108
- return this.type == 'radio' && this.name == name && $.prop(this, 'form') == form;
109
- });
110
- }
111
- }
112
- return ret;
113
- };
114
- var patternTypes = {url: 1, email: 1, text: 1, search: 1, tel: 1, password: 1};
115
- var lengthTypes = $.extend({textarea: 1}, patternTypes);
116
-
117
- var validityRules = {
118
- valueMissing: function(input, val, cache){
119
- if(!input.prop('required')){return false;}
120
- var ret = false;
121
- if(!('type' in cache)){
122
- cache.type = getType(input[0]);
123
- }
124
- if(cache.nodeName == 'select'){
125
- ret = (!val && (input[0].selectedIndex < 0 || isPlaceholderOptionSelected(input[0]) ));
126
- } else if(checkTypes[cache.type]){
127
- ret = (cache.type == 'checkbox') ? !input.is(':checked') : !getGroupElements(input).filter(':checked')[0];
128
- } else {
129
- ret = !(val);
130
- }
131
- return ret;
132
- },
133
- patternMismatch: function(input, val, cache) {
134
- if(val === '' || cache.nodeName == 'select'){return false;}
135
- if(!('type' in cache)){
136
- cache.type = getType(input[0]);
137
- }
138
- if(!patternTypes[cache.type]){return false;}
139
- var pattern = input.attr('pattern');
140
- if(!pattern){return false;}
141
- try {
142
- pattern = new RegExp('^(?:' + pattern + ')$');
143
- } catch(er){
144
- webshims.error('invalid pattern value: "'+ pattern +'" | '+ er);
145
- pattern = false;
146
- }
147
- if(!pattern){return false;}
148
- return !(pattern.test(val));
149
- }
150
- }
151
- ;
152
-
153
- $.each({tooShort: ['minLength', -1], tooLong: ['maxLength', 1]}, function(name, props){
154
- validityRules[name] = function(input, val, cache){
155
- //defaultValue is not the same as dirty flag, but very similiar
156
- if(cache.nodeName == 'select' || input.prop('defaultValue') == val){return false;}
157
- if(!('type' in cache)){
158
- cache.type = getType(input[0]);
159
- }
160
- if(!lengthTypes[cache.type]){return false;}
161
- var prop = input.prop(props[0]);
162
-
163
- return ( prop > 0 && prop * props[1] < val.length * props[1] );
164
- };
165
- });
166
-
167
- $.each({typeMismatch: 'mismatch', badInput: 'bad'}, function(name, fn){
168
- validityRules[name] = function (input, val, cache){
169
- if(val === '' || cache.nodeName == 'select'){return false;}
170
- var ret = false;
171
- if(!('type' in cache)){
172
- cache.type = getType(input[0]);
173
- }
174
-
175
- if(typeModels[cache.type] && typeModels[cache.type][fn]){
176
- ret = typeModels[cache.type][fn](val, input);
177
- } else if('validity' in input[0] && ('name' in input[0].validity)){
178
- ret = input[0].validity[name] || false;
179
- }
180
- return ret;
181
- };
182
- });
183
-
184
- webshims.addValidityRule = function(type, fn){
185
- validityRules[type] = fn;
186
- };
187
-
188
- $.event.special.invalid = {
189
- add: function(){
190
- $.event.special.invalid.setup.call(this.form || this);
191
- },
192
- setup: function(){
193
- var form = this.form || this;
194
- if( $.data(form, 'invalidEventShim') ){
195
- form = null;
196
- return;
197
- }
198
- $(form)
199
- .data('invalidEventShim', true)
200
- .on('submit', $.event.special.invalid.handler)
201
- ;
202
- webshims.moveToFirstEvent(form, 'submit');
203
- if(webshims.bugs.bustedValidity && $.nodeName(form, 'form')){
204
- (function(){
205
- var noValidate = form.getAttribute('novalidate');
206
- form.setAttribute('novalidate', 'novalidate');
207
- webshims.data(form, 'bustedNoValidate', (noValidate == null) ? null : noValidate);
208
- })();
209
- }
210
- form = null;
211
- },
212
- teardown: $.noop,
213
- handler: function(e, d){
214
-
215
- if( e.type != 'submit' || e.testedValidity || !e.originalEvent || !$.nodeName(e.target, 'form') || $.prop(e.target, 'noValidate') ){return;}
216
-
217
- e.testedValidity = true;
218
- var notValid = !($(e.target).callProp('reportValidity'));
219
- if(notValid){
220
- e.stopImmediatePropagation();
221
- if(!options.noFormInvalid){
222
- $(e.target).trigger('invalid');
223
- }
224
- return false;
225
- }
226
- }
227
- };
228
-
229
- $.event.special.submit = $.event.special.submit || {setup: function(){return false;}};
230
- var submitSetup = $.event.special.submit.setup;
231
- $.extend($.event.special.submit, {
232
- setup: function(){
233
- if($.nodeName(this, 'form')){
234
- $(this).on('invalid', $.noop);
235
- } else {
236
- $('form', this).on('invalid', $.noop);
237
- }
238
- return submitSetup.apply(this, arguments);
239
- }
240
- });
241
- webshims.ready('form-shim-extend2 WINDOWLOAD', function(){
242
- $(window).on('invalid', $.noop);
243
- });
244
-
245
-
246
- webshims.addInputType('email', {
247
- mismatch: (function(){
248
- //taken from http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
249
- var test = cfg.emailReg || /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
250
- var splitReg = /\s*,\s*/g;
251
- return function(val, input){
252
- var ret = false;
253
- val = $(input).prop('multiple') ? val.split(splitReg) : [val];
254
-
255
- for(var i = 0; i < val.length; i++){
256
- if(!test.test(val[i])){
257
- ret = true;
258
- break;
259
- }
260
- }
261
- return ret;
262
- };
263
- })()
264
- });
265
-
266
- webshims.addInputType('url', {
267
- mismatch: (function(){
268
- //taken from scott gonzales
269
- 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;
270
- return function(val){
271
- return !test.test(val);
272
- };
273
- })()
274
- });
275
-
276
- webshims.defineNodeNameProperty('input', 'type', {
277
- prop: {
278
- get: function(){
279
- var elem = this;
280
- var type = (elem.getAttribute('type') || '').toLowerCase();
281
- return (webshims.inputTypes[type]) ? type : elem.type;
282
- }
283
- }
284
- });
285
-
286
- // IDLs for constrain validation API
287
- //ToDo: add object to this list
288
- webshims.defineNodeNamesProperties(['button', 'fieldset', 'output'], {
289
- checkValidity: {
290
- value: function(){return true;}
291
- },
292
- reportValidity: {
293
- value: function(){return true;}
294
- },
295
- willValidate: {
296
- value: false
297
- },
298
- setCustomValidity: {
299
- value: $.noop
300
- },
301
- validity: {
302
- writeable: false,
303
- get: function(){
304
- return $.extend({}, validityPrototype);
305
- }
306
- }
307
- }, 'prop');
308
-
309
- var baseCheckValidity = function(elem, type){
310
- var e,
311
- v = $.prop(elem, 'validity')
312
- ;
313
- if(v){
314
- $.data(elem, 'cachedValidity', v);
315
- } else {
316
- return true;
317
- }
318
- if( !v.valid ){
319
- e = $.Event('invalid');
320
- var jElm = $(elem).trigger(e);
321
- if(type == 'reportValidity' && !baseCheckValidity.unhandledInvalids && !e.isDefaultPrevented()){
322
- webshims.validityAlert.showFor(jElm);
323
- baseCheckValidity.unhandledInvalids = true;
324
- }
325
- }
326
- $.removeData(elem, 'cachedValidity');
327
- return v.valid;
328
- };
329
- var rsubmittable = /^(?:select|textarea|input)/i;
330
-
331
- ['checkValidity', 'reportValidity'].forEach(function(name){
332
- webshims.defineNodeNameProperty('form', name, {
333
- prop: {
334
- value: function(){
335
-
336
- var ret = true,
337
- elems = $($.prop(this, 'elements')).filter(function(){
338
- if(!rsubmittable.test(this.nodeName)){return false;}
339
- var shadowData = webshims.data(this, 'shadowData');
340
- return !shadowData || !shadowData.nativeElement || shadowData.nativeElement === this;
341
- })
342
- ;
343
-
344
- baseCheckValidity.unhandledInvalids = false;
345
- for(var i = 0, len = elems.length; i < len; i++){
346
- if( !baseCheckValidity(elems[i], name) ){
347
- ret = false;
348
- }
349
- }
350
- return ret;
351
- }
352
- }
353
- });
354
- });
355
-
356
-
357
-
358
-
359
- ['input', 'textarea', 'select'].forEach(function(nodeName){
360
- var inputValidationAPI = {
361
- setCustomValidity: {
362
- value: function(error){
363
- $.removeData(this, 'cachedValidity');
364
- webshims.data(this, 'customvalidationMessage', ''+error);
365
- if(bugs.bustedValidity && inputValidationAPI.setCustomValidity.prop._supvalue){
366
- inputValidationAPI.setCustomValidity.prop._supvalue.apply(this, arguments);
367
- }
368
- }
369
- },
370
- willValidate: {
371
- writeable: false,
372
- get: (function(){
373
- var types = {
374
- button: 1,
375
- reset: 1,
376
- hidden: 1,
377
- image: 1
378
- }
379
- ;
380
- return function(){
381
- var elem = $(this).getNativeElement()[0];
382
- return !!(!elem.readOnly && !types[elem.type] && !$(elem).is(':disabled') );
383
- };
384
- })()
385
- },
386
- validity: {
387
- writeable: false,
388
- get: function(){
389
- var jElm = $(this).getNativeElement();
390
- var elem = jElm[0];
391
- var validityState = $.data(elem, 'cachedValidity');
392
- if(validityState){
393
- return validityState;
394
- }
395
- validityState = $.extend({}, validityPrototype);
396
-
397
- if( !$.prop(elem, 'willValidate') || elem.type == 'submit' ){
398
- return validityState;
399
- }
400
- var val = jElm.val(),
401
- cache = {nodeName: elem.nodeName.toLowerCase()}
402
- ;
403
-
404
- validityState.customError = !!(webshims.data(elem, 'customvalidationMessage'));
405
- if( validityState.customError ){
406
- validityState.valid = false;
407
- }
408
-
409
- $.each(validityRules, function(rule, fn){
410
- if (fn(jElm, val, cache)) {
411
- validityState[rule] = true;
412
- validityState.valid = false;
413
- }
414
- });
415
- $(this).getShadowFocusElement().attr('aria-invalid', validityState.valid ? 'false' : 'true');
416
- jElm = null;
417
- elem = null;
418
- return validityState;
419
- }
420
- }
421
- };
422
-
423
- ['checkValidity', 'reportValidity'].forEach(function(name){
424
- inputValidationAPI[name] = {
425
- value: function(){
426
- baseCheckValidity.unhandledInvalids = false;
427
- return baseCheckValidity($(this).getNativeElement()[0], name);
428
- }
429
- }
430
- });
431
-
432
- webshims.defineNodeNameProperties(nodeName, inputValidationAPI, 'prop');
433
- });
434
-
435
-
436
- webshims.defineNodeNamesBooleanProperty(['input', 'textarea', 'select'], 'required', {
437
- set: function(value){
438
- $(this).getShadowFocusElement().attr('aria-required', !!(value)+'');
439
- },
440
- initAttr: Modernizr.localstorage //only if we have aria-support
441
- });
442
- webshims.defineNodeNamesBooleanProperty(['input'], 'multiple');
443
-
444
- if(bugs.bustedValidity){
445
-
446
- webshims.defineNodeNameProperty('form', 'novalidate', {
447
- attr: {
448
- set: function(val){
449
- webshims.data(this, 'bustedNoValidate', ''+val);
450
- },
451
- get: function(){
452
- var ret = webshims.data(this, 'bustedNoValidate');
453
- return ret == null ? undefined : ret;
454
- }
455
- },
456
- removeAttr: {
457
- value: function(){
458
- webshims.data(this, 'bustedNoValidate', null);
459
- }
460
- }
461
- });
462
-
463
- $.each(['rangeUnderflow', 'rangeOverflow', 'stepMismatch'], function(i, name){
464
- validityRules[name] = function(elem){
465
- return (elem[0].validity || {})[name] || false;
466
- };
467
- });
468
-
469
- }
470
-
471
- webshims.defineNodeNameProperty('form', 'noValidate', {
472
- prop: {
473
- set: function(val){
474
- val = !!val;
475
- if(val){
476
- $.attr(this, 'novalidate', 'novalidate');
477
- } else {
478
- $(this).removeAttr('novalidate');
479
- }
480
- },
481
- get: function(){
482
- return $.attr(this, 'novalidate') != null;
483
- }
484
- }
485
- });
486
-
487
- ['minlength', 'minLength'].forEach(function(propName){
488
- webshims.defineNodeNamesProperty(['input', 'textarea'], propName, {
489
- prop: {
490
- set: function(val){
491
- val *= 1;
492
- if(val < 0){
493
- throw('INDEX_SIZE_ERR');
494
- }
495
- this.setAttribute('minlength', val || 0);
496
- },
497
- get: function(){
498
- var val = this.getAttribute('minlength');
499
- return val == null ? -1 : (val * 1) || 0;
500
- }
501
- }
502
- });
503
- });
504
-
505
- if(Modernizr.inputtypes.date && /webkit/i.test(navigator.userAgent)){
506
- (function(){
507
-
508
- var noInputTriggerEvts = {updateInput: 1, input: 1},
509
- fixInputTypes = {
510
- date: 1,
511
- time: 1,
512
- month: 1,
513
- week: 1,
514
- "datetime-local": 1
515
- },
516
- noFocusEvents = {
517
- focusout: 1,
518
- blur: 1
519
- },
520
- changeEvts = {
521
- updateInput: 1,
522
- change: 1
523
- },
524
- observe = function(input){
525
- var timer,
526
- focusedin = true,
527
- lastInputVal = input.prop('value'),
528
- lastChangeVal = lastInputVal,
529
- trigger = function(e){
530
- //input === null
531
- if(!input){return;}
532
- var newVal = input.prop('value');
533
-
534
- if(newVal !== lastInputVal){
535
- lastInputVal = newVal;
536
- if(!e || !noInputTriggerEvts[e.type]){
537
- input.trigger('input');
538
- }
539
- }
540
- if(e && changeEvts[e.type]){
541
- lastChangeVal = newVal;
542
- }
543
- if(!focusedin && newVal !== lastChangeVal){
544
- input.trigger('change');
545
- }
546
- },
547
- extraTimer,
548
- extraTest = function(){
549
- clearTimeout(extraTimer);
550
- extraTimer = setTimeout(trigger, 9);
551
- },
552
- unbind = function(e){
553
- clearInterval(timer);
554
- setTimeout(function(){
555
- if(e && noFocusEvents[e.type]){
556
- focusedin = false;
557
- }
558
- if(input){
559
- input.off('focusout blur', unbind).off('input change updateInput', trigger);
560
- trigger();
561
- }
562
- input = null;
563
- }, 1);
564
-
565
- }
566
- ;
567
-
568
- clearInterval(timer);
569
- timer = setInterval(trigger, 160);
570
- extraTest();
571
- input
572
- .off({
573
- 'focusout blur': unbind,
574
- 'input change updateInput': trigger
575
- })
576
- .on({
577
- 'focusout blur': unbind,
578
- 'input updateInput change': trigger
579
- })
580
- ;
581
- }
582
- ;
583
-
584
-
585
- $(document)
586
- .on('focusin', function(e){
587
- if( e.target && fixInputTypes[e.target.type] && !e.target.readOnly && !e.target.disabled ){
588
- observe($(e.target));
589
- }
590
- })
591
- ;
592
-
593
-
594
- })();
595
- }
596
-
597
- webshims.addReady(function(context, contextElem){
598
- //start constrain-validation
599
- var focusElem;
600
- $('form', context)
601
- .add(contextElem.filter('form'))
602
- .on('invalid', $.noop)
603
- ;
604
-
605
- try {
606
- if(context == document && !('form' in (document.activeElement || {}))) {
607
- focusElem = $('input[autofocus], select[autofocus], textarea[autofocus]', context).eq(0).getShadowFocusElement()[0];
608
- if (focusElem && focusElem.offsetHeight && focusElem.offsetWidth) {
609
- focusElem.focus();
610
- }
611
- }
612
- }
613
- catch (er) {}
614
-
615
- });
616
-
617
- if(!Modernizr.input.list){
618
- webshims.defineNodeNameProperty('datalist', 'options', {
619
- prop: {
620
- writeable: false,
621
- get: function(){
622
- var elem = this;
623
- var select = $('select', elem);
624
- var options;
625
- if(select[0]){
626
- options = $.makeArray(select[0].options || []);
627
- } else {
628
- options = $('option', elem).get();
629
- if(options.length){
630
- webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
631
- }
632
- }
633
- return options;
634
- }
635
- }
636
- });
637
- }
638
-
639
-
640
-
641
- var submitterTypes = {submit: 1, button: 1, image: 1};
642
- var formSubmitterDescriptors = {};
643
- [
644
- {
645
- name: "enctype",
646
- limitedTo: {
647
- "application/x-www-form-urlencoded": 1,
648
- "multipart/form-data": 1,
649
- "text/plain": 1
650
- },
651
- defaultProp: "application/x-www-form-urlencoded",
652
- proptype: "enum"
653
- },
654
- {
655
- name: "method",
656
- limitedTo: {
657
- "get": 1,
658
- "post": 1
659
- },
660
- defaultProp: "get",
661
- proptype: "enum"
662
- },
663
- {
664
- name: "action",
665
- proptype: "url"
666
- },
667
- {
668
- name: "target"
669
- },
670
- {
671
- name: "novalidate",
672
- propName: "noValidate",
673
- proptype: "boolean"
674
- }
675
- ].forEach(function(desc){
676
- var propName = 'form'+ (desc.propName || desc.name).replace(/^[a-z]/, function(f){
677
- return f.toUpperCase();
678
- });
679
- var attrName = 'form'+ desc.name;
680
- var formName = desc.name;
681
- var eventName = 'click.webshimssubmittermutate'+formName;
682
-
683
- var changeSubmitter = function(){
684
- var elem = this;
685
- if( !('form' in elem) || !submitterTypes[elem.type] ){return;}
686
- var form = $.prop(elem, 'form');
687
- if(!form){return;}
688
- var attr = $.attr(elem, attrName);
689
- if(attr != null && ( !desc.limitedTo || attr.toLowerCase() === $.prop(elem, propName))){
690
-
691
- var oldAttr = $.attr(form, formName);
692
-
693
- $.attr(form, formName, attr);
694
- setTimeout(function(){
695
- if(oldAttr != null){
696
- $.attr(form, formName, oldAttr);
697
- } else {
698
- try {
699
- $(form).removeAttr(formName);
700
- } catch(er){
701
- form.removeAttribute(formName);
702
- }
703
- }
704
- }, 9);
705
- }
706
- };
707
-
708
-
709
-
710
- switch(desc.proptype) {
711
- case "url":
712
- var urlForm = document.createElement('form');
713
- formSubmitterDescriptors[propName] = {
714
- prop: {
715
- set: function(value){
716
- $.attr(this, attrName, value);
717
- },
718
- get: function(){
719
- var value = $.attr(this, attrName);
720
- if(value == null){return '';}
721
- urlForm.setAttribute('action', value);
722
- return urlForm.action;
723
- }
724
- }
725
- };
726
- break;
727
- case "boolean":
728
- formSubmitterDescriptors[propName] = {
729
- prop: {
730
- set: function(val){
731
- val = !!val;
732
- if(val){
733
- $.attr(this, 'formnovalidate', 'formnovalidate');
734
- } else {
735
- $(this).removeAttr('formnovalidate');
736
- }
737
- },
738
- get: function(){
739
- return $.attr(this, 'formnovalidate') != null;
740
- }
741
- }
742
- };
743
- break;
744
- case "enum":
745
- formSubmitterDescriptors[propName] = {
746
- prop: {
747
- set: function(value){
748
- $.attr(this, attrName, value);
749
- },
750
- get: function(){
751
- var value = $.attr(this, attrName);
752
- return (!value || ( (value = value.toLowerCase()) && !desc.limitedTo[value] )) ? desc.defaultProp : value;
753
- }
754
- }
755
- };
756
- break;
757
- default:
758
- formSubmitterDescriptors[propName] = {
759
- prop: {
760
- set: function(value){
761
- $.attr(this, attrName, value);
762
- },
763
- get: function(){
764
- var value = $.attr(this, attrName);
765
- return (value != null) ? value : "";
766
- }
767
- }
768
- };
769
- }
770
-
771
-
772
- if(!formSubmitterDescriptors[attrName]){
773
- formSubmitterDescriptors[attrName] = {};
774
- }
775
- formSubmitterDescriptors[attrName].attr = {
776
- set: function(value){
777
- formSubmitterDescriptors[attrName].attr._supset.call(this, value);
778
- $(this).off(eventName).on(eventName, changeSubmitter);
779
- },
780
- get: function(){
781
- return formSubmitterDescriptors[attrName].attr._supget.call(this);
782
- }
783
- };
784
- formSubmitterDescriptors[attrName].initAttr = true;
785
- formSubmitterDescriptors[attrName].removeAttr = {
786
- value: function(){
787
- $(this).off(eventName);
788
- formSubmitterDescriptors[attrName].removeAttr._supvalue.call(this);
789
- }
790
- };
791
- });
792
-
793
- webshims.defineNodeNamesProperties(['input', 'button'], formSubmitterDescriptors);
794
-
795
- }); //webshims.ready end
796
- ;webshims.register('form-shim-extend2', function($, webshims, window, document, undefined, options){
797
- "use strict";
798
- var emptyJ = $([]);
799
- var isNumber = function(string){
800
- return (typeof string == 'number' || (string && string == string * 1));
801
- };
802
- var getGroupElements = function(elem){
803
- elem = $(elem);
804
- var name;
805
- var form;
806
- var ret = emptyJ;
807
- if(elem[0].type == 'radio'){
808
- form = elem.prop('form');
809
- name = elem[0].name;
810
- if(!name){
811
- ret = elem;
812
- } else if(form){
813
- ret = $(form[name]);
814
- } else {
815
- ret = $(document.getElementsByName(name)).filter(function(){
816
- return !$.prop(this, 'form');
817
- });
818
- }
819
- ret = ret.filter('[type="radio"]');
820
- }
821
- return ret;
822
- };
823
- //support getSetAttribute
824
- var supportGetSetAttribute = !(('getSetAttribute' in $.support) && !$.support.getSetAttribute);
825
- //submitbubbles for IE6-IE8
826
- var supportSubmitBubbles = !('submitBubbles' in $.support) || $.support.submitBubbles;
827
- var addSubmitBubbles = function(form){
828
- if (!supportSubmitBubbles && form && typeof form == 'object' && !form._submit_attached ) {
829
-
830
- $.event.add( form, 'submit._submit', function( event ) {
831
- event._submit_bubble = true;
832
- });
833
-
834
- form._submit_attached = true;
835
- }
836
- };
837
- if(!supportSubmitBubbles && $.event.special.submit){
838
-
839
- $.event.special.submit.setup = function() {
840
- // Only need this for delegated form submit events
841
- if ( $.nodeName( this, "form" ) ) {
842
- return false;
843
- }
844
-
845
- // Lazy-add a submit handler when a descendant form may potentially be submitted
846
- $.event.add( this, "click._submit keypress._submit", function( e ) {
847
- // Node name check avoids a VML-related crash in IE (#9807)
848
- var elem = e.target,
849
- form = $.nodeName( elem, 'input' ) || $.nodeName( elem, 'button' ) ? $.prop(elem, 'form') : undefined;
850
- addSubmitBubbles(form);
851
-
852
- });
853
- // return undefined since we don't need an event listener
854
- };
855
- }
856
-
857
-
858
-
859
- webshims.defineNodeNamesBooleanProperty(['input', 'textarea', 'select'], 'required', {
860
- set: function(value){
861
- $(this).getShadowFocusElement().attr('aria-required', !!(value)+'');
862
- },
863
- initAttr: true
864
- });
865
-
866
- webshims.reflectProperties(['input'], ['pattern']);
867
-
868
-
869
- if( !('maxLength' in document.createElement('textarea')) ){
870
- var constrainMaxLength = (function(){
871
- var timer;
872
- var curLength = 0;
873
- var lastElement = $([]);
874
- var max = 1e9;
875
- var constrainLength = function(){
876
- var nowValue = lastElement.prop('value');
877
- var nowLen = nowValue.length;
878
- if(nowLen > curLength && nowLen > max){
879
- nowLen = Math.max(curLength, max);
880
- lastElement.prop('value', nowValue.substr(0, nowLen ));
881
- }
882
- curLength = nowLen;
883
- };
884
- var remove = function(){
885
- clearTimeout(timer);
886
- lastElement.off('.maxlengthconstraint');
887
- };
888
- return function(element, maxLength){
889
- remove();
890
- if(maxLength > -1){
891
- max = maxLength;
892
- curLength = $.prop(element, 'value').length;
893
- lastElement = $(element);
894
- lastElement.on({
895
- 'keydown.maxlengthconstraint keypress.maxlengthconstraint paste.maxlengthconstraint cut.maxlengthconstraint': function(e){
896
- setTimeout(constrainLength, 0);
897
- },
898
- 'keyup.maxlengthconstraint': constrainLength,
899
- 'blur.maxlengthconstraint': remove
900
- });
901
- timer = setInterval(constrainLength, 200);
902
- }
903
- };
904
- })();
905
-
906
- constrainMaxLength.update = function(element, maxLength){
907
- if($(element).is(':focus')){
908
- if(!maxLength){
909
- maxLength = $.prop(element, 'maxlength');
910
- }
911
- constrainMaxLength(element, maxLength);
912
- }
913
- };
914
-
915
- $(document).on('focusin', function(e){
916
- var maxLength;
917
- if(e.target.nodeName == "TEXTAREA" && (maxLength = $.prop(e.target, 'maxlength')) > -1){
918
- constrainMaxLength(e.target, maxLength);
919
- }
920
- });
921
-
922
- webshims.defineNodeNameProperty('textarea', 'maxlength', {
923
- attr: {
924
- set: function(val){
925
- this.setAttribute('maxlength', ''+val);
926
- constrainMaxLength.update(this);
927
- },
928
- get: function(){
929
- var ret = this.getAttribute('maxlength');
930
- return ret == null ? undefined : ret;
931
- }
932
- },
933
- prop: {
934
- set: function(val){
935
- if(isNumber(val)){
936
- if(val < 0){
937
- throw('INDEX_SIZE_ERR');
938
- }
939
- val = parseInt(val, 10);
940
- this.setAttribute('maxlength', val);
941
- constrainMaxLength.update(this, val);
942
- return;
943
- }
944
- this.setAttribute('maxlength', '0');
945
- constrainMaxLength.update(this, 0);
946
- },
947
- get: function(){
948
- var val = this.getAttribute('maxlength');
949
- return (isNumber(val) && val >= 0) ? parseInt(val, 10) : -1;
950
-
951
- }
952
- }
953
- });
954
- webshims.defineNodeNameProperty('textarea', 'maxLength', {
955
- prop: {
956
- set: function(val){
957
- $.prop(this, 'maxlength', val);
958
- },
959
- get: function(){
960
- return $.prop(this, 'maxlength');
961
- }
962
- }
963
- });
964
- }
965
-
966
- if(!supportGetSetAttribute && $('<form novalidate></form>').attr('novalidate') == null){
967
- webshims.defineNodeNameProperty('form', 'novalidate', {
968
- attr: {
969
- set: function(val){
970
- this.setAttribute('novalidate', ''+val);
971
- },
972
- get: function(){
973
- var ret = this.getAttribute('novalidate');
974
- return ret == null ? undefined : ret;
975
- }
976
- }
977
- });
978
- }
979
-
980
-
981
- if(!Modernizr.formattribute || !Modernizr.fieldsetdisabled || !Modernizr.fieldsetelements){
982
- (function(){
983
- if(!Modernizr.fieldsetdisabled){
984
- var isFieldsetGroup = /^(?:fieldset)$/i;
985
- var disableElementsSel = 'input, textarea, select, button';
986
- $.extend($.expr[":"], {
987
- "enabled": function( elem ) {
988
- return elem.disabled === false || (isFieldsetGroup.test(elem.nodeName) && webshims.contentAttr(elem, 'disabled') == null && !$(elem).is('fieldset[disabled] *')) ;
989
- },
990
-
991
- "disabled": function( elem ) {
992
- return elem.disabled === true || (isFieldsetGroup.test(elem.nodeName) && (webshims.contentAttr(elem, 'disabled') != null || $(elem).is('fieldset[disabled] *')));
993
- }
994
- });
995
-
996
-
997
- var groupControl = {
998
- getElements: function(group){
999
- $(disableElementsSel, group).each(groupControl.disable);
1000
- },
1001
- disable: function(){
1002
- if(!this.disabled){
1003
- webshims.data(this, 'groupedisabled', true);
1004
- this.disabled = true;
1005
- }
1006
- },
1007
- enable: function(){
1008
- if(this.disabled && webshims.data(this, 'groupedisabled')){
1009
- webshims.data(this, 'groupedisabled', false);
1010
- this.disabled = false;
1011
- }
1012
- }
1013
- };
1014
-
1015
- $(window).on('unload', function(){
1016
- $(disableElementsSel).each(groupControl.enable);
1017
- });
1018
-
1019
- webshims.defineNodeNamesBooleanProperty(['fieldset'], 'disabled', {
1020
- set: function(value){
1021
-
1022
- if(value){
1023
- $(disableElementsSel, this).each(groupControl.disable);
1024
- } else if(!$(this).is('fieldset[disabled] *')){
1025
- var nested = $('fieldset[disabled]', this);
1026
- var elements = $(disableElementsSel, this);
1027
-
1028
- if(nested.length){
1029
- elements = elements.not('fieldset[disabled] *');
1030
- }
1031
-
1032
- elements.each(groupControl.enable);
1033
- }
1034
- },
1035
- initAttr: true,
1036
- useContentAttribute: true
1037
- });
1038
-
1039
- ['input', 'textarea', 'select', 'button'].forEach(function(nodeName){
1040
- var desc = webshims.defineNodeNameProperty(nodeName, 'disabled', {
1041
- prop: {
1042
- set: function(value){
1043
- if(value){
1044
- webshims.data(this, 'groupedisabled', false);
1045
- desc.prop._supset.call(this, value);
1046
- } else if($(this).is('fieldset[disabled] *')){
1047
- webshims.data(this, 'groupedisabled', true);
1048
- desc.prop._supset.call(this, true);
1049
- } else {
1050
- webshims.data(this, 'groupedisabled', false);
1051
- desc.prop._supset.call(this, value);
1052
- }
1053
- },
1054
- get: function(){
1055
- var ret = desc.prop._supget.call(this);
1056
- return ret ? !webshims.data(this, 'groupedisabled') : ret;
1057
- }
1058
- },
1059
- removeAttr: {
1060
- value: function(){
1061
- desc.prop.set.call(this, false);
1062
- }
1063
- }
1064
- });
1065
- });
1066
-
1067
- webshims.addReady(function(context){
1068
-
1069
- $(context)
1070
- .filter('fieldset[disabled], fieldset[disabled] *')
1071
- .find(disableElementsSel)
1072
- .each(groupControl.disable)
1073
- ;
1074
- });
1075
- }
1076
-
1077
-
1078
- if(!Modernizr.formattribute){
1079
- (function(prop, undefined){
1080
- $.prop = function(elem, name, value){
1081
- var ret;
1082
- if(elem && elem.nodeType == 1 && value === undefined && $.nodeName(elem, 'form') && elem.id){
1083
- ret = document.getElementsByName(name);
1084
- if(!ret || !ret.length){
1085
- ret = document.getElementById(name);
1086
- }
1087
- if(ret){
1088
- ret = $(ret).filter(function(){
1089
- return $.prop(this, 'form') == elem;
1090
- }).get();
1091
- if(ret.length){
1092
- return ret.length == 1 ? ret[0] : ret;
1093
- }
1094
- }
1095
- }
1096
- return prop.apply(this, arguments);
1097
- };
1098
- })($.prop, undefined);
1099
-
1100
- var removeAddedElements = function(form){
1101
- var elements = $.data(form, 'webshimsAddedElements');
1102
- if(elements){
1103
- elements.remove();
1104
- $.removeData(form, 'webshimsAddedElements');
1105
- }
1106
- };
1107
-
1108
- webshims.defineNodeNamesProperty(['input', 'textarea', 'select', 'button', 'fieldset'], 'form', {
1109
- prop: {
1110
- get: function(){
1111
- var form = webshims.contentAttr(this, 'form');
1112
- if(form){
1113
- form = document.getElementById(form);
1114
- if(form && !$.nodeName(form, 'form')){
1115
- form = null;
1116
- }
1117
- }
1118
- return form || this.form;
1119
- },
1120
- writeable: false
1121
- }
1122
- });
1123
-
1124
-
1125
- webshims.defineNodeNamesProperty(['form'], 'elements', {
1126
- prop: {
1127
- get: function(){
1128
- var id = this.id;
1129
- var elements = $.makeArray(this.elements);
1130
- if(id){
1131
- elements = $(elements).add('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"], button[form="'+ id +'"], fieldset[form="'+ id +'"]').not('.webshims-visual-hide > *').get();
1132
- }
1133
- return elements;
1134
- },
1135
- writeable: false
1136
- }
1137
- });
1138
-
1139
-
1140
-
1141
- $(function(){
1142
- var stopPropagation = function(e){
1143
- e.stopPropagation();
1144
- };
1145
- var submitters = {
1146
- image: 1,
1147
- submit: 1
1148
- };
1149
- $(document).on('submit', function(e){
1150
-
1151
- if(!e.isDefaultPrevented()){
1152
- var form = e.target;
1153
- var id = form.id;
1154
- var elements;
1155
-
1156
-
1157
- if(id){
1158
- removeAddedElements(form);
1159
-
1160
- elements = $('input[form="'+ id +'"], select[form="'+ id +'"], textarea[form="'+ id +'"]')
1161
- .filter(function(){
1162
- return !this.disabled && this.name && this.form != form;
1163
- })
1164
- .clone()
1165
- ;
1166
- if(elements.length){
1167
- $.data(form, 'webshimsAddedElements', $('<div class="webshims-visual-hide" />').append(elements).appendTo(form));
1168
- setTimeout(function(){
1169
- removeAddedElements(form);
1170
- }, 9);
1171
- }
1172
- elements = null;
1173
- }
1174
- }
1175
- });
1176
-
1177
-
1178
- $(document).on('click', function(e){
1179
- if(submitters[e.target.type] && !e.isDefaultPrevented() && $(e.target).is('input[form], button[form]')){
1180
- var trueForm = $.prop(e.target, 'form');
1181
- var formIn = e.target.form;
1182
- var clone;
1183
- if(trueForm && trueForm != formIn){
1184
- clone = $(e.target)
1185
- .clone()
1186
- .removeAttr('form')
1187
- .addClass('webshims-visual-hide')
1188
- .on('click', stopPropagation)
1189
- .appendTo(trueForm)
1190
- ;
1191
- if(formIn){
1192
- e.preventDefault();
1193
- }
1194
- addSubmitBubbles(trueForm);
1195
- clone.trigger('click');
1196
- setTimeout(function(){
1197
- clone.remove();
1198
- clone = null;
1199
- }, 9);
1200
- }
1201
- }
1202
- });
1203
- });
1204
-
1205
- if(!$.fn.finish && parseFloat($.fn.jquery, 10) < 1.9){
1206
- var rCRLF = /\r?\n/g,
1207
- rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
1208
- rselectTextarea = /^(?:select|textarea)/i;
1209
- $.fn.serializeArray = function() {
1210
- return this.map(function(){
1211
- var elements = $.prop(this, 'elements');
1212
- return elements ? $.makeArray( elements ) : this;
1213
- })
1214
- .filter(function(){
1215
- return this.name && !$(this).is(':disabled') &&
1216
- ( this.checked || rselectTextarea.test( this.nodeName ) ||
1217
- rinput.test( this.type ) );
1218
- })
1219
- .map(function( i, elem ){
1220
- var val = $( this ).val();
1221
-
1222
- return val == null ?
1223
- null :
1224
- $.isArray( val ) ?
1225
- $.map( val, function( val, i ){
1226
- return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
1227
- }) :
1228
- { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
1229
- }).get();
1230
- };
1231
- }
1232
- }
1233
-
1234
- if(!Modernizr.fieldsetelements){
1235
- webshims.defineNodeNamesProperty(['fieldset'], 'elements', {
1236
- prop: {
1237
- get: function(){
1238
- //add listed elements without keygen, object, output
1239
- return $('input, select, textarea, button, fieldset', this).get() || [];
1240
- },
1241
- writeable: false
1242
- }
1243
- });
1244
- }
1245
-
1246
- })();
1247
- }
1248
-
1249
- if($('<input />').prop('labels') == null){
1250
- webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
1251
- prop: {
1252
- get: function(){
1253
- if(this.type == 'hidden'){return null;}
1254
- var id = this.id;
1255
- var labels = $(this)
1256
- .closest('label')
1257
- .filter(function(){
1258
- var hFor = (this.attributes['for'] || {});
1259
- return (!hFor.specified || hFor.value == id);
1260
- })
1261
- ;
1262
-
1263
- if(id) {
1264
- labels = labels.add('label[for="'+ id +'"]');
1265
- }
1266
- return labels.get();
1267
- },
1268
- writeable: false
1269
- }
1270
- });
1271
- }
1272
-
1273
- if(!('value' in document.createElement('progress'))){
1274
- (function(){
1275
-
1276
- var nan = parseInt('NaN', 10);
1277
-
1278
- var updateProgress = function(progress){
1279
- var position = $.prop(progress, 'position');
1280
-
1281
- $.attr(progress, 'data-position', position);
1282
- $('> span', progress).css({width: (position < 0 ? 100 : position * 100) +'%'});
1283
- };
1284
- var desc = {
1285
- position: {
1286
- prop: {
1287
- get: function(){
1288
- var max;
1289
- //jQuery 1.8.x try's to normalize "0" to 0
1290
- var val = this.getAttribute('value');
1291
- var ret = -1;
1292
-
1293
- val = val ? (val * 1) : nan;
1294
- if(!isNaN(val)){
1295
- max = $.prop(this, 'max');
1296
- ret = Math.max(Math.min(val / max, 1), 0);
1297
- if(updateProgress.isInChange){
1298
- $.attr(this, 'aria-valuenow', ret * 100);
1299
- if(updateProgress.isInChange == 'max'){
1300
- $.attr(this, 'aria-valuemax', max);
1301
- }
1302
- }
1303
- $(this).removeClass('ws-indeterminate');
1304
- } else if(updateProgress.isInChange) {
1305
- $(this).removeAttr('aria-valuenow').addClass('ws-indeterminate');
1306
- }
1307
- return ret;
1308
- },
1309
- writeable: false
1310
- }
1311
- }
1312
- };
1313
-
1314
- $.each({value: 0, max: 1}, function(name, defValue){
1315
- var removeProp = (name == 'value' && !$.fn.finish);
1316
- desc[name] = {
1317
- attr: {
1318
- set: function(value){
1319
- var ret = desc[name].attr._supset.call(this, value);
1320
- updateProgress.isInChange = name;
1321
- updateProgress(this);
1322
- updateProgress.isInChange = false;
1323
- return ret;
1324
- }
1325
- },
1326
- removeAttr: {
1327
- value: function(){
1328
- this.removeAttribute(name);
1329
- if(removeProp){
1330
- try {
1331
- delete this.value;
1332
- } catch(er){}
1333
- }
1334
- updateProgress.isInChange = name;
1335
- updateProgress(this);
1336
- updateProgress.isInChange = false;
1337
- }
1338
- },
1339
- prop: {
1340
- get: function(){
1341
- var max;
1342
- var ret = (desc[name].attr.get.call(this) * 1);
1343
- if(ret < 0 || isNaN(ret)){
1344
- ret = defValue;
1345
- } else if(name == 'value'){
1346
- ret = Math.min(ret, $.prop(this, 'max'));
1347
- } else if(ret === 0){
1348
- ret = defValue;
1349
- }
1350
- return ret;
1351
- },
1352
- set: function(value){
1353
- value = value * 1;
1354
- if(isNaN(value)){
1355
- webshims.error('Floating-point value is not finite.');
1356
- }
1357
- return desc[name].attr.set.call(this, value);
1358
- }
1359
- }
1360
- };
1361
- });
1362
-
1363
- webshims.createElement(
1364
- 'progress',
1365
- function(){
1366
- var labels = $(this)
1367
- .attr({role: 'progressbar', 'aria-valuemin': '0'})
1368
- .html('<span class="progress-value" />')
1369
- .jProp('labels')
1370
- .map(function(){
1371
- return webshims.getID(this);
1372
- })
1373
- .get()
1374
- ;
1375
- if(labels.length){
1376
- $.attr(this, 'aria-labelledby', labels.join(' '));
1377
- } else {
1378
- webshims.info("you should use label elements for your prgogress elements");
1379
- }
1380
- if($(this).css('direction') == 'rtl'){
1381
- $(this).addClass('ws-is-rtl');
1382
- }
1383
- updateProgress.isInChange = 'max';
1384
- updateProgress(this);
1385
- updateProgress.isInChange = false;
1386
- },
1387
- desc
1388
- );
1389
-
1390
- })();
1391
- }
1392
-
1393
- try {
1394
- document.querySelector(':checked');
1395
- } catch(er){
1396
- (function(){
1397
- $('html').addClass('no-csschecked');
1398
- var checkInputs = {
1399
- radio: 1,
1400
- checkbox: 1
1401
- };
1402
- var selectChange = function(){
1403
- var options = this.options || [];
1404
- var i, len, option;
1405
- for(i = 0, len = options.length; i < len; i++){
1406
- option = $(options[i]);
1407
- option[$.prop(options[i], 'selected') ? 'addClass' : 'removeClass']('prop-checked');
1408
- }
1409
- };
1410
- var checkChange = function(){
1411
- var fn = $.prop(this, 'checked') ? 'addClass' : 'removeClass';
1412
- var className = this.className || '';
1413
- var parent;
1414
-
1415
- //IE8- has problems to update styles, we help
1416
- if( (className.indexOf('prop-checked') == -1) == (fn == 'addClass')){
1417
- $(this)[fn]('prop-checked');
1418
- if((parent = this.parentNode)){
1419
- parent.className = parent.className;
1420
- }
1421
- }
1422
- };
1423
-
1424
-
1425
- webshims.onNodeNamesPropertyModify('select', 'value', selectChange);
1426
- webshims.onNodeNamesPropertyModify('select', 'selectedIndex', selectChange);
1427
- webshims.onNodeNamesPropertyModify('option', 'selected', function(){
1428
- $(this).closest('select').each(selectChange);
1429
- });
1430
- webshims.onNodeNamesPropertyModify('input', 'checked', function(value, boolVal){
1431
- var type = this.type;
1432
- if(type == 'radio' && boolVal){
1433
- getGroupElements(this).each(checkChange);
1434
- } else if(checkInputs[type]) {
1435
- $(this).each(checkChange);
1436
- }
1437
- });
1438
-
1439
- $(document).on('change', function(e){
1440
-
1441
- if(checkInputs[e.target.type]){
1442
- if(e.target.type == 'radio'){
1443
- getGroupElements(e.target).each(checkChange);
1444
- } else {
1445
- $(e.target)[$.prop(e.target, 'checked') ? 'addClass' : 'removeClass']('prop-checked');
1446
- }
1447
- } else if(e.target.nodeName.toLowerCase() == 'select'){
1448
- $(e.target).each(selectChange);
1449
- }
1450
- });
1451
-
1452
- webshims.addReady(function(context, contextElem){
1453
- $('option, input', context)
1454
- .add(contextElem.filter('option, input'))
1455
- .each(function(){
1456
- var prop;
1457
- if(checkInputs[this.type]){
1458
- prop = 'checked';
1459
- } else if(this.nodeName.toLowerCase() == 'option'){
1460
- prop = 'selected';
1461
- }
1462
- if(prop){
1463
- $(this)[$.prop(this, prop) ? 'addClass' : 'removeClass']('prop-checked');
1464
- }
1465
-
1466
- })
1467
- ;
1468
- });
1469
- })();
1470
- }
1471
-
1472
- if(!('setSelectionRange' in document.createElement('input'))){
1473
- (function(){
1474
- var getSelection = function(elem, getStart){
1475
- var range, value, normalizedValue, textInputRange, len, endRange;
1476
- var start = 0;
1477
- var end = 0;
1478
- if (document.selection && (range = document.selection.createRange()) && range.parentElement() == elem) {
1479
- value = $.prop(elem, 'value');
1480
- len = value.length;
1481
- normalizedValue = value.replace(/\r\n/g, "\n");
1482
-
1483
- textInputRange = elem.createTextRange();
1484
- textInputRange.moveToBookmark(range.getBookmark());
1485
-
1486
-
1487
- endRange = elem.createTextRange();
1488
- endRange.collapse(false);
1489
-
1490
- if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
1491
- start = end = len;
1492
- } else {
1493
- if(getStart){
1494
- start = -textInputRange.moveStart("character", -len);
1495
- start += normalizedValue.slice(0, start).split("\n").length - 1;
1496
- } else {
1497
- if (textInputRange.compareEndPoints("EndToEnd", endRange) > -1) {
1498
- end = len;
1499
- } else {
1500
- end = -textInputRange.moveEnd("character", -len);
1501
- end += normalizedValue.slice(0, end).split("\n").length - 1;
1502
- }
1503
- }
1504
-
1505
- }
1506
- }
1507
- return {
1508
- start: start,
1509
- end: end
1510
- };
1511
- };
1512
-
1513
- ['input', 'textarea'].forEach(function(name){
1514
- var isTextarea = name == 'textarea';
1515
- //email?
1516
- var allowedTypes = {text: 1, search: 1, url: 1, tel: 1, password: 1, email: 1};
1517
- var error = 'InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable. selection not allowed on this type';
1518
- webshims.defineNodeNameProperties(name, {
1519
- selectionStart: {
1520
- get: function(){
1521
- if(isTextarea || allowedTypes[$.prop(this, 'type')]){
1522
- return getSelection(this, true).start;
1523
- }
1524
- webshims.error(error);
1525
- },
1526
- set: function(v){
1527
- if(this.createTextRange && (isTextarea || allowedTypes[$.prop(this, 'type')])){
1528
- var range = this.createTextRange();
1529
- range.collapse(true);
1530
- range.moveStart('character', v);
1531
- range.moveEnd('character', $.prop(this, 'selectionEnd'));
1532
- if($(this).is(':focus')){
1533
- range.select();
1534
- }
1535
- } else {
1536
- webshims.error(error);
1537
- }
1538
- }
1539
- },
1540
- selectionEnd: {
1541
- get: function(){
1542
- if(isTextarea || allowedTypes[$.prop(this, 'type')]){
1543
- return getSelection(this).end;
1544
- }
1545
- webshims.error(error);
1546
- },
1547
- set: function(v){
1548
- if(this.createTextRange && (isTextarea || allowedTypes[$.prop(this, 'type')])){
1549
- var range = this.createTextRange();
1550
- var start;
1551
- range.collapse(true);
1552
- start = getSelection(this, true).start;
1553
- range.moveStart('character', start);
1554
- range.moveEnd('character', v - start);
1555
- if($(this).is(':focus')){
1556
- range.select();
1557
- }
1558
- } else {
1559
- webshims.error(error);
1560
- }
1561
- }
1562
- },
1563
- setSelectionRange: {
1564
- value: function(start, end, dir){
1565
- if(this.createTextRange && (isTextarea || allowedTypes[$.prop(this, 'type')])){
1566
- var range = this.createTextRange();
1567
- range.collapse(true);
1568
- range.moveStart('character', start);
1569
- range.moveEnd('character', end - start);
1570
- if($(this).is(':focus')){
1571
- range.select();
1572
- }
1573
- } else {
1574
- webshims.error(error);
1575
- }
1576
- }
1577
- }
1578
- }, 'prop');
1579
- });
1580
-
1581
- })();
1582
- }
1583
-
1584
- (function(){
1585
- if(options.noPlaceholderPolyfill){return;}
1586
- var bustedPlaceholder;
1587
- Modernizr.textareaPlaceholder = !!('placeholder' in $('<textarea />')[0]);
1588
- if(Modernizr.input.placeholder && options.overridePlaceholder){
1589
- bustedPlaceholder = true;
1590
- }
1591
- if(Modernizr.input.placeholder && Modernizr.textareaPlaceholder && !bustedPlaceholder){
1592
- (function(){
1593
- var ua = navigator.userAgent;
1594
-
1595
- if(ua.indexOf('Mobile') != -1 && ua.indexOf('Safari') != -1){
1596
- $(window).on('orientationchange', (function(){
1597
- var timer;
1598
- var retVal = function(i, value){
1599
- return value;
1600
- };
1601
-
1602
- var set = function(){
1603
- $('input[placeholder], textarea[placeholder]').attr('placeholder', retVal);
1604
- };
1605
- return function(e){
1606
- clearTimeout(timer);
1607
- timer = setTimeout(set, 9);
1608
- };
1609
- })());
1610
- }
1611
- })();
1612
-
1613
- //abort
1614
- return;
1615
- }
1616
-
1617
- var isOver = (webshims.cfg.forms.placeholderType == 'over');
1618
- var isResponsive = (webshims.cfg.forms.responsivePlaceholder);
1619
- var polyfillElements = ['textarea'];
1620
- if(!Modernizr.input.placeholder || bustedPlaceholder){
1621
- polyfillElements.push('input');
1622
- }
1623
-
1624
- var setSelection = function(elem){
1625
- try {
1626
- $(elem).setSelectionRange(0,0);
1627
- return true;
1628
- } catch(er){}
1629
- };
1630
-
1631
- var hidePlaceholder = function(elem, data, value, _onFocus){
1632
- if(value === false){
1633
- value = $.prop(elem, 'value');
1634
- }
1635
-
1636
- if(!isOver && elem.type != 'password'){
1637
- if(!value && _onFocus && setSelection(elem)){
1638
- var selectTimer = setTimeout(function(){
1639
- setSelection(elem);
1640
- }, 9);
1641
- $(elem)
1642
- .off('.placeholderremove')
1643
- .on({
1644
- 'keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove': function(e){
1645
- if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
1646
- elem.value = $.prop(elem, 'value');
1647
- data.box.removeClass('placeholder-visible');
1648
- clearTimeout(selectTimer);
1649
- $(elem).off('.placeholderremove');
1650
- },
1651
- 'mousedown.placeholderremove drag.placeholderremove select.placeholderremove': function(e){
1652
- setSelection(elem);
1653
- clearTimeout(selectTimer);
1654
- selectTimer = setTimeout(function(){
1655
- setSelection(elem);
1656
- }, 9);
1657
- },
1658
- 'blur.placeholderremove': function(){
1659
- clearTimeout(selectTimer);
1660
- $(elem).off('.placeholderremove');
1661
- }
1662
- })
1663
- ;
1664
- return;
1665
- } else if(!_onFocus && !value && elem.value){ //especially on submit
1666
- elem.value = value;
1667
- }
1668
- } else if(!value && _onFocus){
1669
- $(elem)
1670
- .off('.placeholderremove')
1671
- .on({
1672
- 'keydown.placeholderremove keypress.placeholderremove paste.placeholderremove input.placeholderremove': function(e){
1673
- if(e && (e.keyCode == 17 || e.keyCode == 16)){return;}
1674
- data.box.removeClass('placeholder-visible');
1675
- $(elem).off('.placeholderremove');
1676
- },
1677
- 'blur.placeholderremove': function(){
1678
- $(elem).off('.placeholderremove');
1679
- }
1680
- })
1681
- ;
1682
- return;
1683
- }
1684
- data.box.removeClass('placeholder-visible');
1685
- },
1686
- showPlaceholder = function(elem, data, placeholderTxt){
1687
- if(placeholderTxt === false){
1688
- placeholderTxt = $.prop(elem, 'placeholder');
1689
- }
1690
-
1691
- if(!isOver && elem.type != 'password'){
1692
- elem.value = placeholderTxt;
1693
- }
1694
- data.box.addClass('placeholder-visible');
1695
- },
1696
- changePlaceholderVisibility = function(elem, value, placeholderTxt, data, type){
1697
- if(!data){
1698
- data = $.data(elem, 'placeHolder');
1699
- if(!data){return;}
1700
- }
1701
- var isVisible = $(elem).hasClass('placeholder-visible');
1702
- if(placeholderTxt === false){
1703
- placeholderTxt = $.attr(elem, 'placeholder') || '';
1704
- }
1705
-
1706
- $(elem).off('.placeholderremove');
1707
-
1708
- if(value === false){
1709
- value = $.prop(elem, 'value');
1710
- }
1711
-
1712
- if(!value && (type == 'focus' || (!type && $(elem).is(':focus')))){
1713
- if(elem.type == 'password' || isOver || isVisible){
1714
- hidePlaceholder(elem, data, '', true);
1715
- }
1716
- return;
1717
- }
1718
-
1719
- if(value){
1720
- hidePlaceholder(elem, data, value);
1721
- return;
1722
- }
1723
-
1724
- if(placeholderTxt && !value){
1725
- showPlaceholder(elem, data, placeholderTxt);
1726
- } else {
1727
- hidePlaceholder(elem, data, value);
1728
- }
1729
- },
1730
- hasLabel = function(elem){
1731
- elem = $(elem);
1732
- return !!(elem.prop('title') || elem.attr('aria-labelledby') || elem.attr('aria-label') || elem.jProp('labels').length);
1733
- },
1734
- createPlaceholder = function(elem){
1735
- elem = $(elem);
1736
- return $( hasLabel(elem) ? '<span class="placeholder-text"></span>' : '<label for="'+ elem.prop('id') +'" class="placeholder-text"></label>');
1737
- },
1738
- pHolder = (function(){
1739
- var allowedPlaceholder = {
1740
- text: 1,
1741
- search: 1,
1742
- url: 1,
1743
- email: 1,
1744
- password: 1,
1745
- tel: 1,
1746
- number: 1
1747
- }
1748
- ;
1749
- if(webshims.modules["form-number-date-ui"].loaded){
1750
- delete allowedPlaceholder.number;
1751
- }
1752
-
1753
- return {
1754
- create: function(elem){
1755
- var data = $.data(elem, 'placeHolder');
1756
- var form;
1757
- if(data){return data;}
1758
- data = $.data(elem, 'placeHolder', {});
1759
-
1760
- $(elem).on('focus.placeholder blur.placeholder', function(e){
1761
- changePlaceholderVisibility(this, false, false, data, e.type );
1762
- data.box[e.type == 'focus' ? 'addClass' : 'removeClass']('placeholder-focused');
1763
- });
1764
-
1765
- if((form = $.prop(elem, 'form'))){
1766
- $(elem).onWSOff('reset.placeholder', function(e){
1767
- setTimeout(function(){
1768
- changePlaceholderVisibility(elem, false, false, data, e.type );
1769
- }, 0);
1770
- }, false, form);
1771
- }
1772
-
1773
- if(elem.type == 'password' || isOver){
1774
- data.text = createPlaceholder(elem);
1775
- if(isResponsive || $(elem).is('.responsive-width') || (elem.currentStyle || {width: ''}).width.indexOf('%') != -1){
1776
- data.box = data.text;
1777
- } else {
1778
- data.box = $('<span class="placeholder-box placeholder-box-'+ (elem.nodeName || '').toLowerCase() +' placeholder-box-'+$.css(elem, 'float')+'" />')
1779
- .insertAfter(elem)
1780
- ;
1781
- data.box.append(elem);
1782
- }
1783
- data.text
1784
- .insertAfter(elem)
1785
- .on('mousedown.placeholder', function(){
1786
- changePlaceholderVisibility(this, false, false, data, 'focus');
1787
- try {
1788
- setTimeout(function(){
1789
- elem.focus();
1790
- }, 0);
1791
- } catch(e){}
1792
- return false;
1793
- })
1794
- ;
1795
-
1796
-
1797
- $.each(['lineHeight', 'fontSize', 'fontFamily', 'fontWeight'], function(i, style){
1798
- var prop = $.css(elem, style);
1799
- if(data.text.css(style) != prop){
1800
- data.text.css(style, prop);
1801
- }
1802
- });
1803
- $.each(['Left', 'Top'], function(i, side){
1804
- 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);
1805
- data.text.css('padding'+ side, size);
1806
- });
1807
-
1808
- $(elem)
1809
- .onWSOff('updateshadowdom', (function(){
1810
- var lastWidth, init, timer;
1811
- var jelm = $(elem);
1812
- var lastPos = {};
1813
- return function(){
1814
- var width, fn;
1815
-
1816
- if((width = elem.offsetWidth)){
1817
-
1818
- fn = function(){
1819
- var pos = jelm.position();
1820
- if(width !== lastWidth){
1821
- lastWidth = width;
1822
- data.text[0].style.width = width +'px';
1823
- }
1824
- if(pos.top !== lastPos.top || pos.left !== lastPos.left){
1825
- lastPos = pos;
1826
- data.text[0].style.top = pos.top +'px';
1827
- data.text[0].style.left = pos.left +'px';
1828
- }
1829
- };
1830
- if(!init){
1831
- fn();
1832
- init = true;
1833
- } else {
1834
- clearTimeout(timer);
1835
- timer = setTimeout(fn, 99);
1836
- }
1837
- }
1838
- };
1839
- })(), true)
1840
- ;
1841
-
1842
- } else {
1843
- var reset = function(e){
1844
- if($(elem).hasClass('placeholder-visible')){
1845
- hidePlaceholder(elem, data, '');
1846
-
1847
- setTimeout(function(){
1848
- if(!e || e.type != 'submit' || e.isDefaultPrevented()){
1849
- changePlaceholderVisibility(elem, false, false, data );
1850
- }
1851
- }, 9);
1852
- }
1853
- };
1854
-
1855
- $(elem).onWSOff('beforeunload', reset, false, window);
1856
- data.box = $(elem);
1857
- if(form){
1858
- $(elem).onWSOff('submit', reset, false, form);
1859
- }
1860
- }
1861
-
1862
- return data;
1863
- },
1864
- update: function(elem, val){
1865
- var type = ($.attr(elem, 'type') || $.prop(elem, 'type') || '').toLowerCase();
1866
- if(!allowedPlaceholder[type] && !$.nodeName(elem, 'textarea')){
1867
- webshims.warn('placeholder not allowed on input[type="'+type+'"], but it is a good fallback :-)');
1868
- return;
1869
- }
1870
-
1871
-
1872
- var data = pHolder.create(elem);
1873
- if(data.text){
1874
- data.text.text(val);
1875
- }
1876
-
1877
- changePlaceholderVisibility(elem, false, val, data);
1878
- }
1879
- };
1880
- })()
1881
- ;
1882
-
1883
- $.webshims.publicMethods = {
1884
- pHolder: pHolder
1885
- };
1886
- polyfillElements.forEach(function(nodeName){
1887
- var desc = webshims.defineNodeNameProperty(nodeName, 'placeholder', {
1888
- attr: {
1889
- set: function(val){
1890
- var elem = this;
1891
- if(bustedPlaceholder){
1892
- webshims.data(elem, 'bustedPlaceholder', val);
1893
- elem.placeholder = '';
1894
- } else {
1895
- webshims.contentAttr(elem, 'placeholder', val);
1896
- }
1897
- pHolder.update(elem, val);
1898
- },
1899
- get: function(){
1900
- var placeholder;
1901
- if(bustedPlaceholder){
1902
- placeholder = webshims.data(this, 'bustedPlaceholder');
1903
- }
1904
- return placeholder || webshims.contentAttr(this, 'placeholder');
1905
- }
1906
- },
1907
- reflect: true,
1908
- initAttr: true
1909
- });
1910
- });
1911
-
1912
-
1913
- polyfillElements.forEach(function(name){
1914
- var placeholderValueDesc = {};
1915
- var desc;
1916
- ['attr', 'prop'].forEach(function(propType){
1917
- placeholderValueDesc[propType] = {
1918
- set: function(val){
1919
- var elem = this;
1920
- var placeholder;
1921
- if(bustedPlaceholder){
1922
- placeholder = webshims.data(elem, 'bustedPlaceholder');
1923
- }
1924
- if(!placeholder){
1925
- placeholder = webshims.contentAttr(elem, 'placeholder');
1926
- }
1927
- $.removeData(elem, 'cachedValidity');
1928
- var ret = desc[propType]._supset.call(elem, val);
1929
- if(placeholder && 'value' in elem){
1930
- changePlaceholderVisibility(elem, val, placeholder);
1931
- }
1932
- return ret;
1933
- },
1934
- get: function(){
1935
- var elem = this;
1936
- return $(elem).hasClass('placeholder-visible') ? '' : desc[propType]._supget.call(elem);
1937
- }
1938
- };
1939
- });
1940
- desc = webshims.defineNodeNameProperty(name, 'value', placeholderValueDesc);
1941
- });
1942
-
1943
- })();
1944
-
1945
- (function(){
1946
- var doc = document;
1947
- if( 'value' in document.createElement('output') ){return;}
1948
-
1949
- webshims.defineNodeNameProperty('output', 'value', {
1950
- prop: {
1951
- set: function(value){
1952
- var setVal = $.data(this, 'outputShim');
1953
- if(!setVal){
1954
- setVal = outputCreate(this);
1955
- }
1956
- setVal(value);
1957
- },
1958
- get: function(){
1959
- return webshims.contentAttr(this, 'value') || $(this).text() || '';
1960
- }
1961
- }
1962
- });
1963
-
1964
-
1965
- webshims.onNodeNamesPropertyModify('input', 'value', function(value, boolVal, type){
1966
- if(type == 'removeAttr'){return;}
1967
- var setVal = $.data(this, 'outputShim');
1968
- if(setVal){
1969
- setVal(value);
1970
- }
1971
- });
1972
-
1973
- var outputCreate = function(elem){
1974
- if(elem.getAttribute('aria-live')){return;}
1975
- elem = $(elem);
1976
- var value = (elem.text() || '').trim();
1977
- var id = elem.prop('id');
1978
- var htmlFor = elem.attr('for');
1979
- var shim = $('<input class="output-shim" type="text" disabled name="'+ (elem.attr('name') || '')+'" value="'+value+'" style="display: none !important;" />').insertAfter(elem);
1980
- var form = shim[0].form || doc;
1981
- var setValue = function(val){
1982
- shim[0].value = val;
1983
- val = shim[0].value;
1984
- elem.text(val);
1985
- webshims.contentAttr(elem[0], 'value', val);
1986
- };
1987
-
1988
- elem[0].defaultValue = value;
1989
- webshims.contentAttr(elem[0], 'value', value);
1990
-
1991
- elem.attr({'aria-live': 'polite'});
1992
- if(id){
1993
- shim.attr('id', id);
1994
- elem.attr('aria-labelledby', elem.jProp('labels').map(function(){
1995
- return webshims.getID(this);
1996
- }).get().join(' '));
1997
- }
1998
- if(htmlFor){
1999
- id = webshims.getID(elem);
2000
- htmlFor.split(' ').forEach(function(control){
2001
- control = document.getElementById(control);
2002
- if(control){
2003
- control.setAttribute('aria-controls', id);
2004
- }
2005
- });
2006
- }
2007
- elem.data('outputShim', setValue );
2008
- shim.data('outputShim', setValue );
2009
- return setValue;
2010
- };
2011
-
2012
- webshims.addReady(function(context, contextElem){
2013
- $('output', context).add(contextElem.filter('output')).each(function(){
2014
- outputCreate(this);
2015
- });
2016
- });
2017
-
2018
- /*
2019
- * Implements input event in all browsers
2020
- */
2021
- (function(){
2022
- var noInputTriggerEvts = {updateInput: 1, input: 1},
2023
- noInputTypes = {
2024
- radio: 1,
2025
- checkbox: 1,
2026
- submit: 1,
2027
- button: 1,
2028
- image: 1,
2029
- reset: 1,
2030
- file: 1
2031
-
2032
- //pro forma
2033
- ,color: 1
2034
- },
2035
- observe = function(input){
2036
- var timer,
2037
- lastVal = input.prop('value'),
2038
- trigger = function(e){
2039
- //input === null
2040
- if(!input){return;}
2041
- var newVal = input.prop('value');
2042
- if(newVal !== lastVal){
2043
- lastVal = newVal;
2044
- if(!e || !noInputTriggerEvts[e.type]){
2045
- webshims.triggerInlineForm && webshims.triggerInlineForm(input[0], 'input');
2046
- }
2047
- }
2048
- },
2049
- extraTimer,
2050
- extraTest = function(){
2051
- clearTimeout(extraTimer);
2052
- extraTimer = setTimeout(trigger, 9);
2053
- },
2054
- unbind = function(){
2055
- input.off('focusout', unbind).off('keyup keypress keydown paste cut', extraTest).off('input change updateInput triggerinput', trigger);
2056
- clearInterval(timer);
2057
- setTimeout(function(){
2058
- trigger();
2059
- input = null;
2060
- }, 1);
2061
-
2062
- }
2063
- ;
2064
-
2065
- clearInterval(timer);
2066
- timer = setInterval(trigger, 200);
2067
- extraTest();
2068
- input.on({
2069
- 'keyup keypress keydown paste cut': extraTest,
2070
- focusout: unbind,
2071
- 'input updateInput change triggerinput': trigger
2072
- });
2073
- }
2074
- ;
2075
-
2076
- $(doc)
2077
- .on('focusin', function(e){
2078
- if( e.target && !e.target.readOnly && !e.target.disabled && (e.target.nodeName || '').toLowerCase() == 'input' && !noInputTypes[e.target.type] && !(webshims.data(e.target, 'implemented') || {}).inputwidgets){
2079
- observe($(e.target));
2080
- }
2081
- })
2082
- ;
2083
- })();
2084
- })();
2085
-
2086
-
2087
- });