diff --git a/build/bundle.js b/build/bundle.js index 706f4d69..a85ce0f4 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -11479,14 +11479,20 @@ var eventBaton; var init = function(){ var Visualization = require('../visuals/visualization').Visualization; + var EventBaton = require('../util/eventBaton').EventBaton; + eventBaton = new EventBaton(); ui = new UI(); mainVis = new Visualization({ 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)) { 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"); @@ -11516,23 +11522,11 @@ function UI() { }); $('#commandTextField').focus(); - $(window).focus(_.bind(this.onWindowFocus, this)); + eventBaton.stealBaton('windowFocus', this.onWindowFocus, this); } UI.prototype.onWindowFocus = function() { - if (this.active) { - 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() { @@ -11577,15 +11571,14 @@ EventBaton.prototype.stealBaton = function(name, func, context) { }; EventBaton.prototype.trigger = function(name) { + // arguments is weird and doesnt do slice right var argsToApply = []; for (var i = 1; i < arguments.length; i++) { argsToApply.push(arguments[i]); } - // get the last one var listeners = this.eventMap[name]; if (!listeners) { - console.warn('no listeners for that event', name); return; } // call the top most listener with context and such @@ -14145,6 +14138,10 @@ var MultiView = Backbone.View.extend({ this.start(); }, + onWindowFocus: function() { + // nothing here for now... + }, + getPromise: function() { 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 // other views will take if they need to this.keyboardListener.mute(); - require('../app').getUI().modalEnd(); + require('../app').getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this); setTimeout(_.bind(function() { _.each(this.childViews, function(childView) { @@ -14209,7 +14206,8 @@ var MultiView = Backbone.View.extend({ }, start: function() { - require('../app').getUI().modalStart(); + // steal the window focus baton + require('../app').getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this); this.showViewIndex(this.currentIndex); }, @@ -14263,14 +14261,20 @@ var eventBaton; var init = function(){ var Visualization = require('../visuals/visualization').Visualization; + var EventBaton = require('../util/eventBaton').EventBaton; + eventBaton = new EventBaton(); ui = new UI(); mainVis = new Visualization({ 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)) { 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"); @@ -14300,23 +14304,11 @@ function UI() { }); $('#commandTextField').focus(); - $(window).focus(_.bind(this.onWindowFocus, this)); + eventBaton.stealBaton('windowFocus', this.onWindowFocus, this); } UI.prototype.onWindowFocus = function() { - if (this.active) { - 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() { @@ -17047,15 +17039,14 @@ EventBaton.prototype.stealBaton = function(name, func, context) { }; EventBaton.prototype.trigger = function(name) { + // arguments is weird and doesnt do slice right var argsToApply = []; for (var i = 1; i < arguments.length; i++) { argsToApply.push(arguments[i]); } - // get the last one var listeners = this.eventMap[name]; if (!listeners) { - console.warn('no listeners for that event', name); return; } // call the top most listener with context and such @@ -17872,6 +17863,10 @@ var MultiView = Backbone.View.extend({ this.start(); }, + onWindowFocus: function() { + // nothing here for now... + }, + getPromise: function() { 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 // other views will take if they need to this.keyboardListener.mute(); - require('../app').getUI().modalEnd(); + require('../app').getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this); setTimeout(_.bind(function() { _.each(this.childViews, function(childView) { @@ -17936,7 +17931,8 @@ var MultiView = Backbone.View.extend({ }, start: function() { - require('../app').getUI().modalStart(); + // steal the window focus baton + require('../app').getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this); this.showViewIndex(this.currentIndex); }, diff --git a/src/js/app/index.js b/src/js/app/index.js index 05ca8791..1789e325 100644 --- a/src/js/app/index.js +++ b/src/js/app/index.js @@ -13,14 +13,20 @@ var eventBaton; var init = function(){ var Visualization = require('../visuals/visualization').Visualization; + var EventBaton = require('../util/eventBaton').EventBaton; + eventBaton = new EventBaton(); ui = new UI(); mainVis = new Visualization({ 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)) { 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"); @@ -50,23 +56,11 @@ function UI() { }); $('#commandTextField').focus(); - $(window).focus(_.bind(this.onWindowFocus, this)); + eventBaton.stealBaton('windowFocus', this.onWindowFocus, this); } UI.prototype.onWindowFocus = function() { - if (this.active) { - 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() { diff --git a/src/js/util/eventBaton.js b/src/js/util/eventBaton.js index 7b0b967e..22840caa 100644 --- a/src/js/util/eventBaton.js +++ b/src/js/util/eventBaton.js @@ -19,15 +19,14 @@ EventBaton.prototype.stealBaton = function(name, func, context) { }; EventBaton.prototype.trigger = function(name) { + // arguments is weird and doesnt do slice right var argsToApply = []; for (var i = 1; i < arguments.length; i++) { argsToApply.push(arguments[i]); } - // get the last one var listeners = this.eventMap[name]; if (!listeners) { - console.warn('no listeners for that event', name); return; } // call the top most listener with context and such diff --git a/src/js/views/multiView.js b/src/js/views/multiView.js index befa63b4..38afc220 100644 --- a/src/js/views/multiView.js +++ b/src/js/views/multiView.js @@ -68,6 +68,10 @@ var MultiView = Backbone.View.extend({ this.start(); }, + onWindowFocus: function() { + // nothing here for now... + }, + getPromise: function() { 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 // other views will take if they need to this.keyboardListener.mute(); - require('../app').getUI().modalEnd(); + require('../app').getEventBaton().releaseBaton('windowFocus', this.onWindowFocus, this); setTimeout(_.bind(function() { _.each(this.childViews, function(childView) { @@ -132,7 +136,8 @@ var MultiView = Backbone.View.extend({ }, start: function() { - require('../app').getUI().modalStart(); + // steal the window focus baton + require('../app').getEventBaton().stealBaton('windowFocus', this.onWindowFocus, this); this.showViewIndex(this.currentIndex); }, diff --git a/todo.txt b/todo.txt index 6188c814..b1102fcb 100644 --- a/todo.txt +++ b/todo.txt @@ -12,8 +12,6 @@ Commands ======== [ ] move command creation outside of the command view so multiple things 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 [ ] multiple things can process!!! [ ] sip from buffer with post-command hooks. ideally the git engine @@ -37,6 +35,8 @@ Big Bugs to fix: Done things: (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 filters. no hacky stuff anymore where it's part of the option parser, wtf