move el.focus code elsewhere.

This commit is contained in:
Christopher Jeffrey 2013-07-21 02:12:16 -05:00
parent a98bef4c90
commit 62ebd04231

View File

@ -1150,6 +1150,7 @@ Screen.prototype.focusPush = function(el) {
this.history.shift();
}
this.history.push(el);
el._focus();
};
Screen.prototype.focusLast =
@ -1612,8 +1613,11 @@ Element.prototype.toggle = function() {
};
Element.prototype.focus = function() {
var old = this.screen.focused;
this.screen.focused = this;
};
Element.prototype._focus = function() {
var old = this.screen.history[this.screen.history.length-2];
// Find a scrollable ancestor if we have one.
var el = this;
@ -1640,7 +1644,7 @@ Element.prototype.focus = function() {
}
}
old.emit('blur', this);
if (old) old.emit('blur', this);
this.emit('focus', old);
this.screen.emit('element blur', old, this);
this.screen.emit('element focus', old, this);