ok now it blocks on raphael load

This commit is contained in:
Peter Cottle 2012-11-03 13:06:18 -07:00
parent 44322298ba
commit e8ac126f8f

View file

@ -13,18 +13,15 @@ var animationFactory = null;
var paper = null; var paper = null;
$(document).ready(function(){ $(document).ready(function(){
// static classes
animationFactory = new AnimationFactory(); animationFactory = new AnimationFactory();
// the two major collections that affect everything
var commitCollection = new CommitCollection();
commandCollection = new CommandCollection(); commandCollection = new CommandCollection();
var branchCollection = new BranchCollection();
commandBuffer = new CommandBuffer({ commandBuffer = new CommandBuffer({
collection: commandCollection collection: commandCollection
}); });
// TODO make not global // TODO make not global
commandPromptView = new CommandPromptView({ commandPromptView = new CommandPromptView({
el: $('#commandLineBar'), el: $('#commandLineBar'),
collection: commandCollection collection: commandCollection
@ -34,21 +31,26 @@ $(document).ready(function(){
collection: commandCollection collection: commandCollection
}); });
gitVisuals = new GitVisuals({
commitCollection: commitCollection,
branchCollection: branchCollection
});
gitEngine = new GitEngine({
collection: commitCollection,
branches: branchCollection
});
$('#commandTextField').focus();
// make the canvas for us // make the canvas for us
Raphael(10, 10, 200, 200, function() { Raphael(10, 10, 200, 200, function() {
paper = this; paper = this;
// the two major collections that affect everything
var commitCollection = new CommitCollection();
var branchCollection = new BranchCollection();
gitVisuals = new GitVisuals({
commitCollection: commitCollection,
branchCollection: branchCollection
});
gitEngine = new GitEngine({
collection: commitCollection,
branches: branchCollection
});
$('#commandTextField').focus();
// needs to be called before raphael ready // needs to be called before raphael ready
windowResize(); windowResize();
events.trigger('raphaelReady'); events.trigger('raphaelReady');
@ -58,7 +60,6 @@ $(document).ready(function(){
windowResize(); windowResize();
setTimeout(windowResize, 50); setTimeout(windowResize, 50);
if (/\?demo/.test(window.location.href)) { if (/\?demo/.test(window.location.href)) {
setTimeout(function() { 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"); 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");
@ -68,21 +69,20 @@ $(document).ready(function(){
function windowResize() { function windowResize() {
var smaller = 10; var smaller = 10;
var el = $('#canvasWrapper')[0];
var left = el.offsetLeft;
var top = el.offsetTop;
var width = el.clientWidth - smaller;
var height = el.clientHeight - smaller;
if (paper && paper.canvas) { if (paper && paper.canvas) {
var el = $('#canvasWrapper')[0];
var left = el.offsetLeft;
var top = el.offsetTop;
var width = el.clientWidth - smaller;
var height = el.clientHeight - smaller;
$(paper.canvas).css({ $(paper.canvas).css({
left: left + 'px', left: left + 'px',
top: top + 'px' top: top + 'px'
}); });
paper.setSize(width, height); paper.setSize(width, height);
events.trigger('canvasResize', width, height);
} }
events.trigger('canvasResize', width, height);
} }