diff --git a/couchpotato/core/_base/_core/__init__.py b/couchpotato/core/_base/_core/__init__.py index 5ff0176a..da32bd5f 100644 --- a/couchpotato/core/_base/_core/__init__.py +++ b/couchpotato/core/_base/_core/__init__.py @@ -11,6 +11,7 @@ config = [{ 'tab': 'general', 'name': 'basics', 'description': 'Needs restart before changes take effect.', + 'wizard': True, 'options': [ { 'name': 'username', @@ -30,7 +31,7 @@ config = [{ }, { 'name': 'port', - 'default': 5000, + 'default': 5050, 'type': 'int', 'description': 'The port I should listen to.', }, @@ -39,6 +40,7 @@ config = [{ 'default': 1, 'type': 'bool', 'description': 'Launch the browser when I start.', + 'wizard': True, }, ], }, diff --git a/couchpotato/core/downloaders/blackhole/__init__.py b/couchpotato/core/downloaders/blackhole/__init__.py index 0f0e9bbb..a958ecd1 100644 --- a/couchpotato/core/downloaders/blackhole/__init__.py +++ b/couchpotato/core/downloaders/blackhole/__init__.py @@ -11,6 +11,7 @@ config = [{ 'name': 'blackhole', 'label': 'Black hole', 'description': 'Download the NZB/Torrent to a specific folder.', + 'wizard': True, 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/downloaders/nzbget/__init__.py b/couchpotato/core/downloaders/nzbget/__init__.py index 4dff15e8..00fa3f0f 100644 --- a/couchpotato/core/downloaders/nzbget/__init__.py +++ b/couchpotato/core/downloaders/nzbget/__init__.py @@ -11,6 +11,7 @@ config = [{ 'name': 'nzbget', 'label': 'NZBGet', 'description': 'Send NZBs to your NZBGet installation.', + 'wizard': True, 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/downloaders/sabnzbd/__init__.py b/couchpotato/core/downloaders/sabnzbd/__init__.py index 79fd9035..20af743b 100644 --- a/couchpotato/core/downloaders/sabnzbd/__init__.py +++ b/couchpotato/core/downloaders/sabnzbd/__init__.py @@ -11,6 +11,7 @@ config = [{ 'name': 'sabnzbd', 'label': 'Sabnzbd', 'description': 'Send NZBs to your Sabnzbd installation.', + 'wizard': True, 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/downloaders/transmission/__init__.py b/couchpotato/core/downloaders/transmission/__init__.py index fbd89a58..1173fc2b 100644 --- a/couchpotato/core/downloaders/transmission/__init__.py +++ b/couchpotato/core/downloaders/transmission/__init__.py @@ -11,6 +11,7 @@ config = [{ 'name': 'transmission', 'label': 'Transmission', 'description': 'Send NZBs to your NZBGet installation.', + 'wizard': True, 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/plugins/searcher/__init__.py b/couchpotato/core/plugins/searcher/__init__.py index 7724534f..19a1232d 100644 --- a/couchpotato/core/plugins/searcher/__init__.py +++ b/couchpotato/core/plugins/searcher/__init__.py @@ -72,6 +72,7 @@ config = [{ 'tab': 'searcher', 'name': 'nzb', 'label': 'NZB', + 'wizard': True, 'options': [ { 'name': 'retention', diff --git a/couchpotato/core/plugins/wizard/static/wizard.css b/couchpotato/core/plugins/wizard/static/wizard.css new file mode 100644 index 00000000..9688f874 --- /dev/null +++ b/couchpotato/core/plugins/wizard/static/wizard.css @@ -0,0 +1,70 @@ +/* @override http://127.0.0.1:5000/static/wizard/wizard.css */ + +.page.wizard h1 { + padding: 10px 30px; + margin: 0; + display: block; + font-size: 40px; + margin-top: 80px; +} + +.page.wizard .description { + padding: 10px 30px; + font-size: 18px; + display: block; +} + +.page.wizard .tab_wrapper { + background: #5c697b; + padding: 18px 0; + font-size: 27px; + position: fixed; + top: 0; + margin: 0; + width: 100%; + left: 0; + z-index: 2; + + box-shadow: 0 0 50px rgba(0,0,0,0.55); + -moz-box-shadow: 0 0 50px rgba(0,0,0,0.55); + -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.55); +} + + .page.wizard .tab_wrapper .tabs { + text-align: center; + padding: 0; + margin: 0; + display: block; + } + + .page.wizard .tabs li { + display: inline-block; + } + .page.wizard .tabs li a { + padding: 20px 30px; + } + + .page.wizard .tab_wrapper .pointer { + border-right: 10px solid transparent; + border-left: 10px solid transparent; + border-top: 10px solid #5c697b; + display: block; + position: absolute; + top: 60px; + } + +.page.wizard .tab_content { + margin: 20px 0 160px; +} + +.page.wizard .wgroup_finish { + height: 300px; +} + + .page.wizard .button.green { + padding: 20px; + font-size: 25px; + margin: 10px 30px; + display: block; + text-align: center; + } \ No newline at end of file diff --git a/couchpotato/core/plugins/wizard/static/wizard.js b/couchpotato/core/plugins/wizard/static/wizard.js index 4ae51bbc..135e0747 100644 --- a/couchpotato/core/plugins/wizard/static/wizard.js +++ b/couchpotato/core/plugins/wizard/static/wizard.js @@ -1,225 +1,242 @@ Page.Wizard = new Class({ - Extends: PageBase, + Extends: Page.Settings, name: 'wizard', has_tab: false, + wizard_only: true, - options: { - 'onOpened': function(){ + headers: { + 'general': { + 'title': 'General', + 'description': 'If you want to access CP from outside your local network, you better secure it a bit with a username & password.' + }, + 'downloaders': { + 'title': 'What download apps are you using?', + 'description': 'If you don\'t have any of these listed, you have to use Blackhole. Or drop me a line, maybe I\'ll support your download app.' + }, + 'providers': { + 'title': 'Are you registered at any of these sites?', + 'description': 'CP uses these sites to search for movies. A few free are enabled by default, but it\'s always better to have a few more.' + }, + 'renamer': { + 'title': 'Move & rename the movies after downloading?', + 'description': '' + }, + 'finish': { + 'title': 'Finish Up', + 'description': 'Are you done? Did you fill in everything or as much as possible? Yes, ok gogogo!', + 'content': new Element('div').adopt( + new Element('a.button.green', { + 'text': 'I\'m ready to start the awesomeness, wow this button is big and green!', + 'events': { + 'click': function(e){ + (e).stop(); + Api.request('settings.save', { + 'data': { + 'section': 'core', + 'name': 'show_wizard', + 'value': 0 + }, + 'useSpinner': true, + 'spinnerOptions': { + 'target': self.el + }, + 'onComplete': function(){ + window.location = App.createUrl(); + } + }); + } + } + }) + ) + } + }, + groups: ['general', 'downloaders', 'searcher', 'providers', 'renamer', 'finish'], + + open: function(action, params){ + var self = this; + + if(!self.initialized){ App.fireEvent('unload'); App.getBlock('header').hide(); + + self.parent(action, params); + + self.addEvent('create', function(){ + var mnn = new MultipleNewznab('Wizard'); + mnn.addSettings(); + + self.order(); + }); + + self.initialized = true; + + self.scroll = new Fx.Scroll(document.body, { + 'transition': 'quint:in:out' + }); } + else + (function(){ + var sc = self.el.getElement('.wgroup_'+action); + self.scroll.start(0, sc.getCoordinates().top-80); + }).delay(1) }, - initialize: function(options){ + order: function(){ var self = this; - self.parent(options); - // Create steps - self.steps = [ - {'step':'index', 'title': 'Welcome'}, - {'step':'step1', 'title': 'Security'}, - {'step':'step2', 'title': 'Downloaders'} - ] + var form = self.el.getElement('.uniForm'); + var tabs = self.el.getElement('.tabs'); - self.breadcrumbs = new Element('ul').inject(self.el); - Object.each(self.steps, function(step, nr){ - step.el = new Element('li', { - 'class': (nr == 0 ? 'active ' : '') + 'step_'+step.step, - 'data-nr': nr, - 'text': step.title - }).inject(self.breadcrumbs) + self.groups.each(function(group){ + if(self.headers[group]){ + group_container = new Element('.wgroup_'+group, { + 'styles': { + 'opacity': 0.2 + }, + 'tween': { + 'duration': 350 + } + }); + group_container.adopt( + new Element('h1', { + 'text': self.headers[group].title + }), + self.headers[group].description ? new Element('span.description', { + 'text': self.headers[group].description + }) : null, + self.headers[group].content ? self.headers[group].content : null + ).inject(form); + } + + var tab_navigation = tabs.getElement('.t_'+group); + if(tab_navigation && group_container){ + tab_navigation.inject(tabs); // Tab navigation + self.el.getElement('.tab_'+group).inject(group_container); // Tab content + } + else { + new Element('li.t_'+group).adopt( + new Element('a', { + 'href': App.createUrl('wizard/'+group), + 'text': group.capitalize() + }) + ).inject(tabs); + } }); - p(self.steps); + // Remove toggle + self.el.getElement('.advanced_toggle').destroy(); - }, + // Hide retention + self.el.getElement('.tab_searcher').hide(); + self.el.getElement('.t_searcher').hide(); - nextStep: function(e){ - var self = this; - (e).stop(); - - var next = (self.current_step || 0)+1; - var step = self.steps[next]; - self.breadcrumbs.getElement('.active').removeClass('active'); - step.el.addClass('active'); - - self.openUrl('/'+self.name+'/'+step.step+'/'); - - p('nextStep'); - }, - - previousStep: function(){ - var self = this; - - p('previousStep'); - }, - - stop: function(){ - var self = this; - (e).stop(); - - p('close'); - }, - - // Welcome - indexAction: function(){ - var self = this; - - var step = new Page.Wizard.Step('welcome', { - 'title': 'Welcome to the CouchPotato wizard', - 'description': 'Before you can start creating that butt-formed hole in you couch, you must complete the following wizard.', - 'groups': [ - { - 'content': new Element('a.button.green', { - 'text': 'Go to the first step', - 'events': { - 'click': self.nextStep.bind(self) - } - }) - }, - { - 'title': 'Skip wizard', - 'description': 'You can always activate the wizard from within the settings page', - 'content': new Element('a.button.orange', { - 'text': 'I already know how this works, I\'ll fill it in manually, thanks.', - 'events': { - 'click': self.stop.bind(self) - } - }) + // Add pointer + new Element('.tab_wrapper').wraps(tabs).adopt( + self.pointer = new Element('.pointer', { + 'tween': { + 'transition': 'quint:in:out' } - ] + }) + ); + + // Add nav + var minimum = self.el.getSize().y-window.getSize().y; + self.groups.each(function(group, nr){ + + var g = self.el.getElement('.wgroup_'+group); + if(!g || !g.isVisible()) return; + var t = self.el.getElement('.t_'+group); + if(!t) return; + + var func = function(){ + var ct = t.getCoordinates(); + self.pointer.tween('left', ct.left+(ct.width/2)-(self.pointer.getWidth()/2)); + g.tween('opacity', 1); + } + + if(nr == 0) + func(); + + + var ss = new ScrollSpy( { + min: function(){ + var c = g.getCoordinates(); + var top = c.top-(window.getSize().y/2); + return top > minimum ? minimum : top + }, + max: function(){ + var c = g.getCoordinates(); + return c.top+(c.height/2) + }, + onEnter: func, + onLeave: function(){ + g.tween('opacity', 0.2) + } + }); }); - return [self.breadcrumbs, step] - - }, - - // Username password browser - step1Action: function(){ - var self = this; - - var step = new Page.Wizard.Step('security', { - 'title': 'Security', - 'description': 'Before you can start creating that butt-formed hole in you couch, you must complete the following wizard.', - 'groups': [ - { - 'title': 'Fill in your username and password', - 'description': 'Keep blank if you don\'t want to secure CP.', - 'fields': ['core.username', 'core.password'] - }, - { - 'title': 'Launch the browser when CP starts', - 'fields': ['core.launch_browser'] - } - ] - }) - - return [self.breadcrumbs, step] - }, - - // NZB Torrent, downloaders - step2Action: function(){ - var options = { - 'title': 'What do you use to download your movies', - 'answers': [ - {'name': 'nzb', 'label': 'Usenet'}, - {'name': 'torrent', 'label': 'Torrents'} - ] - } } - // NZB show affiliates - // NZB: retention - // Downloaders - // Providers - // Automated registration nzb.su via email api - // Renamer - // Userscript, depending on browser - // Extras: - // Notifications - // Metadata - }); -Page.Wizard.Step = new Class({ - - Implements: [Options], - - initialize: function(name, options){ - var self = this; - self.setOptions(options); - - self.name = name; - self.create(); - +var ScrollSpy = new Class( { + Implements : [ Options, Events ], + + options : { + min : 0, + mode : "vertical", + max : 0, + container : window, + onEnter : Function.from(), + onLeave : Function.from(), + onTick : Function.from() }, + initialize : function(b) { + this.setOptions(b); + this.container = $(this.options.container); + this.enters = this.leaves = 0; + this.timer = 0; - create: function(){ - var self = this; - - // Main element - self.el = new Element('div.step').addClass(self.name || ''); - - self.createTitleDescription(self.options, self.el); - - // Groups - if(self.options.groups){ - self.groups = new Element('div.groups').inject(self.el); - self.options.groups.each(self.createGroup.bind(self)); + if (this.options.max == 0) { + var c = this.container.getScrollSize(); + this.options.max = this.options.mode == "vertical" ? c.y : c.x; } - + this.addListener(); }, - - createGroup: function(options){ + addListener : function() { var self = this; - - var group = new Element('div.group').inject(self.groups); - - self.createTitleDescription(options, group); - - // Content - if(options.content) - options.content.inject(group); - - // Fields - if(options.fields) - options.fields.each(self.createField.bind(self)) - - + + self.inside = false; + self.container.addEvent("scroll", function() { + if(self.timer) clearTimeout(self.timer); + self.timer = self.scrollHandler(); + }); }, - - createField: function(field){ - - }, - - createTitleDescription: function(options, inject_in){ + + scrollHandler: function(){ var self = this; - - - // Title - if(options.title) - self.title = new Element('div.title', { - 'text': options.title - }).inject(inject_in); - - // Descriptions - if(options.description) - self.title = new Element('div.description', { - 'text': options.description - }).inject(inject_in); - - }, - - toElement: function(){ - return this.el; + + var b = self.container.getScroll(); + var c = self.options.mode == "vertical" ? b.y : b.x; + + var min = typeOf(self.options.min) == 'function' ? self.options.min() : self.options.min; + var max = typeOf(self.options.max) == 'function' ? self.options.max() : self.options.max; + + if (c >= min && c <= max) { + if (!self.inside) { + self.inside = true; + self.enters++; + self.fireEvent("enter", [ b, this.enters ]); + } + self.fireEvent("tick", [ b, self.inside, self.enters, self.leaves ]); + } else { + if (self.inside) { + self.inside = false; + self.leaves++; + self.fireEvent("leave", [ b, self.leaves ]); + } + } } - -}) - -window.addEvent('domready', function(){ - - // Check if wizard is enabled - }); diff --git a/couchpotato/core/providers/movie/themoviedb/main.py b/couchpotato/core/providers/movie/themoviedb/main.py index f44cba59..8229841a 100644 --- a/couchpotato/core/providers/movie/themoviedb/main.py +++ b/couchpotato/core/providers/movie/themoviedb/main.py @@ -151,10 +151,10 @@ class TheMovieDb(MovieProvider): 'titles': [toUnicode(movie.get('name'))], 'original_title': movie.get('original_name'), 'images': { - 'poster': [poster], - 'backdrop': [backdrop], - 'poster_original': [poster_original], - 'backdrop_original': [backdrop_original], + 'poster': [poster] if poster else [], + 'backdrop': [backdrop] if backdrop else [], + 'poster_original': [poster_original] if poster_original else [], + 'backdrop_original': [backdrop_original] if backdrop_original else [], }, 'imdb': movie.get('imdb_id'), 'runtime': movie.get('runtime'), diff --git a/couchpotato/core/providers/nzb/newzbin/__init__.py b/couchpotato/core/providers/nzb/newzbin/__init__.py index 0b411bff..ea0c27df 100644 --- a/couchpotato/core/providers/nzb/newzbin/__init__.py +++ b/couchpotato/core/providers/nzb/newzbin/__init__.py @@ -9,6 +9,7 @@ config = [{ { 'tab': 'providers', 'name': 'newzbin', + 'wizard': True, 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/providers/nzb/newznab/__init__.py b/couchpotato/core/providers/nzb/newznab/__init__.py index 341e6fd3..e519b96a 100644 --- a/couchpotato/core/providers/nzb/newznab/__init__.py +++ b/couchpotato/core/providers/nzb/newznab/__init__.py @@ -10,6 +10,7 @@ config = [{ 'tab': 'providers', 'name': 'newznab', 'description': 'Enable multiple NewzNab providers such as NZB.su', + 'wizard': True, 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/providers/nzb/newznab/static/newznab.js b/couchpotato/core/providers/nzb/newznab/static/newznab.js index dc730a66..13647b59 100644 --- a/couchpotato/core/providers/nzb/newznab/static/newznab.js +++ b/couchpotato/core/providers/nzb/newznab/static/newznab.js @@ -2,13 +2,15 @@ var MultipleNewznab = new Class({ input_types: ['use', 'host', 'api_key'], - initialize: function(){ + initialize: function(page){ var self = this; self.items = []; self.values = []; self.inputs = {}; + self.page = page; + App.addEvent('load', self.addSettings.bind(self)) }, @@ -16,7 +18,7 @@ var MultipleNewznab = new Class({ addSettings: function(){ var self = this; - self.settings = App.getPage('Settings') + self.settings = App.getPage(self.page || 'Settings') self.settings.addEvent('create', function(){ self.fieldset = self.settings.tabs.providers.content.getElement('.section_newznab'); diff --git a/couchpotato/core/providers/nzb/nzbindex/__init__.py b/couchpotato/core/providers/nzb/nzbindex/__init__.py index cf3139c9..822823b1 100644 --- a/couchpotato/core/providers/nzb/nzbindex/__init__.py +++ b/couchpotato/core/providers/nzb/nzbindex/__init__.py @@ -10,6 +10,7 @@ config = [{ 'tab': 'providers', 'name': 'nzbindex', 'description': 'Free provider, but less accurate.', + 'advanced': True, 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/providers/nzb/nzbmatrix/__init__.py b/couchpotato/core/providers/nzb/nzbmatrix/__init__.py index 37586a16..84d17074 100644 --- a/couchpotato/core/providers/nzb/nzbmatrix/__init__.py +++ b/couchpotato/core/providers/nzb/nzbmatrix/__init__.py @@ -10,6 +10,7 @@ config = [{ 'tab': 'providers', 'name': 'nzbmatrix', 'label': 'NZBMatrix', + 'wizard': True, 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/providers/nzb/nzbs/__init__.py b/couchpotato/core/providers/nzb/nzbs/__init__.py index c4c60002..bd9f9a37 100644 --- a/couchpotato/core/providers/nzb/nzbs/__init__.py +++ b/couchpotato/core/providers/nzb/nzbs/__init__.py @@ -10,6 +10,7 @@ config = [{ 'tab': 'providers', 'name': 'nzbs', 'description': 'Id and Key can be found on your nzbs.org RSS page.', + 'wizard': True, 'options': [ { 'name': 'enabled', diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index 84a885dd..7ab21d03 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -22,13 +22,12 @@ var CouchPotato = new Class({ self.createLayout(); self.createPages(); - History.addEvent('change', self.openPage.bind(self)); - if(window.location.hash) History.handleInitialState(); else self.openPage(window.location.pathname); + History.addEvent('change', self.openPage.bind(self)); self.c.addEvent('click:relay(a[href]:not([target=_blank]):not([normalhref=true]))', self.pushState.bind(self)); }, @@ -79,6 +78,10 @@ var CouchPotato = new Class({ openPage: function(url) { var self = this; + var current_url = url.replace(/^\/+|\/+$/g, ''); + if(current_url == self.current_url) + return; + self.route.parse(url); var page_name = self.route.getPage().capitalize(); var action = self.route.getAction(); @@ -89,14 +92,15 @@ var CouchPotato = new Class({ try { var page = self.pages[page_name] || self.pages.Wanted; - page.open(action, params); - page.show(); + page.open(action, params); + page.show(); } catch(e){ - p("Can't open page:" + url) + console.error("Can't open page:" + url, e) } self.current_page = page; + self.current_url = current_url; }, @@ -160,6 +164,10 @@ var CouchPotato = new Class({ unBlockPage: function(){ var self = this; self.mask.hide(); + }, + + createUrl: function(action, params){ + return this.options.base_url + (action ? action+'/' : '') + (params ? '?'+Object.toQueryString(params) : '') } }); @@ -314,4 +322,5 @@ function randomString(length, extra) { return this.sort(comparer); }); -})(); \ No newline at end of file +})(); + diff --git a/couchpotato/static/scripts/page.js b/couchpotato/static/scripts/page.js index e7c49559..73753ffe 100644 --- a/couchpotato/static/scripts/page.js +++ b/couchpotato/static/scripts/page.js @@ -33,9 +33,11 @@ var PageBase = new Class({ //p('Opening: ' +self.getName() + ', ' + action + ', ' + Object.toQueryString(params)); try { - self.el.empty(); var elements = self[action+'Action'](params); - self.el.adopt(elements); + if(elements !== undefined){ + self.el.empty(); + self.el.adopt(elements); + } self.fireEvent('opened'); } diff --git a/couchpotato/static/scripts/page/settings.js b/couchpotato/static/scripts/page/settings.js index b8167ee4..3dcfde3e 100644 --- a/couchpotato/static/scripts/page/settings.js +++ b/couchpotato/static/scripts/page/settings.js @@ -4,15 +4,9 @@ Page.Settings = new Class({ name: 'settings', title: 'Change settings.', + wizard_only: false, - tabs: { - 'general': {}, - 'searcher': {}, - 'providers': {}, - 'downloaders': {}, - 'notifications': {}, - 'renamer': {} - }, + tabs: {}, open: function(action, params){ var self = this; @@ -20,9 +14,10 @@ Page.Settings = new Class({ self.params = params; if(!self.data) - self.getData(self.create.bind(self)) - else + self.getData(self.create.bind(self)); + else { self.openTab(action); + } }, openTab: function(action){ @@ -88,7 +83,7 @@ Page.Settings = new Class({ }, create: function(json){ - var self = this + var self = this; self.el.adopt( self.tabs_container = new Element('ul.tabs'), @@ -108,12 +103,7 @@ Page.Settings = new Class({ ); self.showAdvanced(); - new Form.Check(self.advanced_toggle) - - // Create tabs - Object.each(self.tabs, function(tab, tab_name){ - self.createTab(tab_name, tab) - }); + new Form.Check(self.advanced_toggle); // Add content to tabs Object.each(json.options, function(section, section_name){ @@ -121,6 +111,13 @@ Page.Settings = new Class({ // Add groups to content section.groups.sortBy('order').each(function(group){ + if(self.wizard_only && !group.wizard) + return; + + // Create tab + if(!self.tabs[group.tab] || !self.tabs[group.tab].groups) + self.createTab(group.tab, {}); + // Create the group if(!self.tabs[group.tab].groups[group.name]){ var group_el = self.createGroup(group) @@ -132,7 +129,7 @@ Page.Settings = new Class({ // Add options to group group.options.sortBy('order').each(function(option){ var class_name = (option.type || 'string').capitalize(); - var input = new Option[class_name](self, section_name, option.name, option); + var input = new Option[class_name](section_name, option.name, self.getValue(section_name, option.name), option); input.inject(self.tabs[group.tab].groups[group.name]); input.fireEvent('injected'); }); @@ -152,7 +149,7 @@ Page.Settings = new Class({ return self.tabs[tab_name].tab var label = (tab.label || tab.name || tab_name).capitalize() - var tab_el = new Element('li').adopt( + var tab_el = new Element('li.t_'+tab_name).adopt( new Element('a', { 'href': '/'+self.name+'/'+tab_name+'/', 'text': label @@ -202,13 +199,13 @@ var OptionBase = new Class({ focused_class : 'focused', save_on_change: true, - initialize: function(parent, section, name, options){ + initialize: function(section, name, value, options){ var self = this self.setOptions(options) - self.page = parent; self.section = section; self.name = name; + self.value = value; self.createBase(); self.create(); @@ -316,8 +313,7 @@ var OptionBase = new Class({ }, getSettingValue: function(){ - var self = this; - return self.page.getValue(self.section, self.name); + return this.value; }, inject: function(el, position){ @@ -571,7 +567,7 @@ Option.Directory = new Class({ } }) ) - ).inject(self.el) + ).inject(self.input, 'before'); new Form.Check(self.show_hidden); } diff --git a/couchpotato/static/scripts/page/wanted.js b/couchpotato/static/scripts/page/wanted.js index c2814d65..96e8ac79 100644 --- a/couchpotato/static/scripts/page/wanted.js +++ b/couchpotato/static/scripts/page/wanted.js @@ -24,216 +24,219 @@ Page.Wanted = new Class({ }); var MovieActions = {}; +window.addEvent('domready', function(){ -MovieActions.Wanted = { - 'IMBD': IMDBAction - ,'releases': ReleaseAction - - ,'Edit': new Class({ - - Extends: MovieAction, - - create: function(){ - var self = this; - - self.el = new Element('a.edit', { - 'title': 'Refresh the movie info and do a forced search', - 'events': { - 'click': self.editMovie.bind(self) + MovieActions.Wanted = { + 'IMBD': IMDBAction + ,'releases': ReleaseAction + + ,'Edit': new Class({ + + Extends: MovieAction, + + create: function(){ + var self = this; + + self.el = new Element('a.edit', { + 'title': 'Refresh the movie info and do a forced search', + 'events': { + 'click': self.editMovie.bind(self) + } + }); + + }, + + editMovie: function(e){ + var self = this; + (e).stop(); + + if(!self.options_container){ + self.options_container = new Element('div.options').adopt( + $(self.movie.thumbnail).clone(), + new Element('div.form', { + 'styles': { + 'line-height': self.movie.getHeight() + } + }).adopt( + self.title_select = new Element('select', { + 'name': 'title' + }), + self.profile_select = new Element('select', { + 'name': 'profile' + }), + new Element('a.button.edit', { + 'text': 'Save', + 'events': { + 'click': self.save.bind(self) + } + }) + ) + ).inject(self.movie, 'top'); + + Array.each(self.movie.data.library.titles, function(alt){ + new Element('option', { + 'text': alt.title + }).inject(self.title_select); + }); + + Object.each(Quality.getActiveProfiles(), function(profile){ + new Element('option', { + 'value': profile.id ? profile.id : profile.data.id, + 'text': profile.label ? profile.label : profile.data.label + }).inject(self.profile_select); + self.profile_select.set('value', self.movie.profile.get('id')); + }); + } - }); - - }, - - editMovie: function(e){ - var self = this; - (e).stop(); - - if(!self.options_container){ - self.options_container = new Element('div.options').adopt( - $(self.movie.thumbnail).clone(), - new Element('div.form', { + self.movie.slide('in'); + }, + + save: function(e){ + (e).stop(); + var self = this; + + Api.request('movie.edit', { + 'data': { + 'id': self.movie.get('id'), + 'default_title': self.title_select.get('value'), + 'profile_id': self.profile_select.get('value') + }, + 'useSpinner': true, + 'spinnerTarget': $(self.movie), + 'onComplete': function(){ + self.movie.quality.set('text', self.profile_select.getSelected()[0].get('text')); + self.movie.title.set('text', self.title_select.getSelected()[0].get('text')); + } + }); + + self.movie.slide('out'); + } + + }) + + ,'Refresh': new Class({ + + Extends: MovieAction, + + create: function(){ + var self = this; + + self.el = new Element('a.refresh', { + 'title': 'Refresh the movie info and do a forced search', + 'events': { + 'click': self.doSearch.bind(self) + } + }); + + }, + + doSearch: function(e){ + var self = this; + (e).stop(); + + Api.request('movie.refresh', { + 'data': { + 'id': self.movie.get('id') + } + }); + } + + }) + + ,'Delete': new Class({ + + Extends: MovieAction, + + Implements: [Chain], + + create: function(){ + var self = this; + + self.el = new Element('a.delete', { + 'title': 'Remove the movie from your wanted list', + 'events': { + 'click': self.showConfirm.bind(self) + } + }); + + }, + + showConfirm: function(e){ + var self = this; + (e).stop(); + + if(!self.delete_container){ + self.delete_container = new Element('div.delete_container', { 'styles': { 'line-height': self.movie.getHeight() } }).adopt( - self.title_select = new Element('select', { - 'name': 'title' - }), - self.profile_select = new Element('select', { - 'name': 'profile' - }), - new Element('a.button.edit', { - 'text': 'Save', + new Element('a.cancel', { + 'text': 'Cancel', 'events': { - 'click': self.save.bind(self) + 'click': self.hideConfirm.bind(self) + } + }), + new Element('span.or', { + 'text': 'or' + }), + new Element('a.button.delete', { + 'text': 'Delete ' + self.movie.title.get('text'), + 'events': { + 'click': self.del.bind(self) } }) - ) - ).inject(self.movie, 'top'); - - Array.each(self.movie.data.library.titles, function(alt){ - new Element('option', { - 'text': alt.title - }).inject(self.title_select); - }); - - Object.each(Quality.getActiveProfiles(), function(profile){ - new Element('option', { - 'value': profile.id ? profile.id : profile.data.id, - 'text': profile.label ? profile.label : profile.data.label - }).inject(self.profile_select); - self.profile_select.set('value', self.movie.profile.get('id')); - }); - - } - self.movie.slide('in'); - }, - - save: function(e){ - (e).stop(); - var self = this; - - Api.request('movie.edit', { - 'data': { - 'id': self.movie.get('id'), - 'default_title': self.title_select.get('value'), - 'profile_id': self.profile_select.get('value') - }, - 'useSpinner': true, - 'spinnerTarget': $(self.movie), - 'onComplete': function(){ - self.movie.quality.set('text', self.profile_select.getSelected()[0].get('text')); - self.movie.title.set('text', self.title_select.getSelected()[0].get('text')); + ).inject(self.movie, 'top'); } - }); - - self.movie.slide('out'); - } - - }) - - ,'Refresh': new Class({ - - Extends: MovieAction, - - create: function(){ - var self = this; - - self.el = new Element('a.refresh', { - 'title': 'Refresh the movie info and do a forced search', - 'events': { - 'click': self.doSearch.bind(self) - } - }); - - }, - - doSearch: function(e){ - var self = this; - (e).stop(); - - Api.request('movie.refresh', { - 'data': { - 'id': self.movie.get('id') - } - }); - } - - }) - - ,'Delete': new Class({ - - Extends: MovieAction, - - Implements: [Chain], - - create: function(){ - var self = this; - - self.el = new Element('a.delete', { - 'title': 'Remove the movie from your wanted list', - 'events': { - 'click': self.showConfirm.bind(self) - } - }); - - }, - - showConfirm: function(e){ - var self = this; - (e).stop(); - - if(!self.delete_container){ - self.delete_container = new Element('div.delete_container', { - 'styles': { - 'line-height': self.movie.getHeight() + + self.movie.slide('in'); + + }, + + hideConfirm: function(e){ + var self = this; + (e).stop(); + + self.movie.slide('out'); + }, + + del: function(e){ + (e).stop(); + var self = this; + + var movie = $(self.movie); + + self.chain( + function(){ + self.callChain(); + }, + function(){ + Api.request('movie.delete', { + 'data': { + 'id': self.movie.get('id') + }, + 'onComplete': function(){ + movie.set('tween', { + 'onComplete': function(){ + movie.destroy(); + } + }); + movie.tween('height', 0); + } + }); } - }).adopt( - new Element('a.cancel', { - 'text': 'Cancel', - 'events': { - 'click': self.hideConfirm.bind(self) - } - }), - new Element('span.or', { - 'text': 'or' - }), - new Element('a.button.delete', { - 'text': 'Delete ' + self.movie.title.get('text'), - 'events': { - 'click': self.del.bind(self) - } - }) - ).inject(self.movie, 'top'); + ); + + self.callChain(); + } + + }) + }; + + MovieActions.Snatched = { + 'IMBD': IMDBAction + ,'Delete': MovieActions.Wanted.Delete + }; - self.movie.slide('in'); - - }, - - hideConfirm: function(e){ - var self = this; - (e).stop(); - - self.movie.slide('out'); - }, - - del: function(e){ - (e).stop(); - var self = this; - - var movie = $(self.movie); - - self.chain( - function(){ - self.callChain(); - }, - function(){ - Api.request('movie.delete', { - 'data': { - 'id': self.movie.get('id') - }, - 'onComplete': function(){ - movie.set('tween', { - 'onComplete': function(){ - movie.destroy(); - } - }); - movie.tween('height', 0); - } - }); - } - ); - - self.callChain(); - - } - - }) -}; - -MovieActions.Snatched = { - 'IMBD': IMDBAction - ,'Delete': MovieActions.Wanted.Delete -}; \ No newline at end of file +}) \ No newline at end of file diff --git a/couchpotato/templates/_desktop.html b/couchpotato/templates/_desktop.html index 9943b6f3..67f08874 100644 --- a/couchpotato/templates/_desktop.html +++ b/couchpotato/templates/_desktop.html @@ -69,9 +69,13 @@ 'data_dir': '{{ env.get('data_dir') }}', 'userscript_version': {{ fireEvent('userscript.get_version', single = True)|safe }} }); - - //Wizard.start.delay(100, Wizard); }) + + {% if env.setting('show_wizard') %} + if(!window.location.href.contains('wizard')) + window.location = '{{ url_for('web.index') }}wizard/' + {% endif %} + CouchPotato