summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/js/htdocs/ui.js
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-03-21 07:42:09 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-03-21 07:42:09 +0000
commit96c58efd10432c163c51d72780cece7dce4b05a9 (patch)
tree49c4c70895fa5096ff8ff312b01a5887002cadcb /sca-cpp/trunk/modules/js/htdocs/ui.js
parenta7e5a4216489dda5466eb4b0b83911e36a8f5520 (diff)
Refactor and cleanup edit module, add text components, store page and app run page.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1083694 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/js/htdocs/ui.js')
-rw-r--r--sca-cpp/trunk/modules/js/htdocs/ui.js57
1 files changed, 53 insertions, 4 deletions
diff --git a/sca-cpp/trunk/modules/js/htdocs/ui.js b/sca-cpp/trunk/modules/js/htdocs/ui.js
index b2527dc66b..db8c439de4 100644
--- a/sca-cpp/trunk/modules/js/htdocs/ui.js
+++ b/sca-cpp/trunk/modules/js/htdocs/ui.js
@@ -233,19 +233,28 @@ ui.queryParams = function() {
/**
* Bind a widget iframe to an element.
*/
-ui.widgets = new Array();
+ui.widgets = {};
+ui.onload = {};
-ui.loadwidget = function(el, doc) {
+ui.loadwidget = function(el, doc, cb) {
var f = el + 'Frame';
+ window.ui.widgets[f] = el;
+ window.ui.onload[f] = cb;
var div = document.createElement('div');
div.id = f + 'Div';
- div.innerHTML = '<iframe id="' + f + '" class="widgetframe" scrolling="no" frameborder="0" src="' + doc + '"></iframe>';
+ div.innerHTML = '<iframe id="' + f + '" class="widgetframe" scrolling="no" frameborder="0" src="' + doc + '" onload="window.ui.onload[this.id]()"></iframe>';
document.body.appendChild(div);
- window.ui.widgets[f] = el;
return f;
};
/**
+ * Show the current document body.
+ */
+ui.showbody = function() {
+ document.body.style.visibility = 'visible';
+};
+
+/**
* Install a widget into the element bound to its iframe.
*/
ui.installwidget = function() {
@@ -282,3 +291,43 @@ ui.csspos = function(p) {
return Number(p.substr(0, p.length - 2));
};
+/**
+ * Convert a list of elements to an HTML table.
+ */
+ui.datatable = function(l) {
+ log('datatable', writeValue(l));
+
+ function indent(i) {
+ if (i == 0)
+ return '';
+ return '&nbsp;&nbsp;' + indent(i - 1);
+ }
+
+ function rows(l, i) {
+ if (isNil(l))
+ return '';
+ var e = car(l);
+
+ if (!isList(e))
+ return rows(expandElementValues("'value", l), i);
+
+ if (elementHasValue(e)) {
+ var v = elementValue(e);
+ if (!isList(v)) {
+ return '<tr><td class="datatdl">' + indent(i) + elementName(e).slice(1) + '</td>' +
+ '<td class="datatdr">' + v + '</td></tr>' +
+ rows(cdr(l), i);
+ }
+
+ return rows(expandElementValues(elementName(e), v), i) + rows(cdr(l), i);
+ }
+
+ return '<tr><td class="datatdl">' + indent(i) + elementName(e).slice(1) + '</td>' +
+ '<td class="datatdr">' + '</td></tr>' +
+ rows(elementChildren(e), i + 1) +
+ rows(cdr(l), i);
+ }
+
+ return '<table class="datatable ' + (window.name == 'dataFrame'? ' databg' : '') + '" style="width: 100%;">' + rows(l, 0) + '</table>';
+}
+