2011-12-27 06:54:49 +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],
|
|
|
|
css = {
|
|
|
|
marginTop: '4px',
|
|
|
|
textAlign: 'justify',
|
|
|
|
MozUserSelect: 'text',
|
|
|
|
WebkitUserSelect: 'text'
|
|
|
|
},
|
|
|
|
iconRatio = ui.icons == 'posters'
|
|
|
|
? (ui.showSitePoster ? 5/8 : data.posterRatio) : 1,
|
|
|
|
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,
|
|
|
|
isEditable = canEdit,
|
|
|
|
listWidth = 144 + Ox.UI.SCROLLBAR_SIZE,
|
|
|
|
margin = 16,
|
|
|
|
statisticsWidth = 128,
|
|
|
|
uid = Ox.uid(),
|
|
|
|
|
|
|
|
that = Ox.Element(),
|
|
|
|
|
|
|
|
$list,
|
|
|
|
|
|
|
|
$info = $('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: canEdit && !ui.showIconBrowser ? -listWidth + 'px' : 0,
|
|
|
|
top: 0,
|
|
|
|
right: 0,
|
|
|
|
})
|
|
|
|
.appendTo(that.$element),
|
|
|
|
|
|
|
|
$data = Ox.Container()
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: (canEdit ? listWidth : 0) + 'px',
|
|
|
|
top: 0,
|
|
|
|
right: 0,
|
|
|
|
height: pandora.$ui.contentPanel.size(1) + 'px'
|
|
|
|
})
|
|
|
|
.appendTo($info),
|
|
|
|
|
|
|
|
$icon = Ox.Element({
|
|
|
|
element: '<img>',
|
|
|
|
})
|
|
|
|
.attr({
|
|
|
|
src: '/' + data.id + '/' + (
|
|
|
|
ui.icons == 'posters'
|
|
|
|
? (ui.showSitePoster ? 'siteposter' : 'poster') : 'icon'
|
|
|
|
) + '512.jpg?' + uid
|
|
|
|
})
|
|
|
|
.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',
|
|
|
|
height: iconSize / 2 + 'px',
|
|
|
|
overflow: 'hidden'
|
|
|
|
})
|
|
|
|
.appendTo($data.$element),
|
|
|
|
|
|
|
|
$reflectionIcon = $('<img>')
|
|
|
|
.attr({
|
|
|
|
src: '/' + data.id + '/' + (
|
|
|
|
ui.icons == 'posters' ? 'poster' : 'icon'
|
|
|
|
) + '512.jpg?' + uid
|
|
|
|
})
|
|
|
|
.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',
|
|
|
|
height: iconSize / 2 + 'px'
|
|
|
|
})
|
|
|
|
.appendTo($reflection),
|
|
|
|
|
|
|
|
$text = Ox.Element({
|
|
|
|
tooltip: canEdit && !isEditable ? 'Doubleclick to reload metadata' : ''
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
|
|
|
|
top: margin + 'px',
|
|
|
|
right: margin + statisticsWidth + margin + 'px',
|
|
|
|
//background: 'green'
|
|
|
|
})
|
|
|
|
.bindEvent(canEdit && !isEditable ? {
|
|
|
|
doubleclick: reloadMetadata
|
|
|
|
} : {})
|
|
|
|
.appendTo($data.$element),
|
|
|
|
|
|
|
|
$statistics = $('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
width: statisticsWidth + 'px',
|
|
|
|
top: margin + 'px',
|
|
|
|
right: margin + 'px'
|
|
|
|
})
|
|
|
|
.appendTo($data.$element),
|
|
|
|
|
|
|
|
$capabilities,
|
|
|
|
|
|
|
|
$browserImages = [];
|
|
|
|
|
|
|
|
pandora.createLinks($text);
|
|
|
|
|
|
|
|
// Title -------------------------------------------------------------------
|
|
|
|
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
marginTop: '-2px'
|
|
|
|
})
|
|
|
|
.append(
|
|
|
|
Ox.Editable({
|
|
|
|
editable: isEditable,
|
|
|
|
format: function(value) {
|
|
|
|
return formatTitle(value);
|
|
|
|
},
|
|
|
|
tooltip: isEditable ? 'Doubleclick to edit' : '',
|
|
|
|
value: data.title
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
display: 'inline-block',
|
|
|
|
marginBottom: '-3px',
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: '13px',
|
|
|
|
MozUserSelect: 'text',
|
|
|
|
WebkitUserSelect: 'text'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(event) {
|
|
|
|
editMetadata('title', event.value);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.appendTo($text);
|
|
|
|
|
|
|
|
// Director ----------------------------------------------------------------
|
2011-12-29 12:42:19 +00:00
|
|
|
/*
|
2011-12-27 06:54:49 +00:00
|
|
|
if (data.director || isEditable) {
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
marginTop: '2px'
|
|
|
|
})
|
|
|
|
.append(
|
|
|
|
Ox.Editable({
|
|
|
|
clickLink: pandora.clickLink,
|
|
|
|
editable: isEditable,
|
|
|
|
format: function(value) {
|
|
|
|
return formatValue(value.split(', '), 'name');
|
|
|
|
},
|
|
|
|
placeholder: formatLight('Unknown Director'),
|
|
|
|
tooltip: isEditable ? 'Doubleclick to edit' : '',
|
|
|
|
value: data.director ? data.director.join(', ') : 'Unknown Director'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
display: 'inline-block',
|
|
|
|
marginBottom: '-3px',
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: '13px',
|
|
|
|
MozUserSelect: 'text',
|
|
|
|
WebkitUserSelect: 'text'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(event) {
|
|
|
|
editMetadata('director', event.value);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.appendTo($text);
|
|
|
|
}
|
2011-12-29 12:42:19 +00:00
|
|
|
*/
|
2011-12-27 06:54:49 +00:00
|
|
|
|
|
|
|
// Country, Year, Language, Runtime ----------------------------------------
|
2011-12-27 09:40:11 +00:00
|
|
|
/*
|
2011-12-27 06:54:49 +00:00
|
|
|
if (isEditable) {
|
|
|
|
var $div = $('<div>')
|
|
|
|
.css(css)
|
|
|
|
.appendTo($text);
|
|
|
|
['country', 'year'].forEach(function(key) {
|
|
|
|
$('<div>')
|
|
|
|
.css({float: 'left'})
|
|
|
|
.html(formatKey(key).replace('</span>', ' </span>'))
|
|
|
|
.appendTo($div);
|
|
|
|
Ox.Editable({
|
|
|
|
clickLink: pandora.clickLink,
|
|
|
|
format: function(value) {
|
|
|
|
return formatValue(value.split(', '), key)
|
|
|
|
},
|
|
|
|
placeholder: formatLight('unknown'),
|
|
|
|
tooltip: 'Doubleclick to edit',
|
|
|
|
value: key == 'country'
|
2011-12-27 13:52:16 +00:00
|
|
|
? (data[key] ? data[key].join(', ') : '')
|
2011-12-27 06:54:49 +00:00
|
|
|
: data[key] || ''
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(event) {
|
|
|
|
editMetadata(key, event.value);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo($div);
|
|
|
|
key == 'country' && $('<div>').css({float: 'left'}).html('; ').appendTo($div);
|
|
|
|
});
|
|
|
|
} else if (data.country || data.year || data.language || data.runtime) {
|
|
|
|
var html = [];
|
|
|
|
['country', 'year', 'language', 'runtime'].forEach(function(key) {
|
|
|
|
if (data[key]) {
|
|
|
|
html.push(
|
|
|
|
formatKey(key)
|
|
|
|
+ (key == 'runtime'
|
|
|
|
? Math.round(data[key] / 60) + ' min'
|
|
|
|
: formatValue(data[key], key))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('<div>').css(css).html(html.join('; ')).appendTo($text);
|
|
|
|
}
|
2011-12-27 09:40:11 +00:00
|
|
|
*/
|
2011-12-29 12:42:19 +00:00
|
|
|
$('<div>')
|
|
|
|
.append(
|
|
|
|
Ox.Editable({
|
|
|
|
clickLink: pandora.clickLink,
|
|
|
|
placeholder: formatLight('unknown'),
|
|
|
|
tooltip: 'Doubleclick to edit',
|
|
|
|
type: 'textarea',
|
|
|
|
value: data.description || ''
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(event) {
|
|
|
|
editMetadata('description', event.value);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.appendTo($text);
|
|
|
|
|
|
|
|
var list_keys = ['language', 'category', 'director', 'cinematographer'];
|
2011-12-27 06:54:49 +00:00
|
|
|
$('<div>').html('<br>').appendTo($text);
|
|
|
|
[
|
2011-12-29 12:42:19 +00:00
|
|
|
'date',
|
|
|
|
'location',
|
|
|
|
'director',
|
|
|
|
'cinematographer',
|
2011-12-27 09:40:11 +00:00
|
|
|
'language',
|
2011-12-27 06:54:49 +00:00
|
|
|
'source',
|
|
|
|
'collection',
|
|
|
|
'category',
|
|
|
|
'user',
|
|
|
|
].forEach(function(key) {
|
2011-12-27 09:40:11 +00:00
|
|
|
var $div = $('<div>')
|
|
|
|
.appendTo($text);
|
2011-12-27 06:54:49 +00:00
|
|
|
$('<div>')
|
2011-12-27 09:40:11 +00:00
|
|
|
.html(
|
|
|
|
formatKey({
|
|
|
|
categorty: 'categories',
|
|
|
|
user: 'contributor'
|
|
|
|
}[key] || key).replace('</span>', ' </span>')
|
|
|
|
)
|
|
|
|
.appendTo($div);
|
|
|
|
Ox.Editable({
|
|
|
|
clickLink: pandora.clickLink,
|
|
|
|
format: function(value) {
|
2011-12-29 12:42:19 +00:00
|
|
|
return list_keys.indexOf(key) >= 0
|
2011-12-27 09:40:11 +00:00
|
|
|
? formatValue(value.split(', '), key)
|
|
|
|
: value;
|
|
|
|
},
|
|
|
|
placeholder: formatLight('unknown'),
|
|
|
|
tooltip: 'Doubleclick to edit',
|
2011-12-29 12:42:19 +00:00
|
|
|
value: list_keys.indexOf(key) >= 0
|
2011-12-27 09:40:11 +00:00
|
|
|
? (data[key] || []).join(', ')
|
|
|
|
: data[key] || ''
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(event) {
|
2011-12-27 13:52:16 +00:00
|
|
|
editMetadata(key, event.value);
|
2011-12-27 09:40:11 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo($div);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('<div>').css({height: '16px'}).appendTo($text);
|
2011-12-27 06:54:49 +00:00
|
|
|
[
|
|
|
|
'created',
|
2011-12-27 09:40:11 +00:00
|
|
|
'accessed',
|
|
|
|
'modified',
|
2011-12-27 06:54:49 +00:00
|
|
|
].forEach(function(key) {
|
2011-12-27 09:40:11 +00:00
|
|
|
$('<span>')
|
|
|
|
.css({padding: '4px'})
|
2011-12-27 06:54:49 +00:00
|
|
|
.html(
|
2011-12-27 09:40:11 +00:00
|
|
|
formatKey(key) + data[key]
|
2011-12-27 06:54:49 +00:00
|
|
|
)
|
|
|
|
.appendTo($text);
|
|
|
|
});
|
2011-12-27 09:40:11 +00:00
|
|
|
|
2011-12-27 06:54:49 +00:00
|
|
|
$('<div>').css({height: '16px'}).appendTo($text);
|
|
|
|
|
|
|
|
// Hue, Saturation, Lightness, Volume --------------------------------------
|
|
|
|
|
|
|
|
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
|
|
|
|
$('<div>')
|
|
|
|
.css({marginBottom: '4px'})
|
|
|
|
.append(formatKey(key, true))
|
|
|
|
.append(
|
|
|
|
Ox.Theme.formatColor(
|
|
|
|
data[key] || 0, key == 'volume' ? 'lightness' : key
|
|
|
|
).css({textAlign: 'right'})
|
|
|
|
)
|
|
|
|
.appendTo($statistics);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Rights Level ------------------------------------------------------------
|
|
|
|
|
|
|
|
var $rightsLevel = $('<div>');
|
|
|
|
$('<div>')
|
|
|
|
.css({marginBottom: '4px'})
|
|
|
|
.append(formatKey('Rights Level', true))
|
|
|
|
.append($rightsLevel)
|
|
|
|
.appendTo($statistics);
|
|
|
|
renderRightsLevel();
|
|
|
|
|
|
|
|
// Notes -------------------------------------------------------------------
|
|
|
|
|
|
|
|
if (canEdit) {
|
|
|
|
|
|
|
|
$('<div>')
|
|
|
|
.css({marginBottom: '4px'})
|
|
|
|
.append(formatKey('Notes', true))
|
|
|
|
.append(
|
|
|
|
Ox.Editable({
|
|
|
|
height: 128,
|
|
|
|
placeholder: formatLight('No notes'),
|
|
|
|
tooltip: 'Doubleclick to edit',
|
|
|
|
type: 'textarea',
|
|
|
|
value: data.notes,
|
|
|
|
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);
|
|
|
|
|
|
|
|
function editMetadata(key, value) {
|
|
|
|
if (value != data[key]) {
|
|
|
|
var edit = {id: data.id};
|
|
|
|
if (key == 'title') {
|
|
|
|
Ox.extend(edit, parseTitle(value));
|
2011-12-27 13:52:16 +00:00
|
|
|
} else if(['director', 'country', 'language', 'category'].indexOf(key) >= 0) {
|
|
|
|
edit[key] = value ? value.split(', ') : [];
|
2011-12-27 06:54:49 +00:00
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
// FIXME: value function should accept {k: v, ...}
|
|
|
|
pandora.$ui.browser.value(result.data.id, 'title', result.data.title);
|
|
|
|
pandora.$ui.browser.value(result.data.id, 'director', result.data.director);
|
|
|
|
pandora.$ui.browser.value(result.data.id, 'country', result.data.country);
|
|
|
|
pandora.$ui.browser.value(result.data.id, 'year', result.data.year);
|
|
|
|
//pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatKey(key, isStatistics) {
|
|
|
|
return isStatistics
|
|
|
|
? $('<div>').css({marginBottom: '4px', fontWeight: 'bold'}).html(Ox.toTitleCase(key))
|
|
|
|
: '<span style="font-weight: bold">' + Ox.toTitleCase(key) + ':</span> ';
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatLight(str) {
|
|
|
|
return '<span style="color: rgb(128, 128, 128)">' + str + '</span>';
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatTitle(title) {
|
|
|
|
var match = /(\(S\d{2}E\d{2}\))/.exec(title);
|
|
|
|
if (match) {
|
|
|
|
title = title.replace(match[0], formatLight(match[0]));
|
|
|
|
}
|
|
|
|
return title + (
|
|
|
|
data.originalTitle && data.originalTitle != title
|
|
|
|
? ' ' + formatLight('(' + data.originalTitle + ')') : ''
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatValue(value, key) {
|
|
|
|
return (Ox.isArray(value) ? value : [value]).map(function(value) {
|
|
|
|
return key ?
|
|
|
|
'<a href="/' + key + '=' + value + '">' + value + '</a>'
|
|
|
|
: value;
|
|
|
|
}).join(', ');
|
|
|
|
}
|
|
|
|
|
|
|
|
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),
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function reloadMetadata() {
|
|
|
|
var item = ui.item;
|
|
|
|
// fixme: maybe there's a better method name for this?
|
|
|
|
pandora.api.updateExternalData({
|
|
|
|
id: ui.item
|
|
|
|
}, function(result) {
|
|
|
|
Ox.Request.clearCache(item);
|
|
|
|
if (ui.item == item && ui.itemView == 'info') {
|
|
|
|
pandora.$ui.contentPanel.replaceElement(
|
|
|
|
1, pandora.$ui.item = pandora.ui.item()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderCapabilities(rightsLevel) {
|
|
|
|
var capabilities = Ox.merge(
|
|
|
|
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') + ' '
|
|
|
|
+ Ox.map(Ox.toSlashes(capability.name).split('/'), function(word, i) {
|
|
|
|
return i == 0 ? null : word.toLowerCase();
|
|
|
|
}).join(' '),
|
|
|
|
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({
|
|
|
|
title: 'Help',
|
|
|
|
tooltip: 'About Rights',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({marginLeft: '52px'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
pandora.UI.set({page: 'rights'});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo($line);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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, checked: i == data.rightslevel};
|
|
|
|
}),
|
|
|
|
width: 128
|
|
|
|
})
|
|
|
|
.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({
|
|
|
|
marginBottom: '4px'
|
|
|
|
})
|
|
|
|
.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({
|
|
|
|
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
|
|
|
|
}, 250);
|
|
|
|
pandora.UI.set({infoIconSize: iconSize});
|
|
|
|
}
|
|
|
|
|
|
|
|
that.reload = function() {
|
|
|
|
var src = src = '/' + data.id + '/' + (
|
|
|
|
ui.icons == 'posters'
|
|
|
|
? (ui.showSitePoster ? 'siteposter' : 'poster') : 'icon'
|
|
|
|
) + '512.jpg?' + Ox.uid()
|
|
|
|
$icon.attr({src: src});
|
|
|
|
$reflectionIcon.attr({src: src});
|
|
|
|
iconSize = iconSize == 256 ? 512 : 256;
|
|
|
|
iconRatio = ui.icons == 'posters'
|
|
|
|
? (ui.showSitePoster ? 5/8 : data.posterRatio) : 1;
|
|
|
|
toggleIconSize();
|
|
|
|
pandora.user.level == 'admin' && $list.replaceWith($list = renderList());
|
|
|
|
};
|
|
|
|
|
|
|
|
that.resize = function() {
|
|
|
|
var height = pandora.$ui.contentPanel.size(1);
|
|
|
|
$list && $list.css({height: height + 'px'});
|
|
|
|
$data.css({height: height + 'px'});
|
|
|
|
};
|
|
|
|
|
|
|
|
that.bindEvent({
|
|
|
|
pandora_icons: that.reload,
|
|
|
|
pandora_showsiteposter: function() {
|
|
|
|
ui.icons == 'posters' && that.reload();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
}
|