')
.css(css)
.html(
formatKey(key) + data[key].map(function(value) {
return '
'
}).join(', ')
)
.appendTo($text);
});
$('
').css({height: '8px'}).appendTo($text);
if (pandora.user.level == 'admin') {
var icon = 'posters',
selectedImage = {};
$poster.bindEvent({
doubleclick: function() {
if (!editPoster) {
$info.animate({
left: 0
}, 250);
editPoster = true;
} else {
$info.animate({
left: -listWidth + 'px'
}, 250);
editPoster = false;
}
}
});
pandora.api.get({
id: data.id,
keys: [icon]
}, 0, function(result) {
Ox.print('RESULT', result.data)
var images = result.data[icon];
selectedImage = images.filter(function(image) {
return image.selected;
})[0];
$list = Ox.IconList({
defaultRatio: 5/8,
item: function(data, sort, size) {
var ratio = data.width / data.height;
size = size || 128;
return {
height: ratio <= 1 ? size : size / ratio,
id: data['id'],
info: data.width + ' x ' + data.height + ' px',
title: icon == 'posters' ? data.source : Ox.formatDuration(data.position),
url: data.url,
width: ratio >= 1 ? size : size * ratio
}
},
items: images,
keys: icon == 'posters'
? ['index', 'source', 'width', 'height', 'url']
: ['index', 'position', 'width', 'height', 'url'],
max: 1,
min: 1,
orientation: 'vertical',
selected: [selectedImage['index']],
size: 128,
sort: [{key: 'index', operator: '+'}],
unique: 'index'
})
.css({
display: 'block',
position: 'absolute',
left: 0,
top: 0,
width: listWidth + 'px',
height: pandora.$ui.contentPanel.size(1) + 'px'
})
.bindEvent({
select: function(event) {
var index = event.ids[0];
selectedImage = images.filter(function(image) {
return image.index == index;
})[0];
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() {
$browserImages.each(function() {
$(this).attr({src: '/' + data.id + '/poster.64.jpg?' + Ox.uid()});
});
});
}
})
.appendTo($info);
});
}
function formatKey(key) {
return '
' + Ox.toTitleCase(key) + ': ';
}
function formatLight(str) {
return '
' + str + '';
}
function formatValue(value, key) {
return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ? '
' + value + '' : value;
}).join(', ');
}
function togglePosterSize() {
posterSize = posterSize == 256 ? 512 : 256;
posterWidth = posterRatio > 1 ? posterSize : Math.round(posterSize * posterRatio);
posterHeight = posterRatio < 1 ? posterSize : Math.round(posterSize / posterRatio);
posterLeft = posterSize == 256 ? Math.floor((posterSize - posterWidth) / 2) : 0,
$poster.animate({
left: margin + posterLeft + 'px',
width: posterWidth + 'px',
height: posterHeight + 'px'
}, 250);
$reflection.animate({
top: margin + posterHeight + 'px',
width: posterSize + 'px',
height: posterSize / 2 + 'px'
}, 250);
$reflectionPoster.animate({
left: posterLeft + 'px',
width: posterWidth + 'px',
height: posterHeight + 'px',
}, 250);
$reflectionGradient.animate({
width: posterSize + 'px',
height: posterSize / 2 + 'px'
}, 250);
$text.animate({
left: margin + (posterSize == 256 ? 256 : posterWidth) + margin + 'px',
}, 250);
pandora.api.setUI({infoIconSize: pandora.user.ui.infoIconSize = posterSize});
}
that.resize = function() {
var height = pandora.$ui.contentPanel.size(1);
$list && $list.css({height: height + 'px'});
$data.css({height: height + 'px'});
};
return that;
}