pandora/static/js/documentsDialog.js

83 lines
2.6 KiB
JavaScript
Raw Normal View History

2013-03-24 09:43:24 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.ui.documentsDialog = function() {
2014-01-05 12:40:54 +00:00
2013-03-24 09:43:24 +00:00
var dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
dialogWidth = Math.round(window.innerWidth * 0.9),
// FIXME: user may not have the manage entites capability
$switchButton = Ox.Button({
2015-04-20 08:13:56 +00:00
disabled: !pandora.site.entities.length
2017-11-04 09:53:27 +00:00
|| !pandora.hasCapability('canManageEntities'),
title: Ox._('Manage Entities...')
})
.bindEvent({
click: function() {
that.close();
(pandora.$ui.entitiesDialog || (
pandora.$ui.entitiesDialog = pandora.ui.entitiesDialog()
)).open();
}
}),
$doneButton = Ox.Button({
id: 'done',
title: Ox._('Done'),
width: 48
}).bindEvent({
click: function() {
that.close();
}
}),
2013-03-24 09:43:24 +00:00
2014-01-09 08:06:01 +00:00
// reference in pandora.$ui needed to receive pandora_ events
$content = pandora.$ui.documentsDialogPanel = pandora.ui.documentsPanel({
isItemView: false
2013-03-24 09:43:24 +00:00
}),
that = Ox.Dialog({
buttons: [$switchButton, {}, $doneButton],
2013-03-24 09:43:24 +00:00
closeButton: true,
content: $content,
height: dialogHeight,
maximizeButton: true,
minHeight: 256,
minWidth: 512,
padding: 0,
removeOnClose: true,
title: Ox._('Manage Documents'),
2013-03-24 09:43:24 +00:00
width: dialogWidth
})
.bindEvent({
resize: $content.updateSize
2014-01-09 08:06:01 +00:00
});
2013-03-24 09:43:24 +00:00
2014-12-22 22:21:42 +00:00
that.superClose = that.close;
that.close = function() {
Ox.Request.clearCache('findDocuments');
that.superClose();
// needed in documentDialog to determine if isItemView
delete pandora.$ui.documentsDialog;
};
function addDocuments() {
pandora.api.addDocument({
item: pandora.user.ui.item,
2014-01-09 08:06:01 +00:00
ids: pandora.user.ui.documentsSelection['']
}, function() {
Ox.Request.clearCache();
if (pandora.user.ui.itemView == 'documents') {
//fixme just upload list here
//self.$documentsList.reloadList();
pandora.$ui.contentPanel.replaceElement(1,
pandora.$ui.item = pandora.ui.item());
}
});
}
2013-03-24 09:43:24 +00:00
return that;
};