diff --git a/Gruntfile.js b/Gruntfile.js
index 25ea797..a571c1d 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -23,7 +23,8 @@ module.exports = function(grunt){
'couchpotato/static/scripts/vendor/Array.stableSort.js',
'couchpotato/static/scripts/vendor/history.js',
'couchpotato/static/scripts/vendor/dynamics.js',
- 'couchpotato/static/scripts/vendor/fastclick.js'
+ 'couchpotato/static/scripts/vendor/fastclick.js',
+ 'couchpotato/static/scripts/vendor/requestAnimationFrame.js'
];
var scripts_files = [
diff --git a/couchpotato/core/_base/downloader/static/downloaders.js b/couchpotato/core/_base/downloader/static/downloaders.js
index f963ca8..fd6185d 100644
--- a/couchpotato/core/_base/downloader/static/downloaders.js
+++ b/couchpotato/core/_base/downloader/static/downloaders.js
@@ -54,9 +54,9 @@ var DownloadersBase = new Class({
}).inject(button, 'after');
}
- (function(){
+ requestTimeout(function(){
message.destroy();
- }).delay(3000);
+ }, 3000);
}
});
}
diff --git a/couchpotato/core/_base/updater/static/updater.js b/couchpotato/core/_base/updater/static/updater.js
index 932c3b6..158c8d9 100644
--- a/couchpotato/core/_base/updater/static/updater.js
+++ b/couchpotato/core/_base/updater/static/updater.js
@@ -8,7 +8,7 @@ var UpdaterBase = new Class({
App.addEvent('load', self.info.bind(self, 2000));
App.addEvent('unload', function(){
if(self.timer)
- clearTimeout(self.timer);
+ clearRequestTimeout(self.timer);
});
},
@@ -34,9 +34,9 @@ var UpdaterBase = new Class({
info: function(timeout){
var self = this;
- if(self.timer) clearTimeout(self.timer);
+ if(self.timer) clearRequestTimeout(self.timer);
- self.timer = setTimeout(function(){
+ self.timer = requestTimeout(function(){
Api.request('updater.info', {
'onComplete': function(json){
self.json = json;
@@ -102,9 +102,11 @@ var UpdaterBase = new Class({
},
updating: function(){
- App.checkAvailable.delay(500, App, [1000, function(){
- window.location.reload();
- }]);
+ requestTimeout(function(){
+ App.checkAvailable(1000, function(){
+ window.location.reload();
+ });
+ }, 500);
if(self.message)
self.message.destroy();
}
diff --git a/couchpotato/core/media/_base/search/static/search.js b/couchpotato/core/media/_base/search/static/search.js
index 7b9a536..e0aa23d 100644
--- a/couchpotato/core/media/_base/search/static/search.js
+++ b/couchpotato/core/media/_base/search/static/search.js
@@ -37,15 +37,15 @@ var BlockSearch = new Class({
'change': self.keyup.bind(self),
'keyup': self.keyup.bind(self),
'focus': function(){
- if(focus_timer) clearTimeout(focus_timer);
+ if(focus_timer) clearRequestTimeout(focus_timer);
if(this.get('value'))
self.hideResults(false);
},
'blur': function(){
- focus_timer = (function(){
+ focus_timer = requestTimeout(function(){
self.el.removeClass('focused');
self.last_q = null;
- }).delay(100);
+ }, 100);
}
}
})
@@ -127,8 +127,8 @@ var BlockSearch = new Class({
if(self.api_request && self.api_request.isRunning())
self.api_request.cancel();
- if(self.autocomplete_timer) clearTimeout(self.autocomplete_timer);
- self.autocomplete_timer = self.autocomplete.delay(300, self);
+ if(self.autocomplete_timer) clearRequestTimeout(self.autocomplete_timer);
+ self.autocomplete_timer = requestTimeout(self.autocomplete.bind(self), 300);
}
},
@@ -152,7 +152,7 @@ var BlockSearch = new Class({
self.hideResults(false);
if(!cache){
- setTimeout(function(){
+ requestTimeout(function(){
self.mask.addClass('show');
}, 10);
diff --git a/couchpotato/core/media/movie/_base/static/list.js b/couchpotato/core/media/movie/_base/static/list.js
index 3eb18d7..d715502 100644
--- a/couchpotato/core/media/movie/_base/static/list.js
+++ b/couchpotato/core/media/movie/_base/static/list.js
@@ -546,8 +546,8 @@ var MovieList = new Class({
search: function(){
var self = this;
- if(self.search_timer) clearTimeout(self.search_timer);
- self.search_timer = (function(){
+ if(self.search_timer) clearRequestTimeout(self.search_timer);
+ self.search_timer = requestTimeout(function(){
var search_value = self.navigation_search_input.get('value');
if (search_value == self.last_search_value) return;
@@ -560,7 +560,7 @@ var MovieList = new Class({
self.last_search_value = search_value;
- }).delay(250);
+ }, 250);
},
@@ -588,7 +588,7 @@ var MovieList = new Class({
createSpinner(self.loader_first);
var lfc = self.loader_first;
- loader_timeout = setTimeout(function(){
+ loader_timeout = requestTimeout(function(){
lfc.addClass('show');
}, 10);
@@ -607,13 +607,13 @@ var MovieList = new Class({
if(reset)
self.movie_list.empty();
- if(loader_timeout) clearTimeout(loader_timeout);
+ if(loader_timeout) clearRequestTimeout(loader_timeout);
if(self.loader_first){
var lf = self.loader_first;
self.loader_first = null;
lf.removeClass('show');
- setTimeout(function(){
+ requestTimeout(function(){
lf.destroy();
}, 1000);
self.el.setStyle('min-height', null);
diff --git a/couchpotato/core/media/movie/_base/static/manage.js b/couchpotato/core/media/movie/_base/static/manage.js
index 16d0a54..9d379ad 100644
--- a/couchpotato/core/media/movie/_base/static/manage.js
+++ b/couchpotato/core/media/movie/_base/static/manage.js
@@ -84,7 +84,7 @@ var MoviesManage = new Class({
startProgressInterval: function(){
var self = this;
- self.progress_interval = setInterval(function(){
+ self.progress_interval = requestInterval(function(){
if(self.progress_request && self.progress_request.running)
return;
@@ -94,7 +94,7 @@ var MoviesManage = new Class({
'onComplete': function(json){
if(!json || !json.progress){
- clearInterval(self.progress_interval);
+ clearRequestInterval(self.progress_interval);
self.update_in_progress = false;
if(self.progress_container){
self.progress_container.destroy();
diff --git a/couchpotato/core/media/movie/_base/static/movie.actions.js b/couchpotato/core/media/movie/_base/static/movie.actions.js
index d963a9e..96db48f 100644
--- a/couchpotato/core/media/movie/_base/static/movie.actions.js
+++ b/couchpotato/core/media/movie/_base/static/movie.actions.js
@@ -392,7 +392,7 @@ MA.Trailer = new Class({
self.background = new Element('div.background')
);
- setTimeout(function(){
+ requestTimeout(function(){
var url = data_url.substitute({
'title': encodeURI(self.getTitle()),
diff --git a/couchpotato/core/media/movie/_base/static/movie.js b/couchpotato/core/media/movie/_base/static/movie.js
index f72fff8..f546496 100644
--- a/couchpotato/core/media/movie/_base/static/movie.js
+++ b/couchpotato/core/media/movie/_base/static/movie.js
@@ -57,7 +57,7 @@ var Movie = new Class({
App.getPageContainer().grab(self.details);
- self.details.open.delay(10, self.details);
+ requestTimeout(self.details.open.bind(self.details), 10);
},
addEvents: function(){
@@ -70,7 +70,9 @@ var Movie = new Class({
if(self.data._id != notification.data._id) return;
self.busy(false);
- self.update.delay(2000, self, notification);
+ requestTimeout(function(){
+ self.update(notification);
+ }, 2000);
};
App.on('movie.update', self.global_events['movie.update']);
@@ -137,10 +139,10 @@ var Movie = new Class({
var self = this;
if(!set_busy){
- setTimeout(function(){
+ requestTimeout(function(){
if(self.spinner){
self.mask.fade('out');
- setTimeout(function(){
+ requestTimeout(function(){
if(self.mask)
self.mask.destroy();
if(self.spinner)
@@ -311,7 +313,7 @@ var Movie = new Class({
if(self.list.current_view == 'thumb'){
self.el.addClass('hover_start');
- setTimeout(function(){
+ requestTimeout(function(){
self.el.removeClass('hover_start');
}, 300);
diff --git a/couchpotato/core/media/movie/_base/static/wanted.js b/couchpotato/core/media/movie/_base/static/wanted.js
index f5c72d1..718f8bc 100644
--- a/couchpotato/core/media/movie/_base/static/wanted.js
+++ b/couchpotato/core/media/movie/_base/static/wanted.js
@@ -45,7 +45,7 @@ var MoviesWanted = new Class({
$(self.list).inject(self.content);
// Check if search is in progress
- self.startProgressInterval.delay(4000, self);
+ requestTimeout(self.startProgressInterval.bind(self), 4000);
}
},
@@ -66,13 +66,13 @@ var MoviesWanted = new Class({
var self = this;
var start_text = self.manual_search.get('text');
- self.progress_interval = setInterval(function(){
+ self.progress_interval = requestInterval(function(){
if(self.search_progress && self.search_progress.running) return;
self.search_progress = Api.request('movie.searcher.progress', {
'onComplete': function(json){
self.search_in_progress = true;
if(!json.movie){
- clearInterval(self.progress_interval);
+ clearRequestInterval(self.progress_interval);
self.search_in_progress = false;
self.manual_search.set('text', start_text);
}
diff --git a/couchpotato/core/media/movie/charts/static/charts.js b/couchpotato/core/media/movie/charts/static/charts.js
index 5c956d9..51c4f55 100644
--- a/couchpotato/core/media/movie/charts/static/charts.js
+++ b/couchpotato/core/media/movie/charts/static/charts.js
@@ -23,8 +23,10 @@ var Charts = new Class({
);
self.show();
- self.fireEvent.delay(0, self, 'created');
+ requestTimeout(function(){
+ self.fireEvent('created');
+ }, 0);
},
fill: function(json){
@@ -74,7 +76,7 @@ var Charts = new Class({
self.el.show();
if(!self.shown_once){
- setTimeout(function(){
+ requestTimeout(function(){
self.api_request = Api.request('charts.view', {
'onComplete': self.fill.bind(self)
});
diff --git a/couchpotato/core/notifications/core/static/notification.js b/couchpotato/core/notifications/core/static/notification.js
index c9ac01b..718f2f3 100644
--- a/couchpotato/core/notifications/core/static/notification.js
+++ b/couchpotato/core/notifications/core/static/notification.js
@@ -31,7 +31,9 @@ var NotificationBase = new Class({
});
window.addEvent('load', function(){
- self.startInterval.delay($(window).getSize().x <= 480 ? 2000 : 100, self);
+ requestTimeout(function(){
+ self.startInterval($(window).getSize().x <= 480 ? 2000 : 100);
+ }, 0);
});
},
@@ -107,7 +109,7 @@ var NotificationBase = new Class({
}
}).send();
- setInterval(function(){
+ requestInterval(function(){
if(self.request && self.request.isRunning()){
self.request.cancel();
@@ -135,7 +137,7 @@ var NotificationBase = new Class({
'last_id': self.last_id
},
'onFailure': function(){
- self.startPoll.delay(2000, self);
+ requestTimeout(self.startPoll.bind(self), 2000);
}
}).send();
@@ -163,7 +165,7 @@ var NotificationBase = new Class({
}
// Restart poll
- self.startPoll.delay(1500, self);
+ requestTimeout(self.startPoll.bind(self), 1500);
},
showMessage: function(message, sticky, data){
@@ -177,13 +179,13 @@ var NotificationBase = new Class({
'html': '
' + message + '
'
}).inject(self.message_container, 'top');
- setTimeout(function(){
+ requestTimeout(function(){
new_message.addClass('show');
}, 10);
var hide_message = function(){
new_message.addClass('hide');
- setTimeout(function(){
+ requestTimeout(function(){
new_message.destroy();
}, 1000);
};
@@ -200,7 +202,7 @@ var NotificationBase = new Class({
})
);
else
- setTimeout(hide_message, 4000);
+ requestTimeout(hide_message, 4000);
},
@@ -246,9 +248,9 @@ var NotificationBase = new Class({
}).inject(button, 'after');
}
- (function(){
+ requestTimeout(function(){
message.destroy();
- }).delay(3000);
+ }, 3000);
}
});
}
diff --git a/couchpotato/core/plugins/category/static/category.js b/couchpotato/core/plugins/category/static/category.js
index 3a270c0..9161102 100644
--- a/couchpotato/core/plugins/category/static/category.js
+++ b/couchpotato/core/plugins/category/static/category.js
@@ -232,8 +232,8 @@ var Category = new Class({
save: function(delay){
var self = this;
- if(self.save_timer) clearTimeout(self.save_timer);
- self.save_timer = (function(){
+ if(self.save_timer) clearRequestTimeout(self.save_timer);
+ self.save_timer = requestTimeout(function(){
Api.request('category.save', {
'data': self.getData(),
@@ -248,7 +248,7 @@ var Category = new Class({
}
});
- }).delay(delay || 0, self);
+ }, delay || 0);
},
diff --git a/couchpotato/core/plugins/log/static/log.js b/couchpotato/core/plugins/log/static/log.js
index 0d47914..e52bc56 100644
--- a/couchpotato/core/plugins/log/static/log.js
+++ b/couchpotato/core/plugins/log/static/log.js
@@ -39,7 +39,9 @@ Page.Log = new Class({
'text': 'loading...',
'events': {
'mouseup:relay(.time)': function(e){
- self.showSelectionButton.delay(100, self, e);
+ requestTimeout(function(){
+ self.showSelectionButton(2);
+ }, 100);
}
}
}).inject(self.content);
@@ -211,7 +213,7 @@ Page.Log = new Class({
}
}).inject(document.body);
- setTimeout(function(){
+ requestTimeout(function(){
document.body.addEvent('click', remove_button);
}, 0);
diff --git a/couchpotato/core/plugins/profile/static/profile.js b/couchpotato/core/plugins/profile/static/profile.js
index a502729..01fad1e 100644
--- a/couchpotato/core/plugins/profile/static/profile.js
+++ b/couchpotato/core/plugins/profile/static/profile.js
@@ -96,8 +96,8 @@ var Profile = new Class({
save: function(delay){
var self = this;
- if(self.save_timer) clearTimeout(self.save_timer);
- self.save_timer = (function(){
+ if(self.save_timer) clearRequestTimeout(self.save_timer);
+ self.save_timer = requestTimeout(function(){
self.addType();
@@ -123,7 +123,7 @@ var Profile = new Class({
}
});
- }).delay(delay, self);
+ }, delay);
},
diff --git a/couchpotato/core/plugins/quality/static/quality.js b/couchpotato/core/plugins/quality/static/quality.js
index 67924b0..60a2449 100644
--- a/couchpotato/core/plugins/quality/static/quality.js
+++ b/couchpotato/core/plugins/quality/static/quality.js
@@ -221,9 +221,9 @@ var QualityBase = new Class({
changeSize: function(identifier, type, value){
var self = this;
- if(self.size_timer[identifier + type]) clearTimeout(self.size_timer[identifier + type]);
+ if(self.size_timer[identifier + type]) clearRequestTimeout(self.size_timer[identifier + type]);
- self.size_timer[identifier + type] = (function(){
+ self.size_timer[identifier + type] = requestTimeout(function(){
Api.request('quality.size.save', {
'data': {
'identifier': identifier,
@@ -231,7 +231,7 @@ var QualityBase = new Class({
'value': value
}
});
- }).delay(300);
+ }, 300);
}
diff --git a/couchpotato/core/plugins/wizard/static/wizard.js b/couchpotato/core/plugins/wizard/static/wizard.js
index d7a0102..49080c7 100644
--- a/couchpotato/core/plugins/wizard/static/wizard.js
+++ b/couchpotato/core/plugins/wizard/static/wizard.js
@@ -102,10 +102,10 @@ Page.Wizard = new Class({
});
}
else
- (function(){
+ requestTimeout(function(){
var sc = self.el.getElement('.wgroup_'+action);
self.scroll.start(0, sc.getCoordinates().top-80);
- }).delay(1);
+ }, 1);
},
orderGroups: function(){
diff --git a/couchpotato/static/scripts/combined.base.min.js b/couchpotato/static/scripts/combined.base.min.js
index 8166ec3..53cd100 100644
--- a/couchpotato/static/scripts/combined.base.min.js
+++ b/couchpotato/static/scripts/combined.base.min.js
@@ -39,7 +39,7 @@ var Question = new Class({
}), hint = this.hint ? new Element("div.hint", {
html: this.hint
}) : null)).inject(document.body);
- setTimeout(function() {
+ requestTimeout(function() {
self.container.addClass("show");
self.inner.getElements("> *").each(function(el, nr) {
dynamics.css(el, {
@@ -201,10 +201,10 @@ var CouchPotato = new Class({
}
});
ripple.inject(el);
- setTimeout(function() {
+ requestTimeout(function() {
ripple.addClass("animate");
}, 0);
- setTimeout(function() {
+ requestTimeout(function() {
ripple.dispose();
}, 2100);
},
@@ -333,7 +333,7 @@ var CouchPotato = new Class({
click: function(e) {
e.preventDefault();
self.shutdown();
- q.close.delay(100, q);
+ requestTimeout(q.close.bind(q), 100);
}
}
}, {
@@ -356,7 +356,7 @@ var CouchPotato = new Class({
click: function(e) {
e.preventDefault();
self.restart(message, title);
- q.close.delay(100, q);
+ requestTimeout(q.close.bind(q), 100);
}
}
}, {
@@ -372,9 +372,11 @@ var CouchPotato = new Class({
},
checkAvailable: function(delay, onAvailable) {
var self = this;
- (function() {
+ requestTimeout(function() {
var onFailure = function() {
- self.checkAvailable.delay(1e3, self, [ delay, onAvailable ]);
+ requestTimeout(function() {
+ self.checkAvailable(delay, onAvailable);
+ }, 1e3);
self.fireEvent("unload");
};
var request = Api.request("app.available", {
@@ -390,7 +392,7 @@ var CouchPotato = new Class({
self.fireEvent("reload");
}
});
- }).delay(delay || 0);
+ }, delay || 0);
},
blockPage: function(message, title) {
var self = this;
@@ -401,7 +403,7 @@ var CouchPotato = new Class({
text: message || "Something must have crashed.. check the logs ;)"
}))).inject(document.body);
createSpinner(self.mask);
- setTimeout(function() {
+ requestTimeout(function() {
self.mask.addClass("show");
}, 10);
},
@@ -460,7 +462,7 @@ var CouchPotato = new Class({
args = [];
}
self.global_events[name].each(function(handle) {
- setTimeout(function() {
+ requestTimeout(function() {
var results = handle.apply(handle, args || []);
if (on_complete) on_complete(results);
}, 0);
@@ -668,7 +670,7 @@ var PageBase = new Class({
class: "page " + self.getPageClass() + (" level_" + (options.level || 0))
}).grab(self.content = new Element("div.scroll_content"));
App.addEvent("load", function() {
- setTimeout(function() {
+ requestTimeout(function() {
if (!App.mobile_screen && !App.getOption("dev")) {
self.content.addEvent("scroll", self.preventHover.bind(self));
}
@@ -770,9 +772,9 @@ var PageBase = new Class({
},
preventHover: function() {
var self = this;
- if (self.hover_timer) clearTimeout(self.hover_timer);
+ if (self.hover_timer) clearRequestTimeout(self.hover_timer);
self.el.addClass("disable_hover");
- self.hover_timer = setTimeout(function() {
+ self.hover_timer = requestTimeout(function() {
self.el.removeClass("disable_hover");
}, 200);
},
@@ -1238,7 +1240,7 @@ Page.Settings = new Class({
});
});
});
- setTimeout(function() {
+ requestTimeout(function() {
self.el.grab(self.navigation);
self.content.adopt(self.tabs_container, self.containers);
self.fireEvent("create");
@@ -1368,8 +1370,8 @@ var OptionBase = new Class({
var self = this;
if (self.getValue() != self.previous_value) {
if (self.save_on_change) {
- if (self.changed_timer) clearTimeout(self.changed_timer);
- self.changed_timer = self.save.delay(300, self);
+ if (self.changed_timer) clearRequestTimeout(self.changed_timer);
+ self.changed_timer = requestTimeout(self.save.bind(self), 300);
}
self.fireEvent("change");
}
@@ -1394,9 +1396,9 @@ var OptionBase = new Class({
var sc = json.success ? "save_success" : "save_failed";
self.previous_value = self.getValue();
self.el.addClass(sc);
- (function() {
+ requestTimeout(function() {
self.el.removeClass(sc);
- }).delay(3e3, self);
+ }, 3e3);
},
setName: function(name) {
this.name = name;
@@ -1859,7 +1861,7 @@ Option.Combined = new Class({
add_empty_timeout: 0,
addEmpty: function() {
var self = this;
- if (self.add_empty_timeout) clearTimeout(self.add_empty_timeout);
+ if (self.add_empty_timeout) clearRequestTimeout(self.add_empty_timeout);
var has_empty = 0;
self.items.each(function(ctrl_holder) {
var empty_count = 0;
@@ -1871,7 +1873,7 @@ Option.Combined = new Class({
ctrl_holder[empty_count == self.options.combine.length ? "addClass" : "removeClass"]("is_empty");
});
if (has_empty > 0) return;
- self.add_empty_timeout = setTimeout(function() {
+ self.add_empty_timeout = requestTimeout(function() {
self.createItem({
use: true
});
diff --git a/couchpotato/static/scripts/combined.plugins.min.js b/couchpotato/static/scripts/combined.plugins.min.js
index 45576ff..269e94a 100644
--- a/couchpotato/static/scripts/combined.plugins.min.js
+++ b/couchpotato/static/scripts/combined.plugins.min.js
@@ -35,9 +35,9 @@ var DownloadersBase = new Class({
text: msg_text
}).inject(button, "after");
}
- (function() {
+ requestTimeout(function() {
message.destroy();
- }).delay(3e3);
+ }, 3e3);
}
});
}
@@ -58,7 +58,7 @@ var UpdaterBase = new Class({
var self = this;
App.addEvent("load", self.info.bind(self, 2e3));
App.addEvent("unload", function() {
- if (self.timer) clearTimeout(self.timer);
+ if (self.timer) clearRequestTimeout(self.timer);
});
},
check: function(onComplete) {
@@ -75,8 +75,8 @@ var UpdaterBase = new Class({
},
info: function(timeout) {
var self = this;
- if (self.timer) clearTimeout(self.timer);
- self.timer = setTimeout(function() {
+ if (self.timer) clearRequestTimeout(self.timer);
+ self.timer = requestTimeout(function() {
Api.request("updater.info", {
onComplete: function(json) {
self.json = json;
@@ -121,9 +121,11 @@ var UpdaterBase = new Class({
});
},
updating: function() {
- App.checkAvailable.delay(500, App, [ 1e3, function() {
- window.location.reload();
- } ]);
+ requestTimeout(function() {
+ App.checkAvailable(1e3, function() {
+ window.location.reload();
+ });
+ }, 500);
if (self.message) self.message.destroy();
}
});
@@ -203,14 +205,14 @@ var BlockSearch = new Class({
change: self.keyup.bind(self),
keyup: self.keyup.bind(self),
focus: function() {
- if (focus_timer) clearTimeout(focus_timer);
+ if (focus_timer) clearRequestTimeout(focus_timer);
if (this.get("value")) self.hideResults(false);
},
blur: function() {
- focus_timer = function() {
+ focus_timer = requestTimeout(function() {
self.el.removeClass("focused");
self.last_q = null;
- }.delay(100);
+ }, 100);
}
}
}))));
@@ -265,8 +267,8 @@ var BlockSearch = new Class({
self.el[self.q() ? "addClass" : "removeClass"]("filled");
if (self.q() != self.last_q) {
if (self.api_request && self.api_request.isRunning()) self.api_request.cancel();
- if (self.autocomplete_timer) clearTimeout(self.autocomplete_timer);
- self.autocomplete_timer = self.autocomplete.delay(300, self);
+ if (self.autocomplete_timer) clearRequestTimeout(self.autocomplete_timer);
+ self.autocomplete_timer = requestTimeout(self.autocomplete.bind(self), 300);
}
},
autocomplete: function() {
@@ -281,7 +283,7 @@ var BlockSearch = new Class({
var self = this, q = self.q(), cache = self.cache[q];
self.hideResults(false);
if (!cache) {
- setTimeout(function() {
+ requestTimeout(function() {
self.mask.addClass("show");
}, 10);
if (!self.spinner) self.spinner = createSpinner(self.mask);
@@ -789,8 +791,8 @@ var MovieList = new Class({
},
search: function() {
var self = this;
- if (self.search_timer) clearTimeout(self.search_timer);
- self.search_timer = function() {
+ if (self.search_timer) clearRequestTimeout(self.search_timer);
+ self.search_timer = requestTimeout(function() {
var search_value = self.navigation_search_input.get("value");
if (search_value == self.last_search_value) return;
self.reset();
@@ -798,7 +800,7 @@ var MovieList = new Class({
self.filter.search = search_value;
self.getMovies(true);
self.last_search_value = search_value;
- }.delay(250);
+ }, 250);
},
update: function() {
var self = this;
@@ -818,7 +820,7 @@ var MovieList = new Class({
})).inject(self.el, "top");
createSpinner(self.loader_first);
var lfc = self.loader_first;
- loader_timeout = setTimeout(function() {
+ loader_timeout = requestTimeout(function() {
lfc.addClass("show");
}, 10);
self.el.setStyle("min-height", 220);
@@ -831,12 +833,12 @@ var MovieList = new Class({
}, self.filter),
onSuccess: function(json) {
if (reset) self.movie_list.empty();
- if (loader_timeout) clearTimeout(loader_timeout);
+ if (loader_timeout) clearRequestTimeout(loader_timeout);
if (self.loader_first) {
var lf = self.loader_first;
self.loader_first = null;
lf.removeClass("show");
- setTimeout(function() {
+ requestTimeout(function() {
lf.destroy();
}, 1e3);
self.el.setStyle("min-height", null);
@@ -941,13 +943,13 @@ var MoviesManage = new Class({
},
startProgressInterval: function() {
var self = this;
- self.progress_interval = setInterval(function() {
+ self.progress_interval = requestInterval(function() {
if (self.progress_request && self.progress_request.running) return;
self.update_in_progress = true;
self.progress_request = Api.request("manage.progress", {
onComplete: function(json) {
if (!json || !json.progress) {
- clearInterval(self.progress_interval);
+ clearRequestInterval(self.progress_interval);
self.update_in_progress = false;
if (self.progress_container) {
self.progress_container.destroy();
@@ -1267,7 +1269,7 @@ MA.Trailer = new Class({
click: self.watch.bind(self)
}
}).adopt(new Element('span[text="watch"]'), new Element('span[text="trailer"]')), self.background = new Element("div.background"));
- setTimeout(function() {
+ requestTimeout(function() {
var url = data_url.substitute({
title: encodeURI(self.getTitle()),
year: self.get("year")
@@ -1763,7 +1765,7 @@ var Movie = new Class({
});
}
App.getPageContainer().grab(self.details);
- self.details.open.delay(10, self.details);
+ requestTimeout(self.details.open.bind(self.details), 10);
},
addEvents: function() {
var self = this;
@@ -1771,7 +1773,9 @@ var Movie = new Class({
self.global_events["movie.update"] = function(notification) {
if (self.data._id != notification.data._id) return;
self.busy(false);
- self.update.delay(2e3, self, notification);
+ requestTimeout(function() {
+ self.update(notification);
+ }, 2e3);
};
App.on("movie.update", self.global_events["movie.update"]);
[ "media.busy", "movie.searcher.started" ].each(function(listener) {
@@ -1814,10 +1818,10 @@ var Movie = new Class({
busy: function(set_busy, timeout) {
var self = this;
if (!set_busy) {
- setTimeout(function() {
+ requestTimeout(function() {
if (self.spinner) {
self.mask.fade("out");
- setTimeout(function() {
+ requestTimeout(function() {
if (self.mask) self.mask.destroy();
if (self.spinner) self.spinner.destroy();
self.spinner = null;
@@ -1925,7 +1929,7 @@ var Movie = new Class({
self.addActions();
if (self.list.current_view == "thumb") {
self.el.addClass("hover_start");
- setTimeout(function() {
+ requestTimeout(function() {
self.el.removeClass("hover_start");
}, 300);
dynamics.css(self.inner, {
@@ -2244,7 +2248,7 @@ var MoviesWanted = new Class({
}), App.createUserscriptButtons())
});
$(self.list).inject(self.content);
- self.startProgressInterval.delay(4e3, self);
+ requestTimeout(self.startProgressInterval.bind(self), 4e3);
}
},
doFullSearch: function() {
@@ -2257,13 +2261,13 @@ var MoviesWanted = new Class({
startProgressInterval: function() {
var self = this;
var start_text = self.manual_search.get("text");
- self.progress_interval = setInterval(function() {
+ self.progress_interval = requestInterval(function() {
if (self.search_progress && self.search_progress.running) return;
self.search_progress = Api.request("movie.searcher.progress", {
onComplete: function(json) {
self.search_in_progress = true;
if (!json.movie) {
- clearInterval(self.progress_interval);
+ clearRequestInterval(self.progress_interval);
self.search_in_progress = false;
self.manual_search.set("text", start_text);
} else {
@@ -2327,7 +2331,9 @@ var Charts = new Class({
text: "Refreshing charts..."
})));
self.show();
- self.fireEvent.delay(0, self, "created");
+ requestTimeout(function() {
+ self.fireEvent("created");
+ }, 0);
},
fill: function(json) {
var self = this;
@@ -2361,7 +2367,7 @@ var Charts = new Class({
var self = this;
self.el.show();
if (!self.shown_once) {
- setTimeout(function() {
+ requestTimeout(function() {
self.api_request = Api.request("charts.view", {
onComplete: self.fill.bind(self)
});
@@ -2439,7 +2445,9 @@ var NotificationBase = new Class({
self.badge = new Element("div.badge").inject(App.block.notification, "top").hide();
});
window.addEvent("load", function() {
- self.startInterval.delay($(window).getSize().x <= 480 ? 2e3 : 100, self);
+ requestTimeout(function() {
+ self.startInterval($(window).getSize().x <= 480 ? 2e3 : 100);
+ }, 0);
});
},
notify: function(result) {
@@ -2501,7 +2509,7 @@ var NotificationBase = new Class({
self.processData(json, true);
}
}).send();
- setInterval(function() {
+ requestInterval(function() {
if (self.request && self.request.isRunning()) {
self.request.cancel();
self.startPoll();
@@ -2520,7 +2528,7 @@ var NotificationBase = new Class({
last_id: self.last_id
},
onFailure: function() {
- self.startPoll.delay(2e3, self);
+ requestTimeout(self.startPoll.bind(self), 2e3);
}
}).send();
},
@@ -2537,7 +2545,7 @@ var NotificationBase = new Class({
});
if (json.result.length > 0) self.last_id = json.result.getLast().message_id;
}
- self.startPoll.delay(1500, self);
+ requestTimeout(self.startPoll.bind(self), 1500);
},
showMessage: function(message, sticky, data) {
var self = this;
@@ -2546,12 +2554,12 @@ var NotificationBase = new Class({
class: "message" + (sticky ? " sticky" : ""),
html: '' + message + "
"
}).inject(self.message_container, "top");
- setTimeout(function() {
+ requestTimeout(function() {
new_message.addClass("show");
}, 10);
var hide_message = function() {
new_message.addClass("hide");
- setTimeout(function() {
+ requestTimeout(function() {
new_message.destroy();
}, 1e3);
};
@@ -2562,7 +2570,7 @@ var NotificationBase = new Class({
hide_message();
}
}
- })); else setTimeout(hide_message, 4e3);
+ })); else requestTimeout(hide_message, 4e3);
},
addTestButtons: function() {
var self = this;
@@ -2593,9 +2601,9 @@ var NotificationBase = new Class({
text: "Notification failed. Check logs for details."
}).inject(button, "after");
}
- (function() {
+ requestTimeout(function() {
message.destroy();
- }).delay(3e3);
+ }, 3e3);
}
});
}
@@ -2818,8 +2826,8 @@ var Category = new Class({
},
save: function(delay) {
var self = this;
- if (self.save_timer) clearTimeout(self.save_timer);
- self.save_timer = function() {
+ if (self.save_timer) clearRequestTimeout(self.save_timer);
+ self.save_timer = requestTimeout(function() {
Api.request("category.save", {
data: self.getData(),
useSpinner: true,
@@ -2832,7 +2840,7 @@ var Category = new Class({
}
}
});
- }.delay(delay || 0, self);
+ }, delay || 0);
},
getData: function() {
var self = this;
@@ -2919,7 +2927,9 @@ Page.Log = new Class({
text: "loading...",
events: {
"mouseup:relay(.time)": function(e) {
- self.showSelectionButton.delay(100, self, e);
+ requestTimeout(function() {
+ self.showSelectionButton(2);
+ }, 100);
}
}
}).inject(self.content);
@@ -3054,7 +3064,7 @@ Page.Log = new Class({
}
}
}).inject(document.body);
- setTimeout(function() {
+ requestTimeout(function() {
document.body.addEvent("click", remove_button);
}, 0);
},
@@ -3179,8 +3189,8 @@ var Profile = new Class({
},
save: function(delay) {
var self = this;
- if (self.save_timer) clearTimeout(self.save_timer);
- self.save_timer = function() {
+ if (self.save_timer) clearRequestTimeout(self.save_timer);
+ self.save_timer = requestTimeout(function() {
self.addType();
var data = self.getData();
if (data.types.length < 2) return; else self.delete_button.show();
@@ -3197,7 +3207,7 @@ var Profile = new Class({
}
}
});
- }.delay(delay, self);
+ }, delay);
},
getData: function() {
var self = this;
@@ -3541,8 +3551,8 @@ var QualityBase = new Class({
size_timer: {},
changeSize: function(identifier, type, value) {
var self = this;
- if (self.size_timer[identifier + type]) clearTimeout(self.size_timer[identifier + type]);
- self.size_timer[identifier + type] = function() {
+ if (self.size_timer[identifier + type]) clearRequestTimeout(self.size_timer[identifier + type]);
+ self.size_timer[identifier + type] = requestTimeout(function() {
Api.request("quality.size.save", {
data: {
identifier: identifier,
@@ -3550,7 +3560,7 @@ var QualityBase = new Class({
value: value
}
});
- }.delay(300);
+ }, 300);
}
});
@@ -3731,10 +3741,10 @@ Page.Wizard = new Class({
self.scroll = new Fx.Scroll(document.body, {
transition: "quint:in:out"
});
- } else (function() {
+ } else requestTimeout(function() {
var sc = self.el.getElement(".wgroup_" + action);
self.scroll.start(0, sc.getCoordinates().top - 80);
- }).delay(1);
+ }, 1);
},
orderGroups: function() {
var self = this;
diff --git a/couchpotato/static/scripts/combined.vendor.min.js b/couchpotato/static/scripts/combined.vendor.min.js
index 40b1e01..cbc329c 100644
--- a/couchpotato/static/scripts/combined.vendor.min.js
+++ b/couchpotato/static/scripts/combined.vendor.min.js
@@ -9027,4 +9027,44 @@ History.handleInitialState = function(base) {
} else {
window.FastClick = FastClick;
}
-})();
\ No newline at end of file
+})();
+
+window.requestAnimFrame = function() {
+ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback, element) {
+ window.setTimeout(callback, 1e3 / 60);
+ };
+}();
+
+window.requestInterval = function(fn, delay) {
+ if (!window.requestAnimationFrame && !window.webkitRequestAnimationFrame && !(window.mozRequestAnimationFrame && window.mozCancelRequestAnimationFrame) && !window.oRequestAnimationFrame && !window.msRequestAnimationFrame) return window.setInterval(fn, delay);
+ var start = new Date().getTime(), handle = new Object();
+ function loop() {
+ var current = new Date().getTime(), delta = current - start;
+ if (delta >= delay) {
+ fn.call();
+ start = new Date().getTime();
+ }
+ handle.value = requestAnimFrame(loop);
+ }
+ handle.value = requestAnimFrame(loop);
+ return handle;
+};
+
+window.clearRequestInterval = function(handle) {
+ window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) : window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) : window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) : window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) : window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) : window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) : clearInterval(handle);
+};
+
+window.requestTimeout = function(fn, delay) {
+ if (!window.requestAnimationFrame && !window.webkitRequestAnimationFrame && !(window.mozRequestAnimationFrame && window.mozCancelRequestAnimationFrame) && !window.oRequestAnimationFrame && !window.msRequestAnimationFrame) return window.setTimeout(fn, delay);
+ var start = new Date().getTime(), handle = new Object();
+ function loop() {
+ var current = new Date().getTime(), delta = current - start;
+ delta >= delay ? fn.call() : handle.value = requestAnimFrame(loop);
+ }
+ handle.value = requestAnimFrame(loop);
+ return handle;
+};
+
+window.clearRequestTimeout = function(handle) {
+ window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) : window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) : window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) : window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) : window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) : window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) : clearTimeout(handle);
+};
\ No newline at end of file
diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js
index 5101c59..12175e4 100644
--- a/couchpotato/static/scripts/couchpotato.js
+++ b/couchpotato/static/scripts/couchpotato.js
@@ -69,8 +69,8 @@
ripple.inject(el);
- setTimeout(function(){ ripple.addClass('animate'); }, 0);
- setTimeout(function(){ ripple.dispose(); }, 2100);
+ requestTimeout(function(){ ripple.addClass('animate'); }, 0);
+ requestTimeout(function(){ ripple.dispose(); }, 2100);
},
getOption: function(name){
@@ -264,7 +264,7 @@
'click': function(e){
(e).preventDefault();
self.shutdown();
- q.close.delay(100, q);
+ requestTimeout(q.close.bind(q), 100);
}
}
}, {
@@ -291,7 +291,7 @@
'click': function(e){
(e).preventDefault();
self.restart(message, title);
- q.close.delay(100, q);
+ requestTimeout(q.close.bind(q), 100);
}
}
}, {
@@ -312,10 +312,12 @@
checkAvailable: function(delay, onAvailable){
var self = this;
- (function(){
+ requestTimeout(function(){
var onFailure = function(){
- self.checkAvailable.delay(1000, self, [delay, onAvailable]);
+ requestTimeout(function(){
+ self.checkAvailable(delay, onAvailable);
+ }, 1000);
self.fireEvent('unload');
};
@@ -334,7 +336,7 @@
}
});
- }).delay(delay || 0);
+ }, delay || 0);
},
blockPage: function(message, title){
@@ -351,7 +353,7 @@
createSpinner(self.mask);
- setTimeout(function(){
+ requestTimeout(function(){
self.mask.addClass('show');
}, 10);
},
@@ -449,7 +451,7 @@
// Create parallel callback
self.global_events[name].each(function(handle){
- setTimeout(function(){
+ requestTimeout(function(){
var results = handle.apply(handle, args || []);
if(on_complete)
diff --git a/couchpotato/static/scripts/library/question.js b/couchpotato/static/scripts/library/question.js
index d385f0b..bcc3c92 100644
--- a/couchpotato/static/scripts/library/question.js
+++ b/couchpotato/static/scripts/library/question.js
@@ -29,7 +29,7 @@ var Question = new Class( {
)
).inject(document.body);
- setTimeout(function(){
+ requestTimeout(function(){
self.container.addClass('show');
self.inner.getElements('> *').each(function(el, nr){
diff --git a/couchpotato/static/scripts/page.js b/couchpotato/static/scripts/page.js
index e59f941..355a0dd 100644
--- a/couchpotato/static/scripts/page.js
+++ b/couchpotato/static/scripts/page.js
@@ -29,7 +29,7 @@ var PageBase = new Class({
// Stop hover events while scrolling
App.addEvent('load', function(){
- setTimeout(function(){
+ requestTimeout(function(){
if(!App.mobile_screen && !App.getOption('dev')){
self.content.addEvent('scroll', self.preventHover.bind(self));
}
@@ -165,10 +165,10 @@ var PageBase = new Class({
preventHover: function(){
var self = this;
- if(self.hover_timer) clearTimeout(self.hover_timer);
+ if(self.hover_timer) clearRequestTimeout(self.hover_timer);
self.el.addClass('disable_hover');
- self.hover_timer = setTimeout(function(){
+ self.hover_timer = requestTimeout(function(){
self.el.removeClass('disable_hover');
}, 200);
},
diff --git a/couchpotato/static/scripts/page/settings.js b/couchpotato/static/scripts/page/settings.js
index 3628bc8..c255279 100644
--- a/couchpotato/static/scripts/page/settings.js
+++ b/couchpotato/static/scripts/page/settings.js
@@ -208,7 +208,7 @@ Page.Settings = new Class({
});
});
- setTimeout(function(){
+ requestTimeout(function(){
self.el.grab(
self.navigation
);
@@ -408,8 +408,8 @@ var OptionBase = new Class({
if(self.getValue() != self.previous_value){
if(self.save_on_change){
- if(self.changed_timer) clearTimeout(self.changed_timer);
- self.changed_timer = self.save.delay(300, self);
+ if(self.changed_timer) clearRequestTimeout(self.changed_timer);
+ self.changed_timer = requestTimeout(self.save.bind(self), 300);
}
self.fireEvent('change');
}
@@ -442,9 +442,9 @@ var OptionBase = new Class({
self.previous_value = self.getValue();
self.el.addClass(sc);
- (function(){
+ requestTimeout(function(){
self.el.removeClass(sc);
- }).delay(3000, self);
+ }, 3000);
},
setName: function(name){
@@ -1132,7 +1132,7 @@ Option.Combined = new Class({
addEmpty: function(){
var self = this;
- if(self.add_empty_timeout) clearTimeout(self.add_empty_timeout);
+ if(self.add_empty_timeout) clearRequestTimeout(self.add_empty_timeout);
var has_empty = 0;
self.items.each(function(ctrl_holder){
@@ -1147,7 +1147,7 @@ Option.Combined = new Class({
});
if(has_empty > 0) return;
- self.add_empty_timeout = setTimeout(function(){
+ self.add_empty_timeout = requestTimeout(function(){
self.createItem({'use': true});
}, 10);
},
diff --git a/couchpotato/static/scripts/vendor/requestAnimationFrame.js b/couchpotato/static/scripts/vendor/requestAnimationFrame.js
new file mode 100644
index 0000000..9737d47
--- /dev/null
+++ b/couchpotato/static/scripts/vendor/requestAnimationFrame.js
@@ -0,0 +1,100 @@
+// requestAnimationFrame() shim by Paul Irish
+// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
+window.requestAnimFrame = (function() {
+ return window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function(/* function */ callback, /* DOMElement */ element){
+ window.setTimeout(callback, 1000 / 60);
+ };
+})();
+
+/**
+ * Behaves the same as setInterval except uses requestAnimationFrame() where possible for better performance
+ * @param {function} fn The callback function
+ * @param {int} delay The delay in milliseconds
+ */
+window.requestInterval = function(fn, delay) {
+ if( !window.requestAnimationFrame &&
+ !window.webkitRequestAnimationFrame &&
+ !(window.mozRequestAnimationFrame && window.mozCancelRequestAnimationFrame) && // Firefox 5 ships without cancel support
+ !window.oRequestAnimationFrame &&
+ !window.msRequestAnimationFrame)
+ return window.setInterval(fn, delay);
+
+ var start = new Date().getTime(),
+ handle = new Object();
+
+ function loop() {
+ var current = new Date().getTime(),
+ delta = current - start;
+
+ if(delta >= delay) {
+ fn.call();
+ start = new Date().getTime();
+ }
+
+ handle.value = requestAnimFrame(loop);
+ };
+
+ handle.value = requestAnimFrame(loop);
+ return handle;
+}
+
+/**
+ * Behaves the same as clearInterval except uses cancelRequestAnimationFrame() where possible for better performance
+ * @param {int|object} fn The callback function
+ */
+window.clearRequestInterval = function(handle) {
+ window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
+ window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) :
+ window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) : /* Support for legacy API */
+ window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
+ window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
+ window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) :
+ clearInterval(handle);
+};
+
+/**
+ * Behaves the same as setTimeout except uses requestAnimationFrame() where possible for better performance
+ * @param {function} fn The callback function
+ * @param {int} delay The delay in milliseconds
+ */
+
+window.requestTimeout = function(fn, delay) {
+ if( !window.requestAnimationFrame &&
+ !window.webkitRequestAnimationFrame &&
+ !(window.mozRequestAnimationFrame && window.mozCancelRequestAnimationFrame) && // Firefox 5 ships without cancel support
+ !window.oRequestAnimationFrame &&
+ !window.msRequestAnimationFrame)
+ return window.setTimeout(fn, delay);
+
+ var start = new Date().getTime(),
+ handle = new Object();
+
+ function loop(){
+ var current = new Date().getTime(),
+ delta = current - start;
+
+ delta >= delay ? fn.call() : handle.value = requestAnimFrame(loop);
+ };
+
+ handle.value = requestAnimFrame(loop);
+ return handle;
+};
+
+/**
+ * Behaves the same as clearTimeout except uses cancelRequestAnimationFrame() where possible for better performance
+ * @param {int|object} fn The callback function
+ */
+window.clearRequestTimeout = function(handle) {
+ window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
+ window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) :
+ window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) : /* Support for legacy API */
+ window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
+ window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
+ window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) :
+ clearTimeout(handle);
+};
diff --git a/couchpotato/templates/index.html b/couchpotato/templates/index.html
index 06e7948..a89fec0 100644
--- a/couchpotato/templates/index.html
+++ b/couchpotato/templates/index.html
@@ -22,16 +22,6 @@