From 096267376b3f6d5d48dd45d1e97cd79991fce753 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 25 Aug 2015 19:06:07 +0200 Subject: [PATCH] Movie base class extensions --- couchpotato/core/media/movie/_base/static/list.js | 10 +++++++--- couchpotato/core/media/movie/_base/static/search.js | 4 +++- couchpotato/static/scripts/block/navigation.js | 9 +++++++++ couchpotato/static/scripts/couchpotato.js | 8 ++++++++ couchpotato/templates/index.html | 3 ++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/couchpotato/core/media/movie/_base/static/list.js b/couchpotato/core/media/movie/_base/static/list.js index 6177da4..41025f1 100644 --- a/couchpotato/core/media/movie/_base/static/list.js +++ b/couchpotato/core/media/movie/_base/static/list.js @@ -2,6 +2,9 @@ var MovieList = new Class({ Implements: [Events, Options], + media_type: 'movie', + list_key: 'movies', + options: { api_call: 'media.list', navigation: true, @@ -598,7 +601,7 @@ var MovieList = new Class({ Api.request(self.options.api_call, { 'data': Object.merge({ - 'type': self.options.type || 'movie', + 'type': self.media_type || 'movie', 'status': self.options.status, 'limit_offset': self.options.limit ? self.options.limit + ',' + self.offset : null }, self.filter), @@ -619,8 +622,9 @@ var MovieList = new Class({ self.el.setStyle('min-height', null); } - self.store(json.movies); - self.addMovies(json.movies, json.total || json.movies.length); + var items = json[self.list_key] || []; + self.store(items); + self.addMovies(items, json.total || items.length); if(self.scrollspy) { self.load_more.set('text', 'load more movies'); self.scrollspy.start(); diff --git a/couchpotato/core/media/movie/_base/static/search.js b/couchpotato/core/media/movie/_base/static/search.js index 734f464..b46c3de 100644 --- a/couchpotato/core/media/movie/_base/static/search.js +++ b/couchpotato/core/media/movie/_base/static/search.js @@ -2,6 +2,8 @@ var BlockSearchMovieItem = new Class({ Implements: [Options, Events], + media_type: 'movie', + initialize: function(info, options){ var self = this; self.setOptions(options); @@ -113,7 +115,7 @@ var BlockSearchMovieItem = new Class({ self.loadingMask(); - Api.request('movie.add', { + Api.request(self.media_type + '.add', { 'data': { 'identifier': self.info.imdb, 'title': self.title_select.get('value'), diff --git a/couchpotato/static/scripts/block/navigation.js b/couchpotato/static/scripts/block/navigation.js index 1201085..9407b64 100644 --- a/couchpotato/static/scripts/block/navigation.js +++ b/couchpotato/static/scripts/block/navigation.js @@ -20,6 +20,15 @@ var BlockNavigation = new Class({ }, + removeTab: function(name) { + var self = this; + + var element = self.nav.getElement('li.tab_'+name); + if (element) { + element.dispose() + } + }, + activate: function(name){ var self = this; diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index 42a77c4..bc358d0 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -164,6 +164,14 @@ self.block.more.addLink(a); }); + // Add support classes + var support_classes = []; + self.options.support.each(function(support){ + if(support){ + support_classes.push('support_'+support); + } + }); + document.body.addClass(support_classes.join(' ')); new ScrollSpy({ min: 10, diff --git a/couchpotato/templates/index.html b/couchpotato/templates/index.html index fb1bcc4..7d1cd5d 100755 --- a/couchpotato/templates/index.html +++ b/couchpotato/templates/index.html @@ -81,7 +81,8 @@ 'app_dir': {{ json_encode(Env.get('app_dir', unicode = True)) }}, 'data_dir': {{ json_encode(Env.get('data_dir', unicode = True)) }}, 'pid': {{ json_encode(Env.getPid()) }}, - 'userscript_version': {{ json_encode(fireEvent('userscript.get_version', single = True)) }} + 'userscript_version': {{ json_encode(fireEvent('userscript.get_version', single = True)) }}, + 'support': {{ json_encode(['show' if Env.setting('enabled', 'shows') else '', 'movie']) }} }); })