[Origin] visualization commands fall through to origin as well

This commit is contained in:
Peter Cottle 2013-05-26 17:04:22 -07:00
parent 91f0e13132
commit 6641417422
4 changed files with 102 additions and 18 deletions

View file

@ -6744,8 +6744,15 @@ var Visualization = Backbone.View.extend({
return this.originVis; return this.originVis;
}, },
originToo: function(methodToCall, args) {
if (this.originVis) {
this.originVis[methodToCall].apply(this.originVis, args);
}
},
setTreeIndex: function(level) { setTreeIndex: function(level) {
$(this.paper.canvas).css('z-index', level); $(this.paper.canvas).css('z-index', level);
this.originToo('setTreeIndex', arguments);
}, },
setTreeOpacity: function(level) { setTreeOpacity: function(level) {
@ -6754,6 +6761,7 @@ var Visualization = Backbone.View.extend({
} }
$(this.paper.canvas).css('opacity', level); $(this.paper.canvas).css('opacity', level);
this.originToo('setTreeOpacity', arguments);
}, },
getAnimationTime: function() { return 300; }, getAnimationTime: function() { return 300; },
@ -6761,11 +6769,13 @@ var Visualization = Backbone.View.extend({
fadeTreeIn: function() { fadeTreeIn: function() {
this.shown = true; this.shown = true;
$(this.paper.canvas).animate({opacity: 1}, this.getAnimationTime()); $(this.paper.canvas).animate({opacity: 1}, this.getAnimationTime());
this.originToo('fadeTreeIn', arguments);
}, },
fadeTreeOut: function() { fadeTreeOut: function() {
this.shown = false; this.shown = false;
$(this.paper.canvas).animate({opacity: 0}, this.getAnimationTime()); $(this.paper.canvas).animate({opacity: 0}, this.getAnimationTime());
this.originToo('fadeTreeOut', arguments);
}, },
hide: function() { hide: function() {
@ -6774,20 +6784,24 @@ var Visualization = Backbone.View.extend({
setTimeout(_.bind(function() { setTimeout(_.bind(function() {
$(this.paper.canvas).css('visibility', 'hidden'); $(this.paper.canvas).css('visibility', 'hidden');
}, this), this.getAnimationTime()); }, this), this.getAnimationTime());
this.originToo('hide', arguments);
}, },
show: function() { show: function() {
$(this.paper.canvas).css('visibility', 'visible'); $(this.paper.canvas).css('visibility', 'visible');
setTimeout(_.bind(this.fadeTreeIn, this), 10); setTimeout(_.bind(this.fadeTreeIn, this), 10);
this.originToo('show', arguments);
}, },
showHarsh: function() { showHarsh: function() {
$(this.paper.canvas).css('visibility', 'visible'); $(this.paper.canvas).css('visibility', 'visible');
this.setTreeOpacity(1); this.setTreeOpacity(1);
this.originToo('showHarsh', arguments);
}, },
resetFromThisTreeNow: function(treeString) { resetFromThisTreeNow: function(treeString) {
this.treeString = treeString; this.treeString = treeString;
console.warn('need to figure out this method...');
}, },
reset: function(tree) { reset: function(tree) {
@ -6799,12 +6813,16 @@ var Visualization = Backbone.View.extend({
this.gitEngine.defaultInit(); this.gitEngine.defaultInit();
} }
this.fadeTreeIn(); this.fadeTreeIn();
console.warn('also figure this one out');
this.originToo('reset', arguments);
}, },
tearDown: function() { tearDown: function() {
this.gitEngine.tearDown(); this.gitEngine.tearDown();
this.gitVisuals.tearDown(); this.gitVisuals.tearDown();
delete this.paper; delete this.paper;
this.originToo('tearDown', arguments);
}, },
die: function() { die: function() {
@ -6814,6 +6832,7 @@ var Visualization = Backbone.View.extend({
this.tearDown(); this.tearDown();
} }
}, this), this.getAnimationTime()); }, this), this.getAnimationTime());
this.originToo('die', arguments);
}, },
myResize: function() { myResize: function() {
@ -15474,7 +15493,7 @@ GitVisuals.prototype.calcDepth = function() {
var depthIncrement = this.getDepthIncrement(maxDepth); var depthIncrement = this.getDepthIncrement(maxDepth);
_.each(this.visNodeMap, function(visNode) { _.each(this.visNodeMap, function(visNode) {
visNode.setDepthBasedOn(depthIncrement); visNode.setDepthBasedOn(depthIncrement, this.getHeaderOffset());
}, this); }, this);
}; };
@ -15555,17 +15574,27 @@ GitVisuals.prototype.animateEdges = function(speed) {
}; };
GitVisuals.prototype.getMinLayers = function() { GitVisuals.prototype.getMinLayers = function() {
return (this.options.smallCanvas) ? 0 : 7; return (this.options.smallCanvas) ? 2 : 7;
}; };
GitVisuals.prototype.getDepthIncrement = function(maxDepth) { GitVisuals.prototype.getDepthIncrement = function(maxDepth) {
// assume there are at least a number of layers until later // assume there are at least a number of layers until later
// to have better visuals // to have better visuals
maxDepth = Math.max(maxDepth, this.getMinLayers()); maxDepth = Math.max(maxDepth, this.getMinLayers());
var increment = 1.0 / maxDepth; // if we have a header, reserve space for that
var vSpace = 1.0 - this.getHeaderOffset();
var increment = vSpace / maxDepth;
return increment; return increment;
}; };
GitVisuals.prototype.shouldHaveHeader = function() {
return this.gitEngine.isOrigin() || this.gitEngine.hasOrigin();
};
GitVisuals.prototype.getHeaderOffset = function() {
return (this.shouldHaveHeader()) ? 0.05 : 0;
};
GitVisuals.prototype.calcDepthRecursive = function(commit, depth) { GitVisuals.prototype.calcDepthRecursive = function(commit, depth) {
commit.get('visNode').setDepth(depth); commit.get('visNode').setDepth(depth);
@ -15802,13 +15831,12 @@ var VisNode = VisBase.extend({
this.set('depth', Math.max(this.get('depth') || 0, depth)); this.set('depth', Math.max(this.get('depth') || 0, depth));
}, },
setDepthBasedOn: function(depthIncrement) { setDepthBasedOn: function(depthIncrement, offset) {
if (this.get('depth') === undefined) { if (this.get('depth') === undefined) {
debugger;
throw new Error('no depth yet!'); throw new Error('no depth yet!');
} }
var pos = this.get('pos'); var pos = this.get('pos');
pos.y = this.get('depth') * depthIncrement; pos.y = this.get('depth') * depthIncrement + offset;
}, },
getMaxWidthScaled: function() { getMaxWidthScaled: function() {
@ -31483,7 +31511,7 @@ GitVisuals.prototype.calcDepth = function() {
var depthIncrement = this.getDepthIncrement(maxDepth); var depthIncrement = this.getDepthIncrement(maxDepth);
_.each(this.visNodeMap, function(visNode) { _.each(this.visNodeMap, function(visNode) {
visNode.setDepthBasedOn(depthIncrement); visNode.setDepthBasedOn(depthIncrement, this.getHeaderOffset());
}, this); }, this);
}; };
@ -31564,17 +31592,27 @@ GitVisuals.prototype.animateEdges = function(speed) {
}; };
GitVisuals.prototype.getMinLayers = function() { GitVisuals.prototype.getMinLayers = function() {
return (this.options.smallCanvas) ? 0 : 7; return (this.options.smallCanvas) ? 2 : 7;
}; };
GitVisuals.prototype.getDepthIncrement = function(maxDepth) { GitVisuals.prototype.getDepthIncrement = function(maxDepth) {
// assume there are at least a number of layers until later // assume there are at least a number of layers until later
// to have better visuals // to have better visuals
maxDepth = Math.max(maxDepth, this.getMinLayers()); maxDepth = Math.max(maxDepth, this.getMinLayers());
var increment = 1.0 / maxDepth; // if we have a header, reserve space for that
var vSpace = 1.0 - this.getHeaderOffset();
var increment = vSpace / maxDepth;
return increment; return increment;
}; };
GitVisuals.prototype.shouldHaveHeader = function() {
return this.gitEngine.isOrigin() || this.gitEngine.hasOrigin();
};
GitVisuals.prototype.getHeaderOffset = function() {
return (this.shouldHaveHeader()) ? 0.05 : 0;
};
GitVisuals.prototype.calcDepthRecursive = function(commit, depth) { GitVisuals.prototype.calcDepthRecursive = function(commit, depth) {
commit.get('visNode').setDepth(depth); commit.get('visNode').setDepth(depth);
@ -32643,13 +32681,12 @@ var VisNode = VisBase.extend({
this.set('depth', Math.max(this.get('depth') || 0, depth)); this.set('depth', Math.max(this.get('depth') || 0, depth));
}, },
setDepthBasedOn: function(depthIncrement) { setDepthBasedOn: function(depthIncrement, offset) {
if (this.get('depth') === undefined) { if (this.get('depth') === undefined) {
debugger;
throw new Error('no depth yet!'); throw new Error('no depth yet!');
} }
var pos = this.get('pos'); var pos = this.get('pos');
pos.y = this.get('depth') * depthIncrement; pos.y = this.get('depth') * depthIncrement + offset;
}, },
getMaxWidthScaled: function() { getMaxWidthScaled: function() {
@ -33129,8 +33166,15 @@ var Visualization = Backbone.View.extend({
return this.originVis; return this.originVis;
}, },
originToo: function(methodToCall, args) {
if (this.originVis) {
this.originVis[methodToCall].apply(this.originVis, args);
}
},
setTreeIndex: function(level) { setTreeIndex: function(level) {
$(this.paper.canvas).css('z-index', level); $(this.paper.canvas).css('z-index', level);
this.originToo('setTreeIndex', arguments);
}, },
setTreeOpacity: function(level) { setTreeOpacity: function(level) {
@ -33139,6 +33183,7 @@ var Visualization = Backbone.View.extend({
} }
$(this.paper.canvas).css('opacity', level); $(this.paper.canvas).css('opacity', level);
this.originToo('setTreeOpacity', arguments);
}, },
getAnimationTime: function() { return 300; }, getAnimationTime: function() { return 300; },
@ -33146,11 +33191,13 @@ var Visualization = Backbone.View.extend({
fadeTreeIn: function() { fadeTreeIn: function() {
this.shown = true; this.shown = true;
$(this.paper.canvas).animate({opacity: 1}, this.getAnimationTime()); $(this.paper.canvas).animate({opacity: 1}, this.getAnimationTime());
this.originToo('fadeTreeIn', arguments);
}, },
fadeTreeOut: function() { fadeTreeOut: function() {
this.shown = false; this.shown = false;
$(this.paper.canvas).animate({opacity: 0}, this.getAnimationTime()); $(this.paper.canvas).animate({opacity: 0}, this.getAnimationTime());
this.originToo('fadeTreeOut', arguments);
}, },
hide: function() { hide: function() {
@ -33159,20 +33206,24 @@ var Visualization = Backbone.View.extend({
setTimeout(_.bind(function() { setTimeout(_.bind(function() {
$(this.paper.canvas).css('visibility', 'hidden'); $(this.paper.canvas).css('visibility', 'hidden');
}, this), this.getAnimationTime()); }, this), this.getAnimationTime());
this.originToo('hide', arguments);
}, },
show: function() { show: function() {
$(this.paper.canvas).css('visibility', 'visible'); $(this.paper.canvas).css('visibility', 'visible');
setTimeout(_.bind(this.fadeTreeIn, this), 10); setTimeout(_.bind(this.fadeTreeIn, this), 10);
this.originToo('show', arguments);
}, },
showHarsh: function() { showHarsh: function() {
$(this.paper.canvas).css('visibility', 'visible'); $(this.paper.canvas).css('visibility', 'visible');
this.setTreeOpacity(1); this.setTreeOpacity(1);
this.originToo('showHarsh', arguments);
}, },
resetFromThisTreeNow: function(treeString) { resetFromThisTreeNow: function(treeString) {
this.treeString = treeString; this.treeString = treeString;
console.warn('need to figure out this method...');
}, },
reset: function(tree) { reset: function(tree) {
@ -33184,12 +33235,16 @@ var Visualization = Backbone.View.extend({
this.gitEngine.defaultInit(); this.gitEngine.defaultInit();
} }
this.fadeTreeIn(); this.fadeTreeIn();
console.warn('also figure this one out');
this.originToo('reset', arguments);
}, },
tearDown: function() { tearDown: function() {
this.gitEngine.tearDown(); this.gitEngine.tearDown();
this.gitVisuals.tearDown(); this.gitVisuals.tearDown();
delete this.paper; delete this.paper;
this.originToo('tearDown', arguments);
}, },
die: function() { die: function() {
@ -33199,6 +33254,7 @@ var Visualization = Backbone.View.extend({
this.tearDown(); this.tearDown();
} }
}, this), this.getAnimationTime()); }, this), this.getAnimationTime());
this.originToo('die', arguments);
}, },
myResize: function() { myResize: function() {

View file

@ -562,7 +562,7 @@ GitVisuals.prototype.calcDepth = function() {
var depthIncrement = this.getDepthIncrement(maxDepth); var depthIncrement = this.getDepthIncrement(maxDepth);
_.each(this.visNodeMap, function(visNode) { _.each(this.visNodeMap, function(visNode) {
visNode.setDepthBasedOn(depthIncrement); visNode.setDepthBasedOn(depthIncrement, this.getHeaderOffset());
}, this); }, this);
}; };
@ -643,17 +643,27 @@ GitVisuals.prototype.animateEdges = function(speed) {
}; };
GitVisuals.prototype.getMinLayers = function() { GitVisuals.prototype.getMinLayers = function() {
return (this.options.smallCanvas) ? 0 : 7; return (this.options.smallCanvas) ? 2 : 7;
}; };
GitVisuals.prototype.getDepthIncrement = function(maxDepth) { GitVisuals.prototype.getDepthIncrement = function(maxDepth) {
// assume there are at least a number of layers until later // assume there are at least a number of layers until later
// to have better visuals // to have better visuals
maxDepth = Math.max(maxDepth, this.getMinLayers()); maxDepth = Math.max(maxDepth, this.getMinLayers());
var increment = 1.0 / maxDepth; // if we have a header, reserve space for that
var vSpace = 1.0 - this.getHeaderOffset();
var increment = vSpace / maxDepth;
return increment; return increment;
}; };
GitVisuals.prototype.shouldHaveHeader = function() {
return this.gitEngine.isOrigin() || this.gitEngine.hasOrigin();
};
GitVisuals.prototype.getHeaderOffset = function() {
return (this.shouldHaveHeader()) ? 0.05 : 0;
};
GitVisuals.prototype.calcDepthRecursive = function(commit, depth) { GitVisuals.prototype.calcDepthRecursive = function(commit, depth) {
commit.get('visNode').setDepth(depth); commit.get('visNode').setDepth(depth);

View file

@ -60,13 +60,12 @@ var VisNode = VisBase.extend({
this.set('depth', Math.max(this.get('depth') || 0, depth)); this.set('depth', Math.max(this.get('depth') || 0, depth));
}, },
setDepthBasedOn: function(depthIncrement) { setDepthBasedOn: function(depthIncrement, offset) {
if (this.get('depth') === undefined) { if (this.get('depth') === undefined) {
debugger;
throw new Error('no depth yet!'); throw new Error('no depth yet!');
} }
var pos = this.get('pos'); var pos = this.get('pos');
pos.y = this.get('depth') * depthIncrement; pos.y = this.get('depth') * depthIncrement + offset;
}, },
getMaxWidthScaled: function() { getMaxWidthScaled: function() {

View file

@ -104,8 +104,15 @@ var Visualization = Backbone.View.extend({
return this.originVis; return this.originVis;
}, },
originToo: function(methodToCall, args) {
if (this.originVis) {
this.originVis[methodToCall].apply(this.originVis, args);
}
},
setTreeIndex: function(level) { setTreeIndex: function(level) {
$(this.paper.canvas).css('z-index', level); $(this.paper.canvas).css('z-index', level);
this.originToo('setTreeIndex', arguments);
}, },
setTreeOpacity: function(level) { setTreeOpacity: function(level) {
@ -114,6 +121,7 @@ var Visualization = Backbone.View.extend({
} }
$(this.paper.canvas).css('opacity', level); $(this.paper.canvas).css('opacity', level);
this.originToo('setTreeOpacity', arguments);
}, },
getAnimationTime: function() { return 300; }, getAnimationTime: function() { return 300; },
@ -121,11 +129,13 @@ var Visualization = Backbone.View.extend({
fadeTreeIn: function() { fadeTreeIn: function() {
this.shown = true; this.shown = true;
$(this.paper.canvas).animate({opacity: 1}, this.getAnimationTime()); $(this.paper.canvas).animate({opacity: 1}, this.getAnimationTime());
this.originToo('fadeTreeIn', arguments);
}, },
fadeTreeOut: function() { fadeTreeOut: function() {
this.shown = false; this.shown = false;
$(this.paper.canvas).animate({opacity: 0}, this.getAnimationTime()); $(this.paper.canvas).animate({opacity: 0}, this.getAnimationTime());
this.originToo('fadeTreeOut', arguments);
}, },
hide: function() { hide: function() {
@ -134,20 +144,24 @@ var Visualization = Backbone.View.extend({
setTimeout(_.bind(function() { setTimeout(_.bind(function() {
$(this.paper.canvas).css('visibility', 'hidden'); $(this.paper.canvas).css('visibility', 'hidden');
}, this), this.getAnimationTime()); }, this), this.getAnimationTime());
this.originToo('hide', arguments);
}, },
show: function() { show: function() {
$(this.paper.canvas).css('visibility', 'visible'); $(this.paper.canvas).css('visibility', 'visible');
setTimeout(_.bind(this.fadeTreeIn, this), 10); setTimeout(_.bind(this.fadeTreeIn, this), 10);
this.originToo('show', arguments);
}, },
showHarsh: function() { showHarsh: function() {
$(this.paper.canvas).css('visibility', 'visible'); $(this.paper.canvas).css('visibility', 'visible');
this.setTreeOpacity(1); this.setTreeOpacity(1);
this.originToo('showHarsh', arguments);
}, },
resetFromThisTreeNow: function(treeString) { resetFromThisTreeNow: function(treeString) {
this.treeString = treeString; this.treeString = treeString;
console.warn('need to figure out this method...');
}, },
reset: function(tree) { reset: function(tree) {
@ -159,12 +173,16 @@ var Visualization = Backbone.View.extend({
this.gitEngine.defaultInit(); this.gitEngine.defaultInit();
} }
this.fadeTreeIn(); this.fadeTreeIn();
console.warn('also figure this one out');
this.originToo('reset', arguments);
}, },
tearDown: function() { tearDown: function() {
this.gitEngine.tearDown(); this.gitEngine.tearDown();
this.gitVisuals.tearDown(); this.gitVisuals.tearDown();
delete this.paper; delete this.paper;
this.originToo('tearDown', arguments);
}, },
die: function() { die: function() {
@ -174,6 +192,7 @@ var Visualization = Backbone.View.extend({
this.tearDown(); this.tearDown();
} }
}, this), this.getAnimationTime()); }, this), this.getAnimationTime());
this.originToo('die', arguments);
}, },
myResize: function() { myResize: function() {