From 6cd378c78c6144c42e705215e4261a79a474b499 Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 7 Aug 2011 02:43:33 +0000 Subject: [PATCH] simplify size calculation when using fixed ratio --- static/js/pandora/ui/list.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 48fdba8f..789fea7f 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -111,19 +111,15 @@ pandora.ui.list = function(view) { // fixme: remove view argument } else if (view == 'calendars') { that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.'); } else if (view == 'clip') { + var fixedRatio = 16/9; that = Ox.IconList({ - fixedRatio: 4/3, + fixedRatio: fixedRatio, item: function(data, sort, size) { size = size || 128; var ratio = data.aspectRatio, - width = ratio > 1 ? size : Math.round(size * ratio), - height = ratio > 1 ? Math.round(size / ratio) : size, + width = ratio > fixedRatio ? size : Math.round(size * ratio / fixedRatio), + height = Math.round(width / ratio), url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg'; - // fixme: ugly - if (height > 96) { - width = Math.round(width * 96 / height); - height = 96; - } return { height: height, id: data['id'],