Skip to content

Commit

Permalink
Replacing _.defer with RAF where appropriate and removing addt window…
Browse files Browse the repository at this point in the history
…. references
  • Loading branch information
MeoMix committed May 6, 2015
1 parent 08b1e3e commit c291c9f
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/js/background/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
},

_setInstanceId: function() {
var instanceId = window.localStorage.getItem('instanceId');
var instanceId = localStorage.getItem('instanceId');

if (instanceId === null) {
instanceId = 'instance_' + _.now();
window.localStorage.setItem('instanceId', instanceId);
localStorage.setItem('instanceId', instanceId);
}

this.instanceId = instanceId;
Expand Down
6 changes: 3 additions & 3 deletions src/js/background/collection/playlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
_onReset: function() {
// Ensure there is an always active playlist by trying to load from localstorage
if (this.length > 0 && _.isUndefined(this.getActivePlaylist())) {
var activePlaylistId = window.localStorage.getItem('activePlaylistId');
var activePlaylistId = localStorage.getItem('activePlaylistId');

// Be sure to always have an active playlist if there is one available.
var playlistToSetActive = this.get(activePlaylistId) || this.at(0);
Expand Down Expand Up @@ -186,7 +186,7 @@
// Ensure only one playlist is active at a time by de-activating all other active playlists.
if (active) {
this._deactivateAllExcept(changedPlaylist);
window.localStorage.setItem('activePlaylistId', changedPlaylist.get('id'));
localStorage.setItem('activePlaylistId', changedPlaylist.get('id'));
}
},

Expand Down Expand Up @@ -232,7 +232,7 @@
_onRemove: function(removedPlaylist, collection, options) {
if (removedPlaylist.get('active')) {
// Clear local storage of the active playlist if it gets removed.
window.localStorage.setItem('activePlaylistId', null);
localStorage.setItem('activePlaylistId', null);
// If the index of the item removed was the last one in the list, activate previous.
var index = options.index === this.length ? options.index - 1 : options.index;
this._activateByIndex(index);
Expand Down
4 changes: 2 additions & 2 deletions src/js/background/model/clientError.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
_getBrowserVersion: function() {
var browserVersion = '';

var chromeMatch = window.navigator.appVersion.match(/Chrome\/(.*?) /);
var chromeMatch = navigator.appVersion.match(/Chrome\/(.*?) /);
browserVersion += chromeMatch ? chromeMatch[0] : '';

var operaMatch = window.navigator.appVersion.match(/OPR\/.*/);
var operaMatch = navigator.appVersion.match(/OPR\/.*/);
browserVersion += operaMatch ? operaMatch[0] : '';

return browserVersion;
Expand Down
2 changes: 1 addition & 1 deletion src/js/background/model/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// The foreground has to be able to call this whenever a view opens.
stopClearQueryTimer: function() {
window.clearTimeout(this.get('clearQueryTimeout'));
clearTimeout(this.get('clearQueryTimeout'));
this.set('clearQueryTimeout', null);
},

Expand Down
2 changes: 1 addition & 1 deletion src/js/background/model/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ define(function(require) {
},

tryloadByUserId: function() {
var userId = window.localStorage.getItem('userId');
var userId = localStorage.getItem('userId');

if (userId === null) {
this._create();
Expand Down
2 changes: 1 addition & 1 deletion src/js/contentScript/beatport.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
// So, watch for a loading class being added and then removed. The new page is loaded once the class has been removed.
this.toggleObservePageLoad = function(enable) {
if (enable) {
this.pageLoadObserver = new window.MutationObserver(function(mutations) {
this.pageLoadObserver = new MutationObserver(function(mutations) {
var isPageLoading = mutations[0].target.classList.contains('loading');

if (!isPageLoading) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/contentScript/youTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
// the page does not reload because they use AJAX to load the video page.
var isPageLoaded = false;

var observer = new window.MutationObserver(function(mutations) {
var observer = new MutationObserver(function(mutations) {
var hasPageLoadedClass = mutations[0].target.classList.contains('page-loaded');

if (hasPageLoadedClass && !isPageLoaded) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/foreground/view/dialog/dialogView.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},

onAttach: function() {
_.defer(this._transitionIn.bind(this));
requestAnimationFrame(this._transitionIn.bind(this));
},

// Unless a dialog specifically implements reminderProperty it is assumed that reminder is enabled and the dialog will be shown when asked.
Expand Down
2 changes: 1 addition & 1 deletion src/js/foreground/view/element/simpleMenuView.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
this._centerActive();
}

_.defer(function() {
requestAnimationFrame(function() {
this.$el.addClass('is-visible');
}.bind(this));
},
Expand Down
2 changes: 1 addition & 1 deletion src/js/foreground/view/stream/activeStreamItemView.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
this.$el.addClass('is-visible');
Streamus.channels.activeStreamItemArea.vent.trigger('visible');
} else {
_.defer(function() {
requestAnimationFrame(function() {
this.$el.addClass('is-visible');
}.bind(this));

Expand Down

0 comments on commit c291c9f

Please sign in to comment.