Compare commits

..

No commits in common. "0a4c5073463096c6131f091c7e6f817f49626c54" and "06e89c264b8988edfcd24863120868063c92b70a" have entirely different histories.

17 changed files with 513 additions and 887 deletions

View file

@ -262,8 +262,6 @@ def update_static():
pandora_json = os.path.join(settings.STATIC_ROOT, 'json/pandora.json') pandora_json = os.path.join(settings.STATIC_ROOT, 'json/pandora.json')
for root, folders, files in os.walk(os.path.join(settings.STATIC_ROOT, 'js')): for root, folders, files in os.walk(os.path.join(settings.STATIC_ROOT, 'js')):
for f in files: for f in files:
if f.startswith('._'):
continue
f = os.path.join(root, f) f = os.path.join(root, f)
#ignore old embed js file #ignore old embed js file
if 'js/embed/' in f: if 'js/embed/' in f:

View file

@ -119,7 +119,7 @@ class Chop(object):
self.keyframes = make_keyframe_index(video) self.keyframes = make_keyframe_index(video)
return self.keyframes return self.keyframes
def get_gop_sections(self, start, end): def get_gop_sections(self, start: float, end: float) -> dict:
keyframes = self.get_keyframes() keyframes = self.get_keyframes()
start_pos = bisect_left(keyframes, start) start_pos = bisect_left(keyframes, start)
end_pos = bisect_left(keyframes, end) end_pos = bisect_left(keyframes, end)

View file

@ -10,7 +10,6 @@
annotations by specific users can be turned on and off annotations by specific users can be turned on and off
*/ */
"annotations": { "annotations": {
"separator": ";",
"showUsers": false "showUsers": false
}, },
/* /*

View file

@ -11,7 +11,6 @@
annotations by specific users can be turned on and off annotations by specific users can be turned on and off
*/ */
"annotations": { "annotations": {
"separator": ";",
"showUsers": true "showUsers": true
}, },
/* /*

View file

@ -10,7 +10,6 @@
annotations by specific users can be turned on and off annotations by specific users can be turned on and off
*/ */
"annotations": { "annotations": {
"separator": ";",
"showUsers": true "showUsers": true
}, },
/* /*

View file

@ -132,19 +132,14 @@ def editDocument(request, data):
response = json_response() response = json_response()
item = 'item' in data and Item.objects.get(public_id=data['item']) or None item = 'item' in data and Item.objects.get(public_id=data['item']) or None
if data['id']: if data['id']:
if isinstance(data['id'], list): document = models.Document.get(data['id'])
documents = models.Document.objects.filter(pk__in=map(ox.fromAZ, data['id'])) if document.editable(request.user, item):
add_changelog(request, data)
document.edit(data, request.user, item)
document.save()
response['data'] = document.json(user=request.user, item=item)
else: else:
documents = [models.Document.get(data['id'])] response = json_response(status=403, text='permission denied')
for document in documents:
if document.editable(request.user, item):
if document == documents[0]:
add_changelog(request, data)
document.edit(data, request.user, item)
document.save()
response['data'] = document.json(user=request.user, item=item)
else:
response = json_response(status=403, text='permission denied')
else: else:
response = json_response(status=500, text='invalid request') response = json_response(status=500, text='invalid request')
return render_to_json_response(response) return render_to_json_response(response)

View file

@ -622,19 +622,14 @@ def edit(request, data):
} }
see: add, find, get, lookup, remove, upload see: add, find, get, lookup, remove, upload
''' '''
if isinstance(data['id'], list): item = get_object_or_404_json(models.Item, public_id=data['id'])
items = models.Item.objects.filter(public_id__in=data['id']) if item.editable(request.user):
request_data = data.copy()
response = edit_item(request, item, data)
response['data'] = item.json()
add_changelog(request, request_data)
else: else:
items = [get_object_or_404_json(models.Item, public_id=data['id'])] response = json_response(status=403, text='permission denied')
for item in items:
if item.editable(request.user):
request_data = data.copy()
response = edit_item(request, item, data)
response['data'] = item.json()
if item == items[0]:
add_changelog(request, request_data)
else:
response = json_response(status=403, text='permission denied')
return render_to_json_response(response) return render_to_json_response(response)
actions.register(edit, cache=False) actions.register(edit, cache=False)

View file

@ -17,7 +17,7 @@ class JSONField(django.contrib.postgres.fields.JSONField):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
if 'encoder' not in kwargs: if 'encoder' not in kwargs:
kwargs['encoder'] = DjangoJSONEncoder kwargs['encoder'] = DjangoJSONEncoder
super(JSONField, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def to_json(python_object): def to_json(python_object):
if isinstance(python_object, datetime.datetime): if isinstance(python_object, datetime.datetime):
@ -74,8 +74,6 @@ class DictField(models.TextField):
except: except:
raise Exception('failed to parse value: %s' % value) raise Exception('failed to parse value: %s' % value)
if value is not None: if value is not None:
if isinstance(value, string_types):
value = json.loads(value)
assert isinstance(value, self._type) assert isinstance(value, self._type)
return value return value

View file

@ -1,11 +1,9 @@
'use strict'; 'use strict';
pandora.ui.documentInfoView = function(data, isMixed) { pandora.ui.documentInfoView = function(data) {
isMixed = isMixed || {};
var ui = pandora.user.ui, var ui = pandora.user.ui,
isMultiple = arguments.length == 2, canEdit = pandora.hasCapability('canEditMetadata') || data.editable,
canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable,
canRemove = pandora.hasCapability('canRemoveItems'), canRemove = pandora.hasCapability('canRemoveItems'),
css = { css = {
marginTop: '4px', marginTop: '4px',
@ -13,8 +11,8 @@ pandora.ui.documentInfoView = function(data, isMixed) {
}, },
html, html,
iconRatio = data.ratio, iconRatio = data.ratio,
iconSize = isMultiple ? 0 : ui.infoIconSize, iconSize = ui.infoIconSize,
iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), iconWidth = iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio),
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
margin = 16, margin = 16,
@ -105,65 +103,63 @@ pandora.ui.documentInfoView = function(data, isMixed) {
that = Ox.SplitPanel({ that = Ox.SplitPanel({
elements: [ elements: [
{element: $bar, size: isMultiple ? 0 : 16}, {element: $bar, size: 16},
{element: $info} {element: $info}
], ],
orientation: 'vertical' orientation: 'vertical'
}); }),
if (!isMultiple) { $icon = Ox.Element({
var $icon = Ox.Element({ element: '<img>',
element: '<img>', })
}) .attr({
.attr({ src: '/documents/' + data.id + '/512p.jpg?' + data.modified
src: '/documents/' + data.id + '/512p.jpg?' + data.modified })
}) .css({
.css({ position: 'absolute',
position: 'absolute', left: margin + iconLeft + 'px',
left: margin + iconLeft + 'px', top: margin + 'px',
top: margin + 'px', width: iconWidth + 'px',
width: iconWidth + 'px', height: iconHeight + 'px'
height: iconHeight + 'px' })
}) .bindEvent({
.bindEvent({ // singleclick: toggleIconSize
// singleclick: toggleIconSize })
}) .appendTo($info),
.appendTo($info),
$reflection = $('<div>') $reflection = $('<div>')
.addClass('OxReflection') .addClass('OxReflection')
.css({ .css({
position: 'absolute', position: 'absolute',
left: margin + 'px', left: margin + 'px',
top: margin + iconHeight + 'px', top: margin + iconHeight + 'px',
width: iconSize + 'px', width: iconSize + 'px',
height: iconSize / 2 + 'px', height: iconSize / 2 + 'px',
overflow: 'hidden' overflow: 'hidden'
}) })
.appendTo($info), .appendTo($info),
$reflectionIcon = $('<img>') $reflectionIcon = $('<img>')
.attr({ .attr({
src: '/documents/' + data.id + '/512p.jpg?' + data.modified src: '/documents/' + data.id + '/512p.jpg?' + data.modified
}) })
.css({ .css({
position: 'absolute', position: 'absolute',
left: iconLeft + 'px', left: iconLeft + 'px',
width: iconWidth + 'px', width: iconWidth + 'px',
height: iconHeight + 'px', height: iconHeight + 'px',
}) })
.appendTo($reflection), .appendTo($reflection),
$reflectionGradient = $('<div>') $reflectionGradient = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
width: iconSize + 'px', width: iconSize + 'px',
height: iconSize / 2 + 'px' height: iconSize / 2 + 'px'
}) })
.appendTo($reflection); .appendTo($reflection),
}
var $text = Ox.Element() $text = Ox.Element()
.addClass('OxTextPage') .addClass('OxTextPage')
.css({ .css({
position: 'absolute', position: 'absolute',
@ -267,13 +263,13 @@ pandora.ui.documentInfoView = function(data, isMixed) {
} }
// Referenced -------------------------------------------------------------- // Referenced --------------------------------------------------------------
if ( if (
!isMultiple && (
data.referenced.items.length data.referenced.items.length
|| data.referenced.annotations.length || data.referenced.annotations.length
|| data.referenced.documents.length || data.referenced.documents.length
|| data.referenced.entities.length || data.referenced.entities.length
)) { ) {
var itemsById = {} var itemsById = {}
data.referenced.items.forEach(function(item) { data.referenced.items.forEach(function(item) {
@ -291,6 +287,7 @@ pandora.ui.documentInfoView = function(data, isMixed) {
itemsById[itemId].annotations = itemsById[itemId].annotations.concat(annotation); itemsById[itemId].annotations = itemsById[itemId].annotations.concat(annotation);
}); });
var html = Ox.sortBy(Object.values(itemsById), 'title').map(function(item) { var html = Ox.sortBy(Object.values(itemsById), 'title').map(function(item) {
console.log('item', item)
return (item.referenced ? '<a href="/' + item.id + '/documents">' : '') return (item.referenced ? '<a href="/' + item.id + '/documents">' : '')
+ item.title //Ox.encodeHTMLEntities(item.title) + item.title //Ox.encodeHTMLEntities(item.title)
+ (item.referenced ? '</a>' : '') + (item.referenced ? '</a>' : '')
@ -363,9 +360,7 @@ pandora.ui.documentInfoView = function(data, isMixed) {
function editMetadata(key, value) { function editMetadata(key, value) {
if (value != data[key]) { if (value != data[key]) {
var edit = { var edit = {id: data.id};
id: isMultiple ? ui.collectionSelection : data.id,
};
if (key == 'title') { if (key == 'title') {
edit[key] = value; edit[key] = value;
} else if (listKeys.indexOf(key) >= 0) { } else if (listKeys.indexOf(key) >= 0) {
@ -374,26 +369,23 @@ pandora.ui.documentInfoView = function(data, isMixed) {
edit[key] = value ? value : null; edit[key] = value ? value : null;
} }
pandora.api.editDocument(edit, function(result) { pandora.api.editDocument(edit, function(result) {
if (!isMultiple) { var src;
var src; data[key] = result.data[key];
data[key] = result.data[key]; Ox.Request.clearCache(); // fixme: too much? can change filter/list etc
Ox.Request.clearCache(); // fixme: too much? can change filter/list etc if (result.data.id != data.id) {
if (result.data.id != data.id) { pandora.UI.set({document: result.data.id});
pandora.UI.set({document: result.data.id}); pandora.$ui.browser.value(data.id, 'id', result.data.id);
pandora.$ui.browser.value(data.id, 'id', result.data.id);
}
//pandora.updateItemContext();
//pandora.$ui.browser.value(result.data.id, key, result.data[key]);
pandora.$ui.itemTitle
.options({title: '<b>' + (pandora.getDocumentTitle(result.data)) + '</b>'});
} }
that.triggerEvent('change', Ox.extend({}, key, value)); //pandora.updateItemContext();
//pandora.$ui.browser.value(result.data.id, key, result.data[key]);
pandora.$ui.itemTitle
.options({title: '<b>' + (pandora.getDocumentTitle(result.data)) + '</b>'});
}); });
} }
} }
function formatKey(key, mode) { function formatKey(key, mode) {
var item = Ox.getObjectById(pandora.site.documentKeys, key); var item = Ox.getObjectById(pandora.site.itemKeys, key);
key = Ox._(item ? item.title : key); key = Ox._(item ? item.title : key);
mode = mode || 'text'; mode = mode || 'text';
return mode == 'text' return mode == 'text'
@ -429,11 +421,7 @@ pandora.ui.documentInfoView = function(data, isMixed) {
} else if (['type', 'publisher'].indexOf(key) > -1) { } else if (['type', 'publisher'].indexOf(key) > -1) {
ret = formatLink(value, key); ret = formatLink(value, key);
} else { } else {
if (isMixed[key]) { ret = pandora.formatDocumentKey(Ox.getObjectById(pandora.site.documentKeys, key), data);
ret = 'Mixed'
} else {
ret = pandora.formatDocumentKey(Ox.getObjectById(pandora.site.documentKeys, key), data);
}
} }
return ret; return ret;
} }
@ -545,7 +533,7 @@ pandora.ui.documentInfoView = function(data, isMixed) {
format: function(value) { format: function(value) {
return formatValue(key, value); return formatValue(key, value);
}, },
placeholder: formatLight(Ox._(isMixed[key] ? 'mixed' : 'unknown')), placeholder: formatLight(Ox._('unknown')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
value: getValue(key, data[key]) value: getValue(key, data[key])
}) })
@ -588,12 +576,8 @@ pandora.ui.documentInfoView = function(data, isMixed) {
.css({background: $rightsLevelElement.css('background')}) .css({background: $rightsLevelElement.css('background')})
.data({OxColor: $rightsLevelElement.data('OxColor')}) .data({OxColor: $rightsLevelElement.data('OxColor')})
//renderCapabilities(rightsLevel); //renderCapabilities(rightsLevel);
var edit = { pandora.api.editDocument({id: data.id, rightslevel: rightsLevel}, function(result) {
id: isMultiple ? ui.collectionSelection : data.id, // ...
rightslevel: rightsLevel
};
pandora.api.editDocument(edit, function(result) {
that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel));
}); });
} }
}) })

View file

@ -1,124 +0,0 @@
'use strict';
pandora.ui.editDialog = function() {
var ui = pandora.user.ui,
hasChanged = false,
ids = ui.listSelection.filter(function(id) {
return pandora.$ui.list.value(id, 'editable');
}),
keys = pandora.site.itemKeys.filter(function(key) {
return key.id != '*'
}).map(function(key) {
return key.id
}),
listKeys = pandora.site.itemKeys.filter(function(key) {
return Ox.isArray(key.type);
}).map(function(key){
return key.id;
}),
mixed = ' ',
separator = '; ',
tooltip = Ox._('Doubleclick to edit'),
$info = Ox.Element()
.addClass('OxSelectable')
.css({padding: '16px'});
var that = Ox.Dialog({
buttons: [
Ox.Button({
style: 'squared',
title: Ox._('Done')
})
.bindEvent({
click: function() {
if (!ui.updateResults && hasChanged) {
pandora.$ui.list.reloadList()
}
that.close();
}
})
],
closeButton: true,
content: Ox.LoadingScreen().start(),
height: 576,
removeOnClose: true,
title: Ox._('Edit Metadata for {0}', [
Ox.formatNumber(ids.length) + ' ' + Ox._(
ids.length == 1 ? pandora.site.itemName.singular : pandora.site.itemName.plural
)
]),
width: 768
}),
$updateCheckbox = Ox.Checkbox({
style: 'squared',
title: Ox._('Update Results in the Background'),
value: ui.updateResults
})
.css({
float: 'left',
margin: '4px'
})
.bindEvent({
change: function(data) {
pandora.UI.set({updateResults: data.value});
}
});
/*
$($updateCheckbox.find('.OxButton')[0]).css({margin: 0});
$(that.find('.OxBar')[1]).append($updateCheckbox);
*/
getMetadata();
function getMetadata(callback) {
pandora.api.find({
keys: keys,
query: {
conditions: ids.map(function(id) {
return {
key: 'id',
operator: '==',
value: id
};
}),
operator: '|'
}
}, function(result) {
var data = {},
isMixed = {},
items = result.data.items;
keys.forEach(function(key) {
var isArray = Ox.contains(listKeys, key),
values = items.map(function(item) {
return item[key];
});
if (isArray) {
values = values.map(function(value) {
return (value || []).join(separator);
});
}
if (Ox.unique(values).length > 1) {
isMixed[key] = true;
}
data[key] = isMixed[key] ? null
: isArray ? values[0].split(separator)
: values[0];
});
that.options({
content: pandora.ui.infoView(data, isMixed).bindEvent({
change: function() {
hasChanged = true;
Ox.Request.clearCache();
}
})
});
});
}
return that;
};

