got rid of every underscore bind i think -- 1500 line diff

This commit is contained in:
Peter Cottle 2015-04-20 16:41:56 +10:00
parent 3833319476
commit 2257668f9d
21 changed files with 229 additions and 230 deletions

View file

@ -39,20 +39,20 @@ GitShim.prototype.processGitCommand = function(command, deferred) {
// functionality. we give this new deferred to the eventBaton handler // functionality. we give this new deferred to the eventBaton handler
var newDeferred = Q.defer(); var newDeferred = Q.defer();
newDeferred.promise newDeferred.promise
.then(_.bind(function() { .then(function() {
// give this method the original defer so it can resolve it // give this method the original defer so it can resolve it
this.afterGitCommandProcessed(command, deferred); this.afterGitCommandProcessed(command, deferred);
}, this)) }.bind(this))
.done(); .done();
// now our shim owner might want to launch some kind of deferred beforehand, like // now our shim owner might want to launch some kind of deferred beforehand, like
// a modal or something. in order to do this, we need to defer the passing // a modal or something. in order to do this, we need to defer the passing
// of the event baton backwards, and either resolve that promise immediately or // of the event baton backwards, and either resolve that promise immediately or
// give it to our shim owner. // give it to our shim owner.
var passBaton = _.bind(function() { var passBaton = function() {
// punt to the previous listener // punt to the previous listener
this.eventBaton.passBatonBack('processGitCommand', this.processGitCommand, this, [command, newDeferred]); this.eventBaton.passBatonBack('processGitCommand', this.processGitCommand, this, [command, newDeferred]);
}, this); }.bind(this);
var beforeDefer = Q.defer(); var beforeDefer = Q.defer();
beforeDefer.promise beforeDefer.promise

View file

@ -1,4 +1,3 @@
var _ = require('underscore');
var Backbone = require('backbone'); var Backbone = require('backbone');
var Q = require('q'); var Q = require('q');
@ -111,7 +110,7 @@ HeadlessGit.prototype.sendCommand = function(value, entireCommandPromise) {
var startTime = new Date().getTime(); var startTime = new Date().getTime();
util.splitTextCommand(value, function(commandStr) { util.splitTextCommand(value, function(commandStr) {
chain = chain.then(_.bind(function() { chain = chain.then(function() {
var commandObj = new Command({ var commandObj = new Command({
rawStr: commandStr rawStr: commandStr
}); });
@ -119,7 +118,7 @@ HeadlessGit.prototype.sendCommand = function(value, entireCommandPromise) {
var thisDeferred = Q.defer(); var thisDeferred = Q.defer();
this.gitEngine.dispatch(commandObj, thisDeferred); this.gitEngine.dispatch(commandObj, thisDeferred);
return thisDeferred.promise; return thisDeferred.promise;
}, this)); }.bind(this));
}, this); }, this);
chain.then(function() { chain.then(function() {

View file

@ -102,18 +102,18 @@ GitEngine.prototype.setMode = function(vcs) {
// branching ahead... // branching ahead...
var neededUpdate = this.updateAllBranchesForHg(); var neededUpdate = this.updateAllBranchesForHg();
if (neededUpdate) { if (neededUpdate) {
chain = chain.then(_.bind(function() { chain = chain.then(function() {
return this.animationFactory.playRefreshAnimationSlow(this.gitVisuals); return this.animationFactory.playRefreshAnimationSlow(this.gitVisuals);
}, this)); }.bind(this));
// ok we need to refresh anyways, so do the prune after // ok we need to refresh anyways, so do the prune after
chain = chain.then(_.bind(function() { chain = chain.then(function() {
var neededPrune = this.pruneTree(); var neededPrune = this.pruneTree();
if (!neededPrune) { if (!neededPrune) {
return; return;
} }
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }.bind(this));
return chain; return chain;
} }
@ -795,7 +795,7 @@ GitEngine.prototype.printRemotes = function(options) {
GitEngine.prototype.getUniqueID = function() { GitEngine.prototype.getUniqueID = function() {
var id = this.uniqueId('C'); var id = this.uniqueId('C');
var hasID = _.bind(function(idToCheck) { var hasID = function(idToCheck) {
// loop through and see if we have it locally or // loop through and see if we have it locally or
// remotely // remotely
if (this.refs[idToCheck]) { if (this.refs[idToCheck]) {
@ -805,7 +805,7 @@ GitEngine.prototype.getUniqueID = function() {
return true; return true;
} }
return false; return false;
}, this); }.bind(this);
while (hasID(id)) { while (hasID(id)) {
id = this.uniqueId('C'); id = this.uniqueId('C');
@ -852,7 +852,7 @@ GitEngine.prototype.revert = function(whichCommits) {
var base = this.getCommitFromRef('HEAD'); var base = this.getCommitFromRef('HEAD');
// each step makes a new commit // each step makes a new commit
var chainStep = _.bind(function(oldCommit) { var chainStep = function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id')); var newId = this.rebaseAltID(oldCommit.get('id'));
var commitMessage = intl.str('git-revert-msg', { var commitMessage = intl.str('git-revert-msg', {
oldCommit: this.resolveName(oldCommit), oldCommit: this.resolveName(oldCommit),
@ -867,7 +867,7 @@ GitEngine.prototype.revert = function(whichCommits) {
newCommit, newCommit,
this.gitVisuals this.gitVisuals
); );
}, this); }.bind(this);
// set up the promise chain // set up the promise chain
_.each(toRevert, function(commit) { _.each(toRevert, function(commit) {
@ -877,10 +877,10 @@ GitEngine.prototype.revert = function(whichCommits) {
}, this); }, this);
// done! update our location // done! update our location
chain = chain.then(_.bind(function() { chain = chain.then(function() {
this.setTargetLocation('HEAD', base); this.setTargetLocation('HEAD', base);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }.bind(this));
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
}; };
@ -901,13 +901,13 @@ GitEngine.prototype.setupCherrypickChain = function(toCherrypick) {
destinationBranch destinationBranch
); );
var chainStep = _.bind(function(commit) { var chainStep = function(commit) {
var newCommit = this.cherrypick(commit); var newCommit = this.cherrypick(commit);
return this.animationFactory.playCommitBirthPromiseAnimation( return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit, newCommit,
this.gitVisuals this.gitVisuals
); );
}, this); }.bind(this);
_.each(toCherrypick, function(arg) { _.each(toCherrypick, function(arg) {
chain = chain.then(function() { chain = chain.then(function() {
@ -1085,34 +1085,34 @@ GitEngine.prototype.push = function(options) {
return !this.origin.refs[commitJSON.id]; return !this.origin.refs[commitJSON.id];
}, this); }, this);
var makeCommit = _.bind(function(id, parentIDs) { var makeCommit = function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know // need to get the parents first. since we order by depth, we know
// the dependencies are there already // the dependencies are there already
var parents = _.map(parentIDs, function(parentID) { var parents = _.map(parentIDs, function(parentID) {
return this.origin.refs[parentID]; return this.origin.refs[parentID];
}, this); }, this);
return this.origin.makeCommit(parents, id); return this.origin.makeCommit(parents, id);
}, this); }.bind(this);
// now make the promise chain to make each commit // now make the promise chain to make each commit
var chainStep = _.bind(function(id, parents) { var chainStep = function(id, parents) {
var newCommit = makeCommit(id, parents); var newCommit = makeCommit(id, parents);
return this.animationFactory.playCommitBirthPromiseAnimation( return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit, newCommit,
this.origin.gitVisuals this.origin.gitVisuals
); );
}, this); }.bind(this);
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
_.each(commitsToMake, function(commitJSON) { _.each(commitsToMake, function(commitJSON) {
chain = chain.then(_.bind(function() { chain = chain.then(function() {
return this.animationFactory.playHighlightPromiseAnimation( return this.animationFactory.playHighlightPromiseAnimation(
this.refs[commitJSON.id], this.refs[commitJSON.id],
branchOnRemote branchOnRemote
); );
}, this)); }.bind(this));
chain = chain.then(function() { chain = chain.then(function() {
return chainStep( return chainStep(
@ -1122,21 +1122,21 @@ GitEngine.prototype.push = function(options) {
}); });
}, this); }, this);
chain = chain.then(_.bind(function() { chain = chain.then(function() {
var localLocationID = this.getCommitFromRef(sourceLocation).get('id'); var localLocationID = this.getCommitFromRef(sourceLocation).get('id');
var remoteCommit = this.origin.refs[localLocationID]; var remoteCommit = this.origin.refs[localLocationID];
this.origin.setTargetLocation(branchOnRemote, remoteCommit); this.origin.setTargetLocation(branchOnRemote, remoteCommit);
// unhighlight local // unhighlight local
this.animationFactory.playRefreshAnimation(this.gitVisuals); this.animationFactory.playRefreshAnimation(this.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals); return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
}, this)); }.bind(this));
// HAX HAX update master and remote tracking for master // HAX HAX update master and remote tracking for master
chain = chain.then(_.bind(function() { chain = chain.then(function() {
var localCommit = this.getCommitFromRef(sourceLocation); var localCommit = this.getCommitFromRef(sourceLocation);
this.setTargetLocation(this.refs[ORIGIN_PREFIX + options.destination], localCommit); this.setTargetLocation(this.refs[ORIGIN_PREFIX + options.destination], localCommit);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }.bind(this));
if (!options.dontResolvePromise) { if (!options.dontResolvePromise) {
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
@ -1259,31 +1259,31 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
return !this.refs[commitJSON.id]; return !this.refs[commitJSON.id];
}, this); }, this);
var makeCommit = _.bind(function(id, parentIDs) { var makeCommit = function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know // need to get the parents first. since we order by depth, we know
// the dependencies are there already // the dependencies are there already
var parents = _.map(parentIDs, function(parentID) { var parents = _.map(parentIDs, function(parentID) {
return this.refs[parentID]; return this.refs[parentID];
}, this); }, this);
return this.makeCommit(parents, id); return this.makeCommit(parents, id);
}, this); }.bind(this);
// now make the promise chain to make each commit // now make the promise chain to make each commit
var chainStep = _.bind(function(id, parents) { var chainStep = function(id, parents) {
var newCommit = makeCommit(id, parents); var newCommit = makeCommit(id, parents);
return this.animationFactory.playCommitBirthPromiseAnimation( return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit, newCommit,
this.gitVisuals this.gitVisuals
); );
}, this); }.bind(this);
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
if (options.didMakeBranch) { if (options.didMakeBranch) {
chain = chain.then(_.bind(function() { chain = chain.then(function() {
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals); this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }.bind(this));
} }
var originBranchSet = this.origin.getUpstreamBranchSet(); var originBranchSet = this.origin.getUpstreamBranchSet();
@ -1293,12 +1293,12 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
var originBranch = originBranchSet[commitJSON.id][0].obj; var originBranch = originBranchSet[commitJSON.id][0].obj;
var localBranch = this.refs[originBranch.getPrefixedID()]; var localBranch = this.refs[originBranch.getPrefixedID()];
chain = chain.then(_.bind(function() { chain = chain.then(function() {
return this.animationFactory.playHighlightPromiseAnimation( return this.animationFactory.playHighlightPromiseAnimation(
this.origin.refs[commitJSON.id], this.origin.refs[commitJSON.id],
localBranch localBranch
); );
}, this)); }.bind(this));
chain = chain.then(function() { chain = chain.then(function() {
return chainStep( return chainStep(
@ -1308,7 +1308,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
}); });
}, this); }, this);
chain = chain.then(_.bind(function() { chain = chain.then(function() {
// update all the destinations // update all the destinations
_.each(sourceDestPairs, function(pair) { _.each(sourceDestPairs, function(pair) {
var ours = this.refs[pair.destination]; var ours = this.refs[pair.destination];
@ -1322,7 +1322,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
// unhighlight origin by refreshing // unhighlight origin by refreshing
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals); this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }.bind(this));
if (!options.dontResolvePromise) { if (!options.dontResolvePromise) {
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
@ -1366,31 +1366,31 @@ GitEngine.prototype.pullFinishWithRebase = function(
) { ) {
var chain = pendingFetch.chain; var chain = pendingFetch.chain;
var deferred = pendingFetch.deferred; var deferred = pendingFetch.deferred;
chain = chain.then(_.bind(function() { chain = chain.then(function() {
if (this.isUpstreamOf(remoteBranch, localBranch)) { if (this.isUpstreamOf(remoteBranch, localBranch)) {
this.command.set('error', new CommandResult({ this.command.set('error', new CommandResult({
msg: intl.str('git-result-uptodate') msg: intl.str('git-result-uptodate')
})); }));
throw SHORT_CIRCUIT_CHAIN; throw SHORT_CIRCUIT_CHAIN;
} }
}, this)); }.bind(this));
// delay a bit after the intense refresh animation from // delay a bit after the intense refresh animation from
// fetch // fetch
chain = chain.then(_.bind(function() { chain = chain.then(function() {
return this.animationFactory.getDelayedPromise(300); return this.animationFactory.getDelayedPromise(300);
}, this)); }.bind(this));
chain = chain.then(_.bind(function() { chain = chain.then(function() {
// highlight last commit on o/master to color of // highlight last commit on o/master to color of
// local branch // local branch
return this.animationFactory.playHighlightPromiseAnimation( return this.animationFactory.playHighlightPromiseAnimation(
this.getCommitFromRef(remoteBranch), this.getCommitFromRef(remoteBranch),
localBranch localBranch
); );
}, this)); }.bind(this));
chain = chain.then(_.bind(function() { chain = chain.then(function() {
pendingFetch.dontResolvePromise = true; pendingFetch.dontResolvePromise = true;
try { try {
@ -1410,7 +1410,7 @@ GitEngine.prototype.pullFinishWithRebase = function(
this.checkout(localBranch); this.checkout(localBranch);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
} }
}, this)); }.bind(this));
chain = chain.fail(catchShortCircuit); chain = chain.fail(catchShortCircuit);
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
@ -1424,43 +1424,43 @@ GitEngine.prototype.pullFinishWithMerge = function(
var chain = pendingFetch.chain; var chain = pendingFetch.chain;
var deferred = pendingFetch.deferred; var deferred = pendingFetch.deferred;
chain = chain.then(_.bind(function() { chain = chain.then(function() {
if (this.mergeCheck(remoteBranch, localBranch)) { if (this.mergeCheck(remoteBranch, localBranch)) {
this.command.set('error', new CommandResult({ this.command.set('error', new CommandResult({
msg: intl.str('git-result-uptodate') msg: intl.str('git-result-uptodate')
})); }));
throw SHORT_CIRCUIT_CHAIN; throw SHORT_CIRCUIT_CHAIN;
} }
}, this)); }.bind(this));
// delay a bit after the intense refresh animation from // delay a bit after the intense refresh animation from
// fetch // fetch
chain = chain.then(_.bind(function() { chain = chain.then(function() {
return this.animationFactory.getDelayedPromise(300); return this.animationFactory.getDelayedPromise(300);
}, this)); }.bind(this));
chain = chain.then(_.bind(function() { chain = chain.then(function() {
// highlight last commit on o/master to color of // highlight last commit on o/master to color of
// local branch // local branch
return this.animationFactory.playHighlightPromiseAnimation( return this.animationFactory.playHighlightPromiseAnimation(
this.getCommitFromRef(remoteBranch), this.getCommitFromRef(remoteBranch),
localBranch localBranch
); );
}, this)); }.bind(this));
chain = chain.then(_.bind(function() { chain = chain.then(function() {
// highlight commit on master to color of remote // highlight commit on master to color of remote
return this.animationFactory.playHighlightPromiseAnimation( return this.animationFactory.playHighlightPromiseAnimation(
this.getCommitFromRef(localBranch), this.getCommitFromRef(localBranch),
remoteBranch remoteBranch
); );
}, this)); }.bind(this));
// delay and merge // delay and merge
chain = chain.then(_.bind(function() { chain = chain.then(function() {
return this.animationFactory.getDelayedPromise(700); return this.animationFactory.getDelayedPromise(700);
}, this)); }.bind(this));
chain = chain.then(_.bind(function() { chain = chain.then(function() {
var newCommit = this.merge(remoteBranch); var newCommit = this.merge(remoteBranch);
if (!newCommit) { if (!newCommit) {
// it is a fast forward // it is a fast forward
@ -1471,25 +1471,25 @@ GitEngine.prototype.pullFinishWithMerge = function(
newCommit, newCommit,
this.gitVisuals this.gitVisuals
); );
}, this)); }.bind(this));
chain = chain.fail(catchShortCircuit); chain = chain.fail(catchShortCircuit);
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
}; };
GitEngine.prototype.fakeTeamwork = function(numToMake, branch) { GitEngine.prototype.fakeTeamwork = function(numToMake, branch) {
var makeOriginCommit = _.bind(function() { var makeOriginCommit = function() {
var id = this.getUniqueID(); var id = this.getUniqueID();
return this.origin.receiveTeamwork(id, branch, this.animationQueue); return this.origin.receiveTeamwork(id, branch, this.animationQueue);
}, this); }.bind(this);
var chainStep = _.bind(function() { var chainStep = function() {
var newCommit = makeOriginCommit(); var newCommit = makeOriginCommit();
return this.animationFactory.playCommitBirthPromiseAnimation( return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit, newCommit,
this.origin.gitVisuals this.origin.gitVisuals
); );
}, this); }.bind(this);
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
@ -2033,7 +2033,7 @@ GitEngine.prototype.hgRebase = function(destination, base) {
return id; return id;
}); });
chain = chain.then(_.bind(function() { chain = chain.then(function() {
// now we just moved a bunch of commits, but we havent updated the // now we just moved a bunch of commits, but we havent updated the
// dangling guys. lets do that and then prune // dangling guys. lets do that and then prune
var anyChange = this.updateCommitParentsForHgRebase(masterSet); var anyChange = this.updateCommitParentsForHgRebase(masterSet);
@ -2041,16 +2041,16 @@ GitEngine.prototype.hgRebase = function(destination, base) {
return; return;
} }
return this.animationFactory.playRefreshAnimationSlow(this.gitVisuals); return this.animationFactory.playRefreshAnimationSlow(this.gitVisuals);
}, this)); }.bind(this));
chain = chain.then(_.bind(function() { chain = chain.then(function() {
return this.updateAllBranchesForHgAndPlay(branchList); return this.updateAllBranchesForHgAndPlay(branchList);
}, this)); }.bind(this));
chain = chain.then(_.bind(function() { chain = chain.then(function() {
// now that we have moved branches, lets prune // now that we have moved branches, lets prune
return this.pruneTreeAndPlay(); return this.pruneTreeAndPlay();
}, this)); }.bind(this));
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
}; };
@ -2194,7 +2194,7 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation,
var deferred = Q.defer(); var deferred = Q.defer();
deferred.promise deferred.promise
.then(_.bind(function(userSpecifiedRebase) { .then(function(userSpecifiedRebase) {
// first, they might have dropped everything (annoying) // first, they might have dropped everything (annoying)
if (!userSpecifiedRebase.length) { if (!userSpecifiedRebase.length) {
throw new CommandResult({ throw new CommandResult({
@ -2204,12 +2204,12 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation,
// finish the rebase crap and animate! // finish the rebase crap and animate!
this.rebaseFinish(userSpecifiedRebase, {}, targetSource, currentLocation); this.rebaseFinish(userSpecifiedRebase, {}, targetSource, currentLocation);
}, this)) }.bind(this))
.fail(_.bind(function(err) { .fail(function(err) {
this.filterError(err); this.filterError(err);
this.command.set('error', err); this.command.set('error', err);
this.animationQueue.start(); this.animationQueue.start();
}, this)) }.bind(this))
.done(); .done();
// If we have a solution provided, set up the GUI to display it by default // If we have a solution provided, set up the GUI to display it by default
@ -2316,7 +2316,7 @@ GitEngine.prototype.rebaseFinish = function(
var base = this.getCommitFromRef(targetSource); var base = this.getCommitFromRef(targetSource);
var hasStartedChain = false; var hasStartedChain = false;
// each step makes a new commit // each step makes a new commit
var chainStep = _.bind(function(oldCommit) { var chainStep = function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id')); var newId = this.rebaseAltID(oldCommit.get('id'));
var parents; var parents;
if (!options.preserveMerges || !hasStartedChain) { if (!options.preserveMerges || !hasStartedChain) {
@ -2338,7 +2338,7 @@ GitEngine.prototype.rebaseFinish = function(
newCommit, newCommit,
this.gitVisuals this.gitVisuals
); );
}, this); }.bind(this);
// set up the promise chain // set up the promise chain
_.each(toRebase, function(commit) { _.each(toRebase, function(commit) {
@ -2347,7 +2347,7 @@ GitEngine.prototype.rebaseFinish = function(
}); });
}, this); }, this);
chain = chain.then(_.bind(function() { chain = chain.then(function() {
if (this.resolveID(currentLocation).get('type') == 'commit') { if (this.resolveID(currentLocation).get('type') == 'commit') {
// we referenced a commit like git rebase C2 C1, so we have // we referenced a commit like git rebase C2 C1, so we have
// to manually check out C1' // to manually check out C1'
@ -2358,7 +2358,7 @@ GitEngine.prototype.rebaseFinish = function(
this.checkout(currentLocation); this.checkout(currentLocation);
} }
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }.bind(this));
if (!options.dontResolvePromise) { if (!options.dontResolvePromise) {
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
@ -2600,9 +2600,9 @@ GitEngine.prototype.externalRefresh = function() {
GitEngine.prototype.dispatch = function(command, deferred) { GitEngine.prototype.dispatch = function(command, deferred) {
this.command = command; this.command = command;
var vcs = command.get('vcs'); var vcs = command.get('vcs');
var executeCommand = _.bind(function() { var executeCommand = function() {
this.dispatchProcess(command, deferred); this.dispatchProcess(command, deferred);
}, this); }.bind(this);
// handle mode change will either execute sync or // handle mode change will either execute sync or
// animate during tree pruning / etc // animate during tree pruning / etc
this.handleModeChange(vcs, executeCommand); this.handleModeChange(vcs, executeCommand);
@ -2610,9 +2610,9 @@ GitEngine.prototype.dispatch = function(command, deferred) {
GitEngine.prototype.dispatchProcess = function(command, deferred) { GitEngine.prototype.dispatchProcess = function(command, deferred) {
// set up the animation queue // set up the animation queue
var whenDone = _.bind(function() { var whenDone = function() {
command.finishWith(deferred); command.finishWith(deferred);
}, this); }.bind(this);
this.animationQueue = new AnimationQueue({ this.animationQueue = new AnimationQueue({
callback: whenDone callback: whenDone
}); });

View file

@ -159,7 +159,7 @@ TreeCompare.compareBranchesWithinTreesHashAgnostic = function(treeA, treeB, bran
this.reduceTreeFields([treeA, treeB]); this.reduceTreeFields([treeA, treeB]);
// get a function to compare branch objects without hashes // get a function to compare branch objects without hashes
var compareBranchObjs = _.bind(function(branchA, branchB) { var compareBranchObjs = function(branchA, branchB) {
if (!branchA || !branchB) { if (!branchA || !branchB) {
return false; return false;
} }
@ -171,7 +171,7 @@ TreeCompare.compareBranchesWithinTreesHashAgnostic = function(treeA, treeB, bran
branchB.target = this.getBaseRef(branchB.target); branchB.target = this.getBaseRef(branchB.target);
return _.isEqual(branchA, branchB); return _.isEqual(branchA, branchB);
}, this); }.bind(this);
// and a function to compare recursively without worrying about hashes // and a function to compare recursively without worrying about hashes
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB); var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
@ -268,7 +268,7 @@ TreeCompare.getRecurseCompareHashAgnostic = function(treeA, treeB) {
// recursive compare. // recursive compare.
// some buildup functions // some buildup functions
var getStrippedCommitCopy = _.bind(function(commit) { var getStrippedCommitCopy = function(commit) {
if (!commit) { return {}; } if (!commit) { return {}; }
return _.extend( return _.extend(
{}, {},
@ -278,7 +278,7 @@ TreeCompare.getRecurseCompareHashAgnostic = function(treeA, treeB) {
parents: null parents: null
} }
); );
}, this); }.bind(this);
var isEqual = function(commitA, commitB) { var isEqual = function(commitA, commitB) {
return _.isEqual( return _.isEqual(

View file

@ -272,9 +272,9 @@ var LevelBuilder = Level.extend({
deferred: whenDoneEditing deferred: whenDoneEditing
}); });
whenDoneEditing.promise whenDoneEditing.promise
.then(_.bind(function(levelObj) { .then(function(levelObj) {
this.startDialogObj = levelObj; this.startDialogObj = levelObj;
}, this)) }.bind(this))
.fail(function() { .fail(function() {
// nothing to do, they dont want to edit it apparently // nothing to do, they dont want to edit it apparently
}) })
@ -316,10 +316,10 @@ var LevelBuilder = Level.extend({
] ]
}); });
askForHintView.getPromise() askForHintView.getPromise()
.then(_.bind(this.defineHint, this)) .then(this.defineHint, this))
.fail(_.bind(function() { .fail(function() {
this.level.hint = {'en_US': ''}; this.level.hint = {'en_US': ''};
}, this)) }.bind(this))
.done(function() { .done(function() {
askForHintDeferred.resolve(); askForHintDeferred.resolve();
}); });
@ -337,13 +337,13 @@ var LevelBuilder = Level.extend({
] ]
}); });
askForStartView.getPromise() askForStartView.getPromise()
.then(_.bind(function() { .then(function() {
// oh boy this is complex // oh boy this is complex
var whenEditedDialog = Q.defer(); var whenEditedDialog = Q.defer();
// the undefined here is the command that doesnt need resolving just yet... // the undefined here is the command that doesnt need resolving just yet...
this.editDialog(undefined, whenEditedDialog); this.editDialog(undefined, whenEditedDialog);
return whenEditedDialog.promise; return whenEditedDialog.promise;
}, this)) }.bind(this))
.fail(function() { .fail(function() {
// if they dont want to edit the start dialog, do nothing // if they dont want to edit the start dialog, do nothing
}) })
@ -352,14 +352,14 @@ var LevelBuilder = Level.extend({
}); });
} }
chain = chain.done(_.bind(function() { chain = chain.done(function() {
// ok great! lets just give them the goods // ok great! lets just give them the goods
new MarkdownPresenter({ new MarkdownPresenter({
fillerText: JSON.stringify(this.getExportObj(), null, 2), fillerText: JSON.stringify(this.getExportObj(), null, 2),
previewText: intl.str('share-json') previewText: intl.str('share-json')
}); });
command.finishWith(deferred); command.finishWith(deferred);
}, this)); }.bind(this));
masterDeferred.resolve(); masterDeferred.resolve();
}, },

View file

@ -204,7 +204,7 @@ var Level = Sandbox.extend({
// If the goal visualization gets dragged to the right side of the screen, then squeeze the main // If the goal visualization gets dragged to the right side of the screen, then squeeze the main
// repo visualization a bit to make room. This way, you could have the goal window hang out on // repo visualization a bit to make room. This way, you could have the goal window hang out on
// the right side of the screen and still see the repo visualization. // the right side of the screen and still see the repo visualization.
this.goalVis.customEvents.on('drag', _.bind(function(event, ui) { this.goalVis.customEvents.on('drag', function(event, ui) {
if (ui.position.left > 0.5 * $(window).width()) { if (ui.position.left > 0.5 * $(window).width()) {
if (!$('#goalPlaceholder').is(':visible')) { if (!$('#goalPlaceholder').is(':visible')) {
$('#goalPlaceholder').show(); $('#goalPlaceholder').show();
@ -216,7 +216,7 @@ var Level = Sandbox.extend({
this.mainVis.myResize(); this.mainVis.myResize();
} }
} }
}, this)); }.bind(this));
return this.goalCanvasHolder; return this.goalCanvasHolder;
}, },
@ -242,14 +242,14 @@ var Level = Sandbox.extend({
showSolution: function(command, deferred) { showSolution: function(command, deferred) {
var toIssue = this.level.solutionCommand; var toIssue = this.level.solutionCommand;
var issueFunc = _.bind(function() { var issueFunc = function() {
this.isShowingSolution = true; this.isShowingSolution = true;
Main.getEventBaton().trigger( Main.getEventBaton().trigger(
'commandSubmitted', 'commandSubmitted',
toIssue toIssue
); );
log.showLevelSolution(this.getEnglishName()); log.showLevelSolution(this.getEnglishName());
}, this); }.bind(this);
var commandStr = command.get('rawStr'); var commandStr = command.get('rawStr');
if (!this.testOptionOnString(commandStr, 'noReset')) { if (!this.testOptionOnString(commandStr, 'noReset')) {
@ -368,16 +368,16 @@ var Level = Sandbox.extend({
initGitShim: function(options) { initGitShim: function(options) {
// ok we definitely want a shim here // ok we definitely want a shim here
this.gitShim = new GitShim({ this.gitShim = new GitShim({
beforeCB: _.bind(this.beforeCommandCB, this), beforeCB: this.beforeCommandCB, this),
afterCB: _.bind(this.afterCommandCB, this), afterCB: this.afterCommandCB, this),
afterDeferHandler: _.bind(this.afterCommandDefer, this) afterDeferHandler: this.afterCommandDefer, this)
}); });
}, },
undo: function() { undo: function() {
this.gitCommandsIssued.pop(); this.gitCommandsIssued.pop();
Level.__super__.undo.apply(this, arguments); Level.__super__.undo.apply(this, arguments);
}, }.bind(this)
afterCommandCB: function(command) { afterCommandCB: function(command) {
if (command.get('error')) { if (command.get('error')) {
@ -516,13 +516,13 @@ var Level = Sandbox.extend({
}, },
getInstantCommands: function() { getInstantCommands: function() {
var getHint = _.bind(function() { var getHint = function() {
var hint = intl.getHint(this.level); var hint = intl.getHint(this.level);
if (!hint || !hint.length) { if (!hint || !hint.length) {
return intl.str('no-hint'); return intl.str('no-hint');
} }
return hint; return hint;
}, this); }.bind(this);
return [ return [
[/^help$|^\?$/, function() { [/^help$|^\?$/, function() {

View file

@ -55,9 +55,9 @@ var CommandBuffer = Backbone.Model.extend({
setTimeout: function() { setTimeout: function() {
this.timeout = setTimeout(_.bind(function() { this.timeout = setTimeout(function() {
this.sipFromBuffer(); this.sipFromBuffer();
}, this), TIME.betweenCommandsDelay); }.bind(this), TIME.betweenCommandsDelay);
}, },
popAndProcess: function() { popAndProcess: function() {
@ -79,9 +79,9 @@ var CommandBuffer = Backbone.Model.extend({
command.set('status', 'processing'); command.set('status', 'processing');
var deferred = Q.defer(); var deferred = Q.defer();
deferred.promise.then(_.bind(function() { deferred.promise.then(function() {
this.setTimeout(); this.setTimeout();
}, this)); }.bind(this));
var eventName = command.get('eventName'); var eventName = command.get('eventName');
if (!eventName) { if (!eventName) {

View file

@ -68,7 +68,7 @@ var Sandbox = Backbone.View.extend({
initGitShim: function(options) { initGitShim: function(options) {
this.gitShim = new GitShim({ this.gitShim = new GitShim({
beforeCB: _.bind(this.beforeCommandCB, this) beforeCB: this.beforeCommandCB, this)
}); });
}, },
@ -83,7 +83,7 @@ var Sandbox = Backbone.View.extend({
Main.getEventBaton().stealBaton('levelExited', this.levelExited, this); Main.getEventBaton().stealBaton('levelExited', this.levelExited, this);
this.insertGitShim(); this.insertGitShim();
}, }.bind(this)
releaseControl: function() { releaseControl: function() {
// we will be handling commands that are submitted, mainly to add the sanadbox // we will be handling commands that are submitted, mainly to add the sanadbox
@ -331,7 +331,7 @@ var Sandbox = Backbone.View.extend({
fillerText: ' ' fillerText: ' '
}); });
jsonGrabber.deferred.promise jsonGrabber.deferred.promise
.then(_.bind(function(treeJSON) { .then(function(treeJSON) {
try { try {
this.mainVis.gitEngine.loadTree(JSON.parse(treeJSON)); this.mainVis.gitEngine.loadTree(JSON.parse(treeJSON));
} catch(e) { } catch(e) {
@ -351,7 +351,7 @@ var Sandbox = Backbone.View.extend({
}] }]
}); });
} }
}, this)) }.bind(this))
.fail(function() { }) .fail(function() { })
.done(function() { .done(function() {
command.finishWith(deferred); command.finishWith(deferred);
@ -365,7 +365,7 @@ var Sandbox = Backbone.View.extend({
}); });
jsonGrabber.deferred.promise jsonGrabber.deferred.promise
.then(_.bind(function(inputText) { .then(function(inputText) {
var Level = require('../level').Level; var Level = require('../level').Level;
try { try {
var levelJSON = JSON.parse(inputText); var levelJSON = JSON.parse(inputText);
@ -397,7 +397,7 @@ var Sandbox = Backbone.View.extend({
}); });
command.finishWith(deferred); command.finishWith(deferred);
} }
}, this)) }.bind(this))
.fail(function() { .fail(function() {
command.finishWith(deferred); command.finishWith(deferred);
}) })
@ -456,10 +456,10 @@ var Sandbox = Backbone.View.extend({
var helpDialog = new MultiView({ var helpDialog = new MultiView({
childViews: intl.getDialog(require('../dialogs/sandbox')) childViews: intl.getDialog(require('../dialogs/sandbox'))
}); });
helpDialog.getPromise().then(_.bind(function() { helpDialog.getPromise().then(function() {
// the view has been closed, lets go ahead and resolve our command // the view has been closed, lets go ahead and resolve our command
command.finishWith(deferred); command.finishWith(deferred);
}, this)) }.bind(this))
.done(); .done();
} }
}); });

View file

@ -68,14 +68,14 @@ var MarkdownGrabber = ContainedBase.extend({
// do button stuff // do button stuff
var buttonDefer = Q.defer(); var buttonDefer = Q.defer();
buttonDefer.promise buttonDefer.promise
.then(_.bind(this.confirmed, this)) .then(this.confirmed, this))
.fail(_.bind(this.cancelled, this)) .fail(this.cancelled, this))
.done(); .done();
var confirmCancel = new Views.ConfirmCancelView({ var confirmCancel = new Views.ConfirmCancelView({
deferred: buttonDefer, deferred: buttonDefer,
destination: this.getDestination() destination: this.getDestination()
}); }.bind(this)
} }
this.updatePreview(); this.updatePreview();
@ -98,7 +98,7 @@ var MarkdownGrabber = ContainedBase.extend({
keyup: function() { keyup: function() {
if (!this.throttledPreview) { if (!this.throttledPreview) {
this.throttledPreview = _.throttle( this.throttledPreview = _.throttle(
_.bind(this.updatePreview, this), this.updatePreview, this),
500 500
); );
} }
@ -107,7 +107,7 @@ var MarkdownGrabber = ContainedBase.extend({
getRawText: function() { getRawText: function() {
return this.$('textarea').val(); return this.$('textarea').val();
}, }.bind(this)
exportToArray: function() { exportToArray: function() {
return this.getRawText().split('\n'); return this.getRawText().split('\n');
@ -149,13 +149,13 @@ var MarkdownPresenter = ContainedBase.extend({
destination: this.getDestination() destination: this.getDestination()
}); });
confirmCancel.deferred.promise confirmCancel.deferred.promise
.then(_.bind(function() { .then(function() {
this.deferred.resolve(this.grabText()); this.deferred.resolve(this.grabText());
}, this)) }.bind(this))
.fail(_.bind(function() { .fail(function() {
this.deferred.reject(); this.deferred.reject();
}, this)) }.bind(this))
.done(_.bind(this.die, this)); .done(this.die, this));
} }
this.show(); this.show();
@ -163,7 +163,7 @@ var MarkdownPresenter = ContainedBase.extend({
grabText: function() { grabText: function() {
return this.$('textarea').val(); return this.$('textarea').val();
} }.bind(this)
}); });
var DemonstrationBuilder = ContainedBase.extend({ var DemonstrationBuilder = ContainedBase.extend({
@ -230,8 +230,8 @@ var DemonstrationBuilder = ContainedBase.extend({
}); });
buttonDeferred.promise buttonDeferred.promise
.then(_.bind(this.confirmed, this)) .then(this.confirmed, this))
.fail(_.bind(this.cancelled, this)) .fail(this.cancelled, this))
.done(); .done();
}, },
@ -243,7 +243,7 @@ var DemonstrationBuilder = ContainedBase.extend({
options: this.getExportObj() options: this.getExportObj()
}] }]
}); });
}, }.bind(this)
getExportObj: function() { getExportObj: function() {
return { return {
@ -326,13 +326,13 @@ var MultiViewBuilder = ContainedBase.extend({
deferred: whenDone deferred: whenDone
}); });
whenDone.promise whenDone.promise
.then(_.bind(function() { .then(function() {
var newView = { var newView = {
type: type, type: type,
options: builder.getExportObj() options: builder.getExportObj()
}; };
this.addChildViewObj(newView); this.addChildViewObj(newView);
}, this)) }.bind(this))
.fail(function() { .fail(function() {
// they dont want to add the view apparently, so just return // they dont want to add the view apparently, so just return
}) })
@ -367,7 +367,7 @@ var MultiViewBuilder = ContainedBase.extend({
fromObj: this.getChildViews()[index] fromObj: this.getChildViews()[index]
}); });
whenDone.promise whenDone.promise
.then(_.bind(function() { .then(function() {
var newView = { var newView = {
type: type, type: type,
options: builder.getExportObj() options: builder.getExportObj()
@ -375,7 +375,7 @@ var MultiViewBuilder = ContainedBase.extend({
var views = this.getChildViews(); var views = this.getChildViews();
views[index] = newView; views[index] = newView;
this.setChildViews(views); this.setChildViews(views);
}, this)) }.bind(this))
.fail(function() { }) .fail(function() { })
.done(); .done();
}, },

View file

@ -59,15 +59,15 @@ var CommandPromptView = Backbone.View.extend({
// we need to capture some of these events. // we need to capture some of these events.
var keyToFuncMap = { var keyToFuncMap = {
enter: _.bind(function() { enter: function() {
this.submit(); this.submit();
}, this), }.bind(this),
up: _.bind(function() { up: function() {
this.commandSelectChange(1); this.commandSelectChange(1);
}, this), }.bind(this),
down: _.bind(function() { down: function() {
this.commandSelectChange(-1); this.commandSelectChange(-1);
}, this) }.bind(this)
}; };
var key = keyboard.mapKeycodeToKey(e.which || e.keyCode); var key = keyboard.mapKeycodeToKey(e.which || e.keyCode);

View file

@ -97,10 +97,10 @@ var GitDemonstrationView = ContainedBase.extend({
var whenHaveTree = Q.defer(); var whenHaveTree = Q.defer();
HeadlessGit.getTreeQuick(this.options.beforeCommand, whenHaveTree); HeadlessGit.getTreeQuick(this.options.beforeCommand, whenHaveTree);
whenHaveTree.promise.then(_.bind(function(tree) { whenHaveTree.promise.then(function(tree) {
this.mainVis.gitEngine.loadTree(tree); this.mainVis.gitEngine.loadTree(tree);
this.mainVis.gitVisuals.refreshTreeHarsh(); this.mainVis.gitVisuals.refreshTreeHarsh();
}, this)); }.bind(this));
}, },
takeControl: function() { takeControl: function() {
@ -142,11 +142,11 @@ var GitDemonstrationView = ContainedBase.extend({
var whenDone = Q.defer(); var whenDone = Q.defer();
this.dispatchCommand(this.JSON.command, whenDone); this.dispatchCommand(this.JSON.command, whenDone);
whenDone.promise.then(_.bind(function() { whenDone.promise.then(function() {
this.$el.toggleClass('demonstrating', false); this.$el.toggleClass('demonstrating', false);
this.$el.toggleClass('demonstrated', true); this.$el.toggleClass('demonstrated', true);
this.releaseControl(); this.releaseControl();
}, this)); }.bind(this));
}, },
negative: function(e) { negative: function(e) {
@ -168,11 +168,11 @@ var GitDemonstrationView = ContainedBase.extend({
var chainPromise = chainDeferred.promise; var chainPromise = chainDeferred.promise;
_.each(commands, function(command, index) { _.each(commands, function(command, index) {
chainPromise = chainPromise.then(_.bind(function() { chainPromise = chainPromise.then(function() {
var myDefer = Q.defer(); var myDefer = Q.defer();
this.mainVis.gitEngine.dispatch(command, myDefer); this.mainVis.gitEngine.dispatch(command, myDefer);
return myDefer.promise; return myDefer.promise;
}, this)); }.bind(this));
chainPromise = chainPromise.then(function() { chainPromise = chainPromise.then(function() {
return Q.delay(300); return Q.delay(300);
}); });
@ -205,12 +205,12 @@ var GitDemonstrationView = ContainedBase.extend({
show: function() { show: function() {
this.takeControl(); this.takeControl();
if (this.visFinished) { if (this.visFinished) {
setTimeout(_.bind(function() { setTimeout(function() {
if (this.shown) { if (this.shown) {
this.mainVis.setTreeIndex(300); this.mainVis.setTreeIndex(300);
this.mainVis.showHarsh(); this.mainVis.showHarsh();
} }
}, this), this.getAnimationTime() * 1.5); }.bind(this), this.getAnimationTime() * 1.5);
} }
this.shown = true; this.shown = true;
@ -231,14 +231,14 @@ var GitDemonstrationView = ContainedBase.extend({
smallCanvas: true, smallCanvas: true,
zIndex: -1 zIndex: -1
}); });
this.mainVis.customEvents.on('paperReady', _.bind(function() { this.mainVis.customEvents.on('paperReady', function() {
this.visFinished = true; this.visFinished = true;
this.dispatchBeforeCommand(); this.dispatchBeforeCommand();
if (this.shown) { if (this.shown) {
// show the canvas once its done if we are shown // show the canvas once its done if we are shown
this.show(); this.show();
} }
}, this)); }.bind(this));
} }
}); });

View file

@ -70,9 +70,9 @@ var ContainedBase = BaseView.extend({
die: function() { die: function() {
this.hide(); this.hide();
setTimeout(_.bind(function() { setTimeout(function() {
this.tearDown(); this.tearDown();
}, this), this.getAnimationTime() * 1.1); }.bind(this), this.getAnimationTime() * 1.1);
} }
}); });
@ -107,7 +107,7 @@ var GeneralButton = ContainedBase.extend({
click: function() { click: function() {
if (!this.clickFunc) { if (!this.clickFunc) {
this.clickFunc = _.throttle( this.clickFunc = _.throttle(
_.bind(this.sendClick, this), this.sendClick, this),
500 500
); );
} }
@ -116,7 +116,7 @@ var GeneralButton = ContainedBase.extend({
sendClick: function() { sendClick: function() {
this.navEvents.trigger('click'); this.navEvents.trigger('click');
} }.bind(this)
}); });
var ConfirmCancelView = ResolveRejectBase.extend({ var ConfirmCancelView = ResolveRejectBase.extend({
@ -252,19 +252,19 @@ var ModalView = Backbone.View.extend({
// on reflow, change our class to animate. for whatever // on reflow, change our class to animate. for whatever
// reason if this is done immediately, chrome might combine // reason if this is done immediately, chrome might combine
// the two changes and lose the ability to animate and it looks bad. // the two changes and lose the ability to animate and it looks bad.
process.nextTick(_.bind(function() { process.nextTick(function() {
this.toggleShow(true); this.toggleShow(true);
}, this)); }.bind(this));
}, },
hide: function() { hide: function() {
this.toggleShow(false); this.toggleShow(false);
setTimeout(_.bind(function() { setTimeout(function() {
// if we are still hidden... // if we are still hidden...
if (!this.shown) { if (!this.shown) {
this.toggleZ(false); this.toggleZ(false);
} }
}, this), this.getAnimationTime()); }.bind(this), this.getAnimationTime());
}, },
getInsideElement: function() { getInsideElement: function() {
@ -388,9 +388,9 @@ var ConfirmCancelTerminal = Backbone.View.extend({
buttonDefer.promise buttonDefer.promise
.then(this.deferred.resolve) .then(this.deferred.resolve)
.fail(this.deferred.reject) .fail(this.deferred.reject)
.done(_.bind(function() { .done(function() {
this.close(); this.close();
}, this)); }.bind(this));
// also setup keyboard // also setup keyboard
this.navEvents = _.clone(Backbone.Events); this.navEvents = _.clone(Backbone.Events);
@ -578,11 +578,11 @@ var CanvasTerminalHolder = BaseView.extend({
// If the entire window gets resized such that the terminal is outside the view, then // If the entire window gets resized such that the terminal is outside the view, then
// move it back into the view, and expand/shrink it vertically as necessary. // move it back into the view, and expand/shrink it vertically as necessary.
$(window).on('resize', _.debounce(_.bind(this.recalcLayout, this), 300)); $(window).on('resize', _.debounce(this.recalcLayout, this), 300));
if (options.additionalClass) { if (options.additionalClass) {
this.$el.addClass(options.additionalClass); this.$el.addClass(options.additionalClass);
} }.bind(this)
}, },
getAnimationTime: function() { return 700; }, getAnimationTime: function() { return 700; },
@ -595,9 +595,9 @@ var CanvasTerminalHolder = BaseView.extend({
this.minimize(); this.minimize();
this.inDom = false; this.inDom = false;
setTimeout(_.bind(function() { setTimeout(function() {
this.tearDown(); this.tearDown();
}, this), this.getAnimationTime()); }.bind(this), this.getAnimationTime());
}, },
minimize: function() { minimize: function() {

View file

@ -42,7 +42,7 @@ var LevelDropdownView = ContainedBase.extend({
this.navEvents = _.clone(Backbone.Events); this.navEvents = _.clone(Backbone.Events);
this.navEvents.on('clickedID', _.debounce( this.navEvents.on('clickedID', _.debounce(
_.bind(this.loadLevelID, this), this.loadLevelID, this),
300, 300,
true true
)); ));
@ -60,7 +60,7 @@ var LevelDropdownView = ContainedBase.extend({
enter: 'positive' enter: 'positive'
}, },
wait: true wait: true
}); }.bind(this)
this.sequences = LevelStore.getSequences(); this.sequences = LevelStore.getSequences();
this.sequenceToLevels = LevelStore.getSequenceToLevels(); this.sequenceToLevels = LevelStore.getSequenceToLevels();

View file

@ -84,15 +84,15 @@ var MultiView = Backbone.View.extend({
}, },
getPosFunc: function() { getPosFunc: function() {
return _.debounce(_.bind(function() { return _.debounce(function() {
this.navForward(); this.navForward();
}, this), this.navEventDebounce, true); }.bind(this), this.navEventDebounce, true);
}, },
getNegFunc: function() { getNegFunc: function() {
return _.debounce(_.bind(function() { return _.debounce(function() {
this.navBackward(); this.navBackward();
}, this), this.navEventDebounce, true); }.bind(this), this.navEventDebounce, true);
}, },
lock: function() { lock: function() {

View file

@ -118,12 +118,12 @@ var InteractiveRebaseView = ContainedBase.extend({
// control for button // control for button
var deferred = Q.defer(); var deferred = Q.defer();
deferred.promise deferred.promise
.then(_.bind(function() { .then(function() {
this.confirm(); this.confirm();
}, this)) }.bind(this))
.fail(_.bind(function() { .fail(function() {
this.cancel(); this.cancel();
}, this)) }.bind(this))
.done(); .done();
// finally get our buttons // finally get our buttons
@ -170,9 +170,9 @@ var RebaseEntryView = Backbone.View.extend({
// hacky :( who would have known jquery barfs on ids with %'s and quotes // hacky :( who would have known jquery barfs on ids with %'s and quotes
this.listEntry = this.$el.children(':last'); this.listEntry = this.$el.children(':last');
this.listEntry.delegate('#toggleButton', 'click', _.bind(function() { this.listEntry.delegate('#toggleButton', 'click', function() {
this.toggle(); this.toggle();
}, this)); }.bind(this));
} }
}); });

View file

@ -77,12 +77,12 @@ AnimationFactory.highlightEachWithPromise = function(
destObj destObj
) { ) {
_.each(toHighlight, function(commit) { _.each(toHighlight, function(commit) {
chain = chain.then(_.bind(function() { chain = chain.then(function() {
return this.playHighlightPromiseAnimation( return this.playHighlightPromiseAnimation(
commit, commit,
destObj destObj
); );
}, this)); }.bind(this));
}, this); }, this);
return chain; return chain;
}; };

View file

@ -42,9 +42,9 @@ var AnimationQueue = Backbone.Model.extend({
}, },
thenFinish: function(promise, deferred) { thenFinish: function(promise, deferred) {
promise.then(_.bind(function() { promise.then(function() {
this.finish(); this.finish();
}, this)); }.bind(this));
promise.fail(function(e) { promise.fail(function(e) {
console.log('uncaught error', e); console.log('uncaught error', e);
throw e; throw e;
@ -97,9 +97,9 @@ var AnimationQueue = Backbone.Model.extend({
next.run(); next.run();
this.set('index', index + 1); this.set('index', index + 1);
setTimeout(_.bind(function() { setTimeout(function() {
this.next(); 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 // a single animation is just something with a timeout, but now
// we want to resolve a deferred when the animation finishes // we want to resolve a deferred when the animation finishes
this.get('closure')(); this.get('closure')();
setTimeout(_.bind(function() { setTimeout(function() {
this.get('deferred').resolve(); this.get('deferred').resolve();
}, this), this.get('duration')); }.bind(this), this.get('duration'));
}, },
then: function(func) { then: function(func) {

View file

@ -217,7 +217,7 @@ GitVisuals.prototype.finishAnimation = function() {
var textString = 'Solved!!\n:D'; var textString = 'Solved!!\n:D';
var text = null; var text = null;
var makeText = _.bind(function() { var makeText = function() {
text = this.paper.text( text = this.paper.text(
this.paper.width / 2, this.paper.width / 2,
this.paper.height / 2, this.paper.height / 2,
@ -233,7 +233,7 @@ GitVisuals.prototype.finishAnimation = function() {
fill: '#000' fill: '#000'
}); });
text.animate({ opacity: 1 }, defaultTime); text.animate({ opacity: 1 }, defaultTime);
}, this); }.bind(this);
// this is a BIG ANIMATION but it ends up just being // this is a BIG ANIMATION but it ends up just being
// a sweet chain of promises but is pretty nice. this is // a sweet chain of promises but is pretty nice. this is
@ -243,47 +243,47 @@ GitVisuals.prototype.finishAnimation = function() {
deferred.promise deferred.promise
// first fade out everything but circles // first fade out everything but circles
.then(_.bind(function() { .then(function() {
return this.animateAllAttrKeys( return this.animateAllAttrKeys(
{ exclude: ['circle'] }, { exclude: ['circle'] },
{ opacity: 0 }, { opacity: 0 },
defaultTime * 1.1 defaultTime * 1.1
); );
}, this)) }.bind(this))
// then make circle radii bigger // then make circle radii bigger
.then(_.bind(function() { .then(function() {
return this.animateAllAttrKeys( return this.animateAllAttrKeys(
{ exclude: ['arrow', 'rect', 'path', 'text'] }, { exclude: ['arrow', 'rect', 'path', 'text'] },
{ r: nodeRadius * 2 }, { r: nodeRadius * 2 },
defaultTime * 1.5 defaultTime * 1.5
); );
}, this)) }.bind(this))
// then shrink em super fast // then shrink em super fast
.then(_.bind(function() { .then(function() {
return this.animateAllAttrKeys( return this.animateAllAttrKeys(
{ exclude: ['arrow', 'rect', 'path', 'text'] }, { exclude: ['arrow', 'rect', 'path', 'text'] },
{ r: nodeRadius * 0.75 }, { r: nodeRadius * 0.75 },
defaultTime * 0.5 defaultTime * 0.5
); );
}, this)) }.bind(this))
// then explode them and display text // then explode them and display text
.then(_.bind(function() { .then(function() {
makeText(); makeText();
return this.explodeNodes(); return this.explodeNodes();
}, this)) }.bind(this))
.then(_.bind(function() { .then(function() {
return this.explodeNodes(); return this.explodeNodes();
}, this)) }.bind(this))
// then fade circles (aka everything) in and back // then fade circles (aka everything) in and back
.then(_.bind(function() { .then(function() {
return this.animateAllAttrKeys( return this.animateAllAttrKeys(
{ exclude: ['arrow', 'rect', 'path', 'text'] }, { exclude: ['arrow', 'rect', 'path', 'text'] },
{}, {},
defaultTime * 1.25 defaultTime * 1.25
); );
}, this)) }.bind(this))
// then fade everything in and remove text // then fade everything in and remove text
.then(_.bind(function() { .then(function() {
text.animate({ opacity: 0 }, defaultTime, undefined, undefined, function() { text.animate({ opacity: 0 }, defaultTime, undefined, undefined, function() {
text.remove(); text.remove();
}); });
@ -291,7 +291,7 @@ GitVisuals.prototype.finishAnimation = function() {
{}, {},
{} {}
); );
}, this)) }.bind(this))
.then(function() { .then(function() {
animationDone.resolve(); animationDone.resolve();
}) })
@ -648,9 +648,9 @@ GitVisuals.prototype.animateNodePositions = function(speed) {
}; };
GitVisuals.prototype.addBranchFromEvent = function(branch, collection, index) { GitVisuals.prototype.addBranchFromEvent = function(branch, collection, index) {
var action = _.bind(function() { var action = function() {
this.addBranch(branch); this.addBranch(branch);
}, this); }.bind(this);
if (!this.gitEngine || !this.gitReady) { if (!this.gitEngine || !this.gitReady) {
this.defer(action); this.defer(action);
@ -670,16 +670,16 @@ GitVisuals.prototype.addBranch = function(branch) {
if (this.gitReady) { if (this.gitReady) {
visBranch.genGraphics(this.paper); visBranch.genGraphics(this.paper);
} else { } else {
this.defer(_.bind(function() { this.defer(function() {
visBranch.genGraphics(this.paper); visBranch.genGraphics(this.paper);
}, this)); }.bind(this));
} }
}; };
GitVisuals.prototype.addTagFromEvent = function(tag, collection, index) { GitVisuals.prototype.addTagFromEvent = function(tag, collection, index) {
var action = _.bind(function() { var action = function() {
this.addTag(tag); this.addTag(tag);
}, this); }.bind(this);
if (!this.gitEngine || !this.gitReady) { if (!this.gitEngine || !this.gitReady) {
this.defer(action); this.defer(action);
@ -699,9 +699,9 @@ GitVisuals.prototype.addTag = function(tag) {
if (this.gitReady) { if (this.gitReady) {
visTag.genGraphics(this.paper); visTag.genGraphics(this.paper);
} else { } else {
this.defer(_.bind(function() { this.defer(function() {
visTag.genGraphics(this.paper); visTag.genGraphics(this.paper);
}, this)); }.bind(this));
} }
}; };
@ -783,9 +783,9 @@ GitVisuals.prototype.canvasResize = function(width, height) {
GitVisuals.prototype.genResizeFunc = function() { GitVisuals.prototype.genResizeFunc = function() {
this.resizeFunc = _.debounce( this.resizeFunc = _.debounce(
_.bind(function(width, height) { function(width, height) {
this.refreshTree(); this.refreshTree();
}, this), }.bind(this),
200, 200,
true true
); );

View file

@ -451,7 +451,7 @@ var VisBranch = VisBase.extend({
]; ];
_.each(objs, function(rObj) { _.each(objs, function(rObj) {
rObj.click(_.bind(this.onClick ,this)); rObj.click(this.onClick.bind(this));
}, this); }, this);
}, },

View file

@ -290,13 +290,13 @@ var VisTag = VisBase.extend({
]; ];
_.each(objs, function(rObj) { _.each(objs, function(rObj) {
rObj.click(_.bind(this.onClick ,this)); rObj.click(this.onClick.bind(this));
}, this); }, this);
}, },
shouldDisableClick: function() { shouldDisableClick: function() {
return this.get('isHead') && !this.gitEngine.getDetachedHead(); return this.get('isHead') && !this.gitEngine.getDetachedHead();
}, }.bind(this),
onClick: function() { onClick: function() {
if (this.shouldDisableClick()) { if (this.shouldDisableClick()) {

View file

@ -69,16 +69,16 @@ var Visualization = Backbone.View.extend({
this.myResize(); this.myResize();
$(window).on('resize', _.bind(function() { $(window).on('resize', function() {
this.myResize(); this.myResize();
}, this)); }.bind(this));
// If the visualization is within a draggable container, we need to update the // If the visualization is within a draggable container, we need to update the
// position whenever the container is moved. // 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.customEvents.trigger('drag', event, ui);
this.myResize(); this.myResize();
}, this)); }.bind(this));
this.gitVisuals.drawTreeFirstTime(); this.gitVisuals.drawTreeFirstTime();
if (this.treeString) { if (this.treeString) {
@ -91,7 +91,7 @@ var Visualization = Backbone.View.extend({
this.shown = false; this.shown = false;
this.setTreeOpacity(0); this.setTreeOpacity(0);
// reflow needed // reflow needed
process.nextTick(_.bind(this.fadeTreeIn, this)); process.nextTick(this.fadeTreeIn, this));
this.customEvents.trigger('gitEngineReady'); this.customEvents.trigger('gitEngineReady');
this.customEvents.trigger('paperReady'); this.customEvents.trigger('paperReady');
@ -99,7 +99,7 @@ var Visualization = Backbone.View.extend({
clearOrigin: function() { clearOrigin: function() {
delete this.originVis; delete this.originVis;
}, }.bind(this)
makeOrigin: function(options) { makeOrigin: function(options) {
// oh god, here we go. We basically do a bizarre form of composition here, // 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 // 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'); var value = $(this.paper.canvas).css('z-index');
this.originVis.setTreeIndex(value); this.originVis.setTreeIndex(value);
}, this)); }.bind(this));
// return the newly created visualization which will soon have a git engine // return the newly created visualization which will soon have a git engine
return this.originVis; return this.originVis;
@ -129,9 +129,9 @@ var Visualization = Backbone.View.extend({
if (!this.originVis) { if (!this.originVis) {
return; return;
} }
var callMethod = _.bind(function() { var callMethod = function() {
this.originVis[methodToCall].apply(this.originVis, args); this.originVis[methodToCall].apply(this.originVis, args);
}, this); }.bind(this);
if (this.originVis.paper) { if (this.originVis.paper) {
callMethod(); callMethod();
@ -178,15 +178,15 @@ var Visualization = Backbone.View.extend({
hide: function() { hide: function() {
this.fadeTreeOut(); this.fadeTreeOut();
// remove click handlers by toggling visibility // remove click handlers by toggling visibility
setTimeout(_.bind(function() { setTimeout(function() {
$(this.paper.canvas).css('visibility', 'hidden'); $(this.paper.canvas).css('visibility', 'hidden');
}, this), this.getAnimationTime()); }.bind(this), this.getAnimationTime());
this.originToo('hide', arguments); 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(this.fadeTreeIn, this), 10);
this.originToo('show', arguments); this.originToo('show', arguments);
this.myResize(); this.myResize();
}, },
@ -196,7 +196,7 @@ var Visualization = Backbone.View.extend({
this.setTreeOpacity(1); this.setTreeOpacity(1);
this.originToo('showHarsh', arguments); this.originToo('showHarsh', arguments);
this.myResize(); this.myResize();
}, }.bind(this)
resetFromThisTreeNow: function(treeString) { resetFromThisTreeNow: function(treeString) {
this.treeString = treeString; this.treeString = treeString;
@ -245,11 +245,11 @@ var Visualization = Backbone.View.extend({
die: function() { die: function() {
this.fadeTreeOut(); this.fadeTreeOut();
setTimeout(_.bind(function() { setTimeout(function() {
if (!this.shown) { if (!this.shown) {
this.tearDown({fromDie: true}); this.tearDown({fromDie: true});
} }
}, this), this.getAnimationTime()); }.bind(this), this.getAnimationTime());
this.originToo('die', arguments); this.originToo('die', arguments);
}, },