update documents panel and dialog

This commit is contained in:
rolux 2014-01-07 12:40:33 +00:00
parent 9a60e569d6
commit df07312df1
2 changed files with 85 additions and 28 deletions

View file

@ -23,25 +23,36 @@ pandora.ui.documentDialog = function(options) {
minWidth: 512, minWidth: 512,
padding: 0, padding: 0,
removeOnClose: true, removeOnClose: true,
title: item.name + '.' + item.extension, title: '',
width: dialogWidth width: dialogWidth
}) })
.bindEvent({ .bindEvent({
close: function() { close: function() {
pandora.UI.set({document: ''}); pandora.UI.set({document: ''});
delete pandora.$ui.documentDialog;
}, },
resize: function(data) { resize: function(data) {
dialogHeight = data.height;
dialogWidth = data.width;
$content.options({ $content.options({
height: data.height, height: dialogHeight,
width: data.width width: dialogWidth
}); });
}, },
pandora_document: function(data) { pandora_document: function(data) {
if (Ox.getObjectById(items, data.value)) { Ox.print('DOCUMENT', data)
if (data.value.length) {
if (Ox.getObjectById(items, data.value)) {
} else {
}
} else { } else {
that.close();
} }
},
pandora_item: function(data) {
pandora.UI.set({document: ''});
} }
}), }),
@ -71,6 +82,7 @@ pandora.ui.documentDialog = function(options) {
// fixme: why is this needed? // fixme: why is this needed?
$(that.find('.OxContent')[0]).css({overflow: 'hidden'}); $(that.find('.OxContent')[0]).css({overflow: 'hidden'});
setTitle();
setContent(); setContent();
function setContent() { function setContent() {
@ -89,10 +101,13 @@ pandora.ui.documentDialog = function(options) {
}) })
) )
.bindEvent({ .bindEvent({
center: function() { center: function(data) {
pandora.UI.set('document.' + item.id + '.center', data.center); pandora.UI.set('document.' + item.id + '.center', data.center);
}, },
page: function() { key_escape: function() {
pandora.$ui.documentDialog.close();
},
page: function(data) {
pandora.UI.set('document.' + item.id + '.page', data.page); pandora.UI.set('document.' + item.id + '.page', data.page);
}, },
zoom: function(data) { zoom: function(data) {
@ -102,6 +117,17 @@ pandora.ui.documentDialog = function(options) {
); );
} }
function setTitle() {
that.options({title: item.name + '.' + item.extension});
}
that.update = function(options) {
items = options.items;
item = items[options.index];
setTitle();
setContent();
};
return that; return that;
}; };

View file

@ -113,7 +113,11 @@ pandora.ui.documentsPanel = function(options) {
.css({float: 'left', margin: '4px 2px 4px 4px'}) .css({float: 'left', margin: '4px 2px 4px 4px'})
.bindEvent({ .bindEvent({
click: function() { click: function() {
if (isItemView) {
} else {
}
} }
}) })
.appendTo($listBar), .appendTo($listBar),
@ -190,7 +194,7 @@ pandora.ui.documentsPanel = function(options) {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
$findInput.options({placeholder: data.title}).focusInput();
} }
}), }),
@ -247,7 +251,7 @@ pandora.ui.documentsPanel = function(options) {
items: isItemView ? [ items: isItemView ? [
{id: 'open', title: '', keyboard: 'return'}, {id: 'open', title: '', keyboard: 'return'},
{id: 'edit', title: ''}, {id: 'edit', title: ''},
{id: 'remove', title: ''} {id: 'remove', title: '', keyboard: 'delete'}
] : [ ] : [
{id: 'open', title: '', keyboard: 'return'}, {id: 'open', title: '', keyboard: 'return'},
{id: 'addtoitem', title: ''}, {id: 'addtoitem', title: ''},
@ -376,6 +380,12 @@ pandora.ui.documentsPanel = function(options) {
pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open(); pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open();
} }
function closeDocuments() {
if (pandora.$ui.documentDialog) {
pandora.$ui.documentDialog.close();
}
}
function deleteDocuments() { function deleteDocuments() {
pandora.ui.deleteDocumentDialog($list.options('selected'), function() { pandora.ui.deleteDocumentDialog($list.options('selected'), function() {
Ox.Request.clearCache(); Ox.Request.clearCache();
@ -393,7 +403,7 @@ pandora.ui.documentsPanel = function(options) {
} }
function getOrderButtonTooltip() { function getOrderButtonTooltip() {
return Ox._(ui.documentsSort[0].operator == '+' ? 'ascending' : 'descending'); return Ox._(ui.documentsSort[0].operator == '+' ? 'Ascending' : 'Descending');
} }
function getPreviewSize() { function getPreviewSize() {
@ -412,6 +422,30 @@ pandora.ui.documentsPanel = function(options) {
}; };
} }
function openDocuments() {
if (!pandora.$ui.documentDialog) {
pandora.$ui.documentDialog = pandora.ui.documentDialog({
index: 0,
items: $list.options('selected').map(function(id) {
return $list.value(id);
})
})
.bindEvent({
close: function() {
$list.closePreview();
}
})
.open();
} else {
pandora.$ui.documentDialog.update({
index: 0,
items: $list.options('selected').map(function(id) {
return $list.value(id);
})
});
}
}
function removeDocuments() { function removeDocuments() {
pandora.api.removeDocument({ pandora.api.removeDocument({
item: ui.item, item: ui.item,
@ -520,7 +554,7 @@ pandora.ui.documentsPanel = function(options) {
function renderList() { function renderList() {
var options = { var options = {
items: pandora.api.findDocuments, items: pandora.api.findDocuments,
keys: ['dimensions', 'extension', 'name', 'ratio', 'size'], keys: ['dimensions', 'extension', 'id', 'name', 'ratio', 'size'],
query: {conditions: [], operator: '&'}, query: {conditions: [], operator: '&'},
selected: ui.documentsSelection[isItemView ? ui.item : ''], selected: ui.documentsSelection[isItemView ? ui.item : ''],
sort: ui.documentsSort.concat([ sort: ui.documentsSort.concat([
@ -554,14 +588,16 @@ pandora.ui.documentsPanel = function(options) {
}))) })))
.bindEvent({ .bindEvent({
add: uploadDocuments, add: uploadDocuments,
closepreview: closeDocuments,
'delete': deleteDocuments, 'delete': deleteDocuments,
init: function(data) { init: function(data) {
Ox.print('INIT', data)
$listStatus.html( $listStatus.html(
Ox.toTitleCase(Ox.formatCount(data.items, 'document')) Ox.toTitleCase(Ox.formatCount(data.items, 'document'))
+ ', ' + Ox.formatValue(data.size, 'B') + ', ' + Ox.formatValue(data.size, 'B')
); );
}, },
open: openDocuments,
openpreview: openDocuments,
select: function(data) { select: function(data) {
pandora.UI.set( pandora.UI.set(
'documentsSelection.' + (isItemView ? ui.item : ''), 'documentsSelection.' + (isItemView ? ui.item : ''),
@ -589,20 +625,15 @@ pandora.ui.documentsPanel = function(options) {
cursor: 'pointer' cursor: 'pointer'
}) })
.on({ .on({
click: function() { click: openDocuments
pandora.$ui.documentDialog = pandora.ui.documentDialog({ // FIXME
index: 0, /*
items: $list.options('selected').map(function(id) { var item = $list.value(selected);
return $list.value(id); window.open(
}) '/documents/' + selected + '/' + item.name + '.' + item.extension,
}).open(); '_blank'
return; );
var item = $list.value(selected); */
window.open(
'/documents/' + selected + '/' + item.name + '.' + item.extension,
'_blank'
);
}
}); });
} }