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
@@ -952,8 +952,8 @@ webshims.register('form-number-date-api', function($, webshims, window, document
952
952
  } else {
953
953
  webshims.error('INVALID_STATE_ERR: DOM Exception 11');
954
954
  }
955
- } else {
956
- valueAsNumberDescriptor.prop._supset && valueAsNumberDescriptor.prop._supset.apply(elem, arguments);
955
+ } else if(valueAsNumberDescriptor.prop._supset) {
956
+ valueAsNumberDescriptor.prop._supset.apply(elem, arguments);
957
957
  }
958
958
  }
959
959
  }
@@ -1080,7 +1080,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1080
1080
  var typeProtos = {
1081
1081
 
1082
1082
  number: {
1083
- mismatch: function(val){
1083
+ bad: function(val){
1084
1084
  return !(isNumber(val));
1085
1085
  },
1086
1086
  step: 1,
@@ -1099,7 +1099,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1099
1099
  maxDefault: 100
1100
1100
  },
1101
1101
  color: {
1102
- mismatch: (function(){
1102
+ bad: (function(){
1103
1103
  var cReg = /^\u0023[a-f0-9]{6}$/;
1104
1104
  return function(val){
1105
1105
  return (!val || val.length != 7 || !(cReg.test(val)));
@@ -1107,7 +1107,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1107
1107
  })()
1108
1108
  },
1109
1109
  date: {
1110
- mismatch: function(val){
1110
+ bad: function(val){
1111
1111
  if(!val || !val.split || !(/\d$/.test(val))){return true;}
1112
1112
  var i;
1113
1113
  var valA = val.split(/\u002D/);
@@ -1132,14 +1132,14 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1132
1132
  //stepBase: 0, 0 = default
1133
1133
  stepScaleFactor: 86400000,
1134
1134
  asDate: function(val, _noMismatch){
1135
- if(!_noMismatch && this.mismatch(val)){
1135
+ if(!_noMismatch && this.bad(val)){
1136
1136
  return null;
1137
1137
  }
1138
1138
  return new Date(this.asNumber(val, true));
1139
1139
  },
1140
1140
  asNumber: function(str, _noMismatch){
1141
1141
  var ret = nan;
1142
- if(_noMismatch || !this.mismatch(str)){
1142
+ if(_noMismatch || !this.bad(str)){
1143
1143
  str = str.split(/\u002D/);
1144
1144
  ret = Date.UTC(str[0], str[1] - 1, str[2]);
1145
1145
  }
@@ -1156,7 +1156,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1156
1156
  * ToDO: WEEK
1157
1157
  */
1158
1158
  // week: {
1159
- // mismatch: function(val){
1159
+ // bad: function(val){
1160
1160
  // if(!val || !val.split){return true;}
1161
1161
  // var valA = val.split('-W');
1162
1162
  // var ret = true;
@@ -1170,7 +1170,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1170
1170
  // stepBase: -259200000,
1171
1171
  // asDate: function(str, _noMismatch){
1172
1172
  // var ret = null;
1173
- // if(_noMismatch || !this.mismatch(str)){
1173
+ // if(_noMismatch || !this.bad(str)){
1174
1174
  // ret = str.split('-W');
1175
1175
  // ret = setWeek(ret[0], ret[1]);
1176
1176
  // }
@@ -1203,7 +1203,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1203
1203
  // }
1204
1204
  // },
1205
1205
  time: {
1206
- mismatch: function(val, _getParsed){
1206
+ bad: function(val, _getParsed){
1207
1207
  if(!val || !val.split || !(/\d$/.test(val))){return true;}
1208
1208
  val = val.split(/\u003A/);
1209
1209
  if(val.length < 2 || val.length > 3){return true;}
@@ -1248,7 +1248,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1248
1248
  },
1249
1249
  asNumber: function(val){
1250
1250
  var ret = nan;
1251
- val = this.mismatch(val, true);
1251
+ val = this.bad(val, true);
1252
1252
  if(val !== true){
1253
1253
  ret = Date.UTC('1970', 0, 1, val[0][0], val[0][1], val[0][2] || 0);
1254
1254
  if(val[1]){
@@ -1276,8 +1276,8 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1276
1276
  }
1277
1277
  },
1278
1278
  month: {
1279
- mismatch: function(val){
1280
- return typeProtos.date.mismatch(val+'-01');
1279
+ bad: function(val){
1280
+ return typeProtos.date.bad(val+'-01');
1281
1281
  },
1282
1282
  step: 1,
1283
1283
  stepScaleFactor: false,
@@ -1288,7 +1288,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1288
1288
  asNumber: function(val){
1289
1289
  //1970-01
1290
1290
  var ret = nan;
1291
- if(val && !this.mismatch(val)){
1291
+ if(val && !this.bad(val)){
1292
1292
  val = val.split(/\u002D/);
1293
1293
  val[0] = (val[0] * 1) - 1970;
1294
1294
  val[1] = (val[1] * 1) - 1;
@@ -1322,46 +1322,46 @@ webshims.register('form-number-date-api', function($, webshims, window, document
1322
1322
  }
1323
1323
  }
1324
1324
  }
1325
- // ,'datetime-local': {
1326
- // mismatch: function(val, _getParsed){
1327
- // if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;}
1328
- // val = val.split(/\u0054/);
1329
- // return ( typeProtos.date.mismatch(val[0]) || typeProtos.time.mismatch(val[1], _getParsed) );
1330
- // },
1331
- // noAsDate: true,
1332
- // asDate: function(val){
1333
- // val = new Date(this.asNumber(val));
1334
- //
1335
- // return (isNaN(val)) ? null : val;
1336
- // },
1337
- // asNumber: function(val){
1338
- // var ret = nan;
1339
- // var time = this.mismatch(val, true);
1340
- // if(time !== true){
1341
- // val = val.split(/\u0054/)[0].split(/\u002D/);
1342
- //
1343
- // ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0);
1344
- // if(time[1]){
1345
- // ret += time[1];
1346
- // }
1347
- // }
1348
- // return ret;
1349
- // },
1350
- // dateToString: function(date, _getParsed){
1351
- // return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed);
1352
- // }
1353
- // }
1325
+ ,'datetime-local': {
1326
+ bad: function(val, _getParsed){
1327
+ if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;}
1328
+ val = val.split(/\u0054/);
1329
+ return ( typeProtos.date.bad(val[0]) || typeProtos.time.bad(val[1], _getParsed) );
1330
+ },
1331
+ noAsDate: true,
1332
+ asDate: function(val){
1333
+ val = new Date(this.asNumber(val));
1334
+
1335
+ return (isNaN(val)) ? null : val;
1336
+ },
1337
+ asNumber: function(val){
1338
+ var ret = nan;
1339
+ var time = this.bad(val, true);
1340
+ if(time !== true){
1341
+ val = val.split(/\u0054/)[0].split(/\u002D/);
1342
+
1343
+ ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0);
1344
+ if(time[1]){
1345
+ ret += time[1];
1346
+ }
1347
+ }
1348
+ return ret;
1349
+ },
1350
+ dateToString: function(date, _getParsed){
1351
+ return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed);
1352
+ }
1353
+ }
1354
1354
  };
1355
1355
 
1356
- if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month')){
1356
+ if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month') || !supportsType('datetime-local')){
1357
1357
  typeProtos.range = $.extend({}, typeProtos.number, typeProtos.range);
1358
1358
  typeProtos.time = $.extend({}, typeProtos.date, typeProtos.time);
1359
1359
  typeProtos.month = $.extend({}, typeProtos.date, typeProtos.month);
1360
- // typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']);
1360
+ typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']);
1361
1361
  }
1362
1362
 
1363
- //'datetime-local'
1364
- ['number', 'month', 'range', 'date', 'time', 'color'].forEach(function(type){
1363
+ //
1364
+ ['number', 'month', 'range', 'date', 'time', 'color', 'datetime-local'].forEach(function(type){
1365
1365
  if(typeBugs || !supportsType(type)){
1366
1366
  webshims.addInputType(type, typeProtos[type]);
1367
1367
  }
@@ -1892,10 +1892,21 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1892
1892
  "use strict";
1893
1893
  var curCfg;
1894
1894
  var formcfg = webshims.formcfg;
1895
-
1895
+ var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
1896
1896
  var stopPropagation = function(e){
1897
1897
  e.stopImmediatePropagation();
1898
1898
  };
1899
+ var getMonthOptions = (function(){
1900
+ var str;
1901
+ return function(){
1902
+ if(!str){
1903
+ str = ('<option></option>')+$.map(monthDigits, function(val){
1904
+ return '<option>'+val+'</option>';
1905
+ }).join('');
1906
+ }
1907
+ return str;
1908
+ };
1909
+ })();
1899
1910
  var createFormat = function(name){
1900
1911
  if(!curCfg.patterns[name+'Obj']){
1901
1912
  var obj = {};
@@ -1907,10 +1918,18 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1907
1918
  };
1908
1919
  var splitInputs = {
1909
1920
  date: {
1910
- _create: function(){
1921
+ _create: function(opts){
1911
1922
  var obj = {
1912
- 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]]
1923
+ splits: [$('<input type="text" class="yy" size="4" inputmode="numeric" />')[0]]
1913
1924
  };
1925
+ if(opts.monthSelect){
1926
+ obj.splits.push($('<select class="mm">'+getMonthOptions()+'</select>')[0]);
1927
+ } else {
1928
+ obj.splits.push($('<input type="text" class="mm" inputmode="numeric" maxlength="2" size="2" />')[0]);
1929
+ }
1930
+ obj.splits.push($('<input type="text" class="dd ws-spin" inputmode="numeric" maxlength="2" size="2" />')[0]);
1931
+
1932
+
1914
1933
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]];
1915
1934
  return obj;
1916
1935
  },
@@ -1918,7 +1937,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1918
1937
  createFormat('d');
1919
1938
  var i = 0;
1920
1939
  var seperators = $('.ws-input-seperator', element).html(curCfg.dFormat);
1921
- var inputs = $('input', element);
1940
+ var inputs = $('input, select', element);
1922
1941
  $.each(curCfg.patterns.dObj, function(name, value){
1923
1942
  var input = inputs.filter('.'+ name);
1924
1943
  if(input[0]){
@@ -1936,17 +1955,23 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1936
1955
  _create: function(opts){
1937
1956
 
1938
1957
  var obj = {
1939
- splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0], $('<input type="text" class="mm ws-spin" />')[0]]
1958
+ splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0]]
1940
1959
  };
1941
- if(opts.onlyMonthDigits){
1942
- $(obj.splits[1]).attr({inputmode: 'numeric', size: 2, maxlength: 2});
1960
+ if(opts.monthSelect){
1961
+ obj.splits.push($('<select class="mm ws-spin">'+getMonthOptions()+'</select>')[0]);
1962
+ } else {
1963
+ obj.splits.push($('<input type="text" class="mm ws-spin" />')[0]);
1964
+ if(opts.onlyMonthDigits){
1965
+ $(obj.splits[1]).attr({inputmode: 'numeric', size: 2, maxlength: 2});
1966
+ }
1943
1967
  }
1968
+
1944
1969
  obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
1945
1970
  return obj;
1946
1971
  },
1947
1972
  sort: function(element){
1948
1973
  var seperator = $('.ws-input-seperator', element).html(curCfg.dFormat);
1949
- var mm = $('input.mm', element);
1974
+ var mm = $('input.mm, select.mm', element);
1950
1975
  var action;
1951
1976
  if(curCfg.date.showMonthAfterYear){
1952
1977
  mm.appendTo(element);
@@ -1960,7 +1985,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1960
1985
  }
1961
1986
  };
1962
1987
 
1963
- var nowDate = new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 );
1988
+ var nowDate = new Date(new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 ));
1989
+ nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime()
1964
1990
  var steps = {
1965
1991
  number: {
1966
1992
  step: 1
@@ -1969,6 +1995,10 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
1969
1995
  // step: 1,
1970
1996
  // start: new Date(nowDate)
1971
1997
  // },
1998
+ 'datetime-local': {
1999
+ step: 60,
2000
+ start: new Date(nowDate).getTime()
2001
+ },
1972
2002
  time: {
1973
2003
  step: 60
1974
2004
  },
@@ -2004,7 +2034,6 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2004
2034
 
2005
2035
 
2006
2036
  (function(){
2007
- var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
2008
2037
 
2009
2038
  formcfg.de = $.extend(true, {
2010
2039
  numberFormat: {
@@ -2054,6 +2083,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2054
2083
  patterns: {
2055
2084
  d: "mm/dd/yy"
2056
2085
  },
2086
+ meridian: ['AM', 'PM'],
2057
2087
  month: {
2058
2088
  currentText: 'This month'
2059
2089
  },
@@ -2107,12 +2137,18 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2107
2137
  langCfg.date.monthkeys = {};
2108
2138
  langCfg.date.monthDigits = monthDigits;
2109
2139
  langCfg.numberSigns += '-';
2140
+ if(langCfg.meridian){
2141
+ langCfg.timeSigns += langCfg.meridian[0] + langCfg.meridian[1];
2142
+ }
2110
2143
  $.each(langCfg.date.monthNames, create);
2111
2144
  $.each(langCfg.date.monthNamesShort, create);
2112
2145
  }
2113
2146
  if(!langCfg.colorSigns){
2114
2147
  langCfg.colorSigns = '#abcdefABCDEF';
2115
2148
  }
2149
+ if(!langCfg['datetime-localSigns']){
2150
+ langCfg['datetime-localSigns'] = langCfg.dateSigns+langCfg.timeSigns;
2151
+ }
2116
2152
  };
2117
2153
  var triggerLocaleChange = function(){
2118
2154
  processLangCFG(curCfg);
@@ -2169,11 +2205,31 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2169
2205
  return (val+'').replace(/\,/g, '').replace(/\./, curCfg.numberFormat['.']);
2170
2206
  },
2171
2207
  time: function(val){
2208
+ var fVal;
2209
+ if(val && curCfg.meridian){
2210
+ val = val.split(':');
2211
+ fVal = (val[0] * 1);
2212
+ if(fVal && fVal >= 12){
2213
+ val[0] = addZero(fVal - 12+'');
2214
+ fVal = 1;
2215
+
2216
+ } else {
2217
+ fVal = 0;
2218
+ }
2219
+ val = $.trim(val.join(':')) + ' '+ curCfg.meridian[fVal];
2220
+ }
2172
2221
  return val;
2173
2222
  },
2174
- week: function(val){
2223
+ 'datetime-local': function(val, o){
2224
+ var fVal = $.trim(val || '').split('T');
2225
+ if(fVal.length == 2){
2226
+ val = this.date(fVal[0], o) +' '+this.time(fVal[1], o);
2227
+ }
2175
2228
  return val;
2176
2229
  },
2230
+ // week: function(val){
2231
+ // return val;
2232
+ // },
2177
2233
  //todo empty val for month/split
2178
2234
  month: function(val, options){
2179
2235
  var names;
@@ -2226,7 +2282,32 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2226
2282
  // week: function(val){
2227
2283
  // return val;
2228
2284
  // },
2285
+ 'datetime-local': function(val, o){
2286
+ var tmp;
2287
+ var fVal = $.trim(val || '').split(/\s+/);
2288
+ if(fVal.length == 2){
2289
+ if(fVal[0].indexOf(':') != -1 && fVal[1].indexOf(':') == -1){
2290
+ tmp = fVal[1];
2291
+ fVal[1] = fVal[0];
2292
+ fVal[0] = tmp;
2293
+ }
2294
+ val = this.date(fVal[0], o) +'T'+ this.time(fVal[1], o);
2295
+ }
2296
+ return val;
2297
+ },
2229
2298
  time: function(val){
2299
+ var fVal;
2300
+ if(val && curCfg.meridian){
2301
+ if(val.indexOf(curCfg.meridian[1]) != -1){
2302
+ val = val.split(':');
2303
+ fVal = (val[0] * 1);
2304
+ if(!isNaN(fVal)){
2305
+ val[0] = fVal + 12;
2306
+ }
2307
+ val = val.join(':');
2308
+ }
2309
+ val = $.trim(val.replace(curCfg.meridian[0], '').replace(curCfg.meridian[1], ''));
2310
+ }
2230
2311
  return val;
2231
2312
  },
2232
2313
  month: function(val, opts, noCorrect){
@@ -2327,8 +2408,16 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2327
2408
  var type = (typeof val == 'object') ? 'valueAsDate' : 'valueAsNumber';
2328
2409
  return input.prop(type, val).prop('value');
2329
2410
  },
2330
- isValid: function(val){
2331
- return input.prop('value', val).is(':valid') && input.prop('value') == val;
2411
+ isValid: function(val, attrs){
2412
+ if(attrs && (attrs.nodeName || attrs.jquery)){
2413
+ attrs = {
2414
+ min: $(attrs).prop('min') || '',
2415
+ max: $(attrs).prop('max') || '',
2416
+ step: $(attrs).prop('step') || 'any'
2417
+ };
2418
+ }
2419
+ attrs = $.extend({step: 'any', min: '', max: ''}, attrs || {});
2420
+ return input.attr(attrs).prop('value', val).is(':valid') && input.prop('value') == val;
2332
2421
  }
2333
2422
  };
2334
2423
  }
@@ -2353,6 +2442,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2353
2442
  o.mirrorValidity = o.mirrorValidity && this.orig && Modernizr.formvalidation && !webshims.bugs.bustedValidity;
2354
2443
 
2355
2444
  if(o.splitInput && this._addSplitInputs){
2445
+ if(o.monthSelect){
2446
+ this.element.addClass('ws-month-select');
2447
+ }
2356
2448
  this._addSplitInputs();
2357
2449
  } else {
2358
2450
  this.inputElements = this.element;
@@ -2604,7 +2696,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2604
2696
  try {
2605
2697
  $(this)
2606
2698
  .next()
2607
- .next('input')
2699
+ .next('input, select')
2608
2700
  .each(select)
2609
2701
  ;
2610
2702
  } catch(er){}
@@ -2682,7 +2774,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2682
2774
  }
2683
2775
  };
2684
2776
  spinEvents.keydown = function(e){
2685
- if(o.list || e.isDefaultPrevented() || $.attr(this, 'list')){return;}
2777
+ if(o.list || e.isDefaultPrevented() || (e.altKey && e.keyCode == 40) || $.attr(this, 'list')){return;}
2686
2778
  var stepped = true;
2687
2779
  var code = e.keyCode;
2688
2780
  if (code == 38) {
@@ -2805,7 +2897,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2805
2897
  return [options, datalist.data('label')];
2806
2898
  },
2807
2899
  list: function(val){
2808
- if(this.type == 'number' || this.type == 'time'){
2900
+ if(this.type == 'number'){
2809
2901
  this.element.attr('list', $.attr(this.orig, 'list'));
2810
2902
  }
2811
2903
  this.options.list = val;
@@ -2888,7 +2980,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2888
2980
  if(!this.inputElements){
2889
2981
  var create = splitInputs[this.type]._create(this.options);
2890
2982
  this.splits = create.splits;
2891
- this.inputElements = $(create.elements).prependTo(this.element).filter('input');
2983
+ this.inputElements = $(create.elements).prependTo(this.element).filter('input, select');
2892
2984
  }
2893
2985
  },
2894
2986
 
@@ -2914,11 +3006,11 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
2914
3006
  reorderInputs: function(){
2915
3007
  if(splitInputs[this.type]){
2916
3008
  var element = this.element;
2917
- splitInputs[this.type].sort(element);
3009
+ splitInputs[this.type].sort(element, this.options);
2918
3010
  setTimeout(function(){
2919
3011
  var data = webshims.data(element);
2920
3012
  if(data && data.shadowData){
2921
- data.shadowData.shadowFocusElement = element.find('input')[0] || element[0];
3013
+ data.shadowData.shadowFocusElement = element.find('input, select')[0] || element[0];
2922
3014
  }
2923
3015
  }, 9);
2924
3016
  }
@@ -3021,8 +3113,21 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3021
3113
  options: options
3022
3114
  });
3023
3115
 
3116
+ webshims.inlinePopover = {
3117
+ _create: function(){
3118
+ this.element = $('<div class="ws-inline-picker"><div class="ws-po-box" /></div>').data('wspopover', this);
3119
+ this.contentElement = $('.ws-po-box', this.element);
3120
+ this.element.insertAfter(this.options.prepareFor);
3121
+ },
3122
+ show: $.noop,
3123
+ hide: $.noop,
3124
+ preventBlur: $.noop,
3125
+ isVisible: true
3126
+ };
3127
+
3024
3128
  picker._genericSetFocus = function(element, _noFocus){
3025
3129
  element = $(element || this.activeButton);
3130
+
3026
3131
  if(!this.popover.openedByFocus && !_noFocus){
3027
3132
  var that = this;
3028
3133
  var setFocus = function(noTrigger){
@@ -3047,12 +3152,14 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3047
3152
  data.setChange(val);
3048
3153
  },
3049
3154
  cancel: function(val, popover, data){
3050
- popover.stopOpen = true;
3051
- data.element.getShadowFocusElement().focus();
3052
- setTimeout(function(){
3053
- popover.stopOpen = false;
3054
- }, 9);
3055
- popover.hide();
3155
+ if(!data.options.inlinePicker){
3156
+ popover.stopOpen = true;
3157
+ data.element.getShadowFocusElement().focus();
3158
+ setTimeout(function(){
3159
+ popover.stopOpen = false;
3160
+ }, 9);
3161
+ popover.hide();
3162
+ }
3056
3163
  }
3057
3164
  };
3058
3165
 
@@ -3065,28 +3172,31 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3065
3172
  popover.element.on('updatepickercontent pickerchange', function(){
3066
3173
  tabbable = false;
3067
3174
  });
3068
- popover.contentElement.on({
3069
- keydown: function(e){
3070
- if(e.keyCode == 9){
3071
- if(!tabbable){
3072
- tabbable = $('input:not(:disabled), [tabindex="0"]:not(:disabled)', this).filter(':visible');
3073
- }
3074
- var index = tabbable.index(e.target);
3075
- if(e.shiftKey && index <= 0){
3076
- tabbable.last().focus();
3077
- return false;
3078
- }
3079
- if(!e.shiftKey && index >= tabbable.length - 1){
3080
- tabbable.first().focus();
3175
+
3176
+ if(!data.options.inlinePicker){
3177
+ popover.contentElement.on({
3178
+ keydown: function(e){
3179
+ if(e.keyCode == 9){
3180
+ if(!tabbable){
3181
+ tabbable = $('input:not(:disabled), [tabindex="0"]:not(:disabled)', this).filter(':visible');
3182
+ }
3183
+ var index = tabbable.index(e.target);
3184
+ if(e.shiftKey && index <= 0){
3185
+ tabbable.last().focus();
3186
+ return false;
3187
+ }
3188
+ if(!e.shiftKey && index >= tabbable.length - 1){
3189
+ tabbable.first().focus();
3190
+ return false;
3191
+ }
3192
+ } else if(e.keyCode == 27){
3193
+ data.element.getShadowFocusElement().focus();
3194
+ popover.hide();
3081
3195
  return false;
3082
3196
  }
3083
- } else if(e.keyCode == 27){
3084
- data.element.getShadowFocusElement().focus();
3085
- popover.hide();
3086
- return false;
3087
3197
  }
3088
- }
3089
- });
3198
+ });
3199
+ }
3090
3200
 
3091
3201
  data._propertyChange = (function(){
3092
3202
  var timer;
@@ -3096,7 +3206,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3096
3206
  }
3097
3207
  };
3098
3208
  return function(prop){
3099
- if(prop == 'value'){return;}
3209
+ if(prop == 'value' && !data.options.inlinePicker){return;}
3100
3210
  popover.isDirty = true;
3101
3211
  if(popover.isVisible){
3102
3212
  clearTimeout(timer);
@@ -3133,7 +3243,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3133
3243
 
3134
3244
  picker._common = function(data){
3135
3245
  var options = data.options;
3136
- var popover = webshims.objectCreate(webshims.wsPopover, {}, {prepareFor: data.element, position: options.widgetPosition});
3246
+ var popover = webshims.objectCreate(options.inlinePicker ? webshims.inlinePopover : webshims.wsPopover, {}, {prepareFor: options.inlinePicker ? data.buttonWrapper : data.element, position: options.widgetPosition});
3137
3247
  var opener = $('<button type="button" class="ws-popover-opener"><span /></button>').appendTo(data.buttonWrapper);
3138
3248
 
3139
3249
 
@@ -3142,18 +3252,34 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3142
3252
  };
3143
3253
  var show = function(){
3144
3254
  var type = loadPicker(data.type, 'DOM');
3145
- if(!options.disabled && !options.readonly && !popover.isVisible){
3255
+ if(!options.disabled && !options.readonly && (options.inlinePicker || !popover.isVisible)){
3146
3256
  webshims.ready(type, showPickerContent);
3147
3257
  popover.show(data.element);
3148
3258
  }
3149
3259
  };
3260
+ var open = function(){
3261
+ if((options.inlinePicker || popover.isVisible) && popover.activeElement){
3262
+ popover.openedByFocus = false;
3263
+ popover.activeElement.focus();
3264
+ }
3265
+ show();
3266
+ };
3267
+
3150
3268
 
3151
3269
  options.containerElements.push(popover.element[0]);
3152
3270
 
3153
3271
  if(data.type != 'color'){
3272
+ if(options.yearButtons){
3273
+ options.startView = 2;
3274
+ }
3154
3275
  if(!options.startView){
3155
3276
  options.startView = 0;
3156
3277
  }
3278
+
3279
+ if(data.type == 'time'){
3280
+ options.minView = 3;
3281
+ options.startView = 3;
3282
+ }
3157
3283
  if(!options.minView){
3158
3284
  options.minView = 0;
3159
3285
  }
@@ -3183,6 +3309,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3183
3309
  if(popover.activeElement){
3184
3310
  popover.activeElement.removeClass('ws-focus');
3185
3311
  }
3312
+ if(options.inlinePicker){
3313
+ popover.openedByFocus = true;
3314
+ }
3186
3315
  }
3187
3316
  })
3188
3317
  ;
@@ -3198,57 +3327,63 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3198
3327
  opener.prop({disabled: true});
3199
3328
  }
3200
3329
 
3201
- opener
3202
- .on({
3203
- mousedown: function(){
3204
- stopPropagation.apply(this, arguments);
3205
- popover.preventBlur();
3206
- },
3207
- click: function(){
3208
- if(popover.isVisible && popover.activeElement){
3209
- popover.openedByFocus = false;
3210
- popover.activeElement.focus();
3211
- }
3212
- show();
3213
- },
3214
- focus: function(){
3215
- popover.preventBlur();
3216
- }
3217
- })
3218
- ;
3219
3330
 
3220
- (function(){
3221
- var mouseFocus = false;
3222
- var resetMouseFocus = function(){
3223
- mouseFocus = false;
3224
- };
3225
- data.inputElements.on({
3226
- focus: function(){
3227
- if(!popover.stopOpen && (options.buttonOnly || options.openOnFocus || (mouseFocus && options.openOnMouseFocus))){
3228
- popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
3229
- show();
3230
- } else {
3331
+ opener.on({click: open});
3332
+
3333
+ if(options.inlinePicker){
3334
+ popover.openedByFocus = true;
3335
+ } else {
3336
+ opener
3337
+ .on({
3338
+ mousedown: function(){
3339
+ stopPropagation.apply(this, arguments);
3340
+ popover.preventBlur();
3341
+ },
3342
+ focus: function(){
3231
3343
  popover.preventBlur();
3232
3344
  }
3233
- },
3234
- mousedown: function(){
3235
- mouseFocus = true;
3236
- setTimeout(resetMouseFocus, 9);
3237
- if(options.buttonOnly && popover.isVisible && popover.activeElement){
3238
- popover.openedByFocus = false;
3239
- setTimeout(function(){
3345
+ })
3346
+ ;
3347
+
3348
+ (function(){
3349
+ var mouseFocus = false;
3350
+ var resetMouseFocus = function(){
3351
+ mouseFocus = false;
3352
+ };
3353
+ data.inputElements.on({
3354
+ keydown: function(e){
3355
+ if(e.keyCode == 40 && e.altKey){
3356
+ open();
3357
+ }
3358
+ },
3359
+ focus: function(){
3360
+ if(!popover.stopOpen && (options.buttonOnly || options.openOnFocus || (mouseFocus && options.openOnMouseFocus))){
3361
+ popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
3362
+ show();
3363
+ } else {
3364
+ popover.preventBlur();
3365
+ }
3366
+ },
3367
+ mousedown: function(){
3368
+ mouseFocus = true;
3369
+ setTimeout(resetMouseFocus, 9);
3370
+ if(options.buttonOnly && popover.isVisible && popover.activeElement){
3240
3371
  popover.openedByFocus = false;
3241
- popover.activeElement.focus();
3242
- }, 4);
3243
- }
3244
- if(data.element.is(':focus')){
3245
- popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
3246
- show();
3372
+ setTimeout(function(){
3373
+ popover.openedByFocus = false;
3374
+ popover.activeElement.focus();
3375
+ }, 4);
3376
+ }
3377
+ if(data.element.is(':focus')){
3378
+ popover.openedByFocus = options.buttonOnly ? false : !options.noInput;
3379
+ show();
3380
+ }
3381
+ popover.preventBlur();
3247
3382
  }
3248
- popover.preventBlur();
3249
- }
3250
- });
3251
- })();
3383
+ });
3384
+ })();
3385
+ }
3386
+
3252
3387
  data.popover = popover;
3253
3388
  data.opener = opener;
3254
3389
  $(data.orig).on('remove', function(e){
@@ -3259,12 +3394,16 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3259
3394
  }, 4);
3260
3395
  }
3261
3396
  });
3262
-
3397
+ if(options.inlinePicker){
3398
+ show();
3399
+ }
3263
3400
  loadPicker(data.type, 'WINDOWLOAD');
3264
3401
  };
3265
3402
 
3266
3403
  picker.month = picker._common;
3267
3404
  picker.date = picker._common;
3405
+ picker.time = picker._common;
3406
+ picker['datetime-local'] = picker._common;
3268
3407
  // picker.week = picker._common;
3269
3408
  picker.color = function(data){
3270
3409
  var ret = picker._common.apply(this, arguments);
@@ -3448,6 +3587,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3448
3587
  opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
3449
3588
  }
3450
3589
  }
3590
+ if(opts.monthSelect){
3591
+ opts.onlyMonthDigits = true;
3592
+ }
3451
3593
  if(opts.onlyMonthDigits){
3452
3594
  opts.formatMonthNames = 'monthDigits';
3453
3595
  }
@@ -3553,11 +3695,14 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
3553
3695
  });
3554
3696
  }
3555
3697
 
3556
- var isStupid = navigator.userAgent.indexOf('MSIE 10.0') != -1 && navigator.userAgent.indexOf('Touch') == -1;
3557
- ['number', 'time', 'month', 'date', 'color'].forEach(function(name){
3698
+ var isStupid = modernizrInputTypes.number && navigator.userAgent.indexOf('Touch') == -1 && (/MSIE 1[0|1]\.\d/.test(navigator.userAgent) || /Trident\/7\.0/.test(navigator.userAgent));
3699
+ ['number', 'time', 'month', 'date', 'color', 'datetime-local'].forEach(function(name){
3558
3700
  if(!modernizrInputTypes[name] || options.replaceUI || (name == 'number' && isStupid)){
3559
3701
  extendType(name, {
3560
3702
  _create: function(opts, set){
3703
+ if(opts.monthSelect){
3704
+ opts.splitInput = true;
3705
+ }
3561
3706
  if(opts.splitInput && !splitInputs[name]){
3562
3707
  webshims.warn('splitInput not supported for '+ name);
3563
3708
  opts.splitInput = false;