2012-04-20 10:36:42 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
pandora.ui.infoView = function(data) {
|
|
|
|
|
|
|
|
|
|
// fixme: given that currently, the info view doesn't scroll into view nicely
|
|
|
|
|
// when collapsing the movies browser, the info view should become a split panel
|
|
|
|
|
|
|
|
|
|
var ui = pandora.user.ui,
|
|
|
|
|
canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level],
|
2013-07-08 08:56:39 +00:00
|
|
|
|
canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level],
|
2013-03-07 10:46:16 +00:00
|
|
|
|
canSeeAllMetadata = pandora.user.level != 'guest',
|
2012-04-20 10:36:42 +00:00
|
|
|
|
css = {
|
|
|
|
|
marginTop: '4px',
|
2013-07-19 09:34:01 +00:00
|
|
|
|
textAlign: 'justify'
|
2012-04-20 10:36:42 +00:00
|
|
|
|
},
|
2013-05-09 12:03:26 +00:00
|
|
|
|
iconRatio = ui.icons == 'posters' ? (
|
2013-07-08 12:40:23 +00:00
|
|
|
|
ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio
|
2013-05-09 12:03:26 +00:00
|
|
|
|
) : 1,
|
2012-04-20 10:36:42 +00:00
|
|
|
|
iconSize = ui.infoIconSize,
|
|
|
|
|
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,
|
2012-05-24 09:56:52 +00:00
|
|
|
|
isEditable = canEdit && data.id.slice(0, 2) == '0x',
|
2014-09-26 12:12:25 +00:00
|
|
|
|
listWidth = 144 + Ox.UI.SCROLLBAR_SIZE,
|
2012-04-20 10:36:42 +00:00
|
|
|
|
margin = 16,
|
|
|
|
|
statisticsWidth = 128,
|
|
|
|
|
|
2013-07-08 08:56:39 +00:00
|
|
|
|
$bar = Ox.Bar({size: 16})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
doubleclick: function(e) {
|
2013-07-08 11:28:30 +00:00
|
|
|
|
if ($(e.target).is('.OxBar')) {
|
2013-07-08 08:56:39 +00:00
|
|
|
|
$data.animate({scrollTop: 0}, 250);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
$options = Ox.MenuButton({
|
|
|
|
|
items: [
|
|
|
|
|
{
|
|
|
|
|
id: 'update',
|
|
|
|
|
title: Ox._('Update Metadata'),
|
|
|
|
|
disabled: !canEdit || isEditable
|
|
|
|
|
},
|
|
|
|
|
{},
|
|
|
|
|
{
|
|
|
|
|
id: 'delete',
|
|
|
|
|
title: Ox._('Delete {0}...', [pandora.site.itemName.singular]),
|
|
|
|
|
disabled: !canRemove
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
style: 'square',
|
|
|
|
|
title: 'set',
|
|
|
|
|
tooltip: Ox._('Options'),
|
|
|
|
|
type: 'image',
|
|
|
|
|
})
|
|
|
|
|
.css({
|
|
|
|
|
float: 'left',
|
|
|
|
|
borderColor: 'rgba(0, 0, 0, 0)',
|
|
|
|
|
background: 'rgba(0, 0, 0, 0)'
|
|
|
|
|
})
|
|
|
|
|
.bindEvent({
|
2013-08-01 11:04:12 +00:00
|
|
|
|
click: function(data_) {
|
|
|
|
|
if (data_.id == 'update') {
|
2013-07-08 08:56:39 +00:00
|
|
|
|
updateMetadata();
|
2013-08-01 11:04:12 +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-08 08:56:39 +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)'
|
|
|
|
|
})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
click: function(data) {
|
|
|
|
|
// ...
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($bar),
|
|
|
|
|
|
|
|
|
|
$main = Ox.Element(),
|
|
|
|
|
|
|
|
|
|
that = Ox.SplitPanel({
|
|
|
|
|
elements: [
|
|
|
|
|
{element: $bar, size: 16},
|
|
|
|
|
{element: $main}
|
|
|
|
|
],
|
|
|
|
|
orientation: 'vertical'
|
|
|
|
|
}),
|
2012-04-20 10:36:42 +00:00
|
|
|
|
|
|
|
|
|
$list,
|
|
|
|
|
|
|
|
|
|
$info = $('<div>')
|
|
|
|
|
.css({
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
left: canEdit && !ui.showIconBrowser ? -listWidth + 'px' : 0,
|
|
|
|
|
top: 0,
|
2012-05-26 15:46:24 +00:00
|
|
|
|
right: 0
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
2013-07-08 08:56:39 +00:00
|
|
|
|
.appendTo($main),
|
2012-04-20 10:36:42 +00:00
|
|
|
|
|
|
|
|
|
$data = Ox.Container()
|
|
|
|
|
.css({
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
left: (canEdit ? listWidth : 0) + 'px',
|
|
|
|
|
top: 0,
|
|
|
|
|
right: 0,
|
2013-07-11 12:38:19 +00:00
|
|
|
|
height: getHeight() + 'px'
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($info),
|
|
|
|
|
|
|
|
|
|
$icon = Ox.Element({
|
|
|
|
|
element: '<img>',
|
|
|
|
|
tooltip: canEdit ? (
|
|
|
|
|
!ui.showIconBrowser
|
2013-05-09 10:13:58 +00:00
|
|
|
|
? Ox._('Doubleclick to edit icon')
|
|
|
|
|
: Ox._('Doubleclick to hide icons')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
) : ''
|
|
|
|
|
})
|
|
|
|
|
.attr({
|
2014-02-02 11:30:25 +00:00
|
|
|
|
src: pandora.getMediaURL('/' + data.id + '/' + (
|
2012-04-20 10:36:42 +00:00
|
|
|
|
ui.icons == 'posters'
|
|
|
|
|
? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon'
|
2014-02-02 11:30:25 +00:00
|
|
|
|
) + '512.jpg?' + data.modified)
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.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($data.$element),
|
|
|
|
|
|
|
|
|
|
$reflection = $('<div>')
|
|
|
|
|
.addClass('OxReflection')
|
|
|
|
|
.css({
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
left: margin + 'px',
|
|
|
|
|
top: margin + iconHeight + 'px',
|
|
|
|
|
width: iconSize + 'px',
|
2013-05-09 12:03:26 +00:00
|
|
|
|
height: Math.round(iconSize / 2) + 'px',
|
2012-04-20 10:36:42 +00:00
|
|
|
|
overflow: 'hidden'
|
|
|
|
|
})
|
|
|
|
|
.appendTo($data.$element),
|
|
|
|
|
|
|
|
|
|
$reflectionIcon = $('<img>')
|
|
|
|
|
.attr({
|
2014-02-02 11:30:25 +00:00
|
|
|
|
src: pandora.getMediaURL('/' + data.id + '/' + (
|
2012-04-20 10:36:42 +00:00
|
|
|
|
ui.icons == 'posters'
|
|
|
|
|
? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon'
|
2014-02-02 11:30:25 +00:00
|
|
|
|
) + '512.jpg?' + data.modified)
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.css({
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
left: iconLeft + 'px',
|
|
|
|
|
width: iconWidth + 'px',
|
|
|
|
|
height: iconHeight + 'px',
|
|
|
|
|
borderRadius: borderRadius + 'px'
|
|
|
|
|
})
|
|
|
|
|
.appendTo($reflection),
|
|
|
|
|
|
|
|
|
|
$reflectionGradient = $('<div>')
|
|
|
|
|
.css({
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
width: iconSize + 'px',
|
2013-05-09 12:03:26 +00:00
|
|
|
|
height: Math.round(iconSize / 2) + 'px'
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($reflection),
|
|
|
|
|
|
2012-10-10 08:15:30 +00:00
|
|
|
|
$text = Ox.Element()
|
2013-03-08 03:49:55 +00:00
|
|
|
|
.addClass('OxTextPage')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css({
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
|
|
|
|
|
top: margin + 'px',
|
2012-05-26 15:46:24 +00:00
|
|
|
|
right: margin + statisticsWidth + margin + 'px'
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($data.$element),
|
|
|
|
|
|
|
|
|
|
$statistics = $('<div>')
|
|
|
|
|
.css({
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
width: statisticsWidth + 'px',
|
|
|
|
|
top: margin + 'px',
|
|
|
|
|
right: margin + 'px'
|
|
|
|
|
})
|
|
|
|
|
.appendTo($data.$element),
|
|
|
|
|
|
2012-10-10 08:15:30 +00:00
|
|
|
|
$reloadButton,
|
|
|
|
|
|
2012-04-20 10:36:42 +00:00
|
|
|
|
$capabilities,
|
|
|
|
|
|
|
|
|
|
$browserImages = [];
|
|
|
|
|
|
2013-07-08 08:56:39 +00:00
|
|
|
|
[$options, $edit].forEach(function($element) {
|
|
|
|
|
$element.find('input').css({
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
borderRadius: 0,
|
|
|
|
|
padding: '3px'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2013-07-09 14:43:11 +00:00
|
|
|
|
pandora.createLinks($text);
|
2012-04-20 10:36:42 +00:00
|
|
|
|
|
|
|
|
|
// Title -------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({
|
|
|
|
|
marginTop: '-2px'
|
|
|
|
|
})
|
|
|
|
|
.append(
|
2013-05-09 12:03:26 +00:00
|
|
|
|
Ox.EditableContent({
|
2012-09-25 10:52:33 +00:00
|
|
|
|
clickLink: pandora.clickLink,
|
2012-04-20 10:36:42 +00:00
|
|
|
|
editable: isEditable,
|
|
|
|
|
format: function(value) {
|
|
|
|
|
return formatTitle(value);
|
|
|
|
|
},
|
2013-03-01 03:51:39 +00:00
|
|
|
|
tooltip: isEditable ? pandora.getEditTooltip() : '',
|
2012-04-20 10:36:42 +00:00
|
|
|
|
value: data.title
|
|
|
|
|
})
|
|
|
|
|
.css({
|
|
|
|
|
marginBottom: '-3px',
|
|
|
|
|
fontWeight: 'bold',
|
2013-07-19 09:34:01 +00:00
|
|
|
|
fontSize: '13px'
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
submit: function(event) {
|
|
|
|
|
editMetadata('title', event.value);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
|
|
|
|
|
// Director ----------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
if (data.director || isEditable) {
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({
|
|
|
|
|
marginTop: '2px'
|
|
|
|
|
})
|
|
|
|
|
.append(
|
2013-05-09 12:03:26 +00:00
|
|
|
|
Ox.EditableContent({
|
2012-04-20 10:36:42 +00:00
|
|
|
|
clickLink: pandora.clickLink,
|
|
|
|
|
editable: isEditable,
|
|
|
|
|
format: function(value) {
|
|
|
|
|
return formatValue(value.split(', '), 'name');
|
|
|
|
|
},
|
2013-05-09 10:13:58 +00:00
|
|
|
|
placeholder: formatLight(Ox._('Unknown Director')),
|
2013-03-01 03:51:39 +00:00
|
|
|
|
tooltip: isEditable ? pandora.getEditTooltip() : '',
|
2013-02-25 16:38:03 +00:00
|
|
|
|
value: data.director ? data.director.join(', ') : ''
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.css({
|
|
|
|
|
marginBottom: '-3px',
|
|
|
|
|
fontWeight: 'bold',
|
2013-07-19 09:34:01 +00:00
|
|
|
|
fontSize: '13px'
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
submit: function(event) {
|
|
|
|
|
editMetadata('director', event.value);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-08 13:27:38 +00:00
|
|
|
|
// Country, Year, Language, Runtime, Color, Sound --------------------------
|
2012-04-20 10:36:42 +00:00
|
|
|
|
|
|
|
|
|
if (isEditable) {
|
|
|
|
|
var $div = $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css(css)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
['country', 'year'].forEach(function(key, i) {
|
|
|
|
|
i && $('<div>').css({float: 'left'}).html('; ').appendTo($div);
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({float: 'left'})
|
|
|
|
|
.html(formatKey(key).replace('</span>', ' </span>'))
|
|
|
|
|
.appendTo($div);
|
2013-05-09 12:03:26 +00:00
|
|
|
|
Ox.EditableContent({
|
2012-04-20 10:36:42 +00:00
|
|
|
|
clickLink: pandora.clickLink,
|
|
|
|
|
format: function(value) {
|
|
|
|
|
return formatValue(value.split(', '), key)
|
|
|
|
|
},
|
|
|
|
|
placeholder: formatLight('unknown'),
|
2013-03-01 03:51:39 +00:00
|
|
|
|
tooltip: pandora.getEditTooltip(),
|
2012-04-20 10:36:42 +00:00
|
|
|
|
value: key == 'country'
|
|
|
|
|
? (data[key] ? data[key].join(', ') : [''])
|
|
|
|
|
: data[key] || ''
|
|
|
|
|
})
|
|
|
|
|
.css({float: 'left'})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
submit: function(event) {
|
|
|
|
|
editMetadata(key, event.value);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($div);
|
|
|
|
|
});
|
2013-07-08 13:27:38 +00:00
|
|
|
|
} else if (data.country || data.year || data.language || data.runtime || data.color || data.sound) {
|
2012-04-20 10:36:42 +00:00
|
|
|
|
var html = [];
|
2013-07-08 13:27:38 +00:00
|
|
|
|
['country', 'year', 'language', 'runtime', 'color', 'sound'].forEach(function(key) {
|
2012-04-20 10:36:42 +00:00
|
|
|
|
if (data[key]) {
|
|
|
|
|
html.push(
|
|
|
|
|
formatKey(key) + (
|
|
|
|
|
key != 'runtime' ? formatValue(data[key], key)
|
2012-09-24 11:18:47 +00:00
|
|
|
|
: data[key] < 60 ? Math.round(data[key]) + ' sec'
|
|
|
|
|
: Math.round(data[key] / 60) + ' min'
|
2012-04-20 10:36:42 +00:00
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-07-19 09:34:01 +00:00
|
|
|
|
$('<div>')
|
|
|
|
|
.addClass('OxSelectable')
|
|
|
|
|
.css(css)
|
|
|
|
|
.html(html.join('; '))
|
|
|
|
|
.appendTo($text);
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Alternative Titles ------------------------------------------------------
|
|
|
|
|
|
2013-02-22 18:39:33 +00:00
|
|
|
|
// FIXME: This should be an array of objects {title: '', info: ''}
|
2012-04-20 10:36:42 +00:00
|
|
|
|
data.alternativeTitles && $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css(css)
|
|
|
|
|
.html(
|
2013-05-31 17:22:27 +00:00
|
|
|
|
formatKey('Alternative Title' + (data.alternativeTitles.length == 1 ? '' : 's'))
|
2012-04-20 10:36:42 +00:00
|
|
|
|
+ data.alternativeTitles.map(function(value) {
|
2013-03-07 10:46:16 +00:00
|
|
|
|
return value[0] + (
|
2015-05-04 08:55:47 +00:00
|
|
|
|
canSeeAllMetadata && Ox.isArray(value[1]) && value[1].length
|
2013-03-07 10:46:16 +00:00
|
|
|
|
? ' ' + formatLight('(' + value[1].join(', ') + ')')
|
|
|
|
|
: ''
|
|
|
|
|
);
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}).join(', ')
|
|
|
|
|
)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
|
2012-09-15 11:21:29 +00:00
|
|
|
|
// FIXME: we will want to check for data.seriesId here
|
|
|
|
|
if (isEditable && data.seriesTitle) {
|
|
|
|
|
var $div = $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2013-02-25 16:38:03 +00:00
|
|
|
|
// FIXME: Don't extend!
|
2012-09-15 11:21:29 +00:00
|
|
|
|
.css(Ox.extend(css, {marginTop: '20px'})) // FIXME: just a guess
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
['episodeDirector', 'seriesYear'].forEach(function(key, i) {
|
|
|
|
|
i && $('<div>').css({float: 'left'}).html('; ').appendTo($div);
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({float: 'left'})
|
|
|
|
|
.html(formatKey(Ox.toUnderscores(key).replace(/_/g, ' ')).replace('</span>', ' </span>'))
|
|
|
|
|
.appendTo($div);
|
|
|
|
|
Ox.Editable({
|
|
|
|
|
clickLink: pandora.clickLink,
|
|
|
|
|
format: function(value) {
|
2013-07-27 19:29:32 +00:00
|
|
|
|
return formatValue(
|
|
|
|
|
value.split(', '),
|
|
|
|
|
key == 'episodeDirector' ? 'name' : 'year'
|
|
|
|
|
);
|
2012-09-15 11:21:29 +00:00
|
|
|
|
},
|
|
|
|
|
placeholder: formatLight('unknown'),
|
2013-03-01 03:51:39 +00:00
|
|
|
|
tooltip: pandora.getEditTooltip(),
|
2012-09-15 11:21:29 +00:00
|
|
|
|
value: key == 'episodeDirector'
|
|
|
|
|
? (data[key] ? data[key].join(', ') : [''])
|
|
|
|
|
: data[key] || ''
|
|
|
|
|
})
|
|
|
|
|
.css({float: 'left'})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
submit: function(event) {
|
|
|
|
|
editMetadata(key, event.value);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($div);
|
|
|
|
|
});
|
|
|
|
|
} else if (data.episodeDirector || data.writer || data.producer || data.cinematographer || data.editor) {
|
2012-04-20 10:36:42 +00:00
|
|
|
|
$div = $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css(css)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
html = [];
|
|
|
|
|
['episodeDirector', 'writer', 'producer', 'cinematographer', 'editor'].forEach(function(key) {
|
|
|
|
|
data[key] && html.push(
|
|
|
|
|
formatKey(key == 'episodeDirector' ? 'director' : key) + formatValue(data[key], 'name')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
$div.html(html.join('; '));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.cast && $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css(css)
|
|
|
|
|
.html(
|
|
|
|
|
formatKey('cast') + data.cast.map(function(value) {
|
2012-09-25 10:52:33 +00:00
|
|
|
|
// FIXME: 'uncredited' should be removed on the backend
|
2012-04-20 10:36:42 +00:00
|
|
|
|
value.character = value.character.replace('(uncredited)', '').trim();
|
|
|
|
|
return formatValue(value.actor, 'name')
|
2013-03-07 10:46:16 +00:00
|
|
|
|
+ (
|
|
|
|
|
canSeeAllMetadata && value.character
|
2013-07-11 12:38:19 +00:00
|
|
|
|
? ' ' + formatLight('(' + value.character + ')')
|
2013-03-07 10:46:16 +00:00
|
|
|
|
: ''
|
|
|
|
|
);
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}).join(', ')
|
|
|
|
|
)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
|
2013-08-01 14:56:37 +00:00
|
|
|
|
if (data.productionCompany && canSeeAllMetadata) {
|
|
|
|
|
$('<div>')
|
|
|
|
|
.addClass('OxSelectable')
|
|
|
|
|
.css(css)
|
|
|
|
|
.html(
|
|
|
|
|
formatKey('studio')
|
|
|
|
|
+ formatValue(data.productionCompany, 'productionCompany')
|
|
|
|
|
)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
}
|
2013-07-08 13:27:38 +00:00
|
|
|
|
|
2013-03-07 10:46:16 +00:00
|
|
|
|
if (data.genre || (data.keyword && canSeeAllMetadata)) {
|
2012-04-20 10:36:42 +00:00
|
|
|
|
$div = $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css(css)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
html = [];
|
2013-03-07 10:46:16 +00:00
|
|
|
|
(canSeeAllMetadata ? ['genre', 'keyword'] : ['genre']).forEach(function(key) {
|
2012-04-20 10:36:42 +00:00
|
|
|
|
data[key] && html.push(
|
|
|
|
|
formatKey(key == 'keyword' ? 'keywords' : key)
|
|
|
|
|
+ formatValue(data[key], key)
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
$div.html(html.join('; '));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.summary && $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css(css)
|
2013-05-09 12:03:26 +00:00
|
|
|
|
.html(formatKey('summary') + data.summary)
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.appendTo($text);
|
|
|
|
|
|
2013-03-07 10:46:16 +00:00
|
|
|
|
if (canSeeAllMetadata) {
|
|
|
|
|
|
|
|
|
|
data.trivia && data.trivia.forEach(function(value) {
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({
|
|
|
|
|
display: 'table-row'
|
|
|
|
|
})
|
|
|
|
|
.append(
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({
|
|
|
|
|
display: 'table-cell',
|
|
|
|
|
width: '12px',
|
|
|
|
|
paddingTop: '4px'
|
|
|
|
|
})
|
|
|
|
|
.html('<span style="font-weight: bold">•</span>')
|
|
|
|
|
)
|
|
|
|
|
.append(
|
|
|
|
|
$('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2013-03-07 10:46:16 +00:00
|
|
|
|
.css({
|
|
|
|
|
display: 'table-cell',
|
|
|
|
|
paddingTop: '4px',
|
2013-07-19 09:34:01 +00:00
|
|
|
|
textAlign: 'justify'
|
2013-03-07 10:46:16 +00:00
|
|
|
|
})
|
|
|
|
|
.html(value)
|
|
|
|
|
)
|
|
|
|
|
.append(
|
|
|
|
|
$('<div>').css({clear: 'both'})
|
|
|
|
|
)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
});
|
2012-10-07 13:25:42 +00:00
|
|
|
|
|
2013-03-07 10:46:16 +00:00
|
|
|
|
data.filmingLocations && $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2012-10-07 13:25:42 +00:00
|
|
|
|
.css(css)
|
2013-03-07 10:46:16 +00:00
|
|
|
|
.html(
|
2013-05-09 10:13:58 +00:00
|
|
|
|
formatKey(Ox._('Filming Locations')) + data.filmingLocations.map(function(location) {
|
2013-03-07 10:46:16 +00:00
|
|
|
|
return '<a href="/map/@' + location + '">' + location + '</a>'
|
2013-06-01 09:00:04 +00:00
|
|
|
|
}).join('; ')
|
2013-03-07 10:46:16 +00:00
|
|
|
|
)
|
2012-10-07 13:25:42 +00:00
|
|
|
|
.appendTo($text);
|
|
|
|
|
|
2013-03-07 10:46:16 +00:00
|
|
|
|
data.releasedate && $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2012-10-04 09:27:06 +00:00
|
|
|
|
.css(css)
|
2013-03-07 10:46:16 +00:00
|
|
|
|
.html(
|
2013-05-09 10:13:58 +00:00
|
|
|
|
formatKey(Ox._('Release Date')) + Ox.formatDate(data.releasedate, '%A, %B %e, %Y')
|
2013-03-07 10:46:16 +00:00
|
|
|
|
)
|
2012-10-04 09:27:06 +00:00
|
|
|
|
.appendTo($text);
|
2013-03-07 10:46:16 +00:00
|
|
|
|
|
|
|
|
|
if (data.budget || data.gross || data.profit) {
|
|
|
|
|
$div = $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2013-03-07 10:46:16 +00:00
|
|
|
|
.css(css)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
html = [];
|
|
|
|
|
['budget', 'gross', 'profit'].forEach(function(key) {
|
|
|
|
|
data[key] && html.push(
|
|
|
|
|
formatKey(key == 'profit' && data[key] < 0 ? 'loss' : key)
|
|
|
|
|
+ Ox.formatCurrency(Math.abs(data[key]), '$')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
$div.html(html.join('; '));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.connections) {
|
|
|
|
|
$div = $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2013-03-07 10:46:16 +00:00
|
|
|
|
.css(css)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
html = [];
|
|
|
|
|
[
|
|
|
|
|
'Edited from', 'Edited into',
|
|
|
|
|
'Features', 'Featured in',
|
|
|
|
|
'Follows', 'Followed by',
|
|
|
|
|
'References', 'Referenced in',
|
|
|
|
|
'Remake of', 'Remade as',
|
|
|
|
|
'Spin off from', 'Spin off',
|
|
|
|
|
'Spoofs', 'Spoofed in'
|
|
|
|
|
].forEach(function(key) {
|
|
|
|
|
data.connections[key] && html.push(
|
|
|
|
|
formatKey(key) + data.connections[key].map(function(connection) {
|
|
|
|
|
return (
|
|
|
|
|
connection.item
|
|
|
|
|
? '<a href="/' + connection.item + '">' + connection.title + '</a>'
|
|
|
|
|
: connection.title
|
|
|
|
|
) + (
|
|
|
|
|
connection.description
|
|
|
|
|
? ' ' + formatLight('(' + connection.description + ')')
|
|
|
|
|
: ''
|
|
|
|
|
);
|
|
|
|
|
}).join(', ')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
$div.html(html.join('; '));
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-04 09:27:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-20 10:36:42 +00:00
|
|
|
|
['reviews', 'links'].forEach(function(key) {
|
|
|
|
|
data[key] && $('<div>')
|
2013-07-19 09:34:01 +00:00
|
|
|
|
.addClass('OxSelectable')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css(css)
|
|
|
|
|
.html(
|
|
|
|
|
formatKey(key) + data[key].map(function(value) {
|
|
|
|
|
return '<a href="' + value.url + '">' + value.source + '</a>'
|
|
|
|
|
}).join(', ')
|
|
|
|
|
)
|
|
|
|
|
.appendTo($text);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('<div>').css({height: '16px'}).appendTo($text);
|
|
|
|
|
|
2012-10-05 11:40:38 +00:00
|
|
|
|
// Mainstream Score, Arthouse Score ----------------------------------------
|
|
|
|
|
|
|
|
|
|
['votes', 'likes'].forEach(function(key) {
|
|
|
|
|
var value = data[key] || 0;
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({marginBottom: '4px'})
|
2012-10-05 13:35:40 +00:00
|
|
|
|
.append(
|
|
|
|
|
formatKey(
|
2013-07-11 12:38:19 +00:00
|
|
|
|
key == 'votes' ? 'Mainstream Score' : 'Arthouse Score',
|
|
|
|
|
'statistics'
|
2012-10-05 13:35:40 +00:00
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.append(
|
|
|
|
|
Ox.Theme.formatColorPercent(value, 1, true)
|
2013-07-08 15:08:40 +00:00
|
|
|
|
.css({textAlign: 'right', cursor: 'pointer'})
|
|
|
|
|
.bind({
|
|
|
|
|
click: function() {
|
2013-07-14 15:36:49 +00:00
|
|
|
|
pandora.UI.set({listSort: [{
|
2013-07-08 15:08:40 +00:00
|
|
|
|
key: key,
|
|
|
|
|
operator: pandora.getSortOperator(key)
|
2013-07-14 15:36:49 +00:00
|
|
|
|
}]});
|
2013-07-08 15:08:40 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
2012-10-05 13:35:40 +00:00
|
|
|
|
)
|
2012-10-05 11:40:38 +00:00
|
|
|
|
.appendTo($statistics);
|
|
|
|
|
});
|
|
|
|
|
|
2013-01-02 12:59:58 +00:00
|
|
|
|
// Duration, Aspect Ratio --------------------------------------------------
|
|
|
|
|
|
|
|
|
|
['duration', 'aspectratio'].forEach(function(key) {
|
|
|
|
|
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key),
|
|
|
|
|
value = data[key] || 0;
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({marginBottom: '4px'})
|
2013-07-11 12:38:19 +00:00
|
|
|
|
.append(formatKey(itemKey.title, 'statistics'))
|
2013-01-02 12:59:58 +00:00
|
|
|
|
.append(
|
|
|
|
|
Ox.Theme.formatColor(null, 'gradient')
|
2013-07-08 15:08:40 +00:00
|
|
|
|
.css({textAlign: 'right', cursor: 'pointer'})
|
2013-01-02 12:59:58 +00:00
|
|
|
|
.html(
|
|
|
|
|
Ox['format' + Ox.toTitleCase(itemKey.format.type)]
|
|
|
|
|
.apply(null, [value].concat(itemKey.format.args))
|
|
|
|
|
)
|
2013-07-08 15:08:40 +00:00
|
|
|
|
.bind({
|
|
|
|
|
click: function() {
|
2013-07-14 15:36:49 +00:00
|
|
|
|
pandora.UI.set({listSort: [{
|
2013-07-08 15:08:40 +00:00
|
|
|
|
key: key,
|
|
|
|
|
operator: pandora.getSortOperator(key)
|
2013-07-14 15:36:49 +00:00
|
|
|
|
}]});
|
2013-07-08 15:08:40 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
2013-01-02 12:59:58 +00:00
|
|
|
|
)
|
|
|
|
|
.appendTo($statistics);
|
|
|
|
|
});
|
|
|
|
|
|
2012-04-20 10:36:42 +00:00
|
|
|
|
// Hue, Saturation, Lightness, Volume --------------------------------------
|
|
|
|
|
|
|
|
|
|
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
|
2012-10-05 11:40:38 +00:00
|
|
|
|
var value = data[key] || 0;
|
2012-04-20 10:36:42 +00:00
|
|
|
|
$('<div>')
|
|
|
|
|
.css({marginBottom: '4px'})
|
2013-07-11 12:38:19 +00:00
|
|
|
|
.append(formatKey(key, 'statistics'))
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.append(
|
2012-10-05 11:40:38 +00:00
|
|
|
|
Ox.Theme.formatColor(value, key == 'volume' ? 'lightness' : key)
|
2013-07-08 15:08:40 +00:00
|
|
|
|
.css({textAlign: 'right', cursor: 'pointer'})
|
|
|
|
|
.bind({
|
|
|
|
|
click: function() {
|
2013-07-14 15:36:49 +00:00
|
|
|
|
pandora.UI.set({listSort: [{
|
2013-07-08 15:08:40 +00:00
|
|
|
|
key: key,
|
|
|
|
|
operator: pandora.getSortOperator(key)
|
2013-07-14 15:36:49 +00:00
|
|
|
|
}]});
|
2013-07-08 15:08:40 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
2012-04-20 10:36:42 +00:00
|
|
|
|
)
|
|
|
|
|
.appendTo($statistics);
|
|
|
|
|
});
|
|
|
|
|
|
2013-01-02 12:59:58 +00:00
|
|
|
|
// Cuts per Minute, Words per Minute ---------------------------------------
|
|
|
|
|
|
|
|
|
|
['cutsperminute', 'wordsperminute'].forEach(function(key) {
|
|
|
|
|
var value = data[key] || 0;
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({marginBottom: '4px'})
|
|
|
|
|
.append(
|
2013-07-11 12:38:19 +00:00
|
|
|
|
formatKey(key.slice(0, -9) + ' per minute', 'statistics')
|
2013-01-02 12:59:58 +00:00
|
|
|
|
)
|
|
|
|
|
.append(
|
|
|
|
|
Ox.Theme.formatColor(null, 'gradient')
|
2013-07-08 15:08:40 +00:00
|
|
|
|
.css({textAlign: 'right', cursor: 'pointer'})
|
2013-01-30 06:16:44 +00:00
|
|
|
|
.html(Ox.formatNumber(value, 3))
|
2013-07-08 15:08:40 +00:00
|
|
|
|
.bind({
|
|
|
|
|
click: function() {
|
2013-07-14 15:36:49 +00:00
|
|
|
|
pandora.UI.set({listSort: [{
|
2013-07-08 15:08:40 +00:00
|
|
|
|
key: key,
|
|
|
|
|
operator: pandora.getSortOperator(key)
|
2013-07-14 15:36:49 +00:00
|
|
|
|
}]});
|
2013-07-08 15:08:40 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
2013-01-02 12:59:58 +00:00
|
|
|
|
)
|
|
|
|
|
.appendTo($statistics);
|
|
|
|
|
});
|
|
|
|
|
|
2012-04-20 10:36:42 +00:00
|
|
|
|
// Rights Level ------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
var $rightsLevel = $('<div>');
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({marginBottom: '4px'})
|
2013-07-11 12:38:19 +00:00
|
|
|
|
.append(formatKey('Rights Level', 'statistics'))
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.append($rightsLevel)
|
|
|
|
|
.appendTo($statistics);
|
|
|
|
|
renderRightsLevel();
|
|
|
|
|
|
|
|
|
|
// Notes -------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
if (canEdit) {
|
|
|
|
|
$('<div>')
|
|
|
|
|
.css({marginBottom: '4px'})
|
2013-07-11 12:38:19 +00:00
|
|
|
|
.append(formatKey('Notes', 'statistics'))
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.append(
|
2013-05-09 12:03:26 +00:00
|
|
|
|
Ox.EditableContent({
|
2013-02-10 12:31:54 +00:00
|
|
|
|
clickLink: pandora.clickLink,
|
2013-05-09 10:13:58 +00:00
|
|
|
|
placeholder: formatLight(Ox._('No notes')),
|
2013-03-01 03:51:39 +00:00
|
|
|
|
tooltip: pandora.getEditTooltip(),
|
2012-04-20 10:36:42 +00:00
|
|
|
|
type: 'textarea',
|
2013-03-09 08:23:47 +00:00
|
|
|
|
value: data.notes || '',
|
2012-04-20 10:36:42 +00:00
|
|
|
|
width: 128
|
|
|
|
|
})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
submit: function(event) {
|
|
|
|
|
pandora.api.edit({
|
|
|
|
|
id: data.id,
|
|
|
|
|
notes: event.value
|
|
|
|
|
}, function(result) {
|
|
|
|
|
// ...
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
.appendTo($statistics);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('<div>').css({height: '16px'}).appendTo($statistics);
|
|
|
|
|
|
|
|
|
|
if (canEdit) {
|
|
|
|
|
$icon.bindEvent({
|
|
|
|
|
doubleclick: function() {
|
2013-07-14 15:36:49 +00:00
|
|
|
|
pandora.UI.set({showIconBrowser: !ui.showIconBrowser});
|
2012-04-20 10:36:42 +00:00
|
|
|
|
$info.animate({
|
|
|
|
|
left: ui.showIconBrowser ? 0 : -listWidth + 'px'
|
|
|
|
|
}, 250);
|
|
|
|
|
$icon.options({
|
2013-08-07 23:06:47 +00:00
|
|
|
|
tooltip: !ui.showIconBrowser
|
2012-04-20 10:36:42 +00:00
|
|
|
|
? 'Doubleclick to edit icon'
|
|
|
|
|
: 'Doubleclick to hide icons'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
renderList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function editMetadata(key, value) {
|
|
|
|
|
if (value != data[key]) {
|
|
|
|
|
var edit = {id: data.id};
|
|
|
|
|
if (key == 'title') {
|
|
|
|
|
Ox.extend(edit, parseTitle(value));
|
2012-06-10 18:31:02 +00:00
|
|
|
|
} else if (['director', 'country'].indexOf(key) > -1) {
|
2012-04-20 10:36:42 +00:00
|
|
|
|
edit[key] = value ? value.split(', ') : [];
|
|
|
|
|
} else {
|
|
|
|
|
edit[key] = value;
|
|
|
|
|
}
|
|
|
|
|
pandora.api.edit(edit, function(result) {
|
|
|
|
|
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);
|
2013-02-11 11:16:30 +00:00
|
|
|
|
// FIXME: does this update selected?
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}
|
2013-02-11 11:16:30 +00:00
|
|
|
|
pandora.updateItemContext();
|
2013-02-25 10:21:29 +00:00
|
|
|
|
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
|
2012-04-20 10:36:42 +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._(Ox.toTitleCase(key)) + ':</span> '
|
|
|
|
|
: $('<div>').css({marginBottom: '4px', fontWeight: 'bold'})
|
2013-05-09 10:13:58 +00:00
|
|
|
|
.html(Ox._(Ox.toTitleCase(key).replace(' Per ', ' per ')))
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatLight(str) {
|
2013-02-10 14:06:34 +00:00
|
|
|
|
return '<span class="OxLight">' + str + '</span>';
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatTitle(title) {
|
2013-08-27 09:32:55 +00:00
|
|
|
|
var match = /(.+) (\(S\d{2}(E\d{2})?\))/.exec(title);
|
2012-04-20 10:36:42 +00:00
|
|
|
|
if (match) {
|
2012-09-25 10:52:33 +00:00
|
|
|
|
title = formatValue(match[1], 'title') + ' '
|
|
|
|
|
+ formatLight(match[2])
|
|
|
|
|
+ title.substr(match[0].length);
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}
|
|
|
|
|
return title + (
|
2012-10-09 12:57:21 +00:00
|
|
|
|
data.originalTitle && data.originalTitle != title
|
|
|
|
|
? ' ' + formatLight('(' + data.originalTitle + ')') : ''
|
2012-04-20 10:36:42 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatValue(value, key) {
|
|
|
|
|
return (Ox.isArray(value) ? value : [value]).map(function(value) {
|
|
|
|
|
return key ?
|
|
|
|
|
'<a href="/' + key + '=' + value + '">' + value + '</a>'
|
|
|
|
|
: value;
|
|
|
|
|
}).join(', ');
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
|
function getHeight() {
|
|
|
|
|
return pandora.$ui.contentPanel.size(1) - 16;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-20 10:36:42 +00:00
|
|
|
|
function getRightsLevelElement(rightsLevel) {
|
|
|
|
|
return Ox.Theme.formatColorLevel(
|
|
|
|
|
rightsLevel,
|
|
|
|
|
pandora.site.rightsLevels.map(function(rightsLevel) {
|
|
|
|
|
return rightsLevel.name;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseTitle(title) {
|
|
|
|
|
var data = {title: title},
|
|
|
|
|
match = /(\(S(\d{2})E(\d{2})\))/.exec(title),
|
2013-02-09 04:53:35 +00:00
|
|
|
|
episodeMatch = /(.+) \(S01\) (.+)/.exec(title),
|
2012-04-20 10:36:42 +00:00
|
|
|
|
split;
|
|
|
|
|
if (match) {
|
|
|
|
|
data.season = parseInt(match[2], 10);
|
|
|
|
|
data.episode = parseInt(match[3], 10);
|
|
|
|
|
split = title.split(match[1]);
|
|
|
|
|
data.seriesTitle = split[0].trim();
|
|
|
|
|
data.episodeTitle = split[1].trim();
|
2013-02-09 04:53:35 +00:00
|
|
|
|
} else if (episodeMatch) {
|
|
|
|
|
data.seriesTitle = episodeMatch[1].trim();
|
|
|
|
|
data.episodeTitle = episodeMatch[2].trim();
|
2013-05-31 20:47:56 +00:00
|
|
|
|
data.season = 1;
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderCapabilities(rightsLevel) {
|
2012-05-24 08:22:56 +00:00
|
|
|
|
var capabilities = [].concat(
|
2012-04-20 10:36:42 +00:00
|
|
|
|
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) {
|
|
|
|
|
return Ox.toTitleCase(userLevel);
|
|
|
|
|
}), [0, 240]);
|
|
|
|
|
Ox.Label({
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
title: Ox.toTitleCase(userLevel),
|
|
|
|
|
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) {
|
|
|
|
|
var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel,
|
|
|
|
|
$element = Ox.Theme.formatColorLevel(hasCapability, ['', '']);
|
|
|
|
|
Ox.Button({
|
|
|
|
|
tooltip: (canEdit ? Ox.toTitleCase(userLevel) : 'You') + ' '
|
|
|
|
|
+ (hasCapability ? 'can' : 'can\'t') + ' '
|
2012-05-22 15:07:34 +00:00
|
|
|
|
+ Ox.toSlashes(capability.name)
|
|
|
|
|
.split('/').slice(1).join(' ')
|
|
|
|
|
.toLowerCase()
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.replace('see item', 'see the item')
|
|
|
|
|
.replace('play video', 'play the full video')
|
|
|
|
|
.replace('download video', 'download the video'),
|
|
|
|
|
title: capability.symbol,
|
|
|
|
|
type: 'image'
|
|
|
|
|
})
|
|
|
|
|
.addClass('OxColor OxColorGradient')
|
2013-07-08 15:33:04 +00:00
|
|
|
|
.css({
|
|
|
|
|
background: $element.css('background'),
|
|
|
|
|
cursor: hasCapability ? 'pointer' : 'default'
|
|
|
|
|
})
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css('margin' + (canEdit ? 'Left' : 'Right'), '4px')
|
|
|
|
|
.data({OxColor: $element.data('OxColor')})
|
2013-07-08 15:33:04 +00:00
|
|
|
|
.bindEvent({
|
|
|
|
|
click: function() {
|
|
|
|
|
if (hasCapability) {
|
|
|
|
|
if (capability.name == 'canSeeItem') {
|
|
|
|
|
$data.animate({scrollTop: 0}, 250);
|
|
|
|
|
} else if (capability.name == 'canPlayClips') {
|
|
|
|
|
pandora.UI.set({itemView: 'clips'});
|
|
|
|
|
} else if (capability.name == 'canPlayVideo') {
|
|
|
|
|
pandora.UI.set({itemView: ui.videoView});
|
|
|
|
|
} else if (capability.name == 'canDownloadVideo') {
|
|
|
|
|
document.location.href = '/' + ui.item + '/torrent/';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.appendTo($line);
|
|
|
|
|
});
|
|
|
|
|
if (!canEdit) {
|
|
|
|
|
Ox.Button({
|
|
|
|
|
title: 'Help',
|
2013-05-09 10:13:58 +00:00
|
|
|
|
tooltip: Ox._('About Rights'),
|
2012-04-20 10:36:42 +00:00
|
|
|
|
type: 'image'
|
|
|
|
|
})
|
|
|
|
|
.css({marginLeft: '52px'})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
click: function() {
|
|
|
|
|
pandora.UI.set({page: 'rights'});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($line);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderList() {
|
|
|
|
|
pandora.api.get({
|
|
|
|
|
id: data.id,
|
|
|
|
|
keys: [ui.icons == 'posters' ? 'posters' : 'frames']
|
|
|
|
|
}, 0, function(result) {
|
2012-06-30 20:54:46 +00:00
|
|
|
|
var images = result.data[ui.icons == 'posters' ? 'posters' : 'frames'].map(function(image) {
|
|
|
|
|
return Ox.extend(image, {index: image.index.toString()});
|
|
|
|
|
}),
|
2012-04-20 10:36:42 +00:00
|
|
|
|
selectedImage = images.filter(function(image) {
|
|
|
|
|
return image.selected;
|
2013-08-01 17:47:16 +00:00
|
|
|
|
})[0],
|
|
|
|
|
modified = data.modified;
|
2012-04-20 10:36:42 +00:00
|
|
|
|
$list = Ox.IconList({
|
2013-07-08 12:40:23 +00:00
|
|
|
|
defaultRatio: ui.icons == 'posters' || !data.stream ? pandora.site.posters.ratio : data.stream.aspectratio,
|
2012-05-30 15:40:43 +00:00
|
|
|
|
fixedRatio: ui.icons == 'posters' || !data.stream ? false : data.stream.aspectratio,
|
2012-04-20 10:36:42 +00:00
|
|
|
|
item: function(data, sort, size) {
|
|
|
|
|
var ratio = data.width / data.height;
|
|
|
|
|
size = size || 128;
|
|
|
|
|
return {
|
|
|
|
|
height: ratio <= 1 ? size : size / ratio,
|
2013-08-01 17:47:16 +00:00
|
|
|
|
id: data.id,
|
2013-07-22 19:38:31 +00:00
|
|
|
|
info: data.width + ' × ' + data.height + ' px',
|
2012-04-20 10:36:42 +00:00
|
|
|
|
title: ui.icons == 'posters' ? data.source : Ox.formatDuration(data.position),
|
2013-08-01 17:47:16 +00:00
|
|
|
|
url: data.url.replace('http://', '//') + (
|
|
|
|
|
ui.icons == 'posters' && data.source == pandora.site.site.url ? '?' + modified : ''
|
|
|
|
|
),
|
2012-04-20 10:36:42 +00:00
|
|
|
|
width: ratio >= 1 ? size : size * ratio
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
items: images,
|
|
|
|
|
keys: ui.icons == 'posters'
|
|
|
|
|
? ['index', 'source', 'width', 'height', 'url']
|
|
|
|
|
: ['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'
|
|
|
|
|
})
|
2013-02-01 06:31:55 +00:00
|
|
|
|
.addClass('OxMedia')
|
2012-04-20 10:36:42 +00:00
|
|
|
|
.css({
|
|
|
|
|
display: 'block',
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
left: 0,
|
|
|
|
|
top: 0,
|
|
|
|
|
width: listWidth + 'px',
|
2013-07-11 12:38:19 +00:00
|
|
|
|
height: getHeight() + 'px'
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.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.replace('http://', '//');
|
|
|
|
|
if ($browserImages.length == 0) {
|
|
|
|
|
$browserImages = pandora.$ui.browser.find('img[src*="/' + data.id + '/"]');
|
|
|
|
|
}
|
|
|
|
|
if (ui.icons == 'posters' && !ui.showSitePosters) {
|
|
|
|
|
$browserImages.each(function() {
|
|
|
|
|
var $this = $(this),
|
|
|
|
|
size = Math.max($this.width(), $this.height());
|
|
|
|
|
$this.attr({src: src});
|
|
|
|
|
ui.icons == 'posters' && $this.css(imageRatio < 1 ? {
|
|
|
|
|
width: Math.round(size * imageRatio) + 'px',
|
|
|
|
|
height: size + 'px'
|
|
|
|
|
} : {
|
|
|
|
|
width: size + 'px',
|
|
|
|
|
height: Math.round(size / imageRatio) + 'px'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
$icon.attr({src: src});
|
|
|
|
|
$reflectionIcon.attr({src: src});
|
|
|
|
|
iconRatio = imageRatio;
|
|
|
|
|
iconSize = iconSize == 256 ? 512 : 256;
|
|
|
|
|
toggleIconSize();
|
|
|
|
|
}
|
|
|
|
|
pandora.api[ui.icons == 'posters' ? 'setPoster' : 'setPosterFrame'](Ox.extend({
|
|
|
|
|
id: data.id
|
|
|
|
|
}, ui.icons == 'posters' ? {
|
|
|
|
|
source: selectedImage.source
|
|
|
|
|
} : {
|
|
|
|
|
// fixme: api slightly inconsistent, this shouldn't be "position"
|
|
|
|
|
position: selectedImage.index
|
|
|
|
|
}), function() {
|
|
|
|
|
var src;
|
2012-07-01 14:00:48 +00:00
|
|
|
|
Ox.Request.clearCache();
|
2012-04-20 10:36:42 +00:00
|
|
|
|
if (ui.icons == 'frames') {
|
2014-02-02 11:30:25 +00:00
|
|
|
|
src = pandora.getMediaURL('/' + data.id + '/icon512.jpg?' + Ox.uid());
|
2012-04-20 10:36:42 +00:00
|
|
|
|
$icon.attr({src: src});
|
|
|
|
|
$reflectionIcon.attr({src: src});
|
2013-02-11 05:44:13 +00:00
|
|
|
|
if (pandora.$ui.videoPreview) {
|
|
|
|
|
pandora.$ui.videoPreview.options({
|
|
|
|
|
position: $list.value(selectedImage.index, 'position')
|
|
|
|
|
});
|
|
|
|
|
}
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}
|
2013-07-07 15:08:01 +00:00
|
|
|
|
if (!ui.showSitePosters) {
|
|
|
|
|
$browserImages.each(function() {
|
2014-02-02 11:30:25 +00:00
|
|
|
|
$(this).attr({src: pandora.getMediaURL('/' + data.id + '/' + (
|
2013-07-07 15:08:01 +00:00
|
|
|
|
ui.icons == 'posters' ? 'poster' : 'icon'
|
2014-02-02 11:30:25 +00:00
|
|
|
|
) + '128.jpg?' + Ox.uid())});
|
2013-07-07 15:08:01 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-02-12 02:02:59 +00:00
|
|
|
|
if (ui.listSort[0].key == 'modified') {
|
2013-02-12 01:58:09 +00:00
|
|
|
|
pandora.$ui.browser.reloadList();
|
|
|
|
|
}
|
2012-04-20 10:36:42 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($info);
|
|
|
|
|
$list.size();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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, title: rightsLevel.name};
|
|
|
|
|
}),
|
|
|
|
|
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')})
|
|
|
|
|
renderCapabilities(rightsLevel);
|
|
|
|
|
pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) {
|
|
|
|
|
// ...
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($rightsLevel);
|
|
|
|
|
} else {
|
|
|
|
|
$rightsLevelElement
|
|
|
|
|
.css({
|
2013-07-08 15:08:40 +00:00
|
|
|
|
marginBottom: '4px',
|
|
|
|
|
cursor: 'pointer'
|
|
|
|
|
})
|
|
|
|
|
.bind({
|
|
|
|
|
click: function() {
|
2013-07-14 15:36:49 +00:00
|
|
|
|
pandora.UI.set({listSort: [{
|
2013-07-08 15:08:40 +00:00
|
|
|
|
key: 'rightslevel',
|
|
|
|
|
operator: pandora.getSortOperator('rightslevel')
|
2013-07-14 15:36:49 +00:00
|
|
|
|
}]});
|
2013-07-08 15:08:40 +00:00
|
|
|
|
}
|
2012-04-20 10:36:42 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($rightsLevel);
|
|
|
|
|
}
|
|
|
|
|
$capabilities = $('<div>').appendTo($rightsLevel);
|
|
|
|
|
renderCapabilities(data.rightslevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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({
|
2012-05-26 15:46:24 +00:00
|
|
|
|
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px'
|
2012-04-20 10:36:42 +00:00
|
|
|
|
}, 250);
|
|
|
|
|
pandora.UI.set({infoIconSize: iconSize});
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-08 08:56:39 +00:00
|
|
|
|
function updateMetadata() {
|
|
|
|
|
var item = ui.item;
|
|
|
|
|
$options.disableItem('update');
|
|
|
|
|
// fixme: maybe there's a better method name for this?
|
|
|
|
|
pandora.api.updateExternalData({
|
|
|
|
|
id: ui.item
|
|
|
|
|
}, function(result) {
|
2016-09-07 18:16:25 +00:00
|
|
|
|
(result.data.taskId ? pandora.wait : Ox.noop)(result.data.taskId, function(result) {
|
|
|
|
|
pandora.updateItemContext();
|
|
|
|
|
Ox.Request.clearCache();
|
|
|
|
|
if (ui.item == item && ui.itemView == 'info') {
|
|
|
|
|
pandora.$ui.contentPanel.replaceElement(
|
|
|
|
|
1, pandora.$ui.item = pandora.ui.item()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$options.enableItem('update');
|
|
|
|
|
});
|
2013-07-08 08:56:39 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-20 10:36:42 +00:00
|
|
|
|
that.reload = function() {
|
2014-02-02 11:30:25 +00:00
|
|
|
|
var src = pandora.getMediaURL('/' + data.id + '/' + (
|
2012-04-20 10:36:42 +00:00
|
|
|
|
ui.icons == 'posters'
|
|
|
|
|
? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon'
|
2014-02-02 11:30:25 +00:00
|
|
|
|
) + '512.jpg?' + Ox.uid())
|
2012-04-20 10:36:42 +00:00
|
|
|
|
$icon.attr({src: src});
|
|
|
|
|
$reflectionIcon.attr({src: src});
|
|
|
|
|
iconSize = iconSize == 256 ? 512 : 256;
|
|
|
|
|
iconRatio = ui.icons == 'posters'
|
2013-07-08 12:40:23 +00:00
|
|
|
|
? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1;
|
2012-04-20 10:36:42 +00:00
|
|
|
|
toggleIconSize();
|
|
|
|
|
pandora.user.level == 'admin' && $list.replaceWith($list = renderList());
|
|
|
|
|
};
|
|
|
|
|
|
2013-10-22 13:57:35 +00:00
|
|
|
|
that.resizeElement = function() {
|
2013-07-22 19:32:05 +00:00
|
|
|
|
var height = getHeight() + 'px';
|
|
|
|
|
$data.css({height: height});
|
|
|
|
|
$list && $list.css({height: height});
|
2012-04-20 10:36:42 +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
|
|
|
|
},
|
2012-04-20 10:36:42 +00:00
|
|
|
|
pandora_icons: that.reload,
|
|
|
|
|
pandora_showsiteposters: function() {
|
|
|
|
|
ui.icons == 'posters' && that.reload();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
2013-07-11 12:38:19 +00:00
|
|
|
|
};
|