'use strict';
pandora.ui.documentInfoView = function(data, isMixed) {
isMixed = isMixed || {};
var ui = pandora.user.ui,
isMultiple = arguments.length == 2,
canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable,
canRemove = pandora.hasCapability('canRemoveItems'),
css = {
marginTop: '4px',
textAlign: 'justify'
},
html,
iconRatio = data.ratio,
iconSize = isMultiple ? 0 : ui.infoIconSize,
iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio),
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
margin = 16,
nameKeys = pandora.site.documentKeys.filter(function(key) {
return key.sortType == 'person';
}).map(function(key) {
return key.id;
}),
listKeys = pandora.site.documentKeys.filter(function(key) {
return Ox.isArray(key.type);
}).map(function(key){
return key.id;
}),
statisticsWidth = 128,
$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}...', [Ox._('Document')]),
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({
click: function(data_) {
if (data_.id == 'delete') {
pandora.ui.deleteDocumentDialog(
[data],
function() {
Ox.Request.clearCache();
if (ui.document) {
pandora.UI.set({document: ''});
} else {
pandora.$ui.list.reloadList()
}
}
).open();
}
}
})
.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),
$info = Ox.Element().css({overflowY: 'auto'}),
that = Ox.SplitPanel({
elements: [
{element: $bar, size: isMultiple ? 0 : 16},
{element: $info}
],
orientation: 'vertical'
});
if (!isMultiple) {
var $icon = Ox.Element({
element: '',
})
.attr({
src: '/documents/' + data.id + '/512p.jpg?' + data.modified
})
.css({
position: 'absolute',
left: margin + iconLeft + 'px',
top: margin + 'px',
width: iconWidth + 'px',
height: iconHeight + 'px'
})
.bindEvent({
// singleclick: toggleIconSize
})
.appendTo($info),
$reflection = $('
'
}).join('\n')
)
pandora.createLinks($div);
$div.appendTo($text)
}
// Referenced --------------------------------------------------------------
if (
!isMultiple && (
data.referenced.items.length
|| data.referenced.annotations.length
|| data.referenced.documents.length
|| data.referenced.entities.length
)) {
var itemsById = {}
data.referenced.items.forEach(function(item) {
itemsById[item.id] = Ox.extend(item, {annotations: [], referenced: true});
});
data.referenced.annotations.forEach(function(annotation) {
var itemId = annotation.id.split('/')[0];
if (!itemsById[itemId]) {
itemsById[itemId] = {
id: itemId,
title: annotation.title,
annotations: []
};
}
itemsById[itemId].annotations = itemsById[itemId].annotations.concat(annotation);
});
var html = Ox.sortBy(Object.values(itemsById), 'title').map(function(item) {
return (item.referenced ? '' : '')
+ item.title //Ox.encodeHTMLEntities(item.title)
+ (item.referenced ? '' : '')
+ (item.annotations.length
? ' (' + Ox.sortBy(item.annotations, 'in').map(function(annotation) {
return ''
+ Ox.formatDuration(annotation.in) + ''
}).join(', ')
+ ')'
: '')
}).join(', ');
html += data.referenced.documents.map(function(document) {
return ', ' + document.title + '';
}).join('');
html += data.referenced.entities.map(function(entity) {
return ', ' + entity.name + '';
}).join('');
var $div = $('