pandora/static/js/pandora/infoView.padma.js

754 lines
27 KiB
JavaScript
Raw Normal View History

2011-12-27 06:54:49 +00:00
'use strict';
pandora.ui.infoView = function(data) {
var ui = pandora.user.ui,
2012-01-15 15:05:37 +00:00
descriptions = [],
canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level] || data.editable,
2011-12-27 06:54:49 +00:00
css = {
marginTop: '4px',
textAlign: 'justify',
MozUserSelect: 'text',
WebkitUserSelect: 'text'
},
2012-02-11 12:27:58 +00:00
html,
2012-01-20 18:10:25 +00:00
iconRatio = ui.icons == 'posters' ? data.posterRatio : 1,
2011-12-27 06:54:49 +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,
margin = 16,
statisticsWidth = 128,
uid = Ox.uid(),
that = Ox.Element(),
2012-02-11 12:27:58 +00:00
$div,
2011-12-27 06:54:49 +00:00
$list,
2012-01-20 18:10:25 +00:00
$info = Ox.Element()
2011-12-27 06:54:49 +00:00
.css({
position: 'absolute',
2012-01-20 18:10:25 +00:00
left: 0,
2011-12-27 06:54:49 +00:00
top: 0,
right: 0,
2012-01-20 18:10:25 +00:00
bottom: 0,
overflowY: 'auto'
2011-12-27 06:54:49 +00:00
})
2012-01-20 18:10:25 +00:00
.appendTo(that),
2011-12-27 06:54:49 +00:00
2012-01-20 18:10:25 +00:00
$left = Ox.Element()
2011-12-27 06:54:49 +00:00
.appendTo($info),
$icon = Ox.Element({
element: '<img>',
})
.attr({
src: '/' + data.id + '/' + (
2012-01-20 18:10:25 +00:00
ui.icons == 'posters' ? 'poster' : 'icon'
2011-12-27 06:54:49 +00:00
) + '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
})
2012-01-20 18:10:25 +00:00
.appendTo($left),
2011-12-27 06:54:49 +00:00
$reflection = $('<div>')
.addClass('OxReflection')
.css({
position: 'absolute',
left: margin + 'px',
top: margin + iconHeight + 'px',
width: iconSize + 'px',
height: iconSize / 2 + 'px',
overflow: 'hidden'
})
2012-01-20 18:10:25 +00:00
.appendTo($left),
2011-12-27 06:54:49 +00:00
$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),
2012-01-20 18:10:25 +00:00
$data = $('<div>')
.css({
position: 'absolute',
left: margin + 'px',
2012-02-14 06:21:01 +00:00
top: margin + iconHeight + margin + 'px',
width: iconSize + 'px',
2012-01-20 18:10:25 +00:00
})
.appendTo($left),
$center = Ox.Element({
2011-12-27 06:54:49 +00:00
})
.css({
position: 'absolute',
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
top: margin + 'px',
right: margin + statisticsWidth + margin + 'px',
})
2012-01-20 18:10:25 +00:00
.appendTo($info),
2011-12-27 06:54:49 +00:00
2012-01-20 18:10:25 +00:00
$right = $('<div>')
2011-12-27 06:54:49 +00:00
.css({
position: 'absolute',
width: statisticsWidth + 'px',
top: margin + 'px',
right: margin + 'px'
})
2012-01-20 18:10:25 +00:00
.appendTo($info),
$capabilities;
2011-12-27 06:54:49 +00:00
2012-01-20 18:10:25 +00:00
if (!canEdit) {
pandora.createLinks($info);
}
var listKeys = [
'language', 'topic', 'director', 'cinematographer', 'featuring',
'groups', 'license'
];
2011-12-27 06:54:49 +00:00
2012-01-20 18:10:25 +00:00
// Source & Project --------------------------------------------------------
2011-12-27 06:54:49 +00:00
2012-01-20 19:04:48 +00:00
var count = 0;
2012-01-20 18:10:25 +00:00
['source', 'project'].forEach(function(key) {
2012-02-11 12:27:58 +00:00
$div = $('<div>').appendTo($data);
2012-01-20 19:04:48 +00:00
if (canEdit || data[key]) {
count && $('<br>').appendTo($div);
2012-01-20 18:10:25 +00:00
$('<div>')
.css({float: 'left'})
.html(
formatKey({
category: 'categories',
}[key] || key).replace('</span>', '&nbsp;</span>')
)
.appendTo($div);
Ox.Editable({
clickLink: pandora.clickLink,
format: function(value) {
return listKeys.indexOf(key) >= 0
? formatValue(value.split(', '), {
'director': 'name',
'cinematographer': 'name',
'features': 'name',
}[key] || key)
: value;
},
placeholder: formatLight('unknown'),
editable: canEdit,
tooltip: canEdit ? 'Doubleclick to edit' : '',
value: listKeys.indexOf(key) >= 0
? (data[key] || []).join(', ')
: data[key] || ''
})
.css({float: 'left'})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
}
})
.appendTo($div);
if (canEdit || data[key + 'description']) {
2012-02-14 06:24:42 +00:00
$('<br>').css({'clear': 'both'}).appendTo($div);
2012-01-20 18:10:25 +00:00
$('<div>')
.append(
descriptions[key] = Ox.Editable({
clickLink: pandora.clickLink,
placeholder: formatLight('No ' + Ox.toTitleCase(key) + ' Description'),
editable: canEdit,
tooltip: canEdit ? 'Doubleclick to edit' : '',
type: 'textarea',
value: data[key + 'description'] || ''
})
.bindEvent({
submit: function(event) {
editMetadata(key + 'description', event.value);
}
})
.css(css)
).css({
'margin-top': '8px',
})
.appendTo($div);
}
2012-01-20 19:04:48 +00:00
count++;
2012-01-20 18:10:25 +00:00
}
});
2011-12-27 06:54:49 +00:00
// Title -------------------------------------------------------------------
$('<div>')
.css({
2012-01-20 18:10:25 +00:00
marginTop: '-2px',
2011-12-27 06:54:49 +00:00
})
.append(
Ox.Editable({
2012-01-20 18:10:25 +00:00
editable: canEdit,
tooltip: canEdit ? 'Doubleclick to edit' : '',
2011-12-27 06:54:49 +00:00
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);
}
})
)
2012-01-20 18:10:25 +00:00
.appendTo($center);
2011-12-27 06:54:49 +00:00
2012-02-03 12:29:27 +00:00
// Location, Date, Language and Duration -----------------------------------
2012-01-20 18:10:25 +00:00
if (canEdit) {
2012-02-11 12:27:58 +00:00
$div = $('<div>').css(css).css({marginTop: '12px'}).appendTo($center);
2012-02-03 12:29:27 +00:00
['location', 'date', '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-12-27 06:54:49 +00:00
clickLink: pandora.clickLink,
editable: key != 'duration',
2012-01-20 18:10:25 +00:00
format: function(value) {
2012-02-18 13:21:15 +00:00
return formatValue(listKeys.indexOf(key) >= 0
? value.split(', ') : value, key);
2012-01-20 18:10:25 +00:00
},
placeholder: formatLight('unknown'),
tooltip: 'Doubleclick to edit',
value: listKeys.indexOf(key) >= 0
? (data[key] || []).join(', ')
: data[key] || ''
2011-12-27 06:54:49 +00:00
})
2012-01-20 18:10:25 +00:00
.css({float: 'left'})
2011-12-27 06:54:49 +00:00
.bindEvent({
submit: function(event) {
2012-01-20 18:10:25 +00:00
editMetadata(key, event.value);
2011-12-27 06:54:49 +00:00
}
})
2012-01-20 18:10:25 +00:00
.appendTo($div);
});
$('<br>').appendTo($center);
} else {
2012-02-11 12:27:58 +00:00
html = [];
['location', 'date', 'language', 'duration'].forEach(function(key) {
2012-01-20 18:10:25 +00:00
if (data[key]) {
2012-02-18 13:21:15 +00:00
html.push(formatKey(key) + formatValue(data[key], key));
2012-01-20 18:10:25 +00:00
}
});
$('<div>').css(css).html(html.join('; ')).appendTo($center);
2011-12-27 06:54:49 +00:00
}
2011-12-29 12:42:19 +00:00
2012-01-20 18:10:25 +00:00
// Director, Cinematographer and Featuring ---------------------------------
if (canEdit) {
2012-02-11 12:27:58 +00:00
$div = $('<div>').css(css).css('clear', 'both').appendTo($center);
2012-01-20 18:10:25 +00:00
['director', 'cinematographer', 'featuring'].forEach(function(key, i) {
i && $('<div>').css({float: 'left'}).html(';&nbsp;').appendTo($div);
2012-01-15 15:05:37 +00:00
$('<div>')
2012-01-20 18:10:25 +00:00
.css({float: 'left'})
.html(formatKey(key).replace('</span>', '&nbsp;</span>'))
2012-01-15 15:05:37 +00:00
.appendTo($div);
Ox.Editable({
2012-01-20 18:10:25 +00:00
clickLink: pandora.clickLink,
format: function(value) {
2012-02-11 12:27:58 +00:00
return formatValue(value.split(', '), 'name');
2012-01-20 18:10:25 +00:00
},
placeholder: formatLight('unknown'),
tooltip: 'Doubleclick to edit',
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) {
2012-02-11 12:27:58 +00:00
html = [];
2012-01-20 18:10:25 +00:00
['director', 'cinematographer', 'featuring'].forEach(function(key) {
2012-01-21 14:57:38 +00:00
if (data[key] && data[key].length) {
2012-01-20 18:10:25 +00:00
html.push(
formatKey(key)
+ formatValue(data[key], key)
2012-02-10 16:38:53 +00:00
);
2012-01-20 18:10:25 +00:00
}
});
$('<div>').css(css).html(html.join('; ')).appendTo($center);
}
// Topic -------------------------------------------------------------------
if (canEdit) {
2012-02-11 12:27:58 +00:00
var key = 'topic';
$div = $('<div>').css(css).css('clear', 'both').appendTo($center);
2012-01-20 18:10:25 +00:00
$('<div>')
.css({float: 'left'})
.html(formatKey('Topics').replace('</span>', '&nbsp;</span>'))
.appendTo($div);
Ox.Editable({
clickLink: pandora.clickLink,
format: function(value) {
2012-02-11 12:27:58 +00:00
return formatValue(value.split(', '), key);
},
placeholder: formatLight('unknown'),
2012-01-20 18:10:25 +00:00
tooltip: 'Doubleclick to edit',
value: listKeys.indexOf(key) >= 0
? (data[key] || []).join(', ')
: data[key] || ''
})
2012-01-20 18:10:25 +00:00
.css({float: 'left'})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
}
})
.appendTo($div);
2012-01-20 18:10:25 +00:00
$('<br>').appendTo($center);
} else if (data.topic) {
2012-02-11 12:27:58 +00:00
html = formatKey('topics') + formatValue(data.topic, 'topic');
2012-01-20 18:10:25 +00:00
$('<div>').css(css).html(html).appendTo($center);
}
2012-02-16 10:30:52 +00:00
// Summary -------------------------------------------------------------
2012-01-20 18:10:25 +00:00
if (canEdit) {
$('<div>')
.css({marginTop: '16px'})
.append(
Ox.Editable({
clickLink: pandora.clickLink,
editable: canEdit,
maxHeight: Infinity,
2012-02-16 10:30:52 +00:00
placeholder: formatLight('No Summary'),
2012-01-20 18:10:25 +00:00
tooltip: canEdit ? 'Doubleclick to edit' : '',
type: 'textarea',
2012-02-16 10:30:52 +00:00
value: data.summary || '',
2012-01-20 18:10:25 +00:00
//width: 300
})
.bindEvent({
submit: function(event) {
2012-02-16 10:30:52 +00:00
editMetadata('summary', event.value);
2012-01-20 18:10:25 +00:00
}
})
.css(css)
)
.appendTo($center);
2012-02-16 10:30:52 +00:00
} else if(data.summary) {
$('<div>').css(css).html(data.summary).appendTo($center);
2012-01-20 18:10:25 +00:00
}
// License -----------------------------------------------------------------
2012-01-20 18:10:25 +00:00
$div = $('<div>').css(css).css({marginTop: '16px'}).appendTo($center);
if (canEdit) {
$('<div>')
.css({float: 'left'})
.html(formatKey('license').replace('</span>', '&nbsp;</span>'))
.appendTo($div);
Ox.Editable({
placeholder: formatLight('No License'),
tooltip: 'Doubleclick to edit',
2012-01-20 20:23:26 +00:00
value: (data.license || []).join(', ')
2012-01-20 18:10:25 +00:00
})
.bindEvent({
submit: function(event) {
editMetadata('license', event.value);
}
2012-01-20 18:10:25 +00:00
})
.appendTo($div);
} else if(data.license) {
$div.html(
formatKey('License')
2012-01-20 20:23:26 +00:00
+ (data.license || []).join(', ')
2012-01-20 18:10:25 +00:00
);
}
2011-12-27 09:40:11 +00:00
2011-12-27 06:54:49 +00:00
// 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'})
)
2012-01-20 18:10:25 +00:00
.appendTo($right);
2011-12-27 06:54:49 +00:00
});
// User and Groups ---------------------------------------------------------
['user', 'groups'].forEach(function(key) {
2012-02-23 20:57:34 +00:00
(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 ? 'Doubleclick to edit' : '',
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-12-27 06:54:49 +00:00
// Rights Level ------------------------------------------------------------
2012-01-20 18:10:25 +00:00
if (canEdit) {
var $rightsLevel = $('<div>');
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey('Rights Level', true))
.append($rightsLevel)
.appendTo($right);
renderRightsLevel();
}
2011-12-27 06:54:49 +00:00
// Notes --------------------------------------------------------------------
2011-12-27 06:54:49 +00:00
if (canEdit) {
2012-01-15 15:05:37 +00:00
2011-12-27 06:54:49 +00:00
$('<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) {
2012-01-13 09:47:18 +00:00
editMetadata('notes', event.value);
2011-12-27 06:54:49 +00:00
}
})
)
2012-01-20 18:10:25 +00:00
.appendTo($right);
2011-12-27 06:54:49 +00:00
}
2012-01-20 18:10:25 +00:00
$('<div>').css({height: '16px'}).appendTo($right);
2011-12-27 06:54:49 +00:00
function editMetadata(key, value) {
if (value != data[key]) {
var edit = {id: data.id};
if (key == 'title') {
edit[key] = value;
2012-02-17 09:29:21 +00:00
} else if (listKeys.indexOf(key) >= 0) {
2011-12-27 13:52:16 +00:00
edit[key] = value ? value.split(', ') : [];
2011-12-27 06:54:49 +00:00
} else {
2012-02-13 11:33:32 +00:00
edit[key] = value ? value : null;
2011-12-27 06:54:49 +00:00
}
pandora.api.edit(edit, function(result) {
2012-01-15 15:05:37 +00:00
data[key] = value;
descriptions[key] && descriptions[key].options({
2012-01-20 18:10:25 +00:00
value: result.data[key + 'description']
2012-01-15 15:05:37 +00:00
});
2012-01-09 09:55:52 +00:00
Ox.Request.clearCache(); // fixme: too much? can change filter/list etc
2011-12-27 06:54:49 +00:00
if (result.data.id != data.id) {
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.itemTitle
.options({
title: '<b>' + result.data.title
+ (Ox.len(result.data.director)
? ' (' + result.data.director.join(', ') + ')'
: '')
+ (result.data.year ? ' ' + result.data.year : '') + '</b>'
});
2011-12-27 06:54:49 +00:00
//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 formatValue(value, key) {
2012-02-18 13:21:15 +00:00
if(key == 'date') {
return value ? Ox.formatDate(value,
['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length]
) : '';
2012-02-18 13:21:15 +00:00
} else if(key == 'duration') {
return value < 60 ? Math.round(value) + ' sec' : Math.round(value / 60) + ' min';
}
2011-12-27 06:54:49 +00:00
return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ?
'<a href="/' + key + '==' + value + '">' + value + '</a>'
2011-12-27 06:54:49 +00:00
: value;
}).join(', ');
}
function getRightsLevelElement(rightsLevel) {
return Ox.Theme.formatColorLevel(
rightsLevel,
pandora.site.rightsLevels.map(function(rightsLevel) {
return rightsLevel.name;
})
);
}
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) {
2012-01-20 20:56:49 +00:00
return {id: i, title: rightsLevel.name};
2011-12-27 06:54:49 +00:00
}),
2012-01-20 20:56:49 +00:00
width: 128,
value: data.rightslevel
2011-12-27 06:54:49 +00:00
})
.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);
2012-01-20 18:10:25 +00:00
$data.animate({
2012-02-14 06:21:01 +00:00
top: margin + iconHeight + margin + 'px',
width: iconSize + 'px',
2012-01-20 18:10:25 +00:00
}, 250);
$center.animate({
2011-12-27 06:54:49 +00:00
left: margin + (iconSize == 256 ? 256 : iconWidth) + margin + 'px',
}, 250);
pandora.UI.set({infoIconSize: iconSize});
}
that.reload = function() {
var src = src = '/' + data.id + '/' + (
2012-01-20 18:10:25 +00:00
ui.icons == 'posters' ? 'poster' : 'icon'
) + '512.jpg?' + Ox.uid();
2011-12-27 06:54:49 +00:00
$icon.attr({src: src});
$reflectionIcon.attr({src: src});
iconSize = iconSize == 256 ? 512 : 256;
iconRatio = ui.icons == 'posters'
? (ui.showSitePosters ? 5/8 : data.posterRatio) : 1;
2011-12-27 06:54:49 +00:00
toggleIconSize();
};
that.resize = function() {
2012-01-20 18:10:25 +00:00
2011-12-27 06:54:49 +00:00
};
that.bindEvent({
pandora_icons: that.reload,
pandora_showsiteposters: function() {
2011-12-27 06:54:49 +00:00
ui.icons == 'posters' && that.reload();
}
});
return that;
}