From 4db83ba80835f942dfbf19f9d804f51fab39a6f2 Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Sat, 12 Jan 2013 12:54:00 -0800 Subject: [PATCH] refresh fromt ree bug and clicik bug --- build/bundle.js | 62 ++++++++++--------------------- index.html | 2 +- src/js/git/index.js | 12 ++---- src/js/views/levelDropdownView.js | 1 + src/js/visuals/index.js | 13 ++----- src/js/visuals/visBranch.js | 5 +-- 6 files changed, 31 insertions(+), 64 deletions(-) diff --git a/build/bundle.js b/build/bundle.js index 70e5bbca..25c707a7 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -7527,21 +7527,15 @@ GitEngine.prototype.instantiateFromTree = function(tree) { } this.refs = createdSoFar; + this.gitVisuals.gitReady = false; this.branchCollection.each(function(branch) { this.gitVisuals.addBranch(branch); }, this); }; GitEngine.prototype.reloadGraphics = function() { - // get the root commit, no better way to do it - var rootCommit = null; - this.commitCollection.each(function(commit) { - if (commit.get('id') == 'C0') { - rootCommit = commit; - } - }); - this.gitVisuals.rootCommit = rootCommit; - + // get the root commit + this.gitVisuals.rootCommit = this.refs['C0']; // this just basically makes the HEAD branch. the head branch really should have been // a member of a collection and not this annoying edge case stuff... one day this.gitVisuals.initHeadBranch(); @@ -15175,15 +15169,6 @@ GitVisuals.prototype.animateNodePositions = function(speed) { }, this); }; -GitVisuals.prototype.turnOnPaper = function() { - this.gitReady = false; -}; - -// does making an accessor method make it any less hacky? that is the true question -GitVisuals.prototype.turnOffPaper = function() { - this.gitReady = true; -}; - GitVisuals.prototype.addBranchFromEvent = function(branch, collection, index) { var action = _.bind(function() { this.addBranch(branch); @@ -15206,6 +15191,10 @@ GitVisuals.prototype.addBranch = function(branch) { this.visBranchCollection.add(visBranch); if (this.gitReady) { visBranch.genGraphics(this.paper); + } else { + this.defer(_.bind(function() { + visBranch.genGraphics(this.paper); + }, this)); } }; @@ -15962,8 +15951,7 @@ var VisBranch = VisBase.extend({ this.gitVisuals = this.get('gitVisuals'); this.gitEngine = this.get('gitEngine'); if (!this.gitEngine) { - console.log('throw damnit'); - throw new Error('asd'); + throw new Error('asd wtf'); } this.get('branch').set('visBranch', this); @@ -16107,7 +16095,7 @@ var VisBranch = VisBase.extend({ getTextSize: function() { var getTextWidth = function(visBranch) { - var textNode = visBranch.get('text').node; + var textNode = (visBranch.get('text')) ? visBranch.get('text').node : null; return (textNode === null) ? 0 : textNode.clientWidth; }; @@ -17389,6 +17377,7 @@ var SeriesView = BaseView.extend({ } var id = $(ev.srcElement).attr('data-id'); + console.log(id, ev, ev.srcElement); this.navEvents.trigger('clickedID', id); } }); @@ -18692,21 +18681,15 @@ GitEngine.prototype.instantiateFromTree = function(tree) { } this.refs = createdSoFar; + this.gitVisuals.gitReady = false; this.branchCollection.each(function(branch) { this.gitVisuals.addBranch(branch); }, this); }; GitEngine.prototype.reloadGraphics = function() { - // get the root commit, no better way to do it - var rootCommit = null; - this.commitCollection.each(function(commit) { - if (commit.get('id') == 'C0') { - rootCommit = commit; - } - }); - this.gitVisuals.rootCommit = rootCommit; - + // get the root commit + this.gitVisuals.rootCommit = this.refs['C0']; // this just basically makes the HEAD branch. the head branch really should have been // a member of a collection and not this annoying edge case stuff... one day this.gitVisuals.initHeadBranch(); @@ -24639,6 +24622,7 @@ var SeriesView = BaseView.extend({ } var id = $(ev.srcElement).attr('data-id'); + console.log(id, ev, ev.srcElement); this.navEvents.trigger('clickedID', id); } }); @@ -25926,15 +25910,6 @@ GitVisuals.prototype.animateNodePositions = function(speed) { }, this); }; -GitVisuals.prototype.turnOnPaper = function() { - this.gitReady = false; -}; - -// does making an accessor method make it any less hacky? that is the true question -GitVisuals.prototype.turnOffPaper = function() { - this.gitReady = true; -}; - GitVisuals.prototype.addBranchFromEvent = function(branch, collection, index) { var action = _.bind(function() { this.addBranch(branch); @@ -25957,6 +25932,10 @@ GitVisuals.prototype.addBranch = function(branch) { this.visBranchCollection.add(visBranch); if (this.gitReady) { visBranch.genGraphics(this.paper); + } else { + this.defer(_.bind(function() { + visBranch.genGraphics(this.paper); + }, this)); } }; @@ -26277,8 +26256,7 @@ var VisBranch = VisBase.extend({ this.gitVisuals = this.get('gitVisuals'); this.gitEngine = this.get('gitEngine'); if (!this.gitEngine) { - console.log('throw damnit'); - throw new Error('asd'); + throw new Error('asd wtf'); } this.get('branch').set('visBranch', this); @@ -26422,7 +26400,7 @@ var VisBranch = VisBase.extend({ getTextSize: function() { var getTextWidth = function(visBranch) { - var textNode = visBranch.get('text').node; + var textNode = (visBranch.get('text')) ? visBranch.get('text').node : null; return (textNode === null) ? 0 : textNode.clientWidth; }; diff --git a/index.html b/index.html index 3bb0cfb0..ad69181b 100644 --- a/index.html +++ b/index.html @@ -192,7 +192,7 @@ <% for (var i = 0; i < ids.length; i++) { %>
- +
<%= i + 1 %>
diff --git a/src/js/git/index.js b/src/js/git/index.js index 93ec9cf7..dffbcb3d 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -164,21 +164,15 @@ GitEngine.prototype.instantiateFromTree = function(tree) { } this.refs = createdSoFar; + this.gitVisuals.gitReady = false; this.branchCollection.each(function(branch) { this.gitVisuals.addBranch(branch); }, this); }; GitEngine.prototype.reloadGraphics = function() { - // get the root commit, no better way to do it - var rootCommit = null; - this.commitCollection.each(function(commit) { - if (commit.get('id') == 'C0') { - rootCommit = commit; - } - }); - this.gitVisuals.rootCommit = rootCommit; - + // get the root commit + this.gitVisuals.rootCommit = this.refs['C0']; // this just basically makes the HEAD branch. the head branch really should have been // a member of a collection and not this annoying edge case stuff... one day this.gitVisuals.initHeadBranch(); diff --git a/src/js/views/levelDropdownView.js b/src/js/views/levelDropdownView.js index 3f1de3cc..bd1dbeda 100644 --- a/src/js/views/levelDropdownView.js +++ b/src/js/views/levelDropdownView.js @@ -288,6 +288,7 @@ var SeriesView = BaseView.extend({ } var id = $(ev.srcElement).attr('data-id'); + console.log(id, ev, ev.srcElement); this.navEvents.trigger('clickedID', id); } }); diff --git a/src/js/visuals/index.js b/src/js/visuals/index.js index 2fef89bf..45b0165a 100644 --- a/src/js/visuals/index.js +++ b/src/js/visuals/index.js @@ -557,15 +557,6 @@ GitVisuals.prototype.animateNodePositions = function(speed) { }, this); }; -GitVisuals.prototype.turnOnPaper = function() { - this.gitReady = false; -}; - -// does making an accessor method make it any less hacky? that is the true question -GitVisuals.prototype.turnOffPaper = function() { - this.gitReady = true; -}; - GitVisuals.prototype.addBranchFromEvent = function(branch, collection, index) { var action = _.bind(function() { this.addBranch(branch); @@ -588,6 +579,10 @@ GitVisuals.prototype.addBranch = function(branch) { this.visBranchCollection.add(visBranch); if (this.gitReady) { visBranch.genGraphics(this.paper); + } else { + this.defer(_.bind(function() { + visBranch.genGraphics(this.paper); + }, this)); } }; diff --git a/src/js/visuals/visBranch.js b/src/js/visuals/visBranch.js index 10f2bb69..d130e91e 100644 --- a/src/js/visuals/visBranch.js +++ b/src/js/visuals/visBranch.js @@ -55,8 +55,7 @@ var VisBranch = VisBase.extend({ this.gitVisuals = this.get('gitVisuals'); this.gitEngine = this.get('gitEngine'); if (!this.gitEngine) { - console.log('throw damnit'); - throw new Error('asd'); + throw new Error('asd wtf'); } this.get('branch').set('visBranch', this); @@ -200,7 +199,7 @@ var VisBranch = VisBase.extend({ getTextSize: function() { var getTextWidth = function(visBranch) { - var textNode = visBranch.get('text').node; + var textNode = (visBranch.get('text')) ? visBranch.get('text').node : null; return (textNode === null) ? 0 : textNode.clientWidth; };