View file

@ -1,124 +0,0 @@
'use strict';
pandora.ui.editDocumentsDialog = function() {
var ui = pandora.user.ui,
hasChanged = false,
ids = ui.collectionSelection.filter(function(id) {
return pandora.$ui.list.value(id, 'editable');
}),
keys = pandora.site.documentKeys.filter(function(key) {
return key.id != '*'
}).map(function(key) {
return key.id
}),
listKeys = pandora.site.documentKeys.filter(function(key) {
return Ox.isArray(key.type);
}).map(function(key){
return key.id;
}),
mixed = ' ',
separator = '; ',
tooltip = Ox._('Doubleclick to edit'),
$info = Ox.Element()
.addClass('OxSelectable')
.css({padding: '16px'});
var that = Ox.Dialog({
buttons: [
Ox.Button({
style: 'squared',
title: Ox._('Done')
})
.bindEvent({
click: function() {
if (!ui.updateResults && hasChanged) {
pandora.$ui.list.reloadList()
}
that.close();
}
})
],
closeButton: true,
content: Ox.LoadingScreen().start(),
height: 576,
removeOnClose: true,
title: Ox._('Edit Metadata for {0}', [
Ox.formatNumber(ids.length) + ' ' + Ox._(
ids.length == 1 ? 'Document' : 'Documents'
)
]),
width: 768
}),
$updateCheckbox = Ox.Checkbox({
style: 'squared',
title: Ox._('Update Results in the Background'),
value: ui.updateResults
})
.css({
float: 'left',
margin: '4px'
})
.bindEvent({
change: function(data) {
pandora.UI.set({updateResults: data.value});
}
});
/*
$($updateCheckbox.find('.OxButton')[0]).css({margin: 0});
$(that.find('.OxBar')[1]).append($updateCheckbox);
*/
getMetadata();
function getMetadata(callback) {
pandora.api.findDocuments({
keys: keys,
query: {
conditions: ids.map(function(id) {
return {
key: 'id',
operator: '==',
value: id
};
}),
operator: '|'
}
}, function(result) {
var data = {},
isMixed = {},
items = result.data.items;
keys.forEach(function(key) {
var isArray = Ox.contains(listKeys, key),
values = items.map(function(item) {
return item[key];
});
if (isArray) {
values = values.map(function(value) {
return (value || []).join(separator);
});
}
if (Ox.unique(values).length > 1) {
isMixed[key] = true;
}
console.log(key, values)
data[key] = isMixed[key] ? null
: isArray && values.length ? values[0].split(separator)
: values[0];
});
that.options({
content: pandora.ui.documentInfoView(data, isMixed).bindEvent({
change: function() {
hasChanged = true;
Ox.Request.clearCache();
}
})
});
});
}
return that;
};

