documents panel: update menu

This commit is contained in:
rolux 2014-01-16 04:50:44 +00:00
parent 21c03ab85d
commit 07f6e46509

View file

@ -256,11 +256,17 @@ pandora.ui.documentsPanel = function(options) {
$itemMenu = Ox.MenuButton({ $itemMenu = Ox.MenuButton({
items: isItemView ? [ items: isItemView ? [
{id: 'add', title: Ox._(
'Add Documents to ' + pandora.site.itemName.singular + '...'
), keyboard: 'control n'},
{},
{id: 'open', title: '', keyboard: 'return'}, {id: 'open', title: '', keyboard: 'return'},
{id: 'edit', title: ''}, {id: 'edit', title: ''},
{}, {},
{id: 'remove', title: '', keyboard: 'delete'} {id: 'remove', title: '', keyboard: 'delete'}
] : [ ] : [
{id: 'upload', title: Ox._('Upload Documents...')},
{},
{id: 'open', title: '', keyboard: 'return'}, {id: 'open', title: '', keyboard: 'return'},
{id: 'add', title: ''}, {id: 'add', title: ''},
{}, {},
@ -275,7 +281,7 @@ pandora.ui.documentsPanel = function(options) {
.bindEvent({ .bindEvent({
click: function(data) { click: function(data) {
if (data.id == 'add') { if (data.id == 'add') {
addDocuments(); isItemView ? openDocumentsDialog() : addDocuments();
} else if (data.id == 'open') { } else if (data.id == 'open') {
openDocuments(); openDocuments();
} else if (data.id == 'edit') { } else if (data.id == 'edit') {
@ -708,13 +714,13 @@ pandora.ui.documentsPanel = function(options) {
function resizeItem() { function resizeItem() {
var size = getPreviewSize(), var size = getPreviewSize(),
width = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE; width = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE;
$preview.options({ $preview && $preview.options({
height: size.height, height: size.height,
width: size.width width: size.width
}).css({ }).css({
margin: size.margin margin: size.margin
}); });
$form.options('items').forEach(function($item) { $form && $form.options('items').forEach(function($item) {
$item.options({width: width}); $item.options({width: width});
}); });
} }
@ -723,10 +729,16 @@ pandora.ui.documentsPanel = function(options) {
var selected = ui.documentsSelection[isItemView ? ui.item : ''] || [], var selected = ui.documentsSelection[isItemView ? ui.item : ''] || [],
string = selected.length < 2 ? 'Document' : ' Documents'; string = selected.length < 2 ? 'Document' : ' Documents';
$list.options({selected: selected}); $list.options({selected: selected});
$itemMenu.setItemTitle('open', Ox._('Open ' + string)); $itemMenu.setItemTitle('open', Ox._('Open ' + string))
[selected.length > 0 ? 'enableItem' : 'disableItem']('open');
if (isItemView) { if (isItemView) {
$itemMenu.setItemTitle('edit', Ox._('Edit ' + string + '...')) $itemMenu.setItemTitle('edit', Ox._('Edit ' + string + '...'))
.setItemTitle('remove', Ox._('Remove ' + string)); .setItemTitle('remove', Ox._(
'Remove ' + string + ' from '
+ pandora.site.itemName.singular
))
[selected.length > 0 ? 'enableItem' : 'disableItem']('edit')
[selected.length > 0 ? 'enableItem' : 'disableItem']('remove');
} else { } else {
$itemMenu.setItemTitle('add', Ox._( $itemMenu.setItemTitle('add', Ox._(
'Add ' + string + ' to Current ' 'Add ' + string + ' to Current '
@ -734,9 +746,9 @@ pandora.ui.documentsPanel = function(options) {
)) ))
.setItemTitle('replace', Ox._('Replace ' + string + '...')) .setItemTitle('replace', Ox._('Replace ' + string + '...'))
.setItemTitle('delete', Ox._('Delete ' + string + '...')) .setItemTitle('delete', Ox._('Delete ' + string + '...'))
[selected.length == 1 ? 'enableItem' : 'disableItem']('replace'); [selected.length == 1 ? 'enableItem' : 'disableItem']('replace')
[selected.length > 0 ? 'enableItem' : 'disableItem']('delete');
} }
$itemMenu[selected.length ? 'show' : 'hide']();
$selectButton[selected.length > 1 ? 'show' : 'hide'](); $selectButton[selected.length > 1 ? 'show' : 'hide']();
$deselectButton[selected.length ? 'show' : 'hide'](); $deselectButton[selected.length ? 'show' : 'hide']();
$item.empty(); $item.empty();