pandora/static/js/pandora/infoView.js

662 lines
24 KiB
JavaScript
Raw Normal View History

2011-11-05 17:04:10 +00:00
'use strict';
2011-08-05 18:26:27 +00:00
pandora.ui.infoView = function(data) {
2011-10-02 15:37:58 +00:00
var ui = pandora.user.ui,
2012-04-20 10:36:42 +00:00
descriptions = [],
canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level] || data.editable,
2011-10-02 15:37:58 +00:00
css = {
2011-08-06 03:19:14 +00:00
marginTop: '4px',
textAlign: 'justify',
MozUserSelect: 'text',
WebkitUserSelect: 'text'
},
2012-04-20 10:36:42 +00:00
html,
iconRatio = ui.icons == 'posters' ? data.posterRatio : 1,
2011-10-02 15:37:58 +00:00
iconSize = ui.infoIconSize,
2011-08-07 22:15:08 +00:00
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,
2011-10-02 15:37:58 +00:00
margin = 16,
statisticsWidth = 128,
2011-08-06 13:34:56 +00:00
uid = Ox.uid(),
2011-10-02 15:37:58 +00:00
that = Ox.Element(),
2012-04-20 10:36:42 +00:00
$div,
2011-08-05 18:26:27 +00:00
$list,
2011-10-02 15:37:58 +00:00
2012-04-20 10:36:42 +00:00
$info = Ox.Element()
2011-08-05 18:26:27 +00:00
.css({
position: 'absolute',
2012-04-20 10:36:42 +00:00
left: 0,
2011-08-05 18:26:27 +00:00
top: 0,
right: 0,
2012-04-20 10:36:42 +00:00
bottom: 0,
overflowY: 'auto'
2011-08-05 18:26:27 +00:00
})
2012-04-20 10:36:42 +00:00
.appendTo(that),
2011-10-02 15:37:58 +00:00
2012-04-20 10:36:42 +00:00
$left = Ox.Element()
2011-08-05 18:26:27 +00:00
.appendTo($info),
2011-10-02 15:37:58 +00:00
$icon = Ox.Element({
element: '<img>',
})
2011-08-05 18:26:27 +00:00
.attr({
2011-08-07 22:15:08 +00:00
src: '/' + data.id + '/' + (
2012-04-20 10:36:42 +00:00
ui.icons == 'posters' ? 'poster' : 'icon'
2011-08-07 22:15:08 +00:00
) + '512.jpg?' + uid
2011-08-05 18:26:27 +00:00
})
.css({
position: 'absolute',
2011-08-07 22:15:08 +00:00
left: margin + iconLeft + 'px',
2011-08-05 18:26:27 +00:00
top: margin + 'px',
2011-08-07 22:15:08 +00:00
width: iconWidth + 'px',
height: iconHeight + 'px',
borderRadius: borderRadius + 'px',
2011-08-06 01:34:07 +00:00
cursor: 'pointer'
})
.bindEvent({
2011-08-07 22:15:08 +00:00
singleclick: toggleIconSize
2011-08-05 18:26:27 +00:00
})
2012-04-20 10:36:42 +00:00
.appendTo($left),
2011-10-02 15:37:58 +00:00
2011-08-05 18:26:27 +00:00
$reflection = $('<div>')
2011-08-07 16:30:26 +00:00
.addClass('OxReflection')
2011-08-05 18:26:27 +00:00
.css({
position: 'absolute',
left: margin + 'px',
2011-08-07 22:15:08 +00:00
top: margin + iconHeight + 'px',
width: iconSize + 'px',
height: iconSize / 2 + 'px',
2011-08-05 18:26:27 +00:00
overflow: 'hidden'
})
2012-04-20 10:36:42 +00:00
.appendTo($left),
2011-10-02 15:37:58 +00:00
2011-08-07 22:15:08 +00:00
$reflectionIcon = $('<img>')
2011-08-05 18:26:27 +00:00
.attr({
2011-08-07 22:15:08 +00:00
src: '/' + data.id + '/' + (
2012-04-20 10:36:42 +00:00
ui.icons == 'posters' ? 'poster' : 'icon'
2011-08-07 22:15:08 +00:00
) + '512.jpg?' + uid
2011-08-05 18:26:27 +00:00
})
.css({
position: 'absolute',
2011-08-07 22:15:08 +00:00
left: iconLeft + 'px',
width: iconWidth + 'px',
height: iconHeight + 'px',
borderRadius: borderRadius + 'px'
2011-08-05 18:26:27 +00:00
})
.appendTo($reflection),
2011-10-02 15:37:58 +00:00
2011-08-05 18:26:27 +00:00
$reflectionGradient = $('<div>')
.css({
position: 'absolute',
2011-08-07 22:15:08 +00:00
width: iconSize + 'px',
height: iconSize / 2 + 'px'
2011-08-05 18:26:27 +00:00
})
.appendTo($reflection),
2011-10-02 15:37:58 +00:00
2012-04-20 10:36:42 +00:00
$data = $('<div>')
.css({
position: 'absolute',
left: margin + 'px',
top: margin + iconHeight + margin + 'px',
width: iconSize + 'px',
})
.appendTo($left),
$center = Ox.Element()
.addClass('OxTextPage')
2011-08-05 18:26:27 +00:00
.css({
position: 'absolute',
2011-08-07 22:15:08 +00:00
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
2011-08-05 18:26:27 +00:00
top: margin + 'px',
right: margin + statisticsWidth + margin + 'px',
2011-08-05 18:26:27 +00:00
})
2012-04-20 10:36:42 +00:00
.appendTo($info),
2011-10-02 15:37:58 +00:00
2012-04-20 10:36:42 +00:00
$right = $('<div>')
2011-10-02 15:37:58 +00:00
.css({
position: 'absolute',
width: statisticsWidth + 'px',
top: margin + 'px',
right: margin + 'px'
})
2012-04-20 10:36:42 +00:00
.appendTo($info),
$capabilities;
if (!canEdit) {
pandora.createLinks($info);
}
2011-10-02 15:37:58 +00:00
2012-04-20 10:36:42 +00:00
var listKeys = [
'country', 'language', 'director', 'featuring',
'groups'
2012-04-20 10:36:42 +00:00
];
2011-11-05 17:26:03 +00:00
2011-10-24 21:30:45 +00:00
// Title -------------------------------------------------------------------
2011-08-06 03:19:14 +00:00
$('<div>')
.css({
2012-04-20 10:36:42 +00:00
marginTop: '-2px',
2011-08-06 03:19:14 +00:00
})
.append(
Ox.Editable({
2012-04-20 10:36:42 +00:00
editable: canEdit,
tooltip: canEdit ? pandora.getEditTooltip() : '',
2013-04-18 15:59:30 +00:00
value: data.title || ''
})
.css({
display: 'inline-block',
2011-11-03 17:11:10 +00:00
marginBottom: '-3px',
fontWeight: 'bold',
fontSize: '13px',
MozUserSelect: 'text',
WebkitUserSelect: 'text'
})
.bindEvent({
2011-10-24 21:30:45 +00:00
submit: function(event) {
editMetadata('title', event.value);
}
})
2011-08-06 03:19:14 +00:00
)
2012-04-20 10:36:42 +00:00
.appendTo($center);
2011-10-24 21:30:45 +00:00
// Year, Country, Language and Duration -----------------------------------
2011-08-06 01:04:09 +00:00
2012-04-20 10:36:42 +00:00
if (canEdit) {
$div = $('<div>').css(css).css({marginTop: '12px'}).appendTo($center);
['year', 'country', 'language', 'duration'].forEach(function(key, i) {
2012-01-20 18:10:25 +00:00
i && $('<div>').css({float: 'left'}).html(';&nbsp;').appendTo($div);
$('<div>')
.css({float: 'left'})
.html(formatKey(key).replace('</span>', '&nbsp;</span>'))
.appendTo($div);
Ox.Editable({
2011-10-27 18:47:52 +00:00
clickLink: pandora.clickLink,
2012-04-20 10:36:42 +00:00
editable: key != 'duration',
format: function(value) {
2012-04-20 10:36:42 +00:00
return formatValue(listKeys.indexOf(key) >= 0
? value.split(', ') : value, key);
},
2011-11-03 17:11:10 +00:00
placeholder: formatLight('unknown'),
tooltip: pandora.getEditTooltip(),
2012-04-20 10:36:42 +00:00
value: listKeys.indexOf(key) >= 0
? (data[key] || []).join(', ')
: data[key] || ''
})
.css({float: 'left'})
2011-10-24 21:30:45 +00:00
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
}
})
.appendTo($div);
});
2012-04-20 10:36:42 +00:00
$('<br>').appendTo($center);
} else {
html = [];
['year', 'country', 'language', 'duration'].forEach(function(key) {
if (data[key]) {
2012-04-20 10:36:42 +00:00
html.push(formatKey(key) + formatValue(data[key], key));
2011-08-06 01:04:09 +00:00
}
});
2012-04-20 10:36:42 +00:00
$('<div>').css(css).html(html.join('; ')).appendTo($center);
2011-08-06 01:04:09 +00:00
}
2012-04-20 10:36:42 +00:00
// Director, Cinematographer and Featuring ---------------------------------
2011-08-06 01:04:09 +00:00
2012-04-20 10:36:42 +00:00
if (canEdit) {
$div = $('<div>').css(css).css('clear', 'both').appendTo($center);
['director', 'featuring'].forEach(function(key, i) {
2012-04-20 10:36:42 +00:00
i && $('<div>').css({float: 'left'}).html(';&nbsp;').appendTo($div);
$('<div>')
.css({float: 'left'})
.html(formatKey(key).replace('</span>', '&nbsp;</span>'))
.appendTo($div);
Ox.Editable({
clickLink: pandora.clickLink,
format: function(value) {
return formatValue(value.split(', '), 'name');
},
placeholder: formatLight('unknown'),
tooltip: pandora.getEditTooltip(),
2012-04-20 10:36:42 +00:00
value: listKeys.indexOf(key) >= 0
? (data[key] || []).join(', ')
: data[key] || ''
})
.css({float: 'left'})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
}
})
.appendTo($div);
});
$('<br>').appendTo($center);
} else if (data.director || data.cinematographer || data.featuring) {
2011-08-06 01:04:09 +00:00
html = [];
['director', 'featuring'].forEach(function(key) {
2012-04-20 10:36:42 +00:00
if (data[key] && data[key].length) {
html.push(
formatKey(key)
+ formatValue(data[key], key)
);
}
2011-08-06 01:04:09 +00:00
});
2012-04-20 10:36:42 +00:00
$('<div>').css(css).html(html.join('; ')).appendTo($center);
2011-08-06 01:04:09 +00:00
}
2012-04-20 10:36:42 +00:00
// Summary -------------------------------------------------------------
$div = $('<div>').css(css).css('clear', 'both').appendTo($center);
2011-08-05 18:26:27 +00:00
2012-04-20 10:36:42 +00:00
if (canEdit) {
2011-08-05 18:26:27 +00:00
$('<div>')
2012-04-20 10:36:42 +00:00
.css({marginTop: '16px'})
2011-08-05 18:26:27 +00:00
.append(
2012-04-20 10:36:42 +00:00
Ox.Editable({
clickLink: pandora.clickLink,
editable: canEdit,
maxHeight: Infinity,
placeholder: formatLight('No Summary'),
tooltip: canEdit ? pandora.getEditTooltip() : '',
2012-04-20 10:36:42 +00:00
type: 'textarea',
value: data.summary || '',
//width: 300
})
.bindEvent({
submit: function(event) {
editMetadata('summary', event.value);
}
})
.css(css)
2011-08-05 18:26:27 +00:00
)
2012-04-20 10:36:42 +00:00
.appendTo($center);
2012-06-10 18:31:02 +00:00
} else if (data.summary) {
2012-04-20 10:36:42 +00:00
$('<div>').css(css).html(data.summary).appendTo($center);
2011-08-05 18:26:27 +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'})
.append(formatKey(itemKey.title, true))
.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($right);
});
2011-10-25 13:59:27 +00:00
// Hue, Saturation, Lightness, Volume --------------------------------------
2011-10-24 10:04:41 +00:00
2011-10-23 09:13:57 +00:00
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
2011-10-02 15:37:58 +00:00
$('<div>')
2011-10-23 09:13:57 +00:00
.css({marginBottom: '4px'})
.append(formatKey(key, true))
.append(
Ox.Theme.formatColor(
data[key] || 0, key == 'volume' ? 'lightness' : key
).css({textAlign: 'right'})
)
2012-04-20 10:36:42 +00:00
.appendTo($right);
});
// Cuts per Minute ---------------------------------------------------------
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey('cuts per minute', true))
.append(
Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'})
.html(Ox.formatNumber(data['cutsperminute'] || 0, 3))
)
.appendTo($right);
2012-04-20 10:36:42 +00:00
// User and Groups ---------------------------------------------------------
['user', 'groups'].forEach(function(key) {
(canEdit || data[key] && data[key].length) && $('<div>')
.css({marginBottom: '4px'})
.append(formatKey(key, true))
.append(
$('<div>')
.css({margin: '2px 0 0 -1px'}) // fixme: weird
.append(
Ox.Editable({
placeholder: key == 'groups' ? formatLight('No Groups') : '',
editable: canEdit,
tooltip: canEdit ? pandora.getEditTooltip() : '',
2012-04-20 10:36:42 +00:00
value: key == 'user' ? data[key] : data[key].join(', ')
})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
}
})
)
)
.appendTo($right);
});
// Created and Modified ----------------------------------------------------
['created', 'modified'].forEach(function(key) {
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey(key, true))
.append(
$('<div>').html(Ox.formatDate(data[key], '%B %e, %Y'))
)
.appendTo($right);
2011-10-02 15:37:58 +00:00
});
2011-10-22 21:03:28 +00:00
2011-10-25 13:59:27 +00:00
// Rights Level ------------------------------------------------------------
2012-04-20 10:36:42 +00:00
if (canEdit) {
var $rightsLevel = $('<div>');
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey('Rights Level', true))
.append($rightsLevel)
.appendTo($right);
renderRightsLevel();
}
2011-08-06 01:34:07 +00:00
2012-04-20 10:36:42 +00:00
// Notes --------------------------------------------------------------------
2011-10-25 13:59:27 +00:00
if (canEdit) {
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey('Notes', true))
.append(
Ox.Editable({
height: 128,
placeholder: formatLight('No notes'),
tooltip: pandora.getEditTooltip(),
2011-10-25 13:59:27 +00:00
type: 'textarea',
2013-04-18 15:59:30 +00:00
value: data.notes || '',
2011-10-25 13:59:27 +00:00
width: 128
})
.bindEvent({
submit: function(event) {
2012-04-20 10:36:42 +00:00
editMetadata('notes', event.value);
2011-10-25 13:59:27 +00:00
}
})
)
2012-04-20 10:36:42 +00:00
.appendTo($right);
2011-10-29 17:46:46 +00:00
2011-10-25 13:59:27 +00:00
}
2012-04-20 10:36:42 +00:00
$('<div>').css({height: '16px'}).appendTo($right);
2011-08-05 18:26:27 +00:00
2011-10-24 21:30:45 +00:00
function editMetadata(key, value) {
if (value != data[key]) {
var edit = {id: data.id};
if (key == 'title') {
2012-04-20 10:36:42 +00:00
edit[key] = value;
} else if (listKeys.indexOf(key) >= 0) {
edit[key] = value ? value.split(', ') : [];
} else {
2012-04-20 10:36:42 +00:00
edit[key] = value ? value : null;
2011-10-24 21:30:45 +00:00
}
pandora.api.edit(edit, function(result) {
2012-04-20 10:36:42 +00:00
data[key] = value;
descriptions[key] && descriptions[key].options({
value: result.data[key + 'description']
});
Ox.Request.clearCache(); // fixme: too much? can change filter/list etc
if (result.data.id != data.id) {
pandora.UI.set({item: result.data.id});
pandora.$ui.browser.value(data.id, 'id', result.data.id);
}
2013-02-11 12:14:15 +00:00
pandora.updateItemContext();
// 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);
2012-04-20 10:36:42 +00:00
pandora.$ui.itemTitle
.options({
title: '<b>' + result.data.title
+ (Ox.len(result.data.director)
? ' (' + result.data.director.join(', ') + ')'
: '')
+ (result.data.year ? ' ' + result.data.year : '') + '</b>'
});
//pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser());
});
}
2011-10-24 21:30:45 +00:00
}
2011-10-02 15:37:58 +00:00
function formatKey(key, isStatistics) {
return isStatistics
? $('<div>').css({marginBottom: '4px', fontWeight: 'bold'})
.html(Ox.toTitleCase(key).replace(' Per ', ' per '))
2011-10-02 15:37:58 +00:00
: '<span style="font-weight: bold">' + Ox.toTitleCase(key) + ':</span> ';
2011-08-05 18:26:27 +00:00
}
2011-08-06 03:19:14 +00:00
function formatLight(str) {
return '<span style="color: rgb(128, 128, 128)">' + str + '</span>';
}
2011-08-05 18:26:27 +00:00
function formatValue(value, key) {
2012-06-10 18:31:02 +00:00
if (key == 'date') {
2012-04-20 10:36:42 +00:00
return value ? Ox.formatDate(value,
['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length]
) : '';
2012-06-10 18:31:02 +00:00
} else if (key == 'duration') {
return value < 60 ? Math.round(value) + ' sec'
: Math.round(value / 60) + ' min';
2012-04-20 10:36:42 +00:00
}
2011-08-05 18:26:27 +00:00
return (Ox.isArray(value) ? value : [value]).map(function(value) {
2011-08-07 16:30:26 +00:00
return key ?
2012-04-20 10:36:42 +00:00
'<a href="/' + key + '==' + value + '">' + value + '</a>'
2011-08-07 16:30:26 +00:00
: value;
2011-08-05 18:26:27 +00:00
}).join(', ');
}
2011-10-26 14:52:23 +00:00
function getRightsLevelElement(rightsLevel) {
return Ox.Theme.formatColorLevel(
rightsLevel,
pandora.site.rightsLevels.map(function(rightsLevel) {
return rightsLevel.name;
})
);
2011-10-24 10:04:41 +00:00
}
function renderCapabilities(rightsLevel) {
2012-05-24 08:22:56 +00:00
var capabilities = [].concat(
canEdit ? [{name: 'canSeeItem', symbol: 'Find'}] : [],
2011-10-24 10:04:41 +00:00
[
{name: 'canPlayClips', symbol: 'PlayInToOut'},
{name: 'canPlayVideo', symbol: 'Play'},
{name: 'canDownloadVideo', symbol: 'Download'}
]
),
userLevels = canEdit ? pandora.site.userLevels : [pandora.user.level];
$capabilities.empty();
2011-10-26 14:52:23 +00:00
userLevels.forEach(function(userLevel, i) {
var $element,
$line = $('<div>')
.css({
height: '16px',
marginBottom: '4px'
})
.appendTo($capabilities);
2011-10-25 13:59:27 +00:00
if (canEdit) {
2011-10-26 14:52:23 +00:00
$element = Ox.Theme.formatColorLevel(i, userLevels.map(function(userLevel) {
return Ox.toTitleCase(userLevel);
}), [0, 240]);
2011-10-25 13:59:27 +00:00
Ox.Label({
textAlign: 'center',
title: Ox.toTitleCase(userLevel),
2011-10-26 14:52:23 +00:00
width: 60
2011-10-25 13:59:27 +00:00
})
2011-10-26 14:52:23 +00:00
.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')})
2011-10-25 13:59:27 +00:00
.appendTo($line);
}
2011-10-24 10:04:41 +00:00
capabilities.forEach(function(capability) {
2011-10-26 14:52:23 +00:00
var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel,
$element = Ox.Theme.formatColorLevel(hasCapability, ['', '']);
2011-10-24 10:04:41 +00:00
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(),
2011-10-24 10:04:41 +00:00
title: capability.symbol,
type: 'image'
})
2011-10-26 14:52:23 +00:00
.addClass('OxColor OxColorGradient')
.css({background: $element.css('background')})
2011-10-25 13:59:27 +00:00
.css('margin' + (canEdit ? 'Left' : 'Right'), '4px')
2011-10-26 14:52:23 +00:00
.data({OxColor: $element.data('OxColor')})
2011-10-24 10:04:41 +00:00
.appendTo($line);
});
2011-10-25 13:59:27 +00:00
if (!canEdit) {
Ox.Button({
title: 'Help',
tooltip: 'About Rights',
type: 'image'
})
.css({marginLeft: '52px'})
.bindEvent({
click: function() {
2011-11-11 16:53:05 +00:00
pandora.UI.set({page: 'rights'});
2011-10-25 13:59:27 +00:00
}
})
.appendTo($line);
}
2011-10-24 10:04:41 +00:00
});
}
2011-10-24 10:04:41 +00:00
function renderRightsLevel() {
2011-11-05 17:26:03 +00:00
var $rightsLevelElement = getRightsLevelElement(data.rightslevel),
2011-10-26 14:52:23 +00:00
$rightsLevelSelect;
2011-10-24 10:04:41 +00:00
$rightsLevel.empty();
if (canEdit) {
$rightsLevelSelect = Ox.Select({
items: pandora.site.rightsLevels.map(function(rightsLevel, i) {
2011-12-22 17:37:13 +00:00
return {id: i, title: rightsLevel.name};
2011-10-24 10:04:41 +00:00
}),
2011-12-22 17:37:13 +00:00
width: 128,
value: data.rightslevel
2011-10-24 10:04:41 +00:00
})
2011-10-26 14:52:23 +00:00
.addClass('OxColor OxColorGradient')
.css({
marginBottom: '4px',
background: $rightsLevelElement.css('background')
})
.data({OxColor: $rightsLevelElement.data('OxColor')})
2011-10-24 10:04:41 +00:00
.bindEvent({
change: function(event) {
2011-12-27 06:54:49 +00:00
var rightsLevel = event.value;
2011-10-26 14:52:23 +00:00
$rightsLevelElement = getRightsLevelElement(rightsLevel);
$rightsLevelSelect
.css({background: $rightsLevelElement.css('background')})
.data({OxColor: $rightsLevelElement.data('OxColor')})
2011-10-24 10:04:41 +00:00
renderCapabilities(rightsLevel);
2011-10-25 13:59:27 +00:00
pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) {
2011-10-24 10:04:41 +00:00
// ...
});
}
})
.appendTo($rightsLevel);
2011-10-25 13:59:27 +00:00
} else {
2011-11-05 17:21:49 +00:00
$rightsLevelElement
2011-10-26 14:52:23 +00:00
.css({
2011-10-25 13:59:27 +00:00
marginBottom: '4px'
2011-10-26 14:52:23 +00:00
})
2011-10-25 13:59:27 +00:00
.appendTo($rightsLevel);
2011-10-24 10:04:41 +00:00
}
$capabilities = $('<div>').appendTo($rightsLevel);
2011-10-25 13:59:27 +00:00
renderCapabilities(data.rightslevel);
2011-10-24 10:04:41 +00:00
}
2011-08-07 22:15:08 +00:00
function toggleIconSize() {
iconSize = iconSize == 256 ? 512 : 256;
iconWidth = iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio);
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio);
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
2011-10-02 15:37:58 +00:00
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8;
2011-08-07 22:15:08 +00:00
$icon.animate({
left: margin + iconLeft + 'px',
width: iconWidth + 'px',
height: iconHeight + 'px',
2011-10-29 17:46:46 +00:00
borderRadius: borderRadius + 'px'
2011-08-06 01:34:07 +00:00
}, 250);
$reflection.animate({
2011-08-07 22:15:08 +00:00
top: margin + iconHeight + 'px',
width: iconSize + 'px',
height: iconSize / 2 + 'px'
2011-08-06 01:34:07 +00:00
}, 250);
2011-08-07 22:15:08 +00:00
$reflectionIcon.animate({
left: iconLeft + 'px',
width: iconWidth + 'px',
height: iconHeight + 'px',
borderRadius: borderRadius + 'px'
2011-08-06 01:34:07 +00:00
}, 250);
$reflectionGradient.animate({
2011-08-07 22:15:08 +00:00
width: iconSize + 'px',
height: iconSize / 2 + 'px'
2011-08-06 01:34:07 +00:00
}, 250);
2012-04-20 10:36:42 +00:00
$data.animate({
top: margin + iconHeight + margin + 'px',
width: iconSize + 'px',
}, 250);
$center.animate({
2011-08-07 22:15:08 +00:00
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
2011-08-06 01:34:07 +00:00
}, 250);
2011-08-07 22:15:08 +00:00
pandora.UI.set({infoIconSize: iconSize});
2011-08-06 01:34:07 +00:00
}
2011-08-07 22:15:08 +00:00
that.reload = function() {
var src = src = '/' + data.id + '/' + (
2012-04-20 10:36:42 +00:00
ui.icons == 'posters' ? 'poster' : 'icon'
) + '512.jpg?' + Ox.uid();
2011-08-07 22:15:08 +00:00
$icon.attr({src: src});
$reflectionIcon.attr({src: src});
iconSize = iconSize == 256 ? 512 : 256;
2011-10-02 15:37:58 +00:00
iconRatio = ui.icons == 'posters'
? (ui.showSitePosters ? 5/8 : data.posterRatio) : 1;
2011-08-07 22:15:08 +00:00
toggleIconSize();
};
2011-08-05 18:26:27 +00:00
that.resize = function() {
2012-04-20 10:36:42 +00:00
2011-08-05 18:26:27 +00:00
};
that.bindEvent({
pandora_icons: that.reload,
pandora_showsiteposters: function() {
2011-10-02 15:37:58 +00:00
ui.icons == 'posters' && that.reload();
2011-09-27 14:14:40 +00:00
}
});
2011-08-05 18:26:27 +00:00
return that;
2011-08-20 09:07:45 +00:00
}