webshims-rails 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/lib/webshims-rails/version.rb +2 -2
  2. data/vendor/assets/javascripts/webshims/extras/custom-validity.js +253 -253
  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/polyfiller.js +1 -1
  6. data/vendor/assets/javascripts/webshims/minified/shims/combos/10.js +1 -1
  7. data/vendor/assets/javascripts/webshims/minified/shims/combos/12.js +1 -1
  8. data/vendor/assets/javascripts/webshims/minified/shims/combos/16.js +1 -1
  9. data/vendor/assets/javascripts/webshims/minified/shims/combos/17.js +1 -1
  10. data/vendor/assets/javascripts/webshims/minified/shims/combos/19.js +1 -1
  11. data/vendor/assets/javascripts/webshims/minified/shims/combos/2.js +1 -1
  12. data/vendor/assets/javascripts/webshims/minified/shims/combos/20.js +1 -1
  13. data/vendor/assets/javascripts/webshims/minified/shims/combos/21.js +1 -1
  14. data/vendor/assets/javascripts/webshims/minified/shims/combos/22.js +1 -1
  15. data/vendor/assets/javascripts/webshims/minified/shims/combos/23.js +1 -1
  16. data/vendor/assets/javascripts/webshims/minified/shims/combos/24.js +1 -1
  17. data/vendor/assets/javascripts/webshims/minified/shims/combos/25.js +1 -1
  18. data/vendor/assets/javascripts/webshims/minified/shims/combos/26.js +1 -1
  19. data/vendor/assets/javascripts/webshims/minified/shims/combos/27.js +1 -1
  20. data/vendor/assets/javascripts/webshims/minified/shims/combos/3.js +1 -1
  21. data/vendor/assets/javascripts/webshims/minified/shims/combos/4.js +1 -1
  22. data/vendor/assets/javascripts/webshims/minified/shims/combos/5.js +1 -1
  23. data/vendor/assets/javascripts/webshims/minified/shims/combos/59.js +1 -1
  24. data/vendor/assets/javascripts/webshims/minified/shims/combos/8.js +1 -1
  25. data/vendor/assets/javascripts/webshims/minified/shims/combos/9.js +1 -1
  26. data/vendor/assets/javascripts/webshims/minified/shims/form-core.js +1 -1
  27. data/vendor/assets/javascripts/webshims/minified/shims/form-message.js +1 -1
  28. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-de.txt +33 -33
  29. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-en.txt +34 -34
  30. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-core.js +1 -1
  31. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-jaris.js +1 -1
  32. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-swf.js +1 -1
  33. data/vendor/assets/javascripts/webshims/minified/shims/swf/JarisFLVPlayer.swf +0 -0
  34. data/vendor/assets/javascripts/webshims/polyfiller.js +1188 -1188
  35. data/vendor/assets/javascripts/webshims/shims/FlashCanvasPro/README +82 -82
  36. data/vendor/assets/javascripts/webshims/shims/combos/1.js +1752 -1752
  37. data/vendor/assets/javascripts/webshims/shims/combos/10.js +3310 -3311
  38. data/vendor/assets/javascripts/webshims/shims/combos/11.js +1631 -1631
  39. data/vendor/assets/javascripts/webshims/shims/combos/12.js +1695 -1696
  40. data/vendor/assets/javascripts/webshims/shims/combos/13.js +1098 -1098
  41. data/vendor/assets/javascripts/webshims/shims/combos/14.js +477 -477
  42. data/vendor/assets/javascripts/webshims/shims/combos/15.js +317 -317
  43. data/vendor/assets/javascripts/webshims/shims/combos/16.js +2177 -2154
  44. data/vendor/assets/javascripts/webshims/shims/combos/17.js +2354 -2319
  45. data/vendor/assets/javascripts/webshims/shims/combos/18.js +1322 -1322
  46. data/vendor/assets/javascripts/webshims/shims/combos/19.js +2262 -2238
  47. data/vendor/assets/javascripts/webshims/shims/combos/2.js +2376 -2340
  48. data/vendor/assets/javascripts/webshims/shims/combos/20.js +1557 -1558
  49. data/vendor/assets/javascripts/webshims/shims/combos/21.js +1745 -1733
  50. data/vendor/assets/javascripts/webshims/shims/combos/22.js +2360 -2361
  51. data/vendor/assets/javascripts/webshims/shims/combos/23.js +2342 -2331
  52. data/vendor/assets/javascripts/webshims/shims/combos/24.js +2859 -2836
  53. data/vendor/assets/javascripts/webshims/shims/combos/25.js +1547 -1548
  54. data/vendor/assets/javascripts/webshims/shims/combos/26.js +2178 -2155
  55. data/vendor/assets/javascripts/webshims/shims/combos/27.js +3311 -3312
  56. data/vendor/assets/javascripts/webshims/shims/combos/3.js +3058 -3022
  57. data/vendor/assets/javascripts/webshims/shims/combos/4.js +807 -771
  58. data/vendor/assets/javascripts/webshims/shims/combos/5.js +1063 -1027
  59. data/vendor/assets/javascripts/webshims/shims/combos/59.js +1745 -1709
  60. data/vendor/assets/javascripts/webshims/shims/combos/6.js +384 -384
  61. data/vendor/assets/javascripts/webshims/shims/combos/7.js +640 -640
  62. data/vendor/assets/javascripts/webshims/shims/combos/8.js +1546 -1547
  63. data/vendor/assets/javascripts/webshims/shims/combos/9.js +2507 -2508
  64. data/vendor/assets/javascripts/webshims/shims/details.js +148 -148
  65. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +949 -949
  66. data/vendor/assets/javascripts/webshims/shims/es5.js +802 -802
  67. data/vendor/assets/javascripts/webshims/shims/excanvas.js +924 -924
  68. data/vendor/assets/javascripts/webshims/shims/form-core.js +630 -606
  69. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +681 -681
  70. data/vendor/assets/javascripts/webshims/shims/form-message.js +176 -164
  71. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +255 -255
  72. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +383 -383
  73. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +1568 -1568
  74. data/vendor/assets/javascripts/webshims/shims/geolocation.js +168 -168
  75. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ar.js +32 -32
  76. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ch-ZN.js +32 -32
  77. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-de.txt +33 -33
  78. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-el.js +32 -32
  79. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-en.txt +34 -34
  80. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-es.js +31 -31
  81. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-fr.js +32 -32
  82. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-he.js +32 -32
  83. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hi.js +32 -32
  84. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-hu.js +32 -32
  85. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-it.js +32 -32
  86. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ja.js +32 -32
  87. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-nl.js +32 -32
  88. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-pt-PT.js +32 -32
  89. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-ru.js +31 -31
  90. data/vendor/assets/javascripts/webshims/shims/i18n/errormessages-sv.js +32 -32
  91. data/vendor/assets/javascripts/webshims/shims/json-storage.js +308 -308
  92. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +596 -597
  93. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +891 -891
  94. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +98 -98
  95. data/vendor/assets/javascripts/webshims/shims/mediaelement-swf.js +960 -960
  96. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +543 -543
  97. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +697 -697
  98. data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  99. metadata +2 -4
  100. data/vendor/assets/javascripts/webshims/minified/shims/range-ui.js +0 -1
  101. data/vendor/assets/javascripts/webshims/shims/range-ui.js +0 -66
