window focus back

This commit is contained in:
Peter Cottle 2012-12-24 13:41:36 -08:00
parent 93f6f3c6ca
commit 3664ad8b65
5 changed files with 177 additions and 15 deletions

View file

@ -28,11 +28,11 @@ var init = function(){
$(document).ready(init);
function UI() {
this.active = true;
var Collections = require('../models/collections');
var CommandViews = require('../views/commandViews');
this.commandCollection = new Collections.CommandCollection();
this.commandBuffer = new Collections.CommandBuffer({
collection: this.commandCollection
});
@ -47,8 +47,25 @@ function UI() {
});
$('#commandTextField').focus();
$(window).focus(_.bind(this.onWindowFocus, this));
}
UI.prototype.onWindowFocus = function() {
if (this.active) {
this.commandPromptView.focus();
}
};
UI.prototype.modalStart = function() {
this.active = false;
this.commandPromptView.blur();
};
UI.prototype.modalEnd = function() {
this.commandPromptView.focus();
this.active = true;
};
exports.getEvents = function() {
return events;
};