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;
}

View file

@ -14,7 +14,7 @@ var TIME = {
};
var GRAPHICS = {
nodeRadius: 15,
nodeRadius: 17,
curveControlPointOffset: 50,
defaultEasing: 'easeInOut',
defaultAnimationTime: 300,

View file

@ -288,6 +288,10 @@ p.commandLine span.prompt {
-webkit-animation-iteration-count: 99999; */
background: #DDD;
position: relative;
opacity: 0;
}
#prompt span.cursor.shown {
opacity: 0.7;
}

View file

@ -526,6 +526,7 @@ var VisNode = Backbone.Model.extend({
var text = paper.text(textPos.x, textPos.y, String(this.get('id')));
text.attr({
'font-size': 12,
'font-weight': 'bold',
'font-family': 'Monaco, Courier, font-monospace',
opacity: this.getOpacity()
});