yay better

This commit is contained in:
Peter Cottle 2012-12-25 17:02:08 -08:00
parent b1427556ef
commit 2fb843a8d6
3 changed files with 34 additions and 33 deletions

View file

@ -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) {

View file

@ -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) {

View file

@ -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