some fixes for info view

This commit is contained in:
rolux 2011-08-06 13:34:56 +00:00
parent 3e151a1a86
commit 1523a81007
4 changed files with 44 additions and 29 deletions

View file

@ -444,6 +444,8 @@ class Item(models.Model):
if not keys or 'poster' in keys: if not keys or 'poster' in keys:
i['poster'] = self.get_poster() i['poster'] = self.get_poster()
#only needed by admins
if keys and 'posters' in keys: if keys and 'posters' in keys:
i['posters'] = self.get_posters() i['posters'] = self.get_posters()
if keys and 'frames' in keys: if keys and 'frames' in keys:

View file

@ -339,9 +339,9 @@ def get(request):
item = get_object_or_404_json(models.Item, itemId=data['id']) item = get_object_or_404_json(models.Item, itemId=data['id'])
if item.access(request.user): if item.access(request.user):
info = item.get_json(data['keys']) 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() 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) info['layers'] = item.get_layers(request.user)
response['data'] = info response['data'] = info
else: else:

View file

@ -15,6 +15,7 @@ pandora.ui.infoView = function(data) {
posterLeft = posterSize == 256 ? Math.floor((posterSize - posterWidth) / 2) : 0, posterLeft = posterSize == 256 ? Math.floor((posterSize - posterWidth) / 2) : 0,
editPoster = false, editPoster = false,
that = Ox.Element(), that = Ox.Element(),
uid = Ox.uid(),
$list, $list,
$info = $('<div>') $info = $('<div>')
.css({ .css({
@ -35,7 +36,7 @@ pandora.ui.infoView = function(data) {
.appendTo($info), .appendTo($info),
$poster = Ox.Element('<img>') $poster = Ox.Element('<img>')
.attr({ .attr({
src: '/' + data.id + '/poster.jpg' src: '/' + data.id + '/poster.jpg?' + uid
}) })
.css({ .css({
position: 'absolute', position: 'absolute',
@ -62,7 +63,7 @@ pandora.ui.infoView = function(data) {
.appendTo($data.$element), .appendTo($data.$element),
$reflectionPoster = $('<img>') $reflectionPoster = $('<img>')
.attr({ .attr({
src: '/' + data.id + '/poster.jpg' src: '/' + data.id + '/poster.jpg?' + uid
}) })
.css({ .css({
position: 'absolute', position: 'absolute',
@ -90,7 +91,8 @@ pandora.ui.infoView = function(data) {
top: margin + 'px', top: margin + 'px',
right: margin + 'px' right: margin + 'px'
}) })
.appendTo($data.$element); .appendTo($data.$element),
$browserImages = [];
var match = /(\(S\d{2}(E\d{2})?\))/.exec(data.title); var match = /(\(S\d{2}(E\d{2})?\))/.exec(data.title);
if (match) { if (match) {
@ -106,8 +108,10 @@ pandora.ui.infoView = function(data) {
WebkitUserSelect: 'text' WebkitUserSelect: 'text'
}) })
.html( .html(
data.title + (data.original_title ? ' ' data.title + (
+ formatLight('(' + data.original_title + ')') : '') data.original_title && data.original_title != data.title
? ' ' + formatLight('(' + data.original_title + ')') : ''
)
) )
.appendTo($text); .appendTo($text);
@ -327,7 +331,7 @@ pandora.ui.infoView = function(data) {
pandora.api.get({ pandora.api.get({
id: data.id, id: data.id,
keys: [icon] keys: [icon]
}, function(result) { }, 0, function(result) {
Ox.print('RESULT', result.data) Ox.print('RESULT', result.data)
var images = result.data[icon]; var images = result.data[icon];
selectedImage = images.filter(function(image) { selectedImage = images.filter(function(image) {
@ -373,22 +377,14 @@ pandora.ui.infoView = function(data) {
selectedImage = images.filter(function(image) { selectedImage = images.filter(function(image) {
return image.index == index; return image.index == index;
})[0]; })[0];
//renderPreview(selectedImage); var imageRatio = selectedImage.width / selectedImage.height,
pandora.api[icon == 'posters' ? 'setPoster' : 'setPosterFrame'](Ox.extend({ src = selectedImage.url;
id: data.id if ($browserImages.length == 0) {
}, icon == 'posters' ? { $browserImages = pandora.$ui.browser.find('img[src*="/' + data.id + '/poster"]');
source: selectedImage.source }
} : { $browserImages.each(function() {
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), var $this = $(this),
size = Math.max($this.width(), $this.height()), size = Math.max($this.width(), $this.height());
src = $this.attr('src').split('?')[0] + '?' + Ox.uid();
$('<img>')
.attr({src: src})
.load(function() {
$this.attr({src: src}); $this.attr({src: src});
icon == 'posters' && $this.css(imageRatio < 1 ? { icon == 'posters' && $this.css(imageRatio < 1 ? {
width: Math.round(size * imageRatio) + 'px', width: Math.round(size * imageRatio) + 'px',
@ -398,6 +394,20 @@ pandora.ui.infoView = function(data) {
height: Math.round(size / imageRatio) + '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() {
$browserImages.each(function() {
$(this).attr({src: '/' + data.id + '/poster.64.jpg?' + Ox.uid()});
}); });
}); });
} }

View file

@ -1,7 +1,10 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.item = function() { pandora.ui.item = function() {
var that = Ox.Element(); 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) { if (result.status.code != 200) {
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.contentPanel.replaceElement(1,
Ox.Element().html( Ox.Element().html(