mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-15 00:54:25 +02:00
git demonstration view done pretty much, whatabitch
This commit is contained in:
parent
3d02036a54
commit
b34422d648
9 changed files with 446 additions and 231 deletions
|
@ -50,6 +50,13 @@ EventBaton.prototype.getListenersThrow = function(name) {
|
|||
return listeners;
|
||||
};
|
||||
|
||||
EventBaton.prototype.passBatonBackSoft = function(name, func, context, args) {
|
||||
try {
|
||||
return this.passBatonBack(name, func, context, args);
|
||||
} catch (e) {
|
||||
}
|
||||
};
|
||||
|
||||
EventBaton.prototype.passBatonBack = function(name, func, context, args) {
|
||||
// this method will call the listener BEFORE the name/func pair. this
|
||||
// basically allows you to put in shims, where you steal batons but pass
|
||||
|
@ -81,7 +88,10 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
var found = false;
|
||||
_.each(listeners, function(listenerObj) {
|
||||
if (listenerObj.func === func && listenerObj.context === context) {
|
||||
if (found) { console.warn('woah duplicates!!!'); }
|
||||
if (found) {
|
||||
console.warn('woah duplicates!!!');
|
||||
console.log(listeners);
|
||||
}
|
||||
found = true;
|
||||
} else {
|
||||
newListeners.push(listenerObj);
|
||||
|
|
|
@ -20,18 +20,22 @@ function KeyboardListener(options) {
|
|||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
this.keydownListener = _.bind(this.keydown, this);
|
||||
if (!options.wait) {
|
||||
this.listen();
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardListener.prototype.listen = function() {
|
||||
Main.getEventBaton().stealBaton('docKeydown', this.keydownListener, this);
|
||||
if (this.listening) {
|
||||
return;
|
||||
}
|
||||
this.listening = true;
|
||||
Main.getEventBaton().stealBaton('docKeydown', this.keydown, this);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.mute = function() {
|
||||
Main.getEventBaton().releaseBaton('docKeydown', this.keydownListener, this);
|
||||
this.listening = false;
|
||||
Main.getEventBaton().releaseBaton('docKeydown', this.keydown, this);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.keydown = function(e) {
|
||||
|
@ -42,12 +46,16 @@ KeyboardListener.prototype.keydown = function(e) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.fireEvent(key);
|
||||
this.fireEvent(key, e);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.fireEvent = function(eventName) {
|
||||
KeyboardListener.prototype.fireEvent = function(eventName, e) {
|
||||
eventName = this.aliasMap[eventName] || eventName;
|
||||
this.events.trigger(eventName);
|
||||
this.events.trigger(eventName, e);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.passEventBack = function(e) {
|
||||
Main.getEventBaton().passBatonBackSoft('docKeydown', this.keydown, this, [e]);
|
||||
};
|
||||
|
||||
exports.KeyboardListener = KeyboardListener;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue