set UI on document pan/zoom

This commit is contained in:
rolux 2014-01-16 04:50:27 +00:00
parent f4074a15ea
commit 21c03ab85d

View file

@ -4,12 +4,17 @@
pandora.ui.documentDialog = function(options) { pandora.ui.documentDialog = function(options) {
Ox.print('OPTIONS', options)
var dialogHeight = Math.round((window.innerHeight - 48) * 0.9) + 24, var dialogHeight = Math.round((window.innerHeight - 48) * 0.9) + 24,
dialogWidth = Math.round(window.innerWidth * 0.9), dialogWidth = Math.round(window.innerWidth * 0.9),
items = options.items, items = options.items,
item = items[options.index], item = items[options.index],
settings = Ox.extend(item.extension == 'pdf' ? {
page: 1,
zoom: 'fit'
} : {
center: 'auto',
zoom: 'fit'
}, pandora.user.ui.document[item.id] || {}),
$content = Ox.Element(), $content = Ox.Element(),
@ -42,9 +47,9 @@ pandora.ui.documentDialog = function(options) {
pandora_document: function(data) { pandora_document: function(data) {
if (data.value) { if (data.value) {
if (Ox.getObjectById(items, data.value)) { if (Ox.getObjectById(items, data.value)) {
// ...
} else { } else {
// ...
} }
} else { } else {
that.close(); that.close();
@ -91,32 +96,42 @@ pandora.ui.documentDialog = function(options) {
item.extension == 'pdf' item.extension == 'pdf'
? Ox.PDFViewer({ ? Ox.PDFViewer({
height: dialogHeight, height: dialogHeight,
page: settings.page,
url: '/documents/' + item.id + '/' url: '/documents/' + item.id + '/'
+ item.name + '.' + item.extension, + item.name + '.' + item.extension,
width: dialogWidth width: dialogWidth,
zoom: settings.zoom
}) })
: Ox.ImageViewer({ : Ox.ImageViewer({
center: settings.center,
height: dialogHeight, height: dialogHeight,
imageHeight: item.dimensions[1], imageHeight: item.dimensions[1],
imagePreviewURL: '/documents/' + item.id + '/256p.jpg', imagePreviewURL: '/documents/' + item.id + '/256p.jpg',
imageURL: '/documents/' + item.id + '/' imageURL: '/documents/' + item.id + '/'
+ item.name + '.' + item.extension, + item.name + '.' + item.extension,
imageWidth: item.dimensions[0], imageWidth: item.dimensions[0],
width: dialogWidth width: dialogWidth,
zoom: settings.zoom
}) })
) )
.bindEvent({ .bindEvent({
center: function(data) { center: function(data) {
pandora.UI.set('document.' + item.id + '.center', data.center); pandora.UI.set('document.' + item.id, Ox.extend(settings, {
center: data.center
}));
}, },
key_escape: function() { key_escape: function() {
pandora.$ui.documentDialog.close(); pandora.$ui.documentDialog.close();
}, },
page: function(data) { page: function(data) {
pandora.UI.set('document.' + item.id + '.page', data.page); pandora.UI.set('document.' + item.id, Ox.extend(settings, {
page: data.page
}));
}, },
zoom: function(data) { zoom: function(data) {
pandora.UI.set('document.' + item.id + '.zoom', data.zoom); pandora.UI.set('document.' + item.id, Ox.extend(settings, {
zoom: data.zoom
}));
} }
}) })
); );