mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 07:58:34 +02:00
awesome
This commit is contained in:
parent
764fbf63bc
commit
de9d91773a
8 changed files with 461 additions and 270 deletions
585
build/bundle.js
585
build/bundle.js
|
@ -4601,7 +4601,7 @@ var ModalView = Backbone.View.extend({
|
|||
console.log('window focus doing nothing', e);
|
||||
},
|
||||
|
||||
documentClick: function(e) {
|
||||
onDocumentClick: function(e) {
|
||||
console.log('doc click doing nothing', e);
|
||||
},
|
||||
|
||||
|
@ -4964,7 +4964,7 @@ exports.getEventBaton = function() {
|
|||
|
||||
exports.getCommandUI = function() {
|
||||
return commandUI;
|
||||
}
|
||||
};
|
||||
|
||||
exports.init = init;
|
||||
|
||||
|
@ -4983,11 +4983,10 @@ var DisabledMap = require('../level/disabledMap').DisabledMap;
|
|||
var Command = require('../models/commandModel').Command;
|
||||
|
||||
var ModalTerminal = require('../views').ModalTerminal;
|
||||
var ContainedBase = require('../views').ContainedBase;
|
||||
var ConfirmCancelView = require('../views').ConfirmCancelView;
|
||||
var LeftRightView = require('../views').LeftRightView;
|
||||
var ModalAlert = require('../views').ModalAlert;
|
||||
|
||||
var MultiView = require('../views/multiView').MultiView;
|
||||
|
||||
function Sandbox(options) {
|
||||
options = options || {};
|
||||
|
||||
|
@ -5038,14 +5037,20 @@ Sandbox.prototype.processSandboxCommand = function(command, callback) {
|
|||
};
|
||||
|
||||
Sandbox.prototype.helpDialog = function(command, callback) {
|
||||
var a = new ModalAlert({
|
||||
markdown: '#wutttt'
|
||||
var helpDialog = new MultiView({
|
||||
childViews: require('../dialogs/sandbox').helpDialog
|
||||
});
|
||||
a.show();
|
||||
helpDialog.getPromise().then(_.bind(function() {
|
||||
// the view has been closed, lets go ahead and resolve our command
|
||||
command.set('status', 'finished');
|
||||
callback();
|
||||
}, this))
|
||||
.done();
|
||||
};
|
||||
|
||||
exports.Sandbox = Sandbox;
|
||||
|
||||
|
||||
});
|
||||
|
||||
require.define("/src/js/visuals/visualization.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||
|
@ -11549,6 +11554,267 @@ DisabledMap.prototype.getInstantCommands = function() {
|
|||
exports.DisabledMap = DisabledMap;
|
||||
|
||||
|
||||
});
|
||||
|
||||
require.define("/src/js/views/multiView.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError;
|
||||
var _ = require('underscore');
|
||||
var Q = require('q');
|
||||
// horrible hack to get localStorage Backbone plugin
|
||||
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
|
||||
|
||||
var ModalTerminal = require('../views').ModalTerminal;
|
||||
var ContainedBase = require('../views').ContainedBase;
|
||||
var ConfirmCancelView = require('../views').ConfirmCancelView;
|
||||
var LeftRightView = require('../views').LeftRightView;
|
||||
var ModalAlert = require('../views').ModalAlert;
|
||||
var KeyboardListener = require('../util/keyboard').KeyboardListener;
|
||||
|
||||
var MultiView = Backbone.View.extend({
|
||||
tagName: 'div',
|
||||
className: 'multiView',
|
||||
// ms to debounce the nav functions
|
||||
navEventDebounce: 750,
|
||||
deathTime: 700,
|
||||
|
||||
// a simple mapping of what childViews we support
|
||||
typeToConstructor: {
|
||||
ModalAlert: ModalAlert
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
this.childViewJSONs = options.childViews || [{
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdown: 'Woah wtf!!'
|
||||
}
|
||||
}, {
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdown: 'Im second'
|
||||
}
|
||||
}, {
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdown: 'Im second'
|
||||
}
|
||||
}, {
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdown: 'Im second'
|
||||
}
|
||||
}];
|
||||
this.deferred = Q.defer();
|
||||
|
||||
this.childViews = [];
|
||||
this.currentIndex = 0;
|
||||
|
||||
this.navEvents = _.clone(Backbone.Events);
|
||||
this.navEvents.on('negative', this.getNegFunc(), this);
|
||||
this.navEvents.on('positive', this.getPosFunc(), this);
|
||||
|
||||
this.keyboardListener = new KeyboardListener({
|
||||
events: this.navEvents,
|
||||
aliasMap: {
|
||||
left: 'negative',
|
||||
right: 'positive',
|
||||
enter: 'positive'
|
||||
}
|
||||
});
|
||||
|
||||
this.render();
|
||||
if (!options.wait) {
|
||||
this.start();
|
||||
}
|
||||
},
|
||||
|
||||
onWindowFocus: function() {
|
||||
// nothing here for now...
|
||||
},
|
||||
|
||||
getPromise: function() {
|
||||
return this.deferred.promise;
|
||||
},
|
||||
|
||||
getPosFunc: function() {
|
||||
return _.debounce(_.bind(function() {
|
||||
this.navForward();
|
||||
}, this), this.navEventDebounce, true);
|
||||
},
|
||||
|
||||
getNegFunc: function() {
|
||||
return _.debounce(_.bind(function() {
|
||||
this.navBackward();
|
||||
}, this), this.navEventDebounce, true);
|
||||
},
|
||||
|
||||
navForward: function() {
|
||||
if (this.currentIndex === this.childViews.length - 1) {
|
||||
this.hideViewIndex(this.currentIndex);
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
this.navIndexChange(1);
|
||||
},
|
||||
|
||||
navBackward: function() {
|
||||
if (this.currentIndex === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.navIndexChange(-1);
|
||||
},
|
||||
|
||||
navIndexChange: function(delta) {
|
||||
this.hideViewIndex(this.currentIndex);
|
||||
this.currentIndex += delta;
|
||||
this.showViewIndex(this.currentIndex);
|
||||
},
|
||||
|
||||
hideViewIndex: function(index) {
|
||||
this.childViews[index].hide();
|
||||
},
|
||||
|
||||
showViewIndex: function(index) {
|
||||
this.childViews[index].show();
|
||||
},
|
||||
|
||||
finish: function() {
|
||||
// first we stop listening to keyboard and give that back to UI, which
|
||||
// other views will take if they need to
|
||||
this.keyboardListener.mute();
|
||||
|
||||
_.each(this.childViews, function(childView) {
|
||||
childView.die();
|
||||
});
|
||||
|
||||
this.deferred.resolve();
|
||||
},
|
||||
|
||||
start: function() {
|
||||
// steal the window focus baton
|
||||
this.showViewIndex(this.currentIndex);
|
||||
},
|
||||
|
||||
createChildView: function(viewJSON) {
|
||||
var type = viewJSON.type;
|
||||
if (!this.typeToConstructor[type]) {
|
||||
throw new Error('no constructor for type "' + type + '"');
|
||||
}
|
||||
var view = new this.typeToConstructor[type](viewJSON.options);
|
||||
return view;
|
||||
},
|
||||
|
||||
addNavToView: function(view, index) {
|
||||
var leftRight = new LeftRightView({
|
||||
events: this.navEvents,
|
||||
// we want the arrows to be on the same level as the content (not
|
||||
// beneath), so we go one level up with getDestination()
|
||||
destination: view.getDestination(),
|
||||
showLeft: (index !== 0),
|
||||
lastNav: (index === this.childViewJSONs.length - 1)
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
// go through each and render... show the first
|
||||
_.each(this.childViewJSONs, function(childViewJSON, index) {
|
||||
var childView = this.createChildView(childViewJSON);
|
||||
this.childViews.push(childView);
|
||||
this.addNavToView(childView, index);
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
|
||||
exports.MultiView = MultiView;
|
||||
|
||||
|
||||
});
|
||||
|
||||
require.define("/src/js/util/keyboard.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
var mapKeycodeToKey = function(keycode) {
|
||||
// TODO -- internationalize? Dvorak? I have no idea
|
||||
var keyMap = {
|
||||
37: 'left',
|
||||
38: 'up',
|
||||
39: 'right',
|
||||
40: 'down',
|
||||
27: 'esc',
|
||||
13: 'enter'
|
||||
};
|
||||
return keyMap[keycode];
|
||||
};
|
||||
|
||||
function KeyboardListener(options) {
|
||||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
this.keydownListener = _.bind(this.keydown, this);
|
||||
this.listen();
|
||||
}
|
||||
|
||||
KeyboardListener.prototype.listen = function() {
|
||||
$(document).bind('keydown', this.keydownListener);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.mute = function() {
|
||||
$(document).unbind('keydown', this.keydownListener);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.keydown = function(e) {
|
||||
var which = e.which;
|
||||
|
||||
var key = mapKeycodeToKey(which);
|
||||
if (key === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.fireEvent(key);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.fireEvent = function(eventName) {
|
||||
eventName = this.aliasMap[eventName] || eventName;
|
||||
this.events.trigger(eventName);
|
||||
};
|
||||
|
||||
exports.KeyboardListener = KeyboardListener;
|
||||
exports.mapKeycodeToKey = mapKeycodeToKey;
|
||||
|
||||
|
||||
});
|
||||
|
||||
require.define("/src/js/dialogs/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){exports.helpDialog = [{
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdowns: [
|
||||
'## Welcome to LearnGitBranching!',
|
||||
'',
|
||||
'This application is designed to help beginners grasp ',
|
||||
'the powerful concepts behind branching when working ',
|
||||
'with git. We hope you enjoy this application and maybe ',
|
||||
'even learn something!',
|
||||
''
|
||||
]
|
||||
}
|
||||
}, {
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdowns: [
|
||||
'## The LearnGitBranching Interface',
|
||||
'',
|
||||
'There are features to use within the user interface behind ',
|
||||
'this modal dialog. A list:',
|
||||
'',
|
||||
' * git commands (to interact with git)',
|
||||
' * level commands (to get level hints or solutions)',
|
||||
' * sandbox commands (like this one)'
|
||||
]
|
||||
}
|
||||
}];
|
||||
|
||||
});
|
||||
|
||||
require.define("/src/js/util/eventBaton.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||
|
@ -11562,6 +11828,7 @@ function EventBaton() {
|
|||
// EventBaton.prototype.on = function(name, func, context) {
|
||||
EventBaton.prototype.stealBaton = function(name, func, context) {
|
||||
if (!name) { throw new Error('need name'); }
|
||||
if (!func) { throw new Error('need func!'); }
|
||||
|
||||
var listeners = this.eventMap[name] || [];
|
||||
listeners.push({
|
||||
|
@ -11599,7 +11866,8 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
var newListeners = [];
|
||||
var found = false;
|
||||
_.each(listeners, function(listenerObj) {
|
||||
if (listenerObj.func === func) {
|
||||
if (listenerObj.func === func && listenerObj.context === context) {
|
||||
if (found) { console.warn('woah duplicates!!!'); }
|
||||
found = true;
|
||||
} else {
|
||||
newListeners.push(listenerObj);
|
||||
|
@ -11607,7 +11875,8 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
}, this);
|
||||
|
||||
if (!found) {
|
||||
throw new Error('did not find that function', func, context, name, arguments);
|
||||
console.log('did not find that function', func, context, name, arguments);
|
||||
throw new Error('cant releasebaton if yu dont have it');
|
||||
}
|
||||
this.eventMap[name] = newListeners;
|
||||
};
|
||||
|
@ -12019,60 +12288,6 @@ var CommandLineHistoryView = Backbone.View.extend({
|
|||
exports.CommandPromptView = CommandPromptView;
|
||||
exports.CommandLineHistoryView = CommandLineHistoryView;
|
||||
|
||||
});
|
||||
|
||||
require.define("/src/js/util/keyboard.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
var mapKeycodeToKey = function(keycode) {
|
||||
// TODO -- internationalize? Dvorak? I have no idea
|
||||
var keyMap = {
|
||||
37: 'left',
|
||||
38: 'up',
|
||||
39: 'right',
|
||||
40: 'down',
|
||||
27: 'esc',
|
||||
13: 'enter'
|
||||
};
|
||||
return keyMap[keycode];
|
||||
};
|
||||
|
||||
function KeyboardListener(options) {
|
||||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
this.keydownListener = _.bind(this.keydown, this);
|
||||
this.listen();
|
||||
}
|
||||
|
||||
KeyboardListener.prototype.listen = function() {
|
||||
$(document).bind('keydown', this.keydownListener);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.mute = function() {
|
||||
$(document).unbind('keydown', this.keydownListener);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.keydown = function(e) {
|
||||
var which = e.which;
|
||||
|
||||
var key = mapKeycodeToKey(which);
|
||||
if (key === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.fireEvent(key);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.fireEvent = function(eventName) {
|
||||
eventName = this.aliasMap[eventName] || eventName;
|
||||
this.events.trigger(eventName);
|
||||
};
|
||||
|
||||
exports.KeyboardListener = KeyboardListener;
|
||||
exports.mapKeycodeToKey = mapKeycodeToKey;
|
||||
|
||||
|
||||
});
|
||||
|
||||
require.define("/node_modules/markdown/package.json",function(require,module,exports,__dirname,__filename,process,global){module.exports = {"main":"./lib/index.js"}
|
||||
|
@ -14305,182 +14520,6 @@ HeadlessGit.prototype.sendCommand = function(value) {
|
|||
exports.HeadlessGit = HeadlessGit;
|
||||
|
||||
|
||||
});
|
||||
|
||||
require.define("/src/js/views/multiView.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError;
|
||||
var _ = require('underscore');
|
||||
var Q = require('q');
|
||||
// horrible hack to get localStorage Backbone plugin
|
||||
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
|
||||
|
||||
var ModalTerminal = require('../views').ModalTerminal;
|
||||
var ContainedBase = require('../views').ContainedBase;
|
||||
var ConfirmCancelView = require('../views').ConfirmCancelView;
|
||||
var LeftRightView = require('../views').LeftRightView;
|
||||
var ModalAlert = require('../views').ModalAlert;
|
||||
var KeyboardListener = require('../util/keyboard').KeyboardListener;
|
||||
|
||||
var MultiView = Backbone.View.extend({
|
||||
tagName: 'div',
|
||||
className: 'multiView',
|
||||
// ms to debounce the nav functions
|
||||
navEventDebounce: 750,
|
||||
deathTime: 700,
|
||||
|
||||
// a simple mapping of what childViews we support
|
||||
typeToConstructor: {
|
||||
ModalAlert: ModalAlert
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
this.childViewJSONs = options.childViews || [{
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdown: 'Woah wtf!!'
|
||||
}
|
||||
}, {
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdown: 'Im second'
|
||||
}
|
||||
}, {
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdown: 'Im second'
|
||||
}
|
||||
}, {
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdown: 'Im second'
|
||||
}
|
||||
}];
|
||||
this.deferred = Q.defer();
|
||||
|
||||
this.childViews = [];
|
||||
this.currentIndex = 0;
|
||||
|
||||
this.navEvents = _.clone(Backbone.Events);
|
||||
this.navEvents.on('negative', this.getNegFunc(), this);
|
||||
this.navEvents.on('positive', this.getPosFunc(), this);
|
||||
|
||||
this.keyboardListener = new KeyboardListener({
|
||||
events: this.navEvents,
|
||||
aliasMap: {
|
||||
left: 'negative',
|
||||
right: 'positive',
|
||||
enter: 'positive'
|
||||
}
|
||||
});
|
||||
|
||||
this.render();
|
||||
this.start();
|
||||
},
|
||||
|
||||
onWindowFocus: function() {
|
||||
// nothing here for now...
|
||||
},
|
||||
|
||||
getPromise: function() {
|
||||
return this.deferred.promise;
|
||||
},
|
||||
|
||||
getPosFunc: function() {
|
||||
return _.debounce(_.bind(function() {
|
||||
this.navForward();
|
||||
}, this), this.navEventDebounce, true);
|
||||
},
|
||||
|
||||
getNegFunc: function() {
|
||||
return _.debounce(_.bind(function() {
|
||||
this.navBackward();
|
||||
}, this), this.navEventDebounce, true);
|
||||
},
|
||||
|
||||
navForward: function() {
|
||||
if (this.currentIndex === this.childViews.length - 1) {
|
||||
this.hideViewIndex(this.currentIndex);
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
this.navIndexChange(1);
|
||||
},
|
||||
|
||||
navBackward: function() {
|
||||
if (this.currentIndex === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.navIndexChange(-1);
|
||||
},
|
||||
|
||||
navIndexChange: function(delta) {
|
||||
this.hideViewIndex(this.currentIndex);
|
||||
this.currentIndex += delta;
|
||||
this.showViewIndex(this.currentIndex);
|
||||
},
|
||||
|
||||
hideViewIndex: function(index) {
|
||||
this.childViews[index].hide();
|
||||
},
|
||||
|
||||
showViewIndex: function(index) {
|
||||
this.childViews[index].show();
|
||||
},
|
||||
|
||||
finish: function() {
|
||||
// first we stop listening to keyboard and give that back to UI, which
|
||||
// other views will take if they need to
|
||||
this.keyboardListener.mute();
|
||||
|
||||
setTimeout(_.bind(function() {
|
||||
_.each(this.childViews, function(childView) {
|
||||
childView.tearDown();
|
||||
});
|
||||
}, this), this.deathTime);
|
||||
|
||||
this.deferred.resolve();
|
||||
},
|
||||
|
||||
start: function() {
|
||||
// steal the window focus baton
|
||||
this.showViewIndex(this.currentIndex);
|
||||
},
|
||||
|
||||
createChildView: function(viewJSON) {
|
||||
var type = viewJSON.type;
|
||||
if (!this.typeToConstructor[type]) {
|
||||
throw new Error('no constructor for type "' + type + '"');
|
||||
}
|
||||
var view = new this.typeToConstructor[type](viewJSON.options);
|
||||
return view;
|
||||
},
|
||||
|
||||
addNavToView: function(view, index) {
|
||||
var leftRight = new LeftRightView({
|
||||
events: this.navEvents,
|
||||
// we want the arrows to be on the same level as the content (not
|
||||
// beneath), so we go one level up with getDestination()
|
||||
destination: view.getDestination(),
|
||||
showLeft: (index !== 0),
|
||||
lastNav: (index === this.childViewJSONs.length - 1)
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
// go through each and render... show the first
|
||||
_.each(this.childViewJSONs, function(childViewJSON, index) {
|
||||
var childView = this.createChildView(childViewJSON);
|
||||
this.childViews.push(childView);
|
||||
this.addNavToView(childView, index);
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
|
||||
exports.MultiView = MultiView;
|
||||
|
||||
|
||||
});
|
||||
|
||||
require.define("/src/js/app/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||
|
@ -14609,7 +14648,7 @@ exports.getEventBaton = function() {
|
|||
|
||||
exports.getCommandUI = function() {
|
||||
return commandUI;
|
||||
}
|
||||
};
|
||||
|
||||
exports.init = init;
|
||||
|
||||
|
@ -14617,6 +14656,38 @@ exports.init = init;
|
|||
});
|
||||
require("/src/js/app/index.js");
|
||||
|
||||
require.define("/src/js/dialogs/sandbox.js",function(require,module,exports,__dirname,__filename,process,global){exports.helpDialog = [{
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdowns: [
|
||||
'## Welcome to LearnGitBranching!',
|
||||
'',
|
||||
'This application is designed to help beginners grasp ',
|
||||
'the powerful concepts behind branching when working ',
|
||||
'with git. We hope you enjoy this application and maybe ',
|
||||
'even learn something!',
|
||||
''
|
||||
]
|
||||
}
|
||||
}, {
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdowns: [
|
||||
'## The LearnGitBranching Interface',
|
||||
'',
|
||||
'There are features to use within the user interface behind ',
|
||||
'this modal dialog. A list:',
|
||||
'',
|
||||
' * git commands (to interact with git)',
|
||||
' * level commands (to get level hints or solutions)',
|
||||
' * sandbox commands (like this one)'
|
||||
]
|
||||
}
|
||||
}];
|
||||
|
||||
});
|
||||
require("/src/js/dialogs/sandbox.js");
|
||||
|
||||
require.define("/src/js/git/commands.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||
|
||||
var Errors = require('../util/errors');
|
||||
|
@ -16818,11 +16889,10 @@ var DisabledMap = require('../level/disabledMap').DisabledMap;
|
|||
var Command = require('../models/commandModel').Command;
|
||||
|
||||
var ModalTerminal = require('../views').ModalTerminal;
|
||||
var ContainedBase = require('../views').ContainedBase;
|
||||
var ConfirmCancelView = require('../views').ConfirmCancelView;
|
||||
var LeftRightView = require('../views').LeftRightView;
|
||||
var ModalAlert = require('../views').ModalAlert;
|
||||
|
||||
var MultiView = require('../views/multiView').MultiView;
|
||||
|
||||
function Sandbox(options) {
|
||||
options = options || {};
|
||||
|
||||
|
@ -16873,14 +16943,20 @@ Sandbox.prototype.processSandboxCommand = function(command, callback) {
|
|||
};
|
||||
|
||||
Sandbox.prototype.helpDialog = function(command, callback) {
|
||||
var a = new ModalAlert({
|
||||
markdown: '#wutttt'
|
||||
var helpDialog = new MultiView({
|
||||
childViews: require('../dialogs/sandbox').helpDialog
|
||||
});
|
||||
a.show();
|
||||
helpDialog.getPromise().then(_.bind(function() {
|
||||
// the view has been closed, lets go ahead and resolve our command
|
||||
command.set('status', 'finished');
|
||||
callback();
|
||||
}, this))
|
||||
.done();
|
||||
};
|
||||
|
||||
exports.Sandbox = Sandbox;
|
||||
|
||||
|
||||
});
|
||||
require("/src/js/level/sandbox.js");
|
||||
|
||||
|
@ -17410,6 +17486,7 @@ function EventBaton() {
|
|||
// EventBaton.prototype.on = function(name, func, context) {
|
||||
EventBaton.prototype.stealBaton = function(name, func, context) {
|
||||
if (!name) { throw new Error('need name'); }
|
||||
if (!func) { throw new Error('need func!'); }
|
||||
|
||||
var listeners = this.eventMap[name] || [];
|
||||
listeners.push({
|
||||
|
@ -17447,7 +17524,8 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
var newListeners = [];
|
||||
var found = false;
|
||||
_.each(listeners, function(listenerObj) {
|
||||
if (listenerObj.func === func) {
|
||||
if (listenerObj.func === func && listenerObj.context === context) {
|
||||
if (found) { console.warn('woah duplicates!!!'); }
|
||||
found = true;
|
||||
} else {
|
||||
newListeners.push(listenerObj);
|
||||
|
@ -17455,7 +17533,8 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
}, this);
|
||||
|
||||
if (!found) {
|
||||
throw new Error('did not find that function', func, context, name, arguments);
|
||||
console.log('did not find that function', func, context, name, arguments);
|
||||
throw new Error('cant releasebaton if yu dont have it');
|
||||
}
|
||||
this.eventMap[name] = newListeners;
|
||||
};
|
||||
|
@ -18129,7 +18208,7 @@ var ModalView = Backbone.View.extend({
|
|||
console.log('window focus doing nothing', e);
|
||||
},
|
||||
|
||||
documentClick: function(e) {
|
||||
onDocumentClick: function(e) {
|
||||
console.log('doc click doing nothing', e);
|
||||
},
|
||||
|
||||
|
@ -18344,7 +18423,9 @@ var MultiView = Backbone.View.extend({
|
|||
});
|
||||
|
||||
this.render();
|
||||
if (!options.wait) {
|
||||
this.start();
|
||||
}
|
||||
},
|
||||
|
||||
onWindowFocus: function() {
|
||||
|
@ -18404,11 +18485,9 @@ var MultiView = Backbone.View.extend({
|
|||
// other views will take if they need to
|
||||
this.keyboardListener.mute();
|
||||
|
||||
setTimeout(_.bind(function() {
|
||||
_.each(this.childViews, function(childView) {
|
||||
childView.tearDown();
|
||||
childView.die();
|
||||
});
|
||||
}, this), this.deathTime);
|
||||
|
||||
this.deferred.resolve();
|
||||
},
|
||||
|
|
|
@ -124,7 +124,7 @@ exports.getEventBaton = function() {
|
|||
|
||||
exports.getCommandUI = function() {
|
||||
return commandUI;
|
||||
}
|
||||
};
|
||||
|
||||
exports.init = init;
|
||||
|
||||
|
|
28
src/js/dialogs/sandbox.js
Normal file
28
src/js/dialogs/sandbox.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
exports.helpDialog = [{
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdowns: [
|
||||
'## Welcome to LearnGitBranching!',
|
||||
'',
|
||||
'This application is designed to help beginners grasp ',
|
||||
'the powerful concepts behind branching when working ',
|
||||
'with git. We hope you enjoy this application and maybe ',
|
||||
'even learn something!',
|
||||
''
|
||||
]
|
||||
}
|
||||
}, {
|
||||
type: 'ModalAlert',
|
||||
options: {
|
||||
markdowns: [
|
||||
'## The LearnGitBranching Interface',
|
||||
'',
|
||||
'There are features to use within the user interface behind ',
|
||||
'this modal dialog. A list:',
|
||||
'',
|
||||
' * git commands (to interact with git)',
|
||||
' * level commands (to get level hints or solutions)',
|
||||
' * sandbox commands (like this one)'
|
||||
]
|
||||
}
|
||||
}];
|
79
src/js/level/sandbox.js
Normal file
79
src/js/level/sandbox.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
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 ModalTerminal = require('../views').ModalTerminal;
|
||||
var ModalAlert = require('../views').ModalAlert;
|
||||
|
||||
var MultiView = require('../views/multiView').MultiView;
|
||||
|
||||
function Sandbox(options) {
|
||||
options = options || {};
|
||||
|
||||
this.mainVis = new Visualization({
|
||||
el: options.el || $('#canvasWrapper')[0]
|
||||
});
|
||||
|
||||
// don't add it to just any collection -- adding to the
|
||||
// CommandUI collection will put in history
|
||||
this.commandCollection = Main.getCommandUI().commandCollection;
|
||||
|
||||
this.parseWaterfall = new ParseWaterfall();
|
||||
this.parseWaterfall.addFirst(
|
||||
'instantWaterfall',
|
||||
new DisabledMap().getInstantCommands()
|
||||
);
|
||||
|
||||
if (!options.defer) {
|
||||
this.takeControl();
|
||||
}
|
||||
}
|
||||
|
||||
Sandbox.prototype.takeControl = function() {
|
||||
Main.getEventBaton().stealBaton('commandSubmitted', this.commandSubmitted, this);
|
||||
Main.getEvents().on('processSandboxCommand', this.processSandboxCommand, this);
|
||||
};
|
||||
|
||||
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, callback) {
|
||||
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, callback]);
|
||||
};
|
||||
|
||||
Sandbox.prototype.helpDialog = function(command, callback) {
|
||||
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.set('status', 'finished');
|
||||
callback();
|
||||
}, this))
|
||||
.done();
|
||||
};
|
||||
|
||||
exports.Sandbox = Sandbox;
|
||||
|
|
@ -9,6 +9,7 @@ function EventBaton() {
|
|||
// EventBaton.prototype.on = function(name, func, context) {
|
||||
EventBaton.prototype.stealBaton = function(name, func, context) {
|
||||
if (!name) { throw new Error('need name'); }
|
||||
if (!func) { throw new Error('need func!'); }
|
||||
|
||||
var listeners = this.eventMap[name] || [];
|
||||
listeners.push({
|
||||
|
@ -46,7 +47,8 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
var newListeners = [];
|
||||
var found = false;
|
||||
_.each(listeners, function(listenerObj) {
|
||||
if (listenerObj.func === func) {
|
||||
if (listenerObj.func === func && listenerObj.context === context) {
|
||||
if (found) { console.warn('woah duplicates!!!'); }
|
||||
found = true;
|
||||
} else {
|
||||
newListeners.push(listenerObj);
|
||||
|
@ -54,7 +56,8 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
}, this);
|
||||
|
||||
if (!found) {
|
||||
throw new Error('did not find that function', func, context, name, arguments);
|
||||
console.log('did not find that function', func, context, name, arguments);
|
||||
throw new Error('cant releasebaton if yu dont have it');
|
||||
}
|
||||
this.eventMap[name] = newListeners;
|
||||
};
|
||||
|
|
|
@ -159,7 +159,7 @@ var ModalView = Backbone.View.extend({
|
|||
console.log('window focus doing nothing', e);
|
||||
},
|
||||
|
||||
documentClick: function(e) {
|
||||
onDocumentClick: function(e) {
|
||||
console.log('doc click doing nothing', e);
|
||||
},
|
||||
|
||||
|
|
|
@ -65,7 +65,9 @@ var MultiView = Backbone.View.extend({
|
|||
});
|
||||
|
||||
this.render();
|
||||
if (!options.wait) {
|
||||
this.start();
|
||||
}
|
||||
},
|
||||
|
||||
onWindowFocus: function() {
|
||||
|
@ -125,11 +127,9 @@ var MultiView = Backbone.View.extend({
|
|||
// other views will take if they need to
|
||||
this.keyboardListener.mute();
|
||||
|
||||
setTimeout(_.bind(function() {
|
||||
_.each(this.childViews, function(childView) {
|
||||
childView.tearDown();
|
||||
childView.die();
|
||||
});
|
||||
}, this), this.deathTime);
|
||||
|
||||
this.deferred.resolve();
|
||||
},
|
||||
|
|
10
todo.txt
10
todo.txt
|
@ -10,9 +10,7 @@ Medium things:
|
|||
|
||||
Commands
|
||||
========
|
||||
[ ] move command creation outside of the command view so multiple things
|
||||
can be responsible for specifying the waterfall associated with a command!
|
||||
[ ] multiple things can process!!!
|
||||
[ ] transition to deferreds / promises for command callbacks
|
||||
[ ] sip from buffer with post-command hooks. ideally the git engine
|
||||
knows nothing about the level being played
|
||||
|
||||
|
@ -21,7 +19,6 @@ Small things to implement:
|
|||
|
||||
Minor Bugs to fix:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[ ] figure out why multiview baton passing doesn't work...
|
||||
|
||||
Big Bugs to fix:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -35,6 +32,11 @@ Big Bugs to fix:
|
|||
Done things:
|
||||
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[x] awesome ability to have dialogs and such handle command processing and block
|
||||
[x] figure out why multiview baton passing doesn't work...
|
||||
[x] multiple things can process!!!
|
||||
[x] move command creation outside of the command view so multiple things
|
||||
can be responsible for specifying the waterfall associated with a command!
|
||||
[x] awesome zoom level polling and sweet event baton stealing :DDDDDDDDDDDDDD
|
||||
[x] then refactor keyboard input and UI.listen() to that event system
|
||||
[x] make some kind of "single listener" event system... will make keyboard stuff easy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue