From b2bd5646c45b9e84b4b65f1ccfa33896396129a2 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 19 Nov 2014 16:04:45 +0000 Subject: [PATCH] add entitiesDialog.js and entity.js --- static/js/entitiesDialog.js | 111 ++++++++++++++++++++++++++++++++++++ static/js/entity.js | 27 +++++++++ 2 files changed, 138 insertions(+) create mode 100644 static/js/entitiesDialog.js create mode 100644 static/js/entity.js diff --git a/static/js/entitiesDialog.js b/static/js/entitiesDialog.js new file mode 100644 index 000000000..a05e0c296 --- /dev/null +++ b/static/js/entitiesDialog.js @@ -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; + +}; \ No newline at end of file diff --git a/static/js/entity.js b/static/js/entity.js new file mode 100644 index 000000000..285120e94 --- /dev/null +++ b/static/js/entity.js @@ -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); + }); + } + ); +}; \ No newline at end of file