forked from 0x2620/pandora
add entitiesDialog.js and entity.js
This commit is contained in:
parent
2627bff48f
commit
b2bd5646c4
2 changed files with 138 additions and 0 deletions
111
static/js/entitiesDialog.js
Normal file
111
static/js/entitiesDialog.js
Normal file
|
@ -0,0 +1,111 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
|
||||
'use strict';
|
||||
|
||||
pandora.ui.entitiesDialog = function(options) {
|
||||
|
||||
var dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
|
||||
dialogWidth = Math.round(window.innerWidth * 0.9),
|
||||
|
||||
that = Ox.Dialog({
|
||||
buttons: [
|
||||
Ox.Button({
|
||||
title: Ox._('Manage Documents...')
|
||||
})
|
||||
.bindEvent({
|
||||
click: function() {
|
||||
that.close();
|
||||
(pandora.$ui.documentsDialog || (
|
||||
pandora.$ui.documentsDialog = pandora.ui.documentsDialog()
|
||||
)).open();
|
||||
}
|
||||
}),
|
||||
{},
|
||||
Ox.Button({
|
||||
title: Ox._('Done'),
|
||||
width: 48
|
||||
})
|
||||
.bindEvent({
|
||||
click: function() {
|
||||
that.close();
|
||||
}
|
||||
})
|
||||
],
|
||||
closeButton: true
|
||||
content: Ox.LoadingScreen().start(),
|
||||
height: dialogHeight,
|
||||
maximizeButton: true,
|
||||
minHeight: 256,
|
||||
minWidth: 512,
|
||||
padding: 0,
|
||||
removeOnClose: true,
|
||||
title: Ox._('Manage Entities'),
|
||||
width: dialogWidth
|
||||
})
|
||||
.bindEvent({
|
||||
// resize: ...
|
||||
}),
|
||||
|
||||
$toolbar = Ox.Bar({size: 24}),
|
||||
|
||||
$findbar = Ox.Bar({size: 24}),
|
||||
|
||||
$statusbar = Ox.Bar({size: 16}),
|
||||
|
||||
$listPanel = Ox.SplitPanel({
|
||||
elements: [
|
||||
{element: $findbar, size: 24},
|
||||
{element: Ox.Element},
|
||||
{element: $statusbar, size: 16}
|
||||
],
|
||||
orientation: 'vertical'
|
||||
}),
|
||||
|
||||
$leftPanel = Ox.SplitPanel({
|
||||
elements: [
|
||||
{element: $toolbar, size: 24},
|
||||
{element: $listPanel}
|
||||
],
|
||||
orientation: 'vertical'
|
||||
}),
|
||||
|
||||
$entity = Ox.Element(),
|
||||
|
||||
$titlebar = Ox.Bar({size: 24}),
|
||||
|
||||
$rightPanel = Ox.SplitPanel({
|
||||
elements: [
|
||||
{element: $titlebar, size: 24},
|
||||
{element: $form}
|
||||
],
|
||||
orientation: 'vertical'
|
||||
}),
|
||||
|
||||
$content = Ox.SplitPanel({
|
||||
elements: [
|
||||
{
|
||||
element: $leftPanel,
|
||||
resizable: true,
|
||||
resize: [256, 384, 512],
|
||||
size: 256
|
||||
},
|
||||
{
|
||||
element: $entity
|
||||
},
|
||||
{
|
||||
element: $rightPanel,
|
||||
resizable: true,
|
||||
resize: [256, 384, 512],
|
||||
size: 256
|
||||
}
|
||||
],
|
||||
orientation: 'horizontal'
|
||||
});
|
||||
|
||||
Ox.noop(function() {
|
||||
that.options({content: $content});
|
||||
});
|
||||
|
||||
return that;
|
||||
|
||||
};
|
27
static/js/entity.js
Normal file
27
static/js/entity.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
|
||||
'use strict';
|
||||
|
||||
pandora.ui.entity = function(options, callback) {
|
||||
// options: {id, type, view}
|
||||
Ox.get(
|
||||
'/static/html/entities.' + options.type + '.' + options.view + '.html',
|
||||
function(html) {
|
||||
pandora.api.getEntity({
|
||||
id: options.id
|
||||
}, function(data) {
|
||||
html = html.replace(/\{(.+?)\}/g, function() {
|
||||
var parts = arguments[1].split('|'),
|
||||
value = data[parts[0]];
|
||||
return Ox.isEmpty(value)
|
||||
|| Ox.isNull(value)
|
||||
|| Ox.isUndefined(value)
|
||||
? Ox._(parts[1] || 'unknown')
|
||||
: Ox.isArray(value) ? value.join('; ')
|
||||
: value;
|
||||
});
|
||||
callback(html);
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
Loading…
Reference in a new issue