View file

@ -1,16 +1,14 @@
'use strict'; 'use strict';
pandora.ui.infoView = function(data, isMixed) { pandora.ui.infoView = function(data) {
isMixed = isMixed || {};
// fixme: given that currently, the info view doesn't scroll into view nicely // 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 // when collapsing the movies browser, the info view should become a split panel
var ui = pandora.user.ui, var ui = pandora.user.ui,
isMultiple = arguments.length == 2, canEdit = pandora.hasCapability('canEditMetadata'),
canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable,
canRemove = pandora.hasCapability('canRemoveItems'), canRemove = pandora.hasCapability('canRemoveItems'),
canSeeAllMetadata = pandora.user.level != 'guest' && !isMultiple, canSeeAllMetadata = pandora.user.level != 'guest',
css = { css = {
marginTop: '4px', marginTop: '4px',
textAlign: 'justify' textAlign: 'justify'
@ -18,15 +16,12 @@ pandora.ui.infoView = function(data, isMixed) {
iconRatio = ui.icons == 'posters' ? ( iconRatio = ui.icons == 'posters' ? (
ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio
) : 1, ) : 1,
iconSize = isMultiple ? 0 : ui.infoIconSize, iconSize = ui.infoIconSize,
iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), iconWidth = iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio),
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8, borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
isEditable = canEdit && (isMultiple isEditable = canEdit && data.id.slice(0, 2) == '0x',
? !ui.listSelection.some(function(id) { return id.slice(0, 2) != '0x' })
: data.id.slice(0, 2) == '0x'
),
listWidth = 144 + Ox.UI.SCROLLBAR_SIZE, listWidth = 144 + Ox.UI.SCROLLBAR_SIZE,
margin = 16, margin = 16,
statisticsWidth = 128, statisticsWidth = 128,
@ -106,7 +101,7 @@ pandora.ui.infoView = function(data, isMixed) {
that = Ox.SplitPanel({ that = Ox.SplitPanel({
elements: [ elements: [
{element: $bar, size: isMultiple ? 0 : 16}, {element: $bar, size: 16},
{element: $main} {element: $main}
], ],
orientation: 'vertical' orientation: 'vertical'
@ -131,75 +126,73 @@ pandora.ui.infoView = function(data, isMixed) {
right: 0, right: 0,
height: getHeight() + 'px' height: getHeight() + 'px'
}) })
.appendTo($info); .appendTo($info),
if (!isMultiple) { $icon = Ox.Element({
var $icon = Ox.Element({ element: '<img>',
element: '<img>', tooltip: canEdit ? (
tooltip: canEdit ? ( !ui.showIconBrowser
!ui.showIconBrowser ? Ox._('Doubleclick to edit icon')
? Ox._('Doubleclick to edit icon') : Ox._('Doubleclick to hide icons')
: Ox._('Doubleclick to hide icons') ) : ''
) : '' })
}) .attr({
.attr({ src: pandora.getMediaURL('/' + data.id + '/' + (
src: pandora.getMediaURL('/' + data.id + '/' + ( ui.icons == 'posters'
ui.icons == 'posters' ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon'
? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' ) + '512.jpg?' + data.modified)
) + '512.jpg?' + data.modified) })
}) .css({
.css({ position: 'absolute',
position: 'absolute', left: margin + iconLeft + 'px',
left: margin + iconLeft + 'px', top: margin + 'px',
top: margin + 'px', width: iconWidth + 'px',
width: iconWidth + 'px', height: iconHeight + 'px',
height: iconHeight + 'px', borderRadius: borderRadius + 'px',
borderRadius: borderRadius + 'px', cursor: 'pointer'
cursor: 'pointer' })
}) .bindEvent({
.bindEvent({ singleclick: toggleIconSize
singleclick: toggleIconSize })
}) .appendTo($data.$element),
.appendTo($data.$element),
$reflection = $('<div>') $reflection = $('<div>')
.addClass('OxReflection') .addClass('OxReflection')
.css({ .css({
position: 'absolute', position: 'absolute',
left: margin + 'px', left: margin + 'px',
top: margin + iconHeight + 'px', top: margin + iconHeight + 'px',
width: iconSize + 'px', width: iconSize + 'px',
height: Math.round(iconSize / 2) + 'px', height: Math.round(iconSize / 2) + 'px',
overflow: 'hidden' overflow: 'hidden'
}) })
.appendTo($data.$element), .appendTo($data.$element),
$reflectionIcon = $('<img>') $reflectionIcon = $('<img>')
.attr({ .attr({
src: pandora.getMediaURL('/' + data.id + '/' + ( src: pandora.getMediaURL('/' + data.id + '/' + (
ui.icons == 'posters' ui.icons == 'posters'
? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon'
) + '512.jpg?' + data.modified) ) + '512.jpg?' + data.modified)
}) })
.css({ .css({
position: 'absolute', position: 'absolute',
left: iconLeft + 'px', left: iconLeft + 'px',
width: iconWidth + 'px', width: iconWidth + 'px',
height: iconHeight + 'px', height: iconHeight + 'px',
borderRadius: borderRadius + 'px' borderRadius: borderRadius + 'px'
}) })
.appendTo($reflection), .appendTo($reflection),
$reflectionGradient = $('<div>') $reflectionGradient = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
width: iconSize + 'px', width: iconSize + 'px',
height: Math.round(iconSize / 2) + 'px' height: Math.round(iconSize / 2) + 'px'
}) })
.appendTo($reflection); .appendTo($reflection),
}
var $text = Ox.Element() $text = Ox.Element()
.addClass('OxTextPage') .addClass('OxTextPage')
.css({ .css({
position: 'absolute', position: 'absolute',
@ -235,7 +228,7 @@ pandora.ui.infoView = function(data, isMixed) {
pandora.createLinks($text); pandora.createLinks($text);
// Title ------------------------------------------------------------------- // Title -------------------------------------------------------------------
if (!isMultiple) {
$('<div>') $('<div>')
.css({ .css({
marginTop: '-2px' marginTop: '-2px'
@ -262,7 +255,6 @@ pandora.ui.infoView = function(data, isMixed) {
}) })
) )
.appendTo($text); .appendTo($text);
}
// Director ---------------------------------------------------------------- // Director ----------------------------------------------------------------
@ -278,7 +270,7 @@ pandora.ui.infoView = function(data, isMixed) {
format: function(value) { format: function(value) {
return formatValue(value.split(', '), 'name'); return formatValue(value.split(', '), 'name');
}, },
placeholder: formatLight(Ox._(isMixed.director ? 'Mixed Director' : 'Unknown Director')), placeholder: formatLight(Ox._('Unknown Director')),
tooltip: isEditable ? pandora.getEditTooltip() : '', tooltip: isEditable ? pandora.getEditTooltip() : '',
value: data.director ? data.director.join(', ') : '' value: data.director ? data.director.join(', ') : ''
}) })
@ -314,7 +306,7 @@ pandora.ui.infoView = function(data, isMixed) {
format: function(value) { format: function(value) {
return formatValue(value.split(', '), key) return formatValue(value.split(', '), key)
}, },
placeholder: formatLight(isMixed[key] ? 'mixed' : 'unknown'), placeholder: formatLight('unknown'),
tooltip: pandora.getEditTooltip(), tooltip: pandora.getEditTooltip(),
value: key == 'country' value: key == 'country'
? (data[key] ? data[key].join(', ') : ['']) ? (data[key] ? data[key].join(', ') : [''])
@ -328,7 +320,7 @@ pandora.ui.infoView = function(data, isMixed) {
}) })
.appendTo($div); .appendTo($div);
}); });
} else if (!isMultiple && (data.country || data.year || data.language || data.runtime || data.color || data.sound)) { } else if (data.country || data.year || data.language || data.runtime || data.color || data.sound) {
var html = []; var html = [];
['country', 'year', 'language', 'runtime', 'color', 'sound'].forEach(function(key) { ['country', 'year', 'language', 'runtime', 'color', 'sound'].forEach(function(key) {
if (data[key]) { if (data[key]) {
@ -387,7 +379,7 @@ pandora.ui.infoView = function(data, isMixed) {
key == 'episodeDirector' ? 'name' : 'year' key == 'episodeDirector' ? 'name' : 'year'
); );
}, },
placeholder: formatLight(Ox._(isMixed[key] ? 'mixed' : 'unknown')), placeholder: formatLight('unknown'),
tooltip: pandora.getEditTooltip(), tooltip: pandora.getEditTooltip(),
value: key == 'episodeDirector' value: key == 'episodeDirector'
? (data[key] ? data[key].join(', ') : ['']) ? (data[key] ? data[key].join(', ') : [''])
@ -401,7 +393,7 @@ pandora.ui.infoView = function(data, isMixed) {
}) })
.appendTo($div); .appendTo($div);
}); });
} else if (!isMultiple && (data.episodeDirector || data.writer || data.producer || data.cinematographer || data.editor)) { } else if (data.episodeDirector || data.writer || data.producer || data.cinematographer || data.editor) {
$div = $('<div>') $div = $('<div>')
.addClass('OxSelectable') .addClass('OxSelectable')
.css(css) .css(css)
@ -443,7 +435,7 @@ pandora.ui.infoView = function(data, isMixed) {
.appendTo($text); .appendTo($text);
} }
if (!isMultiple && (data.genre || (data.keyword && canSeeAllMetadata))) { if (data.genre || (data.keyword && canSeeAllMetadata)) {
$div = $('<div>') $div = $('<div>')
.addClass('OxSelectable') .addClass('OxSelectable')
.css(css) .css(css)
@ -464,7 +456,8 @@ pandora.ui.infoView = function(data, isMixed) {
.html(formatKey('summary') + data.summary) .html(formatKey('summary') + data.summary)
.appendTo($text); .appendTo($text);
if (!isMultiple && canSeeAllMetadata) { if (canSeeAllMetadata) {
data.trivia && data.trivia.forEach(function(value) { data.trivia && data.trivia.forEach(function(value) {
$('<div>') $('<div>')
.css({ .css({
@ -577,7 +570,7 @@ pandora.ui.infoView = function(data, isMixed) {
$('<div>').css({height: '16px'}).appendTo($text); $('<div>').css({height: '16px'}).appendTo($text);
// Mainstream Score, Arthouse Score ---------------------------------------- // Mainstream Score, Arthouse Score ----------------------------------------
if (!isMultiple) {
['votes', 'likes'].forEach(function(key) { ['votes', 'likes'].forEach(function(key) {
var value = data[key] || 0; var value = data[key] || 0;
$('<div>') $('<div>')
@ -604,6 +597,7 @@ pandora.ui.infoView = function(data, isMixed) {
}); });
// Duration, Aspect Ratio -------------------------------------------------- // Duration, Aspect Ratio --------------------------------------------------
['duration', 'aspectratio'].forEach(function(key) { ['duration', 'aspectratio'].forEach(function(key) {
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key), var itemKey = Ox.getObjectById(pandora.site.itemKeys, key),
value = data[key] || 0; value = data[key] || 0;
@ -675,7 +669,6 @@ pandora.ui.infoView = function(data, isMixed) {
) )
.appendTo($statistics); .appendTo($statistics);
}); });
}
// Rights Level ------------------------------------------------------------ // Rights Level ------------------------------------------------------------
@ -696,7 +689,7 @@ pandora.ui.infoView = function(data, isMixed) {
.append( .append(
Ox.EditableContent({ Ox.EditableContent({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
placeholder: formatLight(Ox._(isMixed.notes ? 'Mixed notes' : 'No notes')), placeholder: formatLight(Ox._('No notes')),
tooltip: pandora.getEditTooltip(), tooltip: pandora.getEditTooltip(),
type: 'textarea', type: 'textarea',
value: data.notes || '', value: data.notes || '',
@ -704,7 +697,12 @@ pandora.ui.infoView = function(data, isMixed) {
}) })
.bindEvent({ .bindEvent({
submit: function(event) { submit: function(event) {
editMetadata('notes', event.value); pandora.api.edit({
id: data.id,
notes: event.value
}, function(result) {
// ...
});
} }
}) })
) )
@ -713,7 +711,7 @@ pandora.ui.infoView = function(data, isMixed) {
$('<div>').css({height: '16px'}).appendTo($statistics); $('<div>').css({height: '16px'}).appendTo($statistics);
if (canEdit && !isMultiple) { if (canEdit) {
$icon.bindEvent({ $icon.bindEvent({
doubleclick: function() { doubleclick: function() {
pandora.UI.set({showIconBrowser: !ui.showIconBrowser}); pandora.UI.set({showIconBrowser: !ui.showIconBrowser});
@ -732,7 +730,7 @@ pandora.ui.infoView = function(data, isMixed) {
function editMetadata(key, value) { function editMetadata(key, value) {
if (value != data[key]) { if (value != data[key]) {
var edit = {id: isMultiple ? ui.listSelection : data.id}; var edit = {id: data.id};
if (key == 'title') { if (key == 'title') {
Ox.extend(edit, parseTitle(value)); Ox.extend(edit, parseTitle(value));
} else if (['director', 'country'].indexOf(key) > -1) { } else if (['director', 'country'].indexOf(key) > -1) {
@ -741,17 +739,14 @@ pandora.ui.infoView = function(data, isMixed) {
edit[key] = value; edit[key] = value;
} }
pandora.api.edit(edit, function(result) { pandora.api.edit(edit, function(result) {
if (!isMultiple) { if (result.data.id != data.id) {
if (result.data.id != data.id) { Ox.Request.clearCache(); // fixme: too much
Ox.Request.clearCache(); // fixme: too much pandora.UI.set({item: result.data.id});
pandora.UI.set({item: result.data.id}); pandora.$ui.browser.value(data.id, 'id', result.data.id);
pandora.$ui.browser.value(data.id, 'id', result.data.id); // FIXME: does this update selected?
// FIXME: does this update selected?
}
pandora.updateItemContext();
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
} }
that.triggerEvent('change', Ox.extend({}, key, value)); pandora.updateItemContext();
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
}); });
} }
} }
@ -1064,12 +1059,8 @@ pandora.ui.infoView = function(data, isMixed) {
.css({background: $rightsLevelElement.css('background')}) .css({background: $rightsLevelElement.css('background')})
.data({OxColor: $rightsLevelElement.data('OxColor')}) .data({OxColor: $rightsLevelElement.data('OxColor')})
renderCapabilities(rightsLevel); renderCapabilities(rightsLevel);
var edit = { pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) {
id: isMultiple ? ui.listSelection : data.id, // ...
rightslevel: rightsLevel
};
pandora.api.edit(edit, function(result) {
that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel));
}); });
} }
}) })

View file

@ -1,11 +1,9 @@
'use strict'; 'use strict';
pandora.ui.infoView = function(data, isMixed) { pandora.ui.infoView = function(data) {
isMixed = isMixed || {};
var ui = pandora.user.ui, var ui = pandora.user.ui,
isMultiple = arguments.length == 2, canEdit = pandora.hasCapability('canEditMetadata'),
canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable,
canRemove = pandora.hasCapability('canRemoveItems'), canRemove = pandora.hasCapability('canRemoveItems'),
canSeeAllMetadata = pandora.user.level != 'guest', canSeeAllMetadata = pandora.user.level != 'guest',
css = { css = {
@ -15,8 +13,8 @@ pandora.ui.infoView = function(data, isMixed) {
iconRatio = ui.icons == 'posters' ? ( iconRatio = ui.icons == 'posters' ? (
ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio
) : 1, ) : 1,
iconSize = isMultiple ? 0 : ui.infoIconSize, iconSize = ui.infoIconSize,
iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), iconWidth = iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio),
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8, borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
@ -135,73 +133,71 @@ pandora.ui.infoView = function(data, isMixed) {
that = Ox.SplitPanel({ that = Ox.SplitPanel({
elements: [ elements: [
{element: $bar, size: isMultiple ? 0 : 16}, {element: $bar, size: 16},
{element: $info} {element: $info}
], ],
orientation: 'vertical' orientation: 'vertical'
}); }),
if (!isMultiple) { $icon = Ox.Element({
var $icon = Ox.Element({ element: '<img>'
element: '<img>' })
}) .attr({
.attr({ src: pandora.getMediaURL('/' + data.id + '/' + (
src: pandora.getMediaURL('/' + data.id + '/' + ( ui.icons == 'posters' ? 'poster' : 'icon'
ui.icons == 'posters' ? 'poster' : 'icon' ) + '512.jpg?' + data.modified)
) + '512.jpg?' + data.modified) })
}) .css({
.css({ position: 'absolute',
position: 'absolute', left: margin + iconLeft + 'px',
left: margin + iconLeft + 'px', top: margin + 'px',
top: margin + 'px', width: iconWidth + 'px',
width: iconWidth + 'px', height: iconHeight + 'px',
height: iconHeight + 'px', borderRadius: borderRadius + 'px',
borderRadius: borderRadius + 'px', cursor: 'pointer'
cursor: 'pointer' })
}) .bindEvent({
.bindEvent({ singleclick: toggleIconSize
singleclick: toggleIconSize })
}) .appendTo($info),
.appendTo($info),
$reflection = $('<div>') $reflection = $('<div>')
.addClass('OxReflection') .addClass('OxReflection')
.css({ .css({
position: 'absolute', position: 'absolute',
left: margin + 'px', left: margin + 'px',
top: margin + iconHeight + 'px', top: margin + iconHeight + 'px',
width: iconSize + 'px', width: iconSize + 'px',
height: Math.round(iconSize / 2) + 'px', height: Math.round(iconSize / 2) + 'px',
overflow: 'hidden' overflow: 'hidden'
}) })
.appendTo($info), .appendTo($info),
$reflectionIcon = $('<img>') $reflectionIcon = $('<img>')
.attr({ .attr({
src: pandora.getMediaURL('/' + data.id + '/' + ( src: pandora.getMediaURL('/' + data.id + '/' + (
ui.icons == 'posters' ui.icons == 'posters'
? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon'
) + '512.jpg?' + data.modified) ) + '512.jpg?' + data.modified)
}) })
.css({ .css({
position: 'absolute', position: 'absolute',
left: iconLeft + 'px', left: iconLeft + 'px',
width: iconWidth + 'px', width: iconWidth + 'px',
height: iconHeight + 'px', height: iconHeight + 'px',
borderRadius: borderRadius + 'px' borderRadius: borderRadius + 'px'
}) })
.appendTo($reflection), .appendTo($reflection),
$reflectionGradient = $('<div>') $reflectionGradient = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
width: iconSize + 'px', width: iconSize + 'px',
height: Math.round(iconSize / 2) + 'px' height: Math.round(iconSize / 2) + 'px'
}) })
.appendTo($reflection); .appendTo($reflection),
}
var $text = Ox.Element() $text = Ox.Element()
.addClass('OxTextPage') .addClass('OxTextPage')
.css({ .css({
position: 'absolute', position: 'absolute',
@ -247,7 +243,6 @@ pandora.ui.infoView = function(data, isMixed) {
}); });
// Title ------------------------------------------------------------------- // Title -------------------------------------------------------------------
if (!isMultiple) {
$('<div>') $('<div>')
.css({ .css({
@ -275,7 +270,6 @@ pandora.ui.infoView = function(data, isMixed) {
}) })
) )
.appendTo($text); .appendTo($text);
}
// Director ---------------------------------------------------------------- // Director ----------------------------------------------------------------
@ -291,7 +285,7 @@ pandora.ui.infoView = function(data, isMixed) {
format: function(value) { format: function(value) {
return formatLink(value.split(', '), 'name'); return formatLink(value.split(', '), 'name');
}, },
placeholder: formatLight(Ox._(isMixed.director ? 'Mixed Director' : 'Unknown Director')), placeholder: formatLight(Ox._('Unknown Director')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
value: data.director ? data.director.join(', ') : '' value: data.director ? data.director.join(', ') : ''
}) })
@ -361,7 +355,7 @@ pandora.ui.infoView = function(data, isMixed) {
'<img style="float: left; max-width: 256px; max-height: 256px; margin: 0 16px 16px 0" src=' '<img style="float: left; max-width: 256px; max-height: 256px; margin: 0 16px 16px 0" src='
); );
}, },
placeholder: formatLight(Ox._(isMixed.summary ? 'Mixed Summary' : 'No Summary')), placeholder: formatLight(Ox._('No Summary')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
type: 'textarea', type: 'textarea',
value: data.summary || '' value: data.summary || ''
@ -441,7 +435,7 @@ pandora.ui.infoView = function(data, isMixed) {
'<img style="float: left; max-width: 256px; max-height: 256px; margin: 0 16px 16px 0" src=' '<img style="float: left; max-width: 256px; max-height: 256px; margin: 0 16px 16px 0" src='
); );
}, },
placeholder: formatLight(Ox._(isMixed.songs ? 'Mixed Songs' : 'No Songs')), placeholder: formatLight(Ox._('No Songs')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
type: 'textarea', type: 'textarea',
value: data.songs || '' value: data.songs || ''
@ -461,7 +455,6 @@ pandora.ui.infoView = function(data, isMixed) {
} }
// Descriptions ------------------------------------------------------------ // Descriptions ------------------------------------------------------------
if (!isMultiple) {
$descriptions = $('<div>').attr({id: 'descriptions'}).appendTo($text); $descriptions = $('<div>').attr({id: 'descriptions'}).appendTo($text);
@ -557,8 +550,6 @@ pandora.ui.infoView = function(data, isMixed) {
// no video placeholder // no video placeholder
} }
}
// Rights Level ------------------------------------------------------------ // Rights Level ------------------------------------------------------------
var $rightsLevel = $('<div>'); var $rightsLevel = $('<div>');
@ -590,7 +581,7 @@ pandora.ui.infoView = function(data, isMixed) {
.append( .append(
Ox.EditableContent({ Ox.EditableContent({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
placeholder: formatLight(Ox._(isMixed.comments ? 'Mixed comments' : 'No comments')), placeholder: formatLight(Ox._('No comments')),
tooltip: pandora.getEditTooltip(), tooltip: pandora.getEditTooltip(),
type: 'textarea', type: 'textarea',
value: data.comments || '', value: data.comments || '',
@ -598,7 +589,12 @@ pandora.ui.infoView = function(data, isMixed) {
}) })
.bindEvent({ .bindEvent({
submit: function(event) { submit: function(event) {
editMetadata('comments', event.value); pandora.api.edit({
id: data.id,
comments: event.value
}, function(result) {
// ...
});
} }
}) })
) )
@ -609,7 +605,7 @@ pandora.ui.infoView = function(data, isMixed) {
function editMetadata(key, value) { function editMetadata(key, value) {
if (value != data[key]) { if (value != data[key]) {
var edit = {id: isMultiple ? ui.listSelection : data.id}; var edit = {id: data.id};
if (key == 'alternativeTitles') { if (key == 'alternativeTitles') {
edit[key] = value ? Ox.decodeHTMLEntities(value).split('; ').map(function(value) { edit[key] = value ? Ox.decodeHTMLEntities(value).split('; ').map(function(value) {
return [Ox.encodeHTMLEntities(value), []]; return [Ox.encodeHTMLEntities(value), []];
@ -633,36 +629,33 @@ pandora.ui.infoView = function(data, isMixed) {
edit[key] = value; edit[key] = value;
} }
pandora.api.edit(edit, function(result) { pandora.api.edit(edit, function(result) {
if (!isMultiple) { var src;
var src; data[key] = result.data[key];
data[key] = result.data[key]; if (result.data.id != data.id) {
if (result.data.id != data.id) { Ox.Request.clearCache(); // fixme: too much
Ox.Request.clearCache(); // fixme: too much pandora.UI.set({item: result.data.id});
pandora.UI.set({item: result.data.id}); pandora.$ui.browser.value(data.id, 'id', result.data.id);
pandora.$ui.browser.value(data.id, 'id', result.data.id); } else {
} else { Ox.Request.clearCache('autocomplete');
Ox.Request.clearCache('autocomplete'); }
} pandora.updateItemContext();
pandora.updateItemContext(); pandora.$ui.browser.value(result.data.id, key, result.data[key]);
pandora.$ui.browser.value(result.data.id, key, result.data[key]); if (Ox.contains(posterKeys, key) && ui.icons == 'posters') {
if (Ox.contains(posterKeys, key) && ui.icons == 'posters') { src = pandora.getMediaURL('/' + data.id + '/poster512.jpg?' + Ox.uid());
src = pandora.getMediaURL('/' + data.id + '/poster512.jpg?' + Ox.uid()); $icon.attr({src: src});
$icon.attr({src: src}); $reflectionIcon.attr({src: src});
$reflectionIcon.attr({src: src}); }
} if (Ox.contains(nameKeys, key)) {
if (Ox.contains(nameKeys, key)) { data['namedescription'] = result.data['namedescription'];
data['namedescription'] = result.data['namedescription']; descriptions.names = getNames();
descriptions.names = getNames(); renderDescriptions();
renderDescriptions(); } else if (key == 'productionCompany') {
} else if (key == 'productionCompany') { data['productionCompanydescription'] = result.data['productionCompanydescription'];
data['productionCompanydescription'] = result.data['productionCompanydescription']; descriptions.studios = getStudios();
descriptions.studios = getStudios(); renderDescriptions();
renderDescriptions(); } else if (key == 'imdbId') {
} else if (key == 'imdbId') { updateIMDb();
updateIMDb();
}
} }
that.triggerEvent('change', Ox.extend({}, key, value));
}); });
} }
} }
@ -1067,7 +1060,7 @@ pandora.ui.infoView = function(data, isMixed) {
format: function(value) { format: function(value) {
return formatValue(key, value); return formatValue(key, value);
}, },
placeholder: formatLight(Ox._(isMixed[key] ? 'mixed': 'unknown')), placeholder: formatLight(Ox._('unknown')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
value: getValue(key, data[key]) value: getValue(key, data[key])
}) })
@ -1137,12 +1130,8 @@ pandora.ui.infoView = function(data, isMixed) {
.css({background: $rightsLevelElement.css('background')}) .css({background: $rightsLevelElement.css('background')})
.data({OxColor: $rightsLevelElement.data('OxColor')}) .data({OxColor: $rightsLevelElement.data('OxColor')})
// renderCapabilities(rightsLevel); // renderCapabilities(rightsLevel);
var edit = { pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) {
id: isMultiple ? ui.listSelection : data.id, // ...
rightslevel: rightsLevel
};
pandora.api.edit(edit, function(result) {
that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel));
}); });
} }
}) })

View file

@ -1,12 +1,10 @@
'use strict'; 'use strict';
pandora.ui.infoView = function(data, isMixed) { pandora.ui.infoView = function(data) {
isMixed = isMixed || {};
var ui = pandora.user.ui, var ui = pandora.user.ui,
descriptions = [], descriptions = [],
isMultiple = arguments.length == 2, canEdit = pandora.hasCapability('canEditMetadata') || data.editable,
canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable,
canRemove = pandora.hasCapability('canRemoveItems'), canRemove = pandora.hasCapability('canRemoveItems'),
css = { css = {
marginTop: '4px', marginTop: '4px',
@ -14,10 +12,10 @@ pandora.ui.infoView = function(data, isMixed) {
}, },
html, html,
iconRatio = ui.icons == 'posters' ? data.posterRatio : 1, iconRatio = ui.icons == 'posters' ? data.posterRatio : 1,
iconSize = isMultiple ? 0 : ui.infoIconSize, iconSize = ui.infoIconSize,
iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), iconWidth = iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio),
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = isMultiple ? 0 : iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8, borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
margin = 16, margin = 16,
nameKeys = pandora.site.itemKeys.filter(function(key) { nameKeys = pandora.site.itemKeys.filter(function(key) {
@ -100,72 +98,70 @@ pandora.ui.infoView = function(data, isMixed) {
that = Ox.SplitPanel({ that = Ox.SplitPanel({
elements: [ elements: [
{element: $bar, size: isMultiple ? 0 : 16}, {element: $bar, size: 16},
{element: $info} {element: $info}
], ],
orientation: 'vertical' orientation: 'vertical'
}); }),
if (!isMultiple) { $icon = Ox.Element({
var $icon = Ox.Element({ element: '<img>',
element: '<img>', })
}) .attr({
.attr({ src: '/' + data.id + '/' + (
src: '/' + data.id + '/' + ( ui.icons == 'posters' ? 'poster' : 'icon'
ui.icons == 'posters' ? 'poster' : 'icon' ) + '512.jpg?' + data.modified
) + '512.jpg?' + data.modified })
}) .css({
.css({ position: 'absolute',
position: 'absolute', left: margin + iconLeft + 'px',
left: margin + iconLeft + 'px', top: margin + 'px',
top: margin + 'px', width: iconWidth + 'px',
width: iconWidth + 'px', height: iconHeight + 'px',
height: iconHeight + 'px', borderRadius: borderRadius + 'px',
borderRadius: borderRadius + 'px', cursor: 'pointer'
cursor: 'pointer' })
}) .bindEvent({
.bindEvent({ singleclick: toggleIconSize
singleclick: toggleIconSize })
}) .appendTo($info),
.appendTo($info),
$reflection = $('<div>') $reflection = $('<div>')
.addClass('OxReflection') .addClass('OxReflection')
.css({ .css({
position: 'absolute', position: 'absolute',
left: margin + 'px', left: margin + 'px',
top: margin + iconHeight + 'px', top: margin + iconHeight + 'px',
width: iconSize + 'px', width: iconSize + 'px',
height: iconSize / 2 + 'px', height: iconSize / 2 + 'px',
overflow: 'hidden' overflow: 'hidden'
}) })
.appendTo($info), .appendTo($info),
$reflectionIcon = $('<img>') $reflectionIcon = $('<img>')
.attr({ .attr({
src: '/' + data.id + '/' + ( src: '/' + data.id + '/' + (
ui.icons == 'posters' ? 'poster' : 'icon' ui.icons == 'posters' ? 'poster' : 'icon'
) + '512.jpg?' + data.modified ) + '512.jpg?' + data.modified
}) })
.css({ .css({
position: 'absolute', position: 'absolute',
left: iconLeft + 'px', left: iconLeft + 'px',
width: iconWidth + 'px', width: iconWidth + 'px',
height: iconHeight + 'px', height: iconHeight + 'px',
borderRadius: borderRadius + 'px' borderRadius: borderRadius + 'px'
}) })
.appendTo($reflection), .appendTo($reflection),
$reflectionGradient = $('<div>') $reflectionGradient = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
width: iconSize + 'px', width: iconSize + 'px',
height: iconSize / 2 + 'px' height: iconSize / 2 + 'px'
}) })
.appendTo($reflection); .appendTo($reflection),
}
var $text = Ox.Element() $text = Ox.Element()
.addClass('OxTextPage') .addClass('OxTextPage')
.css({ .css({
position: 'absolute', position: 'absolute',
@ -252,7 +248,7 @@ pandora.ui.infoView = function(data, isMixed) {
); );
}, },
maxHeight: Infinity, maxHeight: Infinity,
placeholder: formatLight(Ox._( isMixed.summary ? 'Mixed Summary' : 'No Summary')), placeholder: formatLight(Ox._('No Summary')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
type: 'textarea', type: 'textarea',
value: data.summary || '' value: data.summary || ''
@ -272,50 +268,49 @@ pandora.ui.infoView = function(data, isMixed) {
} }
// Duration, Aspect Ratio -------------------------------------------------- // Duration, Aspect Ratio --------------------------------------------------
if (!isMultiple) {
['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, 'statistics'))
.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($statistics);
});
// Hue, Saturation, Lightness, Volume --------------------------------------
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey(key, 'statistics'))
.append(
Ox.Theme.formatColor(
data[key] || 0, key == 'volume' ? 'lightness' : key
).css({textAlign: 'right'})
)
.appendTo($statistics);
});
// Cuts per Minute ---------------------------------------------------------
['duration', 'aspectratio'].forEach(function(key) {
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key),
value = data[key] || 0;
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
.append(formatKey('cuts per minute', 'statistics')) .append(formatKey(itemKey.title, 'statistics'))
.append( .append(
Ox.Theme.formatColor(null, 'gradient') Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'}) .css({textAlign: 'right'})
.html(Ox.formatNumber(data['cutsperminute'] || 0, 3)) .html(
Ox['format' + Ox.toTitleCase(itemKey.format.type)]
.apply(null, [value].concat(itemKey.format.args))
)
) )
.appendTo($statistics); .appendTo($statistics);
} });
// Hue, Saturation, Lightness, Volume --------------------------------------
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey(key, 'statistics'))
.append(
Ox.Theme.formatColor(
data[key] || 0, key == 'volume' ? 'lightness' : key
).css({textAlign: 'right'})
)
.appendTo($statistics);
});
// Cuts per Minute ---------------------------------------------------------
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey('cuts per minute', 'statistics'))
.append(
Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'})
.html(Ox.formatNumber(data['cutsperminute'] || 0, 3))
)
.appendTo($statistics);
// Rights Level ------------------------------------------------------------ // Rights Level ------------------------------------------------------------
@ -347,7 +342,7 @@ pandora.ui.infoView = function(data, isMixed) {
.append( .append(
Ox.EditableContent({ Ox.EditableContent({
height: 128, height: 128,
placeholder: formatLight(Ox._(isMixed ? 'Mixed notes' : 'No notes')), placeholder: formatLight(Ox._('No notes')),
tooltip: pandora.getEditTooltip(), tooltip: pandora.getEditTooltip(),
type: 'textarea', type: 'textarea',
value: data.notes || '', value: data.notes || '',
@ -366,7 +361,7 @@ pandora.ui.infoView = function(data, isMixed) {
function editMetadata(key, value) { function editMetadata(key, value) {
if (value != data[key]) { if (value != data[key]) {
var edit = {id: isMultiple ? ui.listSelection : data.id}; var edit = {id: data.id};
if (key == 'title') { if (key == 'title') {
edit[key] = value; edit[key] = value;
} else if (listKeys.indexOf(key) >= 0) { } else if (listKeys.indexOf(key) >= 0) {
@ -375,34 +370,31 @@ pandora.ui.infoView = function(data, isMixed) {
edit[key] = value ? value : null; edit[key] = value ? value : null;
} }
pandora.api.edit(edit, function(result) { pandora.api.edit(edit, function(result) {
if (!isMultiple) { var src;
var src; data[key] = result.data[key];
data[key] = result.data[key]; descriptions[key] && descriptions[key].options({
descriptions[key] && descriptions[key].options({ value: result.data[key + 'description']
value: result.data[key + 'description'] });
}); Ox.Request.clearCache(); // fixme: too much? can change filter/list etc
Ox.Request.clearCache(); // fixme: too much? can change filter/list etc if (result.data.id != data.id) {
if (result.data.id != data.id) { pandora.UI.set({item: result.data.id});
pandora.UI.set({item: result.data.id}); pandora.$ui.browser.value(data.id, 'id', result.data.id);
pandora.$ui.browser.value(data.id, 'id', result.data.id);
}
pandora.updateItemContext();
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
if (Ox.contains(posterKeys, key) && ui.icons == 'posters') {
src = pandora.getMediaURL('/' + data.id + '/poster512.jpg?' + Ox.uid());
$icon.attr({src: src});
$reflectionIcon.attr({src: src});
}
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>'
});
} }
that.triggerEvent('change', Ox.extend({}, key, value)); pandora.updateItemContext();
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
if (Ox.contains(posterKeys, key) && ui.icons == 'posters') {
src = pandora.getMediaURL('/' + data.id + '/poster512.jpg?' + Ox.uid());
$icon.attr({src: src});
$reflectionIcon.attr({src: src});
}
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>'
});
}); });
} }
} }
@ -554,7 +546,7 @@ pandora.ui.infoView = function(data, isMixed) {
format: function(value) { format: function(value) {
return formatValue(key, value); return formatValue(key, value);
}, },
placeholder: formatLight(Ox._( isMixed[key] ? 'mixed' : 'unknown')), placeholder: formatLight(Ox._('unknown')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
value: getValue(key, data[key]) value: getValue(key, data[key])
}) })
@ -596,12 +588,8 @@ pandora.ui.infoView = function(data, isMixed) {
.css({background: $rightsLevelElement.css('background')}) .css({background: $rightsLevelElement.css('background')})
.data({OxColor: $rightsLevelElement.data('OxColor')}) .data({OxColor: $rightsLevelElement.data('OxColor')})
renderCapabilities(rightsLevel); renderCapabilities(rightsLevel);
var edit = { pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) {
id: isMultiple ? ui.listSelection : data.id, // ...
rightslevel: rightsLevel
};
pandora.api.edit(edit, function(result) {
that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel));
}); });
} }
}) })

