Refactoring focus for checkbox/radiobox
This commit is contained in:
parent
cbab777f48
commit
703f0f7532
|
@ -146,11 +146,9 @@ define([
|
|||
if (disabled !== this.disabled) {
|
||||
this.$label.toggleClass('disabled', disabled);
|
||||
(disabled) ? this.$chk.attr({disabled: disabled}) : this.$chk.removeAttr('disabled');
|
||||
if (disabled) {
|
||||
this.tabindex = this.$label.attr('tabindex');
|
||||
this.$label.attr('tabindex', -1);
|
||||
} else if (this.tabindex) {
|
||||
this.$label.attr('tabindex', this.tabindex);
|
||||
if (this.tabindex!==undefined) {
|
||||
disabled && (this.tabindex = this.$label.attr('tabindex'));
|
||||
this.$label.attr('tabindex', disabled ? "-1" : this.tabindex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,6 +214,14 @@ define([
|
|||
|
||||
focus: function() {
|
||||
this.$label && this.$label.focus();
|
||||
},
|
||||
|
||||
setTabIndex: function(tabindex) {
|
||||
if (!this.rendered)
|
||||
return;
|
||||
|
||||
this.tabindex = tabindex.toString();
|
||||
!this.disabled && this.$label.attr('tabindex', this.tabindex);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -75,7 +75,7 @@ Common.UI.FocusManager = new(function() {
|
|||
item.selector = '.form-control';
|
||||
}
|
||||
item.el = (item.cmp.$el || $(item.cmp.el || item.cmp)).find(item.selector).addBack().filter(item.selector);
|
||||
item.el && item.el.attr && item.el.attr('tabindex', _tabindex.toString());
|
||||
item.el && item.el.attr && (item.cmp.setTabIndex ? item.cmp.setTabIndex(_tabindex) : item.el.attr('tabindex', _tabindex.toString()));
|
||||
arr.push(item);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -120,11 +120,9 @@ define([
|
|||
this.$label.toggleClass('disabled', disabled);
|
||||
this.$radio.toggleClass('disabled', disabled);
|
||||
(disabled) ? this.$radio.attr({disabled: disabled}) : this.$radio.removeAttr('disabled');
|
||||
if (disabled) {
|
||||
this.tabindex = this.$label.attr('tabindex');
|
||||
this.$label.attr('tabindex', -1);
|
||||
} else if (this.tabindex) {
|
||||
this.$label.attr('tabindex', this.tabindex);
|
||||
if (this.tabindex!==undefined) {
|
||||
disabled && (this.tabindex = this.$label.attr('tabindex'));
|
||||
this.$label.attr('tabindex', disabled ? "-1" : this.tabindex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,6 +174,14 @@ define([
|
|||
|
||||
focus: function() {
|
||||
this.$label && this.$label.focus();
|
||||
},
|
||||
|
||||
setTabIndex: function(tabindex) {
|
||||
if (!this.rendered)
|
||||
return;
|
||||
|
||||
this.tabindex = tabindex.toString();
|
||||
!this.disabled && this.$label.attr('tabindex', this.tabindex);
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue