better focus and blur

This commit is contained in:
Peter Cottle 2012-09-30 17:07:48 -07:00
parent 2866ff38bb
commit 529f69599b
4 changed files with 23 additions and 4 deletions

View file

@ -12,6 +12,16 @@ var CommandPromptView = Backbone.View.extend({
$(document).delegate('#commandLineHistory', 'click', _.bind(function() {
this.focus();
}, this));
$(document).delegate('#commandTextField', 'blur', _.bind(function() {
this.blur();
}, this));
// hacky timeout focus
setTimeout(_.bind(function() {
this.focus();
}, this), 100);
},
events: {
@ -19,8 +29,15 @@ var CommandPromptView = Backbone.View.extend({
'keyup #commandTextField': 'onKeyUp'
},
blur: function() {
console.log('got blur');
$(this.commandCursor).toggleClass('shown', false);
},
focus: function() {
this.$('#commandTextField').focus();
// we now our cursor is there so...
$(this.commandCursor).toggleClass('shown', true);
},
onKey: function(e) {
@ -259,9 +276,6 @@ var CommandLineHistoryView = Backbone.View.extend({
var t = $('#terminal')[0];
if ($(t).hasClass('scrolling')) {
console.log('scrolling');
console.log(t.scrollHeight);
console.log(t.scrollTop);
t.scrollTop = t.scrollHeight;
return;
}