mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 07:58:34 +02:00
able to open up views now from comand line
This commit is contained in:
parent
4aeb56c840
commit
764fbf63bc
9 changed files with 813 additions and 643 deletions
1381
build/bundle.js
1381
build/bundle.js
File diff suppressed because it is too large
Load diff
|
@ -4,16 +4,13 @@ var Backbone = require('backbone');
|
|||
var Constants = require('../util/constants');
|
||||
var Views = require('../views');
|
||||
var util = require('../util');
|
||||
var Command = require('../models/commandModel').Command;
|
||||
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
|
||||
var DisabledMap = require('../level/disabledMap').DisabledMap;
|
||||
|
||||
/**
|
||||
* Globals
|
||||
*/
|
||||
var events = _.clone(Backbone.Events);
|
||||
var commandUI;
|
||||
var mainVis;
|
||||
var sandbox;
|
||||
var eventBaton;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
@ -28,14 +25,12 @@ var init = function() {
|
|||
* - initializing the command input bar
|
||||
* - handling window.focus and zoom events
|
||||
**/
|
||||
var Visualization = require('../visuals/visualization').Visualization;
|
||||
var Sandbox = require('../level/sandbox').Sandbox;
|
||||
var EventBaton = require('../util/eventBaton').EventBaton;
|
||||
|
||||
eventBaton = new EventBaton();
|
||||
commandUI = new CommandUI();
|
||||
mainVis = new Visualization({
|
||||
el: $('#canvasWrapper')[0]
|
||||
});
|
||||
sandbox = new Sandbox();
|
||||
|
||||
// we always want to focus the text area to collect input
|
||||
var focusTextArea = function() {
|
||||
|
@ -113,38 +108,23 @@ function CommandUI() {
|
|||
el: $('#commandLineHistory'),
|
||||
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() {
|
||||
return events;
|
||||
};
|
||||
|
||||
exports.getUI = function() {
|
||||
return commandUI;
|
||||
};
|
||||
|
||||
exports.getMainVis = function() {
|
||||
return mainVis;
|
||||
exports.getSandbox = function() {
|
||||
return sandbox;
|
||||
};
|
||||
|
||||
exports.getEventBaton = function() {
|
||||
return eventBaton;
|
||||
};
|
||||
|
||||
exports.getCommandUI = function() {
|
||||
return commandUI;
|
||||
}
|
||||
|
||||
exports.init = init;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ var parse = function(str) {
|
|||
options = str.slice(thisMethod.length + 1);
|
||||
method = thisMethod.slice('git '.length);
|
||||
}
|
||||
}, this);
|
||||
});
|
||||
|
||||
if (!method) {
|
||||
return false;
|
||||
|
|
|
@ -1356,7 +1356,6 @@ GitEngine.prototype.dispatch = function(command, callback) {
|
|||
callback: whenDone
|
||||
});
|
||||
|
||||
command.set('status', 'processing');
|
||||
try {
|
||||
var methodName = command.get('method').replace(/-/g, '') + 'Starter';
|
||||
this[methodName]();
|
||||
|
|
|
@ -16,7 +16,8 @@ function ParseWaterfall(options) {
|
|||
];
|
||||
|
||||
this.parseWaterfall = options.parseWaterfall || [
|
||||
GitCommands.parse
|
||||
GitCommands.parse,
|
||||
SandboxCommands.parse
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -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.parse = parse;
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@ var CommandBuffer = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
processCommand: function(command) {
|
||||
command.set('status', 'processing');
|
||||
|
||||
var callback = _.bind(function() {
|
||||
this.setTimeout();
|
||||
}, this);
|
||||
|
|
|
@ -25,7 +25,7 @@ _.each(toGlobalize, function(module) {
|
|||
|
||||
$(document).ready(function() {
|
||||
window.events = toGlobalize.Main.getEvents();
|
||||
window.mainVis = toGlobalize.Main.getMainVis();
|
||||
window.ui = toGlobalize.Main.getMainVis();
|
||||
window.eventBaton = toGlobalize.Main.getEventBaton();
|
||||
window.sandbox = toGlobalize.Main.getSandbox();
|
||||
});
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ var setupZoomPoll = function(callback, context) {
|
|||
currentZoom = newZoom;
|
||||
callback.apply(context, [newZoom]);
|
||||
}
|
||||
}, 100);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
exports.setupZoomPoll = setupZoomPoll;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue