update documents panel and dialog

This commit is contained in:
rolux 2014-01-07 14:29:12 +00:00
parent e3ca70c9ea
commit b9b5a0d5b3
2 changed files with 35 additions and 10 deletions

View file

@ -40,8 +40,7 @@ pandora.ui.documentDialog = function(options) {
}); });
}, },
pandora_document: function(data) { pandora_document: function(data) {
Ox.print('DOCUMENT', data) if (data.value) {
if (data.value.length) {
if (Ox.getObjectById(items, data.value)) { if (Ox.getObjectById(items, data.value)) {
} else { } else {
@ -68,6 +67,7 @@ pandora.ui.documentDialog = function(options) {
right: '4px', right: '4px',
top: '4px' top: '4px'
}) })
[items.length > 1 ? 'show' : 'hide']()
.bindEvent({ .bindEvent({
click: function(data) { click: function(data) {
options.index = Ox.mod( options.index = Ox.mod(
@ -89,7 +89,12 @@ pandora.ui.documentDialog = function(options) {
$content.replaceWith( $content.replaceWith(
$content = ( $content = (
item.extension == 'pdf' item.extension == 'pdf'
? Ox.Element() ? Ox.PDFViewer({
height: dialogHeight,
url: '/documents/' + item.id + '/'
+ item.name + '.' + item.extension,
width: dialogWidth
})
: Ox.ImageViewer({ : Ox.ImageViewer({
height: dialogHeight, height: dialogHeight,
imageHeight: item.dimensions[1], imageHeight: item.dimensions[1],

View file

@ -114,7 +114,7 @@ pandora.ui.documentsPanel = function(options) {
.bindEvent({ .bindEvent({
click: function() { click: function() {
if (isItemView) { if (isItemView) {
editDocuments();
} else { } else {
} }
@ -265,8 +265,16 @@ pandora.ui.documentsPanel = function(options) {
}) })
.css({float: 'left', margin: '4px'}) .css({float: 'left', margin: '4px'})
.bindEvent({ .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), .appendTo($itemBar),
@ -318,7 +326,6 @@ pandora.ui.documentsPanel = function(options) {
overflow: 'hidden', overflow: 'hidden',
textOverflow: 'ellipsis' textOverflow: 'ellipsis'
}) })
.html(Ox._('No document selected'))
.appendTo($itemStatusbar), .appendTo($itemStatusbar),
$itemPanel = Ox.SplitPanel({ $itemPanel = Ox.SplitPanel({
@ -338,7 +345,7 @@ pandora.ui.documentsPanel = function(options) {
ui.documentSize = 0; ui.documentSize = 0;
pandora.UI.set({documentSize: data.size}); pandora.UI.set({documentSize: data.size});
}, },
toggle: function() { toggle: function(data) {
pandora.UI.set({showDocument: !data.collapsed}); pandora.UI.set({showDocument: !data.collapsed});
} }
}), }),
@ -350,11 +357,13 @@ pandora.ui.documentsPanel = function(options) {
}, },
{ {
collapsible: isItemView, collapsible: isItemView,
collapsed: !ui.showDocument, collapsed: isItemView && !ui.showDocument,
element: $itemPanel, element: $itemPanel,
size: ui.documentSize, size: ui.documentSize,
resizable: true, resizable: true,
resize: [192, 256, 320, 384] resize: [192, 256, 320, 384],
tooltip: 'document <span class="OxBright">'
+ Ox.SYMBOLS.SHIFT + 'D</span>'
} }
], ],
orientation: 'horizontal' orientation: 'horizontal'
@ -366,6 +375,9 @@ pandora.ui.documentsPanel = function(options) {
}, },
pandora_documentsview: function(data) { pandora_documentsview: function(data) {
$listPanel.replaceElement(1, $list = renderList()); $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') + ', ' + Ox.formatValue(data.size, 'B')
); );
}, },
key_escape: function() {
pandora.UI.set({document: ''});
},
open: openDocuments, open: openDocuments,
openpreview: openDocuments, openpreview: openDocuments,
select: function(data) { select: function(data) {
@ -664,6 +679,11 @@ pandora.ui.documentsPanel = function(options) {
$preview = renderPreview().appendTo($item); $preview = renderPreview().appendTo($item);
$form = renderForm().appendTo($item); $form = renderForm().appendTo($item);
} }
$itemStatus.html(
selected.length
? Ox.formatCount(selected.length, 'Document')
: Ox._('No document selected')
);
} }
function updateList() { function updateList() {