forked from 0x2620/pandora
select frame in show site poster mode or if no other posters exist
This commit is contained in:
parent
ae211e0e95
commit
d3f2cf770f
1 changed files with 126 additions and 32 deletions
|
@ -919,12 +919,12 @@ pandora.ui.infoView = function(data, isMixed) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderList() {
|
function renderFrames() {
|
||||||
pandora.api.get({
|
pandora.api.get({
|
||||||
id: data.id,
|
id: data.id,
|
||||||
keys: [ui.icons == 'posters' ? 'posters' : 'frames']
|
keys: ['frames']
|
||||||
}, 0, function(result) {
|
}, 0, function(result) {
|
||||||
var images = result.data[ui.icons == 'posters' ? 'posters' : 'frames'].map(function(image) {
|
var images = result.data.frames.map(function(image) {
|
||||||
return Ox.extend(image, {index: image.index.toString()});
|
return Ox.extend(image, {index: image.index.toString()});
|
||||||
}),
|
}),
|
||||||
selectedImage = images.filter(function(image) {
|
selectedImage = images.filter(function(image) {
|
||||||
|
@ -932,8 +932,8 @@ pandora.ui.infoView = function(data, isMixed) {
|
||||||
})[0],
|
})[0],
|
||||||
modified = data.modified;
|
modified = data.modified;
|
||||||
$list = Ox.IconList({
|
$list = Ox.IconList({
|
||||||
defaultRatio: ui.icons == 'posters' || !data.stream ? pandora.site.posters.ratio : data.stream.aspectratio,
|
defaultRatio: !data.stream ? pandora.site.posters.ratio : data.stream.aspectratio,
|
||||||
fixedRatio: ui.icons == 'posters' || !data.stream ? false : data.stream.aspectratio,
|
fixedRatio: !data.stream ? false : data.stream.aspectratio,
|
||||||
item: function(data, sort, size) {
|
item: function(data, sort, size) {
|
||||||
var ratio = data.width / data.height;
|
var ratio = data.width / data.height;
|
||||||
size = size || 128;
|
size = size || 128;
|
||||||
|
@ -941,17 +941,124 @@ pandora.ui.infoView = function(data, isMixed) {
|
||||||
height: ratio <= 1 ? size : size / ratio,
|
height: ratio <= 1 ? size : size / ratio,
|
||||||
id: data.id,
|
id: data.id,
|
||||||
info: data.width + ' × ' + data.height + ' px',
|
info: data.width + ' × ' + data.height + ' px',
|
||||||
title: ui.icons == 'posters' ? data.source : Ox.formatDuration(data.position),
|
title: Ox.formatDuration(data.position),
|
||||||
|
url: data.url,
|
||||||
|
width: ratio >= 1 ? size : size * ratio
|
||||||
|
}
|
||||||
|
},
|
||||||
|
items: images,
|
||||||
|
keys: ['index', 'position', 'width', 'height', 'url'],
|
||||||
|
max: 1,
|
||||||
|
min: 1,
|
||||||
|
orientation: 'both',
|
||||||
|
// fixme: should never be undefined
|
||||||
|
selected: selectedImage ? [selectedImage['index']] : [],
|
||||||
|
size: 128,
|
||||||
|
sort: [{key: 'index', operator: '+'}],
|
||||||
|
unique: 'index'
|
||||||
|
})
|
||||||
|
.addClass('OxMedia')
|
||||||
|
.css({
|
||||||
|
display: 'block',
|
||||||
|
position: 'absolute',
|
||||||
|
left: 0,
|
||||||
|
top: 0,
|
||||||
|
width: listWidth + 'px',
|
||||||
|
height: getHeight() + '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 + '/"]');
|
||||||
|
}
|
||||||
|
pandora.api.setPosterFrame({
|
||||||
|
id: data.id,
|
||||||
|
// fixme: api slightly inconsistent, this shouldn't be "position"
|
||||||
|
position: selectedImage.index
|
||||||
|
}, function() {
|
||||||
|
var src;
|
||||||
|
Ox.Request.clearCache();
|
||||||
|
if (ui.icons == 'frames') {
|
||||||
|
src = pandora.getMediaURL('/' + data.id + '/icon512.jpg?' + Ox.uid());
|
||||||
|
$icon.attr({src: src});
|
||||||
|
$reflectionIcon.attr({src: src});
|
||||||
|
if (pandora.$ui.videoPreview) {
|
||||||
|
pandora.$ui.videoPreview.options({
|
||||||
|
position: $list.value(selectedImage.index, 'position')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (ui.icons == 'posters' && ui.showSitePosters) {
|
||||||
|
src = pandora.getMediaURL('/' + data.id + '/siteposter512.jpg?' + Ox.uid());
|
||||||
|
$icon.attr({src: src});
|
||||||
|
$reflectionIcon.attr({src: src});
|
||||||
|
}
|
||||||
|
$browserImages.each(function() {
|
||||||
|
$(this).attr({src: pandora.getMediaURL('/' + data.id + '/' + (
|
||||||
|
ui.icons == 'posters'
|
||||||
|
? ui.showSitePosters ? 'siteposter' : 'poster'
|
||||||
|
: 'icon'
|
||||||
|
) + '128.jpg?' + Ox.uid())});
|
||||||
|
});
|
||||||
|
if (ui.listSort[0].key == 'modified') {
|
||||||
|
pandora.$ui.browser.reloadList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.appendTo($info);
|
||||||
|
$list.size();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderList() {
|
||||||
|
if (ui.icons == 'posters' && !ui.showSitePosters) {
|
||||||
|
renderPosters()
|
||||||
|
} else {
|
||||||
|
renderFrames()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPosters() {
|
||||||
|
pandora.api.get({
|
||||||
|
id: data.id,
|
||||||
|
keys: ['posters']
|
||||||
|
}, 0, function(result) {
|
||||||
|
var images = result.data.posters.map(function(image) {
|
||||||
|
return Ox.extend(image, {index: image.index.toString()});
|
||||||
|
}),
|
||||||
|
selectedImage = images.filter(function(image) {
|
||||||
|
return image.selected;
|
||||||
|
})[0],
|
||||||
|
modified = data.modified;
|
||||||
|
if (images.length == 1) {
|
||||||
|
renderFrames()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$list = Ox.IconList({
|
||||||
|
defaultRatio: pandora.site.posters.ratio,
|
||||||
|
fixedRatio: false,
|
||||||
|
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 + ' × ' + data.height + ' px',
|
||||||
|
title: data.source,
|
||||||
url: data.url.replace('http://', '//') + (
|
url: data.url.replace('http://', '//') + (
|
||||||
ui.icons == 'posters' && data.source == pandora.site.site.url ? '?' + modified : ''
|
data.source == pandora.site.site.url ? '?' + modified : ''
|
||||||
),
|
),
|
||||||
width: ratio >= 1 ? size : size * ratio
|
width: ratio >= 1 ? size : size * ratio
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
items: images,
|
items: images,
|
||||||
keys: ui.icons == 'posters'
|
keys: ['index', 'source', 'width', 'height', 'url'],
|
||||||
? ['index', 'source', 'width', 'height', 'url']
|
|
||||||
: ['index', 'position', 'width', 'height', 'url'],
|
|
||||||
max: 1,
|
max: 1,
|
||||||
min: 1,
|
min: 1,
|
||||||
orientation: 'both',
|
orientation: 'both',
|
||||||
|
@ -981,12 +1088,12 @@ pandora.ui.infoView = function(data, isMixed) {
|
||||||
if ($browserImages.length == 0) {
|
if ($browserImages.length == 0) {
|
||||||
$browserImages = pandora.$ui.browser.find('img[src*="/' + data.id + '/"]');
|
$browserImages = pandora.$ui.browser.find('img[src*="/' + data.id + '/"]');
|
||||||
}
|
}
|
||||||
if (ui.icons == 'posters' && !ui.showSitePosters) {
|
if (!ui.showSitePosters) {
|
||||||
$browserImages.each(function() {
|
$browserImages.each(function() {
|
||||||
var $this = $(this),
|
var $this = $(this),
|
||||||
size = Math.max($this.width(), $this.height());
|
size = Math.max($this.width(), $this.height());
|
||||||
$this.attr({src: src});
|
$this.attr({src: src});
|
||||||
ui.icons == 'posters' && $this.css(imageRatio < 1 ? {
|
$this.css(imageRatio < 1 ? {
|
||||||
width: Math.round(size * imageRatio) + 'px',
|
width: Math.round(size * imageRatio) + 'px',
|
||||||
height: size + 'px'
|
height: size + 'px'
|
||||||
} : {
|
} : {
|
||||||
|
@ -1000,31 +1107,17 @@ pandora.ui.infoView = function(data, isMixed) {
|
||||||
iconSize = iconSize == 256 ? 512 : 256;
|
iconSize = iconSize == 256 ? 512 : 256;
|
||||||
toggleIconSize();
|
toggleIconSize();
|
||||||
}
|
}
|
||||||
pandora.api[ui.icons == 'posters' ? 'setPoster' : 'setPosterFrame'](Ox.extend({
|
pandora.api.setPoster({
|
||||||
id: data.id
|
id: data.id,
|
||||||
}, ui.icons == 'posters' ? {
|
|
||||||
source: selectedImage.source
|
source: selectedImage.source
|
||||||
} : {
|
}, function() {
|
||||||
// fixme: api slightly inconsistent, this shouldn't be "position"
|
|
||||||
position: selectedImage.index
|
|
||||||
}), function() {
|
|
||||||
var src;
|
var src;
|
||||||
Ox.Request.clearCache();
|
Ox.Request.clearCache();
|
||||||
if (ui.icons == 'frames') {
|
|
||||||
src = pandora.getMediaURL('/' + data.id + '/icon512.jpg?' + Ox.uid());
|
|
||||||
$icon.attr({src: src});
|
|
||||||
$reflectionIcon.attr({src: src});
|
|
||||||
if (pandora.$ui.videoPreview) {
|
|
||||||
pandora.$ui.videoPreview.options({
|
|
||||||
position: $list.value(selectedImage.index, 'position')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!ui.showSitePosters) {
|
if (!ui.showSitePosters) {
|
||||||
$browserImages.each(function() {
|
$browserImages.each(function() {
|
||||||
$(this).attr({src: pandora.getMediaURL('/' + data.id + '/' + (
|
$(this).attr({
|
||||||
ui.icons == 'posters' ? 'poster' : 'icon'
|
src: pandora.getMediaURL('/' + data.id + '/poster128.jpg?' + Ox.uid())
|
||||||
) + '128.jpg?' + Ox.uid())});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ui.listSort[0].key == 'modified') {
|
if (ui.listSort[0].key == 'modified') {
|
||||||
|
@ -1038,6 +1131,7 @@ pandora.ui.infoView = function(data, isMixed) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function renderRightsLevel() {
|
function renderRightsLevel() {
|
||||||
var $rightsLevelElement = getRightsLevelElement(data.rightslevel),
|
var $rightsLevelElement = getRightsLevelElement(data.rightslevel),
|
||||||
$rightsLevelSelect;
|
$rightsLevelSelect;
|
||||||
|
|
Loading…
Reference in a new issue