mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-08-14 06:58:56 +02:00
window focus back
This commit is contained in:
parent
93f6f3c6ca
commit
3664ad8b65
5 changed files with 177 additions and 15 deletions
|
@ -36,6 +36,7 @@ var CommandPromptView = Backbone.View.extend({
|
|||
});
|
||||
|
||||
this.index = -1;
|
||||
this.listening = false;
|
||||
|
||||
this.commandSpan = this.$('#prompt span.command')[0];
|
||||
this.commandCursor = this.$('#prompt span.cursor')[0];
|
||||
|
@ -69,10 +70,14 @@ var CommandPromptView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
blur: function() {
|
||||
$(this.commandCursor).toggleClass('shown', false);
|
||||
this.listening = false;
|
||||
console.log('blurrring');
|
||||
this.hideCursor();
|
||||
},
|
||||
|
||||
focus: function() {
|
||||
console.log('focusing');
|
||||
this.listening = true;
|
||||
this.$('#commandTextField').focus();
|
||||
this.showCursor();
|
||||
},
|
||||
|
@ -90,11 +95,21 @@ var CommandPromptView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
onKey: function(e) {
|
||||
if (!this.listening) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
var el = e.srcElement;
|
||||
this.updatePrompt(el);
|
||||
},
|
||||
|
||||
onKeyUp: function(e) {
|
||||
if (!this.listening) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
this.onKey(e);
|
||||
|
||||
// we need to capture some of these events.
|
||||
|
|
|
@ -8,6 +8,13 @@ var BaseView = Backbone.View.extend({
|
|||
return this.destination || this.container.getInsideElement();
|
||||
},
|
||||
|
||||
tearDown: function() {
|
||||
this.$el.html('');
|
||||
if (this.container) {
|
||||
this.container.tearDown();
|
||||
}
|
||||
},
|
||||
|
||||
render: function(HTML) {
|
||||
// flexibility
|
||||
var destination = this.getDestination();
|
||||
|
|
|
@ -16,6 +16,7 @@ var MultiView = Backbone.View.extend({
|
|||
className: 'multiView',
|
||||
// ms to throttle the nav functions
|
||||
navEventThrottle: 150,
|
||||
deathTime: 700,
|
||||
|
||||
// a simple mapping of what childViews we support
|
||||
typeToConstructor: {
|
||||
|
@ -48,11 +49,13 @@ var MultiView = Backbone.View.extend({
|
|||
events: this.navEvents,
|
||||
aliasMap: {
|
||||
left: 'negative',
|
||||
right: 'positive'
|
||||
right: 'positive',
|
||||
enter: 'positive'
|
||||
}
|
||||
});
|
||||
|
||||
this.render();
|
||||
this.start();
|
||||
},
|
||||
|
||||
getPosFunc: function() {
|
||||
|
@ -105,6 +108,20 @@ var MultiView = Backbone.View.extend({
|
|||
this.deferred.resolve();
|
||||
} else {
|
||||
console.warn('no promise to resolve');
|
||||
require('../app').getUI().modalEnd();
|
||||
}
|
||||
setTimeout(_.bind(function() {
|
||||
_.each(this.childViews, function(childView) {
|
||||
childView.tearDown();
|
||||
});
|
||||
}, this), this.deathTime);
|
||||
},
|
||||
|
||||
start: function() {
|
||||
this.showViewIndex(this.currentIndex);
|
||||
if (!this.deferred) {
|
||||
console.warn('not part of a promise chain');
|
||||
require('../app').getUI().modalStart();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -135,8 +152,6 @@ var MultiView = Backbone.View.extend({
|
|||
this.childViews.push(childView);
|
||||
this.addNavToView(childView, index);
|
||||
}, this);
|
||||
|
||||
this.showViewIndex(this.currentIndex);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue