mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 00:18:56 +02:00
more glue stuff
This commit is contained in:
parent
ca3c0f2b3f
commit
e412be9b61
2 changed files with 42 additions and 37 deletions
26
src/main.js
26
src/main.js
|
@ -13,6 +13,20 @@ var animationFactory = null;
|
||||||
var paper = null;
|
var paper = null;
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
initUI();
|
||||||
|
var mainVis = new Visualization({
|
||||||
|
el: $('#canvasWrapper')[0]
|
||||||
|
});
|
||||||
|
|
||||||
|
// make the canvas for us
|
||||||
|
if (/\?demo/.test(window.location.href)) {
|
||||||
|
setTimeout(function() {
|
||||||
|
events.trigger('submitCommandValueFromEvent', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase master; git checkout master; gc; gc; git merge bugFix");
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function initUI() {
|
||||||
// static classes
|
// static classes
|
||||||
animationFactory = new AnimationFactory();
|
animationFactory = new AnimationFactory();
|
||||||
commandCollection = new CommandCollection();
|
commandCollection = new CommandCollection();
|
||||||
|
@ -21,7 +35,6 @@ $(document).ready(function(){
|
||||||
collection: commandCollection
|
collection: commandCollection
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO make not global
|
|
||||||
commandPromptView = new CommandPromptView({
|
commandPromptView = new CommandPromptView({
|
||||||
el: $('#commandLineBar'),
|
el: $('#commandLineBar'),
|
||||||
collection: commandCollection
|
collection: commandCollection
|
||||||
|
@ -32,16 +45,7 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#commandTextField').focus();
|
$('#commandTextField').focus();
|
||||||
|
}
|
||||||
var mainVis = new Visualization();
|
|
||||||
|
|
||||||
// make the canvas for us
|
|
||||||
if (/\?demo/.test(window.location.href)) {
|
|
||||||
setTimeout(function() {
|
|
||||||
events.trigger('submitCommandValueFromEvent', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase master; git checkout master; gc; gc; git merge bugFix");
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function windowResize() {
|
function windowResize() {
|
||||||
var smaller = 10;
|
var smaller = 10;
|
||||||
|
|
|
@ -1,34 +1,35 @@
|
||||||
function Visualization(options) {
|
var Visualization = Backbone.View.extend({
|
||||||
|
initialize: function(options) {
|
||||||
|
var _this = this;
|
||||||
|
Raphael(10, 10, 200, 200, function() {
|
||||||
|
// for some reason raphael calls this function with a predefined
|
||||||
|
// context...
|
||||||
|
// so switch it
|
||||||
|
paper = this;
|
||||||
|
_this.paperInitialize(this);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
var _this = this;
|
paperInitialize: function(paper, options) {
|
||||||
Raphael(10, 10, 200, 200, function() {
|
this.commitCollection = new CommitCollection();
|
||||||
// for some reason raphael calls this function with a predefined
|
this.branchCollection = new BranchCollection();
|
||||||
// context...
|
|
||||||
// so switch it
|
|
||||||
paper = this;
|
|
||||||
_this.initialize(this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Visualization.prototype.initialize = function(paper, options) {
|
gitVisuals = new GitVisuals({
|
||||||
this.commitCollection = new CommitCollection();
|
commitCollection: this.commitCollection,
|
||||||
this.branchCollection = new BranchCollection();
|
branchCollection: this.branchCollection
|
||||||
|
});
|
||||||
|
|
||||||
gitVisuals = new GitVisuals({
|
gitEngine = new GitEngine({
|
||||||
commitCollection: this.commitCollection,
|
collection: this.commitCollection,
|
||||||
branchCollection: this.branchCollection
|
branches: this.branchCollection
|
||||||
});
|
});
|
||||||
|
|
||||||
gitEngine = new GitEngine({
|
// needs to be called before raphael ready
|
||||||
collection: this.commitCollection,
|
windowResize();
|
||||||
branches: this.branchCollection
|
events.trigger('raphaelReady');
|
||||||
});
|
}
|
||||||
|
|
||||||
// needs to be called before raphael ready
|
|
||||||
windowResize();
|
|
||||||
events.trigger('raphaelReady');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
function GitVisuals(options) {
|
function GitVisuals(options) {
|
||||||
this.commitCollection = options.commitCollection;
|
this.commitCollection = options.commitCollection;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue