Skip to content

Commit

Permalink
switch to native Function.bind
Browse files Browse the repository at this point in the history
  • Loading branch information
moloko authored and tomgreenfield committed Aug 30, 2018
1 parent 83f2ada commit fd5f531
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion js/adapt-contrib-spoor.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ define([
advancedSettings._commitOnVisibilityChangeHidden !== false) &&
document.addEventListener;

this._onWindowUnload = _.bind(this.onWindowUnload, this);
this._onWindowUnload = this.onWindowUnload.bind(this);
$(window).on('beforeunload unload', this._onWindowUnload);

if (shouldCommitOnVisibilityChange) {
Expand Down
12 changes: 6 additions & 6 deletions js/adapt-stateful-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ define([

// Session Begin
initialize: function(callback) {
this._onWindowUnload = _.bind(this.onWindowUnload, this);
this._onWindowUnload = this.onWindowUnload.bind(this);

this.getConfig();

this.getLearnerInfo();

// Restore state asynchronously to prevent IE8 freezes
this.restoreSessionState(_.bind(function() {
this.restoreSessionState(function() {
// still need to defer call because AdaptModel.check*Status functions are asynchronous
_.defer(_.bind(this.setupEventListeners, this));
_.defer(this.setupEventListeners.bind(this));
callback();
}, this));
}.bind(this));
},

getConfig: function() {
Expand Down Expand Up @@ -61,12 +61,12 @@ define([
var sessionPairs = Adapt.offlineStorage.get();
var hasNoPairs = _.keys(sessionPairs).length === 0;

var doSynchronousPart = _.bind(function() {
var doSynchronousPart = function() {
if (sessionPairs.questions && this._shouldStoreResponses) questions.deserialize(sessionPairs.questions);
if (sessionPairs._isCourseComplete) Adapt.course.set('_isComplete', sessionPairs._isCourseComplete);
if (sessionPairs._isAssessmentPassed) Adapt.course.set('_isAssessmentPassed', sessionPairs._isAssessmentPassed);
callback();
}, this);
}.bind(this);

if (hasNoPairs) return callback();

Expand Down
4 changes: 2 additions & 2 deletions js/scorm/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ define (function(require) {

if(this.timedCommitFrequency > 0) {
var delay = this.timedCommitFrequency * (60 * 1000);
this.timedCommitIntervalID = window.setInterval(_.bind(this.commit, this), delay);
this.timedCommitIntervalID = window.setInterval(this.commit.bind(this), delay);
}
};

Expand All @@ -457,7 +457,7 @@ define (function(require) {

this.commitRetryPending = true;// stop anything else from calling commit until this is done

this.retryCommitTimeoutID = window.setTimeout(_.bind(this.doRetryCommit, this), this.commitRetryDelay);
this.retryCommitTimeoutID = window.setTimeout(this.doRetryCommit.bind(this), this.commitRetryDelay);
};

ScormWrapper.prototype.doRetryCommit = function() {
Expand Down

0 comments on commit fd5f531

Please sign in to comment.