webshims-rails 1.10.3 → 1.10.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +8 -8
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/polyfiller.js +96 -73
  4. data/vendor/assets/javascripts/webshims/shims/color-picker.js +2415 -0
  5. data/vendor/assets/javascripts/webshims/shims/combos/1.js +248 -745
  6. data/vendor/assets/javascripts/webshims/shims/combos/10.js +771 -1206
  7. data/vendor/assets/javascripts/webshims/shims/combos/11.js +679 -1201
  8. data/vendor/assets/javascripts/webshims/shims/combos/12.js +46 -65
  9. data/vendor/assets/javascripts/webshims/shims/combos/13.js +45 -64
  10. data/vendor/assets/javascripts/webshims/shims/combos/14.js +94 -7
  11. data/vendor/assets/javascripts/webshims/shims/combos/15.js +557 -1189
  12. data/vendor/assets/javascripts/webshims/shims/combos/16.js +598 -1249
  13. data/vendor/assets/javascripts/webshims/shims/combos/17.js +697 -1208
  14. data/vendor/assets/javascripts/webshims/shims/combos/18.js +697 -1208
  15. data/vendor/assets/javascripts/webshims/shims/combos/19.js +145 -78
  16. data/vendor/assets/javascripts/webshims/shims/combos/2.js +472 -1280
  17. data/vendor/assets/javascripts/webshims/shims/combos/20.js +144 -77
  18. data/vendor/assets/javascripts/webshims/shims/combos/21.js +14 -15
  19. data/vendor/assets/javascripts/webshims/shims/combos/22.js +2 -2
  20. data/vendor/assets/javascripts/webshims/shims/combos/23.js +45 -64
  21. data/vendor/assets/javascripts/webshims/shims/combos/24.js +848 -0
  22. data/vendor/assets/javascripts/webshims/shims/combos/25.js +4373 -0
  23. data/vendor/assets/javascripts/webshims/shims/combos/26.js +1516 -0
  24. data/vendor/assets/javascripts/webshims/shims/combos/27.js +884 -0
  25. data/vendor/assets/javascripts/webshims/shims/combos/28.js +2067 -0
  26. data/vendor/assets/javascripts/webshims/shims/combos/29.js +1156 -0
  27. data/vendor/assets/javascripts/webshims/shims/combos/3.js +313 -700
  28. data/vendor/assets/javascripts/webshims/shims/combos/30.js +1868 -0
  29. data/vendor/assets/javascripts/webshims/shims/combos/31.js +1663 -0
  30. data/vendor/assets/javascripts/webshims/shims/combos/4.js +111 -20
  31. data/vendor/assets/javascripts/webshims/shims/combos/5.js +747 -1321
  32. data/vendor/assets/javascripts/webshims/shims/combos/6.js +837 -1809
  33. data/vendor/assets/javascripts/webshims/shims/combos/7.js +435 -1239
  34. data/vendor/assets/javascripts/webshims/shims/combos/8.js +360 -766
  35. data/vendor/assets/javascripts/webshims/shims/combos/9.js +843 -1676
  36. data/vendor/assets/javascripts/webshims/shims/details.js +1 -1
  37. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +90 -3
  38. data/vendor/assets/javascripts/webshims/shims/filereader.js +386 -0
  39. data/vendor/assets/javascripts/webshims/shims/form-core.js +201 -680
  40. data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +418 -0
  41. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +69 -467
  42. data/vendor/assets/javascripts/webshims/shims/form-message.js +21 -17
  43. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +19 -82
  44. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +17 -6
  45. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +570 -1185
  46. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +181 -28
  47. data/vendor/assets/javascripts/webshims/shims/form-validation.js +599 -0
  48. data/vendor/assets/javascripts/webshims/{extras/custom-validity.js → shims/form-validators.js} +33 -38
  49. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +865 -0
  50. data/vendor/assets/javascripts/webshims/shims/geolocation.js +2 -2
  51. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-de.txt +37 -34
  52. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-en.txt +88 -48
  53. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-lt.js +74 -0
  54. data/vendor/assets/javascripts/webshims/shims/jpicker/ChangeLog.txt +121 -0
  55. data/vendor/assets/javascripts/webshims/shims/jpicker/ReadMe.txt +47 -0
  56. data/vendor/assets/javascripts/webshims/shims/jpicker/images/AlphaBar.png +0 -0
  57. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Bars.png +0 -0
  58. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Maps.png +0 -0
  59. data/vendor/assets/javascripts/webshims/shims/jpicker/images/NoColor.png +0 -0
  60. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Thumbs.db +0 -0
  61. data/vendor/assets/javascripts/webshims/shims/jpicker/images/bar-opacity.png +0 -0
  62. data/vendor/assets/javascripts/webshims/shims/jpicker/images/map-opacity.png +0 -0
  63. data/vendor/assets/javascripts/webshims/shims/jpicker/images/mappoint.gif +0 -0
  64. data/vendor/assets/javascripts/webshims/shims/jpicker/images/picker.gif +0 -0
  65. data/vendor/assets/javascripts/webshims/shims/jpicker/images/preview-opacity.png +0 -0
  66. data/vendor/assets/javascripts/webshims/shims/jpicker/images/rangearrows.gif +0 -0
  67. data/vendor/assets/javascripts/webshims/shims/jpicker/jpicker.css +257 -0
  68. data/vendor/assets/javascripts/webshims/shims/json-storage.js +4 -4
  69. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +44 -63
  70. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +10 -11
  71. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +2 -1
  72. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +5 -3
  73. data/vendor/assets/javascripts/webshims/shims/range-ui.js +110 -17
  74. data/vendor/assets/javascripts/webshims/shims/styles/forms.png +0 -0
  75. data/vendor/assets/javascripts/webshims/shims/styles/range-track.png +0 -0
  76. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +104 -21
  77. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +90 -16
  78. data/vendor/assets/javascripts/webshims/shims/styles/vertical-range.png +0 -0
  79. data/vendor/assets/javascripts/webshims/shims/swf/filereader.swf +0 -0
  80. data/vendor/assets/javascripts/webshims/shims/swfmini.js +1 -1
  81. data/vendor/assets/javascripts/webshims/shims/track-ui.js +35 -3
  82. data/vendor/assets/javascripts/webshims/shims/track.js +1 -1
  83. metadata +33 -3
@@ -42,6 +42,7 @@
42
42
  var oVal = val;
43
43
  var thumbStyle = {};
44
44
  var rangeStyle = {};
45
+
45
46
  if(!_noNormalize && parseFloat(val, 10) != val){
46
47
  val = o.min + ((o.max - o.min) / 2);
47
48
  }
@@ -51,6 +52,7 @@
51
52
  }
52
53
  left = 100 * ((val - o.min) / (o.max - o.min));
53
54
 
55
+ if(this._init && val == o.value && oVal == val){return;}
54
56
  this.options.value = val;
55
57
  this.thumb.stop();
56
58
  this.range.stop();
@@ -120,24 +122,30 @@
120
122
  $('.ws-range-ticks', trail).remove();
121
123
 
122
124
 
123
- $(this.orig).jProp('list').find('option').each(function(){
124
- o.options[$.prop(this, 'value')] = $.prop(this, 'label');
125
+ $(this.orig).jProp('list').find('option:not([disabled])').each(function(){
126
+ o.options[$.prop(this, 'value')] = $.prop(this, 'label') || '';
125
127
  });
126
128
 
127
129
  $.each(o.options, function(val, label){
128
130
  if(!isNumber(val) || val < min || val > max){return;}
129
131
  var left = 100 * ((val - min) / (max - min));
130
- var title = o.showLabels ? ' title="'+ label +'"' : '';
132
+ var title = o.showLabels && label ? ' title="'+ label +'"' : '';
131
133
  if(that.vertical){
132
134
  left = Math.abs(left - 100);
133
135
  }
134
- trail.append('<span class="ws-range-ticks"'+ title +' style="'+(that.dirs.left)+': '+left+'%;" />');
136
+
137
+ that.posCenter(
138
+ $('<span class="ws-range-ticks"'+ title +' data-label="'+label+'" style="'+(that.dirs.left)+': '+left+'%;" />').appendTo(trail)
139
+ );
135
140
  });
136
141
  },
137
142
  readonly: function(val){
138
143
  val = !!val;
139
144
  this.options.readonly = val;
140
145
  this.element.attr('aria-readonly', ''+val);
146
+ if(this._init){
147
+ this.updateMetrics();
148
+ }
141
149
  },
142
150
  disabled: function(val){
143
151
  val = !!val;
@@ -147,6 +155,9 @@
147
155
  } else {
148
156
  this.element.attr({tabindex: this.options.tabindex, 'aria-disabled': 'false'});
149
157
  }
158
+ if(this._init){
159
+ this.updateMetrics();
160
+ }
150
161
  },
151
162
  tabindex: function(val){
152
163
  this.options.tabindex = val;
@@ -226,6 +237,24 @@
226
237
 
227
238
  return val;
228
239
  },
240
+ addRemoveClass: function(cName, add){
241
+ var isIn = this.element.prop('className').indexOf(cName) != -1;
242
+ var action;
243
+ if(!add && isIn){
244
+ action = 'removeClass';
245
+ this.element.removeClass(cName);
246
+ this.updateMetrics();
247
+ } else if(add && !isIn){
248
+ action = 'addClass';
249
+
250
+ }
251
+ if(action){
252
+ this.element[action](cName);
253
+ if(this._init){
254
+ this.updateMetrics();
255
+ }
256
+ }
257
+ },
229
258
  addBindings: function(){
230
259
  var leftOffset, widgetUnits, hasFocus;
231
260
  var that = this;
@@ -265,25 +294,36 @@
265
294
  that.value(val, false, animate);
266
295
  eventTimer.call('input', val);
267
296
  }
297
+ if(e && e.type == 'mousemove'){
298
+ e.preventDefault();
299
+ }
268
300
  };
269
-
270
301
  var remove = function(e){
271
302
  if(e && e.type == 'mouseup'){
272
303
  eventTimer.call('input', o.value);
273
304
  eventTimer.call('change', o.value);
274
305
  }
275
- that.element.removeClass('ws-active');
306
+ that.addRemoveClass('ws-active');
276
307
  $(document).off('mousemove', setValueFromPos).off('mouseup', remove);
308
+ $(window).off('blur', removeWin);
309
+ };
310
+ var removeWin = function(e){
311
+ if(e.target == window){remove();}
277
312
  };
278
313
  var add = function(e){
314
+ var outerWidth;
279
315
  e.preventDefault();
280
316
  $(document).off('mousemove', setValueFromPos).off('mouseup', remove);
317
+ $(window).off('blur', removeWin);
281
318
  if(!o.readonly && !o.disabled){
282
- leftOffset = that.element.focus().addClass('ws-active').offset();
283
- widgetUnits = that.element[that.dirs.width]();
319
+ that.element.focus();
320
+ that.addRemoveClass('ws-active', true);
321
+ leftOffset = that.element.focus().offset();
322
+ widgetUnits = that.element[that.dirs.innerWidth]();
284
323
  if(!widgetUnits || !leftOffset){return;}
324
+ outerWidth = that.thumb[that.dirs.outerWidth]();
285
325
  leftOffset = leftOffset[that.dirs.pos];
286
- widgetUnits = 100 / (widgetUnits - ((that.thumb[that.dirs.outerWidth]() || 2) / 2));
326
+ widgetUnits = 100 / widgetUnits;
287
327
  setValueFromPos(e, o.animate);
288
328
  $(document)
289
329
  .on({
@@ -291,6 +331,7 @@
291
331
  mousemove: setValueFromPos
292
332
  })
293
333
  ;
334
+ $(window).on('blur', removeWin);
294
335
  e.stopPropagation();
295
336
  }
296
337
  };
@@ -300,18 +341,20 @@
300
341
  if(!o.disabled){
301
342
  eventTimer.init('input', o.value);
302
343
  eventTimer.init('change', o.value);
303
- that.element.addClass('ws-focus');
344
+ that.addRemoveClass('ws-focus', true);
345
+ that.updateMetrics();
304
346
  }
305
347
  hasFocus = true;
306
348
  },
307
349
  blur: function(e){
308
350
  that.element.removeClass('ws-focus ws-active');
351
+ that.updateMetrics();
309
352
  hasFocus = false;
310
353
  eventTimer.init('input', o.value);
311
354
  eventTimer.call('change', o.value);
312
355
  },
313
356
  keyup: function(){
314
- that.element.removeClass('ws-active');
357
+ that.addRemoveClass('ws-active');
315
358
  eventTimer.call('input', o.value);
316
359
  eventTimer.call('change', o.value);
317
360
  },
