better show and hide for goal and start visualizations related to Issue #36 nice

This commit is contained in:
Peter Cottle 2013-02-18 14:19:30 -08:00
parent 902944d53a
commit e8dd24fa5c
7 changed files with 108 additions and 147 deletions

View file

@ -48,7 +48,6 @@ var LevelBuilder = Level.extend({
};
LevelBuilder.__super__.initialize.apply(this, [options]);
this.initStartVisualization();
this.startDialog = undefined;
this.definedGoal = false;
@ -84,11 +83,7 @@ var LevelBuilder = Level.extend({
noKeyboardInput: true,
noClick: true
});
},
startDie: function() {
this.startCanvasHolder.die();
this.startVis.die();
return this.startCanvasHolder;
},
startOffCommand: function() {
@ -144,17 +139,13 @@ var LevelBuilder = Level.extend({
},
showGoal: function() {
this.startCanvasHolder.slideOut();
this.hideStart();
LevelBuilder.__super__.showGoal.apply(this, arguments);
},
showStart: function(command, deferred) {
this.goalCanvasHolder.slideOut();
this.startCanvasHolder.slideIn();
setTimeout(function() {
command.finishWith(deferred);
}, this.startCanvasHolder.getAnimationTime());
this.hideGoal();
this.showSideVis(command, deferred, this.startCanvasHolder, this.initStartVisualization);
},
resetSolution: function() {
@ -163,15 +154,11 @@ var LevelBuilder = Level.extend({
},
hideStart: function(command, deferred) {
this.startCanvasHolder.slideOut();
setTimeout(function() {
command.finishWith(deferred);
}, this.startCanvasHolder.getAnimationTime());
this.hideSideVis(command, deferred, this.startCanvasHolder);
},
defineStart: function(command, deferred) {
this.startDie();
this.hideStart();
command.addWarning(
'Defining start point... solution and goal will be overwritten if they were defined earlier'
@ -181,13 +168,11 @@ var LevelBuilder = Level.extend({
this.level.startTree = this.mainVis.gitEngine.printTree();
this.mainVis.resetFromThisTreeNow(this.level.startTree);
this.initStartVisualization();
this.showStart(command, deferred);
},
defineGoal: function(command, deferred) {
this.goalDie();
this.hideGoal();
if (!this.gitCommandsIssued.length) {
command.set('error', new Errors.GitError({
@ -352,7 +337,7 @@ var LevelBuilder = Level.extend({
},
die: function() {
this.startDie();
this.hideStart();
LevelBuilder.__super__.die.apply(this, arguments);

View file

@ -149,12 +149,7 @@ var Level = Sandbox.extend({
noKeyboardInput: true,
noClick: true
});
},
onGoalVisualizationClick: function() {
// we need to destory this entire view whenever it is hidden so the scroll bar
// still works. unfortunately this
delete this.goalCanvasHolder;
return this.goalCanvasHolder;
},
showSolution: function(command, deferred) {
@ -201,24 +196,36 @@ var Level = Sandbox.extend({
},
showGoal: function(command, defer) {
if (!this.goalCanvasHolder || !this.goalCanvasHolder.inDom) {
this.initGoalVisualization();
}
this.goalCanvasHolder.slideIn();
this.showSideVis(command, defer, this.goalCanvasHolder, this.initGoalVisualization);
},
if (!command || !defer) { return; }
setTimeout(function() {
command.finishWith(defer);
}, this.goalCanvasHolder.getAnimationTime());
showSideVis: function(command, defer, canvasHolder, initMethod) {
var safeFinish = function() {
if (command) { command.finishWith(defer); }
};
if (!canvasHolder || !canvasHolder.inDom) {
canvasHolder = initMethod.apply(this);
}
canvasHolder.slideIn();
setTimeout(safeFinish, canvasHolder.getAnimationTime());
},
hideGoal: function(command, defer) {
this.goalCanvasHolder.die();
if (!command || !defer) { return; }
this.hideSideVis(command, defer, this.goalCanvasHolder);
},
setTimeout(function() {
command.finishWith(defer);
}, this.goalCanvasHolder.getAnimationTime());
hideSideVis: function(command, defer, canvasHolder, vis) {
var safeFinish = function() {
if (command) { command.finishWith(defer); }
};
if (canvasHolder && canvasHolder.inDom) {
canvasHolder.die();
setTimeout(safeFinish, canvasHolder.getAnimationTime());
} else {
safeFinish();
}
},
initParseWaterfall: function(options) {
@ -383,7 +390,7 @@ var Level = Sandbox.extend({
die: function() {
this.levelToolbar.die();
this.goalDie();
this.hideGoal();
this.mainVis.die();
this.releaseControl();
@ -395,11 +402,6 @@ var Level = Sandbox.extend({
delete this.goalCanvasHolder;
},
goalDie: function() {
this.goalCanvasHolder.die();
this.goalVis.die();
},
getInstantCommands: function() {
var hintMsg = (this.level.hint) ?
this.level.hint :