diff --git a/pandora/item/models.py b/pandora/item/models.py index 2dd8450b..e32d1882 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -444,6 +444,8 @@ class Item(models.Model): if not keys or 'poster' in keys: i['poster'] = self.get_poster() + + #only needed by admins if keys and 'posters' in keys: i['posters'] = self.get_posters() if keys and 'frames' in keys: diff --git a/pandora/item/views.py b/pandora/item/views.py index 2751249b..bbe25343 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -339,9 +339,9 @@ def get(request): item = get_object_or_404_json(models.Item, itemId=data['id']) if item.access(request.user): info = item.get_json(data['keys']) - if 'stream' in data['keys']: + if not data['keys'] or 'stream' in data['keys']: info['stream'] = item.get_stream() - if 'layers' in data['keys']: + if not data['keys'] or 'layers' in data['keys']: info['layers'] = item.get_layers(request.user) response['data'] = info else: diff --git a/static/js/pandora/ui/infoView.js b/static/js/pandora/ui/infoView.js index c3703928..332f9dec 100644 --- a/static/js/pandora/ui/infoView.js +++ b/static/js/pandora/ui/infoView.js @@ -15,6 +15,7 @@ pandora.ui.infoView = function(data) { posterLeft = posterSize == 256 ? Math.floor((posterSize - posterWidth) / 2) : 0, editPoster = false, that = Ox.Element(), + uid = Ox.uid(), $list, $info = $('
') .css({ @@ -35,7 +36,7 @@ pandora.ui.infoView = function(data) { .appendTo($info), $poster = Ox.Element('') .attr({ - src: '/' + data.id + '/poster.jpg' + src: '/' + data.id + '/poster.jpg?' + uid }) .css({ position: 'absolute', @@ -62,7 +63,7 @@ pandora.ui.infoView = function(data) { .appendTo($data.$element), $reflectionPoster = $('') .attr({ - src: '/' + data.id + '/poster.jpg' + src: '/' + data.id + '/poster.jpg?' + uid }) .css({ position: 'absolute', @@ -90,7 +91,8 @@ pandora.ui.infoView = function(data) { top: margin + 'px', right: margin + 'px' }) - .appendTo($data.$element); + .appendTo($data.$element), + $browserImages = []; var match = /(\(S\d{2}(E\d{2})?\))/.exec(data.title); if (match) { @@ -106,8 +108,10 @@ pandora.ui.infoView = function(data) { WebkitUserSelect: 'text' }) .html( - data.title + (data.original_title ? ' ' - + formatLight('(' + data.original_title + ')') : '') + data.title + ( + data.original_title && data.original_title != data.title + ? ' ' + formatLight('(' + data.original_title + ')') : '' + ) ) .appendTo($text); @@ -327,7 +331,7 @@ pandora.ui.infoView = function(data) { pandora.api.get({ id: data.id, keys: [icon] - }, function(result) { + }, 0, function(result) { Ox.print('RESULT', result.data) var images = result.data[icon]; selectedImage = images.filter(function(image) { @@ -373,31 +377,37 @@ pandora.ui.infoView = function(data) { selectedImage = images.filter(function(image) { return image.index == index; })[0]; - //renderPreview(selectedImage); + var imageRatio = selectedImage.width / selectedImage.height, + src = selectedImage.url; + if ($browserImages.length == 0) { + $browserImages = pandora.$ui.browser.find('img[src*="/' + data.id + '/poster"]'); + } + $browserImages.each(function() { + var $this = $(this), + size = Math.max($this.width(), $this.height()); + $this.attr({src: src}); + icon == 'posters' && $this.css(imageRatio < 1 ? { + width: Math.round(size * imageRatio) + 'px', + height: size + 'px' + } : { + width: size + 'px', + height: Math.round(size / imageRatio) + 'px' + }); + }); + $poster.attr({src: src}); + $reflectionPoster.attr({src: src}); + posterRatio = imageRatio; + posterSize = posterSize == 256 ? 512 : 256; + togglePosterSize(); pandora.api[icon == 'posters' ? 'setPoster' : 'setPosterFrame'](Ox.extend({ id: data.id }, icon == 'posters' ? { source: selectedImage.source } : { position: selectedImage.index // fixme: api slightly inconsistent - }), function(result) { - var imageRatio = selectedImage.width / selectedImage.height; - $('img[src*="/' + data.id + '/poster"]').each(function() { - var $this = $(this), - size = Math.max($this.width(), $this.height()), - src = $this.attr('src').split('?')[0] + '?' + Ox.uid(); - $('') - .attr({src: src}) - .load(function() { - $this.attr({src: src}); - icon == 'posters' && $this.css(imageRatio < 1 ? { - width: Math.round(size * imageRatio) + 'px', - height: size + 'px' - } : { - width: size + 'px', - height: Math.round(size / imageRatio) + 'px' - }); - }); + }), function() { + $browserImages.each(function() { + $(this).attr({src: '/' + data.id + '/poster.64.jpg?' + Ox.uid()}); }); }); } @@ -458,4 +468,4 @@ pandora.ui.infoView = function(data) { return that; -} +} \ No newline at end of file diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index 810d87ba..0932b610 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -1,7 +1,10 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript pandora.ui.item = function() { var that = Ox.Element(); - pandora.api.getItem(pandora.user.ui.item, function(result) { + pandora.api.get({ + id: pandora.user.ui.item, + keys: [] + }, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) { if (result.status.code != 200) { pandora.$ui.contentPanel.replaceElement(1, Ox.Element().html(