mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-08-30 06:39:49 +02:00
got rid of every underscore bind i think -- 1500 line diff
This commit is contained in:
parent
3833319476
commit
2257668f9d
21 changed files with 229 additions and 230 deletions
|
@ -77,12 +77,12 @@ AnimationFactory.highlightEachWithPromise = function(
|
|||
destObj
|
||||
) {
|
||||
_.each(toHighlight, function(commit) {
|
||||
chain = chain.then(_.bind(function() {
|
||||
chain = chain.then(function() {
|
||||
return this.playHighlightPromiseAnimation(
|
||||
commit,
|
||||
destObj
|
||||
);
|
||||
}, this));
|
||||
}.bind(this));
|
||||
}, this);
|
||||
return chain;
|
||||
};
|
||||
|
|
|
@ -42,9 +42,9 @@ var AnimationQueue = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
thenFinish: function(promise, deferred) {
|
||||
promise.then(_.bind(function() {
|
||||
promise.then(function() {
|
||||
this.finish();
|
||||
}, this));
|
||||
}.bind(this));
|
||||
promise.fail(function(e) {
|
||||
console.log('uncaught error', e);
|
||||
throw e;
|
||||
|
@ -97,9 +97,9 @@ var AnimationQueue = Backbone.Model.extend({
|
|||
next.run();
|
||||
|
||||
this.set('index', index + 1);
|
||||
setTimeout(_.bind(function() {
|
||||
setTimeout(function() {
|
||||
this.next();
|
||||
}, this), duration);
|
||||
}.bind(this), duration);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -127,9 +127,9 @@ var PromiseAnimation = Backbone.Model.extend({
|
|||
// a single animation is just something with a timeout, but now
|
||||
// we want to resolve a deferred when the animation finishes
|
||||
this.get('closure')();
|
||||
setTimeout(_.bind(function() {
|
||||
setTimeout(function() {
|
||||
this.get('deferred').resolve();
|
||||
}, this), this.get('duration'));
|
||||
}.bind(this), this.get('duration'));
|
||||
},
|
||||
|
||||
then: function(func) {
|
||||
|
|
|
@ -217,7 +217,7 @@ GitVisuals.prototype.finishAnimation = function() {
|
|||
|
||||
var textString = 'Solved!!\n:D';
|
||||
var text = null;
|
||||
var makeText = _.bind(function() {
|
||||
var makeText = function() {
|
||||
text = this.paper.text(
|
||||
this.paper.width / 2,
|
||||
this.paper.height / 2,
|
||||
|
@ -233,7 +233,7 @@ GitVisuals.prototype.finishAnimation = function() {
|
|||
fill: '#000'
|
||||
});
|
||||
text.animate({ opacity: 1 }, defaultTime);
|
||||
}, this);
|
||||
}.bind(this);
|
||||
|
||||
// this is a BIG ANIMATION but it ends up just being
|
||||
// a sweet chain of promises but is pretty nice. this is
|
||||
|
@ -243,47 +243,47 @@ GitVisuals.prototype.finishAnimation = function() {
|
|||
|
||||
deferred.promise
|
||||
// first fade out everything but circles
|
||||
.then(_.bind(function() {
|
||||
.then(function() {
|
||||
return this.animateAllAttrKeys(
|
||||
{ exclude: ['circle'] },
|
||||
{ opacity: 0 },
|
||||
defaultTime * 1.1
|
||||
);
|
||||
}, this))
|
||||
}.bind(this))
|
||||
// then make circle radii bigger
|
||||
.then(_.bind(function() {
|
||||
.then(function() {
|
||||
return this.animateAllAttrKeys(
|
||||
{ exclude: ['arrow', 'rect', 'path', 'text'] },
|
||||
{ r: nodeRadius * 2 },
|
||||
defaultTime * 1.5
|
||||
);
|
||||
}, this))
|
||||
}.bind(this))
|
||||
// then shrink em super fast
|
||||
.then(_.bind(function() {
|
||||
.then(function() {
|
||||
return this.animateAllAttrKeys(
|
||||
{ exclude: ['arrow', 'rect', 'path', 'text'] },
|
||||
{ r: nodeRadius * 0.75 },
|
||||
defaultTime * 0.5
|
||||
);
|
||||
}, this))
|
||||
}.bind(this))
|
||||
// then explode them and display text
|
||||
.then(_.bind(function() {
|
||||
.then(function() {
|
||||
makeText();
|
||||
return this.explodeNodes();
|
||||
}, this))
|
||||
.then(_.bind(function() {
|
||||
}.bind(this))
|
||||
.then(function() {
|
||||
return this.explodeNodes();
|
||||
}, this))
|
||||
}.bind(this))
|
||||
// then fade circles (aka everything) in and back
|
||||
.then(_.bind(function() {
|
||||
.then(function() {
|
||||
return this.animateAllAttrKeys(
|
||||
{ exclude: ['arrow', 'rect', 'path', 'text'] },
|
||||
{},
|
||||
defaultTime * 1.25
|
||||
);
|
||||
}, this))
|
||||
}.bind(this))
|
||||
// then fade everything in and remove text
|
||||
.then(_.bind(function() {
|
||||
.then(function() {
|
||||
text.animate({ opacity: 0 }, defaultTime, undefined, undefined, function() {
|
||||
text.remove();
|
||||
});
|
||||
|
@ -291,7 +291,7 @@ GitVisuals.prototype.finishAnimation = function() {
|
|||
{},
|
||||
{}
|
||||
);
|
||||
}, this))
|
||||
}.bind(this))
|
||||
.then(function() {
|
||||
animationDone.resolve();
|
||||
})
|
||||
|
@ -648,9 +648,9 @@ GitVisuals.prototype.animateNodePositions = function(speed) {
|
|||
};
|
||||
|
||||
GitVisuals.prototype.addBranchFromEvent = function(branch, collection, index) {
|
||||
var action = _.bind(function() {
|
||||
var action = function() {
|
||||
this.addBranch(branch);
|
||||
}, this);
|
||||
}.bind(this);
|
||||
|
||||
if (!this.gitEngine || !this.gitReady) {
|
||||
this.defer(action);
|
||||
|
@ -670,16 +670,16 @@ GitVisuals.prototype.addBranch = function(branch) {
|
|||
if (this.gitReady) {
|
||||
visBranch.genGraphics(this.paper);
|
||||
} else {
|
||||
this.defer(_.bind(function() {
|
||||
this.defer(function() {
|
||||
visBranch.genGraphics(this.paper);
|
||||
}, this));
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
GitVisuals.prototype.addTagFromEvent = function(tag, collection, index) {
|
||||
var action = _.bind(function() {
|
||||
var action = function() {
|
||||
this.addTag(tag);
|
||||
}, this);
|
||||
}.bind(this);
|
||||
|
||||
if (!this.gitEngine || !this.gitReady) {
|
||||
this.defer(action);
|
||||
|
@ -699,9 +699,9 @@ GitVisuals.prototype.addTag = function(tag) {
|
|||
if (this.gitReady) {
|
||||
visTag.genGraphics(this.paper);
|
||||
} else {
|
||||
this.defer(_.bind(function() {
|
||||
this.defer(function() {
|
||||
visTag.genGraphics(this.paper);
|
||||
}, this));
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -783,9 +783,9 @@ GitVisuals.prototype.canvasResize = function(width, height) {
|
|||
|
||||
GitVisuals.prototype.genResizeFunc = function() {
|
||||
this.resizeFunc = _.debounce(
|
||||
_.bind(function(width, height) {
|
||||
function(width, height) {
|
||||
this.refreshTree();
|
||||
}, this),
|
||||
}.bind(this),
|
||||
200,
|
||||
true
|
||||
);
|
||||
|
|
|
@ -451,7 +451,7 @@ var VisBranch = VisBase.extend({
|
|||
];
|
||||
|
||||
_.each(objs, function(rObj) {
|
||||
rObj.click(_.bind(this.onClick ,this));
|
||||
rObj.click(this.onClick.bind(this));
|
||||
}, this);
|
||||
},
|
||||
|
||||
|
|
|
@ -290,13 +290,13 @@ var VisTag = VisBase.extend({
|
|||
];
|
||||
|
||||
_.each(objs, function(rObj) {
|
||||
rObj.click(_.bind(this.onClick ,this));
|
||||
rObj.click(this.onClick.bind(this));
|
||||
}, this);
|
||||
},
|
||||
|
||||
shouldDisableClick: function() {
|
||||
return this.get('isHead') && !this.gitEngine.getDetachedHead();
|
||||
},
|
||||
}.bind(this),
|
||||
|
||||
onClick: function() {
|
||||
if (this.shouldDisableClick()) {
|
||||
|
|
|
@ -69,16 +69,16 @@ var Visualization = Backbone.View.extend({
|
|||
|
||||
this.myResize();
|
||||
|
||||
$(window).on('resize', _.bind(function() {
|
||||
$(window).on('resize', function() {
|
||||
this.myResize();
|
||||
}, this));
|
||||
}.bind(this));
|
||||
|
||||
// If the visualization is within a draggable container, we need to update the
|
||||
// position whenever the container is moved.
|
||||
this.$el.parents('.ui-draggable').on('drag', _.bind(function(event, ui) {
|
||||
this.$el.parents('.ui-draggable').on('drag', function(event, ui) {
|
||||
this.customEvents.trigger('drag', event, ui);
|
||||
this.myResize();
|
||||
}, this));
|
||||
}.bind(this));
|
||||
|
||||
this.gitVisuals.drawTreeFirstTime();
|
||||
if (this.treeString) {
|
||||
|
@ -91,7 +91,7 @@ var Visualization = Backbone.View.extend({
|
|||
this.shown = false;
|
||||
this.setTreeOpacity(0);
|
||||
// reflow needed
|
||||
process.nextTick(_.bind(this.fadeTreeIn, this));
|
||||
process.nextTick(this.fadeTreeIn, this));
|
||||
|
||||
this.customEvents.trigger('gitEngineReady');
|
||||
this.customEvents.trigger('paperReady');
|
||||
|
@ -99,7 +99,7 @@ var Visualization = Backbone.View.extend({
|
|||
|
||||
clearOrigin: function() {
|
||||
delete this.originVis;
|
||||
},
|
||||
}.bind(this)
|
||||
|
||||
makeOrigin: function(options) {
|
||||
// oh god, here we go. We basically do a bizarre form of composition here,
|
||||
|
@ -116,10 +116,10 @@ var Visualization = Backbone.View.extend({
|
|||
}
|
||||
));
|
||||
// if the z index is set on ours, carry that over
|
||||
this.originVis.customEvents.on('paperReady', _.bind(function() {
|
||||
this.originVis.customEvents.on('paperReady', function() {
|
||||
var value = $(this.paper.canvas).css('z-index');
|
||||
this.originVis.setTreeIndex(value);
|
||||
}, this));
|
||||
}.bind(this));
|
||||
|
||||
// return the newly created visualization which will soon have a git engine
|
||||
return this.originVis;
|
||||
|
@ -129,9 +129,9 @@ var Visualization = Backbone.View.extend({
|
|||
if (!this.originVis) {
|
||||
return;
|
||||
}
|
||||
var callMethod = _.bind(function() {
|
||||
var callMethod = function() {
|
||||
this.originVis[methodToCall].apply(this.originVis, args);
|
||||
}, this);
|
||||
}.bind(this);
|
||||
|
||||
if (this.originVis.paper) {
|
||||
callMethod();
|
||||
|
@ -178,15 +178,15 @@ var Visualization = Backbone.View.extend({
|
|||
hide: function() {
|
||||
this.fadeTreeOut();
|
||||
// remove click handlers by toggling visibility
|
||||
setTimeout(_.bind(function() {
|
||||
setTimeout(function() {
|
||||
$(this.paper.canvas).css('visibility', 'hidden');
|
||||
}, this), this.getAnimationTime());
|
||||
}.bind(this), this.getAnimationTime());
|
||||
this.originToo('hide', arguments);
|
||||
},
|
||||
|
||||
show: function() {
|
||||
$(this.paper.canvas).css('visibility', 'visible');
|
||||
setTimeout(_.bind(this.fadeTreeIn, this), 10);
|
||||
setTimeout(this.fadeTreeIn, this), 10);
|
||||
this.originToo('show', arguments);
|
||||
this.myResize();
|
||||
},
|
||||
|
@ -196,7 +196,7 @@ var Visualization = Backbone.View.extend({
|
|||
this.setTreeOpacity(1);
|
||||
this.originToo('showHarsh', arguments);
|
||||
this.myResize();
|
||||
},
|
||||
}.bind(this)
|
||||
|
||||
resetFromThisTreeNow: function(treeString) {
|
||||
this.treeString = treeString;
|
||||
|
@ -245,11 +245,11 @@ var Visualization = Backbone.View.extend({
|
|||
|
||||
die: function() {
|
||||
this.fadeTreeOut();
|
||||
setTimeout(_.bind(function() {
|
||||
setTimeout(function() {
|
||||
if (!this.shown) {
|
||||
this.tearDown({fromDie: true});
|
||||
}
|
||||
}, this), this.getAnimationTime());
|
||||
}.bind(this), this.getAnimationTime());
|
||||
this.originToo('die', arguments);
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue