From b9b5a0d5b356946f1bd2c418f628ebd819bd9b63 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 7 Jan 2014 14:29:12 +0000 Subject: [PATCH] update documents panel and dialog --- static/js/documentDialog.js | 11 ++++++++--- static/js/documentsPanel.js | 34 +++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/static/js/documentDialog.js b/static/js/documentDialog.js index 203f7512..5b5612b6 100644 --- a/static/js/documentDialog.js +++ b/static/js/documentDialog.js @@ -40,8 +40,7 @@ pandora.ui.documentDialog = function(options) { }); }, pandora_document: function(data) { - Ox.print('DOCUMENT', data) - if (data.value.length) { + if (data.value) { if (Ox.getObjectById(items, data.value)) { } else { @@ -68,6 +67,7 @@ pandora.ui.documentDialog = function(options) { right: '4px', top: '4px' }) + [items.length > 1 ? 'show' : 'hide']() .bindEvent({ click: function(data) { options.index = Ox.mod( @@ -89,7 +89,12 @@ pandora.ui.documentDialog = function(options) { $content.replaceWith( $content = ( item.extension == 'pdf' - ? Ox.Element() + ? Ox.PDFViewer({ + height: dialogHeight, + url: '/documents/' + item.id + '/' + + item.name + '.' + item.extension, + width: dialogWidth + }) : Ox.ImageViewer({ height: dialogHeight, imageHeight: item.dimensions[1], diff --git a/static/js/documentsPanel.js b/static/js/documentsPanel.js index 06e47e3a..30a1fbe2 100644 --- a/static/js/documentsPanel.js +++ b/static/js/documentsPanel.js @@ -114,7 +114,7 @@ pandora.ui.documentsPanel = function(options) { .bindEvent({ click: function() { if (isItemView) { - + editDocuments(); } else { } @@ -265,8 +265,16 @@ pandora.ui.documentsPanel = function(options) { }) .css({float: 'left', margin: '4px'}) .bindEvent({ - click: function() { - + click: function(data) { + if (data.id == 'open') { + openDocuments(); + } else if (data.id == 'edit') { + editDocuments(); + } else if (data.id == 'remove') { + removeDocuments(); + } else if (data.id == 'delete') { + deleteDocuments(); + } } }) .appendTo($itemBar), @@ -318,7 +326,6 @@ pandora.ui.documentsPanel = function(options) { overflow: 'hidden', textOverflow: 'ellipsis' }) - .html(Ox._('No document selected')) .appendTo($itemStatusbar), $itemPanel = Ox.SplitPanel({ @@ -338,7 +345,7 @@ pandora.ui.documentsPanel = function(options) { ui.documentSize = 0; pandora.UI.set({documentSize: data.size}); }, - toggle: function() { + toggle: function(data) { pandora.UI.set({showDocument: !data.collapsed}); } }), @@ -350,11 +357,13 @@ pandora.ui.documentsPanel = function(options) { }, { collapsible: isItemView, - collapsed: !ui.showDocument, + collapsed: isItemView && !ui.showDocument, element: $itemPanel, size: ui.documentSize, resizable: true, - resize: [192, 256, 320, 384] + resize: [192, 256, 320, 384], + tooltip: 'document ' + + Ox.SYMBOLS.SHIFT + 'D' } ], orientation: 'horizontal' @@ -366,6 +375,9 @@ pandora.ui.documentsPanel = function(options) { }, pandora_documentsview: function(data) { $listPanel.replaceElement(1, $list = renderList()); + }, + pandora_showdocument: function(data) { + isItemView && that.toggle(1); } }); @@ -596,6 +608,9 @@ pandora.ui.documentsPanel = function(options) { + ', ' + Ox.formatValue(data.size, 'B') ); }, + key_escape: function() { + pandora.UI.set({document: ''}); + }, open: openDocuments, openpreview: openDocuments, select: function(data) { @@ -664,6 +679,11 @@ pandora.ui.documentsPanel = function(options) { $preview = renderPreview().appendTo($item); $form = renderForm().appendTo($item); } + $itemStatus.html( + selected.length + ? Ox.formatCount(selected.length, 'Document') + : Ox._('No document selected') + ); } function updateList() {