vendor/assets/javascripts/webshims/shims/combos/11.js in webshims-rails-1.12.7 vs vendor/assets/javascripts/webshims/shims/combos/11.js in webshims-rails-1.13.0
- old
+ new
@@ -1576,11 +1576,10 @@
} else if(!isNaN(this.maxAsNumber) && start > this.maxAsNumber){
start = this.maxAsNumber;
}
this.elemHelper.prop('valueAsNumber', start);
this.options.defValue = this.elemHelper.prop('value');
-
},
reorderInputs: function(){
if(splitInputs[this.type]){
var element = this.element.attr('dir', curCfg.date.isRTL ? 'rtl' : 'ltr');
splitInputs[this.type].sort(element, this.options);
@@ -1643,11 +1642,11 @@
val = this.toFixed(val);
if(isLive && this._getSelectionEnd){
selectionEnd = this._getSelectionEnd(val);
}
this.element.prop(name, val);
- if(selectionEnd){
+ if(selectionEnd != null){
this.element.prop('selectionEnd', selectionEnd);
}
}
this._propertyChange(name);
this.mirrorValidity();
@@ -1658,10 +1657,11 @@
$.each({min: 1, max: -1}, function(name, factor){
var numName = name +'AsNumber';
spinBtnProto[name] = function(val){
this.elemHelper.prop(name, val);
this[numName] = this.asNumber(val);
+
if(this.valueAsNumber != null && (isNaN(this.valueAsNumber) || (!isNaN(this[numName]) && (this.valueAsNumber * factor) < (this[numName] * factor)))){
this._setStartInRange();
}
this.options[name] = val;
if(this._init){
@@ -2294,15 +2294,15 @@
var implementType = function(){
var type = $.prop(this, 'type');
- var i, opts, data, optsName, labels, cNames;
+ var i, opts, data, optsName, labels, cNames, hasInitialFocus;
if(inputTypes[type] && webshims.implement(this, 'inputwidgets')){
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,
@@ -2422,9 +2422,12 @@
if(opts.calculateWidth){
sizeInput(data.shim);
} else {
$(this).css('display', 'none');
+ }
+ if(hasInitialFocus){
+ $(this).getShadowFocusElement().trigger('focus');
}
}
};