mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 01:10:04 +02:00
die for levels
This commit is contained in:
parent
5d981a1268
commit
953bd49ee2
11 changed files with 270 additions and 14 deletions
|
@ -27,6 +27,10 @@ GitShim.prototype.insertShim = function() {
|
|||
this.eventBaton.stealBaton('processGitCommand', this.processGitCommand, this);
|
||||
};
|
||||
|
||||
GitShim.prototype.removeShim = function() {
|
||||
this.eventBaton.releaseBaton('processGitCommand', this.processGitCommand, this);
|
||||
};
|
||||
|
||||
GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||
this.beforeCB(command);
|
||||
|
||||
|
|
|
@ -257,6 +257,10 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
|
|||
throw new Error('ruh rho!! unsupported tyep for ' + objID);
|
||||
};
|
||||
|
||||
GitEngine.prototype.tearDown = function() {
|
||||
this.removeAll();
|
||||
};
|
||||
|
||||
GitEngine.prototype.removeAll = function() {
|
||||
this.branchCollection.reset();
|
||||
this.commitCollection.reset();
|
||||
|
|
|
@ -18,6 +18,7 @@ var ModalAlert = require('../views').ModalAlert;
|
|||
var MultiView = require('../views/multiView').MultiView;
|
||||
var CanvasTerminalHolder = require('../views').CanvasTerminalHolder;
|
||||
var ConfirmCancelTerminal = require('../views').ConfirmCancelTerminal;
|
||||
var LevelToolbar = require('../views').LevelToolbar;
|
||||
|
||||
var TreeCompare = require('../git/treeCompare').TreeCompare;
|
||||
|
||||
|
@ -35,10 +36,25 @@ var Level = Sandbox.extend({
|
|||
this.treeCompare = new TreeCompare();
|
||||
|
||||
this.initGoalData(options);
|
||||
this.initName(options);
|
||||
|
||||
Sandbox.prototype.initialize.apply(this, [options]);
|
||||
this.startOffCommand();
|
||||
},
|
||||
|
||||
initName: function(options) {
|
||||
this.levelName = options.levelName;
|
||||
this.levelID = options.levelID;
|
||||
if (!this.levelName || !this.levelID) {
|
||||
this.levelName = 'Rebase Classic';
|
||||
console.warn('REALLY BAD FORM need ids and names');
|
||||
}
|
||||
|
||||
this.levelToolbar = new LevelToolbar({
|
||||
levelName: this.levelName
|
||||
});
|
||||
},
|
||||
|
||||
initGoalData: function(options) {
|
||||
this.goalTreeString = options.level.goalTree;
|
||||
this.solutionCommand = options.level.solutionCommand;
|
||||
|
@ -59,6 +75,12 @@ var Level = Sandbox.extend({
|
|||
Sandbox.prototype.takeControl.apply(this);
|
||||
},
|
||||
|
||||
releaseControl: function() {
|
||||
Main.getEventBaton().releaseBaton('processLevelCommand', this.processLevelCommand, this);
|
||||
|
||||
Sandbox.prototype.releaseControl.apply(this);
|
||||
},
|
||||
|
||||
startOffCommand: function() {
|
||||
Main.getEventBaton().trigger(
|
||||
'commandSubmitted',
|
||||
|
@ -270,6 +292,22 @@ var Level = Sandbox.extend({
|
|||
});
|
||||
},
|
||||
|
||||
die: function() {
|
||||
this.levelToolbar.die();
|
||||
this.goalCanvasHolder.die();
|
||||
|
||||
this.mainVis.die();
|
||||
this.goalVis.die();
|
||||
this.releaseControl();
|
||||
|
||||
this.clear();
|
||||
|
||||
delete this.commandCollection;
|
||||
delete this.mainVis;
|
||||
delete this.goalVis;
|
||||
delete this.goalCanvasHolder;
|
||||
},
|
||||
|
||||
getInstantCommands: function() {
|
||||
var hintMsg = (this.level.hint) ?
|
||||
this.level.hint :
|
||||
|
|
|
@ -67,6 +67,22 @@ var Sandbox = Backbone.View.extend({
|
|||
this.insertGitShim();
|
||||
},
|
||||
|
||||
releaseControl: function() {
|
||||
// we will be handling commands that are submitted, mainly to add the sanadbox
|
||||
// functionality (which is included by default in ParseWaterfall())
|
||||
Main.getEventBaton().releaseBaton('commandSubmitted', this.commandSubmitted, this);
|
||||
// we obviously take care of sandbox commands
|
||||
Main.getEventBaton().releaseBaton('processSandboxCommand', this.processSandboxCommand, this);
|
||||
|
||||
this.releaseGitShim();
|
||||
},
|
||||
|
||||
releaseGitShim: function() {
|
||||
if (this.gitShim) {
|
||||
this.gitShim.removeShim();
|
||||
}
|
||||
},
|
||||
|
||||
insertGitShim: function() {
|
||||
// and our git shim goes in after the git engine is ready so it doesn't steal the baton
|
||||
// too early
|
||||
|
@ -104,7 +120,9 @@ var Sandbox = Backbone.View.extend({
|
|||
|
||||
clear: function(command, deferred) {
|
||||
Main.getEvents().trigger('clearOldCommands');
|
||||
command.finishWith(deferred);
|
||||
if (command && deferred) {
|
||||
command.finishWith(deferred);
|
||||
}
|
||||
},
|
||||
|
||||
delay: function(command, deferred) {
|
||||
|
|
|
@ -17,7 +17,8 @@ var toGlobalize = {
|
|||
Views: require('../views'),
|
||||
MultiView: require('../views/multiView'),
|
||||
ZoomLevel: require('../util/zoomLevel'),
|
||||
VisBranch: require('../visuals/visBranch')
|
||||
VisBranch: require('../visuals/visBranch'),
|
||||
Level: require('../level')
|
||||
};
|
||||
|
||||
_.each(toGlobalize, function(module) {
|
||||
|
|
|
@ -13,7 +13,7 @@ var BaseView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
tearDown: function() {
|
||||
this.$el.html('');
|
||||
this.$el.remove();
|
||||
if (this.container) {
|
||||
this.container.tearDown();
|
||||
}
|
||||
|
@ -179,7 +179,6 @@ var ModalView = Backbone.View.extend({
|
|||
// reason if this is done immediately, chrome might combine
|
||||
// the two changes and lose the ability to animate and it looks bad.
|
||||
process.nextTick(_.bind(function() {
|
||||
console.log('STEALING KEYBOARD in modal');
|
||||
this.toggleShow(true);
|
||||
}, this));
|
||||
},
|
||||
|
@ -343,6 +342,7 @@ var ZoomAlertWindow = Backbone.View.extend({
|
|||
|
||||
var LevelToolbar = BaseView.extend({
|
||||
tagName: 'div',
|
||||
className: 'levelToolbarHolder',
|
||||
template: _.template($('#level-toolbar-template').html()),
|
||||
|
||||
initialize: function(options) {
|
||||
|
@ -361,6 +361,8 @@ var LevelToolbar = BaseView.extend({
|
|||
}
|
||||
},
|
||||
|
||||
getAnimationTime: function() { return 700; },
|
||||
|
||||
render: function() {
|
||||
var HTML = this.template(this.JSON);
|
||||
|
||||
|
@ -368,6 +370,13 @@ var LevelToolbar = BaseView.extend({
|
|||
this.beforeDestination.after(this.el);
|
||||
},
|
||||
|
||||
die: function() {
|
||||
this.hide();
|
||||
setTimeout(_.bind(function() {
|
||||
this.tearDown();
|
||||
}, this), this.getAnimationTime());
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$('div.toolbar').toggleClass('hidden', true);
|
||||
},
|
||||
|
@ -402,6 +411,13 @@ var CanvasTerminalHolder = BaseView.extend({
|
|||
this.slideOut();
|
||||
},
|
||||
|
||||
die: function() {
|
||||
this.slideOut();
|
||||
setTimeout(_.bind(function() {
|
||||
this.tearDown();
|
||||
}, this));
|
||||
},
|
||||
|
||||
slideOut: function() {
|
||||
this.slideToggle(true);
|
||||
},
|
||||
|
|
|
@ -112,6 +112,7 @@ var Visualization = Backbone.View.extend({
|
|||
tearDown: function() {
|
||||
// hmm -- dont think this will work to unbind the event listener...
|
||||
this.events.off('resize', this.myResize, this);
|
||||
this.gitEngine.tearDown();
|
||||
this.gitVisuals.tearDown();
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue