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

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