2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-09-18 21:17:32 +00:00
|
|
|
pandora.ui.infoView = function(data, isMixed) {
|
|
|
|
isMixed = isMixed || {};
|
2011-08-05 18:26:27 +00:00
|
|
|
|
2011-10-02 15:37:58 +00:00
|
|
|
var ui = pandora.user.ui,
|
2012-04-20 10:36:42 +00:00
|
|
|
descriptions = [],
|
2018-09-18 21:17:32 +00:00
|
|
|
isMultiple = arguments.length == 2,
|
|
|
|
canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable,
|
2017-11-04 09:53:27 +00:00
|
|
|
canRemove = pandora.hasCapability('canRemoveItems'),
|
2011-10-02 15:37:58 +00:00
|
|
|
css = {
|
2011-08-06 03:19:14 +00:00
|
|
|
marginTop: '4px',
|
2013-07-19 09:34:01 +00:00
|
|
|
textAlign: 'justify'
|
2011-08-06 03:19:14 +00:00
|
|
|
},
|
2012-04-20 10:36:42 +00:00
|
|
|
html,
|
|
|
|
iconRatio = ui.icons == 'posters' ? data.posterRatio : 1,
|
2018-09-18 21:17:32 +00:00
|
|
|
iconSize = isMultiple ? 0 : ui.infoIconSize,
|
|
|
|
iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio),
|
2011-08-07 22:15:08 +00:00
|
|
|
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
|
2018-09-18 21:17:32 +00:00
|
|
|
iconLeft = isMultiple ? 0 : iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
|
2011-11-10 08:54:01 +00:00
|
|
|
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
|
2011-10-02 15:37:58 +00:00
|
|
|
margin = 16,
|
2015-10-20 17:13:38 +00:00
|
|
|
nameKeys = pandora.site.itemKeys.filter(function(key) {
|
|
|
|
return key.sortType == 'person';
|
|
|
|
}).map(function(key) {
|
|
|
|
return key.id;
|
|
|
|
}),
|
|
|
|
listKeys = pandora.site.itemKeys.filter(function(key) {
|
|
|
|
return Ox.isArray(key.type);
|
|
|
|
}).map(function(key){
|
|
|
|
return key.id;
|
|
|
|
}),
|
2019-04-28 06:01:04 +00:00
|
|
|
specialListKeys = [].concat(
|
|
|
|
pandora.site.itemKeys.filter(function(key) {
|
|
|
|
return key.type[0] == 'date'
|
|
|
|
}).map(function(key) {
|
|
|
|
return key.id;
|
|
|
|
})
|
|
|
|
),
|
2015-09-21 17:31:44 +00:00
|
|
|
posterKeys = nameKeys.concat(['title', 'year']),
|
2019-11-12 18:18:12 +00:00
|
|
|
displayedKeys = [ // FIXME: can tis be a flag in the config?
|
|
|
|
'title', 'notes', 'name', 'summary', 'id',
|
|
|
|
'hue', 'saturation', 'lightness', 'cutsperminute', 'volume',
|
|
|
|
'user', 'rightslevel', 'bitrate', 'timesaccessed',
|
|
|
|
'numberoffiles', 'numberofannotations', 'numberofcuts', 'words', 'wordsperminute',
|
|
|
|
'duration', 'aspectratio', 'pixels', 'size', 'resolution',
|
|
|
|
'created', 'modified', 'accessed',
|
|
|
|
'random'
|
|
|
|
],
|
2011-10-02 15:37:58 +00:00
|
|
|
statisticsWidth = 128,
|
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
$bar = Ox.Bar({size: 16})
|
|
|
|
.bindEvent({
|
|
|
|
doubleclick: function(e) {
|
|
|
|
if ($(e.target).is('.OxBar')) {
|
|
|
|
$info.animate({scrollTop: 0}, 250);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$options = Ox.MenuButton({
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'delete',
|
|
|
|
title: Ox._('Delete {0}...', [pandora.site.itemName.singular]),
|
|
|
|
disabled: !canRemove
|
|
|
|
}
|
|
|
|
],
|
|
|
|
style: 'square',
|
|
|
|
title: 'set',
|
|
|
|
tooltip: Ox._('Options'),
|
|
|
|
type: 'image',
|
|
|
|
})
|
2011-08-05 18:26:27 +00:00
|
|
|
.css({
|
2013-07-11 12:38:19 +00:00
|
|
|
float: 'left',
|
|
|
|
borderColor: 'rgba(0, 0, 0, 0)',
|
|
|
|
background: 'rgba(0, 0, 0, 0)'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(data_) {
|
|
|
|
if (data_.id == 'delete') {
|
2016-09-15 15:20:24 +00:00
|
|
|
pandora.$ui.deleteItemsDialog = pandora.ui.deleteItemsDialog({
|
|
|
|
items: [data]
|
|
|
|
}).open();
|
2013-07-11 12:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo($bar),
|
|
|
|
|
|
|
|
$edit = Ox.MenuButton({
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
id: 'insert',
|
|
|
|
title: Ox._('Insert HTML...'),
|
|
|
|
disabled: true
|
|
|
|
}
|
|
|
|
],
|
|
|
|
style: 'square',
|
|
|
|
title: 'edit',
|
|
|
|
tooltip: Ox._('Edit'),
|
|
|
|
type: 'image',
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'right',
|
|
|
|
borderColor: 'rgba(0, 0, 0, 0)',
|
|
|
|
background: 'rgba(0, 0, 0, 0)'
|
2011-08-05 18:26:27 +00:00
|
|
|
})
|
2013-07-11 12:38:19 +00:00
|
|
|
.bindEvent({
|
|
|
|
click: function(data) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo($bar),
|
2011-10-02 15:37:58 +00:00
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
$info = Ox.Element().css({overflowY: 'auto'}),
|
|
|
|
|
|
|
|
that = Ox.SplitPanel({
|
|
|
|
elements: [
|
2018-09-18 21:17:32 +00:00
|
|
|
{element: $bar, size: isMultiple ? 0 : 16},
|
2013-07-11 12:38:19 +00:00
|
|
|
{element: $info}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
2018-09-18 21:17:32 +00:00
|
|
|
});
|
2011-10-02 15:37:58 +00:00
|
|
|
|
2018-09-18 21:17:32 +00:00
|
|
|
if (!isMultiple) {
|
|
|
|
var $icon = Ox.Element({
|
|
|
|
element: '<img>',
|
|
|
|
})
|
|
|
|
.attr({
|
|
|
|
src: '/' + data.id + '/' + (
|
|
|
|
ui.icons == 'posters' ? 'poster' : 'icon'
|
|
|
|
) + '512.jpg?' + data.modified
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: margin + iconLeft + 'px',
|
|
|
|
top: margin + 'px',
|
|
|
|
width: iconWidth + 'px',
|
|
|
|
height: iconHeight + 'px',
|
|
|
|
borderRadius: borderRadius + 'px',
|
|
|
|
cursor: 'pointer'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
singleclick: toggleIconSize
|
|
|
|
})
|
|
|
|
.appendTo($info),
|
2011-10-02 15:37:58 +00:00
|
|
|
|
2018-09-18 21:17:32 +00:00
|
|
|
$reflection = $('<div>')
|
|
|
|
.addClass('OxReflection')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: margin + 'px',
|
|
|
|
top: margin + iconHeight + 'px',
|
|
|
|
width: iconSize + 'px',
|
|
|
|
height: iconSize / 2 + 'px',
|
|
|
|
overflow: 'hidden'
|
|
|
|
})
|
|
|
|
.appendTo($info),
|
2011-10-02 15:37:58 +00:00
|
|
|
|
2018-09-18 21:17:32 +00:00
|
|
|
$reflectionIcon = $('<img>')
|
|
|
|
.attr({
|
|
|
|
src: '/' + data.id + '/' + (
|
|
|
|
ui.icons == 'posters' ? 'poster' : 'icon'
|
|
|
|
) + '512.jpg?' + data.modified
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: iconLeft + 'px',
|
|
|
|
width: iconWidth + 'px',
|
|
|
|
height: iconHeight + 'px',
|
|
|
|
borderRadius: borderRadius + 'px'
|
|
|
|
})
|
|
|
|
.appendTo($reflection),
|
2011-10-02 15:37:58 +00:00
|
|
|
|
2018-09-18 21:17:32 +00:00
|
|
|
$reflectionGradient = $('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
width: iconSize + 'px',
|
|
|
|
height: iconSize / 2 + 'px'
|
|
|
|
})
|
|
|
|
.appendTo($reflection);
|
|
|
|
}
|
2011-10-02 15:37:58 +00:00
|
|
|
|
2018-09-18 21:17:32 +00:00
|
|
|
var $text = Ox.Element()
|
2013-03-08 03:49:55 +00:00
|
|
|
.addClass('OxTextPage')
|
2011-08-05 18:26:27 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
2011-08-07 22:15:08 +00:00
|
|
|
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
|
2011-08-05 18:26:27 +00:00
|
|
|
top: margin + 'px',
|
2011-10-24 15:58:10 +00:00
|
|
|
right: margin + statisticsWidth + margin + 'px',
|
2011-08-05 18:26:27 +00:00
|
|
|
})
|
2012-04-20 10:36:42 +00:00
|
|
|
.appendTo($info),
|
2011-10-02 15:37:58 +00:00
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
$statistics = $('<div>')
|
2011-10-02 15:37:58 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
width: statisticsWidth + 'px',
|
|
|
|
top: margin + 'px',
|
|
|
|
right: margin + 'px'
|
|
|
|
})
|
2020-07-21 12:51:14 +00:00
|
|
|
.appendTo($info);
|
2012-04-20 10:36:42 +00:00
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
[$options, $edit].forEach(function($element) {
|
|
|
|
$element.find('input').css({
|
|
|
|
borderWidth: 0,
|
|
|
|
borderRadius: 0,
|
|
|
|
padding: '3px'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-10-20 17:21:18 +00:00
|
|
|
listKeys.forEach(function(key) {
|
|
|
|
if (Ox.isString(data[key])) {
|
|
|
|
data[key] = [data[key]];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-04-20 10:36:42 +00:00
|
|
|
if (!canEdit) {
|
2015-10-20 17:13:38 +00:00
|
|
|
pandora.createLinks($info);
|
2012-04-20 10:36:42 +00:00
|
|
|
}
|
2011-10-02 15:37:58 +00:00
|
|
|
|
2011-10-24 21:30:45 +00:00
|
|
|
// Title -------------------------------------------------------------------
|
2011-08-06 03:19:14 +00:00
|
|
|
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
2012-04-20 10:36:42 +00:00
|
|
|
marginTop: '-2px',
|
2011-08-06 03:19:14 +00:00
|
|
|
})
|
2011-10-24 15:58:10 +00:00
|
|
|
.append(
|
2013-07-11 12:38:19 +00:00
|
|
|
Ox.EditableContent({
|
2012-04-20 10:36:42 +00:00
|
|
|
editable: canEdit,
|
2013-03-01 03:51:39 +00:00
|
|
|
tooltip: canEdit ? pandora.getEditTooltip() : '',
|
2021-04-29 19:57:52 +00:00
|
|
|
placeholder: formatLight(Ox._( isMixed.title ? 'Mixed title' : 'Untitled')),
|
2013-04-18 15:59:30 +00:00
|
|
|
value: data.title || ''
|
2011-10-24 15:58:10 +00:00
|
|
|
})
|
|
|
|
.css({
|
2011-11-03 17:11:10 +00:00
|
|
|
marginBottom: '-3px',
|
2011-10-24 15:58:10 +00:00
|
|
|
fontWeight: 'bold',
|
2013-07-19 09:34:01 +00:00
|
|
|
fontSize: '13px'
|
2011-10-24 15:58:10 +00:00
|
|
|
})
|
2011-10-30 15:22:45 +00:00
|
|
|
.bindEvent({
|
2011-10-24 21:30:45 +00:00
|
|
|
submit: function(event) {
|
|
|
|
editMetadata('title', event.value);
|
|
|
|
}
|
2011-10-30 15:22:45 +00:00
|
|
|
})
|
2011-08-06 03:19:14 +00:00
|
|
|
)
|
2013-07-11 12:38:19 +00:00
|
|
|
.appendTo($text);
|
2011-08-06 01:04:09 +00:00
|
|
|
|
2019-11-12 18:18:12 +00:00
|
|
|
// Director, Year and Country, Language --------------------------------
|
2011-08-06 01:04:09 +00:00
|
|
|
|
2019-11-12 18:18:12 +00:00
|
|
|
renderGroup(['director', 'year', 'country', 'language']);
|
2011-08-06 01:04:09 +00:00
|
|
|
|
2016-08-28 10:03:05 +00:00
|
|
|
// Featuring ----------------------------------------------
|
|
|
|
|
2019-11-19 15:45:18 +00:00
|
|
|
Ox.getObjectById(pandora.site.itemKeys, 'featuring') && renderGroup(['featuring']);
|
2016-08-28 10:03:05 +00:00
|
|
|
|
2019-11-12 18:18:12 +00:00
|
|
|
// Render any remaing keys defined in config
|
|
|
|
|
|
|
|
renderRemainingKeys();
|
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
// Summary -----------------------------------------------------------------
|
2011-08-05 18:26:27 +00:00
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
if (canEdit || data.summary) {
|
2011-08-05 18:26:27 +00:00
|
|
|
$('<div>')
|
|
|
|
.append(
|
2013-07-11 12:38:19 +00:00
|
|
|
Ox.EditableContent({
|
2012-04-20 10:36:42 +00:00
|
|
|
clickLink: pandora.clickLink,
|
|
|
|
editable: canEdit,
|
2013-07-11 12:38:19 +00:00
|
|
|
format: function(value) {
|
|
|
|
return value.replace(
|
|
|
|
/<img src=/g,
|
|
|
|
'<img style="float: left; max-width: 256px; max-height: 256px; margin: 0 16px 16px 0" src='
|
|
|
|
);
|
|
|
|
},
|
2012-04-20 10:36:42 +00:00
|
|
|
maxHeight: Infinity,
|
2018-09-18 21:17:32 +00:00
|
|
|
placeholder: formatLight(Ox._( isMixed.summary ? 'Mixed Summary' : 'No Summary')),
|
2013-03-01 03:51:39 +00:00
|
|
|
tooltip: canEdit ? pandora.getEditTooltip() : '',
|
2012-04-20 10:36:42 +00:00
|
|
|
type: 'textarea',
|
2013-07-11 12:38:19 +00:00
|
|
|
value: data.summary || ''
|
|
|
|
})
|
|
|
|
.css(css)
|
|
|
|
.css({
|
|
|
|
marginTop: '12px',
|
|
|
|
overflow: 'hidden'
|
2012-04-20 10:36:42 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(event) {
|
|
|
|
editMetadata('summary', event.value);
|
|
|
|
}
|
|
|
|
})
|
2011-08-05 18:26:27 +00:00
|
|
|
)
|
2013-07-11 12:38:19 +00:00
|
|
|
.appendTo($text);
|
2011-08-05 18:26:27 +00:00
|
|
|
}
|
|
|
|
|
2019-11-12 18:18:12 +00:00
|
|
|
|
2013-01-02 12:59:58 +00:00
|
|
|
// Duration, Aspect Ratio --------------------------------------------------
|
2018-09-18 21:17:32 +00:00
|
|
|
if (!isMultiple) {
|
|
|
|
['duration', 'aspectratio'].forEach(function(key) {
|
|
|
|
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key),
|
|
|
|
value = data[key] || 0;
|
|
|
|
$('<div>')
|
|
|
|
.css({marginBottom: '4px'})
|
|
|
|
.append(formatKey(itemKey.title, 'statistics'))
|
|
|
|
.append(
|
|
|
|
Ox.Theme.formatColor(null, 'gradient')
|
|
|
|
.css({textAlign: 'right'})
|
|
|
|
.html(
|
|
|
|
Ox['format' + Ox.toTitleCase(itemKey.format.type)]
|
|
|
|
.apply(null, [value].concat(itemKey.format.args))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.appendTo($statistics);
|
|
|
|
});
|
2013-01-02 12:59:58 +00:00
|
|
|
|
2018-09-18 21:17:32 +00:00
|
|
|
// Hue, Saturation, Lightness, Volume --------------------------------------
|
|
|
|
|
|
|
|
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
|
|
|
|
$('<div>')
|
|
|
|
.css({marginBottom: '4px'})
|
|
|
|
.append(formatKey(key, 'statistics'))
|
|
|
|
.append(
|
|
|
|
Ox.Theme.formatColor(
|
|
|
|
data[key] || 0, key == 'volume' ? 'lightness' : key
|
|
|
|
).css({textAlign: 'right'})
|
|
|
|
)
|
|
|
|
.appendTo($statistics);
|
|
|
|
});
|
2013-01-02 12:59:58 +00:00
|
|
|
|
2018-09-18 21:17:32 +00:00
|
|
|
// Cuts per Minute ---------------------------------------------------------
|
2011-10-24 10:04:41 +00:00
|
|
|
|
2011-10-02 15:37:58 +00:00
|
|
|
$('<div>')
|
2011-10-23 09:13:57 +00:00
|
|
|
.css({marginBottom: '4px'})
|
2018-09-18 21:17:32 +00:00
|
|
|
.append(formatKey('cuts per minute', 'statistics'))
|
2011-10-27 13:14:37 +00:00
|
|
|
.append(
|
2018-09-18 21:17:32 +00:00
|
|
|
Ox.Theme.formatColor(null, 'gradient')
|
|
|
|
.css({textAlign: 'right'})
|
|
|
|
.html(Ox.formatNumber(data['cutsperminute'] || 0, 3))
|
2011-10-27 13:14:37 +00:00
|
|
|
)
|
2013-07-11 12:38:19 +00:00
|
|
|
.appendTo($statistics);
|
2018-09-18 21:17:32 +00:00
|
|
|
}
|
2011-10-22 21:03:28 +00:00
|
|
|
|
2011-10-25 13:59:27 +00:00
|
|
|
// Rights Level ------------------------------------------------------------
|
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
var $rightsLevel = $('<div>');
|
|
|
|
$('<div>')
|
|
|
|
.css({marginBottom: '4px'})
|
|
|
|
.append(formatKey('Rights Level', 'statistics'))
|
|
|
|
.append($rightsLevel)
|
|
|
|
.appendTo($statistics);
|
2020-07-21 12:51:14 +00:00
|
|
|
pandora.renderRightsLevel(that, $rightsLevel, data, isMixed, isMultiple, canEdit);
|
2011-08-06 01:34:07 +00:00
|
|
|
|
2012-04-20 10:36:42 +00:00
|
|
|
// Notes --------------------------------------------------------------------
|
2011-10-25 13:59:27 +00:00
|
|
|
|
|
|
|
if (canEdit) {
|
|
|
|
$('<div>')
|
|
|
|
.css({marginBottom: '4px'})
|
|
|
|
.append(
|
2013-07-11 12:38:19 +00:00
|
|
|
formatKey('Notes', 'statistics').options({
|
|
|
|
tooltip: Ox._('Only {0} can see and edit these comments', [
|
|
|
|
Object.keys(pandora.site.capabilities.canEditMetadata).map(function(level, i) {
|
|
|
|
return (
|
|
|
|
i == 0 ? ''
|
|
|
|
: i < Ox.len(pandora.site.capabilities.canEditMetadata) - 1 ? ', '
|
|
|
|
: ' ' + Ox._('and') + ' '
|
|
|
|
) + Ox.toTitleCase(level)
|
|
|
|
}).join('')])
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.append(
|
|
|
|
Ox.EditableContent({
|
2011-10-25 13:59:27 +00:00
|
|
|
height: 128,
|
2019-11-20 12:37:16 +00:00
|
|
|
placeholder: formatLight(Ox._(isMixed.notes ? 'Mixed notes' : 'No notes')),
|
2013-03-01 03:51:39 +00:00
|
|
|
tooltip: pandora.getEditTooltip(),
|
2011-10-25 13:59:27 +00:00
|
|
|
type: 'textarea',
|
2013-04-18 15:59:30 +00:00
|
|
|
value: data.notes || '',
|
2011-10-25 13:59:27 +00:00
|
|
|
width: 128
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(event) {
|
2012-04-20 10:36:42 +00:00
|
|
|
editMetadata('notes', event.value);
|
2011-10-25 13:59:27 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
2013-07-11 12:38:19 +00:00
|
|
|
.appendTo($statistics);
|
2011-10-25 13:59:27 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
$('<div>').css({height: '16px'}).appendTo($statistics);
|
2011-08-05 18:26:27 +00:00
|
|
|
|
2011-10-24 21:30:45 +00:00
|
|
|
function editMetadata(key, value) {
|
2011-10-24 21:50:18 +00:00
|
|
|
if (value != data[key]) {
|
2019-04-28 06:01:04 +00:00
|
|
|
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key);
|
2018-09-18 21:17:32 +00:00
|
|
|
var edit = {id: isMultiple ? ui.listSelection : data.id};
|
2011-10-24 21:50:18 +00:00
|
|
|
if (key == 'title') {
|
2012-04-20 10:36:42 +00:00
|
|
|
edit[key] = value;
|
|
|
|
} else if (listKeys.indexOf(key) >= 0) {
|
2012-01-03 09:03:21 +00:00
|
|
|
edit[key] = value ? value.split(', ') : [];
|
2019-04-28 06:01:04 +00:00
|
|
|
} else if (specialListKeys.indexOf(key) > -1) {
|
|
|
|
edit[key] = value
|
|
|
|
? Ox.decodeHTMLEntities(value).split('; ').map(Ox.encodeHTMLEntities)
|
|
|
|
: [];
|
2011-10-24 21:50:18 +00:00
|
|
|
} else {
|
2012-04-20 10:36:42 +00:00
|
|
|
edit[key] = value ? value : null;
|
2011-10-24 21:30:45 +00:00
|
|
|
}
|
2019-04-28 06:01:04 +00:00
|
|
|
if (itemKey && itemKey.type && itemKey.type[0] == 'date') {
|
2019-11-12 17:50:24 +00:00
|
|
|
edit[key] = edit[key].map(pandora.cleanupDate);
|
2019-04-28 06:01:04 +00:00
|
|
|
}
|
2011-10-24 21:50:18 +00:00
|
|
|
pandora.api.edit(edit, function(result) {
|
2018-09-18 21:17:32 +00:00
|
|
|
if (!isMultiple) {
|
|
|
|
var src;
|
|
|
|
data[key] = result.data[key];
|
|
|
|
descriptions[key] && descriptions[key].options({
|
|
|
|
value: result.data[key + 'description']
|
2012-04-20 10:36:42 +00:00
|
|
|
});
|
2018-09-18 21:17:32 +00:00
|
|
|
Ox.Request.clearCache(); // fixme: too much? can change filter/list etc
|
|
|
|
if (result.data.id != data.id) {
|
|
|
|
pandora.UI.set({item: result.data.id});
|
|
|
|
pandora.$ui.browser.value(data.id, 'id', result.data.id);
|
|
|
|
}
|
|
|
|
pandora.updateItemContext();
|
|
|
|
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
|
|
|
|
if (Ox.contains(posterKeys, key) && ui.icons == 'posters') {
|
|
|
|
src = pandora.getMediaURL('/' + data.id + '/poster512.jpg?' + Ox.uid());
|
|
|
|
$icon.attr({src: src});
|
|
|
|
$reflectionIcon.attr({src: src});
|
|
|
|
}
|
|
|
|
pandora.$ui.itemTitle
|
|
|
|
.options({
|
|
|
|
title: '<b>' + result.data.title
|
|
|
|
+ (Ox.len(result.data.director)
|
|
|
|
? ' (' + result.data.director.join(', ') + ')'
|
|
|
|
: '')
|
|
|
|
+ (result.data.year ? ' ' + result.data.year : '') + '</b>'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
that.triggerEvent('change', Ox.extend({}, key, value));
|
2011-10-24 21:50:18 +00:00
|
|
|
});
|
|
|
|
}
|
2011-10-24 21:30:45 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
function formatKey(key, mode) {
|
|
|
|
var item = Ox.getObjectById(pandora.site.itemKeys, key);
|
|
|
|
key = Ox._(item ? item.title : key);
|
|
|
|
mode = mode || 'text';
|
|
|
|
return mode == 'text'
|
|
|
|
? '<span style="font-weight: bold">' + Ox.toTitleCase(key) + ':</span> '
|
|
|
|
: mode == 'description'
|
|
|
|
? Ox.toTitleCase(key)
|
|
|
|
: Ox.Element()
|
|
|
|
.css({marginBottom: '4px', fontWeight: 'bold'})
|
|
|
|
.html(Ox.toTitleCase(key)
|
|
|
|
.replace(' Per ', ' per '));
|
2011-08-05 18:26:27 +00:00
|
|
|
}
|
|
|
|
|
2011-08-06 03:19:14 +00:00
|
|
|
function formatLight(str) {
|
2013-07-11 12:38:19 +00:00
|
|
|
return '<span class="OxLight">' + str + '</span>';
|
2011-08-06 03:19:14 +00:00
|
|
|
}
|
|
|
|
|
2019-04-28 06:01:04 +00:00
|
|
|
|
|
|
|
function formatLink(value, key, linkValue) {
|
|
|
|
linkValue = linkValue || value
|
|
|
|
linkValue = Ox.isArray(linkValue) ? linkValue: [linkValue]
|
|
|
|
return (Ox.isArray(value) ? value : [value]).map(function(value, idx) {
|
2013-07-11 12:38:19 +00:00
|
|
|
return key
|
2019-04-28 06:01:04 +00:00
|
|
|
? '<a href="/' + (
|
|
|
|
key == 'alternativeTitles' ? 'title' : key
|
2023-11-17 10:36:15 +00:00
|
|
|
) + '=' + pandora.escapeQueryValue(Ox.decodeHTMLEntities(linkValue[idx])) + '">' + value + '</a>'
|
2011-08-07 16:30:26 +00:00
|
|
|
: value;
|
2019-04-28 06:01:04 +00:00
|
|
|
}).join(Ox.contains(specialListKeys, key) ? '; ' : ', ');
|
2011-08-05 18:26:27 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
function formatValue(key, value) {
|
|
|
|
var ret;
|
2016-08-28 11:32:21 +00:00
|
|
|
if (nameKeys.indexOf(key) > -1) {
|
2013-07-11 12:38:19 +00:00
|
|
|
ret = formatLink(value.split(', '), 'name');
|
2019-04-28 06:01:04 +00:00
|
|
|
} else if (
|
|
|
|
listKeys.indexOf(key) > -1 && Ox.getObjectById(pandora.site.itemKeys, key).type[0] == 'date'
|
|
|
|
) {
|
|
|
|
ret = value.split('; ').map(function(date) {
|
2019-11-12 17:50:24 +00:00
|
|
|
date = pandora.cleanupDate(date)
|
2019-04-28 06:01:04 +00:00
|
|
|
return date ? formatLink(Ox.formatDate(date,
|
|
|
|
['', '%Y', '%B %Y', '%B %e, %Y'][date.split('-').length],
|
|
|
|
true
|
|
|
|
), key, date) : '';
|
|
|
|
}).join('; ');
|
2013-07-11 12:38:19 +00:00
|
|
|
} else if (listKeys.indexOf(key) > -1) {
|
|
|
|
ret = formatLink(value.split(', '), key);
|
2019-04-28 06:01:04 +00:00
|
|
|
} else if (specialListKeys.indexOf(key) > -1) {
|
|
|
|
ret = formatLink(
|
|
|
|
Ox.decodeHTMLEntities(value).split('; ').map(Ox.encodeHTMLEntities),
|
|
|
|
key
|
|
|
|
);
|
2016-08-28 11:32:21 +00:00
|
|
|
} else if (['year', 'country'].indexOf(key) > -1) {
|
|
|
|
ret = formatLink(value, key);
|
2013-07-11 12:38:19 +00:00
|
|
|
} else {
|
|
|
|
ret = value;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getValue(key, value) {
|
|
|
|
return !value ? ''
|
2019-04-28 06:01:04 +00:00
|
|
|
: Ox.contains(specialListKeys, key) ? value.join('; ')
|
2013-07-11 12:38:19 +00:00
|
|
|
: Ox.contains(listKeys, key) ? value.join(', ')
|
|
|
|
: value;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderGroup(keys) {
|
|
|
|
var $element;
|
2019-11-12 18:18:12 +00:00
|
|
|
keys.forEach(function(key) { displayedKeys.push(key) });
|
2013-07-11 12:38:19 +00:00
|
|
|
if (canEdit || keys.filter(function(key) {
|
|
|
|
return data[key];
|
|
|
|
}).length) {
|
2013-07-19 09:34:01 +00:00
|
|
|
$element = $('<div>').addClass('OxSelectable').css(css);
|
2013-07-11 12:38:19 +00:00
|
|
|
keys.forEach(function(key, i) {
|
|
|
|
if (canEdit || data[key]) {
|
|
|
|
if ($element.children().length) {
|
|
|
|
$('<span>').html('; ').appendTo($element);
|
|
|
|
}
|
|
|
|
$('<span>').html(formatKey(key)).appendTo($element);
|
|
|
|
Ox.EditableContent({
|
|
|
|
clickLink: pandora.clickLink,
|
2023-07-27 13:06:43 +00:00
|
|
|
editable: canEdit,
|
2013-07-11 12:38:19 +00:00
|
|
|
format: function(value) {
|
|
|
|
return formatValue(key, value);
|
|
|
|
},
|
2023-07-27 13:06:43 +00:00
|
|
|
placeholder: formatLight(Ox._(isMixed[key] ? 'mixed' : 'unknown')),
|
2013-07-11 12:38:19 +00:00
|
|
|
tooltip: canEdit ? pandora.getEditTooltip() : '',
|
|
|
|
value: getValue(key, data[key])
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(data) {
|
|
|
|
editMetadata(key, data.value);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo($element);
|
2020-11-26 19:22:59 +00:00
|
|
|
if (isMixed[key] && Ox.contains(listKeys, key)) {
|
|
|
|
pandora.ui.addRemoveKeyDialog({
|
|
|
|
ids: ui.listSelection,
|
|
|
|
key: key,
|
|
|
|
section: ui.section
|
|
|
|
}).appendTo($element)
|
|
|
|
}
|
2013-07-11 12:38:19 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$element.appendTo($text);
|
|
|
|
}
|
2023-07-27 13:06:43 +00:00
|
|
|
return $element;
|
2013-07-11 12:38:19 +00:00
|
|
|
}
|
|
|
|
|
2019-11-12 18:18:12 +00:00
|
|
|
function renderRemainingKeys() {
|
|
|
|
var keys = pandora.site.itemKeys.filter(function(item) {
|
|
|
|
return item.id != '*' && item.type != 'layer' && !Ox.contains(displayedKeys, item.id);
|
|
|
|
}).map(function(item) {
|
|
|
|
return item.id;
|
|
|
|
});
|
|
|
|
if (keys.length) {
|
|
|
|
renderGroup(keys)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-07 22:15:08 +00:00
|
|
|
function toggleIconSize() {
|
|
|
|
iconSize = iconSize == 256 ? 512 : 256;
|
|
|
|
iconWidth = iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio);
|
|
|
|
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio);
|
|
|
|
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
|
2011-10-02 15:37:58 +00:00
|
|
|
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8;
|
2011-08-07 22:15:08 +00:00
|
|
|
$icon.animate({
|
|
|
|
left: margin + iconLeft + 'px',
|
|
|
|
width: iconWidth + 'px',
|
2011-08-17 09:29:42 +00:00
|
|
|
height: iconHeight + 'px',
|
2011-10-29 17:46:46 +00:00
|
|
|
borderRadius: borderRadius + 'px'
|
2011-08-06 01:34:07 +00:00
|
|
|
}, 250);
|
|
|
|
$reflection.animate({
|
2011-08-07 22:15:08 +00:00
|
|
|
top: margin + iconHeight + 'px',
|
|
|
|
width: iconSize + 'px',
|
|
|
|
height: iconSize / 2 + 'px'
|
2011-08-06 01:34:07 +00:00
|
|
|
}, 250);
|
2011-08-07 22:15:08 +00:00
|
|
|
$reflectionIcon.animate({
|
|
|
|
left: iconLeft + 'px',
|
|
|
|
width: iconWidth + 'px',
|
|
|
|
height: iconHeight + 'px',
|
2011-08-17 09:29:42 +00:00
|
|
|
borderRadius: borderRadius + 'px'
|
2011-08-06 01:34:07 +00:00
|
|
|
}, 250);
|
|
|
|
$reflectionGradient.animate({
|
2011-08-07 22:15:08 +00:00
|
|
|
width: iconSize + 'px',
|
|
|
|
height: iconSize / 2 + 'px'
|
2011-08-06 01:34:07 +00:00
|
|
|
}, 250);
|
2013-07-11 12:38:19 +00:00
|
|
|
$text.animate({
|
2011-08-07 22:15:08 +00:00
|
|
|
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
|
2011-08-06 01:34:07 +00:00
|
|
|
}, 250);
|
2011-08-07 22:15:08 +00:00
|
|
|
pandora.UI.set({infoIconSize: iconSize});
|
2011-08-06 01:34:07 +00:00
|
|
|
}
|
|
|
|
|
2023-07-07 10:44:17 +00:00
|
|
|
that.resizeElement = function() {
|
|
|
|
// overwrite splitpanel resize
|
|
|
|
};
|
|
|
|
|
2011-08-07 22:15:08 +00:00
|
|
|
that.reload = function() {
|
|
|
|
var src = src = '/' + data.id + '/' + (
|
2012-04-20 10:36:42 +00:00
|
|
|
ui.icons == 'posters' ? 'poster' : 'icon'
|
|
|
|
) + '512.jpg?' + Ox.uid();
|
2011-08-07 22:15:08 +00:00
|
|
|
$icon.attr({src: src});
|
|
|
|
$reflectionIcon.attr({src: src});
|
|
|
|
iconSize = iconSize == 256 ? 512 : 256;
|
2011-10-02 15:37:58 +00:00
|
|
|
iconRatio = ui.icons == 'posters'
|
2013-07-08 12:40:23 +00:00
|
|
|
? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1;
|
2011-08-07 22:15:08 +00:00
|
|
|
toggleIconSize();
|
|
|
|
};
|
|
|
|
|
2011-09-27 23:30:13 +00:00
|
|
|
that.bindEvent({
|
2014-09-24 20:54:45 +00:00
|
|
|
mousedown: function() {
|
2014-10-20 15:54:34 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
!Ox.Focus.focusedElementIsInput() && that.gainFocus();
|
|
|
|
});
|
2014-09-24 20:54:45 +00:00
|
|
|
},
|
2011-09-27 23:30:13 +00:00
|
|
|
pandora_icons: that.reload,
|
2012-03-20 12:01:26 +00:00
|
|
|
pandora_showsiteposters: function() {
|
2011-10-02 15:37:58 +00:00
|
|
|
ui.icons == 'posters' && that.reload();
|
2011-09-27 14:14:40 +00:00
|
|
|
}
|
2011-09-23 10:44:54 +00:00
|
|
|
});
|
|
|
|
|
2011-08-05 18:26:27 +00:00
|
|
|
return that;
|
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
};
|