@@ -336,7 +379,7 @@
336
379
  step = false;
337
380
  }
338
381
  if (step) {
339
- that.element.addClass('ws-active');
382
+ that.addRemoveClass('ws-active', true);
340
383
  eventTimer.call('input', o.value);
341
384
  e.preventDefault();
342
385
  }
@@ -358,38 +401,88 @@
358
401
  this.thumb.on({
359
402
  mousedown: add
360
403
  });
404
+ $(function(){
405
+ webshims.ready('dom-support', function(){
406
+ that.element.onWSOff('updateshadowdom', function(){
407
+ that.updateMetrics();
408
+ });
409
+ });
410
+ if(!$.fn.onWSOff){
411
+ webshims._polyfill(['dom-support']);
412
+ }
413
+ });
414
+ },
415
+ posCenter: function(elem, outerWidth){
416
+ var temp;
417
+ if(this.options.calcCenter && (!this._init || this.element[0].offsetWidth)){
418
+ if(!elem){
419
+ elem = this.thumb;
420
+ }
421
+ if(!outerWidth){
422
+ outerWidth = elem[this.dirs.outerWidth]();
423
+ }
424
+ outerWidth = outerWidth / -2;
425
+ elem.css(this.dirs.marginLeft, outerWidth);
426
+
427
+ if(this.options.calcTrail && elem[0] == this.thumb[0]){
428
+ temp = this.element[this.dirs.innerHeight]();
429
+ elem.css(this.dirs.marginTop, (elem[this.dirs.outerHeight]() - temp) / -2);
430
+ this.range.css(this.dirs.marginTop, (this.range[this.dirs.outerHeight]() - temp) / -2 );
431
+ outerWidth *= -1;
432
+ this.trail
433
+ .css(this.dirs.left, outerWidth)
434
+ .css(this.dirs.right, outerWidth)
435
+ ;
436
+ }
437
+ }
361
438
  },
362
439
  updateMetrics: function(){
363
440
  var width = this.element.innerWidth();
364
441
  this.vertical = (width && this.element.innerHeight() - width > 10);
365
442
 
366
443
  this.dirs = this.vertical ?
367
- {mouse: 'pageY', pos: 'top', min: 'max', max: 'min', left: 'top', width: 'height', outerWidth: 'outerHeight'} :
368
- {mouse: 'pageX', pos: 'left', min: 'min', max: 'max', left: 'left', width: 'width', outerWidth: 'outerWidth'}
444
+ {mouse: 'pageY', pos: 'top', min: 'max', max: 'min', left: 'top', right: 'bottom', width: 'height', innerWidth: 'innerHeight', innerHeight: 'innerWidth', outerWidth: 'outerHeight', outerHeight: 'outerWidth', marginTop: 'marginLeft', marginLeft: 'marginTop'} :
445
+ {mouse: 'pageX', pos: 'left', min: 'min', max: 'max', left: 'left', right: 'right', width: 'width', innerWidth: 'innerWidth', innerHeight: 'innerHeight', outerWidth: 'outerWidth', outerHeight: 'outerHeight', marginTop: 'marginTop', marginLeft: 'marginLeft'}
369
446
  ;
370
447
  this.element
371
448
  [this.vertical ? 'addClass' : 'removeClass']('vertical-range')
372
449
  [this.vertical ? 'addClass' : 'removeClass']('horizontal-range')
373
450
  ;
451
+ this.posCenter();
374
452
  }
375
453
  };
376
454
 
377
455
  $.fn.rangeUI = function(opts){
378
- opts = $.extend({readonly: false, disabled: false, tabindex: 0, min: 0, step: 1, max: 100, value: 50, input: $.noop, change: $.noop, _change: $.noop, showLabels: true, options: {}}, opts);
456
+ opts = $.extend({
457
+ readonly: false,
458
+ disabled: false,
459
+ tabindex: 0,
460
+ min: 0,
461
+ step: 1,
462
+ max: 100,
463
+ value: 50,
464
+ input: $.noop,
465
+ change: $.noop,
466
+ _change: $.noop,
467
+ showLabels: true,
468
+ options: {},
469
+ calcCenter: true,
470
+ calcTrail: true
471
+ }, opts);
379
472
  return this.each(function(){
380
- $.webshims.objectCreate(rangeProto, {
473
+ webshims.objectCreate(rangeProto, {
381
474
  element: {
382
475
  value: $(this)
383
476
  }
384
477
  }, opts);
385
478
  });
386
479
  };
387
- jQuery.webshims.isReady('range-ui', true);
480
+ webshims.isReady('range-ui', true);
388
481
  })(jQuery);
389
- jQuery.webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
482
+ webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
390
483
  "use strict";
391
484
  var curCfg;
392
- var formcfg = $.webshims.formcfg;
485
+ var formcfg = webshims.formcfg;
393
486
 
394
487
  var stopPropagation = function(e){
395
488
  e.stopImmediatePropagation(e);
@@ -407,7 +500,7 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
407
500
  date: {
408
501
  _create: function(){
409
502
  var obj = {
410
- splits: [$('<input type="text" class="yy" size="4" maxlength />')[0], $('<input type="text" class="mm" maxlength="2" size="2" />')[0], $('<input type="text" class="dd ws-spin" maxlength="2" size="2" />')[0]]
503
+ splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" />')[0], $('<input type="text" class="mm" inputmode="numeric" maxlength="2" size="2" />')[0], $('<input type="text" class="dd ws-spin" inputmode="numeric" maxlength="2" size="2" />')[0]]
411
504
  };
412
505
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]];
413
506
  return obj;
@@ -433,7 +526,7 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
433
526
  month: {
434
527
  _create: function(){
435
528
  var obj = {
436
- splits: [$('<input type="text" class="yy" size="4" />')[0], $('<input type="text" class="mm ws-spin" />')[0]]
529
+ splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0], $('<input type="text" class="mm ws-spin" />')[0]]
437
530
  };
438
531
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
439
532
  return obj;
@@ -453,6 +546,23 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
453
546
  }
454
547
  }
455
548
  };