View file

@ -1,11 +1,9 @@
'use strict'; 'use strict';
pandora.ui.infoView = function(data, isMixed) { pandora.ui.infoView = function(data) {
isMixed = isMixed || {};
var ui = pandora.user.ui, var ui = pandora.user.ui,
isMultiple = arguments.length == 2, canEdit = pandora.hasCapability('canEditMetadata') || data.editable,
canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable,
canRemove = pandora.hasCapability('canRemoveItems') || data.editable, canRemove = pandora.hasCapability('canRemoveItems') || data.editable,
css = { css = {
marginTop: '4px', marginTop: '4px',
@ -14,8 +12,8 @@ pandora.ui.infoView = function(data, isMixed) {
descriptions = [], descriptions = [],
html, html,
iconRatio = ui.icons == 'posters' ? data.posterRatio : 1, iconRatio = ui.icons == 'posters' ? data.posterRatio : 1,
iconSize = isMultiple ? 0 : ui.infoIconSize, iconSize = ui.infoIconSize,
iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), iconWidth = iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio),
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8, borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
@ -100,7 +98,7 @@ pandora.ui.infoView = function(data, isMixed) {
that = Ox.SplitPanel({ that = Ox.SplitPanel({
elements: [ elements: [
{element: $bar, size: isMultiple ? 0 : 16}, {element: $bar, size: 16},
{element: $info} {element: $info}
], ],
orientation: 'vertical' orientation: 'vertical'
@ -110,74 +108,72 @@ pandora.ui.infoView = function(data, isMixed) {
.css({ .css({
position: 'absolute' position: 'absolute'
}) })
.appendTo($info); .appendTo($info),
if (!isMultiple) { $icon = Ox.Element({
var $icon = Ox.Element({ element: '<img>',
element: '<img>', tooltip: 'Switch to ' + Ox.getObjectById(
tooltip: 'Switch to ' + Ox.getObjectById( pandora.site.itemViews,
pandora.site.itemViews, ui.videoView
ui.videoView ).title + ' View'
).title + ' View' })
}) .attr({
.attr({ src: pandora.getMediaURL('/' + data.id + '/' + (
src: pandora.getMediaURL('/' + data.id + '/' + ( ui.icons == 'posters' ? 'poster' : 'icon'
ui.icons == 'posters' ? 'poster' : 'icon' ) + '512.jpg?' + data.modified)
) + '512.jpg?' + data.modified) })
}) .css({
.css({ position: 'absolute',
position: 'absolute', left: margin + iconLeft + 'px',
left: margin + iconLeft + 'px', top: margin + 'px',
top: margin + 'px', width: iconWidth + 'px',
width: iconWidth + 'px', height: iconHeight + 'px',
height: iconHeight + 'px', borderRadius: borderRadius + 'px',
borderRadius: borderRadius + 'px', cursor: 'pointer'
cursor: 'pointer' })
}) .bindEvent({
.bindEvent({ anyclick: function() {
anyclick: function() { pandora.UI.set({itemView: ui.videoView});
pandora.UI.set({itemView: ui.videoView}); }
} })
}) .appendTo($left),
.appendTo($left),
$reflection = $('<div>') $reflection = $('<div>')
.addClass('OxReflection') .addClass('OxReflection')
.css({ .css({
position: 'absolute', position: 'absolute',
left: margin + 'px', left: margin + 'px',
top: margin + iconHeight + 'px', top: margin + iconHeight + 'px',
width: iconSize + 'px', width: iconSize + 'px',
height: Math.round(iconSize / 2) + 'px', height: Math.round(iconSize / 2) + 'px',
overflow: 'hidden' overflow: 'hidden'
}) })
.appendTo($left), .appendTo($left),
$reflectionIcon = $('<img>') $reflectionIcon = $('<img>')
.attr({ .attr({
src: pandora.getMediaURL('/' + data.id + '/' + ( src: pandora.getMediaURL('/' + data.id + '/' + (
ui.icons == 'posters' ? 'poster' : 'icon' ui.icons == 'posters' ? 'poster' : 'icon'
) + '512.jpg?' + data.modified) ) + '512.jpg?' + data.modified)
}) })
.css({ .css({
position: 'absolute', position: 'absolute',
left: iconLeft + 'px', left: iconLeft + 'px',
width: iconWidth + 'px', width: iconWidth + 'px',
height: iconHeight + 'px', height: iconHeight + 'px',
borderRadius: borderRadius + 'px' borderRadius: borderRadius + 'px'
}) })
.appendTo($reflection), .appendTo($reflection),
$reflectionGradient = $('<div>') $reflectionGradient = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
width: iconSize + 'px', width: iconSize + 'px',
height: Math.round(iconSize / 2) + 'px' height: Math.round(iconSize / 2) + 'px'
}) })
.appendTo($reflection); .appendTo($reflection),
}
var $data = $('<div>') $data = $('<div>')
.addClass('OxTextPage') .addClass('OxTextPage')
.css({ .css({
position: 'absolute', position: 'absolute',
@ -227,7 +223,6 @@ pandora.ui.infoView = function(data, isMixed) {
} }
// Source & Project -------------------------------------------------------- // Source & Project --------------------------------------------------------
if (!isMultiple) {
['source', 'project'].forEach(function(key) { ['source', 'project'].forEach(function(key) {
if (canEdit || data[key]) { if (canEdit || data[key]) {
@ -248,7 +243,7 @@ pandora.ui.infoView = function(data, isMixed) {
format: function(value) { format: function(value) {
return formatValue(key, value); return formatValue(key, value);
}, },
placeholder: formatLight(Ox._(isMixed[key] ? 'mixed' : 'unknown')), placeholder: formatLight(Ox._('unknown')),
editable: canEdit, editable: canEdit,
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
value: listKeys.indexOf(key) >= 0 value: listKeys.indexOf(key) >= 0
@ -291,10 +286,8 @@ pandora.ui.infoView = function(data, isMixed) {
} }
} }
}); });
}
// Title ------------------------------------------------------------------- // Title -------------------------------------------------------------------
if (!isMultiple) {
$('<div>') $('<div>')
.css({ .css({
@ -319,16 +312,12 @@ pandora.ui.infoView = function(data, isMixed) {
}) })
) )
.appendTo($text); .appendTo($text);
}
// Groups ------------------------------------------------------------------ // Groups ------------------------------------------------------------------
renderGroup(['location', 'date', 'language']); renderGroup(['location', 'date', 'language']);
renderGroup(['director', 'cinematographer', 'featuring']); renderGroup(['director', 'cinematographer', 'featuring']);
if (isMultiple) {
renderGroup(['source', 'project']);
}
renderGroup(['topic']); renderGroup(['topic']);
@ -375,17 +364,14 @@ pandora.ui.infoView = function(data, isMixed) {
renderGroup(['license']); renderGroup(['license']);
$('<div>') $('<div>')
.addClass('OxSelectable') .addClass('OxSelectable')
.css(css) .css(css)
.css({height: '16px'}) .css({height: '16px'})
.appendTo($text); .appendTo($text);
// Duration, Aspect Ratio -------------------------------------------------- // Duration, Aspect Ratio --------------------------------------------------
if (!isMultiple) {
['duration', 'aspectratio'].forEach(function(key) { ['duration', 'aspectratio'].forEach(function(key) {
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key), var itemKey = Ox.getObjectById(pandora.site.itemKeys, key),
value = data[key] || 0; value = data[key] || 0;
@ -428,7 +414,7 @@ pandora.ui.infoView = function(data, isMixed) {
.html(Ox.formatNumber(data['cutsperminute'] || 0, 3)) .html(Ox.formatNumber(data['cutsperminute'] || 0, 3))
) )
.appendTo($statistics); .appendTo($statistics);
}
// Rights Level ------------------------------------------------------------ // Rights Level ------------------------------------------------------------
var $rightsLevel = $('<div>'); var $rightsLevel = $('<div>');
@ -440,7 +426,6 @@ pandora.ui.infoView = function(data, isMixed) {
renderRightsLevel(); renderRightsLevel();
// User and Groups --------------------------------------------------------- // User and Groups ---------------------------------------------------------
if (!isMultiple) {
['user', 'groups'].forEach(function(key) { ['user', 'groups'].forEach(function(key) {
var $input; var $input;
@ -452,10 +437,10 @@ pandora.ui.infoView = function(data, isMixed) {
.css({margin: '2px 0 0 -1px'}) // fixme: weird .css({margin: '2px 0 0 -1px'}) // fixme: weird
.append( .append(
$input = Ox.Editable({ $input = Ox.Editable({
placeholder: key == 'groups' ? formatLight(Ox._(isMixed[key] ? 'Mixed Groups' : 'No Groups')) : '', placeholder: key == 'groups' ? formatLight(Ox._('No Groups')) : '',
editable: key == 'user' && canEdit, editable: key == 'user' && canEdit,
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
value: key == 'user' ? data[key] : isMixed[key] ? '' : data[key].join(', ') value: key == 'user' ? data[key] : data[key].join(', ')
}) })
.bindEvent(Ox.extend({ .bindEvent(Ox.extend({
submit: function(event) { submit: function(event) {
@ -489,10 +474,8 @@ pandora.ui.infoView = function(data, isMixed) {
) )
.appendTo($statistics); .appendTo($statistics);
}); });
}
// Created and Modified ---------------------------------------------------- // Created and Modified ----------------------------------------------------
if (!isMultiple) {
['created', 'modified'].forEach(function(key) { ['created', 'modified'].forEach(function(key) {
$('<div>') $('<div>')
@ -504,8 +487,6 @@ pandora.ui.infoView = function(data, isMixed) {
.appendTo($statistics); .appendTo($statistics);
}); });
}
// Notes -------------------------------------------------------------------- // Notes --------------------------------------------------------------------
if (canEdit) { if (canEdit) {
@ -545,7 +526,7 @@ pandora.ui.infoView = function(data, isMixed) {
function editMetadata(key, value) { function editMetadata(key, value) {
if (value != data[key]) { if (value != data[key]) {
var edit = {id: isMultiple ? ui.listSelection : data.id}; var edit = {id: data.id};
if (key == 'title') { if (key == 'title') {
edit[key] = value; edit[key] = value;
} else if (listKeys.indexOf(key) >= 0) { } else if (listKeys.indexOf(key) >= 0) {
@ -554,35 +535,32 @@ pandora.ui.infoView = function(data, isMixed) {
edit[key] = value ? value : null; edit[key] = value ? value : null;
} }
pandora.api.edit(edit, function(result) { pandora.api.edit(edit, function(result) {
var src;
data[key] = result.data[key];
descriptions[key] && descriptions[key].options({
value: result.data[key + 'description']
});
Ox.Request.clearCache(); // fixme: too much? can change filter/list etc Ox.Request.clearCache(); // fixme: too much? can change filter/list etc
if (!isMultiple) { if (result.data.id != data.id) {
var src; pandora.UI.set({item: result.data.id});
data[key] = result.data[key]; pandora.$ui.browser.value(data.id, 'id', result.data.id);
descriptions[key] && descriptions[key].options({
value: result.data[key + 'description']
});
if (result.data.id != data.id) {
pandora.UI.set({item: result.data.id});
pandora.$ui.browser.value(data.id, 'id', result.data.id);
}
pandora.updateItemContext();
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
if (Ox.contains(posterKeys, key) && ui.icons == 'posters') {
src = pandora.getMediaURL('/' + data.id + '/poster512.jpg?' + Ox.uid());
$icon.attr({src: src});
$reflectionIcon.attr({src: src});
}
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());
} }
that.triggerEvent('change', Ox.extend({}, key, value)); pandora.updateItemContext();
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
if (Ox.contains(posterKeys, key) && ui.icons == 'posters') {
src = pandora.getMediaURL('/' + data.id + '/poster512.jpg?' + Ox.uid());
$icon.attr({src: src});
$reflectionIcon.attr({src: src});
}
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());
}); });
} }
} }
@ -741,7 +719,7 @@ pandora.ui.infoView = function(data, isMixed) {
format: function(value) { format: function(value) {
return formatValue(key, value); return formatValue(key, value);
}, },
placeholder: formatLight(Ox._(isMixed[key] ? 'mixed' : 'unknown')), placeholder: formatLight(Ox._('unknown')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
value: getValue(key, data[key]) value: getValue(key, data[key])
}) })
@ -783,12 +761,8 @@ pandora.ui.infoView = function(data, isMixed) {
.css({background: $rightsLevelElement.css('background')}) .css({background: $rightsLevelElement.css('background')})
.data({OxColor: $rightsLevelElement.data('OxColor')}) .data({OxColor: $rightsLevelElement.data('OxColor')})
renderCapabilities(rightsLevel); renderCapabilities(rightsLevel);
var edit = { pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) {
id: isMultiple ? ui.listSelection : data.id, // ...
rightslevel: rightsLevel
};
pandora.api.edit(edit, function(result) {
that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel));
}); });
} }
}) })

View file

@ -433,12 +433,6 @@ pandora.ui.mainMenu = function() {
} }
} else if (data.id == 'edit') { } else if (data.id == 'edit') {
pandora.ui.editItemDialog().open(); pandora.ui.editItemDialog().open();
} else if (data.id == 'batchedit') {
if (ui.section == 'documents') {
pandora.ui.editDocumentsDialog().open();
} else {
pandora.ui.editDialog().open();
}
} else if (data.id == 'deletelist') { } else if (data.id == 'deletelist') {
pandora.ui.deleteListDialog().open(); pandora.ui.deleteListDialog().open();
} else if (data.id == 'print') { } else if (data.id == 'print') {
@ -935,20 +929,6 @@ pandora.ui.mainMenu = function() {
key_control_p: function() { key_control_p: function() {
window.open(document.location.href + '#?print=true', '_blank'); window.open(document.location.href + '#?print=true', '_blank');
}, },
key_control_shift_e: function() {
console.log('!!', ui.section, pandora.enableBatchEdit(ui.section))
if (
!pandora.hasDialogOrScreen() &&
pandora.enableBatchEdit(ui.section)
) {
console.log('!!>>', ui.section)
if (ui.section == 'documents') {
pandora.ui.editDocumentsDialog().open();
} else {
pandora.ui.editDialog().open();
}
}
},
key_control_shift_f: function() { key_control_shift_f: function() {
if (!pandora.hasDialogOrScreen()) { if (!pandora.hasDialogOrScreen()) {
pandora.$ui.filterDialog = pandora.ui.filterDialog().open(); pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
@ -1166,7 +1146,6 @@ pandora.ui.mainMenu = function() {
return { id: 'itemMenu', title: Ox._('Item'), items: [ return { id: 'itemMenu', title: Ox._('Item'), items: [
{ id: 'add', title: Ox._('Add {0}...', [Ox._('Document')]), disabled: !pandora.hasCapability('canAddItems') }, { id: 'add', title: Ox._('Add {0}...', [Ox._('Document')]), disabled: !pandora.hasCapability('canAddItems') },
{ id: 'edit', title: Ox._('Edit {0}...', [Ox._('Document')]), disabled: true /*fixme: !canEdit */ }, { id: 'edit', title: Ox._('Edit {0}...', [Ox._('Document')]), disabled: true /*fixme: !canEdit */ },
{ id: 'batchedit', title: Ox._('Batch Edit {0}...', [Ox._('Documents')]), disabled: !pandora.enableBatchEdit(ui.section), keyboard: 'shift control e' },
{}, {},
{ id: 'selectall', title: Ox._('Select All {0}', [listItemsName]), disabled: !canSelect, keyboard: 'control a' }, { id: 'selectall', title: Ox._('Select All {0}', [listItemsName]), disabled: !canSelect, keyboard: 'control a' },
{ id: 'selectnone', title: Ox._('Select None'), disabled: !canSelect, keyboard: 'shift control a' }, { id: 'selectnone', title: Ox._('Select None'), disabled: !canSelect, keyboard: 'shift control a' },
@ -1444,7 +1423,6 @@ pandora.ui.mainMenu = function() {
return { id: 'itemMenu', title: Ox._('Item'), items: [ return { id: 'itemMenu', title: Ox._('Item'), items: [
{ id: 'add', title: Ox._('Add {0}...', [Ox._(pandora.site.itemName.singular)]), disabled: !pandora.hasCapability('canAddItems') }, { id: 'add', title: Ox._('Add {0}...', [Ox._(pandora.site.itemName.singular)]), disabled: !pandora.hasCapability('canAddItems') },
{ id: 'edit', title: Ox._('Edit {0}...', [Ox._(pandora.site.itemName.singular)]), disabled: true /*fixme: !canEdit */ }, { id: 'edit', title: Ox._('Edit {0}...', [Ox._(pandora.site.itemName.singular)]), disabled: true /*fixme: !canEdit */ },
{ id: 'batchedit', title: Ox._('Batch Edit {0}...', [Ox._(pandora.site.itemName.plural)]), disabled: !pandora.enableBatchEdit(ui.section), keyboard: 'shift control e' },
{}, {},
{ id: 'selectall', title: Ox._('Select All {0}', [listItemsName]), disabled: !canSelect, keyboard: 'control a' }, { id: 'selectall', title: Ox._('Select All {0}', [listItemsName]), disabled: !canSelect, keyboard: 'control a' },
{ id: 'selectnone', title: Ox._('Select None'), disabled: !canSelect, keyboard: 'shift control a' }, { id: 'selectnone', title: Ox._('Select None'), disabled: !canSelect, keyboard: 'shift control a' },

View file

@ -679,19 +679,6 @@ pandora.createLinks = function($element) {
}()); }());
pandora.enableBatchEdit = function(section) {
var ui = pandora.user.ui;
if (section == 'documents') {
return !ui.document && ui.collectionSelection.length > 1 && ui.collectionSelection.every(function(item) {
return pandora.$ui.list && pandora.$ui.list.value(item, 'editable');
})
} else {
return !ui.item && ui.listSelection.length > 1 && ui.listSelection.every(function(item) {
return pandora.$ui.list && pandora.$ui.list.value(item, 'editable');
})
}
};
pandora.enableDragAndDrop = function($list, canMove, section, getItems) { pandora.enableDragAndDrop = function($list, canMove, section, getItems) {
section = section || pandora.user.ui.section; section = section || pandora.user.ui.section;