mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 00:18:56 +02:00
ok moved sandbox to a backbone view for inheritance
This commit is contained in:
parent
134cc9f748
commit
2e92e106d4
5 changed files with 356 additions and 299 deletions
428
build/bundle.js
428
build/bundle.js
|
@ -4467,7 +4467,8 @@ exports.splitTextCommand = function(value, func, context) {
|
||||||
});
|
});
|
||||||
|
|
||||||
require.define("/src/js/level/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
require.define("/src/js/level/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||||
var Backbone = require('backbone');
|
// horrible hack to get localStorage Backbone plugin
|
||||||
|
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
|
||||||
|
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
|
@ -4483,85 +4484,91 @@ var ModalAlert = require('../views').ModalAlert;
|
||||||
|
|
||||||
var MultiView = require('../views/multiView').MultiView;
|
var MultiView = require('../views/multiView').MultiView;
|
||||||
|
|
||||||
function Sandbox(options) {
|
var Sandbox = Backbone.View.extend({
|
||||||
options = options || {};
|
// tag name here is purely vestigial. I made this a view
|
||||||
|
// simply to use inheritance and have a nice event system in place
|
||||||
|
tagName: 'div',
|
||||||
|
initialize: function(options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
this.mainVis = new Visualization({
|
this.mainVis = new Visualization({
|
||||||
el: options.el || $('#canvasWrapper')[0]
|
el: options.el || $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
// don't add it to just any collection -- adding to the
|
// don't add it to just any collection -- adding to the
|
||||||
// CommandUI collection will put in history
|
// CommandUI collection will put in history
|
||||||
this.commandCollection = Main.getCommandUI().commandCollection;
|
this.commandCollection = Main.getCommandUI().commandCollection;
|
||||||
|
|
||||||
this.parseWaterfall = new ParseWaterfall();
|
this.parseWaterfall = new ParseWaterfall();
|
||||||
|
/*
|
||||||
|
this.gitShim = new GitShim({
|
||||||
|
beforeCB: function() { console.log('before'); },
|
||||||
|
afterCB: function() { console.log('after'); }
|
||||||
|
});*/
|
||||||
|
|
||||||
this.gitShim = new GitShim({
|
/* DISBALED MAP example!!!
|
||||||
beforeCB: function() { console.log('before'); },
|
this.parseWaterfall.addFirst(
|
||||||
afterCB: function() { console.log('after'); }
|
'instantWaterfall',
|
||||||
});
|
new DisabledMap().getInstantCommands()
|
||||||
|
);*/
|
||||||
|
|
||||||
/* DISBALED MAP example!!!
|
if (!options.wait) {
|
||||||
this.parseWaterfall.addFirst(
|
this.takeControl();
|
||||||
'instantWaterfall',
|
}
|
||||||
new DisabledMap().getInstantCommands()
|
},
|
||||||
);*/
|
|
||||||
|
|
||||||
if (!options.defer) {
|
takeControl: function() {
|
||||||
this.takeControl();
|
// we will be handling commands that are submitted, mainly to add the sanadbox
|
||||||
|
// functionality (which is included by default in ParseWaterfall())
|
||||||
|
Main.getEventBaton().stealBaton('commandSubmitted', this.commandSubmitted, this);
|
||||||
|
// we obviously take care of sandbox commands
|
||||||
|
Main.getEventBaton().stealBaton('processSandboxCommand', this.processSandboxCommand, this);
|
||||||
|
|
||||||
|
// and our git shim
|
||||||
|
// TODO HACKY needs to be AFTER PAPER INITIALIZE dropped down from visualization wtf
|
||||||
|
if (this.gitShim) {
|
||||||
|
setTimeout(_.bind(function() {
|
||||||
|
this.gitShim.insertShim();
|
||||||
|
}, this), 1000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
commandSubmitted: function(value) {
|
||||||
|
// allow other things to see this command
|
||||||
|
Main.getEvents().trigger('commandSubmittedPassive', value);
|
||||||
|
|
||||||
|
util.splitTextCommand(value, function(command) {
|
||||||
|
this.commandCollection.add(new Command({
|
||||||
|
rawStr: command,
|
||||||
|
parseWaterfall: this.parseWaterfall
|
||||||
|
}));
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
processSandboxCommand: function(command, deferred) {
|
||||||
|
var commandMap = {
|
||||||
|
help: this.helpDialog
|
||||||
|
};
|
||||||
|
var method = commandMap[command.get('method')];
|
||||||
|
if (!method) { throw new Error('no method for that wut'); }
|
||||||
|
|
||||||
|
method.apply(this, [command, deferred]);
|
||||||
|
},
|
||||||
|
|
||||||
|
helpDialog: function(command, deferred) {
|
||||||
|
var helpDialog = new MultiView({
|
||||||
|
childViews: require('../dialogs/sandbox').helpDialog
|
||||||
|
});
|
||||||
|
helpDialog.getPromise().then(_.bind(function() {
|
||||||
|
// the view has been closed, lets go ahead and resolve our command
|
||||||
|
command.finishWith(deferred);
|
||||||
|
}, this))
|
||||||
|
.done();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
Sandbox.prototype.takeControl = function() {
|
|
||||||
// we will be handling commands that are submitted, mainly to add the sanadbox
|
|
||||||
// functionality (which is included by default in ParseWaterfall())
|
|
||||||
Main.getEventBaton().stealBaton('commandSubmitted', this.commandSubmitted, this);
|
|
||||||
// we obviously take care of sandbox commands
|
|
||||||
Main.getEventBaton().stealBaton('processSandboxCommand', this.processSandboxCommand, this);
|
|
||||||
|
|
||||||
// and our git shim
|
|
||||||
// TODO HACKY needs to be AFTER PAPER INITIALIZE dropped down from visualization wtf
|
|
||||||
setTimeout(_.bind(function() {
|
|
||||||
this.gitShim.insertShim();
|
|
||||||
}, this), 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sandbox.prototype.commandSubmitted = function(value) {
|
|
||||||
// allow other things to see this command
|
|
||||||
Main.getEvents().trigger('commandSubmittedPassive', value);
|
|
||||||
|
|
||||||
util.splitTextCommand(value, function(command) {
|
|
||||||
this.commandCollection.add(new Command({
|
|
||||||
rawStr: command,
|
|
||||||
parseWaterfall: this.parseWaterfall
|
|
||||||
}));
|
|
||||||
}, this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sandbox.prototype.processSandboxCommand = function(command, deferred) {
|
|
||||||
var commandMap = {
|
|
||||||
help: this.helpDialog
|
|
||||||
};
|
|
||||||
var method = commandMap[command.get('method')];
|
|
||||||
if (!method) { throw new Error('no method for that wut'); }
|
|
||||||
|
|
||||||
method.apply(this, [command, deferred]);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sandbox.prototype.helpDialog = function(command, deferred) {
|
|
||||||
var helpDialog = new MultiView({
|
|
||||||
childViews: require('../dialogs/sandbox').helpDialog
|
|
||||||
});
|
|
||||||
helpDialog.getPromise().then(_.bind(function() {
|
|
||||||
// the view has been closed, lets go ahead and resolve our command
|
|
||||||
command.finishWith(deferred);
|
|
||||||
}, this))
|
|
||||||
.done();
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Sandbox = Sandbox;
|
exports.Sandbox = Sandbox;
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
require.define("/src/js/app/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
require.define("/src/js/app/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||||
|
@ -14327,21 +14334,6 @@ function GitShim(options) {
|
||||||
};
|
};
|
||||||
this.beforeDeferHandler = options.beforeDeferHandler || resolveImmediately;
|
this.beforeDeferHandler = options.beforeDeferHandler || resolveImmediately;
|
||||||
this.afterDeferHandler = options.afterDeferHandler || resolveImmediately;
|
this.afterDeferHandler = options.afterDeferHandler || resolveImmediately;
|
||||||
|
|
||||||
this.beforeDeferHandler = function(deferred) {
|
|
||||||
var view = new MultiView({
|
|
||||||
});
|
|
||||||
view.getPromise()
|
|
||||||
.then(function() {
|
|
||||||
return Q.delay(700);
|
|
||||||
})
|
|
||||||
.then(function() {
|
|
||||||
console.log('WUTTTTTTT');
|
|
||||||
deferred.resolve();
|
|
||||||
})
|
|
||||||
.done();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.eventBaton = options.eventBaton || Main.getEventBaton();
|
this.eventBaton = options.eventBaton || Main.getEventBaton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14350,17 +14342,18 @@ GitShim.prototype.insertShim = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitShim.prototype.processGitCommand = function(command, deferred) {
|
GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||||
console.log('in before');
|
|
||||||
this.beforeCB(command);
|
this.beforeCB(command);
|
||||||
|
|
||||||
// ok we make a NEW deferred that will, upon resolution,
|
// ok we make a NEW deferred that will, upon resolution,
|
||||||
// call our afterGitCommandProcessed. This inserts the 'after' shim
|
// call our afterGitCommandProcessed. This inserts the 'after' shim
|
||||||
// functionality. we give this new deferred to the eventBaton handler
|
// functionality. we give this new deferred to the eventBaton handler
|
||||||
var newDeferred = Q.defer();
|
var newDeferred = Q.defer();
|
||||||
newDeferred.promise.then(_.bind(function() {
|
newDeferred.promise
|
||||||
|
.then(_.bind(function() {
|
||||||
// give this method the original defer so it can resolve it
|
// give this method the original defer so it can resolve it
|
||||||
this.afterGitCommandProcessed(command, deferred);
|
this.afterGitCommandProcessed(command, deferred);
|
||||||
}, this));
|
}, this))
|
||||||
|
.done();
|
||||||
|
|
||||||
// now our shim owner might want to launch some kind of deferred beforehand, like
|
// now our shim owner might want to launch some kind of deferred beforehand, like
|
||||||
// a modal or something. in order to do this, we need to defer the passing
|
// a modal or something. in order to do this, we need to defer the passing
|
||||||
|
@ -14372,7 +14365,9 @@ GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var beforeDefer = Q.defer();
|
var beforeDefer = Q.defer();
|
||||||
beforeDefer.promise.then(passBaton);
|
beforeDefer.promise
|
||||||
|
.then(passBaton)
|
||||||
|
.done();
|
||||||
|
|
||||||
// if we didnt receive a defer handler in the options, this just
|
// if we didnt receive a defer handler in the options, this just
|
||||||
// resolves immediately
|
// resolves immediately
|
||||||
|
@ -14381,7 +14376,18 @@ GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||||
|
|
||||||
GitShim.prototype.afterGitCommandProcessed = function(command, deferred) {
|
GitShim.prototype.afterGitCommandProcessed = function(command, deferred) {
|
||||||
this.afterCB(command);
|
this.afterCB(command);
|
||||||
deferred.resolve();
|
|
||||||
|
// again we can't just resolve this deferred right away... our shim owner might
|
||||||
|
// want to insert some promise functionality before that happens. so again
|
||||||
|
// we make a defer
|
||||||
|
var afterDefer = Q.defer();
|
||||||
|
afterDefer.promise
|
||||||
|
.then(function() {
|
||||||
|
deferred.resolve();
|
||||||
|
})
|
||||||
|
.done();
|
||||||
|
|
||||||
|
this.afterDeferHandler(afterDefer);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.GitShim = GitShim;
|
exports.GitShim = GitShim;
|
||||||
|
@ -14421,16 +14427,6 @@ var MultiView = Backbone.View.extend({
|
||||||
options: {
|
options: {
|
||||||
markdown: 'Woah wtf!!'
|
markdown: 'Woah wtf!!'
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
type: 'ModalAlert',
|
|
||||||
options: {
|
|
||||||
markdown: 'Im second'
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
type: 'ModalAlert',
|
|
||||||
options: {
|
|
||||||
markdown: 'Im second'
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
type: 'ModalAlert',
|
type: 'ModalAlert',
|
||||||
options: {
|
options: {
|
||||||
|
@ -15050,21 +15046,6 @@ function GitShim(options) {
|
||||||
};
|
};
|
||||||
this.beforeDeferHandler = options.beforeDeferHandler || resolveImmediately;
|
this.beforeDeferHandler = options.beforeDeferHandler || resolveImmediately;
|
||||||
this.afterDeferHandler = options.afterDeferHandler || resolveImmediately;
|
this.afterDeferHandler = options.afterDeferHandler || resolveImmediately;
|
||||||
|
|
||||||
this.beforeDeferHandler = function(deferred) {
|
|
||||||
var view = new MultiView({
|
|
||||||
});
|
|
||||||
view.getPromise()
|
|
||||||
.then(function() {
|
|
||||||
return Q.delay(700);
|
|
||||||
})
|
|
||||||
.then(function() {
|
|
||||||
console.log('WUTTTTTTT');
|
|
||||||
deferred.resolve();
|
|
||||||
})
|
|
||||||
.done();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.eventBaton = options.eventBaton || Main.getEventBaton();
|
this.eventBaton = options.eventBaton || Main.getEventBaton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15073,17 +15054,18 @@ GitShim.prototype.insertShim = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitShim.prototype.processGitCommand = function(command, deferred) {
|
GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||||
console.log('in before');
|
|
||||||
this.beforeCB(command);
|
this.beforeCB(command);
|
||||||
|
|
||||||
// ok we make a NEW deferred that will, upon resolution,
|
// ok we make a NEW deferred that will, upon resolution,
|
||||||
// call our afterGitCommandProcessed. This inserts the 'after' shim
|
// call our afterGitCommandProcessed. This inserts the 'after' shim
|
||||||
// functionality. we give this new deferred to the eventBaton handler
|
// functionality. we give this new deferred to the eventBaton handler
|
||||||
var newDeferred = Q.defer();
|
var newDeferred = Q.defer();
|
||||||
newDeferred.promise.then(_.bind(function() {
|
newDeferred.promise
|
||||||
|
.then(_.bind(function() {
|
||||||
// give this method the original defer so it can resolve it
|
// give this method the original defer so it can resolve it
|
||||||
this.afterGitCommandProcessed(command, deferred);
|
this.afterGitCommandProcessed(command, deferred);
|
||||||
}, this));
|
}, this))
|
||||||
|
.done();
|
||||||
|
|
||||||
// now our shim owner might want to launch some kind of deferred beforehand, like
|
// now our shim owner might want to launch some kind of deferred beforehand, like
|
||||||
// a modal or something. in order to do this, we need to defer the passing
|
// a modal or something. in order to do this, we need to defer the passing
|
||||||
|
@ -15095,7 +15077,9 @@ GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var beforeDefer = Q.defer();
|
var beforeDefer = Q.defer();
|
||||||
beforeDefer.promise.then(passBaton);
|
beforeDefer.promise
|
||||||
|
.then(passBaton)
|
||||||
|
.done();
|
||||||
|
|
||||||
// if we didnt receive a defer handler in the options, this just
|
// if we didnt receive a defer handler in the options, this just
|
||||||
// resolves immediately
|
// resolves immediately
|
||||||
|
@ -15104,7 +15088,18 @@ GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||||
|
|
||||||
GitShim.prototype.afterGitCommandProcessed = function(command, deferred) {
|
GitShim.prototype.afterGitCommandProcessed = function(command, deferred) {
|
||||||
this.afterCB(command);
|
this.afterCB(command);
|
||||||
deferred.resolve();
|
|
||||||
|
// again we can't just resolve this deferred right away... our shim owner might
|
||||||
|
// want to insert some promise functionality before that happens. so again
|
||||||
|
// we make a defer
|
||||||
|
var afterDefer = Q.defer();
|
||||||
|
afterDefer.promise
|
||||||
|
.then(function() {
|
||||||
|
deferred.resolve();
|
||||||
|
})
|
||||||
|
.done();
|
||||||
|
|
||||||
|
this.afterDeferHandler(afterDefer);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.GitShim = GitShim;
|
exports.GitShim = GitShim;
|
||||||
|
@ -17014,6 +17009,42 @@ exports.DisabledMap = DisabledMap;
|
||||||
});
|
});
|
||||||
require("/src/js/level/disabledMap.js");
|
require("/src/js/level/disabledMap.js");
|
||||||
|
|
||||||
|
require.define("/src/js/level/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
var Q = require('q');
|
||||||
|
|
||||||
|
var util = require('../util');
|
||||||
|
var Main = require('../app');
|
||||||
|
|
||||||
|
var Visualization = require('../visuals/visualization').Visualization;
|
||||||
|
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
|
||||||
|
var DisabledMap = require('../level/disabledMap').DisabledMap;
|
||||||
|
var Command = require('../models/commandModel').Command;
|
||||||
|
var GitShim = require('../git/gitShim').GitShim;
|
||||||
|
|
||||||
|
var ModalTerminal = require('../views').ModalTerminal;
|
||||||
|
var ModalAlert = require('../views').ModalAlert;
|
||||||
|
|
||||||
|
var MultiView = require('../views/multiView').MultiView;
|
||||||
|
|
||||||
|
/*
|
||||||
|
this.beforeDeferHandler = function(deferred) {
|
||||||
|
var view = new MultiView({
|
||||||
|
});
|
||||||
|
view.getPromise()
|
||||||
|
.then(function() {
|
||||||
|
return Q.delay(700);
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
|
deferred.resolve();
|
||||||
|
})
|
||||||
|
.done();
|
||||||
|
};*/
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
require("/src/js/level/index.js");
|
||||||
|
|
||||||
require.define("/src/js/level/parseWaterfall.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
require.define("/src/js/level/parseWaterfall.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||||
|
|
||||||
var GitCommands = require('../git/commands');
|
var GitCommands = require('../git/commands');
|
||||||
|
@ -17114,7 +17145,8 @@ exports.ParseWaterfall = ParseWaterfall;
|
||||||
require("/src/js/level/parseWaterfall.js");
|
require("/src/js/level/parseWaterfall.js");
|
||||||
|
|
||||||
require.define("/src/js/level/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
require.define("/src/js/level/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||||
var Backbone = require('backbone');
|
// horrible hack to get localStorage Backbone plugin
|
||||||
|
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
|
||||||
|
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
|
@ -17130,85 +17162,91 @@ var ModalAlert = require('../views').ModalAlert;
|
||||||
|
|
||||||
var MultiView = require('../views/multiView').MultiView;
|
var MultiView = require('../views/multiView').MultiView;
|
||||||
|
|
||||||
function Sandbox(options) {
|
var Sandbox = Backbone.View.extend({
|
||||||
options = options || {};
|
// tag name here is purely vestigial. I made this a view
|
||||||
|
// simply to use inheritance and have a nice event system in place
|
||||||
|
tagName: 'div',
|
||||||
|
initialize: function(options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
this.mainVis = new Visualization({
|
this.mainVis = new Visualization({
|
||||||
el: options.el || $('#canvasWrapper')[0]
|
el: options.el || $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
// don't add it to just any collection -- adding to the
|
// don't add it to just any collection -- adding to the
|
||||||
// CommandUI collection will put in history
|
// CommandUI collection will put in history
|
||||||
this.commandCollection = Main.getCommandUI().commandCollection;
|
this.commandCollection = Main.getCommandUI().commandCollection;
|
||||||
|
|
||||||
this.parseWaterfall = new ParseWaterfall();
|
this.parseWaterfall = new ParseWaterfall();
|
||||||
|
/*
|
||||||
|
this.gitShim = new GitShim({
|
||||||
|
beforeCB: function() { console.log('before'); },
|
||||||
|
afterCB: function() { console.log('after'); }
|
||||||
|
});*/
|
||||||
|
|
||||||
this.gitShim = new GitShim({
|
/* DISBALED MAP example!!!
|
||||||
beforeCB: function() { console.log('before'); },
|
this.parseWaterfall.addFirst(
|
||||||
afterCB: function() { console.log('after'); }
|
'instantWaterfall',
|
||||||
});
|
new DisabledMap().getInstantCommands()
|
||||||
|
);*/
|
||||||
|
|
||||||
/* DISBALED MAP example!!!
|
if (!options.wait) {
|
||||||
this.parseWaterfall.addFirst(
|
this.takeControl();
|
||||||
'instantWaterfall',
|
}
|
||||||
new DisabledMap().getInstantCommands()
|
},
|
||||||
);*/
|
|
||||||
|
|
||||||
if (!options.defer) {
|
takeControl: function() {
|
||||||
this.takeControl();
|
// we will be handling commands that are submitted, mainly to add the sanadbox
|
||||||
|
// functionality (which is included by default in ParseWaterfall())
|
||||||
|
Main.getEventBaton().stealBaton('commandSubmitted', this.commandSubmitted, this);
|
||||||
|
// we obviously take care of sandbox commands
|
||||||
|
Main.getEventBaton().stealBaton('processSandboxCommand', this.processSandboxCommand, this);
|
||||||
|
|
||||||
|
// and our git shim
|
||||||
|
// TODO HACKY needs to be AFTER PAPER INITIALIZE dropped down from visualization wtf
|
||||||
|
if (this.gitShim) {
|
||||||
|
setTimeout(_.bind(function() {
|
||||||
|
this.gitShim.insertShim();
|
||||||
|
}, this), 1000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
commandSubmitted: function(value) {
|
||||||
|
// allow other things to see this command
|
||||||
|
Main.getEvents().trigger('commandSubmittedPassive', value);
|
||||||
|
|
||||||
|
util.splitTextCommand(value, function(command) {
|
||||||
|
this.commandCollection.add(new Command({
|
||||||
|
rawStr: command,
|
||||||
|
parseWaterfall: this.parseWaterfall
|
||||||
|
}));
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
processSandboxCommand: function(command, deferred) {
|
||||||
|
var commandMap = {
|
||||||
|
help: this.helpDialog
|
||||||
|
};
|
||||||
|
var method = commandMap[command.get('method')];
|
||||||
|
if (!method) { throw new Error('no method for that wut'); }
|
||||||
|
|
||||||
|
method.apply(this, [command, deferred]);
|
||||||
|
},
|
||||||
|
|
||||||
|
helpDialog: function(command, deferred) {
|
||||||
|
var helpDialog = new MultiView({
|
||||||
|
childViews: require('../dialogs/sandbox').helpDialog
|
||||||
|
});
|
||||||
|
helpDialog.getPromise().then(_.bind(function() {
|
||||||
|
// the view has been closed, lets go ahead and resolve our command
|
||||||
|
command.finishWith(deferred);
|
||||||
|
}, this))
|
||||||
|
.done();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
Sandbox.prototype.takeControl = function() {
|
|
||||||
// we will be handling commands that are submitted, mainly to add the sanadbox
|
|
||||||
// functionality (which is included by default in ParseWaterfall())
|
|
||||||
Main.getEventBaton().stealBaton('commandSubmitted', this.commandSubmitted, this);
|
|
||||||
// we obviously take care of sandbox commands
|
|
||||||
Main.getEventBaton().stealBaton('processSandboxCommand', this.processSandboxCommand, this);
|
|
||||||
|
|
||||||
// and our git shim
|
|
||||||
// TODO HACKY needs to be AFTER PAPER INITIALIZE dropped down from visualization wtf
|
|
||||||
setTimeout(_.bind(function() {
|
|
||||||
this.gitShim.insertShim();
|
|
||||||
}, this), 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sandbox.prototype.commandSubmitted = function(value) {
|
|
||||||
// allow other things to see this command
|
|
||||||
Main.getEvents().trigger('commandSubmittedPassive', value);
|
|
||||||
|
|
||||||
util.splitTextCommand(value, function(command) {
|
|
||||||
this.commandCollection.add(new Command({
|
|
||||||
rawStr: command,
|
|
||||||
parseWaterfall: this.parseWaterfall
|
|
||||||
}));
|
|
||||||
}, this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sandbox.prototype.processSandboxCommand = function(command, deferred) {
|
|
||||||
var commandMap = {
|
|
||||||
help: this.helpDialog
|
|
||||||
};
|
|
||||||
var method = commandMap[command.get('method')];
|
|
||||||
if (!method) { throw new Error('no method for that wut'); }
|
|
||||||
|
|
||||||
method.apply(this, [command, deferred]);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sandbox.prototype.helpDialog = function(command, deferred) {
|
|
||||||
var helpDialog = new MultiView({
|
|
||||||
childViews: require('../dialogs/sandbox').helpDialog
|
|
||||||
});
|
|
||||||
helpDialog.getPromise().then(_.bind(function() {
|
|
||||||
// the view has been closed, lets go ahead and resolve our command
|
|
||||||
command.finishWith(deferred);
|
|
||||||
}, this))
|
|
||||||
.done();
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Sandbox = Sandbox;
|
exports.Sandbox = Sandbox;
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
require("/src/js/level/sandbox.js");
|
require("/src/js/level/sandbox.js");
|
||||||
|
|
||||||
|
@ -18680,16 +18718,6 @@ var MultiView = Backbone.View.extend({
|
||||||
options: {
|
options: {
|
||||||
markdown: 'Woah wtf!!'
|
markdown: 'Woah wtf!!'
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
type: 'ModalAlert',
|
|
||||||
options: {
|
|
||||||
markdown: 'Im second'
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
type: 'ModalAlert',
|
|
||||||
options: {
|
|
||||||
markdown: 'Im second'
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
type: 'ModalAlert',
|
type: 'ModalAlert',
|
||||||
options: {
|
options: {
|
||||||
|
|
|
@ -20,20 +20,6 @@ function GitShim(options) {
|
||||||
};
|
};
|
||||||
this.beforeDeferHandler = options.beforeDeferHandler || resolveImmediately;
|
this.beforeDeferHandler = options.beforeDeferHandler || resolveImmediately;
|
||||||
this.afterDeferHandler = options.afterDeferHandler || resolveImmediately;
|
this.afterDeferHandler = options.afterDeferHandler || resolveImmediately;
|
||||||
|
|
||||||
this.beforeDeferHandler = function(deferred) {
|
|
||||||
var view = new MultiView({
|
|
||||||
});
|
|
||||||
view.getPromise()
|
|
||||||
.then(function() {
|
|
||||||
return Q.delay(700);
|
|
||||||
})
|
|
||||||
.then(function() {
|
|
||||||
deferred.resolve();
|
|
||||||
})
|
|
||||||
.done();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.eventBaton = options.eventBaton || Main.getEventBaton();
|
this.eventBaton = options.eventBaton || Main.getEventBaton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,17 +28,18 @@ GitShim.prototype.insertShim = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitShim.prototype.processGitCommand = function(command, deferred) {
|
GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||||
console.log('in before');
|
|
||||||
this.beforeCB(command);
|
this.beforeCB(command);
|
||||||
|
|
||||||
// ok we make a NEW deferred that will, upon resolution,
|
// ok we make a NEW deferred that will, upon resolution,
|
||||||
// call our afterGitCommandProcessed. This inserts the 'after' shim
|
// call our afterGitCommandProcessed. This inserts the 'after' shim
|
||||||
// functionality. we give this new deferred to the eventBaton handler
|
// functionality. we give this new deferred to the eventBaton handler
|
||||||
var newDeferred = Q.defer();
|
var newDeferred = Q.defer();
|
||||||
newDeferred.promise.then(_.bind(function() {
|
newDeferred.promise
|
||||||
|
.then(_.bind(function() {
|
||||||
// give this method the original defer so it can resolve it
|
// give this method the original defer so it can resolve it
|
||||||
this.afterGitCommandProcessed(command, deferred);
|
this.afterGitCommandProcessed(command, deferred);
|
||||||
}, this));
|
}, this))
|
||||||
|
.done();
|
||||||
|
|
||||||
// now our shim owner might want to launch some kind of deferred beforehand, like
|
// now our shim owner might want to launch some kind of deferred beforehand, like
|
||||||
// a modal or something. in order to do this, we need to defer the passing
|
// a modal or something. in order to do this, we need to defer the passing
|
||||||
|
@ -64,7 +51,9 @@ GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var beforeDefer = Q.defer();
|
var beforeDefer = Q.defer();
|
||||||
beforeDefer.promise.then(passBaton);
|
beforeDefer.promise
|
||||||
|
.then(passBaton)
|
||||||
|
.done();
|
||||||
|
|
||||||
// if we didnt receive a defer handler in the options, this just
|
// if we didnt receive a defer handler in the options, this just
|
||||||
// resolves immediately
|
// resolves immediately
|
||||||
|
@ -73,7 +62,18 @@ GitShim.prototype.processGitCommand = function(command, deferred) {
|
||||||
|
|
||||||
GitShim.prototype.afterGitCommandProcessed = function(command, deferred) {
|
GitShim.prototype.afterGitCommandProcessed = function(command, deferred) {
|
||||||
this.afterCB(command);
|
this.afterCB(command);
|
||||||
deferred.resolve();
|
|
||||||
|
// again we can't just resolve this deferred right away... our shim owner might
|
||||||
|
// want to insert some promise functionality before that happens. so again
|
||||||
|
// we make a defer
|
||||||
|
var afterDefer = Q.defer();
|
||||||
|
afterDefer.promise
|
||||||
|
.then(function() {
|
||||||
|
deferred.resolve();
|
||||||
|
})
|
||||||
|
.done();
|
||||||
|
|
||||||
|
this.afterDeferHandler(afterDefer);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.GitShim = GitShim;
|
exports.GitShim = GitShim;
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
var Q = require('q');
|
||||||
|
|
||||||
|
var util = require('../util');
|
||||||
|
var Main = require('../app');
|
||||||
|
|
||||||
|
var Visualization = require('../visuals/visualization').Visualization;
|
||||||
|
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
|
||||||
|
var DisabledMap = require('../level/disabledMap').DisabledMap;
|
||||||
|
var Command = require('../models/commandModel').Command;
|
||||||
|
var GitShim = require('../git/gitShim').GitShim;
|
||||||
|
|
||||||
|
var ModalTerminal = require('../views').ModalTerminal;
|
||||||
|
var ModalAlert = require('../views').ModalAlert;
|
||||||
|
|
||||||
|
var MultiView = require('../views/multiView').MultiView;
|
||||||
|
|
||||||
|
/*
|
||||||
|
this.beforeDeferHandler = function(deferred) {
|
||||||
|
var view = new MultiView({
|
||||||
|
});
|
||||||
|
view.getPromise()
|
||||||
|
.then(function() {
|
||||||
|
return Q.delay(700);
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
|
deferred.resolve();
|
||||||
|
})
|
||||||
|
.done();
|
||||||
|
};*/
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var Backbone = require('backbone');
|
// horrible hack to get localStorage Backbone plugin
|
||||||
|
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
|
||||||
|
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
|
@ -15,81 +16,87 @@ var ModalAlert = require('../views').ModalAlert;
|
||||||
|
|
||||||
var MultiView = require('../views/multiView').MultiView;
|
var MultiView = require('../views/multiView').MultiView;
|
||||||
|
|
||||||
function Sandbox(options) {
|
var Sandbox = Backbone.View.extend({
|
||||||
options = options || {};
|
// tag name here is purely vestigial. I made this a view
|
||||||
|
// simply to use inheritance and have a nice event system in place
|
||||||
|
tagName: 'div',
|
||||||
|
initialize: function(options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
this.mainVis = new Visualization({
|
this.mainVis = new Visualization({
|
||||||
el: options.el || $('#canvasWrapper')[0]
|
el: options.el || $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
// don't add it to just any collection -- adding to the
|
// don't add it to just any collection -- adding to the
|
||||||
// CommandUI collection will put in history
|
// CommandUI collection will put in history
|
||||||
this.commandCollection = Main.getCommandUI().commandCollection;
|
this.commandCollection = Main.getCommandUI().commandCollection;
|
||||||
|
|
||||||
this.parseWaterfall = new ParseWaterfall();
|
this.parseWaterfall = new ParseWaterfall();
|
||||||
|
/*
|
||||||
|
this.gitShim = new GitShim({
|
||||||
|
beforeCB: function() { console.log('before'); },
|
||||||
|
afterCB: function() { console.log('after'); }
|
||||||
|
});*/
|
||||||
|
|
||||||
this.gitShim = new GitShim({
|
/* DISBALED MAP example!!!
|
||||||
beforeCB: function() { console.log('before'); },
|
this.parseWaterfall.addFirst(
|
||||||
afterCB: function() { console.log('after'); }
|
'instantWaterfall',
|
||||||
});
|
new DisabledMap().getInstantCommands()
|
||||||
|
);*/
|
||||||
|
|
||||||
/* DISBALED MAP example!!!
|
if (!options.wait) {
|
||||||
this.parseWaterfall.addFirst(
|
this.takeControl();
|
||||||
'instantWaterfall',
|
}
|
||||||
new DisabledMap().getInstantCommands()
|
},
|
||||||
);*/
|
|
||||||
|
|
||||||
if (!options.defer) {
|
takeControl: function() {
|
||||||
this.takeControl();
|
// we will be handling commands that are submitted, mainly to add the sanadbox
|
||||||
|
// functionality (which is included by default in ParseWaterfall())
|
||||||
|
Main.getEventBaton().stealBaton('commandSubmitted', this.commandSubmitted, this);
|
||||||
|
// we obviously take care of sandbox commands
|
||||||
|
Main.getEventBaton().stealBaton('processSandboxCommand', this.processSandboxCommand, this);
|
||||||
|
|
||||||
|
// and our git shim
|
||||||
|
// TODO HACKY needs to be AFTER PAPER INITIALIZE dropped down from visualization wtf
|
||||||
|
if (this.gitShim) {
|
||||||
|
setTimeout(_.bind(function() {
|
||||||
|
this.gitShim.insertShim();
|
||||||
|
}, this), 1000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
commandSubmitted: function(value) {
|
||||||
|
// allow other things to see this command
|
||||||
|
Main.getEvents().trigger('commandSubmittedPassive', value);
|
||||||
|
|
||||||
|
util.splitTextCommand(value, function(command) {
|
||||||
|
this.commandCollection.add(new Command({
|
||||||
|
rawStr: command,
|
||||||
|
parseWaterfall: this.parseWaterfall
|
||||||
|
}));
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
processSandboxCommand: function(command, deferred) {
|
||||||
|
var commandMap = {
|
||||||
|
help: this.helpDialog
|
||||||
|
};
|
||||||
|
var method = commandMap[command.get('method')];
|
||||||
|
if (!method) { throw new Error('no method for that wut'); }
|
||||||
|
|
||||||
|
method.apply(this, [command, deferred]);
|
||||||
|
},
|
||||||
|
|
||||||
|
helpDialog: function(command, deferred) {
|
||||||
|
var helpDialog = new MultiView({
|
||||||
|
childViews: require('../dialogs/sandbox').helpDialog
|
||||||
|
});
|
||||||
|
helpDialog.getPromise().then(_.bind(function() {
|
||||||
|
// the view has been closed, lets go ahead and resolve our command
|
||||||
|
command.finishWith(deferred);
|
||||||
|
}, this))
|
||||||
|
.done();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
Sandbox.prototype.takeControl = function() {
|
|
||||||
// we will be handling commands that are submitted, mainly to add the sanadbox
|
|
||||||
// functionality (which is included by default in ParseWaterfall())
|
|
||||||
Main.getEventBaton().stealBaton('commandSubmitted', this.commandSubmitted, this);
|
|
||||||
// we obviously take care of sandbox commands
|
|
||||||
Main.getEventBaton().stealBaton('processSandboxCommand', this.processSandboxCommand, this);
|
|
||||||
|
|
||||||
// and our git shim
|
|
||||||
// TODO HACKY needs to be AFTER PAPER INITIALIZE dropped down from visualization wtf
|
|
||||||
setTimeout(_.bind(function() {
|
|
||||||
this.gitShim.insertShim();
|
|
||||||
}, this), 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sandbox.prototype.commandSubmitted = function(value) {
|
|
||||||
// allow other things to see this command
|
|
||||||
Main.getEvents().trigger('commandSubmittedPassive', value);
|
|
||||||
|
|
||||||
util.splitTextCommand(value, function(command) {
|
|
||||||
this.commandCollection.add(new Command({
|
|
||||||
rawStr: command,
|
|
||||||
parseWaterfall: this.parseWaterfall
|
|
||||||
}));
|
|
||||||
}, this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sandbox.prototype.processSandboxCommand = function(command, deferred) {
|
|
||||||
var commandMap = {
|
|
||||||
help: this.helpDialog
|
|
||||||
};
|
|
||||||
var method = commandMap[command.get('method')];
|
|
||||||
if (!method) { throw new Error('no method for that wut'); }
|
|
||||||
|
|
||||||
method.apply(this, [command, deferred]);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sandbox.prototype.helpDialog = function(command, deferred) {
|
|
||||||
var helpDialog = new MultiView({
|
|
||||||
childViews: require('../dialogs/sandbox').helpDialog
|
|
||||||
});
|
|
||||||
helpDialog.getPromise().then(_.bind(function() {
|
|
||||||
// the view has been closed, lets go ahead and resolve our command
|
|
||||||
command.finishWith(deferred);
|
|
||||||
}, this))
|
|
||||||
.done();
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Sandbox = Sandbox;
|
exports.Sandbox = Sandbox;
|
||||||
|
|
||||||
|
|
|
@ -30,16 +30,6 @@ var MultiView = Backbone.View.extend({
|
||||||
options: {
|
options: {
|
||||||
markdown: 'Woah wtf!!'
|
markdown: 'Woah wtf!!'
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
type: 'ModalAlert',
|
|
||||||
options: {
|
|
||||||
markdown: 'Im second'
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
type: 'ModalAlert',
|
|
||||||
options: {
|
|
||||||
markdown: 'Im second'
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
type: 'ModalAlert',
|
type: 'ModalAlert',
|
||||||
options: {
|
options: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue