diff --git a/pandora/app/config.py b/pandora/app/config.py index 3a9dd36d..db6093f0 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -262,8 +262,6 @@ def update_static(): 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 f in files: - if f.startswith('._'): - continue f = os.path.join(root, f) #ignore old embed js file if 'js/embed/' in f: diff --git a/pandora/archive/chop.py b/pandora/archive/chop.py index 75e36342..9738c9b5 100644 --- a/pandora/archive/chop.py +++ b/pandora/archive/chop.py @@ -119,7 +119,7 @@ class Chop(object): self.keyframes = make_keyframe_index(video) return self.keyframes - def get_gop_sections(self, start, end): + def get_gop_sections(self, start: float, end: float) -> dict: keyframes = self.get_keyframes() start_pos = bisect_left(keyframes, start) end_pos = bisect_left(keyframes, end) diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index 7ca640c0..d1738c7c 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -10,7 +10,6 @@ annotations by specific users can be turned on and off */ "annotations": { - "separator": ";", "showUsers": false }, /* diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index 2960c173..74586ec5 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -11,7 +11,6 @@ annotations by specific users can be turned on and off */ "annotations": { - "separator": ";", "showUsers": true }, /* diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index 9c8e75ce..da30aea8 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -10,7 +10,6 @@ annotations by specific users can be turned on and off */ "annotations": { - "separator": ";", "showUsers": true }, /* diff --git a/pandora/document/views.py b/pandora/document/views.py index a95ca06e..63ef06a2 100644 --- a/pandora/document/views.py +++ b/pandora/document/views.py @@ -132,19 +132,14 @@ def editDocument(request, data): response = json_response() item = 'item' in data and Item.objects.get(public_id=data['item']) or None if data['id']: - if isinstance(data['id'], list): - documents = models.Document.objects.filter(pk__in=map(ox.fromAZ, data['id'])) + document = models.Document.get(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: - documents = [models.Document.get(data['id'])] - 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') + response = json_response(status=403, text='permission denied') else: response = json_response(status=500, text='invalid request') return render_to_json_response(response) diff --git a/pandora/item/views.py b/pandora/item/views.py index 02d8f924..3600086e 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -622,19 +622,14 @@ def edit(request, data): } see: add, find, get, lookup, remove, upload ''' - if isinstance(data['id'], list): - items = models.Item.objects.filter(public_id__in=data['id']) + item = get_object_or_404_json(models.Item, public_id=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: - items = [get_object_or_404_json(models.Item, public_id=data['id'])] - 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') + response = json_response(status=403, text='permission denied') return render_to_json_response(response) actions.register(edit, cache=False) diff --git a/pandora/oxdjango/fields.py b/pandora/oxdjango/fields.py index b9b1e58b..e4f4ae43 100644 --- a/pandora/oxdjango/fields.py +++ b/pandora/oxdjango/fields.py @@ -17,7 +17,7 @@ class JSONField(django.contrib.postgres.fields.JSONField): def __init__(self, *args, **kwargs): if 'encoder' not in kwargs: kwargs['encoder'] = DjangoJSONEncoder - super(JSONField, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def to_json(python_object): if isinstance(python_object, datetime.datetime): @@ -74,8 +74,6 @@ class DictField(models.TextField): except: raise Exception('failed to parse value: %s' % value) if value is not None: - if isinstance(value, string_types): - value = json.loads(value) assert isinstance(value, self._type) return value diff --git a/static/js/documentInfoView.js b/static/js/documentInfoView.js index 592afd45..9d6c1010 100644 --- a/static/js/documentInfoView.js +++ b/static/js/documentInfoView.js @@ -1,11 +1,9 @@ 'use strict'; -pandora.ui.documentInfoView = function(data, isMixed) { - isMixed = isMixed || {}; +pandora.ui.documentInfoView = function(data) { var ui = pandora.user.ui, - isMultiple = arguments.length == 2, - canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable, + canEdit = pandora.hasCapability('canEditMetadata') || data.editable, canRemove = pandora.hasCapability('canRemoveItems'), css = { marginTop: '4px', @@ -13,8 +11,8 @@ pandora.ui.documentInfoView = function(data, isMixed) { }, html, iconRatio = data.ratio, - iconSize = isMultiple ? 0 : ui.infoIconSize, - iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), + 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, margin = 16, @@ -105,65 +103,63 @@ pandora.ui.documentInfoView = function(data, isMixed) { that = Ox.SplitPanel({ elements: [ - {element: $bar, size: isMultiple ? 0 : 16}, + {element: $bar, size: 16}, {element: $info} ], orientation: 'vertical' - }); + }), - if (!isMultiple) { - var $icon = Ox.Element({ - element: '', - }) - .attr({ - src: '/documents/' + data.id + '/512p.jpg?' + data.modified - }) - .css({ - position: 'absolute', - left: margin + iconLeft + 'px', - top: margin + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px' - }) - .bindEvent({ - // singleclick: toggleIconSize - }) - .appendTo($info), + $icon = Ox.Element({ + element: '', + }) + .attr({ + src: '/documents/' + data.id + '/512p.jpg?' + data.modified + }) + .css({ + position: 'absolute', + left: margin + iconLeft + 'px', + top: margin + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px' + }) + .bindEvent({ + // singleclick: toggleIconSize + }) + .appendTo($info), - $reflection = $('
') - .addClass('OxReflection') - .css({ - position: 'absolute', - left: margin + 'px', - top: margin + iconHeight + 'px', - width: iconSize + 'px', - height: iconSize / 2 + 'px', - overflow: 'hidden' - }) - .appendTo($info), + $reflection = $('
') + .addClass('OxReflection') + .css({ + position: 'absolute', + left: margin + 'px', + top: margin + iconHeight + 'px', + width: iconSize + 'px', + height: iconSize / 2 + 'px', + overflow: 'hidden' + }) + .appendTo($info), - $reflectionIcon = $('') - .attr({ - src: '/documents/' + data.id + '/512p.jpg?' + data.modified - }) - .css({ - position: 'absolute', - left: iconLeft + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px', - }) - .appendTo($reflection), + $reflectionIcon = $('') + .attr({ + src: '/documents/' + data.id + '/512p.jpg?' + data.modified + }) + .css({ + position: 'absolute', + left: iconLeft + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px', + }) + .appendTo($reflection), - $reflectionGradient = $('
') - .css({ - position: 'absolute', - width: iconSize + 'px', - height: iconSize / 2 + 'px' - }) - .appendTo($reflection); - } + $reflectionGradient = $('
') + .css({ + position: 'absolute', + width: iconSize + 'px', + height: iconSize / 2 + 'px' + }) + .appendTo($reflection), - var $text = Ox.Element() + $text = Ox.Element() .addClass('OxTextPage') .css({ position: 'absolute', @@ -267,13 +263,13 @@ pandora.ui.documentInfoView = function(data, isMixed) { } // Referenced -------------------------------------------------------------- + if ( - !isMultiple && ( data.referenced.items.length || data.referenced.annotations.length || data.referenced.documents.length || data.referenced.entities.length - )) { + ) { var itemsById = {} data.referenced.items.forEach(function(item) { @@ -291,6 +287,7 @@ pandora.ui.documentInfoView = function(data, isMixed) { itemsById[itemId].annotations = itemsById[itemId].annotations.concat(annotation); }); var html = Ox.sortBy(Object.values(itemsById), 'title').map(function(item) { + console.log('item', item) return (item.referenced ? '' : '') + item.title //Ox.encodeHTMLEntities(item.title) + (item.referenced ? '' : '') @@ -363,9 +360,7 @@ pandora.ui.documentInfoView = function(data, isMixed) { function editMetadata(key, value) { if (value != data[key]) { - var edit = { - id: isMultiple ? ui.collectionSelection : data.id, - }; + var edit = {id: data.id}; if (key == 'title') { edit[key] = value; } else if (listKeys.indexOf(key) >= 0) { @@ -374,26 +369,23 @@ pandora.ui.documentInfoView = function(data, isMixed) { edit[key] = value ? value : null; } pandora.api.editDocument(edit, function(result) { - if (!isMultiple) { - var src; - data[key] = result.data[key]; - Ox.Request.clearCache(); // fixme: too much? can change filter/list etc - if (result.data.id != data.id) { - pandora.UI.set({document: 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: '' + (pandora.getDocumentTitle(result.data)) + ''}); + var src; + data[key] = result.data[key]; + Ox.Request.clearCache(); // fixme: too much? can change filter/list etc + if (result.data.id != data.id) { + pandora.UI.set({document: result.data.id}); + pandora.$ui.browser.value(data.id, 'id', result.data.id); } - 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: '' + (pandora.getDocumentTitle(result.data)) + ''}); }); } } 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); mode = mode || 'text'; return mode == 'text' @@ -429,11 +421,7 @@ pandora.ui.documentInfoView = function(data, isMixed) { } else if (['type', 'publisher'].indexOf(key) > -1) { ret = formatLink(value, key); } else { - if (isMixed[key]) { - ret = 'Mixed' - } else { - ret = pandora.formatDocumentKey(Ox.getObjectById(pandora.site.documentKeys, key), data); - } + ret = pandora.formatDocumentKey(Ox.getObjectById(pandora.site.documentKeys, key), data); } return ret; } @@ -545,7 +533,7 @@ pandora.ui.documentInfoView = function(data, isMixed) { format: function(value) { return formatValue(key, value); }, - placeholder: formatLight(Ox._(isMixed[key] ? 'mixed' : 'unknown')), + placeholder: formatLight(Ox._('unknown')), tooltip: canEdit ? pandora.getEditTooltip() : '', value: getValue(key, data[key]) }) @@ -588,12 +576,8 @@ pandora.ui.documentInfoView = function(data, isMixed) { .css({background: $rightsLevelElement.css('background')}) .data({OxColor: $rightsLevelElement.data('OxColor')}) //renderCapabilities(rightsLevel); - var edit = { - id: isMultiple ? ui.collectionSelection : data.id, - rightslevel: rightsLevel - }; - pandora.api.editDocument(edit, function(result) { - that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel)); + pandora.api.editDocument({id: data.id, rightslevel: rightsLevel}, function(result) { + // ... }); } }) diff --git a/static/js/editDialog.js b/static/js/editDialog.js deleted file mode 100644 index 6ad47d02..00000000 --- a/static/js/editDialog.js +++ /dev/null @@ -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; - -}; diff --git a/static/js/editDocumentsDialog.js b/static/js/editDocumentsDialog.js deleted file mode 100644 index 3c5cb1b8..00000000 --- a/static/js/editDocumentsDialog.js +++ /dev/null @@ -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; - -}; diff --git a/static/js/infoView.0xdb.js b/static/js/infoView.0xdb.js index 273acb62..c6a849ec 100644 --- a/static/js/infoView.0xdb.js +++ b/static/js/infoView.0xdb.js @@ -1,16 +1,14 @@ 'use strict'; -pandora.ui.infoView = function(data, isMixed) { - isMixed = isMixed || {}; +pandora.ui.infoView = function(data) { // fixme: given that currently, the info view doesn't scroll into view nicely // when collapsing the movies browser, the info view should become a split panel var ui = pandora.user.ui, - isMultiple = arguments.length == 2, - canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable, + canEdit = pandora.hasCapability('canEditMetadata'), canRemove = pandora.hasCapability('canRemoveItems'), - canSeeAllMetadata = pandora.user.level != 'guest' && !isMultiple, + canSeeAllMetadata = pandora.user.level != 'guest', css = { marginTop: '4px', textAlign: 'justify' @@ -18,15 +16,12 @@ pandora.ui.infoView = function(data, isMixed) { iconRatio = ui.icons == 'posters' ? ( ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio ) : 1, - iconSize = isMultiple ? 0 : ui.infoIconSize, - iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), + iconSize = ui.infoIconSize, + iconWidth = iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8, - isEditable = canEdit && (isMultiple - ? !ui.listSelection.some(function(id) { return id.slice(0, 2) != '0x' }) - : data.id.slice(0, 2) == '0x' - ), + isEditable = canEdit && data.id.slice(0, 2) == '0x', listWidth = 144 + Ox.UI.SCROLLBAR_SIZE, margin = 16, statisticsWidth = 128, @@ -106,7 +101,7 @@ pandora.ui.infoView = function(data, isMixed) { that = Ox.SplitPanel({ elements: [ - {element: $bar, size: isMultiple ? 0 : 16}, + {element: $bar, size: 16}, {element: $main} ], orientation: 'vertical' @@ -131,75 +126,73 @@ pandora.ui.infoView = function(data, isMixed) { right: 0, height: getHeight() + 'px' }) - .appendTo($info); + .appendTo($info), - if (!isMultiple) { - var $icon = Ox.Element({ - element: '', - tooltip: canEdit ? ( - !ui.showIconBrowser - ? Ox._('Doubleclick to edit icon') - : Ox._('Doubleclick to hide icons') - ) : '' - }) - .attr({ - src: pandora.getMediaURL('/' + data.id + '/' + ( - ui.icons == 'posters' - ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' - ) + '512.jpg?' + data.modified) - }) - .css({ - position: 'absolute', - left: margin + iconLeft + 'px', - top: margin + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px', - borderRadius: borderRadius + 'px', - cursor: 'pointer' - }) - .bindEvent({ - singleclick: toggleIconSize - }) - .appendTo($data.$element), + $icon = Ox.Element({ + element: '', + tooltip: canEdit ? ( + !ui.showIconBrowser + ? Ox._('Doubleclick to edit icon') + : Ox._('Doubleclick to hide icons') + ) : '' + }) + .attr({ + src: pandora.getMediaURL('/' + data.id + '/' + ( + ui.icons == 'posters' + ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' + ) + '512.jpg?' + data.modified) + }) + .css({ + position: 'absolute', + left: margin + iconLeft + 'px', + top: margin + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px', + borderRadius: borderRadius + 'px', + cursor: 'pointer' + }) + .bindEvent({ + singleclick: toggleIconSize + }) + .appendTo($data.$element), - $reflection = $('
') - .addClass('OxReflection') - .css({ - position: 'absolute', - left: margin + 'px', - top: margin + iconHeight + 'px', - width: iconSize + 'px', - height: Math.round(iconSize / 2) + 'px', - overflow: 'hidden' - }) - .appendTo($data.$element), + $reflection = $('
') + .addClass('OxReflection') + .css({ + position: 'absolute', + left: margin + 'px', + top: margin + iconHeight + 'px', + width: iconSize + 'px', + height: Math.round(iconSize / 2) + 'px', + overflow: 'hidden' + }) + .appendTo($data.$element), - $reflectionIcon = $('') - .attr({ - src: pandora.getMediaURL('/' + data.id + '/' + ( - ui.icons == 'posters' - ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' - ) + '512.jpg?' + data.modified) - }) - .css({ - position: 'absolute', - left: iconLeft + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px', - borderRadius: borderRadius + 'px' - }) - .appendTo($reflection), + $reflectionIcon = $('') + .attr({ + src: pandora.getMediaURL('/' + data.id + '/' + ( + ui.icons == 'posters' + ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' + ) + '512.jpg?' + data.modified) + }) + .css({ + position: 'absolute', + left: iconLeft + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px', + borderRadius: borderRadius + 'px' + }) + .appendTo($reflection), - $reflectionGradient = $('
') - .css({ - position: 'absolute', - width: iconSize + 'px', - height: Math.round(iconSize / 2) + 'px' - }) - .appendTo($reflection); - } + $reflectionGradient = $('
') + .css({ + position: 'absolute', + width: iconSize + 'px', + height: Math.round(iconSize / 2) + 'px' + }) + .appendTo($reflection), - var $text = Ox.Element() + $text = Ox.Element() .addClass('OxTextPage') .css({ position: 'absolute', @@ -235,7 +228,7 @@ pandora.ui.infoView = function(data, isMixed) { pandora.createLinks($text); // Title ------------------------------------------------------------------- - if (!isMultiple) { + $('
') .css({ marginTop: '-2px' @@ -262,7 +255,6 @@ pandora.ui.infoView = function(data, isMixed) { }) ) .appendTo($text); - } // Director ---------------------------------------------------------------- @@ -278,7 +270,7 @@ pandora.ui.infoView = function(data, isMixed) { format: function(value) { return formatValue(value.split(', '), 'name'); }, - placeholder: formatLight(Ox._(isMixed.director ? 'Mixed Director' : 'Unknown Director')), + placeholder: formatLight(Ox._('Unknown Director')), tooltip: isEditable ? pandora.getEditTooltip() : '', value: data.director ? data.director.join(', ') : '' }) @@ -314,7 +306,7 @@ pandora.ui.infoView = function(data, isMixed) { format: function(value) { return formatValue(value.split(', '), key) }, - placeholder: formatLight(isMixed[key] ? 'mixed' : 'unknown'), + placeholder: formatLight('unknown'), tooltip: pandora.getEditTooltip(), value: key == 'country' ? (data[key] ? data[key].join(', ') : ['']) @@ -328,7 +320,7 @@ pandora.ui.infoView = function(data, isMixed) { }) .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 = []; ['country', 'year', 'language', 'runtime', 'color', 'sound'].forEach(function(key) { if (data[key]) { @@ -387,7 +379,7 @@ pandora.ui.infoView = function(data, isMixed) { key == 'episodeDirector' ? 'name' : 'year' ); }, - placeholder: formatLight(Ox._(isMixed[key] ? 'mixed' : 'unknown')), + placeholder: formatLight('unknown'), tooltip: pandora.getEditTooltip(), value: key == 'episodeDirector' ? (data[key] ? data[key].join(', ') : ['']) @@ -401,7 +393,7 @@ pandora.ui.infoView = function(data, isMixed) { }) .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 = $('
') .addClass('OxSelectable') .css(css) @@ -443,7 +435,7 @@ pandora.ui.infoView = function(data, isMixed) { .appendTo($text); } - if (!isMultiple && (data.genre || (data.keyword && canSeeAllMetadata))) { + if (data.genre || (data.keyword && canSeeAllMetadata)) { $div = $('
') .addClass('OxSelectable') .css(css) @@ -464,7 +456,8 @@ pandora.ui.infoView = function(data, isMixed) { .html(formatKey('summary') + data.summary) .appendTo($text); - if (!isMultiple && canSeeAllMetadata) { + if (canSeeAllMetadata) { + data.trivia && data.trivia.forEach(function(value) { $('
') .css({ @@ -577,7 +570,7 @@ pandora.ui.infoView = function(data, isMixed) { $('
').css({height: '16px'}).appendTo($text); // Mainstream Score, Arthouse Score ---------------------------------------- - if (!isMultiple) { + ['votes', 'likes'].forEach(function(key) { var value = data[key] || 0; $('
') @@ -604,6 +597,7 @@ pandora.ui.infoView = function(data, isMixed) { }); // Duration, Aspect Ratio -------------------------------------------------- + ['duration', 'aspectratio'].forEach(function(key) { var itemKey = Ox.getObjectById(pandora.site.itemKeys, key), value = data[key] || 0; @@ -675,7 +669,6 @@ pandora.ui.infoView = function(data, isMixed) { ) .appendTo($statistics); }); - } // Rights Level ------------------------------------------------------------ @@ -696,7 +689,7 @@ pandora.ui.infoView = function(data, isMixed) { .append( Ox.EditableContent({ clickLink: pandora.clickLink, - placeholder: formatLight(Ox._(isMixed.notes ? 'Mixed notes' : 'No notes')), + placeholder: formatLight(Ox._('No notes')), tooltip: pandora.getEditTooltip(), type: 'textarea', value: data.notes || '', @@ -704,7 +697,12 @@ pandora.ui.infoView = function(data, isMixed) { }) .bindEvent({ 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) { $('
').css({height: '16px'}).appendTo($statistics); - if (canEdit && !isMultiple) { + if (canEdit) { $icon.bindEvent({ doubleclick: function() { pandora.UI.set({showIconBrowser: !ui.showIconBrowser}); @@ -732,7 +730,7 @@ pandora.ui.infoView = function(data, isMixed) { function editMetadata(key, value) { if (value != data[key]) { - var edit = {id: isMultiple ? ui.listSelection : data.id}; + var edit = {id: data.id}; if (key == 'title') { Ox.extend(edit, parseTitle(value)); } else if (['director', 'country'].indexOf(key) > -1) { @@ -741,17 +739,14 @@ pandora.ui.infoView = function(data, isMixed) { edit[key] = value; } pandora.api.edit(edit, function(result) { - if (!isMultiple) { - if (result.data.id != data.id) { - Ox.Request.clearCache(); // fixme: too much - pandora.UI.set({item: result.data.id}); - pandora.$ui.browser.value(data.id, 'id', result.data.id); - // FIXME: does this update selected? - } - pandora.updateItemContext(); - pandora.$ui.browser.value(result.data.id, key, result.data[key]); + if (result.data.id != data.id) { + Ox.Request.clearCache(); // fixme: too much + pandora.UI.set({item: result.data.id}); + pandora.$ui.browser.value(data.id, 'id', result.data.id); + // FIXME: does this update selected? } - 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')}) .data({OxColor: $rightsLevelElement.data('OxColor')}) renderCapabilities(rightsLevel); - var edit = { - id: isMultiple ? ui.listSelection : data.id, - rightslevel: rightsLevel - }; - pandora.api.edit(edit, function(result) { - that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel)); + pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) { + // ... }); } }) diff --git a/static/js/infoView.indiancinema.js b/static/js/infoView.indiancinema.js index ef1e7499..4818be62 100644 --- a/static/js/infoView.indiancinema.js +++ b/static/js/infoView.indiancinema.js @@ -1,11 +1,9 @@ 'use strict'; -pandora.ui.infoView = function(data, isMixed) { - isMixed = isMixed || {}; +pandora.ui.infoView = function(data) { var ui = pandora.user.ui, - isMultiple = arguments.length == 2, - canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable, + canEdit = pandora.hasCapability('canEditMetadata'), canRemove = pandora.hasCapability('canRemoveItems'), canSeeAllMetadata = pandora.user.level != 'guest', css = { @@ -15,8 +13,8 @@ pandora.ui.infoView = function(data, isMixed) { iconRatio = ui.icons == 'posters' ? ( ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio ) : 1, - iconSize = isMultiple ? 0 : ui.infoIconSize, - iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), + 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, @@ -135,73 +133,71 @@ pandora.ui.infoView = function(data, isMixed) { that = Ox.SplitPanel({ elements: [ - {element: $bar, size: isMultiple ? 0 : 16}, + {element: $bar, size: 16}, {element: $info} ], orientation: 'vertical' - }); + }), - if (!isMultiple) { - var $icon = Ox.Element({ - element: '' - }) - .attr({ - src: pandora.getMediaURL('/' + data.id + '/' + ( - ui.icons == 'posters' ? 'poster' : 'icon' - ) + '512.jpg?' + data.modified) - }) - .css({ - position: 'absolute', - left: margin + iconLeft + 'px', - top: margin + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px', - borderRadius: borderRadius + 'px', - cursor: 'pointer' - }) - .bindEvent({ - singleclick: toggleIconSize - }) - .appendTo($info), + $icon = Ox.Element({ + element: '' + }) + .attr({ + src: pandora.getMediaURL('/' + data.id + '/' + ( + ui.icons == 'posters' ? 'poster' : 'icon' + ) + '512.jpg?' + data.modified) + }) + .css({ + position: 'absolute', + left: margin + iconLeft + 'px', + top: margin + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px', + borderRadius: borderRadius + 'px', + cursor: 'pointer' + }) + .bindEvent({ + singleclick: toggleIconSize + }) + .appendTo($info), - $reflection = $('
') - .addClass('OxReflection') - .css({ - position: 'absolute', - left: margin + 'px', - top: margin + iconHeight + 'px', - width: iconSize + 'px', - height: Math.round(iconSize / 2) + 'px', - overflow: 'hidden' - }) - .appendTo($info), + $reflection = $('
') + .addClass('OxReflection') + .css({ + position: 'absolute', + left: margin + 'px', + top: margin + iconHeight + 'px', + width: iconSize + 'px', + height: Math.round(iconSize / 2) + 'px', + overflow: 'hidden' + }) + .appendTo($info), - $reflectionIcon = $('') - .attr({ - src: pandora.getMediaURL('/' + data.id + '/' + ( - ui.icons == 'posters' - ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' - ) + '512.jpg?' + data.modified) - }) - .css({ - position: 'absolute', - left: iconLeft + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px', - borderRadius: borderRadius + 'px' - }) - .appendTo($reflection), + $reflectionIcon = $('') + .attr({ + src: pandora.getMediaURL('/' + data.id + '/' + ( + ui.icons == 'posters' + ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' + ) + '512.jpg?' + data.modified) + }) + .css({ + position: 'absolute', + left: iconLeft + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px', + borderRadius: borderRadius + 'px' + }) + .appendTo($reflection), - $reflectionGradient = $('
') - .css({ - position: 'absolute', - width: iconSize + 'px', - height: Math.round(iconSize / 2) + 'px' - }) - .appendTo($reflection); - } + $reflectionGradient = $('
') + .css({ + position: 'absolute', + width: iconSize + 'px', + height: Math.round(iconSize / 2) + 'px' + }) + .appendTo($reflection), - var $text = Ox.Element() + $text = Ox.Element() .addClass('OxTextPage') .css({ position: 'absolute', @@ -247,7 +243,6 @@ pandora.ui.infoView = function(data, isMixed) { }); // Title ------------------------------------------------------------------- - if (!isMultiple) { $('
') .css({ @@ -275,7 +270,6 @@ pandora.ui.infoView = function(data, isMixed) { }) ) .appendTo($text); - } // Director ---------------------------------------------------------------- @@ -291,7 +285,7 @@ pandora.ui.infoView = function(data, isMixed) { format: function(value) { return formatLink(value.split(', '), 'name'); }, - placeholder: formatLight(Ox._(isMixed.director ? 'Mixed Director' : 'Unknown Director')), + placeholder: formatLight(Ox._('Unknown Director')), tooltip: canEdit ? pandora.getEditTooltip() : '', value: data.director ? data.director.join(', ') : '' }) @@ -361,7 +355,7 @@ pandora.ui.infoView = function(data, isMixed) { '').attr({id: 'descriptions'}).appendTo($text); @@ -557,8 +550,6 @@ pandora.ui.infoView = function(data, isMixed) { // no video placeholder } - } - // Rights Level ------------------------------------------------------------ var $rightsLevel = $('
'); @@ -590,7 +581,7 @@ pandora.ui.infoView = function(data, isMixed) { .append( Ox.EditableContent({ clickLink: pandora.clickLink, - placeholder: formatLight(Ox._(isMixed.comments ? 'Mixed comments' : 'No comments')), + placeholder: formatLight(Ox._('No comments')), tooltip: pandora.getEditTooltip(), type: 'textarea', value: data.comments || '', @@ -598,7 +589,12 @@ pandora.ui.infoView = function(data, isMixed) { }) .bindEvent({ 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) { if (value != data[key]) { - var edit = {id: isMultiple ? ui.listSelection : data.id}; + var edit = {id: data.id}; if (key == 'alternativeTitles') { edit[key] = value ? Ox.decodeHTMLEntities(value).split('; ').map(function(value) { return [Ox.encodeHTMLEntities(value), []]; @@ -633,36 +629,33 @@ pandora.ui.infoView = function(data, isMixed) { edit[key] = value; } pandora.api.edit(edit, function(result) { - if (!isMultiple) { - var src; - data[key] = result.data[key]; - if (result.data.id != data.id) { - Ox.Request.clearCache(); // fixme: too much - pandora.UI.set({item: result.data.id}); - pandora.$ui.browser.value(data.id, 'id', result.data.id); - } else { - Ox.Request.clearCache('autocomplete'); - } - 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}); - } - if (Ox.contains(nameKeys, key)) { - data['namedescription'] = result.data['namedescription']; - descriptions.names = getNames(); - renderDescriptions(); - } else if (key == 'productionCompany') { - data['productionCompanydescription'] = result.data['productionCompanydescription']; - descriptions.studios = getStudios(); - renderDescriptions(); - } else if (key == 'imdbId') { - updateIMDb(); - } + var src; + data[key] = result.data[key]; + if (result.data.id != data.id) { + Ox.Request.clearCache(); // fixme: too much + pandora.UI.set({item: result.data.id}); + pandora.$ui.browser.value(data.id, 'id', result.data.id); + } else { + Ox.Request.clearCache('autocomplete'); + } + 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}); + } + if (Ox.contains(nameKeys, key)) { + data['namedescription'] = result.data['namedescription']; + descriptions.names = getNames(); + renderDescriptions(); + } else if (key == 'productionCompany') { + data['productionCompanydescription'] = result.data['productionCompanydescription']; + descriptions.studios = getStudios(); + renderDescriptions(); + } else if (key == 'imdbId') { + updateIMDb(); } - that.triggerEvent('change', Ox.extend({}, key, value)); }); } } @@ -1067,7 +1060,7 @@ pandora.ui.infoView = function(data, isMixed) { format: function(value) { return formatValue(key, value); }, - placeholder: formatLight(Ox._(isMixed[key] ? 'mixed': 'unknown')), + placeholder: formatLight(Ox._('unknown')), tooltip: canEdit ? pandora.getEditTooltip() : '', value: getValue(key, data[key]) }) @@ -1137,12 +1130,8 @@ pandora.ui.infoView = function(data, isMixed) { .css({background: $rightsLevelElement.css('background')}) .data({OxColor: $rightsLevelElement.data('OxColor')}) // renderCapabilities(rightsLevel); - var edit = { - id: isMultiple ? ui.listSelection : data.id, - rightslevel: rightsLevel - }; - pandora.api.edit(edit, function(result) { - that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel)); + pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) { + // ... }); } }) diff --git a/static/js/infoView.js b/static/js/infoView.js index a1460148..1628681d 100644 --- a/static/js/infoView.js +++ b/static/js/infoView.js @@ -1,12 +1,10 @@ 'use strict'; -pandora.ui.infoView = function(data, isMixed) { - isMixed = isMixed || {}; +pandora.ui.infoView = function(data) { var ui = pandora.user.ui, descriptions = [], - isMultiple = arguments.length == 2, - canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable, + canEdit = pandora.hasCapability('canEditMetadata') || data.editable, canRemove = pandora.hasCapability('canRemoveItems'), css = { marginTop: '4px', @@ -14,10 +12,10 @@ pandora.ui.infoView = function(data, isMixed) { }, html, iconRatio = ui.icons == 'posters' ? data.posterRatio : 1, - iconSize = isMultiple ? 0 : ui.infoIconSize, - iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), + iconSize = ui.infoIconSize, + iconWidth = 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, margin = 16, nameKeys = pandora.site.itemKeys.filter(function(key) { @@ -100,72 +98,70 @@ pandora.ui.infoView = function(data, isMixed) { that = Ox.SplitPanel({ elements: [ - {element: $bar, size: isMultiple ? 0 : 16}, + {element: $bar, size: 16}, {element: $info} ], orientation: 'vertical' - }); + }), - if (!isMultiple) { - var $icon = Ox.Element({ - element: '', - }) - .attr({ - src: '/' + data.id + '/' + ( - ui.icons == 'posters' ? 'poster' : 'icon' - ) + '512.jpg?' + data.modified - }) - .css({ - position: 'absolute', - left: margin + iconLeft + 'px', - top: margin + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px', - borderRadius: borderRadius + 'px', - cursor: 'pointer' - }) - .bindEvent({ - singleclick: toggleIconSize - }) - .appendTo($info), + $icon = Ox.Element({ + element: '', + }) + .attr({ + src: '/' + data.id + '/' + ( + ui.icons == 'posters' ? 'poster' : 'icon' + ) + '512.jpg?' + data.modified + }) + .css({ + position: 'absolute', + left: margin + iconLeft + 'px', + top: margin + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px', + borderRadius: borderRadius + 'px', + cursor: 'pointer' + }) + .bindEvent({ + singleclick: toggleIconSize + }) + .appendTo($info), - $reflection = $('
') - .addClass('OxReflection') - .css({ - position: 'absolute', - left: margin + 'px', - top: margin + iconHeight + 'px', - width: iconSize + 'px', - height: iconSize / 2 + 'px', - overflow: 'hidden' - }) - .appendTo($info), + $reflection = $('
') + .addClass('OxReflection') + .css({ + position: 'absolute', + left: margin + 'px', + top: margin + iconHeight + 'px', + width: iconSize + 'px', + height: iconSize / 2 + 'px', + overflow: 'hidden' + }) + .appendTo($info), - $reflectionIcon = $('') - .attr({ - src: '/' + data.id + '/' + ( - ui.icons == 'posters' ? 'poster' : 'icon' - ) + '512.jpg?' + data.modified - }) - .css({ - position: 'absolute', - left: iconLeft + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px', - borderRadius: borderRadius + 'px' - }) - .appendTo($reflection), + $reflectionIcon = $('') + .attr({ + src: '/' + data.id + '/' + ( + ui.icons == 'posters' ? 'poster' : 'icon' + ) + '512.jpg?' + data.modified + }) + .css({ + position: 'absolute', + left: iconLeft + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px', + borderRadius: borderRadius + 'px' + }) + .appendTo($reflection), - $reflectionGradient = $('
') - .css({ - position: 'absolute', - width: iconSize + 'px', - height: iconSize / 2 + 'px' - }) - .appendTo($reflection); - } + $reflectionGradient = $('
') + .css({ + position: 'absolute', + width: iconSize + 'px', + height: iconSize / 2 + 'px' + }) + .appendTo($reflection), - var $text = Ox.Element() + $text = Ox.Element() .addClass('OxTextPage') .css({ position: 'absolute', @@ -252,7 +248,7 @@ pandora.ui.infoView = function(data, isMixed) { ); }, maxHeight: Infinity, - placeholder: formatLight(Ox._( isMixed.summary ? 'Mixed Summary' : 'No Summary')), + placeholder: formatLight(Ox._('No Summary')), tooltip: canEdit ? pandora.getEditTooltip() : '', type: 'textarea', value: data.summary || '' @@ -272,50 +268,49 @@ pandora.ui.infoView = function(data, isMixed) { } // Duration, Aspect Ratio -------------------------------------------------- - if (!isMultiple) { - ['duration', 'aspectratio'].forEach(function(key) { - var itemKey = Ox.getObjectById(pandora.site.itemKeys, key), - value = data[key] || 0; - $('
') - .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) { - $('
') - .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; $('
') .css({marginBottom: '4px'}) - .append(formatKey('cuts per minute', 'statistics')) + .append(formatKey(itemKey.title, 'statistics')) .append( Ox.Theme.formatColor(null, 'gradient') .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); - } + }); + + // Hue, Saturation, Lightness, Volume -------------------------------------- + + ['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) { + $('
') + .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 --------------------------------------------------------- + + $('
') + .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 ------------------------------------------------------------ @@ -347,7 +342,7 @@ pandora.ui.infoView = function(data, isMixed) { .append( Ox.EditableContent({ height: 128, - placeholder: formatLight(Ox._(isMixed ? 'Mixed notes' : 'No notes')), + placeholder: formatLight(Ox._('No notes')), tooltip: pandora.getEditTooltip(), type: 'textarea', value: data.notes || '', @@ -366,7 +361,7 @@ pandora.ui.infoView = function(data, isMixed) { function editMetadata(key, value) { if (value != data[key]) { - var edit = {id: isMultiple ? ui.listSelection : data.id}; + var edit = {id: data.id}; if (key == 'title') { edit[key] = value; } else if (listKeys.indexOf(key) >= 0) { @@ -375,34 +370,31 @@ pandora.ui.infoView = function(data, isMixed) { edit[key] = value ? value : null; } pandora.api.edit(edit, function(result) { - if (!isMultiple) { - 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 - 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: '' + result.data.title - + (Ox.len(result.data.director) - ? ' (' + result.data.director.join(', ') + ')' - : '') - + (result.data.year ? ' ' + result.data.year : '') + '' - }); + 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 + if (result.data.id != data.id) { + pandora.UI.set({item: result.data.id}); + pandora.$ui.browser.value(data.id, 'id', result.data.id); } - 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: '' + result.data.title + + (Ox.len(result.data.director) + ? ' (' + result.data.director.join(', ') + ')' + : '') + + (result.data.year ? ' ' + result.data.year : '') + '' + }); }); } } @@ -554,7 +546,7 @@ pandora.ui.infoView = function(data, isMixed) { format: function(value) { return formatValue(key, value); }, - placeholder: formatLight(Ox._( isMixed[key] ? 'mixed' : 'unknown')), + placeholder: formatLight(Ox._('unknown')), tooltip: canEdit ? pandora.getEditTooltip() : '', value: getValue(key, data[key]) }) @@ -596,12 +588,8 @@ pandora.ui.infoView = function(data, isMixed) { .css({background: $rightsLevelElement.css('background')}) .data({OxColor: $rightsLevelElement.data('OxColor')}) renderCapabilities(rightsLevel); - var edit = { - id: isMultiple ? ui.listSelection : data.id, - rightslevel: rightsLevel - }; - pandora.api.edit(edit, function(result) { - that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel)); + pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) { + // ... }); } }) diff --git a/static/js/infoView.padma.js b/static/js/infoView.padma.js index 93125b48..3bc49b35 100644 --- a/static/js/infoView.padma.js +++ b/static/js/infoView.padma.js @@ -1,11 +1,9 @@ 'use strict'; -pandora.ui.infoView = function(data, isMixed) { - isMixed = isMixed || {}; +pandora.ui.infoView = function(data) { var ui = pandora.user.ui, - isMultiple = arguments.length == 2, - canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable, + canEdit = pandora.hasCapability('canEditMetadata') || data.editable, canRemove = pandora.hasCapability('canRemoveItems') || data.editable, css = { marginTop: '4px', @@ -14,8 +12,8 @@ pandora.ui.infoView = function(data, isMixed) { descriptions = [], html, iconRatio = ui.icons == 'posters' ? data.posterRatio : 1, - iconSize = isMultiple ? 0 : ui.infoIconSize, - iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), + 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, @@ -100,7 +98,7 @@ pandora.ui.infoView = function(data, isMixed) { that = Ox.SplitPanel({ elements: [ - {element: $bar, size: isMultiple ? 0 : 16}, + {element: $bar, size: 16}, {element: $info} ], orientation: 'vertical' @@ -110,74 +108,72 @@ pandora.ui.infoView = function(data, isMixed) { .css({ position: 'absolute' }) - .appendTo($info); + .appendTo($info), - if (!isMultiple) { - var $icon = Ox.Element({ - element: '', - tooltip: 'Switch to ' + Ox.getObjectById( - pandora.site.itemViews, - ui.videoView - ).title + ' View' - }) - .attr({ - src: pandora.getMediaURL('/' + data.id + '/' + ( - ui.icons == 'posters' ? 'poster' : 'icon' - ) + '512.jpg?' + data.modified) - }) - .css({ - position: 'absolute', - left: margin + iconLeft + 'px', - top: margin + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px', - borderRadius: borderRadius + 'px', - cursor: 'pointer' - }) - .bindEvent({ - anyclick: function() { - pandora.UI.set({itemView: ui.videoView}); - } - }) - .appendTo($left), + $icon = Ox.Element({ + element: '', + tooltip: 'Switch to ' + Ox.getObjectById( + pandora.site.itemViews, + ui.videoView + ).title + ' View' + }) + .attr({ + src: pandora.getMediaURL('/' + data.id + '/' + ( + ui.icons == 'posters' ? 'poster' : 'icon' + ) + '512.jpg?' + data.modified) + }) + .css({ + position: 'absolute', + left: margin + iconLeft + 'px', + top: margin + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px', + borderRadius: borderRadius + 'px', + cursor: 'pointer' + }) + .bindEvent({ + anyclick: function() { + pandora.UI.set({itemView: ui.videoView}); + } + }) + .appendTo($left), - $reflection = $('
') - .addClass('OxReflection') - .css({ - position: 'absolute', - left: margin + 'px', - top: margin + iconHeight + 'px', - width: iconSize + 'px', - height: Math.round(iconSize / 2) + 'px', - overflow: 'hidden' - }) - .appendTo($left), + $reflection = $('
') + .addClass('OxReflection') + .css({ + position: 'absolute', + left: margin + 'px', + top: margin + iconHeight + 'px', + width: iconSize + 'px', + height: Math.round(iconSize / 2) + 'px', + overflow: 'hidden' + }) + .appendTo($left), - $reflectionIcon = $('') - .attr({ - src: pandora.getMediaURL('/' + data.id + '/' + ( - ui.icons == 'posters' ? 'poster' : 'icon' - ) + '512.jpg?' + data.modified) - }) - .css({ - position: 'absolute', - left: iconLeft + 'px', - width: iconWidth + 'px', - height: iconHeight + 'px', - borderRadius: borderRadius + 'px' - }) - .appendTo($reflection), + $reflectionIcon = $('') + .attr({ + src: pandora.getMediaURL('/' + data.id + '/' + ( + ui.icons == 'posters' ? 'poster' : 'icon' + ) + '512.jpg?' + data.modified) + }) + .css({ + position: 'absolute', + left: iconLeft + 'px', + width: iconWidth + 'px', + height: iconHeight + 'px', + borderRadius: borderRadius + 'px' + }) + .appendTo($reflection), - $reflectionGradient = $('
') - .css({ - position: 'absolute', - width: iconSize + 'px', - height: Math.round(iconSize / 2) + 'px' - }) - .appendTo($reflection); - } + $reflectionGradient = $('
') + .css({ + position: 'absolute', + width: iconSize + 'px', + height: Math.round(iconSize / 2) + 'px' + }) + .appendTo($reflection), - var $data = $('
') + $data = $('
') .addClass('OxTextPage') .css({ position: 'absolute', @@ -227,7 +223,6 @@ pandora.ui.infoView = function(data, isMixed) { } // Source & Project -------------------------------------------------------- - if (!isMultiple) { ['source', 'project'].forEach(function(key) { if (canEdit || data[key]) { @@ -248,7 +243,7 @@ pandora.ui.infoView = function(data, isMixed) { format: function(value) { return formatValue(key, value); }, - placeholder: formatLight(Ox._(isMixed[key] ? 'mixed' : 'unknown')), + placeholder: formatLight(Ox._('unknown')), editable: canEdit, tooltip: canEdit ? pandora.getEditTooltip() : '', value: listKeys.indexOf(key) >= 0 @@ -291,10 +286,8 @@ pandora.ui.infoView = function(data, isMixed) { } } }); - } // Title ------------------------------------------------------------------- - if (!isMultiple) { $('
') .css({ @@ -319,16 +312,12 @@ pandora.ui.infoView = function(data, isMixed) { }) ) .appendTo($text); - } // Groups ------------------------------------------------------------------ renderGroup(['location', 'date', 'language']); renderGroup(['director', 'cinematographer', 'featuring']); - if (isMultiple) { - renderGroup(['source', 'project']); - } renderGroup(['topic']); @@ -375,17 +364,14 @@ pandora.ui.infoView = function(data, isMixed) { renderGroup(['license']); - $('
') .addClass('OxSelectable') .css(css) .css({height: '16px'}) .appendTo($text); - - // Duration, Aspect Ratio -------------------------------------------------- - if (!isMultiple) { + ['duration', 'aspectratio'].forEach(function(key) { var itemKey = Ox.getObjectById(pandora.site.itemKeys, key), value = data[key] || 0; @@ -428,7 +414,7 @@ pandora.ui.infoView = function(data, isMixed) { .html(Ox.formatNumber(data['cutsperminute'] || 0, 3)) ) .appendTo($statistics); - } + // Rights Level ------------------------------------------------------------ var $rightsLevel = $('
'); @@ -440,7 +426,6 @@ pandora.ui.infoView = function(data, isMixed) { renderRightsLevel(); // User and Groups --------------------------------------------------------- - if (!isMultiple) { ['user', 'groups'].forEach(function(key) { var $input; @@ -452,10 +437,10 @@ pandora.ui.infoView = function(data, isMixed) { .css({margin: '2px 0 0 -1px'}) // fixme: weird .append( $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, 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({ submit: function(event) { @@ -489,10 +474,8 @@ pandora.ui.infoView = function(data, isMixed) { ) .appendTo($statistics); }); - - } + // Created and Modified ---------------------------------------------------- - if (!isMultiple) { ['created', 'modified'].forEach(function(key) { $('
') @@ -504,8 +487,6 @@ pandora.ui.infoView = function(data, isMixed) { .appendTo($statistics); }); - } - // Notes -------------------------------------------------------------------- if (canEdit) { @@ -545,7 +526,7 @@ pandora.ui.infoView = function(data, isMixed) { function editMetadata(key, value) { if (value != data[key]) { - var edit = {id: isMultiple ? ui.listSelection : data.id}; + var edit = {id: data.id}; if (key == 'title') { edit[key] = value; } else if (listKeys.indexOf(key) >= 0) { @@ -554,35 +535,32 @@ pandora.ui.infoView = function(data, isMixed) { edit[key] = value ? value : null; } 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 - if (!isMultiple) { - var src; - data[key] = result.data[key]; - 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: '' + result.data.title - + (Ox.len(result.data.director) - ? ' (' + result.data.director.join(', ') + ')' - : '') - + (result.data.year ? ' ' + result.data.year : '') + '' - }); - //pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser()); + if (result.data.id != data.id) { + pandora.UI.set({item: result.data.id}); + pandora.$ui.browser.value(data.id, 'id', result.data.id); } - 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: '' + result.data.title + + (Ox.len(result.data.director) + ? ' (' + result.data.director.join(', ') + ')' + : '') + + (result.data.year ? ' ' + result.data.year : '') + '' + }); + //pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser()); }); } } @@ -741,7 +719,7 @@ pandora.ui.infoView = function(data, isMixed) { format: function(value) { return formatValue(key, value); }, - placeholder: formatLight(Ox._(isMixed[key] ? 'mixed' : 'unknown')), + placeholder: formatLight(Ox._('unknown')), tooltip: canEdit ? pandora.getEditTooltip() : '', value: getValue(key, data[key]) }) @@ -783,12 +761,8 @@ pandora.ui.infoView = function(data, isMixed) { .css({background: $rightsLevelElement.css('background')}) .data({OxColor: $rightsLevelElement.data('OxColor')}) renderCapabilities(rightsLevel); - var edit = { - id: isMultiple ? ui.listSelection : data.id, - rightslevel: rightsLevel - }; - pandora.api.edit(edit, function(result) { - that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel)); + pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) { + // ... }); } }) diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js index 02193851..bb3e0488 100644 --- a/static/js/mainMenu.js +++ b/static/js/mainMenu.js @@ -433,12 +433,6 @@ pandora.ui.mainMenu = function() { } } else if (data.id == 'edit') { 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') { pandora.ui.deleteListDialog().open(); } else if (data.id == 'print') { @@ -935,20 +929,6 @@ pandora.ui.mainMenu = function() { key_control_p: function() { 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() { if (!pandora.hasDialogOrScreen()) { pandora.$ui.filterDialog = pandora.ui.filterDialog().open(); @@ -1166,7 +1146,6 @@ pandora.ui.mainMenu = function() { return { id: 'itemMenu', title: Ox._('Item'), items: [ { 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: '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: '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: [ { 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: '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: 'selectnone', title: Ox._('Select None'), disabled: !canSelect, keyboard: 'shift control a' }, diff --git a/static/js/utils.js b/static/js/utils.js index 6e01d2be..a1b187db 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -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) { section = section || pandora.user.ui.section;