able to open up views now from comand line

This commit is contained in:
Peter Cottle 2013-01-02 11:57:16 -08:00
parent 4aeb56c840
commit 764fbf63bc
9 changed files with 813 additions and 643 deletions

File diff suppressed because it is too large Load diff

View file

@ -4,16 +4,13 @@ var Backbone = require('backbone');
var Constants = require('../util/constants'); var Constants = require('../util/constants');
var Views = require('../views'); var Views = require('../views');
var util = require('../util'); var util = require('../util');
var Command = require('../models/commandModel').Command;
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
var DisabledMap = require('../level/disabledMap').DisabledMap;
/** /**
* Globals * Globals
*/ */
var events = _.clone(Backbone.Events); var events = _.clone(Backbone.Events);
var commandUI; var commandUI;
var mainVis; var sandbox;
var eventBaton; var eventBaton;
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
@ -28,14 +25,12 @@ var init = function() {
* - initializing the command input bar * - initializing the command input bar
* - handling window.focus and zoom events * - handling window.focus and zoom events
**/ **/
var Visualization = require('../visuals/visualization').Visualization; var Sandbox = require('../level/sandbox').Sandbox;
var EventBaton = require('../util/eventBaton').EventBaton; var EventBaton = require('../util/eventBaton').EventBaton;
eventBaton = new EventBaton(); eventBaton = new EventBaton();
commandUI = new CommandUI(); commandUI = new CommandUI();
mainVis = new Visualization({ sandbox = new Sandbox();
el: $('#canvasWrapper')[0]
});
// we always want to focus the text area to collect input // we always want to focus the text area to collect input
var focusTextArea = function() { var focusTextArea = function() {
@ -113,38 +108,23 @@ function CommandUI() {
el: $('#commandLineHistory'), el: $('#commandLineHistory'),
collection: this.commandCollection collection: this.commandCollection
}); });
this.parseWaterfall = new ParseWaterfall();
this.parseWaterfall.addFirst('instantWaterfall', new DisabledMap().getInstantCommands());
eventBaton.stealBaton('commandSubmitted', this.commandSubmitted, this);
} }
CommandUI.prototype.commandSubmitted = function(value) {
events.trigger('commandSubmittedPassive', value);
util.splitTextCommand(value, function(command) {
this.commandCollection.add(new Command({
rawStr: command,
parseWaterfall: this.parseWaterfall
}));
}, this);
};
exports.getEvents = function() { exports.getEvents = function() {
return events; return events;
}; };
exports.getUI = function() { exports.getSandbox = function() {
return commandUI; return sandbox;
};
exports.getMainVis = function() {
return mainVis;
}; };
exports.getEventBaton = function() { exports.getEventBaton = function() {
return eventBaton; return eventBaton;
}; };
exports.getCommandUI = function() {
return commandUI;
}
exports.init = init; exports.init = init;

View file

@ -73,7 +73,7 @@ var parse = function(str) {
options = str.slice(thisMethod.length + 1); options = str.slice(thisMethod.length + 1);
method = thisMethod.slice('git '.length); method = thisMethod.slice('git '.length);
} }
}, this); });
if (!method) { if (!method) {
return false; return false;

View file

@ -1356,7 +1356,6 @@ GitEngine.prototype.dispatch = function(command, callback) {
callback: whenDone callback: whenDone
}); });
command.set('status', 'processing');
try { try {
var methodName = command.get('method').replace(/-/g, '') + 'Starter'; var methodName = command.get('method').replace(/-/g, '') + 'Starter';
this[methodName](); this[methodName]();

View file

@ -16,7 +16,8 @@ function ParseWaterfall(options) {
]; ];
this.parseWaterfall = options.parseWaterfall || [ this.parseWaterfall = options.parseWaterfall || [
GitCommands.parse GitCommands.parse,
SandboxCommands.parse
]; ];
} }

View file

@ -39,4 +39,27 @@ var instantCommands = [
}] }]
]; ];
var regexMap = {
'help': /^help($|\s)|\?/
};
var parse = function(str) {
var sandboxMethod;
_.each(regexMap, function(regex, method) {
if (regex.test(str)) {
sandboxMethod = method;
}
});
return (!sandboxMethod) ? false : {
toSet: {
eventName: 'processSandboxCommand',
method: sandboxMethod
}
};
};
exports.instantCommands = instantCommands; exports.instantCommands = instantCommands;
exports.parse = parse;

View file

@ -77,6 +77,8 @@ var CommandBuffer = Backbone.Model.extend({
}, },
processCommand: function(command) { processCommand: function(command) {
command.set('status', 'processing');
var callback = _.bind(function() { var callback = _.bind(function() {
this.setTimeout(); this.setTimeout();
}, this); }, this);

View file

@ -25,7 +25,7 @@ _.each(toGlobalize, function(module) {
$(document).ready(function() { $(document).ready(function() {
window.events = toGlobalize.Main.getEvents(); window.events = toGlobalize.Main.getEvents();
window.mainVis = toGlobalize.Main.getMainVis(); window.eventBaton = toGlobalize.Main.getEventBaton();
window.ui = toGlobalize.Main.getMainVis(); window.sandbox = toGlobalize.Main.getSandbox();
}); });

View file

@ -30,7 +30,7 @@ var setupZoomPoll = function(callback, context) {
currentZoom = newZoom; currentZoom = newZoom;
callback.apply(context, [newZoom]); callback.apply(context, [newZoom]);
} }
}, 100); }, 500);
}; };
exports.setupZoomPoll = setupZoomPoll; exports.setupZoomPoll = setupZoomPoll;