From 881ce6513d934d9ac3369d2b6b6f971a5c642631 Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 7 Aug 2011 20:25:33 +0000 Subject: [PATCH] allow for switching list icons --- pandora/scripts/item_icon | 2 -- static/js/pandora/ui/browser.js | 11 +++++++---- static/js/pandora/ui/list.js | 2 +- static/js/pandora/ui/menu.js | 17 ++++++++++------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/pandora/scripts/item_icon b/pandora/scripts/item_icon index 16267c1c..f01a07de 100755 --- a/pandora/scripts/item_icon +++ b/pandora/scripts/item_icon @@ -11,9 +11,7 @@ activate_this = os.path.join(root_dir, 'bin', 'activate_this.py') execfile(activate_this, dict(__file__=activate_this)) import Image -import ImageDraw from optparse import OptionParser -from ox.image import drawText, wrapText import sys diff --git a/static/js/pandora/ui/browser.js b/static/js/pandora/ui/browser.js index 8573316d..3066df95 100644 --- a/static/js/pandora/ui/browser.js +++ b/static/js/pandora/ui/browser.js @@ -38,17 +38,20 @@ pandora.ui.browser = function() { } else { var that = Ox.IconList({ centered: true, - defaultRatio: 5/8, + defaultRatio: pandora.user.ui.icons == 'posters' ? 5/8 : 1, id: 'list', item: function(data, sort, size) { - var ratio = data.poster.width / data.poster.height; + var icons = pandora.user.ui.icons, + ratio = icons == 'posters' ? data.poster.width / data.poster.height : 1; size = size || 64; return { height: ratio <= 1 ? size : size / ratio, - id: data['id'], + id: data.id, info: data[['title', 'director'].indexOf(sort[0].key) > -1 ? 'year' : sort[0].key], title: data.title + (data.director ? ' (' + data.director + ')' : ''), - url: '/' + data['id'] + '/poster' + size + '.jpg', + url: icons == 'posters' + ? '/' + data.id + '/poster' + size + '.jpg' + : '/' + data.id + '/icon' + size + '.jpg', width: ratio >= 1 ? size : size * ratio }; }, diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 789fea7f..ef1b6747 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -72,7 +72,7 @@ pandora.ui.list = function(view) { // fixme: remove view argument }); } else if (view == 'icons') { that = Ox.IconList({ - defaultRatio: 5/8, + defaultRatio: pandora.user.ui.icons == 'posters' ? 5/8 : 1, id: 'list', item: function(data, sort, size) { var icons = pandora.user.ui.icons, diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js index 47352d94..5f514dec 100644 --- a/static/js/pandora/ui/menu.js +++ b/static/js/pandora/ui/menu.js @@ -183,13 +183,16 @@ pandora.ui.mainMenu = function() { pandora.$ui.list.sortList(value, operator); pandora.URL.set(pandora.Query.toString()); } else if (data.id == 'viewicons') { - pandora.UI.set({icons: value}) - var $list = !pandora.user.ui.item ? pandora.$ui.list : pandora.$ui.browser; - /* - list.options({ - item: - }); - */ + var $list; + pandora.UI.set({icons: value}); + if (pandora.user.ui.item) { + $list = pandora.$ui.browser; + } else if (pandora.user.ui.lists[pandora.user.ui.list].listView == 'icons') { + $list = pandora.$ui.list + } + $list && $list.options({ + defaultRatio: value == 'posters' ? 5/8 : 1 + }).reloadList(); } else if (data.id == 'viewmovies') { url('#view=' + value); }