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,1632 +1,1632 @@
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
- jQuery.webshims.register('form-datalist', function($, webshims, window, document, undefined){
952
- "use strict";
953
- var doc = document;
954
-
955
- /*
956
- * implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
957
- */
958
- webshims.propTypes.element = function(descs){
959
- webshims.createPropDefault(descs, 'attr');
960
- if(descs.prop){return;}
961
- descs.prop = {
962
- get: function(){
963
- var elem = descs.attr.get.call(this);
964
- if(elem){
965
- elem = document.getElementById(elem);
966
- if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
967
- elem = null;
968
- }
969
- }
970
- return elem || null;
971
- },
972
- writeable: false
973
- };
974
- };
975
-
976
-
977
- /*
978
- * Implements datalist element and list attribute
979
- */
980
-
981
- (function(){
982
- var formsCFG = $.webshims.cfg.forms;
983
- var listSupport = Modernizr.input.list;
984
- if(listSupport && !formsCFG.customDatalist){return;}
985
-
986
- var initializeDatalist = function(){
987
-
988
-
989
- if(!listSupport){
990
- webshims.defineNodeNameProperty('datalist', 'options', {
991
- prop: {
992
- writeable: false,
993
- get: function(){
994
- var elem = this;
995
- var select = $('select', elem);
996
- var options;
997
- if(select[0]){
998
- options = select[0].options;
999
- } else {
1000
- options = $('option', elem).get();
1001
- if(options.length){
1002
- webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
1003
- }
1004
- }
1005
- return options;
1006
- }
1007
- }
1008
- });
1009
- }
1010
-
1011
- var inputListProto = {
1012
- //override autocomplete
1013
- autocomplete: {
1014
- attr: {
1015
- get: function(){
1016
- var elem = this;
1017
- var data = $.data(elem, 'datalistWidget');
1018
- if(data){
1019
- return data._autocomplete;
1020
- }
1021
- return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
1022
- },
1023
- set: function(value){
1024
- var elem = this;
1025
- var data = $.data(elem, 'datalistWidget');
1026
- if(data){
1027
- data._autocomplete = value;
1028
- if(value == 'off'){
1029
- data.hideList();
1030
- }
1031
- } else {
1032
- if('autocomplete' in elem){
1033
- elem.autocomplete = value;
1034
- } else {
1035
- elem.setAttribute('autocomplete', value);
1036
- }
1037
- }
1038
- }
1039
- }
1040
- }
1041
- };
1042
-
1043
- // if(formsCFG.customDatalist && (!listSupport || !('selectedOption') in $('<input />')[0])){
1044
- // //currently not supported x-browser (FF4 has not implemented and is not polyfilled )
1045
- // inputListProto.selectedOption = {
1046
- // prop: {
1047
- // writeable: false,
1048
- // get: function(){
1049
- // var elem = this;
1050
- // var list = $.prop(elem, 'list');
1051
- // var ret = null;
1052
- // var value, options;
1053
- // if(!list){return ret;}
1054
- // value = $.prop(elem, 'value');
1055
- // if(!value){return ret;}
1056
- // options = $.prop(list, 'options');
1057
- // if(!options.length){return ret;}
1058
- // $.each(options, function(i, option){
1059
- // if(value == $.prop(option, 'value')){
1060
- // ret = option;
1061
- // return false;
1062
- // }
1063
- // });
1064
- // return ret;
1065
- // }
1066
- // }
1067
- // };
1068
- // }
1069
-
1070
- if(!listSupport){
1071
- inputListProto['list'] = {
1072
- attr: {
1073
- get: function(){
1074
- var val = webshims.contentAttr(this, 'list');
1075
- return (val == null) ? undefined : val;
1076
- },
1077
- set: function(value){
1078
- var elem = this;
1079
- webshims.contentAttr(elem, 'list', value);
1080
- webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1081
- }
1082
- },
1083
- initAttr: true,
1084
- reflect: true,
1085
- propType: 'element',
1086
- propNodeName: 'datalist'
1087
- };
1088
- } else {
1089
- //options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
1090
- if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
1091
- webshims.defineNodeNameProperty('datalist', 'options', {
1092
- prop: {
1093
- writeable: false,
1094
- get: function(){
1095
- var options = this.options || [];
1096
- if(!options.length){
1097
- var elem = this;
1098
- var select = $('select', elem);
1099
- if(select[0] && select[0].options && select[0].options.length){
1100
- options = select[0].options;
1101
- }
1102
- }
1103
- return options;
1104
- }
1105
- }
1106
- });
1107
- }
1108
- inputListProto['list'] = {
1109
- attr: {
1110
- get: function(){
1111
- var val = webshims.contentAttr(this, 'list');
1112
- if(val != null){
1113
- this.removeAttribute('list');
1114
- } else {
1115
- val = $.data(this, 'datalistListAttr');
1116
- }
1117
-
1118
- return (val == null) ? undefined : val;
1119
- },
1120
- set: function(value){
1121
- var elem = this;
1122
- $.data(elem, 'datalistListAttr', value);
1123
- webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1124
- }
1125
- },
1126
- initAttr: true,
1127
- reflect: true,
1128
- propType: 'element',
1129
- propNodeName: 'datalist'
1130
- };
1131
- }
1132
-
1133
-
1134
- webshims.defineNodeNameProperties('input', inputListProto);
1135
-
1136
- if($.event.customEvent){
1137
- $.event.customEvent.updateDatalist = true;
1138
- $.event.customEvent.updateInput = true;
1139
- $.event.customEvent.datalistselect = true;
1140
- }
1141
- webshims.addReady(function(context, contextElem){
1142
- contextElem
1143
- .filter('datalist > select, datalist, datalist > option, datalist > select > option')
1144
- .closest('datalist')
1145
- .triggerHandler('updateDatalist')
1146
- ;
1147
-
1148
- });
1149
-
1150
-
1151
- };
1152
-
1153
-
1154
- /*
1155
- * ShadowList
1156
- */
1157
- var listidIndex = 0;
1158
-
1159
- var noDatalistSupport = {
1160
- submit: 1,
1161
- button: 1,
1162
- reset: 1,
1163
- hidden: 1,
1164
-
1165
- //ToDo
1166
- range: 1,
1167
- date: 1
1168
- };
1169
- var lteie6 = ($.browser.msie && parseInt($.browser.version, 10) < 7);
1170
- var globStoredOptions = {};
1171
- var getStoredOptions = function(name){
1172
- if(!name){return [];}
1173
- if(globStoredOptions[name]){
1174
- return globStoredOptions[name];
1175
- }
1176
- var data;
1177
- try {
1178
- data = JSON.parse(localStorage.getItem('storedDatalistOptions'+name));
1179
- } catch(e){}
1180
- globStoredOptions[name] = data || [];
1181
- return data || [];
1182
- };
1183
- var storeOptions = function(name, val){
1184
- if(!name){return;}
1185
- val = val || [];
1186
- try {
1187
- localStorage.setItem( 'storedDatalistOptions'+name, JSON.stringify(val) );
1188
- } catch(e){}
1189
- };
1190
-
1191
- var getText = function(elem){
1192
- return (elem.textContent || elem.innerText || $.text([ elem ]) || '');
1193
- };
1194
-
1195
- var shadowListProto = {
1196
- _create: function(opts){
1197
-
1198
- if(noDatalistSupport[$.prop(opts.input, 'type')]){return;}
1199
- var datalist = opts.datalist;
1200
- var data = $.data(opts.input, 'datalistWidget');
1201
- if(datalist && data && data.datalist !== datalist){
1202
- data.datalist = datalist;
1203
- data.id = opts.id;
1204
-
1205
- data.shadowList.prop('className', 'datalist-polyfill '+ (data.datalist.className || '') + ' '+ data.datalist.id +'-shadowdom');
1206
- if(formsCFG.positionDatalist){
1207
- data.shadowList.insertAfter(opts.input);
1208
- } else {
1209
- data.shadowList.appendTo('body');
1210
- }
1211
- $(data.datalist)
1212
- .off('updateDatalist.datalistWidget')
1213
- .on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
1214
- ;
1215
- data._resetListCached();
1216
- return;
1217
- } else if(!datalist){
1218
- if(data){
1219
- data.destroy();
1220
- }
1221
- return;
1222
- } else if(data && data.datalist === datalist){
1223
- return;
1224
- }
1225
- listidIndex++;
1226
- var that = this;
1227
- this.hideList = $.proxy(that, 'hideList');
1228
- this.timedHide = function(){
1229
- clearTimeout(that.hideTimer);
1230
- that.hideTimer = setTimeout(that.hideList, 9);
1231
- };
1232
- this.datalist = datalist;
1233
- this.id = opts.id;
1234
- this.hasViewableData = true;
1235
- this._autocomplete = $.attr(opts.input, 'autocomplete');
1236
- $.data(opts.input, 'datalistWidget', this);
1237
- this.shadowList = $('<div class="datalist-polyfill '+ (this.datalist.className || '') + ' '+ this.datalist.id +'-shadowdom' +'" />');
1238
-
1239
- if(formsCFG.positionDatalist || $(opts.input).hasClass('position-datalist')){
1240
- this.shadowList.insertAfter(opts.input);
1241
- } else {
1242
- this.shadowList.appendTo('body');
1243
- }
1244
-
1245
- this.index = -1;
1246
- this.input = opts.input;
1247
- this.arrayOptions = [];
1248
-
1249
- this.shadowList
1250
- .delegate('li', 'mouseenter.datalistWidget mousedown.datalistWidget click.datalistWidget', function(e){
1251
- var items = $('li:not(.hidden-item)', that.shadowList);
1252
- var select = (e.type == 'mousedown' || e.type == 'click');
1253
- that.markItem(items.index(e.currentTarget), select, items);
1254
- if(e.type == 'click'){
1255
- that.hideList();
1256
- if(formsCFG.customDatalist){
1257
- $(opts.input).trigger('datalistselect');
1258
- }
1259
- }
1260
- return (e.type != 'mousedown');
1261
- })
1262
- .on('focusout', this.timedHide)
1263
- ;
1264
-
1265
- opts.input.setAttribute('autocomplete', 'off');
1266
-
1267
- $(opts.input)
1268
- .attr({
1269
- //role: 'combobox',
1270
- 'aria-haspopup': 'true'
1271
- })
1272
- .on({
1273
- 'input.datalistWidget': function(){
1274
- if(!that.triggeredByDatalist){
1275
- that.changedValue = false;
1276
- that.showHideOptions();
1277
- }
1278
- },
1279
- 'keydown.datalistWidget': function(e){
1280
- var keyCode = e.keyCode;
1281
- var activeItem;
1282
- var items;
1283
- if(keyCode == 40 && !that.showList()){
1284
- that.markItem(that.index + 1, true);
1285
- return false;
1286
- }
1287
-
1288
- if(!that.isListVisible){return;}
1289
-
1290
-
1291
- if(keyCode == 38){
1292
- that.markItem(that.index - 1, true);
1293
- return false;
1294
- }
1295
- if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
1296
- that.markItem(0, true);
1297
- return false;
1298
- }
1299
- if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
1300
- items = $('li:not(.hidden-item)', that.shadowList);
1301
- that.markItem(items.length - 1, true, items);
1302
- return false;
1303
- }
1304
- if(keyCode == 13 || keyCode == 27){
1305
- if (keyCode == 13){
1306
- activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
1307
- that.changeValue( $('li.active-item:not(.hidden-item)', that.shadowList) );
1308
- }
1309
- that.hideList();
1310
- if(formsCFG.customDatalist && activeItem && activeItem[0]){
1311
- $(opts.input).trigger('datalistselect');
1312
- }
1313
- return false;
1314
- }
1315
- },
1316
- 'focus.datalistWidget': function(){
1317
- if($(this).hasClass('list-focus')){
1318
- that.showList();
1319
- }
1320
- },
1321
- 'mousedown.datalistWidget': function(){
1322
- if($(this).is(':focus')){
1323
- that.showList();
1324
- }
1325
- },
1326
- 'blur.datalistWidget': this.timedHide
1327
- })
1328
- ;
1329
-
1330
-
1331
- $(this.datalist)
1332
- .off('updateDatalist.datalistWidget')
1333
- .on('updateDatalist.datalistWidget', $.proxy(this, '_resetListCached'))
1334
- ;
1335
-
1336
- this._resetListCached();
1337
-
1338
- if(opts.input.form && (opts.input.name || opts.input.id)){
1339
- $(opts.input.form).on('submit.datalistWidget'+opts.input.id, function(){
1340
- if(!$(opts.input).hasClass('no-datalist-cache') && that._autocomplete != 'off'){
1341
- var val = $.prop(opts.input, 'value');
1342
- var name = (opts.input.name || opts.input.id) + $.prop(opts.input, 'type');
1343
- if(!that.storedOptions){
1344
- that.storedOptions = getStoredOptions( name );
1345
- }
1346
- if(val && that.storedOptions.indexOf(val) == -1){
1347
- that.storedOptions.push(val);
1348
- storeOptions(name, that.storedOptions );
1349
- }
1350
- }
1351
- });
1352
- }
1353
- $(window).on('unload.datalist'+this.id+' beforeunload.datalist'+this.id, function(){
1354
- that.destroy();
1355
- });
1356
- },
1357
- destroy: function(){
1358
- var autocomplete = $.attr(this.input, 'autocomplete');
1359
- $(this.input)
1360
- .off('.datalistWidget')
1361
- .removeData('datalistWidget')
1362
- ;
1363
- this.shadowList.remove();
1364
- $(document).off('.datalist'+this.id);
1365
- $(window).off('.datalist'+this.id);
1366
- if(this.input.form && this.input.id){
1367
- $(this.input.form).off('submit.datalistWidget'+this.input.id);
1368
- }
1369
- this.input.removeAttribute('aria-haspopup');
1370
- if(autocomplete === undefined){
1371
- this.input.removeAttribute('autocomplete');
1372
- } else {
1373
- $(this.input).attr('autocomplete', autocomplete);
1374
- }
1375
- },
1376
- _resetListCached: function(e){
1377
- var that = this;
1378
- var forceShow;
1379
- this.needsUpdate = true;
1380
- this.lastUpdatedValue = false;
1381
- this.lastUnfoundValue = '';
1382
-
1383
- if(!this.updateTimer){
1384
- if(window.QUnit || (forceShow = (e && document.activeElement == that.input))){
1385
- that.updateListOptions(forceShow);
1386
- } else {
1387
- webshims.ready('WINDOWLOAD', function(){
1388
- that.updateTimer = setTimeout(function(){
1389
- that.updateListOptions();
1390
- that = null;
1391
- listidIndex = 1;
1392
- }, 200 + (100 * listidIndex));
1393
- });
1394
- }
1395
- }
1396
- },
1397
- maskHTML: function(str){
1398
- return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
1399
- },
1400
- updateListOptions: function(_forceShow){
1401
- this.needsUpdate = false;
1402
- clearTimeout(this.updateTimer);
1403
- this.updateTimer = false;
1404
- this.shadowList
1405
- .css({
1406
- fontSize: $.css(this.input, 'fontSize'),
1407
- fontFamily: $.css(this.input, 'fontFamily')
1408
- })
1409
- ;
1410
- this.searchStart = formsCFG.customDatalist && $(this.input).hasClass('search-start');
1411
-
1412
- var list = [];
1413
-
1414
- var values = [];
1415
- var allOptions = [];
1416
- var rElem, rItem, rOptions, rI, rLen, item;
1417
- for(rOptions = $.prop(this.datalist, 'options'), rI = 0, rLen = rOptions.length; rI < rLen; rI++){
1418
- rElem = rOptions[rI];
1419
- if(rElem.disabled){return;}
1420
- rItem = {
1421
- value: $(rElem).val() || '',
1422
- text: $.trim($.attr(rElem, 'label') || getText(rElem)),
1423
- className: rElem.className || '',
1424
- style: $.attr(rElem, 'style') || ''
1425
- };
1426
- if(!rItem.text){
1427
- rItem.text = rItem.value;
1428
- } else if(rItem.text != rItem.value){
1429
- rItem.className += ' different-label-value';
1430
- }
1431
- values[rI] = rItem.value;
1432
- allOptions[rI] = rItem;
1433
- }
1434
-
1435
- if(!this.storedOptions){
1436
- this.storedOptions = ($(this.input).hasClass('no-datalist-cache') || this._autocomplete == 'off') ? [] : getStoredOptions((this.input.name || this.input.id) + $.prop(this.input, 'type'));
1437
- }
1438
-
1439
- this.storedOptions.forEach(function(val, i){
1440
- if(values.indexOf(val) == -1){
1441
- allOptions.push({value: val, text: val, className: 'stored-suggest', style: ''});
1442
- }
1443
- });
1444
-
1445
- for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
1446
- item = allOptions[rI];
1447
- 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>';
1448
- }
1449
-
1450
- this.arrayOptions = allOptions;
1451
- this.shadowList.html('<div class="datalist-outer-box"><div class="datalist-box"><ul role="list">'+ list.join("\n") +'</ul></div></div>');
1452
-
1453
- if($.fn.bgIframe && lteie6){
1454
- this.shadowList.bgIframe();
1455
- }
1456
-
1457
- if(_forceShow || this.isListVisible){
1458
- this.showHideOptions();
1459
- }
1460
- },
1461
- showHideOptions: function(_fromShowList){
1462
- var value = $.prop(this.input, 'value').toLowerCase();
1463
- //first check prevent infinite loop, second creates simple lazy optimization
1464
- if(value === this.lastUpdatedValue || (this.lastUnfoundValue && value.indexOf(this.lastUnfoundValue) === 0)){
1465
- return;
1466
- }
1467
-
1468
- this.lastUpdatedValue = value;
1469
- var found = false;
1470
- var startSearch = this.searchStart;
1471
- var lis = $('li', this.shadowList);
1472
- if(value){
1473
- this.arrayOptions.forEach(function(item, i){
1474
- var search;
1475
- if(!('lowerText' in item)){
1476
- if(item.text != item.value){
1477
- item.lowerText = item.value.toLowerCase() + item.text.toLowerCase();
1478
- } else {
1479
- item.lowerText = item.text.toLowerCase();
1480
- }
1481
- }
1482
- search = item.lowerText.indexOf(value);
1483
- search = startSearch ? !search : search !== -1;
1484
- if(search){
1485
- $(lis[i]).removeClass('hidden-item');
1486
- found = true;
1487
- } else {
1488
- $(lis[i]).addClass('hidden-item');
1489
- }
1490
- });
1491
- } else if(lis.length) {
1492
- lis.removeClass('hidden-item');
1493
- found = true;
1494
- }
1495
-
1496
- this.hasViewableData = found;
1497
- if(!_fromShowList && found){
1498
- this.showList();
1499
- }
1500
- if(!found){
1501
- this.lastUnfoundValue = value;
1502
- this.hideList();
1503
- }
1504
- },
1505
- setPos: function(){
1506
- this.shadowList.css({marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0});
1507
- var css = (formsCFG.positionDatalist) ? $(this.input).position() : webshims.getRelOffset(this.shadowList, this.input);
1508
- css.top += $(this.input).outerHeight();
1509
- css.width = $(this.input).outerWidth() - (parseInt(this.shadowList.css('borderLeftWidth'), 10) || 0) - (parseInt(this.shadowList.css('borderRightWidth'), 10) || 0);
1510
- this.shadowList.css({marginTop: '', marginLeft: '', marginRight: '', marginBottom: ''}).css(css);
1511
- return css;
1512
- },
1513
- showList: function(){
1514
- if(this.isListVisible){return false;}
1515
- if(this.needsUpdate){
1516
- this.updateListOptions();
1517
- }
1518
- this.showHideOptions(true);
1519
- if(!this.hasViewableData){return false;}
1520
- this.isListVisible = true;
1521
- var that = this;
1522
-
1523
- that.setPos();
1524
- that.shadowList.addClass('datalist-visible').find('li.active-item').removeClass('active-item');
1525
-
1526
- $(window).unbind('.datalist'+that.id);
1527
- $(document)
1528
- .off('.datalist'+that.id)
1529
- .on('mousedown.datalist'+that.id +' focusin.datalist'+that.id, function(e){
1530
- if(e.target === that.input || that.shadowList[0] === e.target || $.contains( that.shadowList[0], e.target )){
1531
- clearTimeout(that.hideTimer);
1532
- setTimeout(function(){
1533
- clearTimeout(that.hideTimer);
1534
- }, 9);
1535
- } else {
1536
- that.timedHide();
1537
- }
1538
- })
1539
- .on('updateshadowdom.datalist'+that.id, function(){
1540
- that.setPos();
1541
- })
1542
- ;
1543
- return true;
1544
- },
1545
- hideList: function(){
1546
- if(!this.isListVisible){return false;}
1547
- var that = this;
1548
- var triggerChange = function(e){
1549
- if(that.changedValue){
1550
- $(that.input).trigger('change');
1551
- }
1552
- that.changedValue = false;
1553
- };
1554
-
1555
- that.shadowList.removeClass('datalist-visible list-item-active');
1556
- that.index = -1;
1557
- that.isListVisible = false;
1558
- if(that.changedValue){
1559
- that.triggeredByDatalist = true;
1560
- webshims.triggerInlineForm && webshims.triggerInlineForm(that.input, 'input');
1561
- if($(that.input).is(':focus')){
1562
- $(that.input).one('blur', triggerChange);
1563
- } else {
1564
- triggerChange();
1565
- }
1566
- that.triggeredByDatalist = false;
1567
- }
1568
- $(document).unbind('.datalist'+that.id);
1569
- $(window)
1570
- .off('.datalist'+that.id)
1571
- .one('resize.datalist'+that.id, function(){
1572
- that.shadowList.css({top: 0, left: 0});
1573
- })
1574
- ;
1575
- return true;
1576
- },
1577
- scrollIntoView: function(elem){
1578
- var ul = $('ul', this.shadowList);
1579
- var div = $('div.datalist-box', this.shadowList);
1580
- var elemPos = elem.position();
1581
- var containerHeight;
1582
- elemPos.top -= (parseInt(ul.css('paddingTop'), 10) || 0) + (parseInt(ul.css('marginTop'), 10) || 0) + (parseInt(ul.css('borderTopWidth'), 10) || 0);
1583
- if(elemPos.top < 0){
1584
- div.scrollTop( div.scrollTop() + elemPos.top - 2);
1585
- return;
1586
- }
1587
- elemPos.top += elem.outerHeight();
1588
- containerHeight = div.height();
1589
- if(elemPos.top > containerHeight){
1590
- div.scrollTop( div.scrollTop() + (elemPos.top - containerHeight) + 2);
1591
- }
1592
- },
1593
- changeValue: function(activeItem){
1594
- if(!activeItem[0]){return;}
1595
- var newValue = $('span.option-value', activeItem).text();
1596
- var oldValue = $.prop(this.input, 'value');
1597
- if(newValue != oldValue){
1598
- $(this.input)
1599
- .prop('value', newValue)
1600
- .triggerHandler('updateInput')
1601
- ;
1602
- this.changedValue = true;
1603
- }
1604
- },
1605
- markItem: function(index, doValue, items){
1606
- var activeItem;
1607
- var goesUp;
1608
-
1609
- items = items || $('li:not(.hidden-item)', this.shadowList);
1610
- if(!items.length){return;}
1611
- if(index < 0){
1612
- index = items.length - 1;
1613
- } else if(index >= items.length){
1614
- index = 0;
1615
- }
1616
- items.removeClass('active-item');
1617
- this.shadowList.addClass('list-item-active');
1618
- activeItem = items.filter(':eq('+ index +')').addClass('active-item');
1619
-
1620
- if(doValue){
1621
- this.changeValue(activeItem);
1622
- this.scrollIntoView(activeItem);
1623
- }
1624
- this.index = index;
1625
- }
1626
- };
1627
-
1628
- //init datalist update
1629
- initializeDatalist();
1630
- })();
1631
-
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
+ jQuery.webshims.register('form-datalist', function($, webshims, window, document, undefined){
952
+ "use strict";
953
+ var doc = document;
954
+
955
+ /*
956
+ * implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
957
+ */
958
+ webshims.propTypes.element = function(descs){
959
+ webshims.createPropDefault(descs, 'attr');
960
+ if(descs.prop){return;}
961
+ descs.prop = {
962
+ get: function(){
963
+ var elem = descs.attr.get.call(this);
964
+ if(elem){
965
+ elem = document.getElementById(elem);
966
+ if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
967
+ elem = null;
968
+ }
969
+ }
970
+ return elem || null;
971
+ },
972
+ writeable: false
973
+ };
974
+ };
975
+
976
+
977
+ /*
978
+ * Implements datalist element and list attribute
979
+ */
980
+
981
+ (function(){
982
+ var formsCFG = $.webshims.cfg.forms;
983
+ var listSupport = Modernizr.input.list;
984
+ if(listSupport && !formsCFG.customDatalist){return;}
985
+
986
+ var initializeDatalist = function(){
987
+
988
+
989
+ if(!listSupport){
990
+ webshims.defineNodeNameProperty('datalist', 'options', {
991
+ prop: {
992
+ writeable: false,
993
+ get: function(){
994
+ var elem = this;
995
+ var select = $('select', elem);
996
+ var options;
997
+ if(select[0]){
998
+ options = select[0].options;
999
+ } else {
1000
+ options = $('option', elem).get();
1001
+ if(options.length){
1002
+ webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
1003
+ }
1004
+ }
1005
+ return options;
1006
+ }
1007
+ }
1008
+ });
1009
+ }
1010
+
1011
+ var inputListProto = {
1012
+ //override autocomplete
1013
+ autocomplete: {
1014
+ attr: {
1015
+ get: function(){
1016
+ var elem = this;
1017
+ var data = $.data(elem, 'datalistWidget');
1018
+ if(data){
1019
+ return data._autocomplete;
1020
+ }
1021
+ return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
1022
+ },
1023
+ set: function(value){
1024
+ var elem = this;
1025
+ var data = $.data(elem, 'datalistWidget');
1026
+ if(data){
1027
+ data._autocomplete = value;
1028
+ if(value == 'off'){
1029
+ data.hideList();
1030
+ }
1031
+ } else {
1032
+ if('autocomplete' in elem){
1033
+ elem.autocomplete = value;
1034
+ } else {
1035
+ elem.setAttribute('autocomplete', value);
1036
+ }
1037
+ }
1038
+ }
1039
+ }
1040
+ }
1041
+ };
1042
+
1043
+ // if(formsCFG.customDatalist && (!listSupport || !('selectedOption') in $('<input />')[0])){
1044
+ // //currently not supported x-browser (FF4 has not implemented and is not polyfilled )
1045
+ // inputListProto.selectedOption = {
1046
+ // prop: {
1047
+ // writeable: false,
1048
+ // get: function(){
1049
+ // var elem = this;
1050
+ // var list = $.prop(elem, 'list');
1051
+ // var ret = null;
1052
+ // var value, options;
1053
+ // if(!list){return ret;}
1054
+ // value = $.prop(elem, 'value');
1055
+ // if(!value){return ret;}
1056
+ // options = $.prop(list, 'options');
1057
+ // if(!options.length){return ret;}
1058
+ // $.each(options, function(i, option){
1059
+ // if(value == $.prop(option, 'value')){
1060
+ // ret = option;
1061
+ // return false;
1062
+ // }
1063
+ // });
1064
+ // return ret;
1065
+ // }
1066
+ // }
1067
+ // };
1068
+ // }
1069
+
1070
+ if(!listSupport){
1071
+ inputListProto['list'] = {
1072
+ attr: {
1073
+ get: function(){
1074
+ var val = webshims.contentAttr(this, 'list');
1075
+ return (val == null) ? undefined : val;
1076
+ },
1077
+ set: function(value){
1078
+ var elem = this;
1079
+ webshims.contentAttr(elem, 'list', value);
1080
+ webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1081
+ }
1082
+ },
1083
+ initAttr: true,
1084
+ reflect: true,
1085
+ propType: 'element',
1086
+ propNodeName: 'datalist'
1087
+ };
1088
+ } else {
1089
+ //options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
1090
+ if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
1091
+ webshims.defineNodeNameProperty('datalist', 'options', {
1092
+ prop: {
1093
+ writeable: false,
1094
+ get: function(){
1095
+ var options = this.options || [];
1096
+ if(!options.length){
1097
+ var elem = this;
1098
+ var select = $('select', elem);
1099
+ if(select[0] && select[0].options && select[0].options.length){
1100
+ options = select[0].options;
1101
+ }
1102
+ }
1103
+ return options;
1104
+ }
1105
+ }
1106
+ });
1107
+ }
1108
+ inputListProto['list'] = {
1109
+ attr: {
1110
+ get: function(){
1111
+ var val = webshims.contentAttr(this, 'list');
1112
+ if(val != null){
1113
+ this.removeAttribute('list');
1114
+ } else {
1115
+ val = $.data(this, 'datalistListAttr');
1116
+ }
1117
+
1118
+ return (val == null) ? undefined : val;
1119
+ },
1120
+ set: function(value){
1121
+ var elem = this;
1122
+ $.data(elem, 'datalistListAttr', value);
1123
+ webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
1124
+ }
1125
+ },
1126
+ initAttr: true,
1127
+ reflect: true,
1128
+ propType: 'element',
1129
+ propNodeName: 'datalist'
1130
+ };
1131
+ }
1132
+
1133
+
1134
+ webshims.defineNodeNameProperties('input', inputListProto);
1135
+
1136
+ if($.event.customEvent){
1137
+ $.event.customEvent.updateDatalist = true;
1138
+ $.event.customEvent.updateInput = true;
1139
+ $.event.customEvent.datalistselect = true;
1140
+ }
1141
+ webshims.addReady(function(context, contextElem){
1142
+ contextElem
1143
+ .filter('datalist > select, datalist, datalist > option, datalist > select > option')
1144
+ .closest('datalist')
1145
+ .triggerHandler('updateDatalist')
1146
+ ;
1147
+
1148
+ });
1149
+
1150
+
1151
+ };
1152
+
1153
+
1154
+ /*
1155
+ * ShadowList
1156
+ */
1157
+ var listidIndex = 0;
1158
+
1159
+ var noDatalistSupport = {
1160
+ submit: 1,
1161
+ button: 1,
1162
+ reset: 1,
1163
+ hidden: 1,
1164
+
1165
+ //ToDo
1166
+ range: 1,
1167
+ date: 1
1168
+ };
1169
+ var lteie6 = ($.browser.msie && parseInt($.browser.version, 10) < 7);
1170
+ var globStoredOptions = {};
1171
+ var getStoredOptions = function(name){
1172
+ if(!name){return [];}
1173
+ if(globStoredOptions[name]){
1174
+ return globStoredOptions[name];
1175
+ }
1176
+ var data;
1177
+ try {
1178
+ data = JSON.parse(localStorage.getItem('storedDatalistOptions'+name));
1179
+ } catch(e){}
1180
+ globStoredOptions[name] = data || [];
1181
+ return data || [];
1182
+ };
1183
+ var storeOptions = function(name, val){
1184
+ if(!name){return;}
1185
+ val = val || [];
1186
+ try {
1187
+ localStorage.setItem( 'storedDatalistOptions'+name, JSON.stringify(val) );
1188
+ } catch(e){}
1189
+ };
1190
+
1191
+ var getText = function(elem){
1192
+ return (elem.textContent || elem.innerText || $.text([ elem ]) || '');
1193
+ };
1194
+
1195
+ var shadowListProto = {
1196
+ _create: function(opts){
1197
+
1198
+ if(noDatalistSupport[$.prop(opts.input, 'type')]){return;}
1199
+ var datalist = opts.datalist;
1200
+ var data = $.data(opts.input, 'datalistWidget');
1201
+ if(datalist && data && data.datalist !== datalist){
1202
+ data.datalist = datalist;
1203
+ data.id = opts.id;
1204
+
1205
+ data.shadowList.prop('className', 'datalist-polyfill '+ (data.datalist.className || '') + ' '+ data.datalist.id +'-shadowdom');
1206
+ if(formsCFG.positionDatalist){
1207
+ data.shadowList.insertAfter(opts.input);
1208
+ } else {
1209
+ data.shadowList.appendTo('body');
1210
+ }
1211
+ $(data.datalist)
1212
+ .off('updateDatalist.datalistWidget')
1213
+ .on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
1214
+ ;
1215
+ data._resetListCached();
1216
+ return;
1217
+ } else if(!datalist){
1218
+ if(data){
1219
+ data.destroy();
1220
+ }
1221
+ return;
1222
+ } else if(data && data.datalist === datalist){
1223
+ return;
1224
+ }
1225
+ listidIndex++;
1226
+ var that = this;
1227
+ this.hideList = $.proxy(that, 'hideList');
1228
+ this.timedHide = function(){
1229
+ clearTimeout(that.hideTimer);
1230
+ that.hideTimer = setTimeout(that.hideList, 9);
1231
+ };
1232
+ this.datalist = datalist;
1233
+ this.id = opts.id;
1234
+ this.hasViewableData = true;
1235
+ this._autocomplete = $.attr(opts.input, 'autocomplete');
1236
+ $.data(opts.input, 'datalistWidget', this);
1237
+ this.shadowList = $('<div class="datalist-polyfill '+ (this.datalist.className || '') + ' '+ this.datalist.id +'-shadowdom' +'" />');
1238
+
1239
+ if(formsCFG.positionDatalist || $(opts.input).hasClass('position-datalist')){
1240
+ this.shadowList.insertAfter(opts.input);
1241
+ } else {
1242
+ this.shadowList.appendTo('body');
1243
+ }
1244
+
1245
+ this.index = -1;
1246
+ this.input = opts.input;
1247
+ this.arrayOptions = [];
1248
+
1249
+ this.shadowList
1250
+ .delegate('li', 'mouseenter.datalistWidget mousedown.datalistWidget click.datalistWidget', function(e){
1251
+ var items = $('li:not(.hidden-item)', that.shadowList);
1252
+ var select = (e.type == 'mousedown' || e.type == 'click');
1253
+ that.markItem(items.index(e.currentTarget), select, items);
1254
+ if(e.type == 'click'){
1255
+ that.hideList();
1256
+ if(formsCFG.customDatalist){
1257
+ $(opts.input).trigger('datalistselect');
1258
+ }
1259
+ }
1260
+ return (e.type != 'mousedown');
1261
+ })
1262
+ .on('focusout', this.timedHide)
1263
+ ;
1264
+
1265
+ opts.input.setAttribute('autocomplete', 'off');
1266
+
1267
+ $(opts.input)
1268
+ .attr({
1269
+ //role: 'combobox',
1270
+ 'aria-haspopup': 'true'
1271
+ })
1272
+ .on({
1273
+ 'input.datalistWidget': function(){
1274
+ if(!that.triggeredByDatalist){
1275
+ that.changedValue = false;
1276
+ that.showHideOptions();
1277
+ }
1278
+ },
1279
+ 'keydown.datalistWidget': function(e){
1280
+ var keyCode = e.keyCode;
1281
+ var activeItem;
1282
+ var items;
1283
+ if(keyCode == 40 && !that.showList()){
1284
+ that.markItem(that.index + 1, true);
1285
+ return false;
1286
+ }
1287
+
1288
+ if(!that.isListVisible){return;}
1289
+
1290
+
1291
+ if(keyCode == 38){
1292
+ that.markItem(that.index - 1, true);
1293
+ return false;
1294
+ }
1295
+ if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
1296
+ that.markItem(0, true);
1297
+ return false;
1298
+ }
1299
+ if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
1300
+ items = $('li:not(.hidden-item)', that.shadowList);
1301
+ that.markItem(items.length - 1, true, items);
1302
+ return false;
1303
+ }
1304
+ if(keyCode == 13 || keyCode == 27){
1305
+ if (keyCode == 13){
1306
+ activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
1307
+ that.changeValue( $('li.active-item:not(.hidden-item)', that.shadowList) );
1308
+ }
1309
+ that.hideList();
1310
+ if(formsCFG.customDatalist && activeItem && activeItem[0]){
1311
+ $(opts.input).trigger('datalistselect');
1312
+ }
1313
+ return false;
1314
+ }
1315
+ },
1316
+ 'focus.datalistWidget': function(){
1317
+ if($(this).hasClass('list-focus')){
1318
+ that.showList();
1319
+ }
1320
+ },
1321
+ 'mousedown.datalistWidget': function(){
1322
+ if($(this).is(':focus')){
1323
+ that.showList();
1324
+ }
1325
+ },
1326
+ 'blur.datalistWidget': this.timedHide
1327
+ })
1328
+ ;
1329
+
1330
+
1331
+ $(this.datalist)
1332
+ .off('updateDatalist.datalistWidget')
1333
+ .on('updateDatalist.datalistWidget', $.proxy(this, '_resetListCached'))
1334
+ ;
1335
+
1336
+ this._resetListCached();
1337
+
1338
+ if(opts.input.form && (opts.input.name || opts.input.id)){
1339
+ $(opts.input.form).on('submit.datalistWidget'+opts.input.id, function(){
1340
+ if(!$(opts.input).hasClass('no-datalist-cache') && that._autocomplete != 'off'){
1341
+ var val = $.prop(opts.input, 'value');
1342
+ var name = (opts.input.name || opts.input.id) + $.prop(opts.input, 'type');
1343
+ if(!that.storedOptions){
1344
+ that.storedOptions = getStoredOptions( name );
1345
+ }
1346
+ if(val && that.storedOptions.indexOf(val) == -1){
1347
+ that.storedOptions.push(val);
1348
+ storeOptions(name, that.storedOptions );
1349
+ }
1350
+ }
1351
+ });
1352
+ }
1353
+ $(window).on('unload.datalist'+this.id+' beforeunload.datalist'+this.id, function(){
1354
+ that.destroy();
1355
+ });
1356
+ },
1357
+ destroy: function(){
1358
+ var autocomplete = $.attr(this.input, 'autocomplete');
1359
+ $(this.input)
1360
+ .off('.datalistWidget')
1361
+ .removeData('datalistWidget')
1362
+ ;
1363
+ this.shadowList.remove();
1364
+ $(document).off('.datalist'+this.id);
1365
+ $(window).off('.datalist'+this.id);
1366
+ if(this.input.form && this.input.id){
1367
+ $(this.input.form).off('submit.datalistWidget'+this.input.id);
1368
+ }
1369
+ this.input.removeAttribute('aria-haspopup');
1370
+ if(autocomplete === undefined){
1371
+ this.input.removeAttribute('autocomplete');
1372
+ } else {
1373
+ $(this.input).attr('autocomplete', autocomplete);
1374
+ }
1375
+ },
1376
+ _resetListCached: function(e){
1377
+ var that = this;
1378
+ var forceShow;
1379
+ this.needsUpdate = true;
1380
+ this.lastUpdatedValue = false;
1381
+ this.lastUnfoundValue = '';
1382
+
1383
+ if(!this.updateTimer){
1384
+ if(window.QUnit || (forceShow = (e && document.activeElement == that.input))){
1385
+ that.updateListOptions(forceShow);
1386
+ } else {
1387
+ webshims.ready('WINDOWLOAD', function(){
1388
+ that.updateTimer = setTimeout(function(){
1389
+ that.updateListOptions();
1390
+ that = null;
1391
+ listidIndex = 1;
1392
+ }, 200 + (100 * listidIndex));
1393
+ });
1394
+ }
1395
+ }
1396
+ },
1397
+ maskHTML: function(str){
1398
+ return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
1399
+ },
1400
+ updateListOptions: function(_forceShow){
1401
+ this.needsUpdate = false;
1402
+ clearTimeout(this.updateTimer);
1403
+ this.updateTimer = false;
1404
+ this.shadowList
1405
+ .css({
1406
+ fontSize: $.css(this.input, 'fontSize'),
1407
+ fontFamily: $.css(this.input, 'fontFamily')
1408
+ })
1409
+ ;
1410
+ this.searchStart = formsCFG.customDatalist && $(this.input).hasClass('search-start');
1411
+
1412
+ var list = [];
1413
+
1414
+ var values = [];
1415
+ var allOptions = [];
1416
+ var rElem, rItem, rOptions, rI, rLen, item;
1417
+ for(rOptions = $.prop(this.datalist, 'options'), rI = 0, rLen = rOptions.length; rI < rLen; rI++){
1418
+ rElem = rOptions[rI];
1419
+ if(rElem.disabled){return;}
1420
+ rItem = {
1421
+ value: $(rElem).val() || '',
1422
+ text: $.trim($.attr(rElem, 'label') || getText(rElem)),
1423
+ className: rElem.className || '',
1424
+ style: $.attr(rElem, 'style') || ''
1425
+ };
1426
+ if(!rItem.text){
1427
+ rItem.text = rItem.value;
1428
+ } else if(rItem.text != rItem.value){
1429
+ rItem.className += ' different-label-value';
1430
+ }
1431
+ values[rI] = rItem.value;
1432
+ allOptions[rI] = rItem;
1433
+ }
1434
+
1435
+ if(!this.storedOptions){
1436
+ this.storedOptions = ($(this.input).hasClass('no-datalist-cache') || this._autocomplete == 'off') ? [] : getStoredOptions((this.input.name || this.input.id) + $.prop(this.input, 'type'));
1437
+ }
1438
+
1439
+ this.storedOptions.forEach(function(val, i){
1440
+ if(values.indexOf(val) == -1){
1441
+ allOptions.push({value: val, text: val, className: 'stored-suggest', style: ''});
1442
+ }
1443
+ });
1444
+
1445
+ for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
1446
+ item = allOptions[rI];
1447
+ 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>';
1448
+ }
1449
+
1450
+ this.arrayOptions = allOptions;
1451
+ this.shadowList.html('<div class="datalist-outer-box"><div class="datalist-box"><ul role="list">'+ list.join("\n") +'</ul></div></div>');
1452
+
1453
+ if($.fn.bgIframe && lteie6){
1454
+ this.shadowList.bgIframe();
1455
+ }
1456
+
1457
+ if(_forceShow || this.isListVisible){
1458
+ this.showHideOptions();
1459
+ }
1460
+ },
1461
+ showHideOptions: function(_fromShowList){
1462
+ var value = $.prop(this.input, 'value').toLowerCase();
1463
+ //first check prevent infinite loop, second creates simple lazy optimization
1464
+ if(value === this.lastUpdatedValue || (this.lastUnfoundValue && value.indexOf(this.lastUnfoundValue) === 0)){
1465
+ return;
1466
+ }
1467
+
1468
+ this.lastUpdatedValue = value;
1469
+ var found = false;
1470
+ var startSearch = this.searchStart;
1471
+ var lis = $('li', this.shadowList);
1472
+ if(value){
1473
+ this.arrayOptions.forEach(function(item, i){
1474
+ var search;
1475
+ if(!('lowerText' in item)){
1476
+ if(item.text != item.value){
1477
+ item.lowerText = item.value.toLowerCase() + item.text.toLowerCase();
1478
+ } else {
1479
+ item.lowerText = item.text.toLowerCase();
1480
+ }
1481
+ }
1482
+ search = item.lowerText.indexOf(value);
1483
+ search = startSearch ? !search : search !== -1;
1484
+ if(search){
1485
+ $(lis[i]).removeClass('hidden-item');
1486
+ found = true;
1487
+ } else {
1488
+ $(lis[i]).addClass('hidden-item');
1489
+ }
1490
+ });
1491
+ } else if(lis.length) {
1492
+ lis.removeClass('hidden-item');
1493
+ found = true;
1494
+ }
1495
+
1496
+ this.hasViewableData = found;
1497
+ if(!_fromShowList && found){
1498
+ this.showList();
1499
+ }
1500
+ if(!found){
1501
+ this.lastUnfoundValue = value;
1502
+ this.hideList();
1503
+ }
1504
+ },
1505
+ setPos: function(){
1506
+ this.shadowList.css({marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0});
1507
+ var css = (formsCFG.positionDatalist) ? $(this.input).position() : webshims.getRelOffset(this.shadowList, this.input);
1508
+ css.top += $(this.input).outerHeight();
1509
+ css.width = $(this.input).outerWidth() - (parseInt(this.shadowList.css('borderLeftWidth'), 10) || 0) - (parseInt(this.shadowList.css('borderRightWidth'), 10) || 0);
1510
+ this.shadowList.css({marginTop: '', marginLeft: '', marginRight: '', marginBottom: ''}).css(css);
1511
+ return css;
1512
+ },
1513
+ showList: function(){
1514
+ if(this.isListVisible){return false;}
1515
+ if(this.needsUpdate){
1516
+ this.updateListOptions();
1517
+ }
1518
+ this.showHideOptions(true);
1519
+ if(!this.hasViewableData){return false;}
1520
+ this.isListVisible = true;
1521
+ var that = this;
1522
+
1523
+ that.setPos();
1524
+ that.shadowList.addClass('datalist-visible').find('li.active-item').removeClass('active-item');
1525
+
1526
+ $(window).unbind('.datalist'+that.id);
1527
+ $(document)
1528
+ .off('.datalist'+that.id)
1529
+ .on('mousedown.datalist'+that.id +' focusin.datalist'+that.id, function(e){
1530
+ if(e.target === that.input || that.shadowList[0] === e.target || $.contains( that.shadowList[0], e.target )){
1531
+ clearTimeout(that.hideTimer);
1532
+ setTimeout(function(){
1533
+ clearTimeout(that.hideTimer);
1534
+ }, 9);
1535
+ } else {
1536
+ that.timedHide();
1537
+ }
1538
+ })
1539
+ .on('updateshadowdom.datalist'+that.id, function(){
1540
+ that.setPos();
1541
+ })
1542
+ ;
1543
+ return true;
1544
+ },
1545
+ hideList: function(){
1546
+ if(!this.isListVisible){return false;}
1547
+ var that = this;
1548
+ var triggerChange = function(e){
1549
+ if(that.changedValue){
1550
+ $(that.input).trigger('change');
1551
+ }
1552
+ that.changedValue = false;
1553
+ };
1554
+
1555
+ that.shadowList.removeClass('datalist-visible list-item-active');
1556
+ that.index = -1;
1557
+ that.isListVisible = false;
1558
+ if(that.changedValue){
1559
+ that.triggeredByDatalist = true;
1560
+ webshims.triggerInlineForm && webshims.triggerInlineForm(that.input, 'input');
1561
+ if($(that.input).is(':focus')){
1562
+ $(that.input).one('blur', triggerChange);
1563
+ } else {
1564
+ triggerChange();
1565
+ }
1566
+ that.triggeredByDatalist = false;
1567
+ }
1568
+ $(document).unbind('.datalist'+that.id);
1569
+ $(window)
1570
+ .off('.datalist'+that.id)
1571
+ .one('resize.datalist'+that.id, function(){
1572
+ that.shadowList.css({top: 0, left: 0});
1573
+ })
1574
+ ;
1575
+ return true;
1576
+ },
1577
+ scrollIntoView: function(elem){
1578
+ var ul = $('ul', this.shadowList);
1579
+ var div = $('div.datalist-box', this.shadowList);
1580
+ var elemPos = elem.position();
1581
+ var containerHeight;
1582
+ elemPos.top -= (parseInt(ul.css('paddingTop'), 10) || 0) + (parseInt(ul.css('marginTop'), 10) || 0) + (parseInt(ul.css('borderTopWidth'), 10) || 0);
1583
+ if(elemPos.top < 0){
1584
+ div.scrollTop( div.scrollTop() + elemPos.top - 2);
1585
+ return;
1586
+ }
1587
+ elemPos.top += elem.outerHeight();
1588
+ containerHeight = div.height();
1589
+ if(elemPos.top > containerHeight){
1590
+ div.scrollTop( div.scrollTop() + (elemPos.top - containerHeight) + 2);
1591
+ }
1592
+ },
1593
+ changeValue: function(activeItem){
1594
+ if(!activeItem[0]){return;}
1595
+ var newValue = $('span.option-value', activeItem).text();
1596
+ var oldValue = $.prop(this.input, 'value');
1597
+ if(newValue != oldValue){
1598
+ $(this.input)
1599
+ .prop('value', newValue)
1600
+ .triggerHandler('updateInput')
1601
+ ;
1602
+ this.changedValue = true;
1603
+ }
1604
+ },
1605
+ markItem: function(index, doValue, items){
1606
+ var activeItem;
1607
+ var goesUp;
1608
+
1609
+ items = items || $('li:not(.hidden-item)', this.shadowList);
1610
+ if(!items.length){return;}
1611
+ if(index < 0){
1612
+ index = items.length - 1;
1613
+ } else if(index >= items.length){
1614
+ index = 0;
1615
+ }
1616
+ items.removeClass('active-item');
1617
+ this.shadowList.addClass('list-item-active');
1618
+ activeItem = items.filter(':eq('+ index +')').addClass('active-item');
1619
+
1620
+ if(doValue){
1621
+ this.changeValue(activeItem);
1622
+ this.scrollIntoView(activeItem);
1623
+ }
1624
+ this.index = index;
1625
+ }
1626
+ };
1627
+
1628
+ //init datalist update
1629
+ initializeDatalist();
1630
+ })();
1631
+
1632
1632
  });