549
+
550
+ var steps = {
551
+ number: {
552
+ step: 1
553
+ },
554
+ time: {
555
+ step: 60
556
+ },
557
+ month: {
558
+ step: 1,
559
+ start: new Date()
560
+ },
561
+ date: {
562
+ step: 1,
563
+ start: new Date()
564
+ }
565
+ };
456
566
  var labelWidth = (function(){
457
567
  var getId = function(){
458
568
  return webshims.getID(this);
@@ -477,7 +587,8 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
477
587
 
478
588
  (function(){
479
589
  var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
480
- formcfg.de = {
590
+
591
+ formcfg.de = $.extend(true, {
481
592
  numberFormat: {
482
593
  ",": ".",
483
594
  ".": ","
@@ -511,9 +622,9 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
511
622
  showMonthAfterYear: false,
512
623
  yearSuffix: ''
513
624
  }
514
- };
625
+ }, formcfg.de || {});
515
626
 
516
- formcfg.en = {
627
+ formcfg.en = $.extend(true, {
517
628
  numberFormat: {
518
629
  ".": ".",
519
630
  ",": ","
@@ -545,13 +656,17 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
545
656
  "showMonthAfterYear": false,
546
657
  "yearSuffix": ""
547
658
  }
548
- };
659
+ }, formcfg['en'] || {});
660
+ if(!formcfg['en-US']){
661
+ formcfg['en-US'] = formcfg['en'];
662
+ }
663
+ if(!formcfg['']){
664
+ formcfg[''] = formcfg['en-US'];
665
+ }
549
666
 
550
- formcfg['en-US'] = formcfg['en-US'] || formcfg['en'];
551
- formcfg[''] = formcfg[''] || formcfg['en-US'];
552
667
  curCfg = formcfg[''];
553
668
 
554
- var createMonthKeys = function(langCfg){
669
+ var processLangCFG = function(langCfg){
555
670
  if(!langCfg.date.monthkeys){
556
671
  var create = function(i, name){
557
672
  var strNum;
@@ -567,24 +682,25 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
567
682
  $.each(langCfg.date.monthNames, create);
568
683
  $.each(langCfg.date.monthNamesShort, create);
569
684
  }
685
+ if(!langCfg.colorSigns){
686
+ langCfg.colorSigns = '#abcdefABCDEF';
687
+ }
570
688
  };
571
689
 
572
- createMonthKeys(curCfg);
690
+ processLangCFG(curCfg);
573
691
 
574
- $.webshims.ready('dom-extend', function(){
575
- $.webshims.activeLang({
576
- register: 'form-core',
577
- callback: function(){
578
- $.each(arguments, function(i, val){
579
- if(formcfg[val]){
580
- curCfg = formcfg[val];
581
- createMonthKeys(curCfg);
582
- $(document).triggerHandler('wslocalechange');
583
- return false;
584
- }
585
- });
586
- }
587
- });
692
+ $.webshims.activeLang({
693
+ register: 'form-core',
694
+ callback: function(){
695
+ $.each(arguments, function(i, val){
696
+ if(formcfg[val]){
697
+ curCfg = formcfg[val];
698
+ processLangCFG(curCfg);
699
+ $(document).triggerHandler('wslocalechange');
700
+ return false;
701
+ }
702
+ });
703
+ }
588
704
  });
589
705
  })();
590
706
 
@@ -604,8 +720,6 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
604
720
  return val * 1;
605
721
  };
606
722
 
607
- var createOpts = ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'value'];
608
-
609
723
 
610
724
  var formatVal = {
611
725
  number: function(val){
@@ -644,6 +758,16 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
644
758
  }
645
759
 
646
760
  return val;
761
+ },
762
+ color: function(val, opts){
763
+ var ret = '#000000';
764
+ if(val){
765
+ val = val.toLowerCase();
766
+ if(val.length == 7 && createHelper('color').isValid(val)) {
767
+ ret = val;
768
+ }
769
+ }
770
+ return ret;
647
771
  }
648
772
  };
649
773
 
@@ -658,7 +782,7 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
658
782
 
659
783
  var p = (!opts.splitInput) ? val.trim().split(/[\.\s-\/\\]+/) : val;
660
784
 
661
- if(p.length == 2){
785
+ if(p.length == 2 && p[0] && p[1]){
662
786
  p[0] = curCfg.date.monthkeys[p[0]] || p[0];
663
787
  p[1] = curCfg.date.monthkeys[p[1]] || p[1];
664
788
  if(p[1].length == 2){
@@ -688,27 +812,25 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
688
812
  ([addZero(val[obj.yy]), addZero(val[obj.mm]), addZero(val[obj.dd])]).join('-') :
689
813
  ''
690
814
  ;
691
- }
692
- };
693
-
694
- var steps = {
695
- number: {
696
- step: 1
697
815
  },
698
- time: {
699
- step: 60
700
- },
701
- month: {
702
- step: 1,
703
- start: new Date()
704
- },
705
- date: {
706
- step: 1,
707
- start: new Date()
816
+ color: function(val, opts){
817
+ var ret = '#000000';
818
+ if(val){
819
+ val = val.toLowerCase();
820
+ if (val.indexOf('#') !== 0) {
821
+ val = '#' + val;
822
+ }
823
+ if(val.length == 4){
824
+ val = '#' + val.charAt(1) + val.charAt(1) + val.charAt(2) + val.charAt(2) + val.charAt(3) + val.charAt(3);
825
+ }
826
+ if(val.length == 7 && createHelper('color').isValid(val)) {
827
+ ret = val;
828
+ }
829
+ }
830
+ return ret;
708
831
  }
709
832
  };
710
833
 
711
-
712
834
  var placeholderFormat = {
713
835
  date: function(val, opts){
714
836
  var hintValue = (val || '').split('-');
@@ -753,6 +875,9 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
753
875
  asValue: function(val){
754
876
  var type = (typeof val == 'object') ? 'valueAsDate' : 'valueAsNumber';
755
877
  return input.prop(type, val).prop('value');
878
+ },
879
+ isValid: function(val){
880
+ return input.prop('value', val).is(':valid') && input.prop('value') == val;
756
881
  }
757
882
  };
758
883
  }
@@ -762,211 +887,80 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
762
887
 
763
888
  steps.range = steps.number;
764
889
 
765
-
766
- var spinBtnProto = {
890
+ var wsWidgetProto = {
767
891
  _create: function(){
768
- var i;
892
+ var i, that, timedMirror;
769
893
  var o = this.options;
770
- var helper = createHelper(o.type);
894
+ var createOpts = this.createOpts;
895
+
771
896
  this.type = o.type;
772
897
  this.orig = o.orig;
773
898
 
774
- this.elemHelper = $('<input type="'+ this.type+'" />');
775
- this.asNumber = helper.asNumber;
776
- this.asValue = helper.asValue;
899
+ this.buttonWrapper = $('<span class="input-buttons '+this.type+'-input-buttons"></span>').insertAfter(this.element);
900
+ this.options.containerElements.push(this.buttonWrapper[0]);
777
901
 
778
- this.buttonWrapper = $('<span class="input-buttons '+this.type+'-input-buttons"><span unselectable="on" class="step-controls"><span class="step-up"></span><span class="step-down"></span></span></span>')
779
- .insertAfter(this.element)
780
- ;
902
+ o.mirrorValidity = o.mirrorValidity && this.orig && Modernizr.formvalidation && !webshims.bugs.bustedValidity;
781
903
 
782
- if(o.splitInput){
904
+ if(o.splitInput && this._addSplitInputs){
783
905
  this._addSplitInputs();
784
906
  } else {
785
907
  this.inputElements = this.element;
786
908
  }
787
909
 
788
- this.options.containerElements.push(this.buttonWrapper[0]);
789
-
790
- if(typeof steps[this.type].start == 'object'){
910
+ if( steps[this.type] && typeof steps[this.type].start == 'object'){
791
911
  steps[this.type].start = this.asNumber(steps[this.type].start);
792
912
  }
793
913
 
794
-
795
-
796
914
  for(i = 0; i < createOpts.length; i++){
797
- this[createOpts[i]](o[createOpts[i]]);
798
- }
799
-
800
- this.element.data('wsspinner', this);
801
-
802
- this.addBindings();
803
-
804
- if(!o.min && typeof o.relMin == 'number'){
805
- o.min = this.asValue(this.getRelNumber(o.relMin));
806
- $.prop(this.orig, 'min', o.min);
915
+ if(o[createOpts[i]] != null){
916
+ this[createOpts[i]](o[createOpts[i]], o[createOpts[i]]);
917
+ }
807
918
  }
808
-
809
- if(!o.max && typeof o.relMax == 'number'){
810
- o.max = this.asValue(this.getRelNumber(o.relMax));
811
- $.prop(this.orig, 'max', o.max);
919
+ if(this.type == 'color'){
920
+ this.inputElements.prop('maxLength', 7);
812
921
  }
922
+ this.addBindings();
923
+ $(this.element).data('wsWidget'+o.type, this);
813
924
 
814
925
  this._init = true;
815
- },
816
- _addSplitInputs: function(){
817
- if(!this.inputElements){
818
- var create = splitInputs[this.type]._create();
819
- this.splits = create.splits;
820
- this.inputElements = $(create.elements).prependTo(this.element).filter('input');
821
- }
822
- },
823
- parseValue: function(){
824
- var value = this.inputElements.map(function(){
825
- return $.prop(this, 'value');
826
- }).get();
827
- if(!this.options.splitInput){
828
- value = value[0];
829
- }
830
- return parseVal[this.type](value, this.options);
831
- },
832
- formatValue: function(val, noSplit){
833
- return formatVal[this.type](val, noSplit === false ? false : this.options);
834
- },
835
- placeholder: function(val){
836
- var options = this.options;
837
- options.placeholder = val;
838
- var placeholder = val;
839
- if(placeholderFormat[this.type]){
840
- placeholder = placeholderFormat[this.type](val, this.options);
841
- }
842
- if(options.splitInput && typeof placeholder == 'object'){
843
- $.each(this.splits, function(i, elem){
844
- $.prop(elem, 'placeholder', placeholder[i]);
845
- });
846
- } else {
847
- this.element.prop('placeholder', placeholder);
848
- }
849
- },
850
- getRelNumber: function(rel){
851
- var start = steps[this.type].start || 0;
852
- if(rel){
853
- start += rel;
854
- }
855
- return start;
856
- },
857
- addZero: addZero,
858
- _setStartInRange: function(){
859
- var start = this.getRelNumber(this.options.relDefaultValue);
860
- if(!isNaN(this.minAsNumber) && start < this.minAsNumber){
861
- start = this.minAsNumber;
862
- } else if(!isNaN(this.maxAsNumber) && start > this.maxAsNumber){
863
- start = this.maxAsNumber;
864
- }
865
- this.elemHelper.prop('valueAsNumber', start);
866
- this.options.defValue = this.elemHelper.prop('value');
867
-
868
- },
869
- reorderInputs: function(){
870
- if(splitInputs[this.type]){
871
- var element = this.element;
872
- splitInputs[this.type].sort(element);
873
- setTimeout(function(){
874
- var data = webshims.data(element);
875
- if(data && data.shadowData){
876
- data.shadowData.shadowFocusElement = element.find('input')[0] || element[0];
877
- }
878
- }, 9);
879
- }
880
- },
881
- value: function(val){
882
- this.valueAsNumber = this.asNumber(val);
883
- this.options.value = val;
884
- if(isNaN(this.valueAsNumber) || (!isNaN(this.minAsNumber) && this.valueAsNumber < this.minAsNumber) || (!isNaN(this.maxAsNumber) && this.valueAsNumber > this.maxAsNumber)){
885
- this._setStartInRange();
886
- } else {
887
- this.elemHelper.prop('value', val);
888
- this.options.defValue = "";
889
- }
890
926
 
891
- val = formatVal[this.type](val, this.options);
892
- if(this.options.splitInput){
927
+ if(o.mirrorValidity){
928
+ that = this;
929
+ timedMirror = function(){
930
+ clearTimeout(timedMirror._timerDealy);
931
+ timedMirror._timerDealy = setTimeout(timedMirror._wsexec, 9);
932
+ };
933
+ timedMirror._wsexec = function(){
934
+ clearTimeout(timedMirror._timerDealy);
935
+ that.mirrorValidity(true);
936
+ };
893
937
 
894
- $.each(this.splits, function(i, elem){
895
- $.prop(elem, 'value', val[i]);
896
- });
897
- } else {
898
- this.element.prop('value', val);
899
- }
900
-
901
- this._propertyChange('value');
902
- },
903
- initDataList: function(){
904
- var listTimer;
905
- var that = this;
906
- var updateList = function(){
907
- $(that.orig)
908
- .jProp('list')
909
- .off('updateDatalist', updateList)
910
- .on('updateDatalist', updateList)
911
- ;
912
- clearTimeout(listTimer);
913
- listTimer = setTimeout(function(){
914
- if(that.list){
915
- that.list();
938
+ timedMirror();
939
+ $(this.orig).on('change input', function(e){
940
+ if(e.type == 'input'){
941
+ timedMirror();
942
+ } else {
943
+ timedMirror._wsexec();
916
944
  }
917
- }, 9);
918
-
919
- };
920
-
921
- $(this.orig).onTrigger('listdatalistchange', updateList);
922
- },
923
- getOptions: function(){
924
- var options = {};
925
- var datalist = $(this.orig).jProp('list');
926
- datalist.find('option').each(function(){
927
- options[$.prop(this, 'value')] = $.prop(this, 'label');
928
- });
929
- return [options, datalist.data('label')];
930
- },
931
- list: function(val){
932
- if(this.type == 'number' || this.type == 'time'){
933
- this.element.attr('list', $.attr(this.orig, 'list'));
934
- }
935
- this.options.list = val;
936
- this._propertyChange('list');
937
- },
938
- _propertyChange: $.noop,
939
- tabindex: function(val){
940
- this.options.tabindex = val;
941
- this.inputElements.prop('tabindex', this.options.tabindex);
942
- },
943
- title: function(val){
944
- this.options.title = val;
945
- this.element.prop('title', this.options.title);
946
- },
947
-
948
- min: function(val){
949
- this.elemHelper.prop('min', val);
950
- this.minAsNumber = this.asNumber(val);
951
- if(this.valueAsNumber != null && isNaN(this.valueAsNumber)){
952
- this._setStartInRange();
945
+ });
953
946
  }
954
- this.options.min = val;
955
- this._propertyChange('min');
956
947
  },
957
- max: function(val){
958
- this.elemHelper.prop('max', val);
959
- this.maxAsNumber = this.asNumber(val);
960
- if(this.valueAsNumber != null && isNaN(this.valueAsNumber)){
961
- this._setStartInRange();
948
+ mirrorValidity: function(_noTest){
949
+ //
950
+ if(this._init && this.options.mirrorValidity){
951
+ if(!_noTest){
952
+ $.prop(this.orig, 'validity');
953
+ }
954
+ var message = $(this.orig).getErrorMessage();
955
+ if(message !== this.lastErrorMessage){
956
+ this.inputElements.prop('setCustomValidity', function(i, val){
957
+ if(val._supvalue){
958
+ val._supvalue.call(this, message);
959
+ }
960
+ });
961
+ this.lastErrorMessage = message;
962
+ }
962
963
  }
963
- this.options.max = val;
964
- this._propertyChange('max');
965
- },
966
- step: function(val){
967
- var defStep = steps[this.type];
968
- this.options.step = val;
969
- this.elemHelper.prop('step', retDefault(val, defStep.step));
970
964
  },
971
965
  addBindings: function(){
972
966
  var isFocused;
@@ -1019,6 +1013,9 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
1019
1013
  var val;
1020
1014
  clearTimeout(timer);
1021
1015
  val = that.parseValue();
1016
+ if(that.type == 'color'){
1017
+ that.inputElements.val(val);
1018
+ }
1022
1019
  $.prop(that.orig, 'value', val);
1023
1020
  eventTimer.call('input', val);
1024
1021
  if(!e || e.type != 'wsupdatevalue'){
@@ -1055,6 +1052,7 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
1055
1052
  ;
1056
1053
  setTimeout(function(){
1057
1054
  if(that.popover){
1055
+ that.popover.element.on('wspopoverhide', onBlur);
1058
1056
  $('> *', that.popover.element)
1059
1057
  .on({
1060
1058
  'focusin': onFocus,
@@ -1135,7 +1133,7 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
1135
1133
  e.preventDefault();
1136
1134
  }
1137
1135
  }
1138
- }
1136
+ };
1139
1137
  })()
1140
1138
  };
1141
1139
  var mouseDownInit = function(){
@@ -1159,28 +1157,6 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
1159
1157
  };
1160
1158
  })();
1161
1159
 
1162
- ['stepUp', 'stepDown'].forEach(function(name){
1163
- step[name] = function(factor){
1164
- if(!o.disabled && !o.readonly){
1165
- if(!isFocused){
1166
- mouseDownInit();
1167
- }
1168
- var ret = false;
1169
- if (!factor) {
1170
- factor = 1;
1171
- }
1172
- try {
1173
- that.elemHelper[name](factor);
1174
- ret = that.elemHelper.prop('value');
1175
- that.value(ret);
1176
- eventTimer.call('input', ret);
1177
- } catch (er) {}
1178
- return ret;
1179
- }
1180
- };
1181
- });
1182
-
1183
-
1184
1160
 
1185
1161
  this.buttonWrapper.on('mousedown', mouseDownInit);
1186
1162
 
@@ -1197,960 +1173,415 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
1197
1173
 
1198
1174
  this.inputElements.on(elementEvts);
1199
1175
 
1200
- if(!o.noSpinbtn){
1201
- spinEvents[$.fn.mwheelIntent ? 'mwheelIntent' : 'mousewheel'] = function(e, delta){
1202
- if(delta && isFocused && !o.disabled){
1203
- step[delta > 0 ? 'stepUp' : 'stepDown']();
1204
- e.preventDefault();
1205
- }
1206
- };
1207
- spinEvents.keydown = function(e){
1208
- if(o.list || e.isDefaultPrevented() || $.attr(this, 'list')){return;}
1209
- var stepped = true;
1210
- var code = e.keyCode;
1211
- if (code == 38) {
1212
- step.stepUp();
1213
- } else if (code == 40) {
1214
- step.stepDown();
1215
- } else {
1216
- stepped = false;
1217
- }
1218
- if(stepped){
1219
- e.preventDefault();
1220
- }
1221
- };
1222
-
1223
- spinElement.attr({'autocomplete': 'off', role: 'spinbutton'}).on(spinEvents);
1224
- }
1225
-
1226
-
1227
- if(!o.splitInput){
1228
- $(document).on('wslocalechange',function(){
1229
- if(o.value){
1230
- that.value(o.value);
1231
- }
1232
-
1233
- if(placeholderFormat[that.type] && o.placeholder){
1234
- that.placeholder(o.placeholder);
1235
- }
1176
+ if(steps[this.type]){
1177
+ ['stepUp', 'stepDown'].forEach(function(name){
1178
+ step[name] = function(factor){
1179
+ if(!o.disabled && !o.readonly){
1180
+ if(!isFocused){
1181
+ mouseDownInit();
1182
+ }
1183
+ var ret = false;
1184
+ if (!factor) {
1185
+ factor = 1;
1186
+ }
1187
+ try {
1188
+ that.elemHelper[name](factor);
1189
+ ret = that.elemHelper.prop('value');
1190
+ that.value(ret);
1191
+ eventTimer.call('input', ret);
1192
+ } catch (er) {}
1193
+ return ret;
1194
+ }
1195
+ };
1236
1196
  });
1237
- } else {
1238
- $(document).onTrigger('wslocalechange',function(){
1239
- that.reorderInputs();
1240
- });
1241
- }
1242
-
1243
- $('.step-up', this.buttonWrapper)
1244
- .on({
1245
- 'mousepressstart mousepressend': mousePress,
1246
- 'mousedown mousepress': function(e){
1247
- step.stepUp();
1248
- }
1249
- })
1250
- ;
1251
- $('.step-down', this.buttonWrapper)
1252
- .on({
1253
- 'mousepressstart mousepressend': mousePress,
1254
- 'mousedown mousepress': function(e){
1255
- step.stepDown();
1256
- }
1257
- })
1258
- ;
1259
- initChangeEvents();
1260
- }
1261
- };
1262
-
1263
- ['readonly', 'disabled'].forEach(function(name){
1264
- spinBtnProto[name] = function(val){
1265
- if(this.options[name] != val || !this._init){
1266
- this.options[name] = !!val;
1267
- if(name == 'readonly' && this.options.noInput){
1268
- this.element
1269
- .prop(name, true)
1270
- .attr({'aria-readonly': this.options[name]})
1271
- ;
1272
- } else {
1273
- this.element.prop(name, this.options[name]);
1197
+ if(!o.noSpinbtn){
1198
+ spinEvents[$.fn.mwheelIntent ? 'mwheelIntent' : 'mousewheel'] = function(e, delta){
1199
+ if(delta && isFocused && !o.disabled){
1200
+ step[delta > 0 ? 'stepUp' : 'stepDown']();
1201
+ e.preventDefault();
1202
+ }
1203
+ };
1204
+ spinEvents.keydown = function(e){
1205
+ if(o.list || e.isDefaultPrevented() || $.attr(this, 'list')){return;}
1206
+ var stepped = true;
1207
+ var code = e.keyCode;
1208
+ if (code == 38) {
1209
+ step.stepUp();
1210
+ } else if (code == 40) {
1211
+ step.stepDown();
1212
+ } else {
1213
+ stepped = false;
1214
+ }
1215
+ if(stepped){
1216
+ e.preventDefault();
1217
+ }
1218
+ };
1219
+
1220
+ spinElement.attr({'autocomplete': 'off', role: 'spinbutton'}).on(spinEvents);
1274
1221
  }
1275
- this.buttonWrapper[this.options[name] ? 'addClass' : 'removeClass']('ws-'+name);
1222
+ $(this.buttonWrapper)
1223
+ .on('mousepressstart mousepressend', '.step-up, .step-down', mousePress)
1224
+ .on('mousedown mousepress', '.step-up', function(e){
1225
+ step.stepUp();
1226
+ })
1227
+ .on('mousedown mousepress', '.step-down', function(e){
1228
+ step.stepDown();
1229
+ })
1230
+ ;
1276
1231
  }
1277
- };
1278
- });
1279
-
1280
-
1281
- $.fn.spinbtnUI = function(opts){
1282
- opts = $.extend({
1283
- monthNames: 'monthNames',
1284
- size: 1,
1285
- startView: 0
1286
- }, opts);
1287
- return this.each(function(){
1288
- $.webshims.objectCreate(spinBtnProto, {
1289
- element: {
1290
- value: $(this)
1291
- }
1292
- }, opts);
1293
- });
1294
- };
1295
- })();
1296
-
1297
- (function(){
1298
- var picker = {};
1299
- var disable = {
1300
-
1301
- };
1302
-
1303
- var getDateArray = function(date){
1304
- var ret = [date.getFullYear(), addZero(date.getMonth() + 1), addZero(date.getDate())];
1305
- ret.month = ret[0]+'-'+ret[1];
1306
- ret.date = ret[0]+'-'+ret[1]+'-'+ret[2];
1307
- return ret;
1308
- };
1309
- var today = getDateArray(new Date());
1232
+ if(this.type != 'color'){
1233
+ (function(){
1234
+ var localeChange ;
1235
+ if(!o.splitInput){
1236
+ localeChange = function(){
1237
+ if(o.value){
1238
+ that.value(o.value);
1239
+ }
1310
1240
 
1311
- var _setFocus = function(element, _noFocus){
1312
- var setFocus, that;
1313
- element = $(element || this.activeButton);
1314
- this.activeButton.attr({tabindex: '-1', 'aria-selected': 'false'});
1315
- this.activeButton = element.attr({tabindex: '0', 'aria-selected': 'true'});
1316
- this.index = this.buttons.index(this.activeButton[0]);
1317
-
1318
- clearTimeout(this.timer);
1319
-
1320
- if(!this.popover.openedByFocus && !_noFocus){
1321
- that = this;
1322
- setFocus = function(noTrigger){
1323
- clearTimeout(that.timer);
1324
- that.timer = setTimeout(function(){
1325
- if(element[0]){
1326
- element[0].focus();
1327
- if(noTrigger !== true && !element.is(':focus')){
1328
- setFocus(true);
1329
- }
1241
+ if(placeholderFormat[that.type] && o.placeholder){
1242
+ that.placeholder(o.placeholder);
1243
+ }
1244
+ };
1245
+ } else {
1246
+ localeChange = function(){
1247
+ that.reorderInputs();
1248
+ };
1249
+ that.reorderInputs();
1330
1250
  }
1331
- }, that.popover.isVisible ? 99 : 360);
1332
- };
1333
- this.popover.activateElement(element);
1334
- setFocus();
1335
- }
1336
-
1337
- };
1338
-
1339
- var _initialFocus = function(){
1340
- var sel;
1341
- if(this.popover.navedInitFocus){
1342
- sel = this.popover.navedInitFocus.sel || this.popover.navedInitFocus;
1343
- if((!this.activeButton || !this.activeButton[0]) && this.buttons[sel]){
1344
- this.activeButton = this.buttons[sel]();
1345
- } else if(sel){
1346
- this.activeButton = $(sel, this.element);
1251
+ $(that.orig).onWSOff('wslocalechange', localeChange);
1252
+ })();
1347
1253
  }
1348
1254
 
1349
- if(!this.activeButton[0] && this.popover.navedInitFocus.alt){
1350
- this.activeButton = this.buttons[this.popover.navedInitFocus.alt]();
1255
+ initChangeEvents();
1256
+ },
1257
+ value: function(val){
1258
+ if(!this._init || val !== this.options.value){
1259
+ this.element.val(this.formatValue(val));
1260
+ this.options.value = val;
1261
+ this._propertyChange('value');
1262
+ this.mirrorValidity();
1351
1263
  }
1352
- }
1353
-
1354
- if(!this.activeButton || !this.activeButton[0]){
1355
- this.activeButton = this.buttons.filter('.checked-value');
1356
- }
1357
-
1358
- if(!this.activeButton[0]){
1359
- this.activeButton = this.buttons.filter('.this-value');
1360
- }
1361
- if(!this.activeButton[0]){
1362
- this.activeButton = this.buttons.eq(0);
1363
- }
1364
-
1365
- this.setFocus(this.activeButton, this.opts.noFocus);
1366
- };
1367
-
1368
-
1369
- webshims.ListBox = function (element, popover, opts){
1370
- this.element = $('ul', element);
1371
- this.popover = popover;
1372
- this.opts = opts || {};
1373
- this.buttons = $('button:not(:disabled)', this.element);
1374
-
1375
-
1376
- this.ons(this);
1377
- this._initialFocus();
1378
- };
1379
-
1380
- webshims.ListBox.prototype = {
1381
- setFocus: _setFocus,
1382
- _initialFocus: _initialFocus,
1383
- prev: function(){
1384
- var index = this.index - 1;
1385
- if(index < 0){
1386
- if(this.opts.prev){
1387
- this.popover.navedInitFocus = 'last';
1388
- this.popover.actionFn(this.opts.prev);
1389
- this.popover.navedInitFocus = false;
1390
- }
1391
- } else {
1392
- this.setFocus(this.buttons.eq(index));
1264
+
1265
+ },
1266
+ required: function(val, boolVal){
1267
+ this.inputElements.attr({'aria-required': ''+boolVal});
1268
+ this.mirrorValidity();
1269
+ },
1270
+ parseValue: function(){
1271
+ var value = this.inputElements.map(function(){
1272
+ return $.prop(this, 'value');
1273
+ }).get();
1274
+ if(!this.options.splitInput){
1275
+ value = value[0];
1393
1276
  }
1277
+ return parseVal[this.type](value, this.options);
1394
1278
  },
1395
- next: function(){
1396
- var index = this.index + 1;
1397
- if(index >= this.buttons.length){
1398
- if(this.opts.next){
1399
- this.popover.navedInitFocus = 'first';
1400
- this.popover.actionFn(this.opts.next);
1401
- this.popover.navedInitFocus = false;
1402
- }
1279
+ formatValue: function(val, noSplit){
1280
+ return formatVal[this.type](val, noSplit === false ? false : this.options);
1281
+ },
1282
+ createOpts: ['readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'value', 'required'],
1283
+ placeholder: function(val){
1284
+ var options = this.options;
1285
+ options.placeholder = val;
1286
+ var placeholder = val;
1287
+ if(placeholderFormat[this.type]){
1288
+ placeholder = placeholderFormat[this.type](val, this.options);
1289
+ }
1290
+ if(options.splitInput && typeof placeholder == 'object'){
1291
+ $.each(this.splits, function(i, elem){
1292
+ $.prop(elem, 'placeholder', placeholder[i]);
1293
+ });
1403
1294
  } else {
1404
- this.setFocus(this.buttons.eq(index));
1295
+ this.element.prop('placeholder', placeholder);
1405
1296
  }
1406
1297
  },
1407
- ons: function(that){
1408
- this.element
1409
- .on({
1410
- 'keydown': function(e){
1411
- var handled;
1412
- var key = e.keyCode;
1413
- if(e.ctrlKey){return;}
1414
- if(key == 36 || key == 33){
1415
- that.setFocus(that.buttons.eq(0));
1416
- handled = true;
1417
- } else if(key == 34 || key == 35){
1418
- that.setFocus(that.buttons.eq(that.buttons.length - 1));
1419
- handled = true;
1420
- } else if(key == 38 || key == 37){
1421
- that.prev();
1422
- handled = true;
1423
- } else if(key == 40 || key == 39){
1424
- that.next();
1425
- handled = true;
1426
- }
1427
- if(handled){
1428
- return false;
1429
- }
1298
+ initDataList: function(){
1299
+ var listTimer;
1300
+ var that = this;
1301
+ var updateList = function(){
1302
+ $(that.orig)
1303
+ .jProp('list')
1304
+ .off('updateDatalist', updateList)
1305
+ .on('updateDatalist', updateList)
1306
+ ;
1307
+ clearTimeout(listTimer);
1308
+ listTimer = setTimeout(function(){
1309
+ if(that.list){
1310
+ that.list();
1430
1311
  }
1431
- })
1432
- ;
1433
- }
1434
- };
1435
-
1436
- webshims.Grid = function (element, popover, opts){
1437
- this.element = $('tbody', element);
1438
- this.popover = popover;
1439
- this.opts = opts || {};
1440
- this.buttons = $('button:not(:disabled,.othermonth)', this.element);
1441
-
1442
- this.ons(this);
1443
-
1444
- this._initialFocus();
1445
- if(this.popover.openedByFocus){
1446
- this.popover.activeElement = this.activeButton;
1447
- }
1448
- };
1449
-
1450
-
1451
-
1452
- webshims.Grid.prototype = {
1453
- setFocus: _setFocus,
1454
- _initialFocus: _initialFocus,
1455
-
1456
- first: function(){
1457
- this.setFocus(this.buttons.eq(0));
1312
+ }, 9);
1313
+
1314
+ };
1315
+
1316
+ $(this.orig).onTrigger('listdatalistchange', updateList);
1458
1317
  },
1459
- last: function(){
1460
- this.setFocus(this.buttons.eq(this.buttons.length - 1));
1318
+ getOptions: function(){
1319
+ var options = {};
1320
+ var datalist = $(this.orig).jProp('list');
1321
+ datalist.find('option').each(function(){
1322
+ options[$.prop(this, 'value')] = $.prop(this, 'label');
1323
+ });
1324
+ return [options, datalist.data('label')];
1461
1325
  },
1462
- upPage: function(){
1463
- $('.ws-picker-header > button:not(:disabled)', this.popover.element).trigger('click');
1326
+ list: function(val){
1327
+ if(this.type == 'number' || this.type == 'time'){
1328
+ this.element.attr('list', $.attr(this.orig, 'list'));
1329
+ }
1330
+ this.options.list = val;
1331
+ this._propertyChange('list');
1464
1332
  },
1465
- downPage: function(){
1466
- this.activeButton.filter(':not([data-action="changeInput"])').trigger('click');
1333
+ _propertyChange: $.noop,
1334
+ tabindex: function(val){
1335
+ this.options.tabindex = val;
1336
+ this.inputElements.prop('tabindex', this.options.tabindex);
1337
+ $('button', this.buttonWrapper).prop('tabindex', this.options.tabindex);
1467
1338
  },
1468
- ons: function(that){
1469
- this.element
1470
- .on({
1471
- 'keydown': function(e){
1472
- var handled;
1473
- var key = e.keyCode;
1474
-
1475
- if(e.shiftKey){return;}
1476
-
1477
- if((e.ctrlKey && key == 40)){
1478
- handled = 'downPage';
1479
- } else if((e.ctrlKey && key == 38)){
1480
- handled = 'upPage';
1481
- } else if(key == 33 || (e.ctrlKey && key == 37)){
1482
- handled = 'prevPage';
1483
- } else if(key == 34 || (e.ctrlKey && key == 39)){
1484
- handled = 'nextPage';
1485
- } else if(e.keyCode == 36 || e.keyCode == 33){
1486
- handled = 'first';
1487
- } else if(e.keyCode == 35){
1488
- handled = 'last';
1489
- } else if(e.keyCode == 38){
1490
- handled = 'up';
1491
- } else if(e.keyCode == 37){
1492
- handled = 'prev';
1493
- } else if(e.keyCode == 40){
1494
- handled = 'down';
1495
- } else if(e.keyCode == 39){
1496
- handled = 'next';
1497
- }
1498
- if(handled){
1499
- that[handled]();
1500
- return false;
1501
- }
1502
- }
1503
- })
1504
- ;
1505
- }
1506
- };
1507
- $.each({
1508
- prevPage: {get: 'last', action: 'prev'},
1509
- nextPage: {get: 'first', action: 'next'}
1510
- }, function(name, val){
1511
- webshims.Grid.prototype[name] = function(){
1512
- if(this.opts[val.action]){
1513
- this.popover.navedInitFocus = {
1514
- sel: 'button[data-id="'+ this.activeButton.attr('data-id') +'"]:not(:disabled,.othermonth)',
1515
- alt: val.get
1516
- };
1517
- this.popover.actionFn(this.opts[val.action]);
1518
- this.popover.navedInitFocus = false;
1519
- }
1520
- };
1521
- });
1522
-
1523
- $.each({
1524
- up: {traverse: 'prevAll', get: 'last', action: 'prev', reverse: true},
1525
- down: {traverse: 'nextAll', get: 'first', action: 'next'}
1526
- }, function(name, val){
1527
- webshims.Grid.prototype[name] = function(){
1528
- var cellIndex = this.activeButton.closest('td').prop('cellIndex');
1529
- var sel = 'td:nth-child('+(cellIndex + 1)+') button:not(:disabled,.othermonth)';
1530
- var button = this.activeButton.closest('tr')[val.traverse]();
1531
-
1532
- if(val.reverse){
1533
- button = $(button.get().reverse());
1534
- }
1535
- button = button.find(sel)[val.get]();
1536
-
1537
- if(!button[0]){
1538
- if(this.opts[val.action]){
1539
- this.popover.navedInitFocus = sel+':'+val.get;
1540
- this.popover.actionFn(this.opts[val.action]);
1541
- this.popover.navedInitFocus = false;
1542
- }
1543
- } else {
1544
- this.setFocus(button.eq(0));
1545
- }
1546
- };
1547
- });
1548
-
1549
- $.each({
1550
- prev: {traverse: 'prevAll',get: 'last', reverse: true},
1551
- next: {traverse: 'nextAll', get: 'first'}
1552
- }, function(name, val){
1553
- webshims.Grid.prototype[name] = function(){
1554
- var sel = 'button:not(:disabled,.othermonth)';
1555
- var button = this.activeButton.closest('td')[val.traverse]('td');
1556
- if(val.reverse){
1557
- button = $(button.get().reverse());
1558
- }
1559
- button = button.find(sel)[val.get]();
1560
- if(!button[0]){
1561
- button = this.activeButton.closest('tr')[val.traverse]('tr');
1562
- if(val.reverse){
1563
- button = $(button.get().reverse());
1564
- }
1565
- button = button.find(sel)[val.get]();
1339
+ title: function(val){
1340
+ if(!val && this.orig && $.attr(this.orig, 'title') == null){
1341
+ val = null;
1566
1342
  }
1567
-
1568
- if(!button[0]){
1569
- if(this.opts[name]){
1570
- this.popover.navedInitFocus = val.get;
1571
- this.popover.actionFn(this.opts[name]);
1572
- this.popover.navedInitFocus = false;
1573
- }
1343
+ this.options.title = val;
1344
+ if(val == null){
1345
+ this.inputElements.removeAttr('title');
1574
1346
  } else {
1575
- this.setFocus(button.eq(0));
1347
+ this.inputElements.prop('title', this.options.title);
1576
1348
  }
1577
- };
1578
- });
1579
-
1580
- picker.getWeek = function(date){
1581
- var onejan = new Date(date.getFullYear(),0,1);
1582
- return Math.ceil((((date - onejan) / 86400000) + onejan.getDay()+1)/7);
1583
- };
1584
- picker.getYearList = function(value, data){
1585
- var j, i, val, disabled, lis, prevDisabled, nextDisabled, classStr, classArray, start;
1586
-
1587
-
1588
- var size = data.options.size;
1589
- var max = data.options.max.split('-');
1590
- var min = data.options.min.split('-');
1591
- var currentValue = data.options.value.split('-');
1592
- var xthCorrect = 0;
1593
- var enabled = 0;
1594
- var str = '';
1595
- var rowNum = 0;
1596
-
1597
- if(data.options.useDecadeBase == 'max' && max[0]){
1598
- xthCorrect = 11 - (max[0] % 12);
1599
- } else if(data.options.useDecadeBase == 'min' && min[0]){
1600
- xthCorrect = 11 - (min[0] % 12);
1601
1349
  }
1602
-
1603
- value = value[0] * 1;
1604
- start = value - ((value + xthCorrect) % (12 * size));
1605
-
1606
-
1607
-
1608
- for(j = 0; j < size; j++){
1609
- if(j){
1610
- start += 12;
1611
- } else {
1612
- prevDisabled = picker.isInRange([start-1], max, min) ? {'data-action': 'setYearList','value': start-1} : false;
1613
- }
1614
-
1615
- str += '<div class="year-list picker-list ws-index-'+ j +'"><div class="ws-picker-header"><button disabled="disabled">'+ start +' – '+(start + 11)+'</button></div>';
1616
- lis = [];
1617
- for(i = 0; i < 12; i++){
1618
- val = start + i ;
1619
- classArray = [];
1620
- if( !picker.isInRange([val], max, min) ){
1621
- disabled = ' disabled=""';
1622
- } else {
1623
- disabled = '';
1624
- enabled++;
1625
- }
1626
-
1627
- if(val == today[0]){
1628
- classArray.push('this-value');
1629
- }
1630
-
1631
- if(currentValue[0] == val){
1632
- classArray.push('checked-value');
1633
- }
1634
-
1635
- classStr = classArray.length ? ' class="'+ (classArray.join(' ')) +'"' : '';
1636
-
1637
- if(i && !(i % 3)){
1638
- rowNum++;
1639
- lis.push('</tr><tr class="ws-row-'+ rowNum +'">');
1640
- }
1641
- lis.push('<td class="ws-item-'+ i +'" role="presentation"><button data-id="year-'+ i +'" type="button"'+ disabled + classStr +' data-action="setMonthList" value="'+val+'" tabindex="-1" role="gridcell">'+val+'</button></td>');
1642
- }
1643
- if(j == size - 1){
1644
- nextDisabled = picker.isInRange([val+1], max, min) ? {'data-action': 'setYearList','value': val+1} : false;
1645
- }
1646
- str += '<div class="picker-grid"><table role="grid" aria-label="'+ start +' – '+(start + 11)+'"><tbody><tr class="ws-row-0">'+ (lis.join(''))+ '</tr></tbody></table></div></div>';
1647
- }
1648
-
1649
- return {
1650
- enabled: enabled,
1651
- main: str,
1652
- next: nextDisabled,
1653
- prev: prevDisabled,
1654
- type: 'Grid'
1655
- };
1656
1350
  };
1657
1351
 
1658
1352
 
1659
- picker.getMonthList = function(value, data){
1660
-
1661
- var j, i, name, val, disabled, lis, fullyDisabled, prevDisabled, nextDisabled, classStr, classArray;
1662
- var o = data.options;
1663
- var size = o.size;
1664
- var max = o.max.split('-');
1665
- var min = o.min.split('-');
1666
- var currentValue = o.value.split('-');
1667
- var enabled = 0;
1668
- var rowNum = 0;
1669
- var str = '';
1670
-
1671
- value = value[0] - Math.floor((size - 1) / 2);
1672
- for(j = 0; j < size; j++){
1673
- if(j){
1674
- value++;
1675
- } else {
1676
- prevDisabled = picker.isInRange([value-1], max, min) ? {'data-action': 'setMonthList','value': value-1} : false;
1677
- }
1678
- if(j == size - 1){
1679
- nextDisabled = picker.isInRange([value+1], max, min) ? {'data-action': 'setMonthList','value': value+1} : false;
1680
- }
1681
- lis = [];
1682
-
1683
- if( !picker.isInRange([value, '01'], max, min) && !picker.isInRange([value, '12'], max, min)){
1684
- disabled = ' disabled=""';
1685
- fullyDisabled = true;
1686
- } else {
1687
- fullyDisabled = false;
1688
- disabled = '';
1689
- }
1690
-
1691
- if(o.minView >= 1){
1692
- disabled = ' disabled=""';
1693
- }
1694
-
1695
- str += '<div class="month-list picker-list ws-index-'+ j +'"><div class="ws-picker-header">';
1696
-
1697
- str += o.selectNav ?
1698
- '<select data-action="setMonthList" class="year-select">'+ picker.createYearSelect(value, max, min).join('') +'</select>' :
1699
- '<button data-action="setYearList"'+disabled+' value="'+ value +'" tabindex="-1">'+ value +'</button>';
1700
- str += '</div>';
1701
-
1702
- for(i = 0; i < 12; i++){
1703
- val = curCfg.date.monthkeys[i+1];
1704
- name = (curCfg.date[o.monthNames] || curCfg.date.monthNames)[i];
1705
- classArray = [];
1706
- if(fullyDisabled || !picker.isInRange([value, val], max, min) ){
1707
- disabled = ' disabled=""';
1708
- } else {
1709
- disabled = '';
1710
- enabled++;
1711
- }
1712
-
1713
- if(value == today[0] && today[1] == val){
1714
- classArray.push('this-value');
1715
- }
1716
-
1717
- if(currentValue[0] == value && currentValue[1] == val){
1718
- classArray.push('checked-value');
1719
- }
1720
-
1721
- classStr = (classArray.length) ? ' class="'+ (classArray.join(' ')) +'"' : '';
1722
- if(i && !(i % 3)){
1723
- rowNum++;
1724
- lis.push('</tr><tr class="ws-row-'+ rowNum +'">');
1353
+ ['readonly', 'disabled'].forEach(function(name){
1354
+ var isDisabled = name == 'disabled';
1355
+ wsWidgetProto[name] = function(val, boolVal){
1356
+ if(this.options[name] != boolVal || !this._init){
1357
+ this.options[name] = !!boolVal;
1358
+ this.inputElements.prop(name, this.options[name]);
1359
+ this.buttonWrapper[this.options[name] ? 'addClass' : 'removeClass']('ws-'+name);
1360
+ if(isDisabled){
1361
+ $('button', this.buttonWrapper).prop('disabled', this.options[name]);
1725
1362
  }
1726
-
1727
- lis.push('<td class="ws-item-'+ i +'" role="presentation"><button data-id="month-'+ i +'" type="button"'+ disabled + classStr +' data-action="'+ (data.type == 'month' ? 'changeInput' : 'setDayList' ) +'" value="'+value+'-'+val+'" tabindex="-1" role="gridcell" aria-label="'+ curCfg.date.monthNames[i] +'">'+name+'</button></td>');
1728
-
1729
1363
  }
1730
-
1731
- str += '<div class="picker-grid"><table role="grid" aria-label="'+value+'"><tbody><tr class="ws-row-0">'+ (lis.join(''))+ '</tr></tbody></table></div></div>';
1732
- }
1733
-
1734
- return {
1735
- enabled: enabled,
1736
- main: str,
1737
- prev: prevDisabled,
1738
- next: nextDisabled,
1739
- type: 'Grid'
1740
1364
  };
1741
- };
1742
-
1743
-
1744
- picker.getDayList = function(value, data){
1745
-
1746
- var j, i, k, day, nDay, name, val, disabled, lis, prevDisabled, nextDisabled, addTr, week, rowNum;
1747
-
1748
- var lastMotnh, curMonth, otherMonth, dateArray, monthName, fullMonthName, buttonStr, date2, classArray;
1749
- var o = data.options;
1750
- var size = o.size;
1751
- var max = o.max.split('-');
1752
- var min = o.min.split('-');
1753
- var currentValue = o.value.split('-');
1754
- var monthNames = curCfg.date[o.monthNamesHead] || curCfg.date[o.monthNames] || curCfg.date.monthNames;
1755
- var enabled = 0;
1756
- var str = [];
1757
- var date = new Date(value[0], value[1] - 1, 1);
1758
-
1759
- date.setMonth(date.getMonth() - Math.floor((size - 1) / 2));
1760
-
1761
- for(j = 0; j < size; j++){
1762
- date.setDate(1);
1763
- lastMotnh = date.getMonth();
1764
- rowNum = 0;
1765
- if(!j){
1766
- date2 = new Date(date.getTime());
1767
- date2.setDate(-1);
1768
- dateArray = getDateArray(date2);
1769
- prevDisabled = picker.isInRange(dateArray, max, min) ? {'data-action': 'setDayList','value': dateArray[0]+'-'+dateArray[1]} : false;
1770
- }
1365
+ });
1366
+
1367
+ var spinBtnProto = $.extend({}, wsWidgetProto, {
1368
+ _create: function(){
1369
+ var o = this.options;
1370
+ var helper = createHelper(o.type);
1771
1371
 
1772
- dateArray = getDateArray(date);
1372
+ this.elemHelper = $('<input type="'+ o.type+'" />');
1373
+ this.asNumber = helper.asNumber;
1374
+ this.asValue = helper.asValue;
1773
1375
 
1774
- str.push('<div class="day-list picker-list ws-index-'+ j +'"><div class="ws-picker-header">');
1775
- if( o.selectNav ){
1776
- monthName = ['<select data-action="setDayList" class="month-select" tabindex="0">'+ picker.createMonthSelect(dateArray, max, min, monthNames).join('') +'</select>', '<select data-action="setDayList" class="year-select" tabindex="0">'+ picker.createYearSelect(dateArray[0], max, min, '-'+dateArray[1]).join('') +'</select>'];
1777
- if(curCfg.date.showMonthAfterYear){
1778
- monthName.reverse();
1779
- }
1780
- str.push( monthName.join(' ') );
1781
- }
1376
+ wsWidgetProto._create.apply(this, arguments);
1377
+ this._init = false;
1782
1378
 
1783
- fullMonthName = [curCfg.date.monthNames[(dateArray[1] * 1) - 1], dateArray[0]];
1784
- monthName = [monthNames[(dateArray[1] * 1) - 1], dateArray[0]];
1785
- if(curCfg.date.showMonthAfterYear){
1786
- monthName.reverse();
1787
- fullMonthName.reverse();
1788
- }
1379
+ this.buttonWrapper.html('<span unselectable="on" class="step-controls"><span class="step-up"></span><span class="step-down"></span></span>');
1789
1380
 
1790
- if(!data.options.selectNav) {
1791
- str.push(
1792
- '<button data-action="setMonthList"'+ (o.minView >= 2 ? ' disabled="" ' : '') +' value="'+ dateArray.date +'" tabindex="-1">'+ monthName.join(' ') +'</button>'
1793
- );
1381
+ if(this.type == 'number'){
1382
+ this.inputElements.attr('inputmode', 'numeric');
1794
1383
  }
1795
1384
 
1796
1385
 
1797
- str.push('</div><div class="picker-grid"><table role="grid" aria-label="'+ fullMonthName.join(' ') +'"><thead><tr>');
1386
+ if(!o.min && typeof o.relMin == 'number'){
1387
+ o.min = this.asValue(this.getRelNumber(o.relMin));
1388
+ $.prop(this.orig, 'min', o.min);
1389
+ }
1798
1390
 
1799
- if(data.options.showWeek){
1800
- str.push('<th class="week-header">'+ curCfg.date.weekHeader +'</th>');
1391
+ if(!o.max && typeof o.relMax == 'number'){
1392
+ o.max = this.asValue(this.getRelNumber(o.relMax));
1393
+ $.prop(this.orig, 'max', o.max);
1801
1394
  }
1802
- for(k = curCfg.date.firstDay; k < curCfg.date.dayNamesShort.length; k++){
1803
- str.push('<th class="day-'+ k +'"><abbr title="'+ curCfg.date.dayNames[k] +'">'+ curCfg.date.dayNamesShort[k] +'</abbr></th>');
1395
+ this._init = true;
1396
+ },
1397
+ createOpts: ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'value', 'required'],
1398
+ _addSplitInputs: function(){
1399
+ if(!this.inputElements){
1400
+ var create = splitInputs[this.type]._create();
1401
+ this.splits = create.splits;
1402
+ this.inputElements = $(create.elements).prependTo(this.element).filter('input');
1804
1403
  }
1805
- k = curCfg.date.firstDay;
1806
- while(k--){
1807
- str.push('<th class="day-'+ k +'"><abbr title="'+ curCfg.date.dayNames[k] +'">'+ curCfg.date.dayNamesShort[k] +'</abbr></th>');
1404
+ },
1405
+
1406
+ getRelNumber: function(rel){
1407
+ var start = steps[this.type].start || 0;
1408
+ if(rel){
1409
+ start += rel;
1808
1410
  }
1809
- str.push('</tr></thead><tbody><tr class="ws-row-0">');
1810
-
1811
- if(data.options.showWeek) {
1812
- week = picker.getWeek(date);
1813
- str.push('<td class="week-cell">'+ week +'</td>');
1411
+ return start;
1412
+ },
1413
+ addZero: addZero,
1414
+ _setStartInRange: function(){
1415
+ var start = this.getRelNumber(this.options.relDefaultValue);
1416
+ if(!isNaN(this.minAsNumber) && start < this.minAsNumber){
1417
+ start = this.minAsNumber;
1418
+ } else if(!isNaN(this.maxAsNumber) && start > this.maxAsNumber){
1419
+ start = this.maxAsNumber;
1814
1420
  }
1421
+ this.elemHelper.prop('valueAsNumber', start);
1422
+ this.options.defValue = this.elemHelper.prop('value');
1815
1423
 
1816
- for (i = 0; i < 99; i++) {
1817
- addTr = (i && !(i % 7));
1818
- curMonth = date.getMonth();
1819
- otherMonth = lastMotnh != curMonth;
1820
- day = date.getDay();
1821
- classArray = [];
1822
-
1823
- if(addTr && otherMonth ){
1824
- str.push('</tr>');
1825
- break;
1826
- }
1827
- if(addTr){
1828
- rowNum++;
1829
- str.push('</tr><tr class="ws-row-'+ rowNum +'">');
1830
- if(data.options.showWeek) {
1831
- week++;
1832
- str.push('<td class="week-cell">'+ week +'</td>');
1833
- }
1834
- }
1835
-
1836
- if(!i){
1837
-
1838
- if(day != curCfg.date.firstDay){
1839
- nDay = day - curCfg.date.firstDay;
1840
- if(nDay < 0){
1841
- nDay += 7;
1842
- }
1843
- date.setDate(date.getDate() - nDay);
1844
- day = date.getDay();
1845
- curMonth = date.getMonth();
1846
- otherMonth = lastMotnh != curMonth;
1424
+ },
1425
+ reorderInputs: function(){
1426
+ if(splitInputs[this.type]){
1427
+ var element = this.element;
1428
+ splitInputs[this.type].sort(element);
1429
+ setTimeout(function(){
1430
+ var data = webshims.data(element);
1431
+ if(data && data.shadowData){
1432
+ data.shadowData.shadowFocusElement = element.find('input')[0] || element[0];
1847
1433
  }
1848
- }
1849
-
1850
- dateArray = getDateArray(date);
1851
- buttonStr = '<td role="presentation" class="day-'+ day +'"><button data-id="day-'+ date.getDate() +'" role="gridcell" data-action="changeInput" value="'+ (dateArray.join('-')) +'"';
1434
+ }, 9);
1435
+ }
1436
+ },
1437
+ value: function(val){
1438
+
1439
+ if(!this._init || this.options.value !== val){
1440
+ this.valueAsNumber = this.asNumber(val);
1441
+ this.options.value = val;
1852
1442
 
1853
- if(otherMonth){
1854
- classArray.push('othermonth');
1443
+ if(isNaN(this.valueAsNumber) || (!isNaN(this.minAsNumber) && this.valueAsNumber < this.minAsNumber) || (!isNaN(this.maxAsNumber) && this.valueAsNumber > this.maxAsNumber)){
1444
+ this._setStartInRange();
1855
1445
  } else {
1856
- classArray.push('day-'+date.getDate());
1446
+ this.elemHelper.prop('value', val);
1447
+ this.options.defValue = "";
1857
1448
  }
1858
1449
 
1859
- if(dateArray[0] == today[0] && today[1] == dateArray[1] && today[2] == dateArray[2]){
1860
- classArray.push('this-value');
1861
- }
1862
-
1863
- if(currentValue[0] == dateArray[0] && dateArray[1] == currentValue[1] && dateArray[2] == currentValue[2]){
1864
- classArray.push('checked-value');
1865
- }
1866
-
1867
- if(classArray.length){
1868
- buttonStr += ' class="'+ classArray.join(' ') +'"';
1869
- }
1870
-
1871
- if(!picker.isInRange(dateArray, max, min) || (data.options.disableDays && $.inArray(day, data.options.disableDays) != -1)){
1872
- buttonStr += ' disabled=""';
1450
+ val = formatVal[this.type](val, this.options);
1451
+ if(this.options.splitInput){
1452
+ $.each(this.splits, function(i, elem){
1453
+ $.prop(elem, 'value', val[i]);
1454
+ });
1455
+ } else {
1456
+ this.element.prop('value', val);
1873
1457
  }
1874
-
1875
- str.push(buttonStr+' tabindex="-1">'+ date.getDate() +'</button></td>');
1876
-
1877
- date.setDate(date.getDate() + 1);
1878
- }
1879
- str.push('</tbody></table></div></div>');
1880
- if(j == size - 1){
1881
- dateArray = getDateArray(date);
1882
- dateArray[2] = 1;
1883
- nextDisabled = picker.isInRange(dateArray, max, min) ? {'data-action': 'setDayList','value': dateArray.date} : false;
1458
+ this._propertyChange('value');
1459
+ this.mirrorValidity();
1884
1460
  }
1461
+ },
1462
+ step: function(val){
1463
+ var defStep = steps[this.type];
1464
+ this.options.step = val;
1465
+ this.elemHelper.prop('step', retDefault(val, defStep.step));
1466
+ this.mirrorValidity();
1885
1467
  }
1886
-
1887
-
1888
- return {
1889
- enabled: 9,
1890
- main: str.join(''),
1891
- prev: prevDisabled,
1892
- next: nextDisabled,
1893
- type: 'Grid'
1894
- };
1895
- };
1468
+ });
1896
1469
 
1897
- picker.isInRange = function(values, max, min){
1898
- var i;
1899
- var ret = true;
1900
- for(i = 0; i < values.length; i++){
1901
-
1902
- if(min[i] && min[i] > values[i]){
1903
- ret = false;
1904
- break;
1905
- } else if( !(min[i] && min[i] == values[i]) ){
1906
- break;
1470
+ $.each({min: 1, max: -1}, function(name, factor){
1471
+ var numName = name +'AsNumber';
1472
+ spinBtnProto[name] = function(val){
1473
+ this.elemHelper.prop(name, val);
1474
+ this[numName] = this.asNumber(val);
1475
+ if(this.valueAsNumber != null && (isNaN(this.valueAsNumber) || (!isNaN(this[numName]) && (this.valueAsNumber * factor) < (this[numName] * factor)))){
1476
+ this._setStartInRange();
1907
1477
  }
1908
- }
1909
- if(ret){
1910
- for(i = 0; i < values.length; i++){
1911
-
1912
- if((max[i] && max[i] < values[i])){
1913
- ret = false;
1914
- break;
1915
- } else if( !(max[i] && max[i] == values[i]) ){
1916
- break;
1478
+ this.options[name] = val;
1479
+ this._propertyChange(name);
1480
+ this.mirrorValidity();
1481
+ };
1482
+ });
1483
+
1484
+ $.fn.wsBaseWidget = function(opts){
1485
+ opts = $.extend({}, opts);
1486
+ return this.each(function(){
1487
+ $.webshims.objectCreate(wsWidgetProto, {
1488
+ element: {
1489
+ value: $(this)
1917
1490
  }
1918
- }
1919
- }
1920
- return ret;
1491
+ }, opts);
1492
+ });
1921
1493
  };
1922
1494
 
1923
- picker.createMonthSelect = function(value, max, min, monthNames){
1924
- if(!monthNames){
1925
- monthNames = curCfg.date.monthNames;
1926
- }
1927
-
1928
- var selected;
1929
- var i = 0;
1930
- var options = [];
1931
- var tempVal = value[1]-1;
1932
- for(; i < monthNames.length; i++){
1933
- selected = tempVal == i ? ' selected=""' : '';
1934
- if(selected || picker.isInRange([value[0], i+1], max, min)){
1935
- options.push('<option value="'+ value[0]+'-'+addZero(i+1) + '"'+selected+'>'+ monthNames[i] +'</option>');
1936
- }
1495
+ $.fn.spinbtnUI = function(opts){
1496
+ opts = $.extend({
1497
+ monthNames: 'monthNames',
1498
+ size: 1,
1499
+ startView: 0
1500
+ }, opts);
1501
+ return this.each(function(){
1502
+ $.webshims.objectCreate(spinBtnProto, {
1503
+ element: {
1504
+ value: $(this)
1505
+ }
1506
+ }, opts);
1507
+ });
1508
+ };
1509
+ })();
1510
+
1511
+ (function(){
1512
+ var picker = {};
1513
+
1514
+ var loadPicker = function(type, name){
1515
+ type = (type == 'color' ? 'color' : 'forms')+'-picker';
1516
+ if(!loadPicker[name+'Loaded'+type]){
1517
+ loadPicker[name+'Loaded'+type] = true;
1518
+ webshims.ready(name, function(){
1519
+ webshims.loader.loadList([type]);
1520
+ });
1937
1521
  }
1938
- return options;
1522
+ return type;
1939
1523
  };
1524
+ options.addZero = addZero;
1525
+ webshims.loader.addModule('forms-picker', {
1526
+ noAutoCallback: true,
1527
+ options: options
1528
+ });
1529
+ webshims.loader.addModule('color-picker', {
1530
+ noAutoCallback: true,
1531
+ css: 'jpicker/jpicker.css',
1532
+ options: options
1533
+ });
1940
1534
 
1941
- picker.createYearSelect = function(value, max, min, valueAdd){
1942
-
1943
- var temp;
1944
- var goUp = true;
1945
- var goDown = true;
1946
- var options = ['<option selected="">'+ value + '</option>'];
1947
- var i = 0;
1948
- if(!valueAdd){
1949
- valueAdd = '';
1950
- }
1951
- while(i < 8 && (goUp || goDown)){
1952
- i++;
1953
- temp = value-i;
1954
- if(goUp && picker.isInRange([temp], max, min)){
1955
- options.unshift('<option value="'+ (temp+valueAdd) +'">'+ temp +'</option>');
1956
- } else {
1957
- goUp = false;
1958
- }
1959
- temp = value + i;
1960
- if(goDown && picker.isInRange([temp], max, min)){
1961
- options.push('<option value="'+ (temp+valueAdd) +'">'+ temp +'</option>');
1962
- } else {
1963
- goDown = false;
1964
- }
1535
+ picker._genericSetFocus = function(element, _noFocus){
1536
+ element = $(element || this.activeButton);
1537
+ if(!this.popover.openedByFocus && !_noFocus){
1538
+ var that = this;
1539
+ var setFocus = function(noTrigger){
1540
+ clearTimeout(that.timer);
1541
+ that.timer = setTimeout(function(){
1542
+ if(element[0]){
1543
+ element[0].focus();
1544
+ if(noTrigger !== true && !element.is(':focus')){
1545
+ setFocus(true);
1546
+ }
1547
+ }
1548
+ }, that.popover.isVisible ? 99 : 360);
1549
+ };
1550
+ this.popover.activateElement(element);
1551
+ setFocus();
1965
1552
  }
1966
- return options;
1967
1553
  };
1968
-
1969
- var actions = {
1554
+
1555
+ picker._actions = {
1970
1556
  changeInput: function(val, popover, data){
1557
+ picker._actions.cancel(val, popover, data);
1558
+ data.setChange(val);
1559
+ },
1560
+ cancel: function(val, popover, data){
1971
1561
  popover.stopOpen = true;
1972
1562
  data.element.getShadowFocusElement().focus();
1973
1563
  setTimeout(function(){
1974
1564
  popover.stopOpen = false;
1975
1565
  }, 9);
1976
1566
  popover.hide();
1977
- data.setChange(val);
1978
1567
  }
1979
1568
  };
1980
1569
 
1981
- (function(){
1982
- var retNames = function(name){
1983
- return 'get'+name+'List';
1984
- };
1985
- var retSetNames = function(name){
1986
- return 'set'+name+'List';
1987
- };
1988
- var stops = {
1989
- date: 'Day',
1990
- week: 'Day',
1991
- month: 'Month'
1992
- };
1993
-
1994
- $.each({'setYearList' : ['Year', 'Month', 'Day'], 'setMonthList': ['Month', 'Day'], 'setDayList': ['Day']}, function(setName, names){
1995
- var getNames = names.map(retNames);
1996
- var setNames = names.map(retSetNames);
1997
- actions[setName] = function(val, popover, data, startAt){
1998
- val = ''+val;
1999
- var o = data.options;
2000
- var values = val.split('-');
2001
- if(!startAt){
2002
- startAt = 0;
2003
- }
2004
- $.each(getNames, function(i, item){
2005
- if(i >= startAt){
2006
- var content = picker[item](values, data);
2007
-
2008
- if( values.length < 2 || content.enabled > 1 || stops[data.type] === names[i]){
2009
- popover.element
2010
- .attr({'data-currentview': setNames[i]})
2011
- .addClass('ws-size-'+o.size)
2012
- .data('pickercontent', {
2013
- data: data,
2014
- content: content,
2015
- values: values
2016
- })
2017
- ;
2018
- popover.bodyElement.html(content.main);
2019
- if(content.prev){
2020
- popover.prevElement
2021
- .attr(content.prev)
2022
- .prop({disabled: false})
2023
- ;
2024
- } else {
2025
- popover.prevElement
2026
- .removeAttr('data-action')
2027
- .prop({disabled: true})
2028
- ;
2029
- }
2030
- if(content.next){
2031
- popover.nextElement
2032
- .attr(content.next)
2033
- .prop({disabled: false})
2034
- ;
2035
- } else {
2036
- popover.nextElement
2037
- .removeAttr('data-action')
2038
- .prop({disabled: true})
2039
- ;
2040
- }
2041
- if(webshims[content.type]){
2042
- new webshims[content.type](popover.bodyElement.children(), popover, content);
2043
- }
2044
- popover.element.trigger('pickerchange');
2045
- return false;
2046
- }
2047
- }
2048
- });
2049
- };
2050
- });
2051
- })();
2052
1570
 
2053
1571
  picker.commonInit = function(data, popover){
2054
- var actionfn = function(e){
2055
- if(!$(this).is('.othermonth') || $(this).css('cursor') == 'pointer'){
2056
- popover.actionFn({
2057
- 'data-action': $.attr(this, 'data-action'),
2058
- value: $(this).val() || $.attr(this, 'value')
2059
- });
2060
- }
2061
- return false;
2062
- };
2063
- var id = new Date().getTime();
2064
- var generateList = function(o, max, min){
2065
- var options = [];
2066
- var label = '';
2067
- var labelId = '';
2068
- o.options = data.getOptions() || {};
2069
- $('div.ws-options', popover.contentElement).remove();
2070
- $.each(o.options[0], function(val, label){
2071
- var disabled = picker.isInRange(val.split('-'), o.maxS, o.minS) ?
2072
- '' :
2073
- ' disabled="" '
2074
- ;
2075
- options.push('<li role="presentation"><button value="'+ val +'" '+disabled+' data-action="changeInput" tabindex="-1" role="option">'+ (label || data.formatValue(val, false)) +'</button></li>');
2076
- });
2077
- if(options.length){
2078
- id++;
2079
- if(o.options[1]){
2080
- labelId = 'datalist-'+id;
2081
- label = '<h5 id="'+labelId+'">'+ o.options[1] +'</h5>';
2082
- labelId = ' aria-labelledbyid="'+ labelId +'" ';
2083
- }
2084
- new webshims.ListBox($('<div class="ws-options">'+label+'<ul role="listbox" '+ labelId +'>'+ options.join('') +'</div>').insertAfter(popover.bodyElement)[0], popover, {noFocus: true});
2085
- }
2086
- };
2087
- var updateContent = function(){
2088
- if(popover.isDirty){
2089
- var o = data.options;
2090
- o.maxS = o.max.split('-');
2091
- o.minS = o.min.split('-');
2092
-
2093
- $('button', popover.buttonRow).each(function(){
2094
- var text;
2095
- if($(this).is('.ws-empty')){
2096
- text = curCfg.date.clear;
2097
- if(!text){
2098
- text = formcfg[''].date.clear || 'clear';
2099
- webshims.warn("could not get clear text from form cfg");
2100
- }
2101
- } else if($(this).is('.ws-current')){
2102
- text = (curCfg[data.type] || {}).currentText;
2103
- if(!text){
2104
- text = (formcfg[''][[data.type]] || {}).currentText || 'current';
2105
- webshims.warn("could not get currentText from form cfg");
2106
- }
2107
- $.prop(this, 'disabled', !picker.isInRange(today[data.type].split('-'), o.maxS, o.minS));
2108
- }
2109
- if(text){
2110
- $(this).text(text).attr({'aria-label': text});
2111
- if(webshims.assumeARIA){
2112
- $.attr(this, 'aria-label', text);
2113
- }
2114
- }
2115
-
2116
- });
2117
- popover.nextElement.attr({'aria-label': curCfg.date.nextText});
2118
- $('> span', popover.nextElement).html(curCfg.date.nextText);
2119
- popover.prevElement.attr({'aria-label': curCfg.date.prevText});
2120
- $('> span', popover.prevElement).html(curCfg.date.prevText);
2121
-
2122
- generateList(o, o.maxS, o.minS);
2123
-
2124
- }
2125
- $('button.ws-empty', popover.buttonRow).prop('disabled', $.prop(data.orig, 'required'));
2126
- popover.isDirty = false;
2127
- };
2128
-
2129
- popover.actionFn = function(obj){
2130
- if(actions[obj['data-action']]){
2131
- actions[obj['data-action']](obj.value, popover, data, 0);
2132
- } else {
2133
- webshims.warn('no action for '+ obj['data-action']);
2134
- }
2135
- };
2136
-
2137
- popover.contentElement.html('<button class="ws-prev" tabindex="0"><span></span></button> <button class="ws-next" tabindex="0"><span></span></button><div class="ws-picker-body"></div><div class="ws-button-row"><button type="button" class="ws-current" data-action="changeInput" value="'+today[data.type]+'" tabindex="0"></button> <button type="button" data-action="changeInput" value="" class="ws-empty" tabindex="0"></button></div>');
2138
- popover.nextElement = $('button.ws-next', popover.contentElement);
2139
- popover.prevElement = $('button.ws-prev', popover.contentElement);
2140
- popover.bodyElement = $('div.ws-picker-body', popover.contentElement);
2141
- popover.buttonRow = $('div.ws-button-row', popover.contentElement);
1572
+ var tabbable;
2142
1573
 
2143
1574
  popover.isDirty = true;
2144
1575
 
2145
- popover.contentElement
2146
- .on('click', 'button[data-action]', actionfn)
2147
- .on('change', 'select[data-action]', actionfn)
2148
- ;
2149
-
1576
+ popover.element.on('updatepickercontent pickerchange', function(){
1577
+ tabbable = false;
1578
+ });
2150
1579
  popover.contentElement.on({
2151
1580
  keydown: function(e){
2152
1581
  if(e.keyCode == 9){
2153
- var tabbable = $('[tabindex="0"]:not(:disabled)', this).filter(':visible');
1582
+ if(!tabbable){
1583
+ tabbable = $('input:not(:disabled), [tabindex="0"]:not(:disabled)', this).filter(':visible');
1584
+ }
2154
1585
  var index = tabbable.index(e.target);
2155
1586
  if(e.shiftKey && index <= 0){
2156
1587
  tabbable.last().focus();
@@ -2168,18 +1599,11 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2168
1599
  }
2169
1600
  });
2170
1601
 
2171
- $(data.options.orig).on('input', function(){
2172
- var currentView;
2173
- if(data.options.updateOnInput && popover.isVisible && data.options.value && (currentView = popover.element.attr('data-currentview'))){
2174
- actions[currentView]( data.options.value , popover, data, 0);
2175
- }
2176
- });
2177
-
2178
1602
  data._propertyChange = (function(){
2179
1603
  var timer;
2180
1604
  var update = function(){
2181
1605
  if(popover.isVisible){
2182
- updateContent();
1606
+ popover.element.triggerHandler('updatepickercontent');
2183
1607
  }
2184
1608
  };
2185
1609
  return function(prop){
@@ -2205,50 +1629,51 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2205
1629
  popover.element.on({
2206
1630
  wspopoverbeforeshow: function(){
2207
1631
  data.element.triggerHandler('wsupdatevalue');
2208
- updateContent();
1632
+ popover.element.triggerHandler('updatepickercontent');
2209
1633
  }
2210
1634
  });
2211
1635
 
2212
- $(document).onTrigger('wslocalechange', data._propertyChange);
1636
+
1637
+ $(data.orig).on('remove', function(e){
1638
+ if(!e.originalEvent){
1639
+ $(document).off('wslocalechange', data._propertyChange);
1640
+ }
1641
+ });
2213
1642
  };
2214
1643
 
1644
+
2215
1645
  picker._common = function(data){
2216
1646
  var popover = webshims.objectCreate(webshims.wsPopover, {}, {prepareFor: data.element});
2217
1647
  var opener = $('<button type="button" class="ws-popover-opener"><span /></button>').appendTo(data.buttonWrapper);
2218
1648
  var options = data.options;
2219
- var init = false;
2220
1649
 
1650
+ var showPickerContent = function(){
1651
+ (picker[data.type].showPickerContent || picker.showPickerContent)(data, popover);
1652
+ };
2221
1653
  var show = function(){
1654
+ var type = loadPicker(data.type, 'DOM');
2222
1655
  if(!options.disabled && !options.readonly && !popover.isVisible){
2223
- if(!init){
2224
- picker.commonInit(data, popover);
2225
- }
2226
-
2227
- if(!init || data.options.restartView) {
2228
- actions.setYearList( options.defValue || options.value, popover, data, data.options.startView);
2229
- } else {
2230
- actions[popover.element.attr('data-currentview') || 'setYearList']( options.defValue || options.value, popover, data, 0);
2231
- }
2232
-
2233
- init = true;
1656
+ webshims.ready(type, showPickerContent);
2234
1657
  popover.show(data.element);
2235
1658
  }
2236
1659
  };
2237
1660
 
2238
1661
  options.containerElements.push(popover.element[0]);
2239
1662
 
2240
- if(!options.startView){
2241
- options.startView = 0;
2242
- }
2243
- if(!options.minView){
2244
- options.minView = 0;
2245
- }
2246
- if(options.startView < options.minView){
2247
- options.minView = options.startView;
2248
- webshims.warn("wrong config for minView/startView.");
2249
- }
2250
- if(!options.size){
2251
- options.size = 1;
1663
+ if(data.type != 'color'){
1664
+ if(!options.startView){
1665
+ options.startView = 0;
1666
+ }
1667
+ if(!options.minView){
1668
+ options.minView = 0;
1669
+ }
1670
+ if(options.startView < options.minView){
1671
+ options.startView = options.minView;
1672
+ webshims.warn("wrong config for minView/startView.");
1673
+ }
1674
+ if(!options.size){
1675
+ options.size = 1;
1676
+ }
2252
1677
  }
2253
1678
 
2254
1679
  popover.element
@@ -2275,10 +1700,15 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2275
1700
  labelWidth(popover.element.children('div.ws-po-outerbox').attr({role: 'group'}), options.labels, true);
2276
1701
  labelWidth(opener, options.labels, true);
2277
1702
 
1703
+ if(options.tabindex != null){
1704
+ opener.attr({tabindex: options.tabindex});
1705
+ }
1706
+
1707
+ if(options.disabled){
1708
+ opener.prop({disabled: true});
1709
+ }
1710
+
2278
1711
  opener
2279
- .attr({
2280
- 'tabindex': options.labels.length ? 0 : '-1'
2281
- })
2282
1712
  .on({
2283
1713
  mousedown: function(){
2284
1714
  stopPropagation.apply(this, arguments);
@@ -2323,10 +1753,51 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2323
1753
  });
2324
1754
  })();
2325
1755
  data.popover = popover;
1756
+ data.opener = opener;
1757
+ $(data.orig).on('remove', function(e){
1758
+ if(!e.originalEvent){
1759
+ opener.remove();
1760
+ popover.element.remove();
1761
+ }
1762
+ });
1763
+
1764
+ loadPicker(data.type, 'WINDOWLOAD');
2326
1765
  };
2327
1766
 
2328
1767
  picker.month = picker._common;
2329
- picker.date = picker.month;
1768
+ picker.date = picker._common;
1769
+ picker.color = function(data){
1770
+ var ret = picker._common.apply(this, arguments);
1771
+ var alpha = $(data.orig).data('alphacontrol');
1772
+ var colorIndicator = data.opener
1773
+ .prepend('<span class="ws-color-indicator-bg"><span class="ws-color-indicator" /></span>')
1774
+ .find('.ws-color-indicator')
1775
+ ;
1776
+ var showColor = function(){
1777
+ colorIndicator.css({backgroundColor: $.prop(this, 'value') || '#000'})
1778
+ };
1779
+ var showOpacity = (function(){
1780
+ var timer;
1781
+ var show = function(){
1782
+ try {
1783
+ var value = data.alpha.prop('valueAsNumber') / (data.alpha.prop('max') || 1);
1784
+ if(!isNaN(value)){
1785
+ colorIndicator.css({opacity: value});
1786
+ }
1787
+ } catch(er){}
1788
+
1789
+ };
1790
+ return function(e){
1791
+ clearTimeout(timer);
1792
+ timer = setTimeout(show, !e || e.type == 'change' ? 4: 40);
1793
+ };
1794
+ })();
1795
+ data.alpha = (alpha) ? $('#'+alpha) : $([]);
1796
+
1797
+ $(data.orig).on('wsupdatevalue change', showColor).each(showColor);
1798
+ data.alpha.on('wsupdatevalue change input', showOpacity).each(showOpacity);
1799
+ return ret;
1800
+ };
2330
1801
 
2331
1802
  webshims.picker = picker;
2332
1803
  })();
@@ -2347,6 +1818,7 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2347
1818
  'max',
2348
1819
  'step',
2349
1820
  'title',
1821
+ 'required',
2350
1822
  'placeholder'
2351
1823
  ];
2352
1824
 
@@ -2355,11 +1827,11 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2355
1827
 
2356
1828
  $.each(copyProps.concat(copyAttrs), function(i, name){
2357
1829
  var fnName = name.replace(/^data\-/, '');
2358
- webshims.onNodeNamesPropertyModify('input', name, function(val){
1830
+ webshims.onNodeNamesPropertyModify('input', name, function(val, boolVal){
2359
1831
  if(!stopCircular){
2360
1832
  var shadowData = webshims.data(this, 'shadowData');
2361
1833
  if(shadowData && shadowData.data && shadowData.nativeElement === this && shadowData.data[fnName]){
2362
- shadowData.data[fnName](val);
1834
+ shadowData.data[fnName](val, boolVal);
2363
1835
  }
2364
1836
  }
2365
1837
  });
@@ -2390,6 +1862,7 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2390
1862
  var sizeInput = function(data){
2391
1863
  var init;
2392
1864
  var updateStyles = function(){
1865
+ $(data.orig).removeClass('ws-important-hide');
2393
1866
  $.style( data.orig, 'display', '' );
2394
1867
  var hasButtons, marginR, marginL;
2395
1868
  var correctWidth = 0.6;
@@ -2423,13 +1896,14 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2423
1896
  data.element.outerWidth( $(data.orig).outerWidth() - correctWidth );
2424
1897
  }
2425
1898
  init = true;
2426
- $.style( data.orig, 'display', 'none' );
1899
+ $(data.orig).addClass('ws-important-hide');
2427
1900
  };
2428
- $(document).onTrigger('updateshadowdom', updateStyles);
1901
+ data.element.onWSOff('updateshadowdom', updateStyles, true);
2429
1902
  };
2430
1903
 
2431
1904
 
2432
1905
  var implementType = function(){
1906
+
2433
1907
  var type = $.prop(this, 'type');
2434
1908
 
2435
1909
  var i, opts, data, optsName, labels;
@@ -2484,7 +1958,7 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2484
1958
  data.shim.options.containerElements.push(data.shim.element[0]);
2485
1959
 
2486
1960
  labelWidth($(this).getShadowFocusElement(), labels);
2487
- $.attr(this, 'required', $.attr(this, 'required'));
1961
+
2488
1962
  $(this).on('change', function(e){
2489
1963
  if(!stopCircular){
2490
1964
  data.shim.value($.prop(this, 'value'));
@@ -2543,18 +2017,13 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2543
2017
 
2544
2018
  if(opts.calculateWidth){
2545
2019
  sizeInput(data.shim);
2020
+ } else {
2021
+ $(this).css({display: 'none'});
2546
2022
  }
2547
- $(this).css({display: 'none'});
2548
2023
  }
2024
+
2549
2025
  };
2550
2026
 
2551
- if(!modernizrInputTypes.range || options.replaceUI){
2552
- extendType('range', {
2553
- _create: function(opts, set){
2554
- return $('<span />').insertAfter(opts.orig).rangeUI(opts).data('rangeUi');
2555
- }
2556
- });
2557
- }
2558
2027
 
2559
2028
  if(Modernizr.formvalidation){
2560
2029
  ['input', 'form'].forEach(function(name){
@@ -2571,12 +2040,20 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2571
2040
  });
2572
2041
  }
2573
2042
 
2043
+ if(!modernizrInputTypes.range || options.replaceUI){
2044
+ extendType('range', {
2045
+ _create: function(opts, set){
2046
+ var data = $('<span />').insertAfter(opts.orig).rangeUI(opts).data('rangeUi');
2047
+ return data;
2048
+ }
2049
+ });
2050
+ }
2574
2051
 
2575
- ['number', 'time', 'month', 'date'].forEach(function(name){
2576
- if(!modernizrInputTypes[name] || options.replaceUI){
2052
+ var isStupid = navigator.userAgent.indexOf('MSIE 10.0') != -1 && navigator.userAgent.indexOf('Touch') == -1;
2053
+ ['number', 'time', 'month', 'date', 'color'].forEach(function(name){
2054
+ if(!modernizrInputTypes[name] || options.replaceUI || (name == 'number' && isStupid)){
2577
2055
  extendType(name, {
2578
2056
  _create: function(opts, set){
2579
-
2580
2057
  if(opts.splitInput && !splitInputs[name]){
2581
2058
  webshims.warn('splitInput not supported for '+ name);
2582
2059
  opts.splitInput = false;
@@ -2584,11 +2061,12 @@ jQuery.webshims.register('form-number-date-ui', function($, webshims, window, do
2584
2061
  var markup = opts.splitInput ?
2585
2062
  '<span class="ws-'+name+' ws-input" role="group"></span>' :
2586
2063
  '<input class="ws-'+name+'" type="text" />';
2587
- var data = $(markup) //role="spinbutton"???
2588
- .insertAfter(opts.orig)
2589
- .spinbtnUI(opts)
2590
- .data('wsspinner')
2591
- ;
2064
+ var data = $(markup).insertAfter(opts.orig);
2065
+ if(steps[name]){
2066
+ data = data.spinbtnUI(opts).data('wsWidget'+name);
2067
+ } else {
2068
+ data = data.wsBaseWidget(opts).data('wsWidget'+name);
2069
+ }
2592
2070
  if(webshims.picker && webshims.picker[name]){
2593
2071
  webshims.picker[name](data);
2594
2072
  }