diff --git a/couchpotato/core/plugins/suggestion/static/suggest.js b/couchpotato/core/plugins/suggestion/static/suggest.js index 16feca97..817d965f 100644 --- a/couchpotato/core/plugins/suggestion/static/suggest.js +++ b/couchpotato/core/plugins/suggestion/static/suggest.js @@ -88,6 +88,8 @@ var SuggestList = new Class({ $(m).inject(self.el); }); + + self.fireEvent('loaded'); }, diff --git a/couchpotato/static/scripts/page/home.js b/couchpotato/static/scripts/page/home.js index 93d04351..75601df2 100644 --- a/couchpotato/static/scripts/page/home.js +++ b/couchpotato/static/scripts/page/home.js @@ -14,10 +14,24 @@ Page.Home = new Class({ self.available_list.update(); self.late_list.update(); - return + return; } - // Snatched + self.chain = new Chain(); + self.chain.chain( + self.createAvailable.bind(self), + self.createSoon.bind(self), + self.createSuggestions.bind(self), + self.createLate.bind(self) + ); + + self.chain.callChain(); + + }, + + createAvailable: function(){ + var self = this; + self.available_list = new MovieList({ 'navigation': false, 'identifier': 'snatched', @@ -40,9 +54,19 @@ Page.Home = new Class({ 'filter': { 'release_status': 'snatched,available' }, - 'limit': null + 'limit': null, + 'onLoaded': function(){ + self.chain.callChain(); + } }); + $(self.available_list).inject(self.el); + + }, + + createSoon: function(){ + var self = this; + // Coming Soon self.soon_list = new MovieList({ 'navigation': false, @@ -61,7 +85,10 @@ Page.Home = new Class({ 'load_more': false, 'view': 'thumbs', 'force_view': true, - 'api_call': 'dashboard.soon' + 'api_call': 'dashboard.soon', + 'onLoaded': function(){ + self.chain.callChain(); + } }); // Make all thumbnails the same size @@ -99,10 +126,30 @@ Page.Home = new Class({ images.setStyle('height', highest); }).delay(300); }); + }); + $(self.soon_list).inject(self.el); + + }, + + createSuggestions: function(){ + var self = this; + // Suggest - self.suggestion_list = new SuggestList(); + self.suggestion_list = new SuggestList({ + 'onLoaded': function(){ + self.chain.callChain(); + } + }); + + $(self.suggestion_list).inject(self.el); + + + }, + + createLate: function(){ + var self = this; // Still not available self.late_list = new MovieList({ @@ -118,24 +165,13 @@ Page.Home = new Class({ 'load_more': false, 'view': 'list', 'actions': [MA.IMDB, MA.Trailer, MA.Edit, MA.Refresh, MA.Delete], - 'api_call': 'dashboard.soon' + 'api_call': 'dashboard.soon', + 'onLoaded': function(){ + self.chain.callChain(); + } }); - self.el.adopt( - $(self.available_list), - $(self.soon_list), - $(self.suggestion_list), - $(self.late_list) - ); - - // Recent - // Snatched - // Renamed - // Added - - // Free space - - // Shortcuts + $(self.late_list).inject(self.el); }