Compare commits

..

No commits in common. "7fa2a8a33803ec632d1471933a5cf2c65291b5ba" and "ae211e0e95e295bd7ff3faa67709116dc1fc8023" have entirely different histories.

3 changed files with 38 additions and 144 deletions

View file

@ -37,7 +37,6 @@ pandora.ui.documentFilterForm = function(options) {
return item.id; return item.id;
}) })
}]), }]),
listName: Ox._('Collection'),
list: mode == 'find' ? { list: mode == 'find' ? {
sort: pandora.user.ui.collectionSort, sort: pandora.user.ui.collectionSort,
view: pandora.user.ui.collectionView view: pandora.user.ui.collectionView

View file

@ -12,9 +12,7 @@ pandora.ui.filterDialog = function() {
click: function() { click: function() {
var list = pandora.$ui.filterForm.getList(); var list = pandora.$ui.filterForm.getList();
if (list.save) { if (list.save) {
pandora.api[ pandora.api.addList({
pandora.user.ui.section == 'documents' ? 'addCollection' : 'addList'
]({
name: list.name, name: list.name,
query: list.query, query: list.query,
status: 'private', status: 'private',
@ -22,21 +20,12 @@ pandora.ui.filterDialog = function() {
}, function(result) { }, function(result) {
var $list = pandora.$ui.folderList.personal, var $list = pandora.$ui.folderList.personal,
id = result.data.id; id = result.data.id;
if (pandora.user.ui.section) {
pandora.UI.set({
findDocuments: {
conditions: [{key: 'collection', value: id, operator: '=='}],
operator: '&'
}
});
} else {
pandora.UI.set({ pandora.UI.set({
find: { find: {
conditions: [{key: 'list', value: id, operator: '=='}], conditions: [{key: 'list', value: id, operator: '=='}],
operator: '&' operator: '&'
} }
}); });
}
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
$list.bindEventOnce({ $list.bindEventOnce({
load: function(data) { load: function(data) {

View file

@ -919,130 +919,21 @@ pandora.ui.infoView = function(data, isMixed) {
}); });
} }
function renderFrames() {
pandora.api.get({
id: data.id,
keys: ['frames']
}, 0, function(result) {
var images = result.data.frames.map(function(image) {
return Ox.extend(image, {index: image.index.toString()});
}),
selectedImage = images.filter(function(image) {
return image.selected;
})[0],
modified = data.modified;
$list = Ox.IconList({
defaultRatio: !data.stream ? pandora.site.posters.ratio : data.stream.aspectratio,
fixedRatio: !data.stream ? false : data.stream.aspectratio,
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: 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() { function renderList() {
if (ui.icons == 'posters' && !ui.showSitePosters) {
renderPosters()
} else {
renderFrames()
}
}
function renderPosters() {
pandora.api.get({ pandora.api.get({
id: data.id, id: data.id,
keys: ['posters'] keys: [ui.icons == 'posters' ? 'posters' : 'frames']
}, 0, function(result) { }, 0, function(result) {
var images = result.data.posters.map(function(image) { var images = result.data[ui.icons == 'posters' ? 'posters' : '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) {
return image.selected; return image.selected;
})[0], })[0],
modified = data.modified; modified = data.modified;
if (images.length == 1) {
renderFrames()
return
}
$list = Ox.IconList({ $list = Ox.IconList({
defaultRatio: pandora.site.posters.ratio, defaultRatio: ui.icons == 'posters' || !data.stream ? pandora.site.posters.ratio : data.stream.aspectratio,
fixedRatio: false, fixedRatio: ui.icons == 'posters' || !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;
@ -1050,15 +941,17 @@ 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: data.source, title: ui.icons == 'posters' ? data.source : Ox.formatDuration(data.position),
url: data.url.replace('http://', '//') + ( url: data.url.replace('http://', '//') + (
data.source == pandora.site.site.url ? '?' + modified : '' ui.icons == 'posters' && data.source == pandora.site.site.url ? '?' + modified : ''
), ),
width: ratio >= 1 ? size : size * ratio width: ratio >= 1 ? size : size * ratio
} }
}, },
items: images, items: images,
keys: ['index', 'source', 'width', 'height', 'url'], keys: ui.icons == 'posters'
? ['index', 'source', 'width', 'height', 'url']
: ['index', 'position', 'width', 'height', 'url'],
max: 1, max: 1,
min: 1, min: 1,
orientation: 'both', orientation: 'both',
@ -1088,12 +981,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.showSitePosters) { if (ui.icons == 'posters' && !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});
$this.css(imageRatio < 1 ? { ui.icons == 'posters' && $this.css(imageRatio < 1 ? {
width: Math.round(size * imageRatio) + 'px', width: Math.round(size * imageRatio) + 'px',
height: size + 'px' height: size + 'px'
} : { } : {
@ -1107,17 +1000,31 @@ pandora.ui.infoView = function(data, isMixed) {
iconSize = iconSize == 256 ? 512 : 256; iconSize = iconSize == 256 ? 512 : 256;
toggleIconSize(); toggleIconSize();
} }
pandora.api.setPoster({ pandora.api[ui.icons == 'posters' ? 'setPoster' : 'setPosterFrame'](Ox.extend({
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({ $(this).attr({src: pandora.getMediaURL('/' + data.id + '/' + (
src: pandora.getMediaURL('/' + data.id + '/poster128.jpg?' + Ox.uid()) ui.icons == 'posters' ? 'poster' : 'icon'
}); ) + '128.jpg?' + Ox.uid())});
}); });
} }
if (ui.listSort[0].key == 'modified') { if (ui.listSort[0].key == 'modified') {
@ -1131,7 +1038,6 @@ pandora.ui.infoView = function(data, isMixed) {
}); });
} }
function renderRightsLevel() { function renderRightsLevel() {
var $rightsLevelElement = getRightsLevelElement(data.rightslevel), var $rightsLevelElement = getRightsLevelElement(data.rightslevel),
$rightsLevelSelect; $rightsLevelSelect;