mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-06 04:34:29 +02:00
one event baton in practice, but keyboard is complicated...
This commit is contained in:
parent
0779bdeadb
commit
8e8eb4f4a9
5 changed files with 53 additions and 59 deletions
|
@ -11479,14 +11479,20 @@ var eventBaton;
|
||||||
|
|
||||||
var init = function(){
|
var init = function(){
|
||||||
var Visualization = require('../visuals/visualization').Visualization;
|
var Visualization = require('../visuals/visualization').Visualization;
|
||||||
|
var EventBaton = require('../util/eventBaton').EventBaton;
|
||||||
|
|
||||||
|
eventBaton = new EventBaton();
|
||||||
ui = new UI();
|
ui = new UI();
|
||||||
mainVis = new Visualization({
|
mainVis = new Visualization({
|
||||||
el: $('#canvasWrapper')[0]
|
el: $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
var EventBaton = require('../util/eventBaton').EventBaton;
|
|
||||||
eventBaton = new EventBaton();
|
|
||||||
|
|
||||||
|
// set up event baton for certain things
|
||||||
|
$(window).focus(function() {
|
||||||
|
eventBaton.trigger('windowFocus');
|
||||||
|
});
|
||||||
|
|
||||||
|
/* hacky demo functionality */
|
||||||
if (/\?demo/.test(window.location.href)) {
|
if (/\?demo/.test(window.location.href)) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
events.trigger('submitCommandValueFromEvent', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix");
|
events.trigger('submitCommandValueFromEvent', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix");
|
||||||
|
@ -11516,23 +11522,11 @@ function UI() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#commandTextField').focus();
|
$('#commandTextField').focus();
|
||||||
$(window).focus(_.bind(this.onWindowFocus, this));
|
eventBaton.stealBaton('windowFocus', this.onWindowFocus, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
UI.prototype.onWindowFocus = function() {
|
UI.prototype.onWindowFocus = function() {
|
||||||
if (this.active) {
|
|
||||||
this.commandPromptView.focus();
|
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() {
|
exports.getEvents = function() {
|
||||||
|
@ -11577,15 +11571,14 @@ EventBaton.prototype.stealBaton = function(name, func, context) {
|
||||||
};
|
};
|
||||||
|
|
||||||
EventBaton.prototype.trigger = function(name) {
|
EventBaton.prototype.trigger = function(name) {
|
||||||
|
// arguments is weird and doesnt do slice right
|
||||||
var argsToApply = [];
|
var argsToApply = [];
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
for (var i = 1; i < arguments.length; i++) {
|
||||||
argsToApply.push(arguments[i]);
|
argsToApply.push(arguments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the last one
|
|
||||||
var listeners = this.eventMap[name];
|
var listeners = this.eventMap[name];
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
console.warn('no listeners for that event', name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// call the top most listener with context and such
|
// call the top most listener with context and such
|
||||||
|
@ -14145,6 +14138,10 @@ var MultiView = Backbone.View.extend({
|
||||||
this.start();
|
this.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onWindowFocus: function() {
|
||||||
|
// nothing here for now...
|
||||||
|
},
|
||||||
|
|
||||||
getPromise: function() {
|
getPromise: function() {
|
||||||
return this.deferred.promise;
|
return this.deferred.promise;
|
||||||
},
|
},
|
||||||
|
@ -14197,7 +14194,7 @@ var MultiView = Backbone.View.extend({
|
||||||
// first we stop listening to keyboard and give that back to UI, which
|
// first we stop listening to keyboard and give that back to UI, which
|
||||||
// other views will take if they need to
|
// other views will take if they need to
|
||||||
this.keyboardListener.mute();
|
this.keyboardListener.mute();
|
||||||
require('../app').getUI().modalEnd();
|
require('../app').getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this);
|
||||||
|
|
||||||
setTimeout(_.bind(function() {
|
setTimeout(_.bind(function() {
|
||||||
_.each(this.childViews, function(childView) {
|
_.each(this.childViews, function(childView) {
|
||||||
|
@ -14209,7 +14206,8 @@ var MultiView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function() {
|
start: function() {
|
||||||
require('../app').getUI().modalStart();
|
// steal the window focus baton
|
||||||
|
require('../app').getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this);
|
||||||
this.showViewIndex(this.currentIndex);
|
this.showViewIndex(this.currentIndex);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -14263,14 +14261,20 @@ var eventBaton;
|
||||||
|
|
||||||
var init = function(){
|
var init = function(){
|
||||||
var Visualization = require('../visuals/visualization').Visualization;
|
var Visualization = require('../visuals/visualization').Visualization;
|
||||||
|
var EventBaton = require('../util/eventBaton').EventBaton;
|
||||||
|
|
||||||
|
eventBaton = new EventBaton();
|
||||||
ui = new UI();
|
ui = new UI();
|
||||||
mainVis = new Visualization({
|
mainVis = new Visualization({
|
||||||
el: $('#canvasWrapper')[0]
|
el: $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
var EventBaton = require('../util/eventBaton').EventBaton;
|
|
||||||
eventBaton = new EventBaton();
|
|
||||||
|
|
||||||
|
// set up event baton for certain things
|
||||||
|
$(window).focus(function() {
|
||||||
|
eventBaton.trigger('windowFocus');
|
||||||
|
});
|
||||||
|
|
||||||
|
/* hacky demo functionality */
|
||||||
if (/\?demo/.test(window.location.href)) {
|
if (/\?demo/.test(window.location.href)) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
events.trigger('submitCommandValueFromEvent', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix");
|
events.trigger('submitCommandValueFromEvent', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix");
|
||||||
|
@ -14300,23 +14304,11 @@ function UI() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#commandTextField').focus();
|
$('#commandTextField').focus();
|
||||||
$(window).focus(_.bind(this.onWindowFocus, this));
|
eventBaton.stealBaton('windowFocus', this.onWindowFocus, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
UI.prototype.onWindowFocus = function() {
|
UI.prototype.onWindowFocus = function() {
|
||||||
if (this.active) {
|
|
||||||
this.commandPromptView.focus();
|
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() {
|
exports.getEvents = function() {
|
||||||
|
@ -17047,15 +17039,14 @@ EventBaton.prototype.stealBaton = function(name, func, context) {
|
||||||
};
|
};
|
||||||
|
|
||||||
EventBaton.prototype.trigger = function(name) {
|
EventBaton.prototype.trigger = function(name) {
|
||||||
|
// arguments is weird and doesnt do slice right
|
||||||
var argsToApply = [];
|
var argsToApply = [];
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
for (var i = 1; i < arguments.length; i++) {
|
||||||
argsToApply.push(arguments[i]);
|
argsToApply.push(arguments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the last one
|
|
||||||
var listeners = this.eventMap[name];
|
var listeners = this.eventMap[name];
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
console.warn('no listeners for that event', name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// call the top most listener with context and such
|
// call the top most listener with context and such
|
||||||
|
@ -17872,6 +17863,10 @@ var MultiView = Backbone.View.extend({
|
||||||
this.start();
|
this.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onWindowFocus: function() {
|
||||||
|
// nothing here for now...
|
||||||
|
},
|
||||||
|
|
||||||
getPromise: function() {
|
getPromise: function() {
|
||||||
return this.deferred.promise;
|
return this.deferred.promise;
|
||||||
},
|
},
|
||||||
|
@ -17924,7 +17919,7 @@ var MultiView = Backbone.View.extend({
|
||||||
// first we stop listening to keyboard and give that back to UI, which
|
// first we stop listening to keyboard and give that back to UI, which
|
||||||
// other views will take if they need to
|
// other views will take if they need to
|
||||||
this.keyboardListener.mute();
|
this.keyboardListener.mute();
|
||||||
require('../app').getUI().modalEnd();
|
require('../app').getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this);
|
||||||
|
|
||||||
setTimeout(_.bind(function() {
|
setTimeout(_.bind(function() {
|
||||||
_.each(this.childViews, function(childView) {
|
_.each(this.childViews, function(childView) {
|
||||||
|
@ -17936,7 +17931,8 @@ var MultiView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function() {
|
start: function() {
|
||||||
require('../app').getUI().modalStart();
|
// steal the window focus baton
|
||||||
|
require('../app').getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this);
|
||||||
this.showViewIndex(this.currentIndex);
|
this.showViewIndex(this.currentIndex);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,20 @@ var eventBaton;
|
||||||
|
|
||||||
var init = function(){
|
var init = function(){
|
||||||
var Visualization = require('../visuals/visualization').Visualization;
|
var Visualization = require('../visuals/visualization').Visualization;
|
||||||
|
var EventBaton = require('../util/eventBaton').EventBaton;
|
||||||
|
|
||||||
|
eventBaton = new EventBaton();
|
||||||
ui = new UI();
|
ui = new UI();
|
||||||
mainVis = new Visualization({
|
mainVis = new Visualization({
|
||||||
el: $('#canvasWrapper')[0]
|
el: $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
var EventBaton = require('../util/eventBaton').EventBaton;
|
|
||||||
eventBaton = new EventBaton();
|
|
||||||
|
|
||||||
|
// set up event baton for certain things
|
||||||
|
$(window).focus(function() {
|
||||||
|
eventBaton.trigger('windowFocus');
|
||||||
|
});
|
||||||
|
|
||||||
|
/* hacky demo functionality */
|
||||||
if (/\?demo/.test(window.location.href)) {
|
if (/\?demo/.test(window.location.href)) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
events.trigger('submitCommandValueFromEvent', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix");
|
events.trigger('submitCommandValueFromEvent', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix");
|
||||||
|
@ -50,23 +56,11 @@ function UI() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#commandTextField').focus();
|
$('#commandTextField').focus();
|
||||||
$(window).focus(_.bind(this.onWindowFocus, this));
|
eventBaton.stealBaton('windowFocus', this.onWindowFocus, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
UI.prototype.onWindowFocus = function() {
|
UI.prototype.onWindowFocus = function() {
|
||||||
if (this.active) {
|
|
||||||
this.commandPromptView.focus();
|
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() {
|
exports.getEvents = function() {
|
||||||
|
|
|
@ -19,15 +19,14 @@ EventBaton.prototype.stealBaton = function(name, func, context) {
|
||||||
};
|
};
|
||||||
|
|
||||||
EventBaton.prototype.trigger = function(name) {
|
EventBaton.prototype.trigger = function(name) {
|
||||||
|
// arguments is weird and doesnt do slice right
|
||||||
var argsToApply = [];
|
var argsToApply = [];
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
for (var i = 1; i < arguments.length; i++) {
|
||||||
argsToApply.push(arguments[i]);
|
argsToApply.push(arguments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the last one
|
|
||||||
var listeners = this.eventMap[name];
|
var listeners = this.eventMap[name];
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
console.warn('no listeners for that event', name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// call the top most listener with context and such
|
// call the top most listener with context and such
|
||||||
|
|
|
@ -68,6 +68,10 @@ var MultiView = Backbone.View.extend({
|
||||||
this.start();
|
this.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onWindowFocus: function() {
|
||||||
|
// nothing here for now...
|
||||||
|
},
|
||||||
|
|
||||||
getPromise: function() {
|
getPromise: function() {
|
||||||
return this.deferred.promise;
|
return this.deferred.promise;
|
||||||
},
|
},
|
||||||
|
@ -120,7 +124,7 @@ var MultiView = Backbone.View.extend({
|
||||||
// first we stop listening to keyboard and give that back to UI, which
|
// first we stop listening to keyboard and give that back to UI, which
|
||||||
// other views will take if they need to
|
// other views will take if they need to
|
||||||
this.keyboardListener.mute();
|
this.keyboardListener.mute();
|
||||||
require('../app').getUI().modalEnd();
|
require('../app').getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this);
|
||||||
|
|
||||||
setTimeout(_.bind(function() {
|
setTimeout(_.bind(function() {
|
||||||
_.each(this.childViews, function(childView) {
|
_.each(this.childViews, function(childView) {
|
||||||
|
@ -132,7 +136,8 @@ var MultiView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function() {
|
start: function() {
|
||||||
require('../app').getUI().modalStart();
|
// steal the window focus baton
|
||||||
|
require('../app').getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this);
|
||||||
this.showViewIndex(this.currentIndex);
|
this.showViewIndex(this.currentIndex);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
4
todo.txt
4
todo.txt
|
@ -12,8 +12,6 @@ Commands
|
||||||
========
|
========
|
||||||
[ ] move command creation outside of the command view so multiple things
|
[ ] move command creation outside of the command view so multiple things
|
||||||
can be responsible for specifying the waterfall associated with a command!
|
can be responsible for specifying the waterfall associated with a command!
|
||||||
[ ] make some kind of "single listener" event system... will make keyboard stuff easy
|
|
||||||
because then you just steal and release for modals and such
|
|
||||||
[ ] then refactor keyboard input and UI.listen() to that event system
|
[ ] then refactor keyboard input and UI.listen() to that event system
|
||||||
[ ] multiple things can process!!!
|
[ ] multiple things can process!!!
|
||||||
[ ] sip from buffer with post-command hooks. ideally the git engine
|
[ ] sip from buffer with post-command hooks. ideally the git engine
|
||||||
|
@ -37,6 +35,8 @@ Big Bugs to fix:
|
||||||
Done things:
|
Done things:
|
||||||
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
[x] make some kind of "single listener" event system... will make keyboard stuff easy
|
||||||
|
because then you just steal and release for modals and such
|
||||||
[x] text input from the commandPromptView must flow down into
|
[x] text input from the commandPromptView must flow down into
|
||||||
filters. no hacky stuff anymore where it's part of the option parser,
|
filters. no hacky stuff anymore where it's part of the option parser,
|
||||||
wtf
|
wtf
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue