webshims-rails 1.10.10 → 1.10.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +8 -8
  2. data/MIT_LICENSE.txt +3 -1
  3. data/lib/webshims-rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/webshims/polyfiller.js +8 -9
  5. data/vendor/assets/javascripts/webshims/shims/combos/1.js +91 -58
  6. data/vendor/assets/javascripts/webshims/shims/combos/10.js +247 -101
  7. data/vendor/assets/javascripts/webshims/shims/combos/11.js +241 -96
  8. data/vendor/assets/javascripts/webshims/shims/combos/12.js +79 -58
  9. data/vendor/assets/javascripts/webshims/shims/combos/13.js +79 -12
  10. data/vendor/assets/javascripts/webshims/shims/combos/14.js +6 -5
  11. data/vendor/assets/javascripts/webshims/shims/combos/15.js +68 -75
  12. data/vendor/assets/javascripts/webshims/shims/combos/16.js +147 -133
  13. data/vendor/assets/javascripts/webshims/shims/combos/17.js +288 -143
  14. data/vendor/assets/javascripts/webshims/shims/combos/18.js +288 -143
  15. data/vendor/assets/javascripts/webshims/shims/combos/19.js +85 -63
  16. data/vendor/assets/javascripts/webshims/shims/combos/2.js +97 -91
  17. data/vendor/assets/javascripts/webshims/shims/combos/20.js +85 -17
  18. data/vendor/assets/javascripts/webshims/shims/combos/21.js +17 -17
  19. data/vendor/assets/javascripts/webshims/shims/combos/23.js +79 -58
  20. data/vendor/assets/javascripts/webshims/shims/combos/24.js +17 -16
  21. data/vendor/assets/javascripts/webshims/shims/combos/25.js +85 -63
  22. data/vendor/assets/javascripts/webshims/shims/combos/26.js +6 -5
  23. data/vendor/assets/javascripts/webshims/shims/combos/27.js +0 -46
  24. data/vendor/assets/javascripts/webshims/shims/combos/28.js +6 -5
  25. data/vendor/assets/javascripts/webshims/shims/combos/29.js +13 -6
  26. data/vendor/assets/javascripts/webshims/shims/combos/3.js +47 -31
  27. data/vendor/assets/javascripts/webshims/shims/combos/30.js +47 -59
  28. data/vendor/assets/javascripts/webshims/shims/combos/31.js +18 -33
  29. data/vendor/assets/javascripts/webshims/shims/combos/4.js +35 -31
  30. data/vendor/assets/javascripts/webshims/shims/combos/5.js +304 -157
  31. data/vendor/assets/javascripts/webshims/shims/combos/6.js +304 -185
  32. data/vendor/assets/javascripts/webshims/shims/combos/7.js +126 -117
  33. data/vendor/assets/javascripts/webshims/shims/combos/8.js +126 -89
  34. data/vendor/assets/javascripts/webshims/shims/combos/9.js +247 -129
  35. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +6 -5
  36. data/vendor/assets/javascripts/webshims/shims/form-core.js +12 -0
  37. data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +3 -0
  38. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +0 -28
  39. data/vendor/assets/javascripts/webshims/shims/form-message.js +29 -26
  40. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +16 -14
  41. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +47 -47
  42. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +241 -96
  43. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +21 -16
  44. data/vendor/assets/javascripts/webshims/shims/form-validation.js +17 -16
  45. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +173 -41
  46. data/vendor/assets/javascripts/webshims/shims/geolocation.js +17 -17
  47. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ar.js +35 -33
  48. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ch-ZN.js +32 -30
  49. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-de.txt +17 -13
  50. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-el.js +32 -30
  51. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-en.txt +4 -1
  52. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-es.js +30 -28
  53. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-fr.js +35 -32
  54. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-he.js +32 -30
  55. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-hi.js +32 -30
  56. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-hu.js +32 -30
  57. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-it.js +32 -30
  58. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ja.js +32 -30
  59. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-lt.js +37 -36
  60. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-nl.js +32 -30
  61. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pl.js +5 -2
  62. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-pt-PT.js +33 -30
  63. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-ru.js +3 -1
  64. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-sv.js +32 -30
  65. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +79 -12
  66. data/vendor/assets/javascripts/webshims/shims/styles/forms.png +0 -0
  67. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +126 -121
  68. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +100 -111
  69. data/vendor/assets/javascripts/webshims/shims/swfmini.js +0 -46
  70. data/vendor/assets/javascripts/webshims/shims/track-ui.js +13 -6
  71. data/webshims-rails.gemspec +1 -0
  72. metadata +4 -3
@@ -32,22 +32,24 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
32
32
  validityRules[type] = fn;
33
33
  };
34
34
 
