poster preview, use posters from instance
This commit is contained in:
parent
afa4e9c584
commit
4b09b8fd98
3 changed files with 18 additions and 21 deletions
|
@ -148,7 +148,9 @@ class Movie(models.Model):
|
|||
if self.poster:
|
||||
self.poster_height = self.poster.height
|
||||
self.poster_width = self.poster.width
|
||||
|
||||
else:
|
||||
self.poster_height = 128
|
||||
self.poster_width = 80
|
||||
super(Movie, self).save(*args, **kwargs)
|
||||
self.updateFind()
|
||||
self.updateSort()
|
||||
|
|
|
@ -9,6 +9,7 @@ urlpatterns = patterns("backend.views",
|
|||
(r'^(?P<id>.*)/(?P<profile>.*.webm)$', 'video'),
|
||||
(r'^(?P<id>.*)/(?P<profile>.*.mp4)$', 'video'),
|
||||
(r'^(?P<id>.*)/poster\.(?P<size>\d+)\.jpg$', 'poster'),
|
||||
(r'^(?P<id>.*)/poster\.(?P<size>large)\.jpg$', 'poster'),
|
||||
(r'^(?P<id>.*)/poster\.jpg$', 'poster'),
|
||||
(r'^(?P<id>.*)/timelines/(?P<timeline>.+)\.(?P<size>\d+)\.(?P<position>\d+)\.png$', 'timeline'),
|
||||
(r'^(?P<id>.*)/data/(?P<data>.+)\.json$', 'data'),
|
||||
|
|
|
@ -516,13 +516,20 @@ app.constructList = function(view) {
|
|||
id: 'list',
|
||||
item: function(data, sort, size) {
|
||||
size = size || 128;
|
||||
if(data.poster.height>data.poster.width) {
|
||||
var height = size,
|
||||
width = height * data.poster.width / data.poster.height;
|
||||
} else {
|
||||
var width = size,
|
||||
height = width * data.poster.height / data.poster.width;
|
||||
}
|
||||
return {
|
||||
height: data.poster.height || 128, // fixme: remove later
|
||||
height: height,
|
||||
id: data['id'],
|
||||
info: data[['title', 'director'].indexOf(sort[0].key) > -1 ? 'year' : sort[0].key],
|
||||
title: data.title + (data.director ? ' (' + data.director + ')' : ''),
|
||||
url: data.poster.url.replace(/jpg$/, size + '.jpg'),
|
||||
width: data.poster.width || 80 // fixme: remove later
|
||||
width: width
|
||||
};
|
||||
},
|
||||
keys: keys,
|
||||
|
@ -559,7 +566,7 @@ app.constructList = function(view) {
|
|||
},
|
||||
openpreview: function(event, data) {
|
||||
app.request('find', {
|
||||
keys: ['director', 'id', 'posterHeight', 'posterWidth', 'posterURL', 'title'],
|
||||
keys: ['director', 'id', 'poster', 'title'],
|
||||
query: {
|
||||
conditions: $.map(data.ids, function(id, i) {
|
||||
return {
|
||||
|
@ -575,27 +582,14 @@ app.constructList = function(view) {
|
|||
title = item.title + (item.director ? ' (' + item.director + ')' : ''),
|
||||
documentHeight = app.$document.height(),
|
||||
dialogHeight = documentHeight - 40,
|
||||
dialogWidth = parseInt((dialogHeight - 48) * 0.75),
|
||||
dialogWidth = parseInt((dialogHeight - 48) * item.poster.width/item.poster.height),
|
||||
$image = $('<img>')
|
||||
.attr({
|
||||
src: 'http://0xdb.org/' + item.id + '/poster.large.jpg'
|
||||
src: item.poster.url.replace(/jpg/, 'large.jpg')
|
||||
})
|
||||
.css({
|
||||
height: (dialogHeight - 48) + 'px',
|
||||
width: dialogWidth + 'px'
|
||||
})
|
||||
.load(function() {
|
||||
var image = $image[0],
|
||||
imageHeight = Math.min(image.height, documentHeight - 88),
|
||||
imageWidth = parseInt(image.width * imageHeight / image.height);
|
||||
app.$ui.previewDialog.options({
|
||||
height: imageHeight + 48,
|
||||
width: imageWidth
|
||||
});
|
||||
$image.css({
|
||||
height: imageHeight + 'px',
|
||||
width: imageWidth + 'px'
|
||||
});
|
||||
height: (dialogHeight - 48 -3) + 'px',
|
||||
width: (dialogWidth - 3*item.poster.width/item.poster.height) + 'px'
|
||||
});
|
||||
if ('previewDialog' in app.$ui) {
|
||||
app.$ui.previewDialog.options({
|
||||
|
|
Loading…
Reference in a new issue