webshims-rails 1.10.6 → 1.10.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/webshims-rails/version.rb +2 -2
- data/vendor/assets/javascripts/webshims/polyfiller.js +14 -7
- data/vendor/assets/javascripts/webshims/shims/color-picker.js +1 -0
- data/vendor/assets/javascripts/webshims/shims/combos/1.js +153 -155
- data/vendor/assets/javascripts/webshims/shims/combos/10.js +168 -136
- data/vendor/assets/javascripts/webshims/shims/combos/11.js +116 -44
- data/vendor/assets/javascripts/webshims/shims/combos/12.js +100 -95
- data/vendor/assets/javascripts/webshims/shims/combos/13.js +100 -95
- data/vendor/assets/javascripts/webshims/shims/combos/14.js +51 -91
- data/vendor/assets/javascripts/webshims/shims/combos/15.js +129 -232
- data/vendor/assets/javascripts/webshims/shims/combos/16.js +228 -326
- data/vendor/assets/javascripts/webshims/shims/combos/17.js +116 -44
- data/vendor/assets/javascripts/webshims/shims/combos/18.js +116 -44
- data/vendor/assets/javascripts/webshims/shims/combos/19.js +210 -214
- data/vendor/assets/javascripts/webshims/shims/combos/2.js +204 -246
- data/vendor/assets/javascripts/webshims/shims/combos/20.js +210 -214
- data/vendor/assets/javascripts/webshims/shims/combos/21.js +59 -28
- data/vendor/assets/javascripts/webshims/shims/combos/23.js +100 -95
- data/vendor/assets/javascripts/webshims/shims/combos/24.js +2 -2
- data/vendor/assets/javascripts/webshims/shims/combos/25.js +210 -214
- data/vendor/assets/javascripts/webshims/shims/combos/26.js +51 -91
- data/vendor/assets/javascripts/webshims/shims/combos/28.js +110 -119
- data/vendor/assets/javascripts/webshims/shims/combos/29.js +6 -0
- data/vendor/assets/javascripts/webshims/shims/combos/3.js +126 -156
- data/vendor/assets/javascripts/webshims/shims/combos/30.js +126 -155
- data/vendor/assets/javascripts/webshims/shims/combos/31.js +104 -151
- data/vendor/assets/javascripts/webshims/shims/combos/4.js +73 -96
- data/vendor/assets/javascripts/webshims/shims/combos/5.js +116 -44
- data/vendor/assets/javascripts/webshims/shims/combos/6.js +116 -44
- data/vendor/assets/javascripts/webshims/shims/combos/7.js +226 -250
- data/vendor/assets/javascripts/webshims/shims/combos/8.js +226 -250
- data/vendor/assets/javascripts/webshims/shims/combos/9.js +168 -136
- data/vendor/assets/javascripts/webshims/shims/dom-extend.js +51 -91
- data/vendor/assets/javascripts/webshims/shims/form-core.js +53 -60
- data/vendor/assets/javascripts/webshims/shims/form-message.js +22 -5
- data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +87 -30
- data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +2 -76
- data/vendor/assets/javascripts/webshims/shims/form-validation.js +2 -2
- data/vendor/assets/javascripts/webshims/shims/forms-picker.js +1 -1
- data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-fr.js +18 -8
- data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +100 -95
- data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +59 -28
- data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +9 -2
- data/vendor/assets/javascripts/webshims/shims/range-ui.js +29 -14
- data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +21 -7
- data/vendor/assets/javascripts/webshims/shims/styles/shim.css +30 -15
- data/vendor/assets/javascripts/webshims/shims/track-ui.js +6 -0
- metadata +2 -2
@@ -1131,16 +1131,20 @@ webshims.register('form-number-date-api', function($, webshims, window, document
|
|
1131
1131
|
this.thumb.on({
|
1132
1132
|
mousedown: add
|
1133
1133
|
});
|
1134
|
-
|
1135
|
-
webshims.ready('
|
1136
|
-
|
1137
|
-
|
1134
|
+
if (window.webshims) {
|
1135
|
+
webshims.ready('WINDOWLOAD', function(){
|
1136
|
+
webshims.ready('dom-support', function(){
|
1137
|
+
if ($.fn.onWSOff) {
|
1138
|
+
that.element.onWSOff('updateshadowdom', function(){
|
1139
|
+
that.updateMetrics();
|
1140
|
+
});
|
1141
|
+
}
|
1138
1142
|
});
|
1143
|
+
if (!$.fn.onWSOff && webshims._polyfill) {
|
1144
|
+
webshims._polyfill(['dom-support']);
|
1145
|
+
}
|
1139
1146
|
});
|
1140
|
-
|
1141
|
-
webshims._polyfill(['dom-support']);
|
1142
|
-
}
|
1143
|
-
});
|
1147
|
+
}
|
1144
1148
|
},
|
1145
1149
|
posCenter: function(elem, outerWidth){
|
1146
1150
|
var temp;
|
@@ -1182,6 +1186,12 @@ webshims.register('form-number-date-api', function($, webshims, window, document
|
|
1182
1186
|
}
|
1183
1187
|
};
|
1184
1188
|
|
1189
|
+
var oCreate = function (o) {
|
1190
|
+
function F() {}
|
1191
|
+
F.prototype = o;
|
1192
|
+
return new F();
|
1193
|
+
};
|
1194
|
+
|
1185
1195
|
$.fn.rangeUI = function(opts){
|
1186
1196
|
opts = $.extend({
|
1187
1197
|
readonly: false,
|
@@ -1200,14 +1210,19 @@ webshims.register('form-number-date-api', function($, webshims, window, document
|
|
1200
1210
|
calcTrail: true
|
1201
1211
|
}, opts);
|
1202
1212
|
return this.each(function(){
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
}
|
1207
|
-
}, opts);
|
1213
|
+
var obj = $.extend(oCreate(rangeProto), {element: $(this)});
|
1214
|
+
obj.options = opts;
|
1215
|
+
obj._create.call(obj);
|
1208
1216
|
});
|
1209
1217
|
};
|
1210
|
-
webshims.isReady
|
1218
|
+
if(window.webshims && webshims.isReady){
|
1219
|
+
webshims.ready('es5', function(){
|
1220
|
+
webshims.isReady('range-ui', true);
|
1221
|
+
});
|
1222
|
+
if(webshims._polyfill){
|
1223
|
+
webshims._polyfill(['es5']);
|
1224
|
+
}
|
1225
|
+
}
|
1211
1226
|
})(jQuery);
|
1212
1227
|
webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
|
1213
1228
|
"use strict";
|
@@ -1254,10 +1269,14 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1254
1269
|
}
|
1255
1270
|
},
|
1256
1271
|
month: {
|
1257
|
-
_create: function(){
|
1272
|
+
_create: function(opts){
|
1273
|
+
|
1258
1274
|
var obj = {
|
1259
1275
|
splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0], $('<input type="text" class="mm ws-spin" />')[0]]
|
1260
1276
|
};
|
1277
|
+
if(opts.onlyMonthDigits){
|
1278
|
+
$(obj.splits[1]).attr({inputmode: 'numeric', size: 2, maxlength: 2});
|
1279
|
+
}
|
1261
1280
|
obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
|
1262
1281
|
return obj;
|
1263
1282
|
},
|
@@ -1277,6 +1296,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1277
1296
|
}
|
1278
1297
|
};
|
1279
1298
|
|
1299
|
+
var nowDate = new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 );
|
1280
1300
|
var steps = {
|
1281
1301
|
number: {
|
1282
1302
|
step: 1
|
@@ -1286,11 +1306,11 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1286
1306
|
},
|
1287
1307
|
month: {
|
1288
1308
|
step: 1,
|
1289
|
-
start: new Date()
|
1309
|
+
start: new Date(nowDate)
|
1290
1310
|
},
|
1291
1311
|
date: {
|
1292
1312
|
step: 1,
|
1293
|
-
start: new Date()
|
1313
|
+
start: new Date(nowDate)
|
1294
1314
|
}
|
1295
1315
|
};
|
1296
1316
|
var labelWidth = (function(){
|
@@ -1386,9 +1406,19 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1386
1406
|
"showMonthAfterYear": false,
|
1387
1407
|
"yearSuffix": ""
|
1388
1408
|
}
|
1389
|
-
}, formcfg
|
1409
|
+
}, formcfg.en || {});
|
1410
|
+
|
1390
1411
|
if(!formcfg['en-US']){
|
1391
|
-
formcfg['en-US'] = formcfg['en'];
|
1412
|
+
formcfg['en-US'] = $.extend(true, {}, formcfg['en']);
|
1413
|
+
}
|
1414
|
+
if(!formcfg['en-GB']){
|
1415
|
+
formcfg['en-GB'] = $.extend(true, {}, formcfg.en, {
|
1416
|
+
date: {firstDay: 1},
|
1417
|
+
patterns: {d: "dd/mm/yy"}
|
1418
|
+
});
|
1419
|
+
}
|
1420
|
+
if(!formcfg['en-AU']){
|
1421
|
+
formcfg['en-AU'] = $.extend(true, {}, formcfg['en-GB']);
|
1392
1422
|
}
|
1393
1423
|
if(!formcfg['']){
|
1394
1424
|
formcfg[''] = formcfg['en-US'];
|
@@ -1416,22 +1446,37 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1416
1446
|
langCfg.colorSigns = '#abcdefABCDEF';
|
1417
1447
|
}
|
1418
1448
|
};
|
1449
|
+
var triggerLocaleChange = function(){
|
1450
|
+
processLangCFG(curCfg);
|
1451
|
+
$(document).triggerHandler('wslocalechange');
|
1452
|
+
};
|
1419
1453
|
|
1420
|
-
|
1454
|
+
triggerLocaleChange();
|
1421
1455
|
|
1422
|
-
|
1423
|
-
register: 'form-core',
|
1456
|
+
webshims.activeLang({
|
1457
|
+
register: 'form-core',
|
1424
1458
|
callback: function(){
|
1425
1459
|
$.each(arguments, function(i, val){
|
1426
1460
|
if(formcfg[val]){
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1461
|
+
if(formcfg[val] != curCfg){
|
1462
|
+
curCfg = formcfg[val];
|
1463
|
+
triggerLocaleChange();
|
1464
|
+
}
|
1430
1465
|
return false;
|
1431
1466
|
}
|
1432
1467
|
});
|
1433
1468
|
}
|
1434
1469
|
});
|
1470
|
+
webshims.activeLang({
|
1471
|
+
langObj: formcfg,
|
1472
|
+
module: 'form-core',
|
1473
|
+
callback: function(val){
|
1474
|
+
if(curCfg != val){
|
1475
|
+
curCfg = val;
|
1476
|
+
triggerLocaleChange();
|
1477
|
+
}
|
1478
|
+
}
|
1479
|
+
});
|
1435
1480
|
})();
|
1436
1481
|
|
1437
1482
|
|
@@ -1470,6 +1515,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1470
1515
|
} else if(p[1]){
|
1471
1516
|
val = curCfg.date.showMonthAfterYear ? p.join(' ') : p[1]+' '+p[0];
|
1472
1517
|
}
|
1518
|
+
} else if(options && options.splitInput){
|
1519
|
+
val = [p[0] || '', p[1] || ''];
|
1473
1520
|
}
|
1474
1521
|
return val;
|
1475
1522
|
},
|
@@ -1508,16 +1555,16 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1508
1555
|
time: function(val){
|
1509
1556
|
return val;
|
1510
1557
|
},
|
1511
|
-
month: function(val, opts){
|
1558
|
+
month: function(val, opts, noCorrect){
|
1512
1559
|
|
1513
1560
|
var p = (!opts.splitInput) ? val.trim().split(/[\.\s-\/\\]+/) : val;
|
1514
1561
|
|
1515
1562
|
if(p.length == 2 && p[0] && p[1]){
|
1516
|
-
p[0] = curCfg.date.monthkeys[p[0]] || p[0];
|
1517
|
-
p[1] = curCfg.date.monthkeys[p[1]] || p[1];
|
1518
|
-
if(p[1].length == 2){
|
1563
|
+
p[0] = !noCorrect && curCfg.date.monthkeys[p[0]] || p[0];
|
1564
|
+
p[1] = !noCorrect && curCfg.date.monthkeys[p[1]] || p[1];
|
1565
|
+
if(p[1].length == 2 && p[0].length > 3){
|
1519
1566
|
val = p[0]+'-'+p[1];
|
1520
|
-
} else if(p[0].length == 2){
|
1567
|
+
} else if(p[0].length == 2 && p[1].length > 3){
|
1521
1568
|
val = p[1]+'-'+p[0];
|
1522
1569
|
} else {
|
1523
1570
|
val = '';
|
@@ -1527,7 +1574,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1527
1574
|
}
|
1528
1575
|
return val;
|
1529
1576
|
},
|
1530
|
-
date: function(val, opts){
|
1577
|
+
date: function(val, opts, noCorrect){
|
1531
1578
|
createFormat('d');
|
1532
1579
|
var i;
|
1533
1580
|
var obj;
|
@@ -1538,7 +1585,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1538
1585
|
val = val.split(curCfg.dFormat);
|
1539
1586
|
}
|
1540
1587
|
|
1541
|
-
return (val.length == 3 && val[0] && val[1] && val[2]) ?
|
1588
|
+
return (val.length == 3 && val[0] && val[1] && val[2] && (!noCorrect || (val[obj.yy].length > 3 && val[obj.mm].length == 2 && val[obj.dd].length == 2))) ?
|
1542
1589
|
([addZero(val[obj.yy]), addZero(val[obj.mm]), addZero(val[obj.dd])]).join('-') :
|
1543
1590
|
''
|
1544
1591
|
;
|
@@ -1596,7 +1643,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1596
1643
|
return function(type){
|
1597
1644
|
var input;
|
1598
1645
|
if(!types[type]){
|
1599
|
-
input = $('<input type="'+type+'" />');
|
1646
|
+
input = $('<input type="'+type+'" step="any" />');
|
1600
1647
|
types[type] = {
|
1601
1648
|
asNumber: function(val){
|
1602
1649
|
var type = (typeof val == 'object') ? 'valueAsDate' : 'value';
|
@@ -1825,6 +1872,22 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1825
1872
|
e.preventDefault();
|
1826
1873
|
}
|
1827
1874
|
},
|
1875
|
+
input: (this.type == 'color' && this.isValid) ?
|
1876
|
+
$.noop :
|
1877
|
+
(function(){
|
1878
|
+
var timer;
|
1879
|
+
var check = function(){
|
1880
|
+
var val = that.parseValue(true);
|
1881
|
+
if(val && that.isValid(val)){
|
1882
|
+
that.setInput(val);
|
1883
|
+
}
|
1884
|
+
|
1885
|
+
};
|
1886
|
+
return function(){
|
1887
|
+
clearTimeout(timer);
|
1888
|
+
timer = setTimeout(check, 200);
|
1889
|
+
};
|
1890
|
+
})(),
|
1828
1891
|
'input keydown keypress': (function(){
|
1829
1892
|
var timer;
|
1830
1893
|
var isStopped = false;
|
@@ -1842,8 +1905,12 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1842
1905
|
timer = setTimeout(releaseTab, 300);
|
1843
1906
|
};
|
1844
1907
|
var select = function(){
|
1845
|
-
this
|
1846
|
-
|
1908
|
+
var elem = this;
|
1909
|
+
setTimeout(function(){
|
1910
|
+
elem.focus();
|
1911
|
+
elem.select();
|
1912
|
+
}, 4);
|
1913
|
+
|
1847
1914
|
stopTab();
|
1848
1915
|
};
|
1849
1916
|
|
@@ -1964,8 +2031,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1964
2031
|
var localeChange ;
|
1965
2032
|
if(!o.splitInput){
|
1966
2033
|
localeChange = function(){
|
2034
|
+
|
1967
2035
|
if(o.value){
|
1968
|
-
that.value(o.value);
|
2036
|
+
that.value(o.value, true);
|
1969
2037
|
}
|
1970
2038
|
|
1971
2039
|
if(placeholderFormat[that.type] && o.placeholder){
|
@@ -1984,8 +2052,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1984
2052
|
|
1985
2053
|
initChangeEvents();
|
1986
2054
|
},
|
1987
|
-
value: function(val){
|
1988
|
-
if(!this._init || val !== this.options.value){
|
2055
|
+
value: function(val, force){
|
2056
|
+
if(!this._init || force || val !== this.options.value){
|
1989
2057
|
this.element.val(this.formatValue(val));
|
1990
2058
|
this.options.value = val;
|
1991
2059
|
this._propertyChange('value');
|
@@ -1997,14 +2065,14 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1997
2065
|
this.inputElements.attr({'aria-required': ''+boolVal});
|
1998
2066
|
this.mirrorValidity();
|
1999
2067
|
},
|
2000
|
-
parseValue: function(){
|
2068
|
+
parseValue: function(noCorrect){
|
2001
2069
|
var value = this.inputElements.map(function(){
|
2002
2070
|
return $.prop(this, 'value');
|
2003
2071
|
}).get();
|
2004
2072
|
if(!this.options.splitInput){
|
2005
2073
|
value = value[0];
|
2006
2074
|
}
|
2007
|
-
return parseVal[this.type](value, this.options);
|
2075
|
+
return parseVal[this.type](value, this.options, noCorrect);
|
2008
2076
|
},
|
2009
2077
|
formatValue: function(val, noSplit){
|
2010
2078
|
return formatVal[this.type](val, noSplit === false ? false : this.options);
|
@@ -2102,6 +2170,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
2102
2170
|
this.elemHelper = $('<input type="'+ o.type+'" />');
|
2103
2171
|
this.asNumber = helper.asNumber;
|
2104
2172
|
this.asValue = helper.asValue;
|
2173
|
+
this.isValid = helper.isValid;
|
2174
|
+
|
2105
2175
|
|
2106
2176
|
wsWidgetProto._create.apply(this, arguments);
|
2107
2177
|
this._init = false;
|
@@ -2127,7 +2197,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
2127
2197
|
createOpts: ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'value', 'required'],
|
2128
2198
|
_addSplitInputs: function(){
|
2129
2199
|
if(!this.inputElements){
|
2130
|
-
var create = splitInputs[this.type]._create();
|
2200
|
+
var create = splitInputs[this.type]._create(this.options);
|
2131
2201
|
this.splits = create.splits;
|
2132
2202
|
this.inputElements = $(create.elements).prependTo(this.element).filter('input');
|
2133
2203
|
}
|
@@ -2164,9 +2234,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
2164
2234
|
}, 9);
|
2165
2235
|
}
|
2166
2236
|
},
|
2167
|
-
value: function(val){
|
2237
|
+
value: function(val, force){
|
2168
2238
|
|
2169
|
-
if(!this._init || this.options.value !== val){
|
2239
|
+
if(!this._init || force || this.options.value !== val){
|
2170
2240
|
this.valueAsNumber = this.asNumber(val);
|
2171
2241
|
this.options.value = val;
|
2172
2242
|
|
@@ -2678,7 +2748,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
2678
2748
|
opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
|
2679
2749
|
}
|
2680
2750
|
}
|
2681
|
-
|
2751
|
+
if(opts.onlyMonthDigits){
|
2752
|
+
opts.formatMonthNames = 'monthDigits';
|
2753
|
+
}
|
2682
2754
|
data.shim = inputTypes[type]._create(opts);
|
2683
2755
|
|
2684
2756
|
webshims.addShadowDom(this, data.shim.element, {
|
@@ -1131,16 +1131,20 @@ webshims.register('form-number-date-api', function($, webshims, window, document
|
|
1131
1131
|
this.thumb.on({
|
1132
1132
|
mousedown: add
|
1133
1133
|
});
|
1134
|
-
|
1135
|
-
webshims.ready('
|
1136
|
-
|
1137
|
-
|
1134
|
+
if (window.webshims) {
|
1135
|
+
webshims.ready('WINDOWLOAD', function(){
|
1136
|
+
webshims.ready('dom-support', function(){
|
1137
|
+
if ($.fn.onWSOff) {
|
1138
|
+
that.element.onWSOff('updateshadowdom', function(){
|
1139
|
+
that.updateMetrics();
|
1140
|
+
});
|
1141
|
+
}
|
1138
1142
|
});
|
1143
|
+
if (!$.fn.onWSOff && webshims._polyfill) {
|
1144
|
+
webshims._polyfill(['dom-support']);
|
1145
|
+
}
|
1139
1146
|
});
|
1140
|
-
|
1141
|
-
webshims._polyfill(['dom-support']);
|
1142
|
-
}
|
1143
|
-
});
|
1147
|
+
}
|
1144
1148
|
},
|
1145
1149
|
posCenter: function(elem, outerWidth){
|
1146
1150
|
var temp;
|
@@ -1182,6 +1186,12 @@ webshims.register('form-number-date-api', function($, webshims, window, document
|
|
1182
1186
|
}
|
1183
1187
|
};
|
1184
1188
|
|
1189
|
+
var oCreate = function (o) {
|
1190
|
+
function F() {}
|
1191
|
+
F.prototype = o;
|
1192
|
+
return new F();
|
1193
|
+
};
|
1194
|
+
|
1185
1195
|
$.fn.rangeUI = function(opts){
|
1186
1196
|
opts = $.extend({
|
1187
1197
|
readonly: false,
|
@@ -1200,14 +1210,19 @@ webshims.register('form-number-date-api', function($, webshims, window, document
|
|
1200
1210
|
calcTrail: true
|
1201
1211
|
}, opts);
|
1202
1212
|
return this.each(function(){
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
}
|
1207
|
-
}, opts);
|
1213
|
+
var obj = $.extend(oCreate(rangeProto), {element: $(this)});
|
1214
|
+
obj.options = opts;
|
1215
|
+
obj._create.call(obj);
|
1208
1216
|
});
|
1209
1217
|
};
|
1210
|
-
webshims.isReady
|
1218
|
+
if(window.webshims && webshims.isReady){
|
1219
|
+
webshims.ready('es5', function(){
|
1220
|
+
webshims.isReady('range-ui', true);
|
1221
|
+
});
|
1222
|
+
if(webshims._polyfill){
|
1223
|
+
webshims._polyfill(['es5']);
|
1224
|
+
}
|
1225
|
+
}
|
1211
1226
|
})(jQuery);
|
1212
1227
|
webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
|
1213
1228
|
"use strict";
|
@@ -1254,10 +1269,14 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1254
1269
|
}
|
1255
1270
|
},
|
1256
1271
|
month: {
|
1257
|
-
_create: function(){
|
1272
|
+
_create: function(opts){
|
1273
|
+
|
1258
1274
|
var obj = {
|
1259
1275
|
splits: [$('<input type="text" class="yy" inputmode="numeric" size="4" />')[0], $('<input type="text" class="mm ws-spin" />')[0]]
|
1260
1276
|
};
|
1277
|
+
if(opts.onlyMonthDigits){
|
1278
|
+
$(obj.splits[1]).attr({inputmode: 'numeric', size: 2, maxlength: 2});
|
1279
|
+
}
|
1261
1280
|
obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
|
1262
1281
|
return obj;
|
1263
1282
|
},
|
@@ -1277,6 +1296,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1277
1296
|
}
|
1278
1297
|
};
|
1279
1298
|
|
1299
|
+
var nowDate = new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 );
|
1280
1300
|
var steps = {
|
1281
1301
|
number: {
|
1282
1302
|
step: 1
|
@@ -1286,11 +1306,11 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1286
1306
|
},
|
1287
1307
|
month: {
|
1288
1308
|
step: 1,
|
1289
|
-
start: new Date()
|
1309
|
+
start: new Date(nowDate)
|
1290
1310
|
},
|
1291
1311
|
date: {
|
1292
1312
|
step: 1,
|
1293
|
-
start: new Date()
|
1313
|
+
start: new Date(nowDate)
|
1294
1314
|
}
|
1295
1315
|
};
|
1296
1316
|
var labelWidth = (function(){
|
@@ -1386,9 +1406,19 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1386
1406
|
"showMonthAfterYear": false,
|
1387
1407
|
"yearSuffix": ""
|
1388
1408
|
}
|
1389
|
-
}, formcfg
|
1409
|
+
}, formcfg.en || {});
|
1410
|
+
|
1390
1411
|
if(!formcfg['en-US']){
|
1391
|
-
formcfg['en-US'] = formcfg['en'];
|
1412
|
+
formcfg['en-US'] = $.extend(true, {}, formcfg['en']);
|
1413
|
+
}
|
1414
|
+
if(!formcfg['en-GB']){
|
1415
|
+
formcfg['en-GB'] = $.extend(true, {}, formcfg.en, {
|
1416
|
+
date: {firstDay: 1},
|
1417
|
+
patterns: {d: "dd/mm/yy"}
|
1418
|
+
});
|
1419
|
+
}
|
1420
|
+
if(!formcfg['en-AU']){
|
1421
|
+
formcfg['en-AU'] = $.extend(true, {}, formcfg['en-GB']);
|
1392
1422
|
}
|
1393
1423
|
if(!formcfg['']){
|
1394
1424
|
formcfg[''] = formcfg['en-US'];
|
@@ -1416,22 +1446,37 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1416
1446
|
langCfg.colorSigns = '#abcdefABCDEF';
|
1417
1447
|
}
|
1418
1448
|
};
|
1449
|
+
var triggerLocaleChange = function(){
|
1450
|
+
processLangCFG(curCfg);
|
1451
|
+
$(document).triggerHandler('wslocalechange');
|
1452
|
+
};
|
1419
1453
|
|
1420
|
-
|
1454
|
+
triggerLocaleChange();
|
1421
1455
|
|
1422
|
-
|
1423
|
-
register: 'form-core',
|
1456
|
+
webshims.activeLang({
|
1457
|
+
register: 'form-core',
|
1424
1458
|
callback: function(){
|
1425
1459
|
$.each(arguments, function(i, val){
|
1426
1460
|
if(formcfg[val]){
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1461
|
+
if(formcfg[val] != curCfg){
|
1462
|
+
curCfg = formcfg[val];
|
1463
|
+
triggerLocaleChange();
|
1464
|
+
}
|
1430
1465
|
return false;
|
1431
1466
|
}
|
1432
1467
|
});
|
1433
1468
|
}
|
1434
1469
|
});
|
1470
|
+
webshims.activeLang({
|
1471
|
+
langObj: formcfg,
|
1472
|
+
module: 'form-core',
|
1473
|
+
callback: function(val){
|
1474
|
+
if(curCfg != val){
|
1475
|
+
curCfg = val;
|
1476
|
+
triggerLocaleChange();
|
1477
|
+
}
|
1478
|
+
}
|
1479
|
+
});
|
1435
1480
|
})();
|
1436
1481
|
|
1437
1482
|
|
@@ -1470,6 +1515,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1470
1515
|
} else if(p[1]){
|
1471
1516
|
val = curCfg.date.showMonthAfterYear ? p.join(' ') : p[1]+' '+p[0];
|
1472
1517
|
}
|
1518
|
+
} else if(options && options.splitInput){
|
1519
|
+
val = [p[0] || '', p[1] || ''];
|
1473
1520
|
}
|
1474
1521
|
return val;
|
1475
1522
|
},
|
@@ -1508,16 +1555,16 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1508
1555
|
time: function(val){
|
1509
1556
|
return val;
|
1510
1557
|
},
|
1511
|
-
month: function(val, opts){
|
1558
|
+
month: function(val, opts, noCorrect){
|
1512
1559
|
|
1513
1560
|
var p = (!opts.splitInput) ? val.trim().split(/[\.\s-\/\\]+/) : val;
|
1514
1561
|
|
1515
1562
|
if(p.length == 2 && p[0] && p[1]){
|
1516
|
-
p[0] = curCfg.date.monthkeys[p[0]] || p[0];
|
1517
|
-
p[1] = curCfg.date.monthkeys[p[1]] || p[1];
|
1518
|
-
if(p[1].length == 2){
|
1563
|
+
p[0] = !noCorrect && curCfg.date.monthkeys[p[0]] || p[0];
|
1564
|
+
p[1] = !noCorrect && curCfg.date.monthkeys[p[1]] || p[1];
|
1565
|
+
if(p[1].length == 2 && p[0].length > 3){
|
1519
1566
|
val = p[0]+'-'+p[1];
|
1520
|
-
} else if(p[0].length == 2){
|
1567
|
+
} else if(p[0].length == 2 && p[1].length > 3){
|
1521
1568
|
val = p[1]+'-'+p[0];
|
1522
1569
|
} else {
|
1523
1570
|
val = '';
|
@@ -1527,7 +1574,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1527
1574
|
}
|
1528
1575
|
return val;
|
1529
1576
|
},
|
1530
|
-
date: function(val, opts){
|
1577
|
+
date: function(val, opts, noCorrect){
|
1531
1578
|
createFormat('d');
|
1532
1579
|
var i;
|
1533
1580
|
var obj;
|
@@ -1538,7 +1585,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1538
1585
|
val = val.split(curCfg.dFormat);
|
1539
1586
|
}
|
1540
1587
|
|
1541
|
-
return (val.length == 3 && val[0] && val[1] && val[2]) ?
|
1588
|
+
return (val.length == 3 && val[0] && val[1] && val[2] && (!noCorrect || (val[obj.yy].length > 3 && val[obj.mm].length == 2 && val[obj.dd].length == 2))) ?
|
1542
1589
|
([addZero(val[obj.yy]), addZero(val[obj.mm]), addZero(val[obj.dd])]).join('-') :
|
1543
1590
|
''
|
1544
1591
|
;
|
@@ -1596,7 +1643,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1596
1643
|
return function(type){
|
1597
1644
|
var input;
|
1598
1645
|
if(!types[type]){
|
1599
|
-
input = $('<input type="'+type+'" />');
|
1646
|
+
input = $('<input type="'+type+'" step="any" />');
|
1600
1647
|
types[type] = {
|
1601
1648
|
asNumber: function(val){
|
1602
1649
|
var type = (typeof val == 'object') ? 'valueAsDate' : 'value';
|
@@ -1825,6 +1872,22 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1825
1872
|
e.preventDefault();
|
1826
1873
|
}
|
1827
1874
|
},
|
1875
|
+
input: (this.type == 'color' && this.isValid) ?
|
1876
|
+
$.noop :
|
1877
|
+
(function(){
|
1878
|
+
var timer;
|
1879
|
+
var check = function(){
|
1880
|
+
var val = that.parseValue(true);
|
1881
|
+
if(val && that.isValid(val)){
|
1882
|
+
that.setInput(val);
|
1883
|
+
}
|
1884
|
+
|
1885
|
+
};
|
1886
|
+
return function(){
|
1887
|
+
clearTimeout(timer);
|
1888
|
+
timer = setTimeout(check, 200);
|
1889
|
+
};
|
1890
|
+
})(),
|
1828
1891
|
'input keydown keypress': (function(){
|
1829
1892
|
var timer;
|
1830
1893
|
var isStopped = false;
|
@@ -1842,8 +1905,12 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1842
1905
|
timer = setTimeout(releaseTab, 300);
|
1843
1906
|
};
|
1844
1907
|
var select = function(){
|
1845
|
-
this
|
1846
|
-
|
1908
|
+
var elem = this;
|
1909
|
+
setTimeout(function(){
|
1910
|
+
elem.focus();
|
1911
|
+
elem.select();
|
1912
|
+
}, 4);
|
1913
|
+
|
1847
1914
|
stopTab();
|
1848
1915
|
};
|
1849
1916
|
|
@@ -1964,8 +2031,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1964
2031
|
var localeChange ;
|
1965
2032
|
if(!o.splitInput){
|
1966
2033
|
localeChange = function(){
|
2034
|
+
|
1967
2035
|
if(o.value){
|
1968
|
-
that.value(o.value);
|
2036
|
+
that.value(o.value, true);
|
1969
2037
|
}
|
1970
2038
|
|
1971
2039
|
if(placeholderFormat[that.type] && o.placeholder){
|
@@ -1984,8 +2052,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1984
2052
|
|
1985
2053
|
initChangeEvents();
|
1986
2054
|
},
|
1987
|
-
value: function(val){
|
1988
|
-
if(!this._init || val !== this.options.value){
|
2055
|
+
value: function(val, force){
|
2056
|
+
if(!this._init || force || val !== this.options.value){
|
1989
2057
|
this.element.val(this.formatValue(val));
|
1990
2058
|
this.options.value = val;
|
1991
2059
|
this._propertyChange('value');
|
@@ -1997,14 +2065,14 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
1997
2065
|
this.inputElements.attr({'aria-required': ''+boolVal});
|
1998
2066
|
this.mirrorValidity();
|
1999
2067
|
},
|
2000
|
-
parseValue: function(){
|
2068
|
+
parseValue: function(noCorrect){
|
2001
2069
|
var value = this.inputElements.map(function(){
|
2002
2070
|
return $.prop(this, 'value');
|
2003
2071
|
}).get();
|
2004
2072
|
if(!this.options.splitInput){
|
2005
2073
|
value = value[0];
|
2006
2074
|
}
|
2007
|
-
return parseVal[this.type](value, this.options);
|
2075
|
+
return parseVal[this.type](value, this.options, noCorrect);
|
2008
2076
|
},
|
2009
2077
|
formatValue: function(val, noSplit){
|
2010
2078
|
return formatVal[this.type](val, noSplit === false ? false : this.options);
|
@@ -2102,6 +2170,8 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
2102
2170
|
this.elemHelper = $('<input type="'+ o.type+'" />');
|
2103
2171
|
this.asNumber = helper.asNumber;
|
2104
2172
|
this.asValue = helper.asValue;
|
2173
|
+
this.isValid = helper.isValid;
|
2174
|
+
|
2105
2175
|
|
2106
2176
|
wsWidgetProto._create.apply(this, arguments);
|
2107
2177
|
this._init = false;
|
@@ -2127,7 +2197,7 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
2127
2197
|
createOpts: ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex', 'placeholder', 'value', 'required'],
|
2128
2198
|
_addSplitInputs: function(){
|
2129
2199
|
if(!this.inputElements){
|
2130
|
-
var create = splitInputs[this.type]._create();
|
2200
|
+
var create = splitInputs[this.type]._create(this.options);
|
2131
2201
|
this.splits = create.splits;
|
2132
2202
|
this.inputElements = $(create.elements).prependTo(this.element).filter('input');
|
2133
2203
|
}
|
@@ -2164,9 +2234,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
2164
2234
|
}, 9);
|
2165
2235
|
}
|
2166
2236
|
},
|
2167
|
-
value: function(val){
|
2237
|
+
value: function(val, force){
|
2168
2238
|
|
2169
|
-
if(!this._init || this.options.value !== val){
|
2239
|
+
if(!this._init || force || this.options.value !== val){
|
2170
2240
|
this.valueAsNumber = this.asNumber(val);
|
2171
2241
|
this.options.value = val;
|
2172
2242
|
|
@@ -2678,7 +2748,9 @@ webshims.register('form-number-date-ui', function($, webshims, window, document,
|
|
2678
2748
|
opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
|
2679
2749
|
}
|
2680
2750
|
}
|
2681
|
-
|
2751
|
+
if(opts.onlyMonthDigits){
|
2752
|
+
opts.formatMonthNames = 'monthDigits';
|
2753
|
+
}
|
2682
2754
|
data.shim = inputTypes[type]._create(opts);
|
2683
2755
|
|
2684
2756
|
webshims.addShadowDom(this, data.shim.element, {
|