/info#embed: support resize

This commit is contained in:
rolux 2014-01-22 13:57:38 +00:00
parent f6ee282606
commit 128eea602b

View file

@ -2,11 +2,19 @@
pandora.ui.embedInfo = function() {
var item = pandora.user.ui.item,
data,
that = Ox.Element();
var data,
item = pandora.user.ui.item,
poster = {
size: 256
},
textCSS = {
marginTop: '8px',
fontWeight: 'bold',
fontSize: '13px',
textAlign: 'center'
},
that = Ox.Element(),
$icon, $reflection, $text;
pandora.api.get({
id: item,
@ -15,73 +23,64 @@ pandora.ui.embedInfo = function() {
data = result.data;
var posterSize = 256,
posterWidth = Math.round(
poster.width = Math.round(
data.posterRatio > 1
? posterSize
: posterSize * data.posterRatio
),
posterHeight = Math.round(
? poster.size
: poster.size * data.posterRatio
);
poster.height = Math.round(
data.posterRatio > 1
? posterSize / data.posterRatio
: posterSize
),
posterLeft = Math.floor(
(window.innerWidth - posterWidth) / 2
),
textCSS = {
marginTop: '8px',
fontWeight: 'bold',
fontSize: '13px',
textAlign: 'center'
},
? poster.size / data.posterRatio
: poster.size
);
poster.left = Math.floor((window.innerWidth - poster.width) / 2);
$icon = Ox.$('<img>')
.attr({src: '/' + item + '/poster256.jpg'})
.css({
position: 'absolute',
left: posterLeft + 'px',
left: poster.left + 'px',
top: '8px',
width: posterWidth + 'px',
height: posterHeight + 'px',
width: poster.width + 'px',
height: poster.height + 'px',
cursor: 'pointer'
})
.appendTo(that),
.appendTo(that);
$reflection = Ox.$('<div>')
.addClass('OxReflection')
.css({
position: 'absolute',
left: posterLeft + 'px',
top: posterHeight + 8 + 'px',
left: poster.left + 'px',
top: poster.height + 8 + 'px',
width: '256px',
height: '128px',
overflow: 'hidden'
})
.appendTo(that),
.appendTo(that);
$reflectionIcon = Ox.$('<img>')
Ox.$('<img>')
.attr({src: '/' + item + '/poster256.jpg'})
.css({
position: 'absolute',
width: posterWidth + 'px',
height: posterHeight + 'px'
width: poster.width + 'px',
height: poster.height + 'px'
})
.appendTo($reflection),
.appendTo($reflection);
$reflectionGradient = Ox.$('<div>')
Ox.$('<div>')
.css({
position: 'absolute',
width: '256px',
height: '128px'
})
.appendTo($reflection),
.appendTo($reflection);
$text = Ox.$('<div>')
.css({
position: 'absolute',
left: '8px',
top: 8 + 8 + posterHeight + 'px',
top: 8 + 8 + poster.height + 'px',
right: '8px'
})
.appendTo(that);
@ -100,6 +99,12 @@ pandora.ui.embedInfo = function() {
});
that.resizePanel = function() {
poster.left = Math.floor((window.innerWidth - poster.width) / 2);
$icon.css({left: poster.left + 'px'});
$reflection.css({left: poster.left + 'px'});
};
return that;
};