diff --git a/build/bundle.js b/build/bundle.js index 8dd7c14a..e0cd55e0 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -13785,7 +13785,7 @@ var MultiView = Backbone.View.extend({ markdown: 'Im second' } }]; - this.deferred = options.deferred; + this.deferred = Q.defer(); this.childViews = []; this.currentIndex = 0; @@ -13807,6 +13807,10 @@ var MultiView = Backbone.View.extend({ this.start(); }, + getPromise: function() { + return this.deferred.promise; + }, + getPosFunc: function() { return _.debounce(_.bind(function() { this.navForward(); @@ -13852,13 +13856,12 @@ var MultiView = Backbone.View.extend({ }, finish: function() { + // first we stop listening to keyboard and give that back to UI, which + // other views will take if they need to this.keyboardListener.mute(); - if (this.deferred) { - this.deferred.resolve(); - } else { - console.warn('no promise to resolve'); - require('../app').getUI().modalEnd(); - } + require('../app').getUI().modalEnd(); + this.deferred.resolve(); + setTimeout(_.bind(function() { _.each(this.childViews, function(childView) { childView.tearDown(); @@ -13867,11 +13870,8 @@ var MultiView = Backbone.View.extend({ }, start: function() { + require('../app').getUI().modalStart(); this.showViewIndex(this.currentIndex); - if (!this.deferred) { - console.warn('not part of a promise chain'); - require('../app').getUI().modalStart(); - } }, createChildView: function(viewJSON) { @@ -17282,7 +17282,7 @@ var MultiView = Backbone.View.extend({ markdown: 'Im second' } }]; - this.deferred = options.deferred; + this.deferred = Q.defer(); this.childViews = []; this.currentIndex = 0; @@ -17304,6 +17304,10 @@ var MultiView = Backbone.View.extend({ this.start(); }, + getPromise: function() { + return this.deferred.promise; + }, + getPosFunc: function() { return _.debounce(_.bind(function() { this.navForward(); @@ -17349,13 +17353,12 @@ var MultiView = Backbone.View.extend({ }, finish: function() { + // first we stop listening to keyboard and give that back to UI, which + // other views will take if they need to this.keyboardListener.mute(); - if (this.deferred) { - this.deferred.resolve(); - } else { - console.warn('no promise to resolve'); - require('../app').getUI().modalEnd(); - } + require('../app').getUI().modalEnd(); + this.deferred.resolve(); + setTimeout(_.bind(function() { _.each(this.childViews, function(childView) { childView.tearDown(); @@ -17364,11 +17367,8 @@ var MultiView = Backbone.View.extend({ }, start: function() { + require('../app').getUI().modalStart(); this.showViewIndex(this.currentIndex); - if (!this.deferred) { - console.warn('not part of a promise chain'); - require('../app').getUI().modalStart(); - } }, createChildView: function(viewJSON) { diff --git a/src/js/views/multiView.js b/src/js/views/multiView.js index 6420f60b..9dd2849a 100644 --- a/src/js/views/multiView.js +++ b/src/js/views/multiView.js @@ -46,7 +46,7 @@ var MultiView = Backbone.View.extend({ markdown: 'Im second' } }]; - this.deferred = options.deferred; + this.deferred = Q.defer(); this.childViews = []; this.currentIndex = 0; @@ -68,6 +68,10 @@ var MultiView = Backbone.View.extend({ this.start(); }, + getPromise: function() { + return this.deferred.promise; + }, + getPosFunc: function() { return _.debounce(_.bind(function() { this.navForward(); @@ -113,13 +117,12 @@ var MultiView = Backbone.View.extend({ }, finish: function() { + // first we stop listening to keyboard and give that back to UI, which + // other views will take if they need to this.keyboardListener.mute(); - if (this.deferred) { - this.deferred.resolve(); - } else { - console.warn('no promise to resolve'); - require('../app').getUI().modalEnd(); - } + require('../app').getUI().modalEnd(); + this.deferred.resolve(); + setTimeout(_.bind(function() { _.each(this.childViews, function(childView) { childView.tearDown(); @@ -128,11 +131,8 @@ var MultiView = Backbone.View.extend({ }, start: function() { + require('../app').getUI().modalStart(); this.showViewIndex(this.currentIndex); - if (!this.deferred) { - console.warn('not part of a promise chain'); - require('../app').getUI().modalStart(); - } }, createChildView: function(viewJSON) { diff --git a/todo.txt b/todo.txt index cdbaa9d8..55a558b2 100644 --- a/todo.txt +++ b/todo.txt @@ -36,6 +36,7 @@ Big Bugs to fix: Done things: (I only started this on Dec 17th 2012 to get a better sense of what was done) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +[x] change to returning a promise for multiview [x] multiViews with multiple terminals... [x] debounce the forward and back methods [x] multiview makes all these arrow views which fire events