35
- webshims.addValidityRule('typeMismatch', function (input, val, cache, validityState){
36
- if(val === ''){return false;}
37
- var ret = validityState.typeMismatch;
38
- if(!('type' in cache)){
39
- cache.type = (input[0].getAttribute('type') || '').toLowerCase();
40
- }
41
-
42
- if(typeModels[cache.type] && typeModels[cache.type].mismatch){
43
- ret = typeModels[cache.type].mismatch(val, input);
44
- }
45
- return ret;
35
+ $.each({typeMismatch: 'mismatch', badInput: 'bad'}, function(name, fn){
36
+ webshims.addValidityRule(name, function (input, val, cache, validityState){
37
+ if(val === ''){return false;}
38
+ var ret = validityState[name];
39
+ if(!('type' in cache)){
40
+ cache.type = (input[0].getAttribute('type') || '').toLowerCase();
41
+ }
42
+
43
+ if(typeModels[cache.type] && typeModels[cache.type][fn]){
44
+ ret = typeModels[cache.type][fn](val, input);
45
+ }
46
+ return ret || false;
47
+ });
46
48
  });
47
49
 
48
50
  var formsExtModule = webshims.modules['form-number-date-api'];
49
51
  var overrideValidity = formsExtModule.loaded && !formsExtModule.test();
50
- var validityProps = ['customError','typeMismatch','rangeUnderflow','rangeOverflow','stepMismatch','tooLong','patternMismatch','valueMissing','valid'];
52
+ var validityProps = ['customError', 'badInput','typeMismatch','rangeUnderflow','rangeOverflow','stepMismatch','tooLong','patternMismatch','valueMissing','valid'];
51
53
 
52
54
  var validityChanger = ['value'];
53
55
  var validityElements = [];
@@ -113,7 +115,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
113
115
  }
114
116
  stopValidity = true;
115
117
  var jElm = $(elem),
116
- cache = {type: (elem.getAttribute && elem.getAttribute('type') || '').toLowerCase(), nodeName: (elem.nodeName || '').toLowerCase()},
118
+ cache = {type: (elem.getAttribute && elem.getAttribute('type') || elem.type || '').toLowerCase(), nodeName: (elem.nodeName || '').toLowerCase()},
117
119
  val = jElm.val(),
118
120
  customError = !!(webshims.data(elem, 'hasCustomError')),
119
121
  setCustomMessage
@@ -140,7 +142,7 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
140
142
 
141
143
  $.each(validityRules, function(rule, fn){
142
144
  validityState[rule] = fn(jElm, val, cache, validityState);
143
- if( validityState[rule] && (validityState.valid || !setCustomMessage) && ((typeModels[cache.type] && typeModels[cache.type].mismatch)) ) {
145
+ if( validityState[rule] && (validityState.valid || !setCustomMessage) && ((typeModels[cache.type])) ) {
144
146
  oldSetCustomValidity[nodeName].call(elem, webshims.createValidationMessage(elem, rule));
145
147
  validityState.valid = false;
146
148
  setCustomMessage = true;
@@ -359,8 +361,8 @@ webshims.register('form-number-date-api', function($, webshims, window, document
359
361
  } else {
360
362
  webshims.error('INVALID_STATE_ERR: DOM Exception 11');
361
363
  }
362
- } else {
363
- valueAsNumberDescriptor.prop._supset && valueAsNumberDescriptor.prop._supset.apply(elem, arguments);
364
+ } else if(valueAsNumberDescriptor.prop._supset) {
365
+ valueAsNumberDescriptor.prop._supset.apply(elem, arguments);
364
366
  }
365
367
  }
366
368
  }
@@ -487,7 +489,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
487
489
  var typeProtos = {
488
490
 
489
491
  number: {
490
- mismatch: function(val){
492
+ bad: function(val){
491
493
  return !(isNumber(val));
492
494
  },
493
495
  step: 1,
@@ -506,7 +508,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
506
508
  maxDefault: 100
507
509
  },
508
510
  color: {
509
- mismatch: (function(){
511
+ bad: (function(){
510
512
  var cReg = /^\u0023[a-f0-9]{6}$/;
511
513
  return function(val){
512
514
  return (!val || val.length != 7 || !(cReg.test(val)));
@@ -514,7 +516,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
514
516
  })()
515
517
  },
516
518
  date: {
517
- mismatch: function(val){
519
+ bad: function(val){
518
520
  if(!val || !val.split || !(/\d$/.test(val))){return true;}
519
521
  var i;
520
522
  var valA = val.split(/\u002D/);
@@ -539,14 +541,14 @@ webshims.register('form-number-date-api', function($, webshims, window, document
539
541
  //stepBase: 0, 0 = default
540
542
  stepScaleFactor: 86400000,
541
543
  asDate: function(val, _noMismatch){
542
- if(!_noMismatch && this.mismatch(val)){
544
+ if(!_noMismatch && this.bad(val)){
543
545
  return null;
544
546
  }
545
547
  return new Date(this.asNumber(val, true));
546
548
  },
547
549
  asNumber: function(str, _noMismatch){
548
550
  var ret = nan;
549
- if(_noMismatch || !this.mismatch(str)){
551
+ if(_noMismatch || !this.bad(str)){
550
552
  str = str.split(/\u002D/);
551
553
  ret = Date.UTC(str[0], str[1] - 1, str[2]);
552
554
  }
@@ -563,7 +565,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
563
565
  * ToDO: WEEK
564
566
  */
565
567
  // week: {
566
- // mismatch: function(val){
568
+ // bad: function(val){
567
569
  // if(!val || !val.split){return true;}
568
570
  // var valA = val.split('-W');
569
571
  // var ret = true;
@@ -577,7 +579,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
577
579
  // stepBase: -259200000,
578
580
  // asDate: function(str, _noMismatch){
579
581
  // var ret = null;
580
- // if(_noMismatch || !this.mismatch(str)){
582
+ // if(_noMismatch || !this.bad(str)){
581
583
  // ret = str.split('-W');
582
584
  // ret = setWeek(ret[0], ret[1]);
583
585
  // }
@@ -610,7 +612,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
610
612
  // }
611
613
  // },
612
614
  time: {
613
- mismatch: function(val, _getParsed){
615
+ bad: function(val, _getParsed){
614
616
  if(!val || !val.split || !(/\d$/.test(val))){return true;}
615
617
  val = val.split(/\u003A/);
616
618
  if(val.length < 2 || val.length > 3){return true;}
@@ -655,7 +657,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
655
657
  },
656
658
  asNumber: function(val){
657
659
  var ret = nan;
658
- val = this.mismatch(val, true);
660
+ val = this.bad(val, true);
659
661
  if(val !== true){
660
662
  ret = Date.UTC('1970', 0, 1, val[0][0], val[0][1], val[0][2] || 0);
661
663
  if(val[1]){
@@ -683,8 +685,8 @@ webshims.register('form-number-date-api', function($, webshims, window, document
683
685
  }
684
686
  },
685
687
  month: {
686
- mismatch: function(val){
687
- return typeProtos.date.mismatch(val+'-01');
688
+ bad: function(val){
689
+ return typeProtos.date.bad(val+'-01');
688
690
  },
689
691
  step: 1,
690
692
  stepScaleFactor: false,
@@ -695,7 +697,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
695
697
  asNumber: function(val){
696
698
  //1970-01
697
699
  var ret = nan;
698
- if(val && !this.mismatch(val)){
700
+ if(val && !this.bad(val)){
699
701
  val = val.split(/\u002D/);
700
702
  val[0] = (val[0] * 1) - 1970;
701
703
  val[1] = (val[1] * 1) - 1;
@@ -729,46 +731,46 @@ webshims.register('form-number-date-api', function($, webshims, window, document
729
731
  }
730
732
  }
731
733
  }
732
- // ,'datetime-local': {
733
- // mismatch: function(val, _getParsed){
734
- // if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;}
735
- // val = val.split(/\u0054/);
736
- // return ( typeProtos.date.mismatch(val[0]) || typeProtos.time.mismatch(val[1], _getParsed) );
737
- // },
738
- // noAsDate: true,
739
- // asDate: function(val){
740
- // val = new Date(this.asNumber(val));
741
- //
742
- // return (isNaN(val)) ? null : val;
743
- // },
744
- // asNumber: function(val){
745
- // var ret = nan;
746
- // var time = this.mismatch(val, true);
747
- // if(time !== true){
748
- // val = val.split(/\u0054/)[0].split(/\u002D/);
749
- //
750
- // ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0);
751
- // if(time[1]){
752
- // ret += time[1];
753
- // }
754
- // }
755
- // return ret;
756
- // },
757
- // dateToString: function(date, _getParsed){
758
- // return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed);
759
- // }
760
- // }
734
+ ,'datetime-local': {
735
+ bad: function(val, _getParsed){
736
+ if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;}
737
+ val = val.split(/\u0054/);
738
+ return ( typeProtos.date.bad(val[0]) || typeProtos.time.bad(val[1], _getParsed) );
739
+ },
740
+ noAsDate: true,
741
+ asDate: function(val){
742
+ val = new Date(this.asNumber(val));
743
+
744
+ return (isNaN(val)) ? null : val;
745
+ },
746
+ asNumber: function(val){
747
+ var ret = nan;
748
+ var time = this.bad(val, true);
749
+ if(time !== true){
750
+ val = val.split(/\u0054/)[0].split(/\u002D/);
751
+
752
+ ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0);
753
+ if(time[1]){
754
+ ret += time[1];
755
+ }
756
+ }
757
+ return ret;
758
+ },
759
+ dateToString: function(date, _getParsed){
760
+ return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed);
761
+ }
762
+ }
761
763
  };
762
764
 
763
- if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month')){
765
+ if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month') || !supportsType('datetime-local')){
764
766
  typeProtos.range = $.extend({}, typeProtos.number, typeProtos.range);
765
767
  typeProtos.time = $.extend({}, typeProtos.date, typeProtos.time);
766
768
  typeProtos.month = $.extend({}, typeProtos.date, typeProtos.month);
767
- // typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']);
769
+ typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']);
768
770
  }
769
771
 
770
- //'datetime-local'
771
- ['number', 'month', 'range', 'date', 'time', 'color'].forEach(function(type){
772
+ //
773
+ ['number', 'month', 'range', 'date', 'time', 'color', 'datetime-local'].forEach(function(type){
772
774
  if(typeBugs || !supportsType(type)){
773
775
  webshims.addInputType(type, typeProtos[type]);
774
776
  }
@@ -1299,10 +1301,21 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1299
1301
  "use strict";
1300
1302
  var curCfg;
1301
1303
  var formcfg = webshims.formcfg;
1302
-
1304
+ var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
1303
1305
  var stopPropagation = function(e){
1304
1306
  e.stopImmediatePropagation();
1305
1307
  };
1308
+ var getMonthOptions = (function(){
1309
+ var str;
1310
+ return function(){
1311
+ if(!str){
1312
+ str = ('<option></option>')+$.map(monthDigits, function(val){
1313
+ return '<option>'+val+'</option>';
1314
+ }).join('');
1315
+ }
1316
+ return str;
1317
+ };
1318
+ })();
1306
1319
  var createFormat = function(name){
1307
1320
  if(!curCfg.patterns[name+'Obj']){
1308
1321
  var obj = {};
@@ -1314,10 +1327,18 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1314
1327
  };
1315
1328
  var splitInputs = {
1316
1329
  date: {
1317
- _create: function(){
1330
+ _create: function(opts){
1318
1331
  var obj = {
1319
- 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]]
1332
+ splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" />')[0]]
1320
1333
  };
1334
+ if(opts.monthSelect){
1335
+ obj.splits.push($('<select class="mm">'+getMonthOptions()+'</select>')[0]);
1336
+ } else {
1337
+ obj.splits.push($('<input type="text" class="mm" inputmode="numeric" maxlength="2" size="2" />')[0]);
1338
+ }
1339
+ obj.splits.push($('<input type="text" class="dd ws-spin" inputmode="numeric" maxlength="2" size="2" />')[0]);
1340
+
1341
+
1321
1342
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]];
1322
1343
  return obj;
1323
1344
  },
@@ -1325,7 +1346,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1325
1346
  createFormat('d');
1326
1347
  var i = 0;
1327
1348
  var seperators = $('.ws-input-seperator', element).html(curCfg.dFormat);
1328
- var inputs = $('input', element);
1349
+ var inputs = $('input, select', element);
1329
1350
  $.each(curCfg.patterns.dObj, function(name, value){
1330
1351
  var input = inputs.filter('.'+ name);
1331
1352
  if(input[0]){
@@ -1343,17 +1364,23 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1343
1364
  _create: function(opts){
1344
1365
 
1345
1366
  var obj = {
1346
- splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0], $('<input type="text" class="mm ws-spin" />')[0]]
1367
+ splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0]]
1347
1368
  };
1348
- if(opts.onlyMonthDigits){
1349
- $(obj.splits[1]).attr({inputmode: 'numeric', size: 2, maxlength: 2});
1369
+ if(opts.monthSelect){
1370
+ obj.splits.push($('<select class="mm ws-spin">'+getMonthOptions()+'</select>')[0]);
1371
+ } else {
1372
+ obj.splits.push($('<input type="text" class="mm ws-spin" />')[0]);
1373
+ if(opts.onlyMonthDigits){
1374
+ $(obj.splits[1]).attr({inputmode: 'numeric', size: 2, maxlength: 2});
1375
+ }
1350
1376
  }
1377
+
1351
1378
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
1352
1379
  return obj;
1353
1380
  },
1354
1381
  sort: function(element){
1355
1382
  var seperator = $('.ws-input-seperator', element).html(curCfg.dFormat);
1356
- var mm = $('input.mm', element);
1383
+ var mm = $('input.mm, select.mm', element);
1357
1384
  var action;
1358
1385
  if(curCfg.date.showMonthAfterYear){
1359
1386
  mm.appendTo(element);
@@ -1367,7 +1394,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1367
1394
  }
1368
1395
  };
1369
1396
 
1370
- var nowDate = new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 );
1397
+ var nowDate = new Date(new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 ));
1398
+ nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime()
1371
1399
  var steps = {
1372
1400
  number: {
1373
1401
  step: 1
@@ -1376,6 +1404,10 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1376
1404
  // step: 1,
1377
1405
  // start: new Date(nowDate)
1378
1406
  // },
1407
+ 'datetime-local': {
1408
+ step: 60,
1409
+ start: new Date(nowDate).getTime()
1410
+ },
1379
1411
  time: {
1380
1412
  step: 60
1381
1413
  },
@@ -1411,7 +1443,6 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1411
1443
 
1412
1444
 
1413
1445
  (function(){
1414
- var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
1415
1446
 
1416
1447
  formcfg.de = $.extend(true, {
1417
1448
  numberFormat: {
@@ -1461,6 +1492,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1461
1492
  patterns: {
1462
1493
  d: "mm/dd/yy"
1463
1494
  },
1495
+ meridian: ['AM', 'PM'],
1464
1496
  month: {
1465
1497
  currentText: 'This month'
1466
1498
  },
@@ -1514,12 +1546,18 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1514
1546
  langCfg.date.monthkeys = {};
1515
1547
  langCfg.date.monthDigits = monthDigits;
1516
1548
  langCfg.numberSigns += '-';
1549
+ if(langCfg.meridian){
1550
+ langCfg.timeSigns += langCfg.meridian[0] + langCfg.meridian[1];
1551
+ }
1517
1552
  $.each(langCfg.date.monthNames, create);
1518
1553
  $.each(langCfg.date.monthNamesShort, create);
1519
1554
  }
1520
1555
  if(!langCfg.colorSigns){
1521
1556
  langCfg.colorSigns = '#abcdefABCDEF';
1522
1557
  }
1558
+ if(!langCfg['datetime-localSigns']){
1559
+ langCfg['datetime-localSigns'] = langCfg.dateSigns+langCfg.timeSigns;
1560
+ }
1523
1561
  };
1524
1562
  var triggerLocaleChange = function(){
1525
1563
  processLangCFG(curCfg);
@@ -1576,11 +1614,31 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1576
1614
  return (val+'').replace(/\,/g, '').replace(/\./, curCfg.numberFormat['.']);
1577
1615
  },
1578
1616
  time: function(val){
1617
+ var fVal;
1618
+ if(val && curCfg.meridian){
1619
+ val = val.split(':');
1620
+ fVal = (val[0] * 1);
1621
+ if(fVal && fVal >= 12){
1622
+ val[0] = addZero(fVal - 12+'');
1623
+ fVal = 1;
1624
+
1625
+ } else {
1626
+ fVal = 0;
1627
+ }
1628
+ val = $.trim(val.join(':')) + ' '+ curCfg.meridian[fVal];
1629
+ }
1579
1630
  return val;
1580
1631
  },
1581
- week: function(val){
1632
+ 'datetime-local': function(val, o){
1633
+ var fVal = $.trim(val || '').split('T');
1634
+ if(fVal.length == 2){
1635
+ val = this.date(fVal[0], o) +' '+this.time(fVal[1], o);
1636
+ }
1582
1637
  return val;
1583
1638
  },
1639
+ // week: function(val){
1640
+ // return val;
1641
+ // },
1584
1642
  //todo empty val for month/split
1585
1643
  month: function(val, options){
1586
1644
  var names;
@@ -1633,7 +1691,32 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1633
1691
  // week: function(val){
1634
1692
  // return val;
1635
1693
  // },
1694
+ 'datetime-local': function(val, o){
1695
+ var tmp;
1696
+ var fVal = $.trim(val || '').split(/\s+/);
1697
+ if(fVal.length == 2){
1698
+ if(fVal[0].indexOf(':') != -1 && fVal[1].indexOf(':') == -1){
1699
+ tmp = fVal[1];
1700
+ fVal[1] = fVal[0];
1701
+ fVal[0] = tmp;
1702
+ }
1703
+ val = this.date(fVal[0], o) +'T'+ this.time(fVal[1], o);
1704
+ }
1705
+ return val;
1706
+ },
1636
1707
  time: function(val){
1708
+ var fVal;
1709
+ if(val && curCfg.meridian){
1710
+ if(val.indexOf(curCfg.meridian[1]) != -1){
1711
+ val = val.split(':');
1712
+ fVal = (val[0] * 1);
1713
+ if(!isNaN(fVal)){
1714
+ val[0] = fVal + 12;
1715
+ }
1716
+ val = val.join(':');
1717
+ }
1718
+ val = $.trim(val.replace(curCfg.meridian[0], '').replace(curCfg.meridian[1], ''));
1719
+ }
1637
1720
  return val;
1638
1721
  },
1639
1722
  month: function(val, opts, noCorrect){
@@ -1734,8 +1817,16 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1734
1817
  var type = (typeof val == 'object') ? 'valueAsDate' : 'valueAsNumber';
1735
1818
  return input.prop(type, val).prop('value');
1736
1819
  },
1737
- isValid: function(val){
1738
- return input.prop('value', val).is(':valid') && input.prop('value') == val;
1820
+ isValid: function(val, attrs){
1821
+ if(attrs && (attrs.nodeName || attrs.jquery)){
1822
+ attrs = {
1823
+ min: $(attrs).prop('min') || '',
1824
+ max: $(attrs).prop('max') || '',
1825
+ step: $(attrs).prop('step') || 'any'
1826
+ };
1827
+ }
1828
+ attrs = $.extend({step: 'any', min: '', max: ''}, attrs || {});
1829
+ return input.attr(attrs).prop('value', val).is(':valid') && input.prop('value') == val;
1739
1830
  }
1740
1831
  };
1741
1832
  }
@@ -1760,6 +1851,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1760
1851
  o.mirrorValidity = o.mirrorValidity && this.orig && Modernizr.formvalidation && !webshims.bugs.bustedValidity;
1761
1852
 
1762
1853
  if(o.splitInput && this._addSplitInputs){
1854
+ if(o.monthSelect){
1855
+ this.element.addClass('ws-month-select');
1856
+ }
1763
1857
  this._addSplitInputs();
1764
1858
  } else {
1765
1859
  this.inputElements = this.element;
@@ -2011,7 +2105,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2011
2105
  try {
2012
2106
  $(this)
2013
2107
  .next()
2014
- .next('input')
2108
+ .next('input, select')
2015
2109
  .each(select)
2016
2110
  ;
2017
2111
  } catch(er){}
@@ -2089,7 +2183,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2089
2183
  }
2090
2184
  };
2091
2185
  spinEvents.keydown = function(e){
2092
- if(o.list || e.isDefaultPrevented() || $.attr(this, 'list')){return;}
2186
+ if(o.list || e.isDefaultPrevented() || (e.altKey && e.keyCode == 40) || $.attr(this, 'list')){return;}
2093
2187
  var stepped = true;
2094
2188
  var code = e.keyCode;
2095
2189
  if (code == 38) {
@@ -2212,7 +2306,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2212
2306
  return [options, datalist.data('label')];
2213
2307
  },
2214
2308
  list: function(val){
2215
- if(this.type == 'number' || this.type == 'time'){
2309
+ if(this.type == 'number'){
2216
2310
  this.element.attr('list', $.attr(this.orig, 'list'));
2217
2311
  }
2218
2312
  this.options.list = val;
@@ -2295,7 +2389,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2295
2389
  if(!this.inputElements){
2296
2390
  var create = splitInputs[this.type]._create(this.options);
2297
2391
  this.splits = create.splits;
2298
- this.inputElements = $(create.elements).prependTo(this.element).filter('input');
2392
+ this.inputElements = $(create.elements).prependTo(this.element).filter('input, select');
2299
2393
  }
2300
2394
  },
2301
2395
 
@@ -2321,11 +2415,11 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2321
2415
  reorderInputs: function(){
2322
2416
  if(splitInputs[this.type]){
2323
2417
  var element = this.element;
2324
- splitInputs[this.type].sort(element);
2418
+ splitInputs[this.type].sort(element, this.options);
2325
2419
  setTimeout(function(){
2326
2420
  var data = webshims.data(element);
2327
2421
  if(data && data.shadowData){
2328
- data.shadowData.shadowFocusElement = element.find('input')[0] || element[0];
2422
+ data.shadowData.shadowFocusElement = element.find('input, select')[0] || element[0];
2329
2423
  }
2330
2424
  }, 9);
2331
2425
  }
@@ -2428,8 +2522,21 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2428
2522
  options: options
2429
2523
  });
2430
2524
 
2525
+ webshims.inlinePopover = {
2526
+ _create: function(){
2527
+ this.element = $('<div class="ws-inline-picker"><div class="ws-po-box" /></div>').data('wspopover', this);
2528
+ this.contentElement = $('.ws-po-box', this.element);
2529
+ this.element.insertAfter(this.options.prepareFor);
2530
+ },
2531
+ show: $.noop,
2532
+ hide: $.noop,
2533
+ preventBlur: $.noop,
2534
+ isVisible: true
2535
+ };
2536
+
2431
2537
  picker._genericSetFocus = function(element, _noFocus){
2432
2538
  element = $(element || this.activeButton);
2539
+
2433
2540
  if(!this.popover.openedByFocus && !_noFocus){
2434
2541
  var that = this;
2435
2542
  var setFocus = function(noTrigger){
@@ -2454,12 +2561,14 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2454
2561
  data.setChange(val);
2455
2562
  },
2456
2563
  cancel: function(val, popover, data){
2457
- popover.stopOpen = true;
2458
- data.element.getShadowFocusElement().focus();
2459
- setTimeout(function(){
2460
- popover.stopOpen = false;
2461
- }, 9);
2462
- popover.hide();
2564
+ if(!data.options.inlinePicker){
2565
+ popover.stopOpen = true;
2566
+ data.element.getShadowFocusElement().focus();
2567
+ setTimeout(function(){
2568
+ popover.stopOpen = false;
2569
+ }, 9);
2570
+ popover.hide();
2571
+ }
2463
2572
  }
2464
2573
  };
2465
2574
 
@@ -2472,28 +2581,31 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2472
2581
  popover.element.on('updatepickercontent pickerchange', function(){
2473
2582
  tabbable = false;
2474
2583
  });
2475
- popover.contentElement.on({
2476
- keydown: function(e){
2477
- if(e.keyCode == 9){
2478
- if(!tabbable){
2479
- tabbable = $('input:not(:disabled), [tabindex="0"]:not(:disabled)', this).filter(':visible');
2480
- }
2481
- var index = tabbable.index(e.target);
2482
- if(e.shiftKey && index <= 0){
2483
- tabbable.last().focus();
2484
- return false;
2485
- }
2486
- if(!e.shiftKey && index >= tabbable.length - 1){
2487
- tabbable.first().focus();
2584
+
2585
+ if(!data.options.inlinePicker){
2586
+ popover.contentElement.on({
2587
+ keydown: function(e){
2588
+ if(e.keyCode == 9){
2589
+ if(!tabbable){
2590
+ tabbable = $('input:not(:disabled), [tabindex="0"]:not(:disabled)', this).filter(':visible');
2591
+ }
2592
+ var index = tabbable.index(e.target);
2593
+ if(e.shiftKey && index <= 0){
2594
+ tabbable.last().focus();
2595
+ return false;
2596
+ }
2597
+ if(!e.shiftKey && index >= tabbable.length - 1){
2598
+ tabbable.first().focus();
2599
+ return false;
2600
+ }
2601
+ } else if(e.keyCode == 27){
2602
+ data.element.getShadowFocusElement().focus();
2603
+ popover.hide();
2488
2604
  return false;
2489
2605
  }
2490
- } else if(e.keyCode == 27){
2491
- data.element.getShadowFocusElement().focus();
2492
- popover.hide();
2493
- return false;
2494
2606
  }
2495
- }
2496
- });
2607
+ });
2608
+ }
2497
2609
 
2498
2610
  data._propertyChange = (function(){
2499
2611
  var timer;
@@ -2503,7 +2615,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2503
2615
  }
2504
2616
  };
2505
2617
  return function(prop){
2506
- if(prop == 'value'){return;}
2618
+ if(prop == 'value' && !data.options.inlinePicker){return;}
2507
2619
  popover.isDirty = true;
2508
2620
  if(popover.isVisible){
2509
2621
  clearTimeout(timer);
@@ -2540,7 +2652,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2540
2652
 
2541
2653
  picker._common = function(data){
2542
2654
  var options = data.options;
2543
- var popover = webshims.objectCreate(webshims.wsPopover, {}, {prepareFor: data.element, position: options.widgetPosition});
2655
+ var popover = webshims.objectCreate(options.inlinePicker ? webshims.inlinePopover : webshims.wsPopover, {}, {prepareFor: options.inlinePicker ? data.buttonWrapper : data.element, position: options.widgetPosition});
2544
2656
  var opener = $('<button type="button" class="ws-popover-opener"><span /></button>').appendTo(data.buttonWrapper);
2545
2657
 
2546
2658
 
@@ -2549,18 +2661,34 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2549
2661
  };
2550
2662
  var show = function(){
2551
2663
  var type = loadPicker(data.type, 'DOM');
2552
- if(!options.disabled && !options.readonly && !popover.isVisible){
2664
+ if(!options.disabled && !options.readonly && (options.inlinePicker || !popover.isVisible)){
2553
2665
  webshims.ready(type, showPickerContent);
2554
2666
  popover.show(data.element);
2555
2667
  }
2556
2668
  };
2669
+ var open = function(){
2670
+ if((options.inlinePicker || popover.isVisible) && popover.activeElement){
2671
+ popover.openedByFocus = false;
2672
+ popover.activeElement.focus();
2673
+ }
2674
+ show();
2675
+ };
2676
+
2557
2677
 
2558
2678
  options.containerElements.push(popover.element[0]);
2559
2679
 
2560
2680
  if(data.type != 'color'){
2681
+ if(options.yearButtons){
2682
+ options.startView = 2;
2683
+ }
2561
2684
  if(!options.startView){
2562
2685
  options.startView = 0;
2563
2686
  }
2687
+
2688
+ if(data.type == 'time'){
2689
+ options.minView = 3;
2690
+ options.startView = 3;
2691
+ }
2564
2692
  if(!options.minView){
2565
2693
  options.minView = 0;
2566
2694
  }
@@ -2590,6 +2718,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2590
2718
  if(popover.activeElement){
2591
2719
  popover.activeElement.removeClass('ws-focus');
2592
2720
  }
2721
+ if(options.inlinePicker){
2722
+ popover.openedByFocus = true;
2723
+ }
2593
2724
  }
2594
2725
  })
2595
2726
  ;
@@ -2605,57 +2736,63 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2605
2736
  opener.prop({disabled: true});
2606
2737
  }
2607
2738
 
2608
- opener
2609
- .on({
2610
- mousedown: function(){
2611
- stopPropagation.apply(this, arguments);
2612
- popover.preventBlur();
2613
- },
2614
- click: function(){
2615
- if(popover.isVisible && popover.activeElement){
2616
- popover.openedByFocus = false;
2617
- popover.activeElement.focus();
2618
- }
2619
- show();
2620
- },
2621
- focus: function(){
2622
- popover.preventBlur();
2623
- }
2624
- })
2625
- ;
2626
2739
 
2627
- (function(){
2628
- var mouseFocus = false;
2629
- var resetMouseFocus = function(){
2630
- mouseFocus = false;
2631
- };
2632
- data.inputElements.on({
2633
- focus: function(){
2634
- if(!popover.stopOpen && (options.buttonOnly || options.openOnFocus || (mouseFocus && options.openOnMouseFocus))){
2635
- popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
2636
- show();
2637
- } else {
2740
+ opener.on({click: open});
2741
+
2742
+ if(options.inlinePicker){
2743
+ popover.openedByFocus = true;
2744
+ } else {
2745
+ opener
2746
+ .on({
2747
+ mousedown: function(){
2748
+ stopPropagation.apply(this, arguments);
2749
+ popover.preventBlur();
2750
+ },
2751
+ focus: function(){
2638
2752
  popover.preventBlur();
2639
2753
  }
2640
- },
2641
- mousedown: function(){
2642
- mouseFocus = true;
2643
- setTimeout(resetMouseFocus, 9);
2644
- if(options.buttonOnly && popover.isVisible && popover.activeElement){
2645
- popover.openedByFocus = false;
2646
- setTimeout(function(){
2754
+ })
2755
+ ;
2756
+
2757
+ (function(){
2758
+ var mouseFocus = false;
2759
+ var resetMouseFocus = function(){
2760
+ mouseFocus = false;
2761
+ };
2762
+ data.inputElements.on({
2763
+ keydown: function(e){
2764
+ if(e.keyCode == 40 && e.altKey){
2765
+ open();
2766
+ }
2767
+ },
2768
+ focus: function(){
2769
+ if(!popover.stopOpen && (options.buttonOnly || options.openOnFocus || (mouseFocus && options.openOnMouseFocus))){
2770
+ popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
2771
+ show();
2772
+ } else {
2773
+ popover.preventBlur();
2774
+ }
2775
+ },
2776
+ mousedown: function(){
2777
+ mouseFocus = true;
2778
+ setTimeout(resetMouseFocus, 9);
2779
+ if(options.buttonOnly && popover.isVisible && popover.activeElement){
2647
2780
  popover.openedByFocus = false;
2648
- popover.activeElement.focus();
2649
- }, 4);
2650
- }
2651
- if(data.element.is(':focus')){
2652
- popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
2653
- show();
2781
+ setTimeout(function(){
2782
+ popover.openedByFocus = false;
2783
+ popover.activeElement.focus();
2784
+ }, 4);
2785
+ }
2786
+ if(data.element.is(':focus')){
2787
+ popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
2788
+ show();
2789
+ }
2790
+ popover.preventBlur();
2654
2791
  }
2655
- popover.preventBlur();
2656
- }
2657
- });
2658
- })();
2792
+ });
2793
+ })();
2794
+ }
2795
+
2659
2796
  data.popover = popover;
2660
2797
  data.opener = opener;
2661
2798
  $(data.orig).on('remove', function(e){
@@ -2666,12 +2803,16 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2666
2803
  }, 4);
2667
2804
  }
2668
2805
  });
2669
-
2806
+ if(options.inlinePicker){
2807
+ show();
2808
+ }
2670
2809
  loadPicker(data.type, 'WINDOWLOAD');
2671
2810
  };
2672
2811
 
2673
2812
  picker.month = picker._common;
2674
2813
  picker.date = picker._common;
2814
+ picker.time = picker._common;
2815
+ picker['datetime-local'] = picker._common;
2675
2816
  // picker.week = picker._common;
2676
2817
  picker.color = function(data){
2677
2818
  var ret = picker._common.apply(this, arguments);
@@ -2855,6 +2996,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2855
2996
  opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
2856
2997
  }
2857
2998
  }
2999
+ if(opts.monthSelect){
3000
+ opts.onlyMonthDigits = true;
3001
+ }
2858
3002
  if(opts.onlyMonthDigits){
2859
3003
  opts.formatMonthNames = 'monthDigits';
2860
3004
  }
@@ -2960,11 +3104,14 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2960
3104
  });
2961
3105
  }
2962
3106
 
2963
- var isStupid = navigator.userAgent.indexOf('MSIE 10.0') != -1 && navigator.userAgent.indexOf('Touch') == -1;
2964
- ['number', 'time', 'month', 'date', 'color'].forEach(function(name){
3107
+ var isStupid = modernizrInputTypes.number && navigator.userAgent.indexOf('Touch') == -1 && (/MSIE 1[0|1]\.\d/.test(navigator.userAgent) || /Trident\/7\.0/.test(navigator.userAgent));
3108
+ ['number', 'time', 'month', 'date', 'color', 'datetime-local'].forEach(function(name){
2965
3109
  if(!modernizrInputTypes[name] || options.replaceUI || (name == 'number' && isStupid)){
2966
3110
  extendType(name, {
2967
3111
  _create: function(opts, set){
3112
+ if(opts.monthSelect){
3113
+ opts.splitInput = true;
3114
+ }
2968
3115
  if(opts.splitInput && !splitInputs[name]){
2969
3116
  webshims.warn('splitInput not supported for '+ name);
2970
3117
  opts.splitInput = false;
@@ -3097,34 +3244,6 @@ webshims.register('form-datalist', function($, webshims, window, document, undef
3097
3244
  }
3098
3245
  };
3099
3246
 
3100
- if(formsCFG.customDatalist && (!listSupport || !('selectedOption' in $('<input />')[0]))){
3101
- //currently not supported x-browser (FF4 has not implemented and is not polyfilled )
3102
- inputListProto.selectedOption = {
3103
- prop: {
3104
- writeable: false,
3105
- get: function(){
3106
- var elem = this;
3107
- var list = $.prop(elem, 'list');
3108
- var ret = null;
3109
- var value, options;
3110
- if(!list){return ret;}
3111
- value = $.prop(elem, 'value');
3112
- if(!value){return ret;}
3113
- options = $.prop(list, 'options');
3114
- if(!options.length){return ret;}
3115
- $.each(options, function(i, option){
3116
- if(value == $.prop(option, 'value')){
3117
- ret = option;
3118
- return false;
3119
- }
3120
- });
3121
- return ret;
3122
- }
3123
- }
3124
- };
3125
- }
3126
-
3127
-
3128
3247
  if(listSupport){
3129
3248
  //options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
3130
3249
  if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){