vendor/assets/javascripts/webshims/shims/combos/11.js in webshims-rails-1.13.0 vs vendor/assets/javascripts/webshims/shims/combos/11.js in webshims-rails-1.14.1
- old
+ new
@@ -667,32 +667,34 @@
}
})
;
}
};
+ var numericType = Modernizr.inputtypes.tel && navigator.userAgent.indexOf('Mobile') != -1 && !('inputMode' in document.createElement('input') && !('inputmode' in document.createElement('input'))) ?
+ 'tel' : 'text';
var splitInputs = {
date: {
_create: function(opts){
var obj = {
splits: []
};
if(opts.yearSelect){
obj.splits.push($('<select class="yy"></select>')[0]);
} else {
- obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
+ obj.splits.push($('<input type="'+ numericType +'" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
}
if(opts.monthSelect){
obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
} else {
- obj.splits.push($('<input type="text" class="mm" inputmode="numeric" maxlength="2" size="2" />')[0]);
+ obj.splits.push($('<input type="'+ numericType +'" class="mm" inputmode="numeric" maxlength="2" size="2" />')[0]);
}
if(opts.daySelect){
obj.splits.push($(daySelect)[0]);
} else {
- obj.splits.push($('<input type="text" class="dd ws-spin" inputmode="numeric" maxlength="2" size="2" />')[0]);
+ obj.splits.push($('<input type="'+ numericType +'" class="dd ws-spin" inputmode="numeric" maxlength="2" size="2" />')[0]);
}
obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1], $('<span class="ws-input-seperator" />')[0], obj.splits[2]];
createYearSelect(obj, opts);
return obj;
@@ -723,19 +725,22 @@
};
if(opts.yearSelect){
obj.splits.push($('<select class="yy"></select>')[0]);
} else {
- obj.splits.push($('<input type="text" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
+ obj.splits.push($('<input type="'+ numericType +'" class="yy" size="4" inputmode="numeric" maxlength="4" />')[0]);
}
if(opts.monthSelect){
obj.splits.push($('<select class="mm">'+getMonthOptions(opts)+'</select>')[0]);
} else {
obj.splits.push($('<input type="text" class="mm ws-spin" />')[0]);
if(opts.onlyMonthDigits){
- $(obj.splits[1]).attr({inputmode: 'numeric', size: 2, maxlength: 2});
+ $().attr({inputmode: 'numeric', size: 2, maxlength: 2});
+ try {
+ obj.splits[1].setAttribute('type', numericType);
+ } catch(e){}
}
}
obj.elements = [obj.splits[0], $('<span class="ws-input-seperator" />')[0], obj.splits[1]];
createYearSelect(obj, opts);
@@ -754,11 +759,11 @@
}
seperator[action](mm);
}
}
};
-
+
var nowDate = new Date(new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 ));
var nowYear = nowDate.getFullYear();
nowDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours()).getTime();
var steps = {
number: {
@@ -1574,11 +1579,15 @@
if(!isNaN(this.minAsNumber) && start < this.minAsNumber){
start = this.minAsNumber;
} else if(!isNaN(this.maxAsNumber) && start > this.maxAsNumber){
start = this.maxAsNumber;
}
- this.elemHelper.prop('valueAsNumber', start);
+ try {
+ this.elemHelper.prop('valueAsNumber', start);
+ } catch(e){
+ webshims.warn('valueAsNumber set: '+e);
+ }
this.options.defValue = this.elemHelper.prop('value');
},
reorderInputs: function(){
if(splitInputs[this.type]){
var element = this.element.attr('dir', curCfg.date.isRTL ? 'rtl' : 'ltr');
@@ -1598,11 +1607,11 @@
this.mirrorValidity();
},
_beforeValue: function(val){
this.valueAsNumber = this.asNumber(val);
this.options.value = val;
-
+
if(isNaN(this.valueAsNumber) || (!isNaN(this.minAsNumber) && this.valueAsNumber < this.minAsNumber) || (!isNaN(this.maxAsNumber) && this.valueAsNumber > this.maxAsNumber)){
this._setStartInRange();
} else {
this.elemHelper.prop('value', val);
this.options.defValue = "";
@@ -1714,13 +1723,13 @@
if(addTouch){
touchEnd = function(e){
var ret, touch;
e = e.originalEvent || {};
- $(this).off('touchend', touchEnd);
+ $(this).off('touchend touchcancel', touchEnd);
var changedTouches = e.changedTouches || e.touches;
- if(!touchData || !changedTouches || changedTouches.length != 1){
+ if(e.type == 'touchcancel' || !touchData || !changedTouches || changedTouches.length != 1){
return;
}
touch = changedTouches[0];
if(Math.abs(touchData.x - touch.pageX) > 40 || Math.abs(touchData.y - touch.pageY) > 40 || Date.now() - touchData.now > 600){
@@ -1747,11 +1756,11 @@
touchData = {
x: touch.pageX,
y: touch.pageY,
now: Date.now()
};
- elemTarget.on('touchend', touchEnd);
+ elemTarget.on('touchend touchcancel', touchEnd);
};
this.each(function(){
this.addEventListener('touchstart', touchStart, true);
});
@@ -1861,11 +1870,11 @@
data.setChange(val);
},
cancel: function(val, popover, data){
if(!data.options.inlinePicker){
popover.stopOpen = true;
- if(assumeVirtualKeyBoard){
+ if(!popover.openedByFocus && assumeVirtualKeyBoard){
$('button', data.buttonWrapper).trigger('focus');
} else {
data.element.getShadowFocusElement().trigger('focus');
}
setTimeout(function(){
@@ -1961,18 +1970,10 @@
if(data.options.nopicker){return;}
var options = data.options;
var popover = webshims.objectCreate(options.inlinePicker ? webshims.inlinePopover : webshims.wsPopover, {}, $.extend(options.popover || {}, {prepareFor: options.inlinePicker ? data.buttonWrapper : data.element}));
var opener = $('<button type="button" class="ws-popover-opener"><span /></button>').appendTo(data.buttonWrapper);
- if(options.widgetPosition){
- webshims.error('options.widgetPosition was removed use options.popover.position instead');
- }
-
- if(options.openOnFocus && popover.options && (popover.options.appendTo == 'auto' || popover.options.appendTo == 'element')){
- webshims.error('openOnFocus and popover.appendTo "auto/element" can prduce a11y problems try to change appendTo to body or similiar or use openOnMouseFocus instead');
- }
-
var showPickerContent = function(){
(picker[data.type].showPickerContent || picker.showPickerContent)(data, popover);
};
var show = function(){
var type = loadPicker(data.type, 'DOM');
@@ -2037,13 +2038,32 @@
.on({
mousedown: function(){
stopPropagation.apply(this, arguments);
popover.preventBlur();
},
- focus: function(){
- popover.preventBlur();
- }
+ keydown: function(e){
+ if(e.keyCode == 40 && e.altKey){
+ open();
+ }
+ },
+ 'focus mousedown': (function(){
+ var allowClose = true;
+ var reset = function(){
+ allowClose = true;
+ };
+ return function(e){
+ if(e.type == 'mousedown'){
+ allowClose = false;
+ setTimeout(reset);
+ }
+ if(e.type == 'focus' && allowClose && options.openOnFocus && popover.openedByFocus && (popover.options.appendTo == 'auto' || popover.options.appendTo == 'element')){
+ popover.hide();
+ } else {
+ popover.preventBlur();
+ }
+ };
+ })()
})
;
(function(){
var mouseFocus = false;
@@ -2286,24 +2306,26 @@
oriStyleO.display = 'none';
init = true;
}
};
+ oriStyleO.webkitAppearance = 'none';
data.element.onWSOff('updateshadowdom', updateStyles, true);
};
var implementType = function(){
var type = $.prop(this, 'type');
-
var i, opts, data, optsName, labels, cNames, hasInitialFocus;
- if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
+
+ if(inputTypes[type] && webshims.implement(this, 'inputwidgets') && (!modernizrInputTypes[type] || !$(this).hasClass('ws-noreplace'))){
data = {};
optsName = type;
hasInitialFocus = $(this).is(':focus');
labels = $(this).jProp('labels');
+
opts = $.extend(webshims.getOptions(this, type, [options.widgets, options[type], $($.prop(this, 'form')).data(type)]), {
orig: this,
type: type,
labels: labels,
options: {},
@@ -2332,10 +2354,11 @@
optsName = copyAttrs[i].replace(/^data\-/, '');
if(optsName == 'placeholder' || !opts[optsName]){
opts[optsName] = $.attr(this, copyAttrs[i]) || opts[optsName];
}
}
+
if(opts.formatMonthNames){
webshims.error('formatMonthNames was renamded to monthNames');
}
if(opts.onlyMonthDigits){
opts.monthNames = 'monthDigits';
@@ -2355,14 +2378,14 @@
if(opts.splitInput || type == 'range'){
cNames = cNames.replace('form-control', '');
}
- data.shim.element.on('change input', stopPropagation).addClass(cNames);
+ data.shim.element.on('change input', stopPropagation).addClass(cNames+' '+webshims.shadowClass);
if(data.shim.buttonWrapper){
- data.shim.buttonWrapper.addClass('input-button-size-'+(data.shim.buttonWrapper.children().filter(isVisible).length));
+ data.shim.buttonWrapper.addClass('input-button-size-'+(data.shim.buttonWrapper.children().filter(isVisible).length)+' '+webshims.shadowClass);
if(data.shim.buttonWrapper.filter(isVisible).length){
data.shim.element.addClass('has-input-buttons');
}
}