@@ -1,2239 +1,2263 @@
1
- //DOM-Extension helper
2
- jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
3
- "use strict";
4
- //shortcus
5
- var modules = webshims.modules;
6
- var listReg = /\s*,\s*/;
7
-
8
- //proxying attribute
9
- var olds = {};
10
- var havePolyfill = {};
11
- var extendedProps = {};
12
- var extendQ = {};
13
- var modifyProps = {};
14
-
15
- var oldVal = $.fn.val;
16
- var singleVal = function(elem, name, val, pass, _argless){
17
- return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
18
- };
19
- $.fn.val = function(val){
20
- var elem = this[0];
21
- if(arguments.length && val == null){
22
- val = '';
23
- }
24
- if(!arguments.length){
25
- if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
26
- return $.prop(elem, 'value', val, 'val', true);
27
- }
28
- if($.isArray(val)){
29
- return oldVal.apply(this, arguments);
30
- }
31
- var isFunction = $.isFunction(val);
32
- return this.each(function(i){
33
- elem = this;
34
- if(elem.nodeType === 1){
35
- if(isFunction){
36
- var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
37
- if(genVal == null){
38
- genVal = '';
39
- }
40
- $.prop(elem, 'value', genVal, 'val') ;
41
- } else {
42
- $.prop(elem, 'value', val, 'val');
43
- }
44
- }
45
- });
46
- };
47
-
48
- var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
49
- var elementData = function(elem, key, val){
50
- elem = elem.jquery ? elem[0] : elem;
51
- if(!elem){return val || {};}
52
- var data = $.data(elem, dataID);
53
- if(val !== undefined){
54
- if(!data){
55
- data = $.data(elem, dataID, {});
56
- }
57
- if(key){
58
- data[key] = val;
59
- }
60
- }
61
-
62
- return key ? data && data[key] : data;
63
- };
64
-
65
-
66
- [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
67
- $.fn[data.name] = function(){
68
- return this.map(function(){
69
- var shadowData = elementData(this, 'shadowData');
70
- return shadowData && shadowData[data.prop] || this;
71
- });
72
- };
73
- });
74
-
75
-
76
- ['removeAttr', 'prop', 'attr'].forEach(function(type){
77
- olds[type] = $[type];
78
- $[type] = function(elem, name, value, pass, _argless){
79
- var isVal = (pass == 'val');
80
- var oldMethod = !isVal ? olds[type] : singleVal;
81
- if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
82
- return oldMethod(elem, name, value, pass, _argless);
83
- }
84
-
85
- var nodeName = (elem.nodeName || '').toLowerCase();
86
- var desc = extendedProps[nodeName];
87
- var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
88
- var propMethod;
89
- var oldValMethod;
90
- var ret;
91
-
92
-
93
- if(!desc){
94
- desc = extendedProps['*'];
95
- }
96
- if(desc){
97
- desc = desc[name];
98
- }
99
-
100
- if(desc){
101
- propMethod = desc[curType];
102
- }
103
-
104
- if(propMethod){
105
- if(name == 'value'){
106
- oldValMethod = propMethod.isVal;
107
- propMethod.isVal = isVal;
108
- }
109
- if(curType === 'removeAttr'){
110
- return propMethod.value.call(elem);
111
- } else if(value === undefined){
112
- return (propMethod.get) ?
113
- propMethod.get.call(elem) :
114
- propMethod.value
115
- ;
116
- } else if(propMethod.set) {
117
- if(type == 'attr' && value === true){
118
- value = name;
119
- }
120
-
121
- ret = propMethod.set.call(elem, value);
122
- }
123
- if(name == 'value'){
124
- propMethod.isVal = oldValMethod;
125
- }
126
- } else {
127
- ret = oldMethod(elem, name, value, pass, _argless);
128
- }
129
- if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
130
-
131
- var boolValue;
132
- if(curType == 'removeAttr'){
133
- boolValue = false;
134
- } else if(curType == 'prop'){
135
- boolValue = !!(value);
136
- } else {
137
- boolValue = true;
138
- }
139
-
140
- modifyProps[nodeName][name].forEach(function(fn){
141
- if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
142
- fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
143
- }
144
- });
145
- }
146
- return ret;
147
- };
148
-
149
- extendQ[type] = function(nodeName, prop, desc){
150
-
151
- if(!extendedProps[nodeName]){
152
- extendedProps[nodeName] = {};
153
- }
154
- if(!extendedProps[nodeName][prop]){
155
- extendedProps[nodeName][prop] = {};
156
- }
157
- var oldDesc = extendedProps[nodeName][prop][type];
158
- var getSup = function(propType, descriptor, oDesc){
159
- if(descriptor && descriptor[propType]){
160
- return descriptor[propType];
161
- }
162
- if(oDesc && oDesc[propType]){
163
- return oDesc[propType];
164
- }
165
- if(type == 'prop' && prop == 'value'){
166
- return function(value){
167
- var elem = this;
168
- return (desc.isVal) ?
169
- singleVal(elem, prop, value, false, (arguments.length === 0)) :
170
- olds[type](elem, prop, value)
171
- ;
172
- };
173
- }
174
- if(type == 'prop' && propType == 'value' && desc.value.apply){
175
- return function(value){
176
- var sup = olds[type](this, prop);
177
- if(sup && sup.apply){
178
- sup = sup.apply(this, arguments);
179
- }
180
- return sup;
181
- };
182
- }
183
- return function(value){
184
- return olds[type](this, prop, value);
185
- };
186
- };
187
- extendedProps[nodeName][prop][type] = desc;
188
- if(desc.value === undefined){
189
- if(!desc.set){
190
- desc.set = desc.writeable ?
191
- getSup('set', desc, oldDesc) :
192
- (webshims.cfg.useStrict && prop == 'prop') ?
193
- function(){throw(prop +' is readonly on '+ nodeName);} :
194
- $.noop
195
- ;
196
- }
197
- if(!desc.get){
198
- desc.get = getSup('get', desc, oldDesc);
199
- }
200
-
201
- }
202
-
203
- ['value', 'get', 'set'].forEach(function(descProp){
204
- if(desc[descProp]){
205
- desc['_sup'+descProp] = getSup(descProp, oldDesc);
206
- }
207
- });
208
- };
209
-
210
- });
211
-
212
- //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
213
- var isExtendNativeSave = (!$.browser.msie || parseInt($.browser.version, 10) > 8);
214
- var extendNativeValue = (function(){
215
- var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
216
- var has = Object.prototype.hasOwnProperty;
217
- return function(nodeName, prop, desc){
218
- var elem = document.createElement(nodeName);
219
- var elemProto = webshims.getPrototypeOf(elem);
220
- if( isExtendNativeSave && elemProto && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
221
- var sup = elem[prop];
222
- desc._supvalue = function(){
223
- if(sup && sup.apply){
224
- return sup.apply(this, arguments);
225
- }
226
- return sup;
227
- };
228
- elemProto[prop] = desc.value;
229
- } else {
230
- desc._supvalue = function(){
231
- var data = elementData(this, 'propValue');
232
- if(data && data[prop] && data[prop].apply){
233
- return data[prop].apply(this, arguments);
234
- }
235
- return data && data[prop];
236
- };
237
- initProp.extendValue(nodeName, prop, desc.value);
238
- }
239
- desc.value._supvalue = desc._supvalue;
240
- };
241
- })();
242
-
243
- var initProp = (function(){
244
-
245
- var initProps = {};
246
-
247
- webshims.addReady(function(context, contextElem){
248
- var nodeNameCache = {};
249
- var getElementsByName = function(name){
250
- if(!nodeNameCache[name]){
251
- nodeNameCache[name] = $(context.getElementsByTagName(name));
252
- if(contextElem[0] && $.nodeName(contextElem[0], name)){
253
- nodeNameCache[name] = nodeNameCache[name].add(contextElem);
254
- }
255
- }
256
- };
257
-
258
-
259
- $.each(initProps, function(name, fns){
260
- getElementsByName(name);
261
- if(!fns || !fns.forEach){
262
- webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
263
- return;
264
- }
265
- fns.forEach(function(fn){
266
- nodeNameCache[name].each(fn);
267
- });
268
- });
269
- nodeNameCache = null;
270
- });
271
-
272
- var tempCache;
273
- var emptyQ = $([]);
274
- var createNodeNameInit = function(nodeName, fn){
275
- if(!initProps[nodeName]){
276
- initProps[nodeName] = [fn];
277
- } else {
278
- initProps[nodeName].push(fn);
279
- }
280
- if($.isDOMReady){
281
- (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
282
- }
283
- };
284
-
285
- var elementExtends = {};
286
- return {
287
- createTmpCache: function(nodeName){
288
- if($.isDOMReady){
289
- tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
290
- }
291
- return tempCache || emptyQ;
292
- },
293
- flushTmpCache: function(){
294
- tempCache = null;
295
- },
296
- content: function(nodeName, prop){
297
- createNodeNameInit(nodeName, function(){
298
- var val = $.attr(this, prop);
299
- if(val != null){
300
- $.attr(this, prop, val);
301
- }
302
- });
303
- },
304
- createElement: function(nodeName, fn){
305
- createNodeNameInit(nodeName, fn);
306
- },
307
- extendValue: function(nodeName, prop, value){
308
- createNodeNameInit(nodeName, function(){
309
- $(this).each(function(){
310
- var data = elementData(this, 'propValue', {});
311
- data[prop] = this[prop];
312
- this[prop] = value;
313
- });
314
- });
315
- }
316
- };
317
- })();
318
-
319
- var createPropDefault = function(descs, removeType){
320
- if(descs.defaultValue === undefined){
321
- descs.defaultValue = '';
322
- }
323
- if(!descs.removeAttr){
324
- descs.removeAttr = {
325
- value: function(){
326
- descs[removeType || 'prop'].set.call(this, descs.defaultValue);
327
- descs.removeAttr._supvalue.call(this);
328
- }
329
- };
330
- }
331
- if(!descs.attr){
332
- descs.attr = {};
333
- }
334
- };
335
-
336
- $.extend(webshims, {
337
-
338
- getID: (function(){
339
- var ID = new Date().getTime();
340
- return function(elem){
341
- elem = $(elem);
342
- var id = elem.attr('id');
343
- if(!id){
344
- ID++;
345
- id = 'ID-'+ ID;
346
- elem.attr('id', id);
347
- }
348
- return id;
349
- };
350
- })(),
351
- extendUNDEFProp: function(obj, props){
352
- $.each(props, function(name, prop){
353
- if( !(name in obj) ){
354
- obj[name] = prop;
355
- }
356
- });
357
- },
358
- //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
359
- createPropDefault: createPropDefault,
360
- data: elementData,
361
- moveToFirstEvent: function(elem, eventType, bindType){
362
- var events = ($._data(elem, 'events') || {})[eventType];
363
- var fn;
364
-
365
- if(events && events.length > 1){
366
- fn = events.pop();
367
- if(!bindType){
368
- bindType = 'bind';
369
- }
370
- if(bindType == 'bind' && events.delegateCount){
371
- events.splice( events.delegateCount, 0, fn);
372
- } else {
373
- events.unshift( fn );
374
- }
375
-
376
-
377
- }
378
- elem = null;
379
- },
380
- addShadowDom: (function(){
381
- var resizeTimer;
382
- var lastHeight;
383
- var lastWidth;
384
-
385
- var docObserve = {
386
- init: false,
387
- runs: 0,
388
- test: function(){
389
- var height = docObserve.getHeight();
390
- var width = docObserve.getWidth();
391
-
392
- if(height != docObserve.height || width != docObserve.width){
393
- docObserve.height = height;
394
- docObserve.width = width;
395
- docObserve.handler({type: 'docresize'});
396
- docObserve.runs++;
397
- if(docObserve.runs < 9){
398
- setTimeout(docObserve.test, 90);
399
- }
400
- } else {
401
- docObserve.runs = 0;
402
- }
403
- },
404
- handler: function(e){
405
- clearTimeout(resizeTimer);
406
- resizeTimer = setTimeout(function(){
407
- if(e.type == 'resize'){
408
- var width = $(window).width();
409
- var height = $(window).width();
410
- if(height == lastHeight && width == lastWidth){
411
- return;
412
- }
413
- lastHeight = height;
414
- lastWidth = width;
415
-
416
- docObserve.height = docObserve.getHeight();
417
- docObserve.width = docObserve.getWidth();
418
-
419
- }
420
- $.event.trigger('updateshadowdom');
421
- }, (e.type == 'resize') ? 50 : 9);
422
- },
423
- _create: function(){
424
- $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
425
- var body = document.body;
426
- var doc = document.documentElement;
427
- docObserve[type] = function(){
428
- return Math.max(
429
- body[ "scroll" + name ], doc[ "scroll" + name ],
430
- body[ "offset" + name ], doc[ "offset" + name ],
431
- doc[ "client" + name ]
432
- );
433
- };
434
- });
435
- },
436
- start: function(){
437
- if(!this.init && document.body){
438
- this.init = true;
439
- this._create();
440
- this.height = docObserve.getHeight();
441
- this.width = docObserve.getWidth();
442
- setInterval(this.test, 600);
443
- $(this.test);
444
- webshims.ready('WINDOWLOAD', this.test);
445
- $(window).bind('resize', this.handler);
446
- (function(){
447
- var oldAnimate = $.fn.animate;
448
- var animationTimer;
449
-
450
- $.fn.animate = function(){
451
- clearTimeout(animationTimer);
452
- animationTimer = setTimeout(function(){
453
- docObserve.test();
454
- }, 99);
455
-
456
- return oldAnimate.apply(this, arguments);
457
- };
458
- })();
459
- }
460
- }
461
- };
462
-
463
-
464
- $.event.customEvent.updateshadowdom = true;
465
- webshims.docObserve = function(){
466
- webshims.ready('DOM', function(){
467
- docObserve.start();
468
- });
469
- };
470
- return function(nativeElem, shadowElem, opts){
471
- opts = opts || {};
472
- if(nativeElem.jquery){
473
- nativeElem = nativeElem[0];
474
- }
475
- if(shadowElem.jquery){
476
- shadowElem = shadowElem[0];
477
- }
478
- var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
479
- var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
480
- var shadowFocusElementData = {};
481
- if(!opts.shadowFocusElement){
482
- opts.shadowFocusElement = shadowElem;
483
- } else if(opts.shadowFocusElement){
484
- if(opts.shadowFocusElement.jquery){
485
- opts.shadowFocusElement = opts.shadowFocusElement[0];
486
- }
487
- shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
488
- }
489
-
490
- nativeData.hasShadow = shadowElem;
491
- shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
492
- shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
493
- nativeElement: nativeElem,
494
- shadowElement: shadowElem,
495
- shadowFocusElement: opts.shadowFocusElement
496
- };
497
- if(opts.shadowChilds){
498
- opts.shadowChilds.each(function(){
499
- elementData(this, 'shadowData', shadowData.shadowData);
500
- });
501
- }
502
-
503
- if(opts.data){
504
- shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
505
- }
506
- opts = null;
507
- webshims.docObserve();
508
- };
509
- })(),
510
- propTypes: {
511
- standard: function(descs, name){
512
- createPropDefault(descs);
513
- if(descs.prop){return;}
514
- descs.prop = {
515
- set: function(val){
516
- descs.attr.set.call(this, ''+val);
517
- },
518
- get: function(){
519
- return descs.attr.get.call(this) || descs.defaultValue;
520
- }
521
- };
522
-
523
- },
524
- "boolean": function(descs, name){
525
-
526
- createPropDefault(descs);
527
- if(descs.prop){return;}
528
- descs.prop = {
529
- set: function(val){
530
- if(val){
531
- descs.attr.set.call(this, "");
532
- } else {
533
- descs.removeAttr.value.call(this);
534
- }
535
- },
536
- get: function(){
537
- return descs.attr.get.call(this) != null;
538
- }
539
- };
540
- },
541
- "src": (function(){
542
- var anchor = document.createElement('a');
543
- anchor.style.display = "none";
544
- return function(descs, name){
545
-
546
- createPropDefault(descs);
547
- if(descs.prop){return;}
548
- descs.prop = {
549
- set: function(val){
550
- descs.attr.set.call(this, val);
551
- },
552
- get: function(){
553
- var href = this.getAttribute(name);
554
- var ret;
555
- if(href == null){return '';}
556
-
557
- anchor.setAttribute('href', href+'' );
558
-
559
- if(!$.support.hrefNormalized){
560
- try {
561
- $(anchor).insertAfter(this);
562
- ret = anchor.getAttribute('href', 4);
563
- } catch(er){
564
- ret = anchor.getAttribute('href', 4);
565
- }
566
- $(anchor).detach();
567
- }
568
- return ret || anchor.href;
569
- }
570
- };
571
- };
572
- })(),
573
- enumarated: function(descs, name){
574
-
575
- createPropDefault(descs);
576
- if(descs.prop){return;}
577
- descs.prop = {
578
- set: function(val){
579
- descs.attr.set.call(this, val);
580
- },
581
- get: function(){
582
- var val = (descs.attr.get.call(this) || '').toLowerCase();
583
- if(!val || descs.limitedTo.indexOf(val) == -1){
584
- val = descs.defaultValue;
585
- }
586
- return val;
587
- }
588
- };
589
- }
590
-
591
- // ,unsignedLong: $.noop
592
- // ,"doubble": $.noop
593
- // ,"long": $.noop
594
- // ,tokenlist: $.noop
595
- // ,settableTokenlist: $.noop
596
- },
597
- reflectProperties: function(nodeNames, props){
598
- if(typeof props == 'string'){
599
- props = props.split(listReg);
600
- }
601
- props.forEach(function(prop){
602
- webshims.defineNodeNamesProperty(nodeNames, prop, {
603
- prop: {
604
- set: function(val){
605
- $.attr(this, prop, val);
606
- },
607
- get: function(){
608
- return $.attr(this, prop) || '';
609
- }
610
- }
611
- });
612
- });
613
- },
614
- defineNodeNameProperty: function(nodeName, prop, descs){
615
- havePolyfill[prop] = true;
616
-
617
- if(descs.reflect){
618
- webshims.propTypes[descs.propType || 'standard'](descs, prop);
619
- }
620
-
621
- ['prop', 'attr', 'removeAttr'].forEach(function(type){
622
- var desc = descs[type];
623
- if(desc){
624
- if(type === 'prop'){
625
- desc = $.extend({writeable: true}, desc);
626
- } else {
627
- desc = $.extend({}, desc, {writeable: true});
628
- }
629
-
630
- extendQ[type](nodeName, prop, desc);
631
- if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
632
- extendNativeValue(nodeName, prop, desc);
633
- }
634
- descs[type] = desc;
635
- }
636
- });
637
- if(descs.initAttr){
638
- initProp.content(nodeName, prop);
639
- }
640
- return descs;
641
- },
642
-
643
- defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
644
- var olddesc;
645
- for(var prop in descs){
646
- if(!_noTmpCache && descs[prop].initAttr){
647
- initProp.createTmpCache(name);
648
- }
649
- if(propType){
650
- if(descs[prop][propType]){
651
- //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
652
- } else {
653
- descs[prop][propType] = {};
654
- ['value', 'set', 'get'].forEach(function(copyProp){
655
- if(copyProp in descs[prop]){
656
- descs[prop][propType][copyProp] = descs[prop][copyProp];
657
- delete descs[prop][copyProp];
658
- }
659
- });
660
- }
661
- }
662
- descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
663
- }
664
- if(!_noTmpCache){
665
- initProp.flushTmpCache();
666
- }
667
- return descs;
668
- },
669
-
670
- createElement: function(nodeName, create, descs){
671
- var ret;
672
- if($.isFunction(create)){
673
- create = {
674
- after: create
675
- };
676
- }
677
- initProp.createTmpCache(nodeName);
678
- if(create.before){
679
- initProp.createElement(nodeName, create.before);
680
- }
681
- if(descs){
682
- ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
683
- }
684
- if(create.after){
685
- initProp.createElement(nodeName, create.after);
686
- }
687
- initProp.flushTmpCache();
688
- return ret;
689
- },
690
- onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
691
- if(typeof nodeNames == 'string'){
692
- nodeNames = nodeNames.split(listReg);
693
- }
694
- if($.isFunction(desc)){
695
- desc = {set: desc};
696
- }
697
-
698
- nodeNames.forEach(function(name){
699
- if(!modifyProps[name]){
700
- modifyProps[name] = {};
701
- }
702
- if(typeof props == 'string'){
703
- props = props.split(listReg);
704
- }
705
- if(desc.initAttr){
706
- initProp.createTmpCache(name);
707
- }
708
- props.forEach(function(prop){
709
- if(!modifyProps[name][prop]){
710
- modifyProps[name][prop] = [];
711
- havePolyfill[prop] = true;
712
- }
713
- if(desc.set){
714
- if(only){
715
- desc.set.only = only;
716
- }
717
- modifyProps[name][prop].push(desc.set);
718
- }
719
-
720
- if(desc.initAttr){
721
- initProp.content(name, prop);
722
- }
723
- });
724
- initProp.flushTmpCache();
725
-
726
- });
727
- },
728
- defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
729
- if(!descs){
730
- descs = {};
731
- }
732
- if($.isFunction(descs)){
733
- descs.set = descs;
734
- }
735
- webshims.defineNodeNamesProperty(elementNames, prop, {
736
- attr: {
737
- set: function(val){
738
- this.setAttribute(prop, val);
739
- if(descs.set){
740
- descs.set.call(this, true);
741
- }
742
- },
743
- get: function(){
744
- var ret = this.getAttribute(prop);
745
- return (ret == null) ? undefined : prop;
746
- }
747
- },
748
- removeAttr: {
749
- value: function(){
750
- this.removeAttribute(prop);
751
- if(descs.set){
752
- descs.set.call(this, false);
753
- }
754
- }
755
- },
756
- reflect: true,
757
- propType: 'boolean',
758
- initAttr: descs.initAttr || false
759
- });
760
- },
761
- contentAttr: function(elem, name, val){
762
- if(!elem.nodeName){return;}
763
- var attr;
764
- if(val === undefined){
765
- attr = (elem.attributes[name] || {});
766
- val = attr.specified ? attr.value : null;
767
- return (val == null) ? undefined : val;
768
- }
769
-
770
- if(typeof val == 'boolean'){
771
- if(!val){
772
- elem.removeAttribute(name);
773
- } else {
774
- elem.setAttribute(name, name);
775
- }
776
- } else {
777
- elem.setAttribute(name, val);
778
- }
779
- },
780
-
781
- // set current Lang:
782
- // - webshims.activeLang(lang:string);
783
- // get current lang
784
- // - webshims.activeLang();
785
- // get current lang
786
- // webshims.activeLang({
787
- // register: moduleName:string,
788
- // callback: callback:function
789
- // });
790
- // get/set including removeLang
791
- // - webshims.activeLang({
792
- // module: moduleName:string,
793
- // callback: callback:function,
794
- // langObj: languageObj:array/object
795
- // });
796
- activeLang: (function(){
797
- var callbacks = [];
798
- var registeredCallbacks = {};
799
- var currentLang;
800
- var shortLang;
801
- var notLocal = /:\/\/|^\.*\//;
802
- var loadRemoteLang = function(data, lang, options){
803
- var langSrc;
804
- if(lang && options && $.inArray(lang, options.availabeLangs || []) !== -1){
805
- data.loading = true;
806
- langSrc = options.langSrc;
807
- if(!notLocal.test(langSrc)){
808
- langSrc = webshims.cfg.basePath+langSrc;
809
- }
810
- webshims.loader.loadScript(langSrc+lang+'.js', function(){
811
- if(data.langObj[lang]){
812
- data.loading = false;
813
- callLang(data, true);
814
- } else {
815
- $(function(){
816
- if(data.langObj[lang]){
817
- callLang(data, true);
818
- }
819
- data.loading = false;
820
- });
821
- }
822
- });
823
- return true;
824
- }
825
- return false;
826
- };
827
- var callRegister = function(module){
828
- if(registeredCallbacks[module]){
829
- registeredCallbacks[module].forEach(function(data){
830
- data.callback();
831
- });
832
- }
833
- };
834
- var callLang = function(data, _noLoop){
835
- if(data.activeLang != currentLang && data.activeLang !== shortLang){
836
- var options = modules[data.module].options;
837
- if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
838
- data.activeLang = currentLang;
839
- data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
840
- callRegister(data.module);
841
- } else if( !_noLoop &&
842
- !loadRemoteLang(data, currentLang, options) &&
843
- !loadRemoteLang(data, shortLang, options) &&
844
- data.langObj[''] && data.activeLang !== '' ) {
845
- data.activeLang = '';
846
- data.callback(data.langObj[''], currentLang);
847
- callRegister(data.module);
848
- }
849
- }
850
- };
851
-
852
-
853
- var activeLang = function(lang){
854
-
855
- if(typeof lang == 'string' && lang !== currentLang){
856
- currentLang = lang;
857
- shortLang = currentLang.split('-')[0];
858
- if(currentLang == shortLang){
859
- shortLang = false;
860
- }
861
- $.each(callbacks, function(i, data){
862
- callLang(data);
863
- });
864
- } else if(typeof lang == 'object'){
865
-
866
- if(lang.register){
867
- if(!registeredCallbacks[lang.register]){
868
- registeredCallbacks[lang.register] = [];
869
- }
870
- registeredCallbacks[lang.register].push(lang);
871
- lang.callback();
872
- } else {
873
- if(!lang.activeLang){
874
- lang.activeLang = '';
875
- }
876
- callbacks.push(lang);
877
- callLang(lang);
878
- }
879
- }
880
- return currentLang;
881
- };
882
-
883
- return activeLang;
884
- })()
885
- });
886
-
887
- $.each({
888
- defineNodeNamesProperty: 'defineNodeNameProperty',
889
- defineNodeNamesProperties: 'defineNodeNameProperties',
890
- createElements: 'createElement'
891
- }, function(name, baseMethod){
892
- webshims[name] = function(names, a, b, c){
893
- if(typeof names == 'string'){
894
- names = names.split(listReg);
895
- }
896
- var retDesc = {};
897
- names.forEach(function(nodeName){
898
- retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
899
- });
900
- return retDesc;
901
- };
902
- });
903
-
904
- webshims.isReady('webshimLocalization', true);
905
- });
906
- //html5a11y
907
- (function($, document){
908
- var browserVersion = $.webshims.browserVersion;
909
- if($.browser.mozilla && browserVersion > 5){return;}
910
- if (!$.browser.msie || (browserVersion < 12 && browserVersion > 7)) {
911
- var elemMappings = {
912
- article: "article",
913
- aside: "complementary",
914
- section: "region",
915
- nav: "navigation",
916
- address: "contentinfo"
917
- };
918
- var addRole = function(elem, role){
919
- var hasRole = elem.getAttribute('role');
920
- if (!hasRole) {
921
- elem.setAttribute('role', role);
922
- }
923
- };
924
-
925
- $.webshims.addReady(function(context, contextElem){
926
- $.each(elemMappings, function(name, role){
927
- var elems = $(name, context).add(contextElem.filter(name));
928
- for (var i = 0, len = elems.length; i < len; i++) {
929
- addRole(elems[i], role);
930
- }
931
- });
932
- if (context === document) {
933
- var header = document.getElementsByTagName('header')[0];
934
- var footers = document.getElementsByTagName('footer');
935
- var footerLen = footers.length;
936
- if (header && !$(header).closest('section, article')[0]) {
937
- addRole(header, 'banner');
938
- }
939
- if (!footerLen) {
940
- return;
941
- }
942
- var footer = footers[footerLen - 1];
943
- if (!$(footer).closest('section, article')[0]) {
944
- addRole(footer, 'contentinfo');
945
- }
946
- }
947
- });
948
- }
949
- })(jQuery, document);
950
-
951
- //additional tests for partial implementation of forms features
952
- (function($){
953
- "use strict";
954
- var Modernizr = window.Modernizr;
955
- var webshims = $.webshims;
956
- var bugs = webshims.bugs;
957
- var form = $('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /><input required="" name="a" /></form>');
958
- var testRequiredFind = function(){
959
- if(form[0].querySelector){
960
- try {
961
- bugs.findRequired = !(form[0].querySelector('select:required'));
962
- } catch(er){
963
- bugs.findRequired = false;
964
- }
965
- }
966
- };
967
- var inputElem = $('input', form).eq(0);
968
- var onDomextend = function(fn){
969
- webshims.loader.loadList(['dom-extend']);
970
- webshims.ready('dom-extend', fn);
971
- };
972
-
973
- bugs.findRequired = false;
974
- bugs.validationMessage = false;
975
-
976
- webshims.capturingEventPrevented = function(e){
977
- if(!e._isPolyfilled){
978
- var isDefaultPrevented = e.isDefaultPrevented;
979
- var preventDefault = e.preventDefault;
980
- e.preventDefault = function(){
981
- clearTimeout($.data(e.target, e.type + 'DefaultPrevented'));
982
- $.data(e.target, e.type + 'DefaultPrevented', setTimeout(function(){
983
- $.removeData(e.target, e.type + 'DefaultPrevented');
984
- }, 30));
985
- return preventDefault.apply(this, arguments);
986
- };
987
- e.isDefaultPrevented = function(){
988
- return !!(isDefaultPrevented.apply(this, arguments) || $.data(e.target, e.type + 'DefaultPrevented') || false);
989
- };
990
- e._isPolyfilled = true;
991
- }
992
- };
993
-
994
- if(!Modernizr.formvalidation || bugs.bustedValidity){
995
- testRequiredFind();
996
- return;
997
- }
998
-
999
- //create delegatable events
1000
- webshims.capturingEvents(['input']);
1001
- webshims.capturingEvents(['invalid'], true);
1002
-
1003
- if(window.opera || window.testGoodWithFix){
1004
-
1005
- form.appendTo('head');
1006
-
1007
- testRequiredFind();
1008
- bugs.validationMessage = !(inputElem.prop('validationMessage'));
1009
-
1010
- webshims.reTest(['form-native-extend', 'form-message']);
1011
-
1012
- form.remove();
1013
-
1014
- $(function(){
1015
- onDomextend(function(){
1016
-
1017
- //Opera shows native validation bubbles in case of input.checkValidity()
1018
- // Opera 11.6/12 hasn't fixed this issue right, it's buggy
1019
- var preventDefault = function(e){
1020
- e.preventDefault();
1021
- };
1022
-
1023
- ['form', 'input', 'textarea', 'select'].forEach(function(name){
1024
- var desc = webshims.defineNodeNameProperty(name, 'checkValidity', {
1025
- prop: {
1026
- value: function(){
1027
- if (!webshims.fromSubmit) {
1028
- $(this).on('invalid.checkvalidity', preventDefault);
1029
- }
1030
-
1031
- webshims.fromCheckValidity = true;
1032
- var ret = desc.prop._supvalue.apply(this, arguments);
1033
- if (!webshims.fromSubmit) {
1034
- $(this).unbind('invalid.checkvalidity', preventDefault);
1035
- }
1036
- webshims.fromCheckValidity = false;
1037
- return ret;
1038
- }
1039
- }
1040
- });
1041
- });
1042
-
1043
- });
1044
- });
1045
- }
1046
-
1047
- if($.browser.webkit && !webshims.bugs.bustedValidity){
1048
- (function(){
1049
- var elems = /^(?:textarea|input)$/i;
1050
- var form = false;
1051
-
1052
- document.addEventListener('contextmenu', function(e){
1053
- if(elems.test( e.target.nodeName || '') && (form = e.target.form)){
1054
- setTimeout(function(){
1055
- form = false;
1056
- }, 1);
1057
- }
1058
- }, false);
1059
-
1060
- $(window).on('invalid', function(e){
1061
- if(e.originalEvent && form && form == e.target.form){
1062
- e.wrongWebkitInvalid = true;
1063
- e.stopImmediatePropagation();
1064
- }
1065
- });
1066
- })();
1067
- }
1068
- })(jQuery);
1069
-
1070
- jQuery.webshims.register('form-core', function($, webshims, window, document, undefined, options){
1071
- "use strict";
1072
-
1073
- var groupTypes = {radio: 1};
1074
- var checkTypes = {checkbox: 1, radio: 1};
1075
- var emptyJ = $([]);
1076
- var bugs = webshims.bugs;
1077
- var getGroupElements = function(elem){
1078
- elem = $(elem);
1079
- var name;
1080
- var form;
1081
- var ret = emptyJ;
1082
- if(groupTypes[elem[0].type]){
1083
- form = elem.prop('form');
1084
- name = elem[0].name;
1085
- if(!name){
1086
- ret = elem;
1087
- } else if(form){
1088
- ret = $(form[name]);
1089
- } else {
1090
- ret = $(document.getElementsByName(name)).filter(function(){
1091
- return !$.prop(this, 'form');
1092
- });
1093
- }
1094
- ret = ret.filter('[type="radio"]');
1095
- }
1096
- return ret;
1097
- };
1098
-
1099
- var getContentValidationMessage = webshims.getContentValidationMessage = function(elem, validity, key){
1100
- var message = $(elem).data('errormessage') || elem.getAttribute('x-moz-errormessage') || '';
1101
- if(key && message[key]){
1102
- message = message[key];
1103
- }
1104
- if(typeof message == 'object'){
1105
- validity = validity || $.prop(elem, 'validity') || {valid: 1};
1106
- if(!validity.valid){
1107
- $.each(validity, function(name, prop){
1108
- if(prop && name != 'valid' && message[name]){
1109
- message = message[name];
1110
- return false;
1111
- }
1112
- });
1113
- }
1114
- }
1115
-
1116
- if(typeof message == 'object'){
1117
- message = message.defaultMessage;
1118
- }
1119
- return message || '';
1120
- };
1121
-
1122
- /*
1123
- * Selectors for all browsers
1124
- */
1125
- var rangeTypes = {number: 1, range: 1, date: 1/*, time: 1, 'datetime-local': 1, datetime: 1, month: 1, week: 1*/};
1126
- var hasInvalid = function(elem){
1127
- var ret = false;
1128
- $($.prop(elem, 'elements')).each(function(){
1129
- ret = $(this).is(':invalid');
1130
- if(ret){
1131
- return false;
1132
- }
1133
- });
1134
- return ret;
1135
- };
1136
- $.extend($.expr[":"], {
1137
- "valid-element": function(elem){
1138
- return $.nodeName(elem, 'form') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
1139
- },
1140
- "invalid-element": function(elem){
1141
- return $.nodeName(elem, 'form') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
1142
- },
1143
- "required-element": function(elem){
1144
- return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
1145
- },
1146
- "user-error": function(elem){
1147
- return ($.prop(elem, 'willValidate') && $(elem).hasClass('user-error'));
1148
- },
1149
- "optional-element": function(elem){
1150
- return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
1151
- },
1152
- "in-range": function(elem){
1153
- if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1154
- return false;
1155
- }
1156
- var val = $.prop(elem, 'validity');
1157
- return !!(val && !val.rangeOverflow && !val.rangeUnderflow);
1158
- },
1159
- "out-of-range": function(elem){
1160
- if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1161
- return false;
1162
- }
1163
- var val = $.prop(elem, 'validity');
1164
- return !!(val && (val.rangeOverflow || val.rangeUnderflow));
1165
- }
1166
-
1167
- });
1168
-
1169
- ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
1170
- $.expr[":"][name] = $.expr.filters[name+"-element"];
1171
- });
1172
-
1173
-
1174
- $.expr[":"].focus = function( elem ) {
1175
- try {
1176
- var doc = elem.ownerDocument;
1177
- return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus());
1178
- } catch(e){}
1179
- return false;
1180
- };
1181
-
1182
- var customEvents = $.event.customEvent || {};
1183
- var isValid = function(elem){
1184
- return ($.prop(elem, 'validity') || {valid: 1}).valid;
1185
- };
1186
-
1187
- if (bugs.bustedValidity || bugs.findRequired) {
1188
- (function(){
1189
- var find = $.find;
1190
- var matchesSelector = $.find.matchesSelector;
1191
-
1192
- var regExp = /(\:valid|\:invalid|\:optional|\:required|\:in-range|\:out-of-range)(?=[\s\[\~\.\+\>\:\#*]|$)/ig;
1193
- var regFn = function(sel){
1194
- return sel + '-element';
1195
- };
1196
-
1197
- $.find = (function(){
1198
- var slice = Array.prototype.slice;
1199
- var fn = function(sel){
1200
- var ar = arguments;
1201
- ar = slice.call(ar, 1, ar.length);
1202
- ar.unshift(sel.replace(regExp, regFn));
1203
- return find.apply(this, ar);
1204
- };
1205
- for (var i in find) {
1206
- if(find.hasOwnProperty(i)){
1207
- fn[i] = find[i];
1208
- }
1209
- }
1210
- return fn;
1211
- })();
1212
- if(!Modernizr.prefixed || Modernizr.prefixed("matchesSelector", document.documentElement)){
1213
- $.find.matchesSelector = function(node, expr){
1214
- expr = expr.replace(regExp, regFn);
1215
- return matchesSelector.call(this, node, expr);
1216
- };
1217
- }
1218
-
1219
- })();
1220
- }
1221
-
1222
- //ToDo needs testing
1223
- var oldAttr = $.prop;
1224
- var changeVals = {selectedIndex: 1, value: 1, checked: 1, disabled: 1, readonly: 1};
1225
- $.prop = function(elem, name, val){
1226
- var ret = oldAttr.apply(this, arguments);
1227
- if(elem && 'form' in elem && changeVals[name] && val !== undefined && $(elem).hasClass(invalidClass)){
1228
- if(isValid(elem)){
1229
- $(elem).getShadowElement().removeClass(invalidClasses);
1230
- if(name == 'checked' && val) {
1231
- getGroupElements(elem).not(elem).removeClass(invalidClasses).removeAttr('aria-invalid');
1232
- }
1233
- }
1234
- }
1235
- return ret;
1236
- };
1237
-
1238
- var returnValidityCause = function(validity, elem){
1239
- var ret;
1240
- $.each(validity, function(name, value){
1241
- if(value){
1242
- ret = (name == 'customError') ? $.prop(elem, 'validationMessage') : name;
1243
- return false;
1244
- }
1245
- });
1246
- return ret;
1247
- };
1248
-
1249
- var isInGroup = function(name){
1250
- var ret;
1251
- try {
1252
- ret = document.activeElement.name === name;
1253
- } catch(e){}
1254
- return ret;
1255
- };
1256
- /* form-ui-invalid/form-ui-valid are deprecated. use user-error/user-succes instead */
1257
- var invalidClass = 'user-error';
1258
- var invalidClasses = 'user-error form-ui-invalid';
1259
- var validClass = 'user-success';
1260
- var validClasses = 'user-success form-ui-valid';
1261
- var switchValidityClass = function(e){
1262
- var elem, timer;
1263
- if(!e.target){return;}
1264
- elem = $(e.target).getNativeElement()[0];
1265
- if(elem.type == 'submit' || !$.prop(elem, 'willValidate')){return;}
1266
- timer = $.data(elem, 'webshimsswitchvalidityclass');
1267
- var switchClass = function(){
1268
- if(e.type == 'focusout' && elem.type == 'radio' && isInGroup(elem.name)){return;}
1269
- var validity = $.prop(elem, 'validity');
1270
- var shadowElem = $(elem).getShadowElement();
1271
- var addClass, removeClass, trigger, generaltrigger, validityCause;
1272
-
1273
- $(elem).trigger('refreshCustomValidityRules');
1274
- if(validity.valid){
1275
- if(!shadowElem.hasClass(validClass)){
1276
- addClass = validClasses;
1277
- removeClass = invalidClasses;
1278
- generaltrigger = 'changedvaliditystate';
1279
- trigger = 'changedvalid';
1280
- if(checkTypes[elem.type] && elem.checked){
1281
- getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass).removeAttr('aria-invalid');
1282
- }
1283
- $.removeData(elem, 'webshimsinvalidcause');
1284
- }
1285
- } else {
1286
- validityCause = returnValidityCause(validity, elem);
1287
- if($.data(elem, 'webshimsinvalidcause') != validityCause){
1288
- $.data(elem, 'webshimsinvalidcause', validityCause);
1289
- generaltrigger = 'changedvaliditystate';
1290
- }
1291
- if(!shadowElem.hasClass(invalidClass)){
1292
- addClass = invalidClasses;
1293
- removeClass = validClasses;
1294
- if (checkTypes[elem.type] && !elem.checked) {
1295
- getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass);
1296
- }
1297
- trigger = 'changedinvalid';
1298
- }
1299
- }
1300
- if(addClass){
1301
- shadowElem.addClass(addClass).removeClass(removeClass);
1302
- //jQuery 1.6.1 IE9 bug (doubble trigger bug)
1303
- setTimeout(function(){
1304
- $(elem).trigger(trigger);
1305
- }, 0);
1306
- }
1307
- if(generaltrigger){
1308
- setTimeout(function(){
1309
- $(elem).trigger(generaltrigger);
1310
- }, 0);
1311
- }
1312
- $.removeData(e.target, 'webshimsswitchvalidityclass');
1313
- };
1314
-
1315
- if(timer){
1316
- clearTimeout(timer);
1317
- }
1318
- if(e.type == 'refreshvalidityui'){
1319
- switchClass();
1320
- } else {
1321
- $.data(elem, 'webshimsswitchvalidityclass', setTimeout(switchClass, 9));
1322
- }
1323
- };
1324
-
1325
- $(document).on(options.validityUIEvents || 'focusout change refreshvalidityui', switchValidityClass);
1326
- customEvents.changedvaliditystate = true;
1327
- customEvents.refreshCustomValidityRules = true;
1328
- customEvents.changedvalid = true;
1329
- customEvents.changedinvalid = true;
1330
- customEvents.refreshvalidityui = true;
1331
-
1332
-
1333
- webshims.triggerInlineForm = function(elem, event){
1334
- $(elem).trigger(event);
1335
- };
1336
-
1337
- webshims.modules["form-core"].getGroupElements = getGroupElements;
1338
-
1339
-
1340
- var setRoot = function(){
1341
- webshims.scrollRoot = ($.browser.webkit || document.compatMode == 'BackCompat') ?
1342
- $(document.body) :
1343
- $(document.documentElement)
1344
- ;
1345
- };
1346
- setRoot();
1347
- webshims.ready('DOM', setRoot);
1348
-
1349
- webshims.getRelOffset = function(posElem, relElem){
1350
- posElem = $(posElem);
1351
- var offset = $(relElem).offset();
1352
- var bodyOffset;
1353
- $.swap($(posElem)[0], {visibility: 'hidden', display: 'inline-block', left: 0, top: 0}, function(){
1354
- bodyOffset = posElem.offset();
1355
- });
1356
- offset.top -= bodyOffset.top;
1357
- offset.left -= bodyOffset.left;
1358
- return offset;
1359
- };
1360
-
1361
- /* some extra validation UI */
1362
- webshims.validityAlert = (function(){
1363
- var alertElem = (!$.browser.msie || parseInt($.browser.version, 10) > 7) ? 'span' : 'label';
1364
- var errorBubble;
1365
- var hideTimer = false;
1366
- var focusTimer = false;
1367
- var resizeTimer = false;
1368
- var boundHide;
1369
-
1370
- var api = {
1371
- hideDelay: 5000,
1372
-
1373
- showFor: function(elem, message, noFocusElem, noBubble){
1374
- api._create();
1375
- elem = $(elem);
1376
- var visual = $(elem).getShadowElement();
1377
- var offset = api.getOffsetFromBody(visual);
1378
- api.clear();
1379
- if(noBubble){
1380
- this.hide();
1381
- } else {
1382
- this.getMessage(elem, message);
1383
- this.position(visual, offset);
1384
-
1385
- this.show();
1386
- if(this.hideDelay){
1387
- hideTimer = setTimeout(boundHide, this.hideDelay);
1388
- }
1389
- $(window)
1390
- .on('resize.validityalert', function(){
1391
- clearTimeout(resizeTimer);
1392
- resizeTimer = setTimeout(function(){
1393
- api.position(visual);
1394
- }, 9);
1395
- })
1396
- ;
1397
- }
1398
-
1399
- if(!noFocusElem){
1400
- this.setFocus(visual, offset);
1401
- }
1402
- },
1403
- getOffsetFromBody: function(elem){
1404
- return webshims.getRelOffset(errorBubble, elem);
1405
- },
1406
- setFocus: function(visual, offset){
1407
- var focusElem = $(visual).getShadowFocusElement();
1408
- var scrollTop = webshims.scrollRoot.scrollTop();
1409
- var elemTop = ((offset || focusElem.offset()).top) - 30;
1410
- var smooth;
1411
-
1412
- if(webshims.getID && alertElem == 'label'){
1413
- errorBubble.attr('for', webshims.getID(focusElem));
1414
- }
1415
-
1416
- if(scrollTop > elemTop){
1417
- webshims.scrollRoot.animate(
1418
- {scrollTop: elemTop - 5},
1419
- {
1420
- queue: false,
1421
- duration: Math.max( Math.min( 600, (scrollTop - elemTop) * 1.5 ), 80 )
1422
- }
1423
- );
1424
- smooth = true;
1425
- }
1426
- try {
1427
- focusElem[0].focus();
1428
- } catch(e){}
1429
- if(smooth){
1430
- webshims.scrollRoot.scrollTop(scrollTop);
1431
- setTimeout(function(){
1432
- webshims.scrollRoot.scrollTop(scrollTop);
1433
- }, 0);
1434
- }
1435
- setTimeout(function(){
1436
- $(document).on('focusout.validityalert', boundHide);
1437
- }, 10);
1438
- },
1439
- getMessage: function(elem, message){
1440
- if (!message) {
1441
- message = getContentValidationMessage(elem[0]) || elem.prop('validationMessage');
1442
- }
1443
- if (message) {
1444
- $('span.va-box', errorBubble).text(message);
1445
- }
1446
- else {
1447
- this.hide();
1448
- }
1449
- },
1450
- position: function(elem, offset){
1451
- offset = offset ? $.extend({}, offset) : api.getOffsetFromBody(elem);
1452
- offset.top += elem.outerHeight();
1453
- errorBubble.css(offset);
1454
- },
1455
- show: function(){
1456
- if(errorBubble.css('display') === 'none'){
1457
- errorBubble.css({opacity: 0}).show();
1458
- }
1459
- errorBubble.addClass('va-visible').fadeTo(400, 1);
1460
- },
1461
- hide: function(){
1462
- errorBubble.removeClass('va-visible').fadeOut();
1463
- },
1464
- clear: function(){
1465
- clearTimeout(focusTimer);
1466
- clearTimeout(hideTimer);
1467
- $(document).unbind('.validityalert');
1468
- $(window).unbind('.validityalert');
1469
- errorBubble.stop().removeAttr('for');
1470
- },
1471
- _create: function(){
1472
- if(errorBubble){return;}
1473
- errorBubble = api.errorBubble = $('<'+alertElem+' class="validity-alert-wrapper" role="alert"><span class="validity-alert"><span class="va-arrow"><span class="va-arrow-box"></span></span><span class="va-box"></span></span></'+alertElem+'>').css({position: 'absolute', display: 'none'});
1474
- webshims.ready('DOM', function(){
1475
- errorBubble.appendTo('body');
1476
- if($.fn.bgIframe && $.browser.msie && parseInt($.browser.version, 10) < 7){
1477
- errorBubble.bgIframe();
1478
- }
1479
- });
1480
- }
1481
- };
1482
-
1483
-
1484
- boundHide = $.proxy(api, 'hide');
1485
-
1486
- return api;
1487
- })();
1488
-
1489
-
1490
- /* extension, but also used to fix native implementation workaround/bugfixes */
1491
- (function(){
1492
- var firstEvent,
1493
- invalids = [],
1494
- stopSubmitTimer,
1495
- form
1496
- ;
1497
-
1498
- $(document).on('invalid', function(e){
1499
- if(e.wrongWebkitInvalid){return;}
1500
- var jElm = $(e.target);
1501
- var shadowElem = jElm.getShadowElement();
1502
- if(!shadowElem.hasClass(invalidClass)){
1503
- shadowElem.addClass(invalidClasses).removeClass(validClasses);
1504
- setTimeout(function(){
1505
- $(e.target).trigger('changedinvalid').trigger('changedvaliditystate');
1506
- }, 0);
1507
- }
1508
-
1509
- if(!firstEvent){
1510
- //trigger firstinvalid
1511
- firstEvent = $.Event('firstinvalid');
1512
- firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
1513
- var firstSystemInvalid = $.Event('firstinvalidsystem');
1514
- $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
1515
- jElm.trigger(firstEvent);
1516
- }
1517
-
1518
- //if firstinvalid was prevented all invalids will be also prevented
1519
- if( firstEvent && firstEvent.isDefaultPrevented() ){
1520
- e.preventDefault();
1521
- }
1522
- invalids.push(e.target);
1523
- e.extraData = 'fix';
1524
- clearTimeout(stopSubmitTimer);
1525
- stopSubmitTimer = setTimeout(function(){
1526
- var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
1527
- //reset firstinvalid
1528
- firstEvent = false;
1529
- invalids = [];
1530
- $(e.target).trigger(lastEvent, lastEvent);
1531
- }, 9);
1532
- jElm = null;
1533
- shadowElem = null;
1534
- });
1535
- })();
1536
-
1537
- $.fn.getErrorMessage = function(){
1538
- var message = '';
1539
- var elem = this[0];
1540
- if(elem){
1541
- message = getContentValidationMessage(elem) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
1542
- }
1543
- return message;
1544
- };
1545
-
1546
- if(options.replaceValidationUI){
1547
- webshims.ready('DOM forms', function(){
1548
- $(document).on('firstinvalid', function(e){
1549
- if(!e.isInvalidUIPrevented()){
1550
- e.preventDefault();
1551
- $.webshims.validityAlert.showFor( e.target, $(e.target).prop('customValidationMessage') );
1552
- }
1553
- });
1554
- });
1555
- }
1556
-
1557
- });
1558
- jQuery.webshims.register('form-datalist', function($, webshims, window, document, undefined){
1559
- "use strict";
1560
- var doc = document;
1561
-
1562
- /*
1563
- * implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
1564
- */
1565
- webshims.propTypes.element = function(descs){
1566
- webshims.createPropDefault(descs, 'attr');
1567
- if(descs.prop){return;}
1568
- descs.prop = {
1569
- get: function(){
1570
- var elem = descs.attr.get.call(this);
1571
- if(elem){
1572
- elem = document.getElementById(elem);
1573
- if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
1574
- elem = null;
1575
- }
1576
- }
1577
- return elem || null;
1578
- },
1579
- writeable: false
1580
- };
1581
- };
1582
-
1583
-
1584
- /*
1585
- * Implements datalist element and list attribute
1586
- */
1587
-
1588
- (function(){
1589
- var formsCFG = $.webshims.cfg.forms;
1590
- var listSupport = Modernizr.input.list;
1591
- if(listSupport && !formsCFG.customDatalist){return;}
1592
-
1593
- var initializeDatalist = function(){
1594
-
1595
-
1596
- if(!listSupport){
1597
- webshims.defineNodeNameProperty('datalist', 'options', {
1598
- prop: {
1599
- writeable: false,
1600
- get: function(){
1601
- var elem = this;
1602
- var select = $('select', elem);
1603
- var options;
1604
- if(select[0]){
1605
- options = select[0].options;
1606
- } else {
1607
- options = $('option', elem).get();
1608
- if(options.length){
1609
- webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
1610
- }
1611
- }
1612
- return options;
1613
- }
1614
- }
1615
- });
1616
- }
1617
-
1618
- var inputListProto = {
1619
- //override autocomplete
1620
- autocomplete: {
1621
- attr: {
1622
- get: function(){
1623
- var elem = this;
1624
- var data = $.data(elem, 'datalistWidget');
1625
- if(data){
1626
- return data._autocomplete;
1627
- }
1628
- return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
1629
- },
1630
- set: function(value){
1631
- var elem = this;
1632
- var data = $.data(elem, 'datalistWidget');
1633
- if(data){
1634
- data._autocomplete = value;
1635
- if(value == 'off'){
1636
- data.hideList();
1637
- }
1638
- } else {
1639
- if('autocomplete' in elem){
1640
- elem.autocomplete = value;
1641
- } else {
1642
- elem.setAttribute('autocomplete', value);
1643
- }
1644
- }
1645
- }
1646
- }
1647
- }
1648
- };
1649
-
1650
- // if(formsCFG.customDatalist && (!listSupport || !('selectedOption') in $('<input />')[0])){
1651
- // //currently not supported x-browser (FF4 has not implemented and is not polyfilled )
1652
- // inputListProto.selectedOption = {
1653
- // prop: {
1654
- // writeable: false,
1655
- // get: function(){
1656
- // var elem = this;
1657
- // var list = $.prop(elem, 'list');
1658
- // var ret = null;
1659
- // var value, options;
1660
- // if(!list){return ret;}
1661
- // value = $.prop(elem, 'value');
1662
- // if(!value){return ret;}
1663
- // options = $.prop(list, 'options');
1664
- // if(!options.length){return ret;}
1665
- // $.each(options, function(i, option){
1666
- // if(value == $.prop(option, 'value')){
1667
- // ret = option;
1668
- // return false;
1669
- // }
1670
- // });
1671
- // return ret;
1672
- // }
1673
- // }
1674
- // };
1675
- // }
1676
-
1677
- if(!listSupport){
1678
- inputListProto['list'] = {
1679
- attr: {
1680
- get: function(){
1681
- var val = webshims.contentAttr(this, 'list');
1682
- return (val == null) ? undefined : val;
1683
- },
1684
- set: function(value){
1685
- var elem = this;
1686
- webshims.contentAttr(elem, 'list', value);
1687
- webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1688
- }
1689
- },
1690
- initAttr: true,
1691
- reflect: true,
1692
- propType: 'element',
1693
- propNodeName: 'datalist'
1694
- };
1695
- } else {
1696
- //options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
1697
- if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
1698
- webshims.defineNodeNameProperty('datalist', 'options', {
1699
- prop: {
1700
- writeable: false,
1701
- get: function(){
1702
- var options = this.options || [];
1703
- if(!options.length){
1704
- var elem = this;
1705
- var select = $('select', elem);
1706
- if(select[0] && select[0].options && select[0].options.length){
1707
- options = select[0].options;
1708
- }
1709
- }
1710
- return options;
1711
- }
1712
- }
1713
- });
1714
- }
1715
- inputListProto['list'] = {
1716
- attr: {
1717
- get: function(){
1718
- var val = webshims.contentAttr(this, 'list');
1719
- if(val != null){
1720
- this.removeAttribute('list');
1721
- } else {
1722
- val = $.data(this, 'datalistListAttr');
1723
- }
1724
-
1725
- return (val == null) ? undefined : val;
1726
- },
1727
- set: function(value){
1728
- var elem = this;
1729
- $.data(elem, 'datalistListAttr', value);
1730
- webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1731
- }
1732
- },
1733
- initAttr: true,
1734
- reflect: true,
1735
- propType: 'element',
1736
- propNodeName: 'datalist'
1737
- };
1738
- }
1739
-
1740
-
1741
- webshims.defineNodeNameProperties('input', inputListProto);
1742
-
1743
- if($.event.customEvent){
1744
- $.event.customEvent.updateDatalist = true;
1745
- $.event.customEvent.updateInput = true;
1746
- $.event.customEvent.datalistselect = true;
1747
- }
1748
- webshims.addReady(function(context, contextElem){
1749
- contextElem
1750
- .filter('datalist > select, datalist, datalist > option, datalist > select > option')
1751
- .closest('datalist')
1752
- .triggerHandler('updateDatalist')
1753
- ;
1754
-
1755
- });
1756
-
1757
-
1758
- };
1759
-
1760
-
1761
- /*
1762
- * ShadowList
1763
- */
1764
- var listidIndex = 0;
1765
-
1766
- var noDatalistSupport = {
1767
- submit: 1,
1768
- button: 1,
1769
- reset: 1,
1770
- hidden: 1,
1771
-
1772
- //ToDo
1773
- range: 1,
1774
- date: 1
1775
- };
1776
- var lteie6 = ($.browser.msie && parseInt($.browser.version, 10) < 7);
1777
- var globStoredOptions = {};
1778
- var getStoredOptions = function(name){
1779
- if(!name){return [];}
1780
- if(globStoredOptions[name]){
1781
- return globStoredOptions[name];
1782
- }
1783
- var data;
1784
- try {
1785
- data = JSON.parse(localStorage.getItem('storedDatalistOptions'+name));
1786
- } catch(e){}
1787
- globStoredOptions[name] = data || [];
1788
- return data || [];
1789
- };
1790
- var storeOptions = function(name, val){
1791
- if(!name){return;}
1792
- val = val || [];
1793
- try {
1794
- localStorage.setItem( 'storedDatalistOptions'+name, JSON.stringify(val) );
1795
- } catch(e){}
1796
- };
1797
-
1798
- var getText = function(elem){
1799
- return (elem.textContent || elem.innerText || $.text([ elem ]) || '');
1800
- };
1801
-
1802
- var shadowListProto = {
1803
- _create: function(opts){
1804
-
1805
- if(noDatalistSupport[$.prop(opts.input, 'type')]){return;}
1806
- var datalist = opts.datalist;
1807
- var data = $.data(opts.input, 'datalistWidget');
1808
- if(datalist && data && data.datalist !== datalist){
1809
- data.datalist = datalist;
1810
- data.id = opts.id;
1811
-
1812
- data.shadowList.prop('className', 'datalist-polyfill '+ (data.datalist.className || '') + ' '+ data.datalist.id +'-shadowdom');
1813
- if(formsCFG.positionDatalist){
1814
- data.shadowList.insertAfter(opts.input);
1815
- } else {
1816
- data.shadowList.appendTo('body');
1817
- }
1818
- $(data.datalist)
1819
- .off('updateDatalist.datalistWidget')
1820
- .on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
1821
- ;
1822
- data._resetListCached();
1823
- return;
1824
- } else if(!datalist){
1825
- if(data){
1826
- data.destroy();
1827
- }
1828
- return;
1829
- } else if(data && data.datalist === datalist){
1830
- return;
1831
- }
1832
- listidIndex++;
1833
- var that = this;
1834
- this.hideList = $.proxy(that, 'hideList');
1835
- this.timedHide = function(){
1836
- clearTimeout(that.hideTimer);
1837
- that.hideTimer = setTimeout(that.hideList, 9);
1838
- };
1839
- this.datalist = datalist;
1840
- this.id = opts.id;
1841
- this.hasViewableData = true;
1842
- this._autocomplete = $.attr(opts.input, 'autocomplete');
1843
- $.data(opts.input, 'datalistWidget', this);
1844
- this.shadowList = $('<div class="datalist-polyfill '+ (this.datalist.className || '') + ' '+ this.datalist.id +'-shadowdom' +'" />');
1845
-
1846
- if(formsCFG.positionDatalist || $(opts.input).hasClass('position-datalist')){
1847
- this.shadowList.insertAfter(opts.input);
1848
- } else {
1849
- this.shadowList.appendTo('body');
1850
- }
1851
-
1852
- this.index = -1;
1853
- this.input = opts.input;
1854
- this.arrayOptions = [];
1855
-
1856
- this.shadowList
1857
- .delegate('li', 'mouseenter.datalistWidget mousedown.datalistWidget click.datalistWidget', function(e){
1858
- var items = $('li:not(.hidden-item)', that.shadowList);
1859
- var select = (e.type == 'mousedown' || e.type == 'click');
1860
- that.markItem(items.index(e.currentTarget), select, items);
1861
- if(e.type == 'click'){
1862
- that.hideList();
1863
- if(formsCFG.customDatalist){
1864
- $(opts.input).trigger('datalistselect');
1865
- }
1866
- }
1867
- return (e.type != 'mousedown');
1868
- })
1869
- .on('focusout', this.timedHide)
1870
- ;
1871
-
1872
- opts.input.setAttribute('autocomplete', 'off');
1873
-
1874
- $(opts.input)
1875
- .attr({
1876
- //role: 'combobox',
1877
- 'aria-haspopup': 'true'
1878
- })
1879
- .on({
1880
- 'input.datalistWidget': function(){
1881
- if(!that.triggeredByDatalist){
1882
- that.changedValue = false;
1883
- that.showHideOptions();
1884
- }
1885
- },
1886
- 'keydown.datalistWidget': function(e){
1887
- var keyCode = e.keyCode;
1888
- var activeItem;
1889
- var items;
1890
- if(keyCode == 40 && !that.showList()){
1891
- that.markItem(that.index + 1, true);
1892
- return false;
1893
- }
1894
-
1895
- if(!that.isListVisible){return;}
1896
-
1897
-
1898
- if(keyCode == 38){
1899
- that.markItem(that.index - 1, true);
1900
- return false;
1901
- }
1902
- if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
1903
- that.markItem(0, true);
1904
- return false;
1905
- }
1906
- if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
1907
- items = $('li:not(.hidden-item)', that.shadowList);
1908
- that.markItem(items.length - 1, true, items);
1909
- return false;
1910
- }
1911
- if(keyCode == 13 || keyCode == 27){
1912
- if (keyCode == 13){
1913
- activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
1914
- that.changeValue( $('li.active-item:not(.hidden-item)', that.shadowList) );
1915
- }
1916
- that.hideList();
1917
- if(formsCFG.customDatalist && activeItem && activeItem[0]){
1918
- $(opts.input).trigger('datalistselect');
1919
- }
1920
- return false;
1921
- }
1922
- },
1923
- 'focus.datalistWidget': function(){
1924
- if($(this).hasClass('list-focus')){
1925
- that.showList();
1926
- }
1927
- },
1928
- 'mousedown.datalistWidget': function(){
1929
- if($(this).is(':focus')){
1930
- that.showList();
1931
- }
1932
- },
1933
- 'blur.datalistWidget': this.timedHide
1934
- })
1935
- ;
1936
-
1937
-
1938
- $(this.datalist)
1939
- .off('updateDatalist.datalistWidget')
1940
- .on('updateDatalist.datalistWidget', $.proxy(this, '_resetListCached'))
1941
- ;
1942
-
1943
- this._resetListCached();
1944
-
1945
- if(opts.input.form && (opts.input.name || opts.input.id)){
1946
- $(opts.input.form).on('submit.datalistWidget'+opts.input.id, function(){
1947
- if(!$(opts.input).hasClass('no-datalist-cache') && that._autocomplete != 'off'){
1948
- var val = $.prop(opts.input, 'value');
1949
- var name = (opts.input.name || opts.input.id) + $.prop(opts.input, 'type');
1950
- if(!that.storedOptions){
1951
- that.storedOptions = getStoredOptions( name );
1952
- }
1953
- if(val && that.storedOptions.indexOf(val) == -1){
1954
- that.storedOptions.push(val);
1955
- storeOptions(name, that.storedOptions );
1956
- }
1957
- }
1958
- });
1959
- }
1960
- $(window).on('unload.datalist'+this.id+' beforeunload.datalist'+this.id, function(){
1961
- that.destroy();
1962
- });
1963
- },
1964
- destroy: function(){
1965
- var autocomplete = $.attr(this.input, 'autocomplete');
1966
- $(this.input)
1967
- .off('.datalistWidget')
1968
- .removeData('datalistWidget')
1969
- ;
1970
- this.shadowList.remove();
1971
- $(document).off('.datalist'+this.id);
1972
- $(window).off('.datalist'+this.id);
1973
- if(this.input.form && this.input.id){
1974
- $(this.input.form).off('submit.datalistWidget'+this.input.id);
1975
- }
1976
- this.input.removeAttribute('aria-haspopup');
1977
- if(autocomplete === undefined){
1978
- this.input.removeAttribute('autocomplete');
1979
- } else {
1980
- $(this.input).attr('autocomplete', autocomplete);
1981
- }
1982
- },
1983
- _resetListCached: function(e){
1984
- var that = this;
1985
- var forceShow;
1986
- this.needsUpdate = true;
1987
- this.lastUpdatedValue = false;
1988
- this.lastUnfoundValue = '';
1989
-
1990
- if(!this.updateTimer){
1991
- if(window.QUnit || (forceShow = (e && document.activeElement == that.input))){
1992
- that.updateListOptions(forceShow);
1993
- } else {
1994
- webshims.ready('WINDOWLOAD', function(){
1995
- that.updateTimer = setTimeout(function(){
1996
- that.updateListOptions();
1997
- that = null;
1998
- listidIndex = 1;
1999
- }, 200 + (100 * listidIndex));
2000
- });
2001
- }
2002
- }
2003
- },
2004
- maskHTML: function(str){
2005
- return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
2006
- },
2007
- updateListOptions: function(_forceShow){
2008
- this.needsUpdate = false;
2009
- clearTimeout(this.updateTimer);
2010
- this.updateTimer = false;
2011
- this.shadowList
2012
- .css({
2013
- fontSize: $.css(this.input, 'fontSize'),
2014
- fontFamily: $.css(this.input, 'fontFamily')
2015
- })
2016
- ;
2017
- this.searchStart = formsCFG.customDatalist && $(this.input).hasClass('search-start');
2018
-
2019
- var list = [];
2020
-
2021
- var values = [];
2022
- var allOptions = [];
2023
- var rElem, rItem, rOptions, rI, rLen, item;
2024
- for(rOptions = $.prop(this.datalist, 'options'), rI = 0, rLen = rOptions.length; rI < rLen; rI++){
2025
- rElem = rOptions[rI];
2026
- if(rElem.disabled){return;}
2027
- rItem = {
2028
- value: $(rElem).val() || '',
2029
- text: $.trim($.attr(rElem, 'label') || getText(rElem)),
2030
- className: rElem.className || '',
2031
- style: $.attr(rElem, 'style') || ''
2032
- };
2033
- if(!rItem.text){
2034
- rItem.text = rItem.value;
2035
- } else if(rItem.text != rItem.value){
2036
- rItem.className += ' different-label-value';
2037
- }
2038
- values[rI] = rItem.value;
2039
- allOptions[rI] = rItem;
2040
- }
2041
-
2042
- if(!this.storedOptions){
2043
- this.storedOptions = ($(this.input).hasClass('no-datalist-cache') || this._autocomplete == 'off') ? [] : getStoredOptions((this.input.name || this.input.id) + $.prop(this.input, 'type'));
2044
- }
2045
-
2046
- this.storedOptions.forEach(function(val, i){
2047
- if(values.indexOf(val) == -1){
2048
- allOptions.push({value: val, text: val, className: 'stored-suggest', style: ''});
2049
- }
2050
- });
2051
-
2052
- for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
2053
- item = allOptions[rI];
2054
- list[rI] = '<li class="'+ item.className +'" style="'+ item.style +'" tabindex="-1" role="listitem"><span class="option-label">'+ this.maskHTML(item.text) +'</span> <span class="option-value">'+ this.maskHTML(item.value) +'</span></li>';
2055
- }
2056
-
2057
- this.arrayOptions = allOptions;
2058
- this.shadowList.html('<div class="datalist-outer-box"><div class="datalist-box"><ul role="list">'+ list.join("\n") +'</ul></div></div>');
2059
-
2060
- if($.fn.bgIframe && lteie6){
2061
- this.shadowList.bgIframe();
2062
- }
2063
-
2064
- if(_forceShow || this.isListVisible){
2065
- this.showHideOptions();
2066
- }
2067
- },
2068
- showHideOptions: function(_fromShowList){
2069
- var value = $.prop(this.input, 'value').toLowerCase();
2070
- //first check prevent infinite loop, second creates simple lazy optimization
2071
- if(value === this.lastUpdatedValue || (this.lastUnfoundValue && value.indexOf(this.lastUnfoundValue) === 0)){
2072
- return;
2073
- }
2074
-
2075
- this.lastUpdatedValue = value;
2076
- var found = false;
2077
- var startSearch = this.searchStart;
2078
- var lis = $('li', this.shadowList);
2079
- if(value){
2080
- this.arrayOptions.forEach(function(item, i){
2081
- var search;
2082
- if(!('lowerText' in item)){
2083
- if(item.text != item.value){
2084
- item.lowerText = item.value.toLowerCase() + item.text.toLowerCase();
2085
- } else {
2086
- item.lowerText = item.text.toLowerCase();
2087
- }
2088
- }
2089
- search = item.lowerText.indexOf(value);
2090
- search = startSearch ? !search : search !== -1;
2091
- if(search){
2092
- $(lis[i]).removeClass('hidden-item');
2093
- found = true;
2094
- } else {
2095
- $(lis[i]).addClass('hidden-item');
2096
- }
2097
- });
2098
- } else if(lis.length) {
2099
- lis.removeClass('hidden-item');
2100
- found = true;
2101
- }
2102
-
2103
- this.hasViewableData = found;
2104
- if(!_fromShowList && found){
2105
- this.showList();
2106
- }
2107
- if(!found){
2108
- this.lastUnfoundValue = value;
2109
- this.hideList();
2110
- }
2111
- },
2112
- setPos: function(){
2113
- this.shadowList.css({marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0});
2114
- var css = (formsCFG.positionDatalist) ? $(this.input).position() : webshims.getRelOffset(this.shadowList, this.input);
2115
- css.top += $(this.input).outerHeight();
2116
- css.width = $(this.input).outerWidth() - (parseInt(this.shadowList.css('borderLeftWidth'), 10) || 0) - (parseInt(this.shadowList.css('borderRightWidth'), 10) || 0);
2117
- this.shadowList.css({marginTop: '', marginLeft: '', marginRight: '', marginBottom: ''}).css(css);
2118
- return css;
2119
- },
2120
- showList: function(){
2121
- if(this.isListVisible){return false;}
2122
- if(this.needsUpdate){
2123
- this.updateListOptions();
2124
- }
2125
- this.showHideOptions(true);
2126
- if(!this.hasViewableData){return false;}
2127
- this.isListVisible = true;
2128
- var that = this;
2129
-
2130
- that.setPos();
2131
- that.shadowList.addClass('datalist-visible').find('li.active-item').removeClass('active-item');
2132
-
2133
- $(window).unbind('.datalist'+that.id);
2134
- $(document)
2135
- .off('.datalist'+that.id)
2136
- .on('mousedown.datalist'+that.id +' focusin.datalist'+that.id, function(e){
2137
- if(e.target === that.input || that.shadowList[0] === e.target || $.contains( that.shadowList[0], e.target )){
2138
- clearTimeout(that.hideTimer);
2139
- setTimeout(function(){
2140
- clearTimeout(that.hideTimer);
2141
- }, 9);
2142
- } else {
2143
- that.timedHide();
2144
- }
2145
- })
2146
- .on('updateshadowdom.datalist'+that.id, function(){
2147
- that.setPos();
2148
- })
2149
- ;
2150
- return true;
2151
- },
2152
- hideList: function(){
2153
- if(!this.isListVisible){return false;}
2154
- var that = this;
2155
- var triggerChange = function(e){
2156
- if(that.changedValue){
2157
- $(that.input).trigger('change');
2158
- }
2159
- that.changedValue = false;
2160
- };
2161
-
2162
- that.shadowList.removeClass('datalist-visible list-item-active');
2163
- that.index = -1;
2164
- that.isListVisible = false;
2165
- if(that.changedValue){
2166
- that.triggeredByDatalist = true;
2167
- webshims.triggerInlineForm && webshims.triggerInlineForm(that.input, 'input');
2168
- if($(that.input).is(':focus')){
2169
- $(that.input).one('blur', triggerChange);
2170
- } else {
2171
- triggerChange();
2172
- }
2173
- that.triggeredByDatalist = false;
2174
- }
2175
- $(document).unbind('.datalist'+that.id);
2176
- $(window)
2177
- .off('.datalist'+that.id)
2178
- .one('resize.datalist'+that.id, function(){
2179
- that.shadowList.css({top: 0, left: 0});
2180
- })
2181
- ;
2182
- return true;
2183
- },
2184
- scrollIntoView: function(elem){
2185
- var ul = $('ul', this.shadowList);
2186
- var div = $('div.datalist-box', this.shadowList);
2187
- var elemPos = elem.position();
2188
- var containerHeight;
2189
- elemPos.top -= (parseInt(ul.css('paddingTop'), 10) || 0) + (parseInt(ul.css('marginTop'), 10) || 0) + (parseInt(ul.css('borderTopWidth'), 10) || 0);
2190
- if(elemPos.top < 0){
2191
- div.scrollTop( div.scrollTop() + elemPos.top - 2);
2192
- return;
2193
- }
2194
- elemPos.top += elem.outerHeight();
2195
- containerHeight = div.height();
2196
- if(elemPos.top > containerHeight){
2197
- div.scrollTop( div.scrollTop() + (elemPos.top - containerHeight) + 2);
2198
- }
2199
- },
2200
- changeValue: function(activeItem){
2201
- if(!activeItem[0]){return;}
2202
- var newValue = $('span.option-value', activeItem).text();
2203
- var oldValue = $.prop(this.input, 'value');
2204
- if(newValue != oldValue){
2205
- $(this.input)
2206
- .prop('value', newValue)
2207
- .triggerHandler('updateInput')
2208
- ;
2209
- this.changedValue = true;
2210
- }
2211
- },
2212
- markItem: function(index, doValue, items){
2213
- var activeItem;
2214
- var goesUp;
2215
-
2216
- items = items || $('li:not(.hidden-item)', this.shadowList);
2217
- if(!items.length){return;}
2218
- if(index < 0){
2219
- index = items.length - 1;
2220
- } else if(index >= items.length){
2221
- index = 0;
2222
- }
2223
- items.removeClass('active-item');
2224
- this.shadowList.addClass('list-item-active');
2225
- activeItem = items.filter(':eq('+ index +')').addClass('active-item');
2226
-
2227
- if(doValue){
2228
- this.changeValue(activeItem);
2229
- this.scrollIntoView(activeItem);
2230
- }
2231
- this.index = index;
2232
- }
2233
- };
2234
-
2235
- //init datalist update
2236
- initializeDatalist();
2237
- })();
2238
-
1
+ //DOM-Extension helper
2
+ jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
3
+ "use strict";
4
+ //shortcus
5
+ var modules = webshims.modules;
6
+ var listReg = /\s*,\s*/;
7
+
8
+ //proxying attribute
9
+ var olds = {};
10
+ var havePolyfill = {};
11
+ var extendedProps = {};
12
+ var extendQ = {};
13
+ var modifyProps = {};
14
+
15
+ var oldVal = $.fn.val;
16
+ var singleVal = function(elem, name, val, pass, _argless){
17
+ return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
18
+ };
19
+ $.fn.val = function(val){
20
+ var elem = this[0];
21
+ if(arguments.length && val == null){
22
+ val = '';
23
+ }
24
+ if(!arguments.length){
25
+ if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
26
+ return $.prop(elem, 'value', val, 'val', true);
27
+ }
28
+ if($.isArray(val)){
29
+ return oldVal.apply(this, arguments);
30
+ }
31
+ var isFunction = $.isFunction(val);
32
+ return this.each(function(i){
33
+ elem = this;
34
+ if(elem.nodeType === 1){
35
+ if(isFunction){
36
+ var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
37
+ if(genVal == null){
38
+ genVal = '';
39
+ }
40
+ $.prop(elem, 'value', genVal, 'val') ;
41
+ } else {
42
+ $.prop(elem, 'value', val, 'val');
43
+ }
44
+ }
45
+ });
46
+ };
47
+
48
+ var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
49
+ var elementData = function(elem, key, val){
50
+ elem = elem.jquery ? elem[0] : elem;
51
+ if(!elem){return val || {};}
52
+ var data = $.data(elem, dataID);
53
+ if(val !== undefined){
54
+ if(!data){
55
+ data = $.data(elem, dataID, {});
56
+ }
57
+ if(key){
58
+ data[key] = val;
59
+ }
60
+ }
61
+
62
+ return key ? data && data[key] : data;
63
+ };
64
+
65
+
66
+ [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
67
+ $.fn[data.name] = function(){
68
+ return this.map(function(){
69
+ var shadowData = elementData(this, 'shadowData');
70
+ return shadowData && shadowData[data.prop] || this;
71
+ });
72
+ };
73
+ });
74
+
75
+
76
+ ['removeAttr', 'prop', 'attr'].forEach(function(type){
77
+ olds[type] = $[type];
78
+ $[type] = function(elem, name, value, pass, _argless){
79
+ var isVal = (pass == 'val');
80
+ var oldMethod = !isVal ? olds[type] : singleVal;
81
+ if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
82
+ return oldMethod(elem, name, value, pass, _argless);
83
+ }
84
+
85
+ var nodeName = (elem.nodeName || '').toLowerCase();
86
+ var desc = extendedProps[nodeName];
87
+ var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
88
+ var propMethod;
89
+ var oldValMethod;
90
+ var ret;
91
+
92
+
93
+ if(!desc){
94
+ desc = extendedProps['*'];
95
+ }
96
+ if(desc){
97
+ desc = desc[name];
98
+ }
99
+
100
+ if(desc){
101
+ propMethod = desc[curType];
102
+ }
103
+
104
+ if(propMethod){
105
+ if(name == 'value'){
106
+ oldValMethod = propMethod.isVal;
107
+ propMethod.isVal = isVal;
108
+ }
109
+ if(curType === 'removeAttr'){
110
+ return propMethod.value.call(elem);
111
+ } else if(value === undefined){
112
+ return (propMethod.get) ?
113
+ propMethod.get.call(elem) :
114
+ propMethod.value
115
+ ;
116
+ } else if(propMethod.set) {
117
+ if(type == 'attr' && value === true){
118
+ value = name;
119
+ }
120
+
121
+ ret = propMethod.set.call(elem, value);
122
+ }
123
+ if(name == 'value'){
124
+ propMethod.isVal = oldValMethod;
125
+ }
126
+ } else {
127
+ ret = oldMethod(elem, name, value, pass, _argless);
128
+ }
129
+ if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
130
+
131
+ var boolValue;
132
+ if(curType == 'removeAttr'){
133
+ boolValue = false;
134
+ } else if(curType == 'prop'){
135
+ boolValue = !!(value);
136
+ } else {
137
+ boolValue = true;
138
+ }
139
+
140
+ modifyProps[nodeName][name].forEach(function(fn){
141
+ if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
142
+ fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
143
+ }
144
+ });
145
+ }
146
+ return ret;
147
+ };
148
+
149
+ extendQ[type] = function(nodeName, prop, desc){
150
+
151
+ if(!extendedProps[nodeName]){
152
+ extendedProps[nodeName] = {};
153
+ }
154
+ if(!extendedProps[nodeName][prop]){
155
+ extendedProps[nodeName][prop] = {};
156
+ }
157
+ var oldDesc = extendedProps[nodeName][prop][type];
158
+ var getSup = function(propType, descriptor, oDesc){
159
+ if(descriptor && descriptor[propType]){
160
+ return descriptor[propType];
161
+ }
162
+ if(oDesc && oDesc[propType]){
163
+ return oDesc[propType];
164
+ }
165
+ if(type == 'prop' && prop == 'value'){
166
+ return function(value){
167
+ var elem = this;
168
+ return (desc.isVal) ?
169
+ singleVal(elem, prop, value, false, (arguments.length === 0)) :
170
+ olds[type](elem, prop, value)
171
+ ;
172
+ };
173
+ }
174
+ if(type == 'prop' && propType == 'value' && desc.value.apply){
175
+ return function(value){
176
+ var sup = olds[type](this, prop);
177
+ if(sup && sup.apply){
178
+ sup = sup.apply(this, arguments);
179
+ }
180
+ return sup;
181
+ };
182
+ }
183
+ return function(value){
184
+ return olds[type](this, prop, value);
185
+ };
186
+ };
187
+ extendedProps[nodeName][prop][type] = desc;
188
+ if(desc.value === undefined){
189
+ if(!desc.set){
190
+ desc.set = desc.writeable ?
191
+ getSup('set', desc, oldDesc) :
192
+ (webshims.cfg.useStrict && prop == 'prop') ?
193
+ function(){throw(prop +' is readonly on '+ nodeName);} :
194
+ $.noop
195
+ ;
196
+ }
197
+ if(!desc.get){
198
+ desc.get = getSup('get', desc, oldDesc);
199
+ }
200
+
201
+ }
202
+
203
+ ['value', 'get', 'set'].forEach(function(descProp){
204
+ if(desc[descProp]){
205
+ desc['_sup'+descProp] = getSup(descProp, oldDesc);
206
+ }
207
+ });
208
+ };
209
+
210
+ });
211
+
212
+ //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
213
+ var isExtendNativeSave = (!$.browser.msie || parseInt($.browser.version, 10) > 8);
214
+ var extendNativeValue = (function(){
215
+ var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
216
+ var has = Object.prototype.hasOwnProperty;
217
+ return function(nodeName, prop, desc){
218
+ var elem = document.createElement(nodeName);
219
+ var elemProto = webshims.getPrototypeOf(elem);
220
+ if( isExtendNativeSave && elemProto && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
221
+ var sup = elem[prop];
222
+ desc._supvalue = function(){
223
+ if(sup && sup.apply){
224
+ return sup.apply(this, arguments);
225
+ }
226
+ return sup;
227
+ };
228
+ elemProto[prop] = desc.value;
229
+ } else {
230
+ desc._supvalue = function(){
231
+ var data = elementData(this, 'propValue');
232
+ if(data && data[prop] && data[prop].apply){
233
+ return data[prop].apply(this, arguments);
234
+ }
235
+ return data && data[prop];
236
+ };
237
+ initProp.extendValue(nodeName, prop, desc.value);
238
+ }
239
+ desc.value._supvalue = desc._supvalue;
240
+ };
241
+ })();
242
+
243
+ var initProp = (function(){
244
+
245
+ var initProps = {};
246
+
247
+ webshims.addReady(function(context, contextElem){
248
+ var nodeNameCache = {};
249
+ var getElementsByName = function(name){
250
+ if(!nodeNameCache[name]){
251
+ nodeNameCache[name] = $(context.getElementsByTagName(name));
252
+ if(contextElem[0] && $.nodeName(contextElem[0], name)){
253
+ nodeNameCache[name] = nodeNameCache[name].add(contextElem);
254
+ }
255
+ }
256
+ };
257
+
258
+
259
+ $.each(initProps, function(name, fns){
260
+ getElementsByName(name);
261
+ if(!fns || !fns.forEach){
262
+ webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
263
+ return;
264
+ }
265
+ fns.forEach(function(fn){
266
+ nodeNameCache[name].each(fn);
267
+ });
268
+ });
269
+ nodeNameCache = null;
270
+ });
271
+
272
+ var tempCache;
273
+ var emptyQ = $([]);
274
+ var createNodeNameInit = function(nodeName, fn){
275
+ if(!initProps[nodeName]){
276
+ initProps[nodeName] = [fn];
277
+ } else {
278
+ initProps[nodeName].push(fn);
279
+ }
280
+ if($.isDOMReady){
281
+ (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
282
+ }
283
+ };
284
+
285
+ var elementExtends = {};
286
+ return {
287
+ createTmpCache: function(nodeName){
288
+ if($.isDOMReady){
289
+ tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
290
+ }
291
+ return tempCache || emptyQ;
292
+ },
293
+ flushTmpCache: function(){
294
+ tempCache = null;
295
+ },
296
+ content: function(nodeName, prop){
297
+ createNodeNameInit(nodeName, function(){
298
+ var val = $.attr(this, prop);
299
+ if(val != null){
300
+ $.attr(this, prop, val);
301
+ }
302
+ });
303
+ },
304
+ createElement: function(nodeName, fn){
305
+ createNodeNameInit(nodeName, fn);
306
+ },
307
+ extendValue: function(nodeName, prop, value){
308
+ createNodeNameInit(nodeName, function(){
309
+ $(this).each(function(){
310
+ var data = elementData(this, 'propValue', {});
311
+ data[prop] = this[prop];
312
+ this[prop] = value;
313
+ });
314
+ });
315
+ }
316
+ };
317
+ })();
318
+
319
+ var createPropDefault = function(descs, removeType){
320
+ if(descs.defaultValue === undefined){
321
+ descs.defaultValue = '';
322
+ }
323
+ if(!descs.removeAttr){
324
+ descs.removeAttr = {
325
+ value: function(){
326
+ descs[removeType || 'prop'].set.call(this, descs.defaultValue);
327
+ descs.removeAttr._supvalue.call(this);
328
+ }
329
+ };
330
+ }
331
+ if(!descs.attr){
332
+ descs.attr = {};
333
+ }
334
+ };
335
+
336
+ $.extend(webshims, {
337
+
338
+ getID: (function(){
339
+ var ID = new Date().getTime();
340
+ return function(elem){
341
+ elem = $(elem);
342
+ var id = elem.attr('id');
343
+ if(!id){
344
+ ID++;
345
+ id = 'ID-'+ ID;
346
+ elem.attr('id', id);
347
+ }
348
+ return id;
349
+ };
350
+ })(),
351
+ extendUNDEFProp: function(obj, props){
352
+ $.each(props, function(name, prop){
353
+ if( !(name in obj) ){
354
+ obj[name] = prop;
355
+ }
356
+ });
357
+ },
358
+ //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
359
+ createPropDefault: createPropDefault,
360
+ data: elementData,
361
+ moveToFirstEvent: function(elem, eventType, bindType){
362
+ var events = ($._data(elem, 'events') || {})[eventType];
363
+ var fn;
364
+
365
+ if(events && events.length > 1){
366
+ fn = events.pop();
367
+ if(!bindType){
368
+ bindType = 'bind';
369
+ }
370
+ if(bindType == 'bind' && events.delegateCount){
371
+ events.splice( events.delegateCount, 0, fn);
372
+ } else {
373
+ events.unshift( fn );
374
+ }
375
+
376
+
377
+ }
378
+ elem = null;
379
+ },
380
+ addShadowDom: (function(){
381
+ var resizeTimer;
382
+ var lastHeight;
383
+ var lastWidth;
384
+
385
+ var docObserve = {
386
+ init: false,
387
+ runs: 0,
388
+ test: function(){
389
+ var height = docObserve.getHeight();
390
+ var width = docObserve.getWidth();
391
+
392
+ if(height != docObserve.height || width != docObserve.width){
393
+ docObserve.height = height;
394
+ docObserve.width = width;
395
+ docObserve.handler({type: 'docresize'});
396
+ docObserve.runs++;
397
+ if(docObserve.runs < 9){
398
+ setTimeout(docObserve.test, 90);
399
+ }
400
+ } else {
401
+ docObserve.runs = 0;
402
+ }
403
+ },
404
+ handler: function(e){
405
+ clearTimeout(resizeTimer);
406
+ resizeTimer = setTimeout(function(){
407
+ if(e.type == 'resize'){
408
+ var width = $(window).width();
409
+ var height = $(window).width();
410
+ if(height == lastHeight && width == lastWidth){
411
+ return;
412
+ }
413
+ lastHeight = height;
414
+ lastWidth = width;
415
+
416
+ docObserve.height = docObserve.getHeight();
417
+ docObserve.width = docObserve.getWidth();
418
+
419
+ }
420
+ $.event.trigger('updateshadowdom');
421
+ }, (e.type == 'resize') ? 50 : 9);
422
+ },
423
+ _create: function(){
424
+ $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
425
+ var body = document.body;
426
+ var doc = document.documentElement;
427
+ docObserve[type] = function(){
428
+ return Math.max(
429
+ body[ "scroll" + name ], doc[ "scroll" + name ],
430
+ body[ "offset" + name ], doc[ "offset" + name ],
431
+ doc[ "client" + name ]
432
+ );
433
+ };
434
+ });
435
+ },
436
+ start: function(){
437
+ if(!this.init && document.body){
438
+ this.init = true;
439
+ this._create();
440
+ this.height = docObserve.getHeight();
441
+ this.width = docObserve.getWidth();
442
+ setInterval(this.test, 600);
443
+ $(this.test);
444
+ webshims.ready('WINDOWLOAD', this.test);
445
+ $(window).bind('resize', this.handler);
446
+ (function(){
447
+ var oldAnimate = $.fn.animate;
448
+ var animationTimer;
449
+
450
+ $.fn.animate = function(){
451
+ clearTimeout(animationTimer);
452
+ animationTimer = setTimeout(function(){
453
+ docObserve.test();
454
+ }, 99);
455
+
456
+ return oldAnimate.apply(this, arguments);
457
+ };
458
+ })();
459
+ }
460
+ }
461
+ };
462
+
463
+
464
+ $.event.customEvent.updateshadowdom = true;
465
+ webshims.docObserve = function(){
466
+ webshims.ready('DOM', function(){
467
+ docObserve.start();
468
+ });
469
+ };
470
+ return function(nativeElem, shadowElem, opts){
471
+ opts = opts || {};
472
+ if(nativeElem.jquery){
473
+ nativeElem = nativeElem[0];
474
+ }
475
+ if(shadowElem.jquery){
476
+ shadowElem = shadowElem[0];
477
+ }
478
+ var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
479
+ var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
480
+ var shadowFocusElementData = {};
481
+ if(!opts.shadowFocusElement){
482
+ opts.shadowFocusElement = shadowElem;
483
+ } else if(opts.shadowFocusElement){
484
+ if(opts.shadowFocusElement.jquery){
485
+ opts.shadowFocusElement = opts.shadowFocusElement[0];
486
+ }
487
+ shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
488
+ }
489
+
490
+ nativeData.hasShadow = shadowElem;
491
+ shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
492
+ shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
493
+ nativeElement: nativeElem,
494
+ shadowElement: shadowElem,
495
+ shadowFocusElement: opts.shadowFocusElement
496
+ };
497
+ if(opts.shadowChilds){
498
+ opts.shadowChilds.each(function(){
499
+ elementData(this, 'shadowData', shadowData.shadowData);
500
+ });
501
+ }
502
+
503
+ if(opts.data){
504
+ shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
505
+ }
506
+ opts = null;
507
+ webshims.docObserve();
508
+ };
509
+ })(),
510
+ propTypes: {
511
+ standard: function(descs, name){
512
+ createPropDefault(descs);
513
+ if(descs.prop){return;}
514
+ descs.prop = {
515
+ set: function(val){
516
+ descs.attr.set.call(this, ''+val);
517
+ },
518
+ get: function(){
519
+ return descs.attr.get.call(this) || descs.defaultValue;
520
+ }
521
+ };
522
+
523
+ },
524
+ "boolean": function(descs, name){
525
+
526
+ createPropDefault(descs);
527
+ if(descs.prop){return;}
528
+ descs.prop = {
529
+ set: function(val){
530
+ if(val){
531
+ descs.attr.set.call(this, "");
532
+ } else {
533
+ descs.removeAttr.value.call(this);
534
+ }
535
+ },
536
+ get: function(){
537
+ return descs.attr.get.call(this) != null;
538
+ }
539
+ };
540
+ },
541
+ "src": (function(){
542
+ var anchor = document.createElement('a');
543
+ anchor.style.display = "none";
544
+ return function(descs, name){
545
+
546
+ createPropDefault(descs);
547
+ if(descs.prop){return;}
548
+ descs.prop = {
549
+ set: function(val){
550
+ descs.attr.set.call(this, val);
551
+ },
552
+ get: function(){
553
+ var href = this.getAttribute(name);
554
+ var ret;
555
+ if(href == null){return '';}
556
+
557
+ anchor.setAttribute('href', href+'' );
558
+
559
+ if(!$.support.hrefNormalized){
560
+ try {
561
+ $(anchor).insertAfter(this);
562
+ ret = anchor.getAttribute('href', 4);
563
+ } catch(er){
564
+ ret = anchor.getAttribute('href', 4);
565
+ }
566
+ $(anchor).detach();
567
+ }
568
+ return ret || anchor.href;
569
+ }
570
+ };
571
+ };
572
+ })(),
573
+ enumarated: function(descs, name){
574
+
575
+ createPropDefault(descs);
576
+ if(descs.prop){return;}
577
+ descs.prop = {
578
+ set: function(val){
579
+ descs.attr.set.call(this, val);
580
+ },
581
+ get: function(){
582
+ var val = (descs.attr.get.call(this) || '').toLowerCase();
583
+ if(!val || descs.limitedTo.indexOf(val) == -1){
584
+ val = descs.defaultValue;
585
+ }
586
+ return val;
587
+ }
588
+ };
589
+ }
590
+
591
+ // ,unsignedLong: $.noop
592
+ // ,"doubble": $.noop
593
+ // ,"long": $.noop
594
+ // ,tokenlist: $.noop
595
+ // ,settableTokenlist: $.noop
596
+ },
597
+ reflectProperties: function(nodeNames, props){
598
+ if(typeof props == 'string'){
599
+ props = props.split(listReg);
600
+ }
601
+ props.forEach(function(prop){
602
+ webshims.defineNodeNamesProperty(nodeNames, prop, {
603
+ prop: {
604
+ set: function(val){
605
+ $.attr(this, prop, val);
606
+ },
607
+ get: function(){
608
+ return $.attr(this, prop) || '';
609
+ }
610
+ }
611
+ });
612
+ });
613
+ },
614
+ defineNodeNameProperty: function(nodeName, prop, descs){
615
+ havePolyfill[prop] = true;
616
+
617
+ if(descs.reflect){
618
+ webshims.propTypes[descs.propType || 'standard'](descs, prop);
619
+ }
620
+
621
+ ['prop', 'attr', 'removeAttr'].forEach(function(type){
622
+ var desc = descs[type];
623
+ if(desc){
624
+ if(type === 'prop'){
625
+ desc = $.extend({writeable: true}, desc);
626
+ } else {
627
+ desc = $.extend({}, desc, {writeable: true});
628
+ }
629
+
630
+ extendQ[type](nodeName, prop, desc);
631
+ if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
632
+ extendNativeValue(nodeName, prop, desc);
633
+ }
634
+ descs[type] = desc;
635
+ }
636
+ });
637
+ if(descs.initAttr){
638
+ initProp.content(nodeName, prop);
639
+ }
640
+ return descs;
641
+ },
642
+
643
+ defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
644
+ var olddesc;
645
+ for(var prop in descs){
646
+ if(!_noTmpCache && descs[prop].initAttr){
647
+ initProp.createTmpCache(name);
648
+ }
649
+ if(propType){
650
+ if(descs[prop][propType]){
651
+ //webshims.log('override: '+ name +'['+prop +'] for '+ propType);
652
+ } else {
653
+ descs[prop][propType] = {};
654
+ ['value', 'set', 'get'].forEach(function(copyProp){
655
+ if(copyProp in descs[prop]){
656
+ descs[prop][propType][copyProp] = descs[prop][copyProp];
657
+ delete descs[prop][copyProp];
658
+ }
659
+ });
660
+ }
661
+ }
662
+ descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
663
+ }
664
+ if(!_noTmpCache){
665
+ initProp.flushTmpCache();
666
+ }
667
+ return descs;
668
+ },
669
+
670
+ createElement: function(nodeName, create, descs){
671
+ var ret;
672
+ if($.isFunction(create)){
673
+ create = {
674
+ after: create
675
+ };
676
+ }
677
+ initProp.createTmpCache(nodeName);
678
+ if(create.before){
679
+ initProp.createElement(nodeName, create.before);
680
+ }
681
+ if(descs){
682
+ ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
683
+ }
684
+ if(create.after){
685
+ initProp.createElement(nodeName, create.after);
686
+ }
687
+ initProp.flushTmpCache();
688
+ return ret;
689
+ },
690
+ onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
691
+ if(typeof nodeNames == 'string'){
692
+ nodeNames = nodeNames.split(listReg);
693
+ }
694
+ if($.isFunction(desc)){
695
+ desc = {set: desc};
696
+ }
697
+
698
+ nodeNames.forEach(function(name){
699
+ if(!modifyProps[name]){
700
+ modifyProps[name] = {};
701
+ }
702
+ if(typeof props == 'string'){
703
+ props = props.split(listReg);
704
+ }
705
+ if(desc.initAttr){
706
+ initProp.createTmpCache(name);
707
+ }
708
+ props.forEach(function(prop){
709
+ if(!modifyProps[name][prop]){
710
+ modifyProps[name][prop] = [];
711
+ havePolyfill[prop] = true;
712
+ }
713
+ if(desc.set){
714
+ if(only){
715
+ desc.set.only = only;
716
+ }
717
+ modifyProps[name][prop].push(desc.set);
718
+ }
719
+
720
+ if(desc.initAttr){
721
+ initProp.content(name, prop);
722
+ }
723
+ });
724
+ initProp.flushTmpCache();
725
+
726
+ });
727
+ },
728
+ defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
729
+ if(!descs){
730
+ descs = {};
731
+ }
732
+ if($.isFunction(descs)){
733
+ descs.set = descs;
734
+ }
735
+ webshims.defineNodeNamesProperty(elementNames, prop, {
736
+ attr: {
737
+ set: function(val){
738
+ this.setAttribute(prop, val);
739
+ if(descs.set){
740
+ descs.set.call(this, true);
741
+ }
742
+ },
743
+ get: function(){
744
+ var ret = this.getAttribute(prop);
745
+ return (ret == null) ? undefined : prop;
746
+ }
747
+ },
748
+ removeAttr: {
749
+ value: function(){
750
+ this.removeAttribute(prop);
751
+ if(descs.set){
752
+ descs.set.call(this, false);
753
+ }
754
+ }
755
+ },
756
+ reflect: true,
757
+ propType: 'boolean',
758
+ initAttr: descs.initAttr || false
759
+ });
760
+ },
761
+ contentAttr: function(elem, name, val){
762
+ if(!elem.nodeName){return;}
763
+ var attr;
764
+ if(val === undefined){
765
+ attr = (elem.attributes[name] || {});
766
+ val = attr.specified ? attr.value : null;
767
+ return (val == null) ? undefined : val;
768
+ }
769
+
770
+ if(typeof val == 'boolean'){
771
+ if(!val){
772
+ elem.removeAttribute(name);
773
+ } else {
774
+ elem.setAttribute(name, name);
775
+ }
776
+ } else {
777
+ elem.setAttribute(name, val);
778
+ }
779
+ },
780
+
781
+ // set current Lang:
782
+ // - webshims.activeLang(lang:string);
783
+ // get current lang
784
+ // - webshims.activeLang();
785
+ // get current lang
786
+ // webshims.activeLang({
787
+ // register: moduleName:string,
788
+ // callback: callback:function
789
+ // });
790
+ // get/set including removeLang
791
+ // - webshims.activeLang({
792
+ // module: moduleName:string,
793
+ // callback: callback:function,
794
+ // langObj: languageObj:array/object
795
+ // });
796
+ activeLang: (function(){
797
+ var callbacks = [];
798
+ var registeredCallbacks = {};
799
+ var currentLang;
800
+ var shortLang;
801
+ var notLocal = /:\/\/|^\.*\//;
802
+ var loadRemoteLang = function(data, lang, options){
803
+ var langSrc;
804
+ if(lang && options && $.inArray(lang, options.availabeLangs || []) !== -1){
805
+ data.loading = true;
806
+ langSrc = options.langSrc;
807
+ if(!notLocal.test(langSrc)){
808
+ langSrc = webshims.cfg.basePath+langSrc;
809
+ }
810
+ webshims.loader.loadScript(langSrc+lang+'.js', function(){
811
+ if(data.langObj[lang]){
812
+ data.loading = false;
813
+ callLang(data, true);
814
+ } else {
815
+ $(function(){
816
+ if(data.langObj[lang]){
817
+ callLang(data, true);
818
+ }
819
+ data.loading = false;
820
+ });
821
+ }
822
+ });
823
+ return true;
824
+ }
825
+ return false;
826
+ };
827
+ var callRegister = function(module){
828
+ if(registeredCallbacks[module]){
829
+ registeredCallbacks[module].forEach(function(data){
830
+ data.callback();
831
+ });
832
+ }
833
+ };
834
+ var callLang = function(data, _noLoop){
835
+ if(data.activeLang != currentLang && data.activeLang !== shortLang){
836
+ var options = modules[data.module].options;
837
+ if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
838
+ data.activeLang = currentLang;
839
+ data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
840
+ callRegister(data.module);
841
+ } else if( !_noLoop &&
842
+ !loadRemoteLang(data, currentLang, options) &&
843
+ !loadRemoteLang(data, shortLang, options) &&
844
+ data.langObj[''] && data.activeLang !== '' ) {
845
+ data.activeLang = '';
846
+ data.callback(data.langObj[''], currentLang);
847
+ callRegister(data.module);
848
+ }
849
+ }
850
+ };
851
+
852
+
853
+ var activeLang = function(lang){
854
+
855
+ if(typeof lang == 'string' && lang !== currentLang){
856
+ currentLang = lang;
857
+ shortLang = currentLang.split('-')[0];
858
+ if(currentLang == shortLang){
859
+ shortLang = false;
860
+ }
861
+ $.each(callbacks, function(i, data){
862
+ callLang(data);
863
+ });
864
+ } else if(typeof lang == 'object'){
865
+
866
+ if(lang.register){
867
+ if(!registeredCallbacks[lang.register]){
868
+ registeredCallbacks[lang.register] = [];
869
+ }
870
+ registeredCallbacks[lang.register].push(lang);
871
+ lang.callback();
872
+ } else {
873
+ if(!lang.activeLang){
874
+ lang.activeLang = '';
875
+ }
876
+ callbacks.push(lang);
877
+ callLang(lang);
878
+ }
879
+ }
880
+ return currentLang;
881
+ };
882
+
883
+ return activeLang;
884
+ })()
885
+ });
886
+
887
+ $.each({
888
+ defineNodeNamesProperty: 'defineNodeNameProperty',
889
+ defineNodeNamesProperties: 'defineNodeNameProperties',
890
+ createElements: 'createElement'
891
+ }, function(name, baseMethod){
892
+ webshims[name] = function(names, a, b, c){
893
+ if(typeof names == 'string'){
894
+ names = names.split(listReg);
895
+ }
896
+ var retDesc = {};
897
+ names.forEach(function(nodeName){
898
+ retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
899
+ });
900
+ return retDesc;
901
+ };
902
+ });
903
+
904
+ webshims.isReady('webshimLocalization', true);
905
+ });
906
+ //html5a11y
907
+ (function($, document){
908
+ var browserVersion = $.webshims.browserVersion;
909
+ if($.browser.mozilla && browserVersion > 5){return;}
910
+ if (!$.browser.msie || (browserVersion < 12 && browserVersion > 7)) {
911
+ var elemMappings = {
912
+ article: "article",
913
+ aside: "complementary",
914
+ section: "region",
915
+ nav: "navigation",
916
+ address: "contentinfo"
917
+ };
918
+ var addRole = function(elem, role){
919
+ var hasRole = elem.getAttribute('role');
920
+ if (!hasRole) {
921
+ elem.setAttribute('role', role);
922
+ }
923
+ };
924
+
925
+ $.webshims.addReady(function(context, contextElem){
926
+ $.each(elemMappings, function(name, role){
927
+ var elems = $(name, context).add(contextElem.filter(name));
928
+ for (var i = 0, len = elems.length; i < len; i++) {
929
+ addRole(elems[i], role);
930
+ }
931
+ });
932
+ if (context === document) {
933
+ var header = document.getElementsByTagName('header')[0];
934
+ var footers = document.getElementsByTagName('footer');
935
+ var footerLen = footers.length;
936
+ if (header && !$(header).closest('section, article')[0]) {
937
+ addRole(header, 'banner');
938
+ }
939
+ if (!footerLen) {
940
+ return;
941
+ }
942
+ var footer = footers[footerLen - 1];
943
+ if (!$(footer).closest('section, article')[0]) {
944
+ addRole(footer, 'contentinfo');
945
+ }
946
+ }
947
+ });
948
+ }
949
+ })(jQuery, document);
950
+
951
+ //additional tests for partial implementation of forms features
952
+ (function($){
953
+ "use strict";
954
+ var Modernizr = window.Modernizr;
955
+ var webshims = $.webshims;
956
+ var bugs = webshims.bugs;
957
+ var form = $('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /><input required="" name="a" /></form>');
958
+ var testRequiredFind = function(){
959
+ if(form[0].querySelector){
960
+ try {
961
+ bugs.findRequired = !(form[0].querySelector('select:required'));
962
+ } catch(er){
963
+ bugs.findRequired = false;
964
+ }
965
+ }
966
+ };
967
+ var inputElem = $('input', form).eq(0);
968
+ var onDomextend = function(fn){
969
+ webshims.loader.loadList(['dom-extend']);
970
+ webshims.ready('dom-extend', fn);
971
+ };
972
+
973
+ bugs.findRequired = false;
974
+ bugs.validationMessage = false;
975
+
976
+ webshims.capturingEventPrevented = function(e){
977
+ if(!e._isPolyfilled){
978
+ var isDefaultPrevented = e.isDefaultPrevented;
979
+ var preventDefault = e.preventDefault;
980
+ e.preventDefault = function(){
981
+ clearTimeout($.data(e.target, e.type + 'DefaultPrevented'));
982
+ $.data(e.target, e.type + 'DefaultPrevented', setTimeout(function(){
983
+ $.removeData(e.target, e.type + 'DefaultPrevented');
984
+ }, 30));
985
+ return preventDefault.apply(this, arguments);
986
+ };
987
+ e.isDefaultPrevented = function(){
988
+ return !!(isDefaultPrevented.apply(this, arguments) || $.data(e.target, e.type + 'DefaultPrevented') || false);
989
+ };
990
+ e._isPolyfilled = true;
991
+ }
992
+ };
993
+
994
+ if(!Modernizr.formvalidation || bugs.bustedValidity){
995
+ testRequiredFind();
996
+ return;
997
+ }
998
+
999
+ //create delegatable events
1000
+ webshims.capturingEvents(['input']);
1001
+ webshims.capturingEvents(['invalid'], true);
1002
+
1003
+ if(window.opera || window.testGoodWithFix){
1004
+
1005
+ form.appendTo('head');
1006
+
1007
+ testRequiredFind();
1008
+ bugs.validationMessage = !(inputElem.prop('validationMessage'));
1009
+
1010
+ webshims.reTest(['form-native-extend', 'form-message']);
1011
+
1012
+ form.remove();
1013
+
1014
+ $(function(){
1015
+ onDomextend(function(){
1016
+
1017
+ //Opera shows native validation bubbles in case of input.checkValidity()
1018
+ // Opera 11.6/12 hasn't fixed this issue right, it's buggy
1019
+ var preventDefault = function(e){
1020
+ e.preventDefault();
1021
+ };
1022
+
1023
+ ['form', 'input', 'textarea', 'select'].forEach(function(name){
1024
+ var desc = webshims.defineNodeNameProperty(name, 'checkValidity', {
1025
+ prop: {
1026
+ value: function(){
1027
+ if (!webshims.fromSubmit) {
1028
+ $(this).on('invalid.checkvalidity', preventDefault);
1029
+ }
1030
+
1031
+ webshims.fromCheckValidity = true;
1032
+ var ret = desc.prop._supvalue.apply(this, arguments);
1033
+ if (!webshims.fromSubmit) {
1034
+ $(this).unbind('invalid.checkvalidity', preventDefault);
1035
+ }
1036
+ webshims.fromCheckValidity = false;
1037
+ return ret;
1038
+ }
1039
+ }
1040
+ });
1041
+ });
1042
+
1043
+ });
1044
+ });
1045
+ }
1046
+
1047
+ if($.browser.webkit && !webshims.bugs.bustedValidity){
1048
+ (function(){
1049
+ var elems = /^(?:textarea|input)$/i;
1050
+ var form = false;
1051
+
1052
+ document.addEventListener('contextmenu', function(e){
1053
+ if(elems.test( e.target.nodeName || '') && (form = e.target.form)){
1054
+ setTimeout(function(){
1055
+ form = false;
1056
+ }, 1);
1057
+ }
1058
+ }, false);
1059
+
1060
+ $(window).on('invalid', function(e){
1061
+ if(e.originalEvent && form && form == e.target.form){
1062
+ e.wrongWebkitInvalid = true;
1063
+ e.stopImmediatePropagation();
1064
+ }
1065
+ });
1066
+
1067
+ })();
1068
+ }
1069
+ })(jQuery);
1070
+
1071
+ jQuery.webshims.register('form-core', function($, webshims, window, document, undefined, options){
1072
+ "use strict";
1073
+
1074
+
1075
+ var checkTypes = {checkbox: 1, radio: 1};
1076
+ var emptyJ = $([]);
1077
+ var bugs = webshims.bugs;
1078
+ var groupTypes = {radio: 1};
1079
+ var getGroupElements = function(elem){
1080
+ elem = $(elem);
1081
+ var name;
1082
+ var form;
1083
+ var ret = emptyJ;
1084
+ if(groupTypes[elem[0].type]){
1085
+ form = elem.prop('form');
1086
+ name = elem[0].name;
1087
+ if(!name){
1088
+ ret = elem;
1089
+ } else if(form){
1090
+ ret = $(form[name]);
1091
+ } else {
1092
+ ret = $(document.getElementsByName(name)).filter(function(){
1093
+ return !$.prop(this, 'form');
1094
+ });
1095
+ }
1096
+ ret = ret.filter('[type="radio"]');
1097
+ }
1098
+ return ret;
1099
+ };
1100
+
1101
+ var getContentValidationMessage = webshims.getContentValidationMessage = function(elem, validity, key){
1102
+ var message = $(elem).data('errormessage') || elem.getAttribute('x-moz-errormessage') || '';
1103
+ if(key && message[key]){
1104
+ message = message[key];
1105
+ }
1106
+ if(typeof message == 'object'){
1107
+ validity = validity || $.prop(elem, 'validity') || {valid: 1};
1108
+ if(!validity.valid){
1109
+ $.each(validity, function(name, prop){
1110
+ if(prop && name != 'valid' && message[name]){
1111
+ message = message[name];
1112
+ return false;
1113
+ }
1114
+ });
1115
+ }
1116
+ }
1117
+
1118
+ if(typeof message == 'object'){
1119
+ message = message.defaultMessage;
1120
+ }
1121
+ return message || '';
1122
+ };
1123
+
1124
+ /*
1125
+ * Selectors for all browsers
1126
+ */
1127
+ var rangeTypes = {number: 1, range: 1, date: 1/*, time: 1, 'datetime-local': 1, datetime: 1, month: 1, week: 1*/};
1128
+ var hasInvalid = function(elem){
1129
+ var ret = false;
1130
+ $($.prop(elem, 'elements')).each(function(){
1131
+ ret = $(this).is(':invalid');
1132
+ if(ret){
1133
+ return false;
1134
+ }
1135
+ });
1136
+ return ret;
1137
+ };
1138
+ $.extend($.expr[":"], {
1139
+ "valid-element": function(elem){
1140
+ return $.nodeName(elem, 'form') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
1141
+ },
1142
+ "invalid-element": function(elem){
1143
+ return $.nodeName(elem, 'form') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
1144
+ },
1145
+ "required-element": function(elem){
1146
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
1147
+ },
1148
+ "user-error": function(elem){
1149
+ return ($.prop(elem, 'willValidate') && $(elem).hasClass('user-error'));
1150
+ },
1151
+ "optional-element": function(elem){
1152
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
1153
+ },
1154
+ "in-range": function(elem){
1155
+ if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1156
+ return false;
1157
+ }
1158
+ var val = $.prop(elem, 'validity');
1159
+ return !!(val && !val.rangeOverflow && !val.rangeUnderflow);
1160
+ },
1161
+ "out-of-range": function(elem){
1162
+ if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1163
+ return false;
1164
+ }
1165
+ var val = $.prop(elem, 'validity');
1166
+ return !!(val && (val.rangeOverflow || val.rangeUnderflow));
1167
+ }
1168
+
1169
+ });
1170
+
1171
+ ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
1172
+ $.expr[":"][name] = $.expr.filters[name+"-element"];
1173
+ });
1174
+
1175
+
1176
+ $.expr[":"].focus = function( elem ) {
1177
+ try {
1178
+ var doc = elem.ownerDocument;
1179
+ return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus());
1180
+ } catch(e){}
1181
+ return false;
1182
+ };
1183
+
1184
+ if(Modernizr.formvalidation && $.browser.webkit && !webshims.bugs.bustedValidity && webshims.browserVersion < 27){
1185
+ (function(){
1186
+ var retriggerRadioValidity = function(){
1187
+ var validity;
1188
+ if((validity = this.validity) && !validity.customError){
1189
+ this.setCustomValidity('');
1190
+ }
1191
+ };
1192
+
1193
+ webshims.addReady(function(context, insertedElement){
1194
+ if(context !== document){
1195
+ $('input[type="radio"]:invalid', context)
1196
+ .add(insertedElement.filter('input[type="radio"]:invalid'))
1197
+ .each(retriggerRadioValidity)
1198
+ ;
1199
+ }
1200
+ });
1201
+ })();
1202
+ }
1203
+
1204
+ var customEvents = $.event.customEvent || {};
1205
+ var isValid = function(elem){
1206
+ return ($.prop(elem, 'validity') || {valid: 1}).valid;
1207
+ };
1208
+
1209
+ if (bugs.bustedValidity || bugs.findRequired) {
1210
+ (function(){
1211
+ var find = $.find;
1212
+ var matchesSelector = $.find.matchesSelector;
1213
+
1214
+ var regExp = /(\:valid|\:invalid|\:optional|\:required|\:in-range|\:out-of-range)(?=[\s\[\~\.\+\>\:\#*]|$)/ig;
1215
+ var regFn = function(sel){
1216
+ return sel + '-element';
1217
+ };
1218
+
1219
+ $.find = (function(){
1220
+ var slice = Array.prototype.slice;
1221
+ var fn = function(sel){
1222
+ var ar = arguments;
1223
+ ar = slice.call(ar, 1, ar.length);
1224
+ ar.unshift(sel.replace(regExp, regFn));
1225
+ return find.apply(this, ar);
1226
+ };
1227
+ for (var i in find) {
1228
+ if(find.hasOwnProperty(i)){
1229
+ fn[i] = find[i];
1230
+ }
1231
+ }
1232
+ return fn;
1233
+ })();
1234
+ if(!Modernizr.prefixed || Modernizr.prefixed("matchesSelector", document.documentElement)){
1235
+ $.find.matchesSelector = function(node, expr){
1236
+ expr = expr.replace(regExp, regFn);
1237
+ return matchesSelector.call(this, node, expr);
1238
+ };
1239
+ }
1240
+
1241
+ })();
1242
+ }
1243
+
1244
+ //ToDo needs testing
1245
+ var oldAttr = $.prop;
1246
+ var changeVals = {selectedIndex: 1, value: 1, checked: 1, disabled: 1, readonly: 1};
1247
+ $.prop = function(elem, name, val){
1248
+ var ret = oldAttr.apply(this, arguments);
1249
+ if(elem && 'form' in elem && changeVals[name] && val !== undefined && $(elem).hasClass(invalidClass)){
1250
+ if(isValid(elem)){
1251
+ $(elem).getShadowElement().removeClass(invalidClasses);
1252
+ if(name == 'checked' && val) {
1253
+ getGroupElements(elem).not(elem).removeClass(invalidClasses).removeAttr('aria-invalid');
1254
+ }
1255
+ }
1256
+ }
1257
+ return ret;
1258
+ };
1259
+
1260
+ var returnValidityCause = function(validity, elem){
1261
+ var ret;
1262
+ $.each(validity, function(name, value){
1263
+ if(value){
1264
+ ret = (name == 'customError') ? $.prop(elem, 'validationMessage') : name;
1265
+ return false;
1266
+ }
1267
+ });
1268
+ return ret;
1269
+ };
1270
+
1271
+ var isInGroup = function(name){
1272
+ var ret;
1273
+ try {
1274
+ ret = document.activeElement.name === name;
1275
+ } catch(e){}
1276
+ return ret;
1277
+ };
1278
+ /* form-ui-invalid/form-ui-valid are deprecated. use user-error/user-success instead */
1279
+ var invalidClass = 'user-error';
1280
+ var invalidClasses = 'user-error form-ui-invalid';
1281
+ var validClass = 'user-success';
1282
+ var validClasses = 'user-success form-ui-valid';
1283
+ var switchValidityClass = function(e){
1284
+ var elem, timer;
1285
+ if(!e.target){return;}
1286
+ elem = $(e.target).getNativeElement()[0];
1287
+ if(elem.type == 'submit' || !$.prop(elem, 'willValidate')){return;}
1288
+ timer = $.data(elem, 'webshimsswitchvalidityclass');
1289
+ var switchClass = function(){
1290
+ if(e.type == 'focusout' && elem.type == 'radio' && isInGroup(elem.name)){return;}
1291
+ var validity = $.prop(elem, 'validity');
1292
+ var shadowElem = $(elem).getShadowElement();
1293
+ var addClass, removeClass, trigger, generaltrigger, validityCause;
1294
+
1295
+ $(elem).trigger('refreshCustomValidityRules');
1296
+ if(validity.valid){
1297
+ if(!shadowElem.hasClass(validClass)){
1298
+ addClass = validClasses;
1299
+ removeClass = invalidClasses;
1300
+ generaltrigger = 'changedvaliditystate';
1301
+ trigger = 'changedvalid';
1302
+ if(checkTypes[elem.type] && elem.checked){
1303
+ getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass).removeAttr('aria-invalid');
1304
+ }
1305
+ $.removeData(elem, 'webshimsinvalidcause');
1306
+ }
1307
+ } else {
1308
+ validityCause = returnValidityCause(validity, elem);
1309
+ if($.data(elem, 'webshimsinvalidcause') != validityCause){
1310
+ $.data(elem, 'webshimsinvalidcause', validityCause);
1311
+ generaltrigger = 'changedvaliditystate';
1312
+ }
1313
+ if(!shadowElem.hasClass(invalidClass)){
1314
+ addClass = invalidClasses;
1315
+ removeClass = validClasses;
1316
+ if (checkTypes[elem.type] && !elem.checked) {
1317
+ getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass);
1318
+ }
1319
+ trigger = 'changedinvalid';
1320
+ }
1321
+ }
1322
+ if(addClass){
1323
+ shadowElem.addClass(addClass).removeClass(removeClass);
1324
+ //jQuery 1.6.1 IE9 bug (doubble trigger bug)
1325
+ setTimeout(function(){
1326
+ $(elem).trigger(trigger);
1327
+ }, 0);
1328
+ }
1329
+ if(generaltrigger){
1330
+ setTimeout(function(){
1331
+ $(elem).trigger(generaltrigger);
1332
+ }, 0);
1333
+ }
1334
+ $.removeData(e.target, 'webshimsswitchvalidityclass');
1335
+ };
1336
+
1337
+ if(timer){
1338
+ clearTimeout(timer);
1339
+ }
1340
+ if(e.type == 'refreshvalidityui'){
1341
+ switchClass();
1342
+ } else {
1343
+ $.data(elem, 'webshimsswitchvalidityclass', setTimeout(switchClass, 9));
1344
+ }
1345
+ };
1346
+
1347
+ $(document).on(options.validityUIEvents || 'focusout change refreshvalidityui', switchValidityClass);
1348
+ customEvents.changedvaliditystate = true;
1349
+ customEvents.refreshCustomValidityRules = true;
1350
+ customEvents.changedvalid = true;
1351
+ customEvents.changedinvalid = true;
1352
+ customEvents.refreshvalidityui = true;
1353
+
1354
+
1355
+ webshims.triggerInlineForm = function(elem, event){
1356
+ $(elem).trigger(event);
1357
+ };
1358
+
1359
+ webshims.modules["form-core"].getGroupElements = getGroupElements;
1360
+
1361
+
1362
+ var setRoot = function(){
1363
+ webshims.scrollRoot = ($.browser.webkit || document.compatMode == 'BackCompat') ?
1364
+ $(document.body) :
1365
+ $(document.documentElement)
1366
+ ;
1367
+ };
1368
+ setRoot();
1369
+ webshims.ready('DOM', setRoot);
1370
+
1371
+ webshims.getRelOffset = function(posElem, relElem){
1372
+ posElem = $(posElem);
1373
+ var offset = $(relElem).offset();
1374
+ var bodyOffset;
1375
+ $.swap($(posElem)[0], {visibility: 'hidden', display: 'inline-block', left: 0, top: 0}, function(){
1376
+ bodyOffset = posElem.offset();
1377
+ });
1378
+ offset.top -= bodyOffset.top;
1379
+ offset.left -= bodyOffset.left;
1380
+ return offset;
1381
+ };
1382
+
1383
+ /* some extra validation UI */
1384
+ webshims.validityAlert = (function(){
1385
+ var alertElem = (!$.browser.msie || parseInt($.browser.version, 10) > 7) ? 'span' : 'label';
1386
+ var errorBubble;
1387
+ var hideTimer = false;
1388
+ var focusTimer = false;
1389
+ var resizeTimer = false;
1390
+ var boundHide;
1391
+
1392
+ var api = {
1393
+ hideDelay: 5000,
1394
+
1395
+ showFor: function(elem, message, noFocusElem, noBubble){
1396
+ api._create();
1397
+ elem = $(elem);
1398
+ var visual = $(elem).getShadowElement();
1399
+ var offset = api.getOffsetFromBody(visual);
1400
+ api.clear();
1401
+ if(noBubble){
1402
+ this.hide();
1403
+ } else {
1404
+
1405
+ this.getMessage(elem, message);
1406
+ this.position(visual, offset);
1407
+
1408
+ this.show();
1409
+ if(this.hideDelay){
1410
+ hideTimer = setTimeout(boundHide, this.hideDelay);
1411
+ }
1412
+ $(window)
1413
+ .on('resize.validityalert reposoverlay.validityalert', function(){
1414
+ clearTimeout(resizeTimer);
1415
+ resizeTimer = setTimeout(function(){
1416
+ api.position(visual);
1417
+ }, 9);
1418
+ })
1419
+ ;
1420
+ }
1421
+
1422
+ if(!noFocusElem){
1423
+ this.setFocus(visual, offset);
1424
+ }
1425
+ },
1426
+ getOffsetFromBody: function(elem){
1427
+ return webshims.getRelOffset(errorBubble, elem);
1428
+ },
1429
+ setFocus: function(visual, offset){
1430
+ var focusElem = $(visual).getShadowFocusElement();
1431
+ var scrollTop = webshims.scrollRoot.scrollTop();
1432
+ var elemTop = ((offset || focusElem.offset()).top) - 30;
1433
+ var smooth;
1434
+
1435
+ if(webshims.getID && alertElem == 'label'){
1436
+ errorBubble.attr('for', webshims.getID(focusElem));
1437
+ }
1438
+
1439
+ if(scrollTop > elemTop){
1440
+ webshims.scrollRoot.animate(
1441
+ {scrollTop: elemTop - 5},
1442
+ {
1443
+ queue: false,
1444
+ duration: Math.max( Math.min( 600, (scrollTop - elemTop) * 1.5 ), 80 )
1445
+ }
1446
+ );
1447
+ smooth = true;
1448
+ }
1449
+ try {
1450
+ focusElem[0].focus();
1451
+ } catch(e){}
1452
+ if(smooth){
1453
+ webshims.scrollRoot.scrollTop(scrollTop);
1454
+ setTimeout(function(){
1455
+ webshims.scrollRoot.scrollTop(scrollTop);
1456
+ }, 0);
1457
+ }
1458
+ setTimeout(function(){
1459
+ $(document).on('focusout.validityalert', boundHide);
1460
+ }, 10);
1461
+ $(window).triggerHandler('reposoverlay');
1462
+ },
1463
+ getMessage: function(elem, message){
1464
+ if (!message) {
1465
+ message = getContentValidationMessage(elem[0]) || elem.prop('customValidationMessage') || elem.prop('validationMessage');
1466
+ }
1467
+ if (message) {
1468
+ $('span.va-box', errorBubble).text(message);
1469
+ }
1470
+ else {
1471
+ this.hide();
1472
+ }
1473
+ },
1474
+ position: function(elem, offset){
1475
+ offset = offset ? $.extend({}, offset) : api.getOffsetFromBody(elem);
1476
+ offset.top += elem.outerHeight();
1477
+ errorBubble.css(offset);
1478
+ },
1479
+ show: function(){
1480
+ if(errorBubble.css('display') === 'none'){
1481
+ errorBubble.css({opacity: 0}).show();
1482
+ }
1483
+ errorBubble.addClass('va-visible').fadeTo(400, 1);
1484
+ },
1485
+ hide: function(){
1486
+ errorBubble.removeClass('va-visible').fadeOut();
1487
+ },
1488
+ clear: function(){
1489
+ clearTimeout(focusTimer);
1490
+ clearTimeout(hideTimer);
1491
+ $(document).unbind('.validityalert');
1492
+ $(window).unbind('.validityalert');
1493
+ errorBubble.stop().removeAttr('for');
1494
+ },
1495
+ _create: function(){
1496
+ if(errorBubble){return;}
1497
+ errorBubble = api.errorBubble = $('<'+alertElem+' class="validity-alert-wrapper" role="alert"><span class="validity-alert"><span class="va-arrow"><span class="va-arrow-box"></span></span><span class="va-box"></span></span></'+alertElem+'>').css({position: 'absolute', display: 'none'});
1498
+ webshims.ready('DOM', function(){
1499
+ errorBubble.appendTo('body');
1500
+ if($.fn.bgIframe && $.browser.msie && parseInt($.browser.version, 10) < 7){
1501
+ errorBubble.bgIframe();
1502
+ }
1503
+ });
1504
+ }
1505
+ };
1506
+
1507
+
1508
+ boundHide = $.proxy(api, 'hide');
1509
+
1510
+ return api;
1511
+ })();
1512
+
1513
+
1514
+ /* extension, but also used to fix native implementation workaround/bugfixes */
1515
+ (function(){
1516
+ var firstEvent,
1517
+ invalids = [],
1518
+ stopSubmitTimer,
1519
+ form
1520
+ ;
1521
+
1522
+ $(document).on('invalid', function(e){
1523
+ if(e.wrongWebkitInvalid){return;}
1524
+ var jElm = $(e.target);
1525
+ var shadowElem = jElm.getShadowElement();
1526
+ if(!shadowElem.hasClass(invalidClass)){
1527
+ shadowElem.addClass(invalidClasses).removeClass(validClasses);
1528
+ setTimeout(function(){
1529
+ $(e.target).trigger('changedinvalid').trigger('changedvaliditystate');
1530
+ }, 0);
1531
+ }
1532
+
1533
+ if(!firstEvent){
1534
+ //trigger firstinvalid
1535
+ firstEvent = $.Event('firstinvalid');
1536
+ firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
1537
+ var firstSystemInvalid = $.Event('firstinvalidsystem');
1538
+ $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
1539
+ jElm.trigger(firstEvent);
1540
+ }
1541
+
1542
+ //if firstinvalid was prevented all invalids will be also prevented
1543
+ if( firstEvent && firstEvent.isDefaultPrevented() ){
1544
+ e.preventDefault();
1545
+ }
1546
+ invalids.push(e.target);
1547
+ e.extraData = 'fix';
1548
+ clearTimeout(stopSubmitTimer);
1549
+ stopSubmitTimer = setTimeout(function(){
1550
+ var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
1551
+ //reset firstinvalid
1552
+ firstEvent = false;
1553
+ invalids = [];
1554
+ $(e.target).trigger(lastEvent, lastEvent);
1555
+ }, 9);
1556
+ jElm = null;
1557
+ shadowElem = null;
1558
+ });
1559
+ })();
1560
+
1561
+ $.fn.getErrorMessage = function(){
1562
+ var message = '';
1563
+ var elem = this[0];
1564
+ if(elem){
1565
+ message = getContentValidationMessage(elem) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
1566
+ }
1567
+ return message;
1568
+ };
1569
+
1570
+ if(options.replaceValidationUI){
1571
+ webshims.ready('DOM forms', function(){
1572
+ $(document).on('firstinvalid', function(e){
1573
+ if(!e.isInvalidUIPrevented()){
1574
+ e.preventDefault();
1575
+ $.webshims.validityAlert.showFor( e.target );
1576
+ }
1577
+ });
1578
+ });
1579
+ }
1580
+
1581
+ });
1582
+ jQuery.webshims.register('form-datalist', function($, webshims, window, document, undefined){
1583
+ "use strict";
1584
+ var doc = document;
1585
+
1586
+ /*
1587
+ * implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
1588
+ */
1589
+ webshims.propTypes.element = function(descs){
1590
+ webshims.createPropDefault(descs, 'attr');
1591
+ if(descs.prop){return;}
1592
+ descs.prop = {
1593
+ get: function(){
1594
+ var elem = descs.attr.get.call(this);
1595
+ if(elem){
1596
+ elem = document.getElementById(elem);
1597
+ if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
1598
+ elem = null;
1599
+ }
1600
+ }
1601
+ return elem || null;
1602
+ },
1603
+ writeable: false
1604
+ };
1605
+ };
1606
+
1607
+
1608
+ /*
1609
+ * Implements datalist element and list attribute
1610
+ */
1611
+
1612
+ (function(){
1613
+ var formsCFG = $.webshims.cfg.forms;
1614
+ var listSupport = Modernizr.input.list;
1615
+ if(listSupport && !formsCFG.customDatalist){return;}
1616
+
1617
+ var initializeDatalist = function(){
1618
+
1619
+
1620
+ if(!listSupport){
1621
+ webshims.defineNodeNameProperty('datalist', 'options', {
1622
+ prop: {
1623
+ writeable: false,
1624
+ get: function(){
1625
+ var elem = this;
1626
+ var select = $('select', elem);
1627
+ var options;
1628
+ if(select[0]){
1629
+ options = select[0].options;
1630
+ } else {
1631
+ options = $('option', elem).get();
1632
+ if(options.length){
1633
+ webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
1634
+ }
1635
+ }
1636
+ return options;
1637
+ }
1638
+ }
1639
+ });
1640
+ }
1641
+
1642
+ var inputListProto = {
1643
+ //override autocomplete
1644
+ autocomplete: {
1645
+ attr: {
1646
+ get: function(){
1647
+ var elem = this;
1648
+ var data = $.data(elem, 'datalistWidget');
1649
+ if(data){
1650
+ return data._autocomplete;
1651
+ }
1652
+ return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
1653
+ },
1654
+ set: function(value){
1655
+ var elem = this;
1656
+ var data = $.data(elem, 'datalistWidget');
1657
+ if(data){
1658
+ data._autocomplete = value;
1659
+ if(value == 'off'){
1660
+ data.hideList();
1661
+ }
1662
+ } else {
1663
+ if('autocomplete' in elem){
1664
+ elem.autocomplete = value;
1665
+ } else {
1666
+ elem.setAttribute('autocomplete', value);
1667
+ }
1668
+ }
1669
+ }
1670
+ }
1671
+ }
1672
+ };
1673
+
1674
+ // if(formsCFG.customDatalist && (!listSupport || !('selectedOption') in $('<input />')[0])){
1675
+ // //currently not supported x-browser (FF4 has not implemented and is not polyfilled )
1676
+ // inputListProto.selectedOption = {
1677
+ // prop: {
1678
+ // writeable: false,
1679
+ // get: function(){
1680
+ // var elem = this;
1681
+ // var list = $.prop(elem, 'list');
1682
+ // var ret = null;
1683
+ // var value, options;
1684
+ // if(!list){return ret;}
1685
+ // value = $.prop(elem, 'value');
1686
+ // if(!value){return ret;}
1687
+ // options = $.prop(list, 'options');
1688
+ // if(!options.length){return ret;}
1689
+ // $.each(options, function(i, option){
1690
+ // if(value == $.prop(option, 'value')){
1691
+ // ret = option;
1692
+ // return false;
1693
+ // }
1694
+ // });
1695
+ // return ret;
1696
+ // }
1697
+ // }
1698
+ // };
1699
+ // }
1700
+
1701
+ if(!listSupport){
1702
+ inputListProto['list'] = {
1703
+ attr: {
1704
+ get: function(){
1705
+ var val = webshims.contentAttr(this, 'list');
1706
+ return (val == null) ? undefined : val;
1707
+ },
1708
+ set: function(value){
1709
+ var elem = this;
1710
+ webshims.contentAttr(elem, 'list', value);
1711
+ webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1712
+ }
1713
+ },
1714
+ initAttr: true,
1715
+ reflect: true,
1716
+ propType: 'element',
1717
+ propNodeName: 'datalist'
1718
+ };
1719
+ } else {
1720
+ //options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
1721
+ if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
1722
+ webshims.defineNodeNameProperty('datalist', 'options', {
1723
+ prop: {
1724
+ writeable: false,
1725
+ get: function(){
1726
+ var options = this.options || [];
1727
+ if(!options.length){
1728
+ var elem = this;
1729
+ var select = $('select', elem);
1730
+ if(select[0] && select[0].options && select[0].options.length){
1731
+ options = select[0].options;
1732
+ }
1733
+ }
1734
+ return options;
1735
+ }
1736
+ }
1737
+ });
1738
+ }
1739
+ inputListProto['list'] = {
1740
+ attr: {
1741
+ get: function(){
1742
+ var val = webshims.contentAttr(this, 'list');
1743
+ if(val != null){
1744
+ this.removeAttribute('list');
1745
+ } else {
1746
+ val = $.data(this, 'datalistListAttr');
1747
+ }
1748
+
1749
+ return (val == null) ? undefined : val;
1750
+ },
1751
+ set: function(value){
1752
+ var elem = this;
1753
+ $.data(elem, 'datalistListAttr', value);
1754
+ webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1755
+ }
1756
+ },
1757
+ initAttr: true,
1758
+ reflect: true,
1759
+ propType: 'element',
1760
+ propNodeName: 'datalist'
1761
+ };
1762
+ }
1763
+
1764
+
1765
+ webshims.defineNodeNameProperties('input', inputListProto);
1766
+
1767
+ if($.event.customEvent){
1768
+ $.event.customEvent.updateDatalist = true;
1769
+ $.event.customEvent.updateInput = true;
1770
+ $.event.customEvent.datalistselect = true;
1771
+ }
1772
+ webshims.addReady(function(context, contextElem){
1773
+ contextElem
1774
+ .filter('datalist > select, datalist, datalist > option, datalist > select > option')
1775
+ .closest('datalist')
1776
+ .triggerHandler('updateDatalist')
1777
+ ;
1778
+
1779
+ });
1780
+
1781
+
1782
+ };
1783
+
1784
+
1785
+ /*
1786
+ * ShadowList
1787
+ */
1788
+ var listidIndex = 0;
1789
+
1790
+ var noDatalistSupport = {
1791
+ submit: 1,
1792
+ button: 1,
1793
+ reset: 1,
1794
+ hidden: 1,
1795
+
1796
+ //ToDo
1797
+ range: 1,
1798
+ date: 1
1799
+ };
1800
+ var lteie6 = ($.browser.msie && parseInt($.browser.version, 10) < 7);
1801
+ var globStoredOptions = {};
1802
+ var getStoredOptions = function(name){
1803
+ if(!name){return [];}
1804
+ if(globStoredOptions[name]){
1805
+ return globStoredOptions[name];
1806
+ }
1807
+ var data;
1808
+ try {
1809
+ data = JSON.parse(localStorage.getItem('storedDatalistOptions'+name));
1810
+ } catch(e){}
1811
+ globStoredOptions[name] = data || [];
1812
+ return data || [];
1813
+ };
1814
+ var storeOptions = function(name, val){
1815
+ if(!name){return;}
1816
+ val = val || [];
1817
+ try {
1818
+ localStorage.setItem( 'storedDatalistOptions'+name, JSON.stringify(val) );
1819
+ } catch(e){}
1820
+ };
1821
+
1822
+ var getText = function(elem){
1823
+ return (elem.textContent || elem.innerText || $.text([ elem ]) || '');
1824
+ };
1825
+
1826
+ var shadowListProto = {
1827
+ _create: function(opts){
1828
+
1829
+ if(noDatalistSupport[$.prop(opts.input, 'type')]){return;}
1830
+ var datalist = opts.datalist;
1831
+ var data = $.data(opts.input, 'datalistWidget');
1832
+ if(datalist && data && data.datalist !== datalist){
1833
+ data.datalist = datalist;
1834
+ data.id = opts.id;
1835
+
1836
+ data.shadowList.prop('className', 'datalist-polyfill '+ (data.datalist.className || '') + ' '+ data.datalist.id +'-shadowdom');
1837
+ if(formsCFG.positionDatalist){
1838
+ data.shadowList.insertAfter(opts.input);
1839
+ } else {
1840
+ data.shadowList.appendTo('body');
1841
+ }
1842
+ $(data.datalist)
1843
+ .off('updateDatalist.datalistWidget')
1844
+ .on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
1845
+ ;
1846
+ data._resetListCached();
1847
+ return;
1848
+ } else if(!datalist){
1849
+ if(data){
1850
+ data.destroy();
1851
+ }
1852
+ return;
1853
+ } else if(data && data.datalist === datalist){
1854
+ return;
1855
+ }
1856
+ listidIndex++;
1857
+ var that = this;
1858
+ this.hideList = $.proxy(that, 'hideList');
1859
+ this.timedHide = function(){
1860
+ clearTimeout(that.hideTimer);
1861
+ that.hideTimer = setTimeout(that.hideList, 9);
1862
+ };
1863
+ this.datalist = datalist;
1864
+ this.id = opts.id;
1865
+ this.hasViewableData = true;
1866
+ this._autocomplete = $.attr(opts.input, 'autocomplete');
1867
+ $.data(opts.input, 'datalistWidget', this);
1868
+ this.shadowList = $('<div class="datalist-polyfill '+ (this.datalist.className || '') + ' '+ this.datalist.id +'-shadowdom' +'" />');
1869
+
1870
+ if(formsCFG.positionDatalist || $(opts.input).hasClass('position-datalist')){
1871
+ this.shadowList.insertAfter(opts.input);
1872
+ } else {
1873
+ this.shadowList.appendTo('body');
1874
+ }
1875
+
1876
+ this.index = -1;
1877
+ this.input = opts.input;
1878
+ this.arrayOptions = [];
1879
+
1880
+ this.shadowList
1881
+ .delegate('li', 'mouseenter.datalistWidget mousedown.datalistWidget click.datalistWidget', function(e){
1882
+ var items = $('li:not(.hidden-item)', that.shadowList);
1883
+ var select = (e.type == 'mousedown' || e.type == 'click');
1884
+ that.markItem(items.index(e.currentTarget), select, items);
1885
+ if(e.type == 'click'){
1886
+ that.hideList();
1887
+ if(formsCFG.customDatalist){
1888
+ $(opts.input).trigger('datalistselect');
1889
+ }
1890
+ }
1891
+ return (e.type != 'mousedown');
1892
+ })
1893
+ .on('focusout', this.timedHide)
1894
+ ;
1895
+
1896
+ opts.input.setAttribute('autocomplete', 'off');
1897
+
1898
+ $(opts.input)
1899
+ .attr({
1900
+ //role: 'combobox',
1901
+ 'aria-haspopup': 'true'
1902
+ })
1903
+ .on({
1904
+ 'input.datalistWidget': function(){
1905
+ if(!that.triggeredByDatalist){
1906
+ that.changedValue = false;
1907
+ that.showHideOptions();
1908
+ }
1909
+ },
1910
+ 'keydown.datalistWidget': function(e){
1911
+ var keyCode = e.keyCode;
1912
+ var activeItem;
1913
+ var items;
1914
+ if(keyCode == 40 && !that.showList()){
1915
+ that.markItem(that.index + 1, true);
1916
+ return false;
1917
+ }
1918
+
1919
+ if(!that.isListVisible){return;}
1920
+
1921
+
1922
+ if(keyCode == 38){
1923
+ that.markItem(that.index - 1, true);
1924
+ return false;
1925
+ }
1926
+ if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
1927
+ that.markItem(0, true);
1928
+ return false;
1929
+ }
1930
+ if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
1931
+ items = $('li:not(.hidden-item)', that.shadowList);
1932
+ that.markItem(items.length - 1, true, items);
1933
+ return false;
1934
+ }
1935
+ if(keyCode == 13 || keyCode == 27){
1936
+ if (keyCode == 13){
1937
+ activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
1938
+ that.changeValue( $('li.active-item:not(.hidden-item)', that.shadowList) );
1939
+ }
1940
+ that.hideList();
1941
+ if(formsCFG.customDatalist && activeItem && activeItem[0]){
1942
+ $(opts.input).trigger('datalistselect');
1943
+ }
1944
+ return false;
1945
+ }
1946
+ },
1947
+ 'focus.datalistWidget': function(){
1948
+ if($(this).hasClass('list-focus')){
1949
+ that.showList();
1950
+ }
1951
+ },
1952
+ 'mousedown.datalistWidget': function(){
1953
+ if($(this).is(':focus')){
1954
+ that.showList();
1955
+ }
1956
+ },
1957
+ 'blur.datalistWidget': this.timedHide
1958
+ })
1959
+ ;
1960
+
1961
+
1962
+ $(this.datalist)
1963
+ .off('updateDatalist.datalistWidget')
1964
+ .on('updateDatalist.datalistWidget', $.proxy(this, '_resetListCached'))
1965
+ ;
1966
+
1967
+ this._resetListCached();
1968
+
1969
+ if(opts.input.form && (opts.input.name || opts.input.id)){
1970
+ $(opts.input.form).on('submit.datalistWidget'+opts.input.id, function(){
1971
+ if(!$(opts.input).hasClass('no-datalist-cache') && that._autocomplete != 'off'){
1972
+ var val = $.prop(opts.input, 'value');
1973
+ var name = (opts.input.name || opts.input.id) + $.prop(opts.input, 'type');
1974
+ if(!that.storedOptions){
1975
+ that.storedOptions = getStoredOptions( name );
1976
+ }
1977
+ if(val && that.storedOptions.indexOf(val) == -1){
1978
+ that.storedOptions.push(val);
1979
+ storeOptions(name, that.storedOptions );
1980
+ }
1981
+ }
1982
+ });
1983
+ }
1984
+ $(window).on('unload.datalist'+this.id+' beforeunload.datalist'+this.id, function(){
1985
+ that.destroy();
1986
+ });
1987
+ },
1988
+ destroy: function(){
1989
+ var autocomplete = $.attr(this.input, 'autocomplete');
1990
+ $(this.input)
1991
+ .off('.datalistWidget')
1992
+ .removeData('datalistWidget')
1993
+ ;
1994
+ this.shadowList.remove();
1995
+ $(document).off('.datalist'+this.id);
1996
+ $(window).off('.datalist'+this.id);
1997
+ if(this.input.form && this.input.id){
1998
+ $(this.input.form).off('submit.datalistWidget'+this.input.id);
1999
+ }
2000
+ this.input.removeAttribute('aria-haspopup');
2001
+ if(autocomplete === undefined){
2002
+ this.input.removeAttribute('autocomplete');
2003
+ } else {
2004
+ $(this.input).attr('autocomplete', autocomplete);
2005
+ }
2006
+ },
2007
+ _resetListCached: function(e){
2008
+ var that = this;
2009
+ var forceShow;
2010
+ this.needsUpdate = true;
2011
+ this.lastUpdatedValue = false;
2012
+ this.lastUnfoundValue = '';
2013
+
2014
+ if(!this.updateTimer){
2015
+ if(window.QUnit || (forceShow = (e && document.activeElement == that.input))){
2016
+ that.updateListOptions(forceShow);
2017
+ } else {
2018
+ webshims.ready('WINDOWLOAD', function(){
2019
+ that.updateTimer = setTimeout(function(){
2020
+ that.updateListOptions();
2021
+ that = null;
2022
+ listidIndex = 1;
2023
+ }, 200 + (100 * listidIndex));
2024
+ });
2025
+ }
2026
+ }
2027
+ },
2028
+ maskHTML: function(str){
2029
+ return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
2030
+ },
2031
+ updateListOptions: function(_forceShow){
2032
+ this.needsUpdate = false;
2033
+ clearTimeout(this.updateTimer);
2034
+ this.updateTimer = false;
2035
+ this.shadowList
2036
+ .css({
2037
+ fontSize: $.css(this.input, 'fontSize'),
2038
+ fontFamily: $.css(this.input, 'fontFamily')
2039
+ })
2040
+ ;
2041
+ this.searchStart = formsCFG.customDatalist && $(this.input).hasClass('search-start');
2042
+
2043
+ var list = [];
2044
+
2045
+ var values = [];
2046
+ var allOptions = [];
2047
+ var rElem, rItem, rOptions, rI, rLen, item;
2048
+ for(rOptions = $.prop(this.datalist, 'options'), rI = 0, rLen = rOptions.length; rI < rLen; rI++){
2049
+ rElem = rOptions[rI];
2050
+ if(rElem.disabled){return;}
2051
+ rItem = {
2052
+ value: $(rElem).val() || '',
2053
+ text: $.trim($.attr(rElem, 'label') || getText(rElem)),
2054
+ className: rElem.className || '',
2055
+ style: $.attr(rElem, 'style') || ''
2056
+ };
2057
+ if(!rItem.text){
2058
+ rItem.text = rItem.value;
2059
+ } else if(rItem.text != rItem.value){
2060
+ rItem.className += ' different-label-value';
2061
+ }
2062
+ values[rI] = rItem.value;
2063
+ allOptions[rI] = rItem;
2064
+ }
2065
+
2066
+ if(!this.storedOptions){
2067
+ this.storedOptions = ($(this.input).hasClass('no-datalist-cache') || this._autocomplete == 'off') ? [] : getStoredOptions((this.input.name || this.input.id) + $.prop(this.input, 'type'));
2068
+ }
2069
+
2070
+ this.storedOptions.forEach(function(val, i){
2071
+ if(values.indexOf(val) == -1){
2072
+ allOptions.push({value: val, text: val, className: 'stored-suggest', style: ''});
2073
+ }
2074
+ });
2075
+
2076
+ for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
2077
+ item = allOptions[rI];
2078
+ list[rI] = '<li class="'+ item.className +'" style="'+ item.style +'" tabindex="-1" role="listitem"><span class="option-label">'+ this.maskHTML(item.text) +'</span> <span class="option-value">'+ this.maskHTML(item.value) +'</span></li>';
2079
+ }
2080
+
2081
+ this.arrayOptions = allOptions;
2082
+ this.shadowList.html('<div class="datalist-outer-box"><div class="datalist-box"><ul role="list">'+ list.join("\n") +'</ul></div></div>');
2083
+
2084
+ if($.fn.bgIframe && lteie6){
2085
+ this.shadowList.bgIframe();
2086
+ }
2087
+
2088
+ if(_forceShow || this.isListVisible){
2089
+ this.showHideOptions();
2090
+ }
2091
+ },
2092
+ showHideOptions: function(_fromShowList){
2093
+ var value = $.prop(this.input, 'value').toLowerCase();
2094
+ //first check prevent infinite loop, second creates simple lazy optimization
2095
+ if(value === this.lastUpdatedValue || (this.lastUnfoundValue && value.indexOf(this.lastUnfoundValue) === 0)){
2096
+ return;
2097
+ }
2098
+
2099
+ this.lastUpdatedValue = value;
2100
+ var found = false;
2101
+ var startSearch = this.searchStart;
2102
+ var lis = $('li', this.shadowList);
2103
+ if(value){
2104
+ this.arrayOptions.forEach(function(item, i){
2105
+ var search;
2106
+ if(!('lowerText' in item)){
2107
+ if(item.text != item.value){
2108
+ item.lowerText = item.value.toLowerCase() + item.text.toLowerCase();
2109
+ } else {
2110
+ item.lowerText = item.text.toLowerCase();
2111
+ }
2112
+ }
2113
+ search = item.lowerText.indexOf(value);
2114
+ search = startSearch ? !search : search !== -1;
2115
+ if(search){
2116
+ $(lis[i]).removeClass('hidden-item');
2117
+ found = true;
2118
+ } else {
2119
+ $(lis[i]).addClass('hidden-item');
2120
+ }
2121
+ });
2122
+ } else if(lis.length) {
2123
+ lis.removeClass('hidden-item');
2124
+ found = true;
2125
+ }
2126
+
2127
+ this.hasViewableData = found;
2128
+ if(!_fromShowList && found){
2129
+ this.showList();
2130
+ }
2131
+ if(!found){
2132
+ this.lastUnfoundValue = value;
2133
+ this.hideList();
2134
+ }
2135
+ },
2136
+ setPos: function(){
2137
+ this.shadowList.css({marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0});
2138
+ var css = (formsCFG.positionDatalist) ? $(this.input).position() : webshims.getRelOffset(this.shadowList, this.input);
2139
+ css.top += $(this.input).outerHeight();
2140
+ css.width = $(this.input).outerWidth() - (parseInt(this.shadowList.css('borderLeftWidth'), 10) || 0) - (parseInt(this.shadowList.css('borderRightWidth'), 10) || 0);
2141
+ this.shadowList.css({marginTop: '', marginLeft: '', marginRight: '', marginBottom: ''}).css(css);
2142
+ return css;
2143
+ },
2144
+ showList: function(){
2145
+ if(this.isListVisible){return false;}
2146
+ if(this.needsUpdate){
2147
+ this.updateListOptions();
2148
+ }
2149
+ this.showHideOptions(true);
2150
+ if(!this.hasViewableData){return false;}
2151
+ this.isListVisible = true;
2152
+ var that = this;
2153
+
2154
+ that.setPos();
2155
+ that.shadowList.addClass('datalist-visible').find('li.active-item').removeClass('active-item');
2156
+
2157
+ $(window).unbind('.datalist'+that.id);
2158
+ $(document)
2159
+ .off('.datalist'+that.id)
2160
+ .on('mousedown.datalist'+that.id +' focusin.datalist'+that.id, function(e){
2161
+ if(e.target === that.input || that.shadowList[0] === e.target || $.contains( that.shadowList[0], e.target )){
2162
+ clearTimeout(that.hideTimer);
2163
+ setTimeout(function(){
2164
+ clearTimeout(that.hideTimer);
2165
+ }, 9);
2166
+ } else {
2167
+ that.timedHide();
2168
+ }
2169
+ })
2170
+ .on('updateshadowdom.datalist'+that.id, function(){
2171
+ that.setPos();
2172
+ })
2173
+ ;
2174
+ return true;
2175
+ },
2176
+ hideList: function(){
2177
+ if(!this.isListVisible){return false;}
2178
+ var that = this;
2179
+ var triggerChange = function(e){
2180
+ if(that.changedValue){
2181
+ $(that.input).trigger('change');
2182
+ }
2183
+ that.changedValue = false;
2184
+ };
2185
+
2186
+ that.shadowList.removeClass('datalist-visible list-item-active');
2187
+ that.index = -1;
2188
+ that.isListVisible = false;
2189
+ if(that.changedValue){
2190
+ that.triggeredByDatalist = true;
2191
+ webshims.triggerInlineForm && webshims.triggerInlineForm(that.input, 'input');
2192
+ if($(that.input).is(':focus')){
2193
+ $(that.input).one('blur', triggerChange);
2194
+ } else {
2195
+ triggerChange();
2196
+ }
2197
+ that.triggeredByDatalist = false;
2198
+ }
2199
+ $(document).unbind('.datalist'+that.id);
2200
+ $(window)
2201
+ .off('.datalist'+that.id)
2202
+ .one('resize.datalist'+that.id, function(){
2203
+ that.shadowList.css({top: 0, left: 0});
2204
+ })
2205
+ ;
2206
+ return true;
2207
+ },
2208
+ scrollIntoView: function(elem){
2209
+ var ul = $('ul', this.shadowList);
2210
+ var div = $('div.datalist-box', this.shadowList);
2211
+ var elemPos = elem.position();
2212
+ var containerHeight;
2213
+ elemPos.top -= (parseInt(ul.css('paddingTop'), 10) || 0) + (parseInt(ul.css('marginTop'), 10) || 0) + (parseInt(ul.css('borderTopWidth'), 10) || 0);
2214
+ if(elemPos.top < 0){
2215
+ div.scrollTop( div.scrollTop() + elemPos.top - 2);
2216
+ return;
2217
+ }
2218
+ elemPos.top += elem.outerHeight();
2219
+ containerHeight = div.height();
2220
+ if(elemPos.top > containerHeight){
2221
+ div.scrollTop( div.scrollTop() + (elemPos.top - containerHeight) + 2);
2222
+ }
2223
+ },
2224
+ changeValue: function(activeItem){
2225
+ if(!activeItem[0]){return;}
2226
+ var newValue = $('span.option-value', activeItem).text();
2227
+ var oldValue = $.prop(this.input, 'value');
2228
+ if(newValue != oldValue){
2229
+ $(this.input)
2230
+ .prop('value', newValue)
2231
+ .triggerHandler('updateInput')
2232
+ ;
2233
+ this.changedValue = true;
2234
+ }
2235
+ },
2236
+ markItem: function(index, doValue, items){
2237
+ var activeItem;
2238
+ var goesUp;
2239
+
2240
+ items = items || $('li:not(.hidden-item)', this.shadowList);
2241
+ if(!items.length){return;}
2242
+ if(index < 0){
2243
+ index = items.length - 1;
2244
+ } else if(index >= items.length){
2245
+ index = 0;
2246
+ }
2247
+ items.removeClass('active-item');
2248
+ this.shadowList.addClass('list-item-active');
2249
+ activeItem = items.filter(':eq('+ index +')').addClass('active-item');
2250
+
2251
+ if(doValue){
2252
+ this.changeValue(activeItem);
2253
+ this.scrollIntoView(activeItem);
2254
+ }
2255
+ this.index = index;
2256
+ }
2257
+ };
2258
+
2259
+ //init datalist update
2260
+ initializeDatalist();
2261
+ })();
2262
+
2239
2263
  });