forked from 0x2620/pandora
some fixes for info view
This commit is contained in:
parent
3e151a1a86
commit
1523a81007
4 changed files with 44 additions and 29 deletions
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 = $('<div>')
|
||||
.css({
|
||||
|
@ -35,7 +36,7 @@ pandora.ui.infoView = function(data) {
|
|||
.appendTo($info),
|
||||
$poster = Ox.Element('<img>')
|
||||
.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 = $('<img>')
|
||||
.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,22 +377,14 @@ pandora.ui.infoView = function(data) {
|
|||
selectedImage = images.filter(function(image) {
|
||||
return image.index == index;
|
||||
})[0];
|
||||
//renderPreview(selectedImage);
|
||||
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 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()),
|
||||
src = $this.attr('src').split('?')[0] + '?' + Ox.uid();
|
||||
$('<img>')
|
||||
.attr({src: src})
|
||||
.load(function() {
|
||||
size = Math.max($this.width(), $this.height());
|
||||
$this.attr({src: src});
|
||||
icon == 'posters' && $this.css(imageRatio < 1 ? {
|
||||
width: Math.round(size * imageRatio) + 'px',
|
||||
|
@ -398,6 +394,20 @@ pandora.ui.infoView = function(data) {
|
|||
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()});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue