pandora/static/js/infoView.indiancinema.js

1284 lines
48 KiB
JavaScript
Raw Permalink Normal View History

2013-02-18 12:53:05 +00:00
'use strict';
2018-09-18 21:17:32 +00:00
pandora.ui.infoView = function(data, isMixed) {
isMixed = isMixed || {};
2013-02-18 12:53:05 +00:00
var ui = pandora.user.ui,
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'),
canSeeAllMetadata = pandora.user.level != 'guest',
2013-02-18 12:53:05 +00:00
css = {
marginTop: '4px',
textAlign: 'justify'
2013-02-18 12:53:05 +00:00
},
iconRatio = ui.icons == 'posters' ? (
ui.showSitePosters ? pandora.site.posters.ratio : 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),
2013-02-18 12:53:05 +00:00
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
isCopyrighted = !data.year || parseInt(data.year) + 60 >= new Date().getFullYear(),
2013-06-06 09:11:48 +00:00
listWidth = 0,
2013-02-18 12:53:05 +00:00
margin = 16,
// these may contain commas, and are thus separated by semicolons
2019-06-17 08:56:27 +00:00
specialListKeys = ['alternativeTitles', 'productionCompany', 'laboratory'].concat(
pandora.site.itemKeys.filter(function(key) {
return key.type[0] == 'date'
}).map(function(key) {
return key.id;
})
),
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) && !Ox.contains(specialListKeys, key.id);
}).map(function(key){
return key.id;
}),
posterKeys = ['title', 'director', 'year'],
descriptions = {
names: getNames(),
studios: getStudios()
},
2013-02-18 12:53:05 +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);
}
}
}),
2013-02-18 12:53:05 +00:00
2013-07-11 12:38:19 +00:00
$options = Ox.MenuButton({
items: [
{
id: 'imdb',
title: Ox._('Update IMDb ID...'),
disabled: !canEdit
2013-07-11 12:38:19 +00:00
},
{
id: 'metadata',
title: Ox._('Update Metadata...'),
disabled: !canEdit
2013-07-11 12:38:19 +00:00
},
{},
{
id: 'upload',
title: Ox._('Upload Video...'),
2017-11-04 09:53:27 +00:00
disabled: !pandora.hasCapability('canAddItems')
2013-07-11 12:38:19 +00:00
},
{},
{
id: 'delete',
title: Ox._('Delete {0}...', [pandora.site.itemName.singular]),
disabled: !canRemove
}
],
style: 'square',
title: 'set',
tooltip: Ox._('Options'),
type: 'image',
})
2013-02-18 12:53:05 +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)'
2013-02-18 12:53:05 +00:00
})
2013-07-11 12:38:19 +00:00
.bindEvent({
click: function(data_) {
if (data_.id == 'imdb') {
pandora.$ui.idDialog = pandora.ui.idDialog(data).open();
} else if (data_.id == 'metadata') {
pandora.$ui.metadataDialog = pandora.ui.metadataDialog(data).open();
} else if (data_.id == 'upload') {
2016-09-15 15:20:24 +00:00
pandora.$ui.addItemDialog = pandora.ui.addItemDialog({
item: pandora.user.ui.item,
selected: 'upload'
}).open();
2013-07-11 12:38:19 +00:00
} else 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),
2013-02-18 12:53:05 +00:00
2013-07-11 12:38:19 +00:00
$edit = Ox.MenuButton({
items: [
{
id: 'insert',
title: Ox._('Insert HTML...'),
disabled: true
}
],
style: 'square',
title: 'edit',
tooltip: Ox._('Edit'),
type: 'image',
})
2013-02-18 12:53:05 +00:00
.css({
2013-07-11 12:38:19 +00:00
float: 'right',
borderColor: 'rgba(0, 0, 0, 0)',
background: 'rgba(0, 0, 0, 0)'
2013-02-18 12:53:05 +00:00
})
2013-07-11 12:38:19 +00:00
.bindEvent({
click: function(data) {
// ...
}
})
.appendTo($bar),
$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
});
2013-02-18 12:53:05 +00:00
2018-09-18 21:17:32 +00:00
if (!isMultiple) {
var $icon = Ox.Element({
element: '<img>'
})
.attr({
src: pandora.getMediaURL('/' + 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),
2013-02-18 12:53:05 +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: Math.round(iconSize / 2) + 'px',
overflow: 'hidden'
})
.appendTo($info),
$reflectionIcon = $('<img>')
.attr({
src: pandora.getMediaURL('/' + data.id + '/' + (
ui.icons == 'posters'
? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon'
) + '512.jpg?' + data.modified)
})
.css({
position: 'absolute',
left: iconLeft + 'px',
width: iconWidth + 'px',
height: iconHeight + 'px',
borderRadius: borderRadius + 'px'
})
.appendTo($reflection),
2013-02-18 12:53:05 +00:00
2018-09-18 21:17:32 +00:00
$reflectionGradient = $('<div>')
.css({
position: 'absolute',
width: iconSize + 'px',
height: Math.round(iconSize / 2) + 'px'
})
.appendTo($reflection);
}
2013-02-18 12:53:05 +00:00
2018-09-18 21:17:32 +00:00
var $text = Ox.Element()
.addClass('OxTextPage')
2013-02-18 12:53:05 +00:00
.css({
position: 'absolute',
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
top: margin + 'px',
right: margin + statisticsWidth + margin + 'px'
})
2013-07-11 12:38:19 +00:00
.appendTo($info),
2013-02-18 12:53:05 +00:00
2013-02-27 10:46:02 +00:00
$alternativeTitles,
$minutes,
2013-02-27 15:54:13 +00:00
$imdb,
$links,
$descriptions,
2013-02-18 12:53:05 +00:00
$statistics = $('<div>')
.css({
position: 'absolute',
width: statisticsWidth + 'px',
top: margin + 'px',
right: margin + 'px'
})
2013-07-11 12:38:19 +00:00
.appendTo($info),
2013-02-18 12:53:05 +00:00
2013-03-02 09:11:14 +00:00
$capabilities;
2013-02-18 12:53:05 +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'
});
});
listKeys.forEach(function(key) {
if (Ox.isString(data[key])) {
data[key] = [data[key]];
}
});
2013-02-18 12:53:05 +00:00
// Title -------------------------------------------------------------------
2018-09-18 21:17:32 +00:00
if (!isMultiple) {
2013-02-18 12:53:05 +00:00
$('<div>')
.css({
marginTop: '-2px'
})
.append(
2013-02-25 18:21:11 +00:00
Ox.EditableContent({
2013-02-18 12:53:05 +00:00
clickLink: pandora.clickLink,
2013-02-25 16:38:22 +00:00
editable: canEdit,
2013-02-18 12:53:05 +00:00
format: function(value) {
return formatTitle(value);
},
tooltip: canEdit ? pandora.getEditTooltip() : '',
2013-02-18 12:53:05 +00:00
value: data.title
})
.css({
marginBottom: '-3px',
fontWeight: 'bold',
fontSize: '13px'
2013-02-18 12:53:05 +00:00
})
.bindEvent({
submit: function(event) {
editMetadata('title', event.value);
}
})
)
.appendTo($text);
2018-09-18 21:17:32 +00:00
}
2013-02-18 12:53:05 +00:00
// Director ----------------------------------------------------------------
2013-02-25 16:38:22 +00:00
if (data.director || canEdit) {
2013-02-18 12:53:05 +00:00
$('<div>')
.css({
marginTop: '2px'
})
.append(
2013-02-25 18:21:11 +00:00
Ox.EditableContent({
2013-02-18 12:53:05 +00:00
clickLink: pandora.clickLink,
2013-02-25 16:38:22 +00:00
editable: canEdit,
2013-02-18 12:53:05 +00:00
format: function(value) {
return formatLink(value.split(', '), 'name');
2013-02-18 12:53:05 +00:00
},
2018-09-18 21:17:32 +00:00
placeholder: formatLight(Ox._(isMixed.director ? 'Mixed Director' : 'Unknown Director')),
tooltip: canEdit ? pandora.getEditTooltip() : '',
2013-02-25 16:38:22 +00:00
value: data.director ? data.director.join(', ') : ''
2013-02-18 12:53:05 +00:00
})
.css({
marginBottom: '-3px',
fontWeight: 'bold',
fontSize: '13px'
2013-02-18 12:53:05 +00:00
})
.bindEvent({
submit: function(event) {
editMetadata('director', event.value);
}
})
)
.appendTo($text);
}
2013-02-28 05:03:40 +00:00
// Groups ------------------------------------------------------------------
renderGroup(['alternativeTitles']);
2013-02-18 12:53:05 +00:00
renderGroup(['country', 'year', 'language', 'runtime', 'color', 'sound']);
2013-02-18 12:53:05 +00:00
renderGroup(['productionCompany']);
renderGroup([
'producer', 'codirector', 'writer', 'cinematographer', 'editor',
'composer', 'lyricist'
]);
renderGroup(['actor']);
2013-02-18 12:53:05 +00:00
2016-11-30 10:07:09 +00:00
renderGroup(canSeeAllMetadata ? ['genre', 'topic'] : ['genre']);
2013-02-18 12:53:05 +00:00
2017-01-25 14:33:20 +00:00
renderGroup([
'censorshipcertificatenumber',
'dateofcensorcertificate',
2019-02-21 14:40:58 +00:00
'certificationcentre',
2017-01-25 14:33:20 +00:00
'ratingcertificate',
'length',
'numberofreels',
2017-03-03 14:29:49 +00:00
'format',
'releasedate'
2017-01-25 14:33:20 +00:00
]);
2013-12-26 08:35:41 +00:00
renderGroup(['imdbId', 'links']);
2013-02-18 12:53:05 +00:00
2013-02-27 15:54:13 +00:00
if (canEdit) {
updateIMDb();
}
// Encyclopedia and Wiki ---------------------------------------------------
if (['staff', 'admin'].indexOf(pandora.user.level) > -1 && canEdit) {
renderGroup(['encyclopedia', 'wiki']);
}
2013-02-28 05:03:40 +00:00
// Summary -----------------------------------------------------------------
2013-02-25 16:38:22 +00:00
if (data.summary || canEdit) {
2013-02-27 10:46:02 +00:00
Ox.EditableContent({
2013-02-25 16:38:22 +00:00
clickLink: pandora.clickLink,
collapseToEnd: false,
2013-02-25 16:38:22 +00:00
editable: canEdit,
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='
);
},
2018-09-18 21:17:32 +00:00
placeholder: formatLight(Ox._(isMixed.summary ? 'Mixed Summary' : 'No Summary')),
tooltip: canEdit ? pandora.getEditTooltip() : '',
2013-02-25 16:38:22 +00:00
type: 'textarea',
value: data.summary || ''
2013-02-18 12:53:05 +00:00
})
.css(css)
2013-03-13 09:13:42 +00:00
.css({
marginTop: '12px',
overflow: 'hidden'
2013-03-13 09:13:42 +00:00
})
2013-02-25 16:38:22 +00:00
.bindEvent({
submit: function(data) {
editMetadata('summary', data.value);
2013-02-25 16:38:22 +00:00
}
})
2013-02-18 12:53:05 +00:00
.appendTo($text);
}
2016-11-30 10:07:09 +00:00
// Extra Metadata
2017-03-01 11:51:19 +00:00
var extra = renderGroup([
2016-11-30 10:07:09 +00:00
'presentedby',
'coproducer',
'associateproducer',
'executiveproducer',
'associatedirector',
'chiefassistantdirector',
'assistantdirector',
'story',
'screenplay',
'dialogue',
'adaptation'
2017-03-01 11:51:19 +00:00
])
extra && extra.css({marginTop: '12px'});
2016-11-30 10:07:09 +00:00
renderGroup([
'musicdirector',
'backgroundmusic',
'orchestration',
'arranger',
2017-01-24 17:40:17 +00:00
'singer',
2016-11-30 10:07:09 +00:00
'sounddesign',
'soundrecording',
'rerecording',
'musiclabel'
]);
renderGroup([
'assistantcinematographer',
'artdirector',
'costumedesign',
'productiondesign',
'specialeffects',
'animation',
'coeditor',
'stills',
'publicitydesign',
'makeup',
'hairstyles',
'dancedirector',
'productioncontroller',
'stuntdirector',
'continuity',
2019-02-21 14:39:40 +00:00
'publicity',
2019-02-21 14:37:53 +00:00
'laboratory'
2017-01-25 14:33:20 +00:00
]);
renderGroup([
2016-11-30 10:07:09 +00:00
'courtesy',
2017-01-25 14:33:20 +00:00
'subtitledby',
'annotatedby',
]);
2016-11-30 10:07:09 +00:00
// Songs
if (data.songs || canEdit) {
2019-06-15 07:46:37 +00:00
$('<div>')
.css({
marginTop: '12px',
})
.html(formatKey('songs'))
.appendTo($text);
2016-11-30 10:07:09 +00:00
Ox.EditableContent({
clickLink: pandora.clickLink,
collapseToEnd: false,
editable: canEdit,
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='
);
},
2019-06-15 07:46:37 +00:00
placeholder: formatLight(Ox._(isMixed.songs ? 'Mixed Songs' : 'unknown')),
2016-11-30 10:07:09 +00:00
tooltip: canEdit ? pandora.getEditTooltip() : '',
type: 'textarea',
value: data.songs || ''
})
.css(css)
.css({
overflow: 'hidden'
})
.bindEvent({
submit: function(data) {
editMetadata('songs', data.value);
}
})
.appendTo($text);
}
2013-02-28 05:03:40 +00:00
// Descriptions ------------------------------------------------------------
2018-09-18 21:17:32 +00:00
if (!isMultiple) {
2013-02-28 05:03:40 +00:00
$descriptions = $('<div>').attr({id: 'descriptions'}).appendTo($text);
renderDescriptions();
2013-02-18 12:53:05 +00:00
$('<div>').css({height: '16px'}).appendTo($text);
2017-01-25 20:49:10 +00:00
// Documents ---------------------------------------------------------------
var $div = $('<div>')
.css({marginBottom: '4px'})
.append(formatKey(
'Documents', 'link', '/' + data['id'] + '/documents'
))
.append(
Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'})
.html(Ox.formatNumber(data.numberofdocuments || 0))
)
.appendTo($statistics);
pandora.createLinks($div);
2016-11-30 10:07:09 +00:00
if (data.parts && data.rendered) {
2017-01-25 20:49:10 +00:00
// Annotations ---------------------------------------------------------
$div = $('<div>')
.css({marginBottom: '4px'})
.append(formatKey(
'Annotations', 'link', '/' + data['id'] + '/' + ui.videoView
))
.append(
Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'})
.html(Ox.formatNumber(data.numberofannotations || 0))
)
.appendTo($statistics);
pandora.createLinks($div);
// Duration, Aspect Ratio ----------------------------------------------
2016-11-30 10:07:09 +00:00
['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-02-18 12:53:05 +00:00
2017-01-25 20:49:10 +00:00
// Hue, Saturation, Lightness, Volume ----------------------------------
2016-11-30 10:07:09 +00:00
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
var value = data[key] || 0;
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey(key, 'statistics'))
.append(
Ox.Theme.formatColor(value, key == 'volume' ? 'lightness' : key)
.css({textAlign: 'right'})
)
.appendTo($statistics);
});
2013-02-18 12:53:05 +00:00
2017-01-25 20:49:10 +00:00
// Cuts per Minute, Words per Minute -----------------------------------
2016-11-30 10:07:09 +00:00
['cutsperminute', 'wordsperminute'].forEach(function(key) {
var value = data[key] || 0;
$('<div>')
.css({marginBottom: '4px'})
.append(
formatKey(Ox.toTitleCase(key.slice(0, -9)) + ' per Minute', 'statistics')
)
.append(
Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'})
.html(Ox.formatNumber(value, 3))
)
.appendTo($statistics);
});
2013-02-18 12:53:05 +00:00
2016-11-30 10:07:09 +00:00
} else {
// no video placeholder
}
2013-02-18 12:53:05 +00:00
2018-09-18 21:17:32 +00:00
}
2013-02-18 12:53:05 +00:00
// Rights Level ------------------------------------------------------------
var $rightsLevel = $('<div>');
2017-01-25 20:49:10 +00:00
var $div = $('<div>')
2013-02-18 12:53:05 +00:00
.css({marginBottom: '4px'})
2017-01-25 20:49:10 +00:00
.append(formatKey('Rights Level', 'link', '/copyrights'))
2013-02-18 12:53:05 +00:00
.append($rightsLevel)
.appendTo($statistics);
2017-01-25 20:49:10 +00:00
pandora.createLinks($div);
2013-02-18 12:53:05 +00:00
renderRightsLevel();
// Comments ----------------------------------------------------------------
2013-02-18 12:53:05 +00:00
if (canEdit) {
$('<div>')
.css({marginBottom: '4px'})
.append(
formatKey('Comments', 'statistics').options({
2013-05-09 10:13:58 +00:00
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 ? ', '
2013-05-09 10:13:58 +00:00
: ' ' + Ox._('and') + ' '
) + Ox.toTitleCase(level)
2013-05-09 10:13:58 +00:00
}).join('')])
})
)
2013-02-18 12:53:05 +00:00
.append(
2013-02-27 10:46:02 +00:00
Ox.EditableContent({
2013-03-01 06:54:00 +00:00
clickLink: pandora.clickLink,
2018-09-18 21:17:32 +00:00
placeholder: formatLight(Ox._(isMixed.comments ? 'Mixed comments' : 'No comments')),
tooltip: pandora.getEditTooltip(),
2013-02-18 12:53:05 +00:00
type: 'textarea',
value: data.comments || '',
2013-02-18 12:53:05 +00:00
width: 128
})
.bindEvent({
submit: function(event) {
2018-09-18 21:17:32 +00:00
editMetadata('comments', event.value);
2013-02-18 12:53:05 +00:00
}
})
)
.appendTo($statistics);
}
$('<div>').css({height: '16px'}).appendTo($statistics);
2019-04-02 03:07:26 +00:00
2013-02-18 12:53:05 +00:00
function editMetadata(key, value) {
if (value != data[key]) {
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key);
2018-09-18 21:17:32 +00:00
var edit = {id: isMultiple ? ui.listSelection : data.id};
2013-02-28 05:03:40 +00:00
if (key == 'alternativeTitles') {
edit[key] = value ? Ox.decodeHTMLEntities(value).split('; ').map(function(value) {
return [Ox.encodeHTMLEntities(value), []];
}) : [];
2013-02-27 10:46:02 +00:00
data[key] = edit[key];
$alternativeTitles.html(formatKey(key));
} else if (key == 'year') {
edit[key] = value ? parseInt(value) : '';
} else if (key == 'runtime') {
edit[key] = value ? parseInt(value) * 60 : '';
2013-02-27 10:46:02 +00:00
$minutes[value ? 'show' : 'hide']();
2013-02-25 18:21:11 +00:00
} else if (listKeys.indexOf(key) > -1) {
2013-02-18 12:53:05 +00:00
edit[key] = value ? value.split(', ') : [];
} else if (specialListKeys.indexOf(key) > -1) {
edit[key] = value
? Ox.decodeHTMLEntities(value).split('; ').map(Ox.encodeHTMLEntities)
: [];
2018-05-09 16:27:34 +00:00
} else if (key == 'imdbId') {
2019-07-23 14:39:41 +00:00
edit[key] = value ? value.match(/\d+/)[0] : value;
2013-02-18 12:53:05 +00:00
} else {
edit[key] = value;
}
if (itemKey && itemKey.type && itemKey.type[0] == 'date') {
2019-11-12 17:50:24 +00:00
edit[key] = edit[key].map(pandora.cleanupDate);
}
2013-02-18 12:53:05 +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];
if (result.data.id != data.id) {
Ox.Request.clearCache(); // fixme: too much
pandora.UI.set({item: result.data.id});
pandora.$ui.browser.value(data.id, 'id', result.data.id);
} else {
Ox.Request.clearCache('autocomplete');
}
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});
}
if (Ox.contains(nameKeys, key)) {
data['namedescription'] = result.data['namedescription'];
descriptions.names = getNames();
renderDescriptions();
} else if (key == 'productionCompany') {
data['productionCompanydescription'] = result.data['productionCompanydescription'];
descriptions.studios = getStudios();
renderDescriptions();
} else if (key == 'imdbId') {
updateIMDb();
}
}
2018-09-18 21:17:32 +00:00
that.triggerEvent('change', Ox.extend({}, key, value));
2013-02-18 12:53:05 +00:00
});
}
}
2017-01-25 20:49:10 +00:00
function formatKey(key, mode, link) {
var item = Ox.getObjectById(pandora.site.itemKeys, key);
2013-05-09 10:13:58 +00:00
key = Ox._(item ? item.title : key);
2013-07-11 12:38:19 +00:00
mode = mode || 'text';
2013-02-25 18:21:11 +00:00
if (key == 'alternativeTitles') {
2014-02-14 15:23:59 +00:00
key = Ox._('Alternative Title' + (
data.alternativeTitles && data.alternativeTitles.length == 1 ? '' : 's'
2014-02-14 15:23:59 +00:00
));
} else if (key == 'keyword') {
key = 'keywords'
2013-02-25 18:21:11 +00:00
}
2017-01-25 20:49:10 +00:00
var value = Ox.toTitleCase(key)
.replace(' Of ', ' of ')
.replace(' Per ', ' per ')
return mode == 'text'
2017-01-25 20:49:10 +00:00
? '<span style="font-weight: bold">' + value + ':</span> '
: mode == 'description'
2017-01-25 20:49:10 +00:00
? value
: mode == 'link'
? Ox.Element()
.css({marginBottom: '4px', fontWeight: 'bold'})
.html('<a href="' + link + '">' + value + '</a>')
: Ox.Element()
.css({marginBottom: '4px', fontWeight: 'bold'})
2017-01-25 20:49:10 +00:00
.html(value);
2013-02-18 12:53:05 +00:00
}
function formatLight(str) {
2013-02-25 16:38:22 +00:00
return '<span class="OxLight">' + str + '</span>';
2013-02-18 12:53:05 +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) {
return key
2013-07-11 12:38:19 +00:00
? '<a href="/' + (
key == 'alternativeTitles' ? 'title' : key
) + '=' + pandora.escapeQueryValue(linkValue[idx]) + '">' + value + '</a>'
: value;
}).join(Ox.contains(specialListKeys, key) ? '; ' : ', ');
}
2013-02-18 12:53:05 +00:00
function formatTitle(title) {
var match = /(.+) (\(S\d{2}(E\d{2})?\))/.exec(title);
2013-02-18 12:53:05 +00:00
if (match) {
title = formatLink(match[1], 'title') + ' '
2013-02-18 12:53:05 +00:00
+ formatLight(match[2])
+ title.substr(match[0].length);
}
return title + (
data.originalTitle && data.originalTitle != title
? ' ' + formatLight('(' + data.originalTitle + ')') : ''
);
}
function formatValue(key, value) {
var ret;
2019-06-12 08:22:01 +00:00
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key)
if (key == 'year') {
2013-03-12 08:33:55 +00:00
ret = formatLink(value, 'year');
} else if (
2019-06-12 08:22:01 +00:00
specialListKeys.indexOf(key) > -1 && itemKey && itemKey.type[0] == 'date'
) {
ret = value.split('; ').map(function(date) {
2019-11-12 17:50:24 +00:00
date = pandora.cleanupDate(date)
return date ? formatLink(Ox.formatDate(date,
['', '%Y', '%B %Y', '%B %e, %Y'][date.split('-').length],
true
), key, date) : '';
}).join('; ');
} else if (['releasedate'].indexOf(key) > -1) {
2019-11-12 17:50:24 +00:00
value = pandora.cleanupDate(value);
2017-03-04 11:05:14 +00:00
ret = value ? Ox.formatDate(value,
['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length],
true
) : '';
2013-12-26 08:35:41 +00:00
} else if (key == 'links') {
ret = value.split(', ').map(function(link) {
return '<a href="' + link + '">' + Ox.parseURL(link).host + '</a>';
}).join(', ');
2013-03-12 02:13:22 +00:00
} else if (nameKeys.indexOf(key) > -1) {
ret = formatLink(value.split(', '), 'name');
} else if (listKeys.indexOf(key) > -1) {
ret = formatLink(value.split(', '), key);
} else if (specialListKeys.indexOf(key) > -1) {
ret = formatLink(
Ox.decodeHTMLEntities(value).split('; ').map(Ox.encodeHTMLEntities),
2013-07-11 12:38:19 +00:00
key
);
2013-02-27 10:46:02 +00:00
} else if (key == 'imdbId') {
ret = '<a href="http://www.imdb.com/title/tt'
+ value + '">' + value + '</a>';
} else if (key == 'encyclopedia') {
ret = '<a href="/texts/indiancine.ma:Encyclopedia%20of%20Indian%20Cinema/'
+ (value == 'Summary' ? '240' : '570') + '">'
+ value + '</a>';
} else if (key == 'wiki') {
2014-02-02 05:06:15 +00:00
ret = '<a href="' + value + '">'
2014-02-05 06:33:09 +00:00
+ Ox.decodeURIComponent(value.split('wiki/').pop()) + '</a>';
} else {
ret = value;
}
return ret;
}
2013-03-14 07:19:04 +00:00
function getFilmography(key, value, roles, callback) {
var keys = ['id', 'title', 'year'].concat(
key == 'name' ? nameKeys : []
);
pandora.api.find({
keys: keys,
query: {
conditions: [{key: key, operator: '==', value: value}],
operator: '&'
},
sort: [
{key: 'year', operator: '+'},
{key: 'title', operator: '+'},
{key: 'director', operator: '+'}
],
range: [0, 1000000]
}, function(result) {
var $element = Ox.Element('<span>'),
items = {};
if (result.data.items) {
result.data.items.forEach(function(item) {
2014-02-17 14:40:15 +00:00
var year = item.year || Ox._('Unknown Year');
2013-03-14 08:45:16 +00:00
if (key == 'name' && result.data.items.length > 1) {
2013-03-14 07:19:04 +00:00
item.roles = nameKeys.filter(function(nameKey) {
2015-05-25 12:51:11 +00:00
return item[nameKey] && Ox.contains(item[nameKey], value);
});
2013-03-14 07:19:04 +00:00
if (roles.length == 1 && Ox.isEqual(item.roles, roles)) {
delete item.roles;
} else {
item.roles = item.roles.map(function(nameKey) {
return Ox.getObjectById(pandora.site.itemKeys, nameKey).title;
});
}
}
if (!items[year]) {
items[year] = [];
}
items[year].push(item);
});
}
$element.html(
Object.keys(items).sort().map(function(year) {
return '<b>' + year + ':</b> ' + items[year].map(function(item) {
return '<a href="/' + item.id + '">' + item.title + '</a>'
2013-03-14 07:19:04 +00:00
+ (item.roles ? ' (' + item.roles.join(', ') + ')' : '');
}).join(', ');
}).join(', ')
);
pandora.createLinks($element);
callback($element);
});
}
function getNames() {
var names = [];
nameKeys.forEach(function(key) {
data[key] && data[key].forEach(function(name) {
var index = Ox.indexOf(names, function(value) {
return value.name == name;
});
if (index == -1) {
names.push({
name: name,
keys: [key],
description: data.namedescription
? data.namedescription[name]
: void 0
});
} else {
names[index].keys.push(key);
}
});
});
return names;
2013-02-18 12:53:05 +00:00
}
function getRightsLevelElement(rightsLevel) {
return Ox.Theme.formatColorLevel(
rightsLevel,
pandora.site.rightsLevels.map(function(rightsLevel) {
2014-02-13 16:24:52 +00:00
return Ox._(rightsLevel.name);
2013-02-18 12:53:05 +00:00
})
);
}
function getStudios() {
var studios = [];
if (data.productionCompany) {
data.productionCompany.forEach(function(studio) {
studios.push({
name: studio,
keys: ['productionCompany'],
description: data.productionCompanydescription
? data.productionCompanydescription[studio]
: void 0
});
});
}
return studios;
}
function getValue(key, value) {
return !value ? ''
: key == 'alternativeTitles' ? value.map(function(value) {
return value[0];
}).join('; ')
: key == 'runtime' ? Math.round(value / 60)
2019-06-11 16:43:44 +00:00
: Ox.contains(listKeys, key) && value.join ? value.join(', ')
: Ox.contains(specialListKeys, key) && value.join ? value.join('; ')
: value;
}
2013-02-18 12:53:05 +00:00
function renderCapabilities(rightsLevel) {
var capabilities = [].concat(
canEdit ? [{name: 'canSeeItem', symbol: 'Find'}] : [],
[
{name: 'canPlayClips', symbol: 'PlayInToOut'},
{name: 'canPlayVideo', symbol: 'Play'},
{name: 'canDownloadVideo', symbol: 'Download'}
]
),
userLevels = canEdit ? pandora.site.userLevels : [pandora.user.level];
$capabilities.empty();
userLevels.forEach(function(userLevel, i) {
var $element,
$line = $('<div>')
.css({
height: '16px',
marginBottom: '4px'
})
.appendTo($capabilities);
if (canEdit) {
$element = Ox.Theme.formatColorLevel(i, userLevels.map(function(userLevel) {
2014-02-13 16:24:52 +00:00
return Ox._(Ox.toTitleCase(userLevel));
2013-02-18 12:53:05 +00:00
}), [0, 240]);
Ox.Label({
textAlign: 'center',
2014-02-13 16:24:52 +00:00
title: Ox._(Ox.toTitleCase(userLevel)),
2013-02-18 12:53:05 +00:00
width: 60
})
.addClass('OxColor OxColorGradient')
.css({
float: 'left',
height: '12px',
paddingTop: '2px',
background: $element.css('background'),
fontSize: '8px',
color: $element.css('color')
})
.data({OxColor: $element.data('OxColor')})
.appendTo($line);
}
capabilities.forEach(function(capability) {
2017-11-04 09:53:27 +00:00
var hasCapability = pandora.hasCapability(capability.name, userLevel) >= rightsLevel,
2013-02-18 12:53:05 +00:00
$element = Ox.Theme.formatColorLevel(hasCapability, ['', '']);
Ox.Button({
2014-02-14 15:23:59 +00:00
tooltip: Ox._('{0} '
2013-02-18 12:53:05 +00:00
+ (hasCapability ? 'can' : 'can\'t') + ' '
+ Ox.toSlashes(capability.name)
.split('/').slice(1).join(' ')
.toLowerCase()
.replace('see item', 'see the item')
.replace('play video', 'play the full video')
2014-02-14 15:23:59 +00:00
.replace('download video', 'download the video'),
2014-02-17 14:40:15 +00:00
[canEdit ? Ox._(Ox.toTitleCase(userLevel)) : Ox._('You')]),
2013-02-18 12:53:05 +00:00
title: capability.symbol,
type: 'image'
})
.addClass('OxColor OxColorGradient')
.css({background: $element.css('background')})
.css('margin' + (canEdit ? 'Left' : 'Right'), '4px')
.data({OxColor: $element.data('OxColor')})
.appendTo($line);
});
if (!canEdit) {
Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Help'),
tooltip: Ox._('About Rights'),
2013-02-18 12:53:05 +00:00
type: 'image'
})
.css({marginLeft: '52px'})
.bindEvent({
click: function() {
2016-11-30 10:07:09 +00:00
pandora.UI.set({page: 'copyrights'});
2013-02-18 12:53:05 +00:00
}
})
.appendTo($line);
}
});
}
function renderDescriptions() {
$descriptions.empty();
['studios', 'names'].forEach(function(key) {
descriptions[key].forEach(function(value) {
if (canEdit || value.description) {
2013-05-09 10:13:58 +00:00
var filmography = key == 'studios' ? Ox._('Films') : Ox._('Filmography'),
$name = Ox.Element()
.addClass('OxSelectable')
.css(css)
.css({marginTop: '12px', fontWeight: 'bold'})
.html(
formatLink(
value.name,
key == 'studios' ? 'productionCompany' : 'name'
) + ' (' + value.keys.map(function(key) {
return formatKey(key, 'description');
}).join(', ') + ') -&nbsp;'
)
.appendTo($descriptions),
$link = $('<span>')
.addClass('OxLink')
.css({fontWeight: 'bold'})
2013-05-09 10:13:58 +00:00
.html(Ox._('Show {0}', [filmography]))
.one({
click: function() {
$link.removeClass('OxLink')
2013-05-09 10:13:58 +00:00
.html(Ox._('Loading {0}...', [filmography]));
getFilmography(
key == 'studios' ? 'productionCompany' : 'name',
Ox.decodeHTMLEntities(value.name),
2013-03-14 07:19:04 +00:00
value.keys,
function($element) {
$link.addClass('OxLink')
2013-05-09 10:13:58 +00:00
.html(Ox._('Hide {0}', [filmography]))
.on({
click: function() {
2013-05-09 10:13:58 +00:00
if (Ox.startsWith($link.html(), Ox._('Show'))) {
$link.html(Ox._('Hide {0}', [filmography]));
$text.show();
} else {
2013-05-09 10:13:58 +00:00
$link.html(Ox._('Show {0}', [filmography]));
$text.hide();
}
}
});
$text.append($element).show();
}
);
}
})
.appendTo($name),
$text = $('<div>')
.addClass('OxSelectable')
.css(css)
.hide()
.appendTo($descriptions);
pandora.createLinks($name);
Ox.EditableContent({
clickLink: pandora.clickLink,
editable: canEdit,
format: function(value) {
return value.replace(
/<img /g,
'<img style="max-width: 256px; max-height: 256px; margin: 0 16px 16px 0; float: left;" '
);
},
2013-05-09 10:13:58 +00:00
placeholder: formatLight(Ox._('No Description')),
tooltip: canEdit ? pandora.getEditTooltip() : '',
type: 'textarea',
value: value.description || ''
})
.css(css)
2013-03-13 09:13:42 +00:00
.css({
overflow: 'hidden'
2013-03-13 09:13:42 +00:00
})
.bindEvent({
submit: function(data) {
editMetadata(
key == 'studios'
? 'productionCompanydescription'
: 'namedescription',
Ox.extend({}, value.name, data.value)
);
}
})
.appendTo($descriptions);
}
});
});
}
function renderGroup(keys) {
var $element;
if (canEdit || keys.filter(function(key) {
return data[key];
}).length) {
$element = $('<div>').addClass('OxSelectable').css(css);
keys.forEach(function(key, i) {
if (canEdit || data[key]) {
if ($element.children().length) {
$('<span>').html('; ').appendTo($element);
}
2013-02-27 10:46:02 +00:00
if (key == 'alternativeTitles') {
$alternativeTitles = $('<span>')
.html(formatKey(key))
.appendTo($element);
} else {
$('<span>')
.html(formatKey(key))
.appendTo($element);
}
Ox.EditableContent({
clickLink: pandora.clickLink,
format: function(value) {
return formatValue(key, value);
},
2018-09-18 21:17:32 +00:00
placeholder: formatLight(Ox._(isMixed[key] ? 'mixed': 'unknown')),
tooltip: canEdit ? pandora.getEditTooltip() : '',
value: getValue(key, data[key])
})
.bindEvent({
2013-02-27 10:46:02 +00:00
edit: function() {
key == 'runtime' && $minutes.show();
},
submit: function(data) {
2014-02-02 05:06:15 +00:00
if (key == 'encyclopedia') {
data.value = ['Index', 'Summary'].indexOf(data.value) > -1
? data.value
: '';
this.options({
value: data.value
});
}
editMetadata(key, data.value);
}
})
.appendTo($element);
if (key == 'runtime') {
2013-02-27 10:46:02 +00:00
$minutes = $('<span>')
.html('&nbsp;min')
[data.runtime ? 'show' : 'hide']()
.appendTo($element);
2013-02-27 15:54:13 +00:00
} else if (key == 'imdbId') {
$imdb = Ox.Element('<span>')
2013-02-27 15:54:13 +00:00
.appendTo($element);
2013-02-28 08:39:37 +00:00
pandora.createLinks($imdb);
}
}
});
$element.appendTo($text);
}
2017-01-25 20:49:10 +00:00
return $element;
}
2013-02-18 12:53:05 +00:00
function renderRightsLevel() {
var $rightsLevelElement = getRightsLevelElement(data.rightslevel),
$rightsLevelSelect;
$rightsLevel.empty();
if (canEdit) {
$rightsLevelSelect = Ox.Select({
items: pandora.site.rightsLevels.map(function(rightsLevel, i) {
return {
id: i,
2014-02-13 16:24:52 +00:00
title: Ox._(rightsLevel.name),
disabled: !isCopyrighted && rightsLevel.name == 'Under Copyright'
|| isCopyrighted && rightsLevel.name == 'Out of Copyright'
};
2013-02-18 12:53:05 +00:00
}),
width: 128,
value: data.rightslevel
})
.addClass('OxColor OxColorGradient')
.css({
marginBottom: '4px',
background: $rightsLevelElement.css('background')
})
.data({OxColor: $rightsLevelElement.data('OxColor')})
.bindEvent({
change: function(event) {
var rightsLevel = event.value;
$rightsLevelElement = getRightsLevelElement(rightsLevel);
$rightsLevelSelect
.css({background: $rightsLevelElement.css('background')})
.data({OxColor: $rightsLevelElement.data('OxColor')})
2017-01-25 20:49:10 +00:00
// renderCapabilities(rightsLevel);
2018-09-18 21:17:32 +00:00
var edit = {
id: isMultiple ? ui.listSelection : data.id,
rightslevel: rightsLevel
};
pandora.api.edit(edit, function(result) {
that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel));
2013-02-18 12:53:05 +00:00
});
}
})
.appendTo($rightsLevel);
} else {
$rightsLevelElement
.css({
marginBottom: '4px'
})
.appendTo($rightsLevel);
}
2017-01-25 20:49:10 +00:00
/*
2016-11-30 10:07:09 +00:00
if (data.parts) {
$capabilities = $('<div>').appendTo($rightsLevel);
renderCapabilities(data.rightslevel);
}
2017-01-25 20:49:10 +00:00
*/
2013-02-18 12:53:05 +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,
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8;
$icon.animate({
left: margin + iconLeft + 'px',
width: iconWidth + 'px',
height: iconHeight + 'px',
borderRadius: borderRadius + 'px'
}, 250);
$reflection.animate({
top: margin + iconHeight + 'px',
width: iconSize + 'px',
height: iconSize / 2 + 'px'
}, 250);
$reflectionIcon.animate({
left: iconLeft + 'px',
width: iconWidth + 'px',
height: iconHeight + 'px',
borderRadius: borderRadius + 'px'
}, 250);
$reflectionGradient.animate({
width: iconSize + 'px',
height: iconSize / 2 + 'px'
}, 250);
$text.animate({
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px'
}, 250);
pandora.UI.set({infoIconSize: iconSize});
}
2013-02-27 15:54:13 +00:00
function updateIMDb() {
if (data.imdbId) {
pandora.api.find({
query: {
2013-03-05 14:53:52 +00:00
conditions: [{key: 'imdbId', operator: '==', value: data.imdbId}]
2013-02-27 15:54:13 +00:00
}
}, function(result) {
if (result.data.items == 1) {
$imdb.empty();
} else {
$imdb.html(
'&nbsp;(<a href="/imdbId=' + data.imdbId + '">'
2013-02-27 16:08:01 +00:00
+ result.data.items + ' '
+ pandora.site.itemName.plural.toLowerCase()
2013-08-01 16:45:30 +00:00
+ '</a> ' + Ox._('with the same IMDb ID') + '</a>)'
2013-02-27 15:54:13 +00:00
);
}
});
} else {
$imdb.empty();
}
}
2013-02-18 12:53:05 +00:00
that.reload = function() {
var src = pandora.getMediaURL('/' + data.id + '/' + (
2013-07-11 12:38:19 +00:00
ui.icons == 'posters' ? 'poster' : 'icon'
) + '512.jpg?' + Ox.uid());
2013-02-18 12:53:05 +00:00
$icon.attr({src: src});
$reflectionIcon.attr({src: src});
iconSize = iconSize == 256 ? 512 : 256;
iconRatio = ui.icons == 'posters'
? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1;
2013-02-18 12:53:05 +00:00
toggleIconSize();
};
2014-10-07 10:29:41 +00:00
that.resizeElement = function() {
// overwrite splitpanel resize
};
2013-02-18 12:53:05 +00:00
that.bindEvent({
mousedown: function() {
setTimeout(function() {
!Ox.Focus.focusedElementIsInput() && that.gainFocus();
});
},
2013-02-18 12:53:05 +00:00
pandora_icons: that.reload,
pandora_showsiteposters: function() {
ui.icons == 'posters' && that.reload();
}
});
return that;
2013-02-25 16:38:22 +00:00
};