some fixes for info view
This commit is contained in:
parent
a1abf5c606
commit
f1393d79e9
4 changed files with 44 additions and 29 deletions
|
@ -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:
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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,31 +377,37 @@ 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,
|
||||||
|
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({
|
pandora.api[icon == 'posters' ? 'setPoster' : 'setPosterFrame'](Ox.extend({
|
||||||
id: data.id
|
id: data.id
|
||||||
}, icon == 'posters' ? {
|
}, icon == 'posters' ? {
|
||||||
source: selectedImage.source
|
source: selectedImage.source
|
||||||
} : {
|
} : {
|
||||||
position: selectedImage.index // fixme: api slightly inconsistent
|
position: selectedImage.index // fixme: api slightly inconsistent
|
||||||
}), function(result) {
|
}), function() {
|
||||||
var imageRatio = selectedImage.width / selectedImage.height;
|
$browserImages.each(function() {
|
||||||
$('img[src*="/' + data.id + '/poster"]').each(function() {
|
$(this).attr({src: '/' + data.id + '/poster.64.jpg?' + Ox.uid()});
|
||||||
var $this = $(this),
|
|
||||||
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});
|
|
||||||
icon == 'posters' && $this.css(imageRatio < 1 ? {
|
|
||||||
width: Math.round(size * imageRatio) + 'px',
|
|
||||||
height: size + 'px'
|
|
||||||
} : {
|
|
||||||
width: size + 'px',
|
|
||||||
height: Math.round(size / imageRatio) + 'px'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -458,4 +468,4 @@ pandora.ui.infoView = function(data) {
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
||||||
}
|
}
|
|
@ -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(
|
||||||
|
|
Loading…
Reference in a new issue