refactor attr swap.

This commit is contained in:
Christopher Jeffrey 2013-06-13 02:26:09 -05:00
parent 607013b22b
commit bca271fbe6
1 changed files with 7 additions and 34 deletions

View File

@ -1430,40 +1430,13 @@ List.prototype.select = function(index) {
if (this.selected === index && this._listInitialized) return; if (this.selected === index && this._listInitialized) return;
this._listInitialized = true; this._listInitialized = true;
if (this.selectedBg) { ['bg', 'fg', 'bold', 'underline',
this.items[this.selected].bg = this.bg; 'blink', 'inverse', 'invisible'].forEach(function(name) {
this.items[index].bg = this.selectedBg; this.items[this.selected][name] = this[name];
} this.items[index][name] = this['selected'
+ name.substring(0, 1).toUpperCase()
if (this.selectedFg) { + name.substring(1)];
this.items[this.selected].fg = this.fg; }, this);
this.items[index].fg = this.selectedFg;
}
if (this.selectedBold != null) {
this.items[this.selected].bold = this.bold;
this.items[index].bold = this.selectedBold;
}
if (this.selectedUnderline != null) {
this.items[this.selected].underline = this.underline;
this.items[index].underline = this.selectedUnderline;
}
if (this.selectedBlink != null) {
this.items[this.selected].blink = this.blink;
this.items[index].blink = this.selectedBlink;
}
if (this.selectedInverse != null) {
this.items[this.selected].inverse = this.inverse;
this.items[index].inverse = this.selectedInverse;
}
if (this.selectedInvisible != null) {
this.items[this.selected].invisible = this.invisible;
this.items[index].invisible = this.selectedInvisible;
}
var diff = index - this.selected; var diff = index - this.selected;
this.selected = index; this.selected = index;