From fa78d18890f8110aac7027a5e66d47d45eec91a6 Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 7 Oct 2013 23:23:46 +0200 Subject: [PATCH] Merge searches --- .../core/media/show/_base/static/search.css | 275 ------------------ .../core/media/show/_base/static/search.js | 187 +----------- couchpotato/static/scripts/couchpotato.js | 1 - 3 files changed, 1 insertion(+), 462 deletions(-) delete mode 100644 couchpotato/core/media/show/_base/static/search.css diff --git a/couchpotato/core/media/show/_base/static/search.css b/couchpotato/core/media/show/_base/static/search.css deleted file mode 100644 index ab648063..00000000 --- a/couchpotato/core/media/show/_base/static/search.css +++ /dev/null @@ -1,275 +0,0 @@ -.show_search_form { - display: inline-block; - vertical-align: middle; - position: absolute; - right: 135px; - top: 0; - text-align: left; - height: 100%; - border-bottom: 4px solid transparent; - transition: all .4s cubic-bezier(0.9,0,0.1,1); - position: absolute; - z-index: 20; - border: 1px solid transparent; - border-width: 0 0 4px; -} - .show_search_form:hover { - border-color: #047792; - } - - @media all and (max-width: 480px) { - .show_search_form { - right: 44px; - } - } - - .show_search_form.focused, - .show_search_form.shown { - border-color: #04bce6; - } - - .show_search_form .input { - height: 100%; - overflow: hidden; - width: 45px; - transition: all .4s cubic-bezier(0.9,0,0.1,1); - } - - .show_search_form.focused .input, - .show_search_form.shown .input { - width: 380px; - background: #4e5969; - } - - .show_search_form .input input { - border-radius: 0; - display: block; - border: 0; - background: none; - color: #FFF; - font-size: 25px; - height: 100%; - padding: 10px; - width: 100%; - opacity: 0; - padding: 0 40px 0 10px; - transition: all .4s ease-in-out .2s; - } - .show_search_form.focused .input input, - .show_search_form.shown .input input { - opacity: 1; - } - - @media all and (max-width: 480px) { - .show_search_form .input input { - font-size: 15px; - } - - .show_search_form.focused .input, - .show_search_form.shown .input { - width: 277px; - } - } - - .show_search_form .input a { - position: absolute; - top: 0; - right: 0; - width: 44px; - height: 100%; - cursor: pointer; - vertical-align: middle; - text-align: center; - line-height: 66px; - font-size: 15px; - color: #FFF; - } - - .show_search_form .input a:after { - content: "\e03e"; - } - - .show_search_form.shown.filled .input a:after { - content: "\e04e"; - } - - @media all and (max-width: 480px) { - .show_search_form .input a { - line-height: 44px; - } - } - - .show_search_form .results_container { - text-align: left; - position: absolute; - background: #5c697b; - margin: 4px 0 0; - width: 470px; - min-height: 50px; - box-shadow: 0 20px 20px -10px rgba(0,0,0,0.55); - display: none; - } - @media all and (max-width: 480px) { - .show_search_form .results_container { - width: 320px; - } - } - .show_search_form.focused.filled .results_container, - .show_search_form.shown.filled .results_container { - display: block; - } - - .show_search_form .results { - max-height: 570px; - overflow-x: hidden; - } - - .show_result { - overflow: hidden; - height: 50px; - position: relative; - } - - .show_result .options { - position: absolute; - height: 100%; - top: 0; - left: 30px; - right: 0; - padding: 13px; - border: 1px solid transparent; - border-width: 1px 0; - border-radius: 0; - box-shadow: inset 0 1px 8px rgba(0,0,0,0.25); - } - .show_result .options > .in_library_wanted { - margin-top: -7px; - } - - .show_result .options > div { - border: 0; - } - - .show_result .options .thumbnail { - vertical-align: middle; - } - - .show_result .options select { - vertical-align: middle; - display: inline-block; - margin-right: 10px; - } - .show_result .options select[name=title] { width: 170px; } - .show_result .options select[name=profile] { width: 90px; } - .show_result .options select[name=category] { width: 80px; } - - @media all and (max-width: 480px) { - - .show_result .options select[name=title] { width: 90px; } - .show_result .options select[name=profile] { width: 50px; } - .show_result .options select[name=category] { width: 50px; } - - } - - .show_result .options .button { - vertical-align: middle; - display: inline-block; - } - - .show_result .options .message { - height: 100%; - font-size: 20px; - color: #fff; - line-height: 20px; - } - - .show_result .data { - position: absolute; - height: 100%; - top: 0; - left: 30px; - right: 0; - background: #5c697b; - cursor: pointer; - border-top: 1px solid rgba(255,255,255, 0.08); - transition: all .4s cubic-bezier(0.9,0,0.1,1); - } - .show_result .data.open { - left: 100% !important; - } - - .show_result:last-child .data { border-bottom: 0; } - - .show_result .in_wanted, .show_result .in_library { - position: absolute; - bottom: 2px; - left: 14px; - font-size: 11px; - } - - .show_result .thumbnail { - width: 34px; - min-height: 100%; - display: block; - margin: 0; - vertical-align: top; - } - - .show_result .info { - position: absolute; - top: 20%; - left: 15px; - right: 7px; - vertical-align: middle; - } - - .show_result .info h2 { - margin: 0; - font-weight: normal; - font-size: 20px; - padding: 0; - } - - .show_search_form .info h2 { - position: absolute; - width: 100%; - } - - .show_result .info h2 .title { - display: block; - margin: 0; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - } - - .show_search_form .info h2 .title { - position: absolute; - width: 88%; - } - - .show_result .info h2 .year { - padding: 0 5px; - text-align: center; - position: absolute; - width: 12%; - right: 0; - } - - @media all and (max-width: 480px) { - - .show_search_form .info h2 .year { - font-size: 12px; - margin-top: 7px; - } - - } - -.show_search_form .mask, -.show_result .mask { - position: absolute; - height: 100%; - width: 100%; - left: 0; - top: 0; -} \ No newline at end of file diff --git a/couchpotato/core/media/show/_base/static/search.js b/couchpotato/core/media/show/_base/static/search.js index 6a089f89..3bfaaf78 100644 --- a/couchpotato/core/media/show/_base/static/search.js +++ b/couchpotato/core/media/show/_base/static/search.js @@ -1,189 +1,4 @@ -Block.ShowSearch = new Class({ - - Extends: BlockBase, - - cache: {}, - - create: function(){ - var self = this; - - var focus_timer = 0; - self.el = new Element('div.show_search_form').adopt( - new Element('div.input').adopt( - self.input = new Element('input', { - 'placeholder': 'Search & add a new *show*', - 'events': { - 'keyup': self.keyup.bind(self), - 'focus': function(){ - if(focus_timer) clearTimeout(focus_timer); - self.el.addClass('focused') - if(this.get('value')) - self.hideResults(false) - }, - 'blur': function(){ - focus_timer = (function(){ - self.el.removeClass('focused') - }).delay(100); - } - } - }), - new Element('a.icon2', { - 'events': { - 'click': self.clear.bind(self), - 'touchend': self.clear.bind(self) - } - }) - ), - self.result_container = new Element('div.results_container', { - 'tween': { - 'duration': 200 - }, - 'events': { - 'mousewheel': function(e){ - (e).stopPropagation(); - } - } - }).adopt( - self.results = new Element('div.results') - ) - ); - - self.mask = new Element('div.mask').inject(self.result_container).fade('hide'); - - }, - - clear: function(e){ - var self = this; - (e).preventDefault(); - - if(self.last_q === ''){ - self.input.blur() - self.last_q = null; - } - else { - - self.last_q = ''; - self.input.set('value', ''); - self.input.focus() - - self.shows = [] - self.results.empty() - self.el.removeClass('filled') - - } - }, - - hideResults: function(bool){ - var self = this; - - if(self.hidden == bool) return; - - self.el[bool ? 'removeClass' : 'addClass']('shown'); - - if(bool){ - History.removeEvent('change', self.hideResults.bind(self, !bool)); - self.el.removeEvent('outerClick', self.hideResults.bind(self, !bool)); - } - else { - History.addEvent('change', self.hideResults.bind(self, !bool)); - self.el.addEvent('outerClick', self.hideResults.bind(self, !bool)); - } - - self.hidden = bool; - }, - - keyup: function(e){ - var self = this; - - 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) - } - - }, - - autocomplete: function(){ - var self = this; - - if(!self.q()){ - self.hideResults(true) - return - } - - self.list() - }, - - list: function(){ - var self = this, - q = self.q(), - cache = self.cache[q]; - - self.hideResults(false); - - if(!cache){ - self.mask.fade('in'); - - if(!self.spinner) - self.spinner = createSpinner(self.mask); - - self.api_request = Api.request('show.search', { - 'data': { - 'q': q - }, - 'onComplete': self.fill.bind(self, q) - }) - } - else - self.fill(q, cache) - - self.last_q = q; - - }, - - fill: function(q, json){ - var self = this; - - self.cache[q] = json - - self.shows = {} - self.results.empty() - - Object.each(json.shows, function(show){ - - var m = new Block.ShowSearch.Item(show); - $(m).inject(self.results) - self.shows[show.imdb || 'r-'+Math.floor(Math.random()*10000)] = m - - if(q == show.imdb) - m.showOptions() - - }); - - // Calculate result heights - var w = window.getSize(), - rc = self.result_container.getCoordinates(); - - self.results.setStyle('max-height', (w.y - rc.top - 50) + 'px') - self.mask.fade('out') - - }, - - loading: function(bool){ - this.el[bool ? 'addClass' : 'removeClass']('loading') - }, - - q: function(){ - return this.input.get('value').trim(); - } - -}); - -Block.ShowSearch.Item = new Class({ +Block.Search.ShowItem = new Class({ Implements: [Options, Events], diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index 26178fb7..77138a75 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -70,7 +70,6 @@ new Element('div').adopt( self.block.navigation = new Block.Navigation(self, {}), self.block.search = new Block.Search(self, {}), - self.block.search = new Block.ShowSearch(self, {}), self.block.more = new Block.Menu(self, {'button_class': 'icon2.cog'}) ) ),