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
var newDeferred = Q.defer();
newDeferred.promise
.then(_.bind(function() {
.then(function() {
// give this method the original defer so it can resolve it
this.afterGitCommandProcessed(command, deferred);
}, this))
}.bind(this))
.done();
// 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
// of the event baton backwards, and either resolve that promise immediately or
// give it to our shim owner.
var passBaton = _.bind(function() {
var passBaton = function() {
// punt to the previous listener
this.eventBaton.passBatonBack('processGitCommand', this.processGitCommand, this, [command, newDeferred]);
}, this);
}.bind(this);
var beforeDefer = Q.defer();
beforeDefer.promise

View file

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

View file

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

View file

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

View file

@ -272,9 +272,9 @@ var LevelBuilder = Level.extend({
deferred: whenDoneEditing
});
whenDoneEditing.promise
.then(_.bind(function(levelObj) {
.then(function(levelObj) {
this.startDialogObj = levelObj;
}, this))
}.bind(this))
.fail(function() {
// nothing to do, they dont want to edit it apparently
})
@ -316,10 +316,10 @@ var LevelBuilder = Level.extend({
]
});
askForHintView.getPromise()
.then(_.bind(this.defineHint, this))
.fail(_.bind(function() {
.then(this.defineHint, this))
.fail(function() {
this.level.hint = {'en_US': ''};
}, this))
}.bind(this))
.done(function() {
askForHintDeferred.resolve();
});
@ -337,13 +337,13 @@ var LevelBuilder = Level.extend({
]
});
askForStartView.getPromise()
.then(_.bind(function() {
.then(function() {
// oh boy this is complex
var whenEditedDialog = Q.defer();
// the undefined here is the command that doesnt need resolving just yet...
this.editDialog(undefined, whenEditedDialog);
return whenEditedDialog.promise;
}, this))
}.bind(this))
.fail(function() {
// 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
new MarkdownPresenter({
fillerText: JSON.stringify(this.getExportObj(), null, 2),
previewText: intl.str('share-json')
});
command.finishWith(deferred);
}, this));
}.bind(this));
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
// 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.
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 (!$('#goalPlaceholder').is(':visible')) {
$('#goalPlaceholder').show();
@ -216,7 +216,7 @@ var Level = Sandbox.extend({
this.mainVis.myResize();
}
}
}, this));
}.bind(this));
return this.goalCanvasHolder;
},
@ -242,14 +242,14 @@ var Level = Sandbox.extend({
showSolution: function(command, deferred) {
var toIssue = this.level.solutionCommand;
var issueFunc = _.bind(function() {
var issueFunc = function() {
this.isShowingSolution = true;
Main.getEventBaton().trigger(
'commandSubmitted',
toIssue
);
log.showLevelSolution(this.getEnglishName());
}, this);
}.bind(this);
var commandStr = command.get('rawStr');
if (!this.testOptionOnString(commandStr, 'noReset')) {
@ -368,16 +368,16 @@ var Level = Sandbox.extend({
initGitShim: function(options) {
// ok we definitely want a shim here
this.gitShim = new GitShim({
beforeCB: _.bind(this.beforeCommandCB, this),
afterCB: _.bind(this.afterCommandCB, this),
afterDeferHandler: _.bind(this.afterCommandDefer, this)
beforeCB: this.beforeCommandCB, this),
afterCB: this.afterCommandCB, this),
afterDeferHandler: this.afterCommandDefer, this)
});
},
undo: function() {
this.gitCommandsIssued.pop();
Level.__super__.undo.apply(this, arguments);
},
}.bind(this)
afterCommandCB: function(command) {
if (command.get('error')) {
@ -516,13 +516,13 @@ var Level = Sandbox.extend({
},
getInstantCommands: function() {
var getHint = _.bind(function() {
var getHint = function() {
var hint = intl.getHint(this.level);
if (!hint || !hint.length) {
return intl.str('no-hint');
}
return hint;
}, this);
}.bind(this);
return [
[/^help$|^\?$/, function() {

View file

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

View file

@ -68,7 +68,7 @@ var Sandbox = Backbone.View.extend({
initGitShim: function(options) {
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);
this.insertGitShim();
},
}.bind(this)
releaseControl: function() {
// we will be handling commands that are submitted, mainly to add the sanadbox
@ -331,7 +331,7 @@ var Sandbox = Backbone.View.extend({
fillerText: ' '
});
jsonGrabber.deferred.promise
.then(_.bind(function(treeJSON) {
.then(function(treeJSON) {
try {
this.mainVis.gitEngine.loadTree(JSON.parse(treeJSON));
} catch(e) {
@ -351,7 +351,7 @@ var Sandbox = Backbone.View.extend({
}]
});
}
}, this))
}.bind(this))
.fail(function() { })
.done(function() {
command.finishWith(deferred);
@ -365,7 +365,7 @@ var Sandbox = Backbone.View.extend({
});
jsonGrabber.deferred.promise
.then(_.bind(function(inputText) {
.then(function(inputText) {
var Level = require('../level').Level;
try {
var levelJSON = JSON.parse(inputText);
@ -397,7 +397,7 @@ var Sandbox = Backbone.View.extend({
});
command.finishWith(deferred);
}
}, this))
}.bind(this))
.fail(function() {
command.finishWith(deferred);
})
@ -456,10 +456,10 @@ var Sandbox = Backbone.View.extend({
var helpDialog = new MultiView({
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
command.finishWith(deferred);
}, this))
}.bind(this))
.done();
}
});

View file

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

View file

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

View file

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

View file

@ -70,9 +70,9 @@ var ContainedBase = BaseView.extend({
die: function() {
this.hide();
setTimeout(_.bind(function() {
setTimeout(function() {
this.tearDown();
}, this), this.getAnimationTime() * 1.1);
}.bind(this), this.getAnimationTime() * 1.1);
}
});
@ -107,7 +107,7 @@ var GeneralButton = ContainedBase.extend({
click: function() {
if (!this.clickFunc) {
this.clickFunc = _.throttle(
_.bind(this.sendClick, this),
this.sendClick, this),
500
);
}
@ -116,7 +116,7 @@ var GeneralButton = ContainedBase.extend({
sendClick: function() {
this.navEvents.trigger('click');
}
}.bind(this)
});
var ConfirmCancelView = ResolveRejectBase.extend({
@ -252,19 +252,19 @@ var ModalView = Backbone.View.extend({
// on reflow, change our class to animate. for whatever
// reason if this is done immediately, chrome might combine
// the two changes and lose the ability to animate and it looks bad.
process.nextTick(_.bind(function() {
process.nextTick(function() {
this.toggleShow(true);
}, this));
}.bind(this));
},
hide: function() {
this.toggleShow(false);
setTimeout(_.bind(function() {
setTimeout(function() {
// if we are still hidden...
if (!this.shown) {
this.toggleZ(false);
}
}, this), this.getAnimationTime());
}.bind(this), this.getAnimationTime());
},
getInsideElement: function() {
@ -388,9 +388,9 @@ var ConfirmCancelTerminal = Backbone.View.extend({
buttonDefer.promise
.then(this.deferred.resolve)
.fail(this.deferred.reject)
.done(_.bind(function() {
.done(function() {
this.close();
}, this));
}.bind(this));
// also setup keyboard
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
// 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) {
this.$el.addClass(options.additionalClass);
}
}.bind(this)
},
getAnimationTime: function() { return 700; },
@ -595,9 +595,9 @@ var CanvasTerminalHolder = BaseView.extend({
this.minimize();
this.inDom = false;
setTimeout(_.bind(function() {
setTimeout(function() {
this.tearDown();
}, this), this.getAnimationTime());
}.bind(this), this.getAnimationTime());
},
minimize: function() {

View file

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

View file

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

View file

@ -118,12 +118,12 @@ var InteractiveRebaseView = ContainedBase.extend({
// control for button
var deferred = Q.defer();
deferred.promise
.then(_.bind(function() {
.then(function() {
this.confirm();
}, this))
.fail(_.bind(function() {
}.bind(this))
.fail(function() {
this.cancel();
}, this))
}.bind(this))
.done();
// 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
this.listEntry = this.$el.children(':last');
this.listEntry.delegate('#toggleButton', 'click', _.bind(function() {
this.listEntry.delegate('#toggleButton', 'click', function() {
this.toggle();
}, this));
}.bind(this));
}
});

View file

@ -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;
};

View file

@ -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) {

View file

@ -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
);

View file

@ -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);
},

View file

@ -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()) {

View file

@ -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);
},