tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1098489 [2/3] - in /tuscany/sca-cpp/trunk: ./ modules/edit/ modules/edit/htdocs/ modules/edit/htdocs/app/ modules/edit/htdocs/clone/ modules/edit/htdocs/create/ modules/edit/htdocs/dash/ modules/edit/htdocs/data/ modules/edit/htdocs/graph/...
Date Mon, 02 May 2011 05:58:27 GMT
Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/graph/index.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/graph/index.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/graph/index.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -18,25 +19,50 @@
 -->
 <html>
 <head>
-<title>App</title>
+<title></title>
 <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> 
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
 <link rel="apple-touch-icon" href="/public/touchicon.png"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
 <script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript" src="/ui.js"></script>
+<script type="text/javascript" src="/all-min.js"></script>
+<script type="text/javascript" src="/menu.js"></script>
+<script type="text/javascript" src="graph.js"></script>
 </head>
-<body class="delayed">
+<body class="delayed" onorientationchange="ui.reload();">
+<div id="bodydiv" class="devicewidth">
+
 <div id="menu"></div>
 
-<h1><span id="h1"></span><span id="appNameHeader"></span></h1>
-<br/>
+<table style="width: 100%;">
+<tr>
+<td><h1><span id="h1"></span><span id="appNameHeader"></span></h1></td>
+<td style="vertical-align: middle; text-align: right;"><span id="saveStatus" style="font-weight: bold; color: #808080;">Saved</span></td>
+</tr>
+</table>
+
+<table style="width: 100%;">
+<tr>
+<th class="thr thl" style="padding-left: 2px; padding-right: 2px;">
+<input id="compValue" type="text" value="" title="Component value" placeholder="Name" style="position: relative; width: 170px;"/>
+<span id="deleteComponentButton" title="Delete a component" class="redbutton" style="font-weight: bold; font-size: 16px; color: #808080; display: inline-block; width: 24px; height: 20px; padding-top: 0px; padding-bottom: 0px; vertical-align: middle; text-align: center; margin-left: 0px; margin-right: 0px;">-</span>
+<span id="addComponentButton" title="Add a component" class="greenbutton" style="font-weight: bold; font-size: 16px; display: inline-block; width: 24px; height: 20px; padding-top: 0px; padding-bottom: 0px; vertical-align: middle; text-align: center; margin-left: 0px; margin-right: 0px;">+</span>
+<span id="playComponentButton" title="View component value" class="bluebutton" style="font-weight: bold; font-size: 16px; color: #808080; display: inline-block; width: 24px; height: 20px; padding-top: 0px; padding-bottom: 0px; vertical-align: middle; text-align: center; margin-left: 0px; margin-right: 0px;">&gt;</span>
+</th>
+</tr>
+</table>
+
+<div id="dataDiv" style="position:absolute; top: 95px; left: 0px; right: 0px; height: 5000px; visibility: hidden">
+</div>
 
-<div id="graph"></div>
+</div>
 
 <script type="text/javascript">
+// Get the app name
+var appname = ui.queryParams()['app'];
+if (isNil(appname))
+    window.open('/', '_self');
 
 /**
  * Return the link to an app.
@@ -51,31 +77,275 @@ function applink(appname) {
     return link;
 }
 
-// Get the app name
-var appname = ui.queryParams()['app'];
-
-// Update the window title
+// Set page titles
 document.title = windowtitle(window.location.hostname) + ' - ' + (isNil(config.compose)? 'Composition' : config.compose) + ' - ' + appname;
 $('h1').innerHTML = hometitle(window.location.hostname);
 $('appNameHeader').innerHTML = ' - <a href=\"' + applink(appname) + '\" target=\"' + '_blank' + '\">' + appname + '</a>';
 
 // Load the menu bar
-ui.loadwidget('menu', '/menu.html?app=' + appname, ui.showbody);
+displaymenu();
+
+// Show the page
+ui.showbody();
+
+// Init componnent references
+var editWidget = sca.component("EditWidget");
+var palettes = sca.reference(editWidget, "palettes");
+var composites = sca.reference(editWidget, "composites");
+
+// Setup remote log
+//rconsole = sca.defun(sca.reference(editWidget, "log"), "log");
+
+/**
+ * The current app composite, corresponding saved XML content and component name.
+ */
+var savedcomposxml = '';
+var composite;
+var compname = '';
+
+/**
+ * Track the composition graph and whether it's visible or not.
+ */
+var g;
+var gdiv;
+var bg;
+var gvisible = true;
+
+// Track the palettes
+var gpalettes = new Array();
+var spalette = 'control';
+
+/**
+ * Return the composite in an ATOM entry.
+ */
+function atomcomposite(doc) {
+    var entry = atom.readATOMEntry(mklist(doc));
+    if (isNil(entry))
+        return mklist();
+    var content = namedElementChild("'content", car(entry));
+    if (content == null)
+        return mklist();
+    return elementChildren(content);
+}
+
+/**
+ * Get and display an app.
+ */
+function getapp(name, g) {
+    if (isNil(name))
+        return false;
+    return composites.get(name, function(doc) {
+        composite = atomcomposite(doc);
+        if (isNil(composite)) {
+
+            // Create a default empty composite if necessary
+            var x = '<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"' +
+                'targetNamespace="http://app" name="app"></composite>';
+            composite = readXML(mklist(x));
+        }
+        graph.edit(name, composite, graph.composite(composite, graph.mkpath().move(palcx,0)), oncomposchange, oncompselect, g);
+
+        // Track the saved composite XML
+        savedcomposxml = car(writeXML(composite, false));
+        return true;
+    });
+}
 
 /**
- * Display the editor for an app.
+ * Display a palette. Get it from the server if needed.
  */
-function editapp(name) {
+function displaypalette(name, g, palette, gpalettes) {
     if (isNil(name))
         return;
-    $('graph').innerHTML =
-        '<iframe id="graphFrame" style="height: 5000px; width: 100%; border: 0px;" scrolling="no" frameborder="0" src="graph.html?' +
-        'app=' + name +
-        '"></iframe>';
+    if (isNil(gpalettes[name])) {
+
+        // Get the palette from the server
+        var doc = palettes.get(name);
+        gpalettes[name] = graph.composite(atomcomposite(doc), graph.mkpath().move(80,0));
+    }
+    graph.display(gpalettes[name], g);
+    return true;
+}
+
+/**
+ * Install a palette, including a button to select the palette, and
+ * the palette content.
+ */
+function installpalette(name, pos, g, bg, palette, gpalettes) {
+    var b = graph.mkbutton(name, pos);
+    graph.display(mklist(b), g);
+    b.onclick = function(e) {
+
+        // Swap the selected palette
+        displaypalette(spalette, bg, palette, gpalettes);
+        spalette = name;
+        return displaypalette(spalette, g, palette, gpalettes);
+    };
+
+    if (name != spalette) {
+
+        // Will get the palette from the server later if needed
+        gpalettes[name] = null;
+        return true;
+    }
+
+    // Display the selected palette
+    return displaypalette(name, g, palette, gpalettes);
+}
+
+/**
+ * Save the current composite.
+ */
+function save(savexml) {
+    $('saveStatus').innerHTML = 'Saving';
+    savedcomposxml = savexml;
+    var entry = '<entry xmlns="http://www.w3.org/2005/Atom">' +
+        '<title type="text">' + appname + '</title><id>' + appname + '</id><content type="application/xml">' +
+        savedcomposxml + '</content></entry>';
+    composites.put(appname, entry);
+    $('saveStatus').innerHTML = 'Saved';
+    return true;
+}
+
+/**
+ * Handle a composite change event.
+ */
+function oncomposchange(prop) {
+    var newxml = car(writeXML(composite, false));
+    if (savedcomposxml == newxml)
+        return false;
+    $('saveStatus').innerHTML = 'Modified';
+
+    // Save property changes right away
+    if (prop)
+        return save(newxml);
+
+    // Autosave other changes after 3 seconds
+    $('saveStatus').innerHTML = 'Modified';
+    setTimeout(function() {
+        var savexml = car(writeXML(composite, false));
+        if (savedcomposxml == savexml) {
+            $('saveStatus').innerHTML = 'Saved';
+            return false;
+        }
+        return save(savexml);
+    }, 1000);
+    return true;
+}
+
+/**
+ * Return the link to a component value.
+ */
+function compvaluelink(appname, cname) {
+    if (cname == '' || isNil(cname))
+        return '';
+    var protocol = window.location.protocol;
+    var host = window.location.hostname;
+    var port = ':' + window.location.port;
+    if (port == ':80' || port == ':443' || port == ':')
+        port = '';
+    var link = protocol + '//' + appname + '.' + host + port + '/data/?component=' + cname;
+    return link;
+}
+
+/**
+ * Return the link to a component raw data.
+ */
+function compdebuglink(appname, cname) {
+    if (cname == '' || isNil(cname))
+        return '';
+    var protocol = window.location.protocol;
+    var host = window.location.hostname;
+    var port = ':' + window.location.port;
+    if (port == ':80' || port == ':443' || port == ':')
+        port = '';
+    var link = protocol + '//' + appname + '.' + host + port + '/components/' + cname;
+    return link;
+}
+
+/**
+ * Handle a component select event.
+ */
+function oncompselect(cname) {
+    if (cname == compname)
+        return true;
+    compname = cname;
+    var link = compvaluelink(appname, cname);
+
+    function updateButton(b, v) {
+        b.style.color = v? '#000000' : '#808080';
+    }
+
+    updateButton($('deleteComponentButton'), link != '');
+    updateButton($('playComponentButton'), link != '');
+    return true;
+}
+
+/**
+ * Show the result data of a component.
+ */
+function showdata(cname) {
+    if (!gvisible)
+        return true;
+    gvisible = false;
+    $('playComponentButton').innerHTML = '&lt;';
+    gdiv.style.visibility = 'hidden'
+    var rdiv = $('dataDiv');
+    rdiv.style.visibility = 'visible';
+    rdiv.innerHTML = '<iframe id="dataFrame" style="position: relative; height: 5000px; width: 100%; border: 0px;" scrolling="no" frameborder="0" src="' +
+                        compvaluelink(appname, cname) + '"></iframe>';
+    return true;
 }
 
-// Display the editor for the current app
-editapp(appname);
+/**
+ * Show the composition graph.
+ */
+function showgraph() {
+    if (gvisible)
+        return true;
+    gvisible = true;
+    $('playComponentButton').innerHTML = '&gt;';
+    var rdiv = $('dataDiv');
+    rdiv.style.visibility = 'hidden';
+    rdiv.innerHTML = '';
+    gdiv.style.visibility = 'visible'
+    return true;
+}
+
+/**
+ * Play the current component.
+ */
+$('playComponentButton').onclick = function() {
+    if (compname == '')
+        return false;
+    if (!gvisible)
+        return showgraph();
+    return showdata(compname);
+}
+
+// Create editor graph area
+g = graph.mkgraph(graph.mkpath().move(-2500,95), $('compValue'), $('addComponentButton'), $('deleteComponentButton'));
+gdiv = g.parentNode;
+bg = graph.mkgroup(graph.mkpath());
+
+// Install the palettes
+var pos = graph.mkpath();
+installpalette('control', pos.rmove(5,0), g, bg, spalette, gpalettes);
+installpalette('values', pos.rmove(0,35), g, bg, spalette, gpalettes);
+installpalette('lists', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('transform', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('text', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('http', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('talk', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('social', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('search', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('database', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('logic', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('math', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+installpalette('python', pos.rmove(0, 35), g, bg, spalette, gpalettes);
+
+// Get and display the current app
+getapp(appname, g);
 
 </script>
 

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/index.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/index.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -16,41 +17,62 @@
  * specific language governing permissions and limitations
  * under the License.    
 -->
-<html manifest="cache-manifest.cmf">
+<html manifest="/cache-manifest.cmf">
 <head>
 <title>Home</title>
 <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> 
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
 <link rel="apple-touch-icon" href="/public/touchicon.png"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
 <script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript">
-document.title = windowtitle(window.location.hostname);
-</script>
-<script type="text/javascript" src="/ui.js"></script>
+<script type="text/javascript" src="/all-min.js"></script>
+<script type="text/javascript" src="/menu.js"></script>
 </head>
-<body class="delayed">
+<body class="delayed" onorientationchange="ui.reload();">
+<div id="bodydiv" class="devicewidth">
+
 <div id="menu"></div>
 
-<h1 id="h1"></h1>
+<table style="width: 100%;">
+<tr><td><h1><span id="h1"></span></h1></td></tr>
+</table>
 <br/>
 
-<div id="main"></div>
+<div style="margin-left: auto; margin-right: auto; text-align: center;">
 
-<script type="text/javascript">
+<h1><span id="maintitle"><span></h1>
+<br/><br/><br/><br/>
+
+<div id="maindiagram"></div>
+<br/><br/><br/><br/>
+
+<input type="button" class="greenbutton" style="font-size: 150%; font-weight: bold; font-style: italic; padding: 10px;" id="getstarted" title="Get Started" value="Get Started"/>
 
+<br/><br/><br/>
+<div>Safari, Chrome, Firefox only for now.</div>
+
+</div>
+
+</div>
+
+<script type="text/javascript">
+// Set page titles
+document.title = windowtitle(window.location.hostname);
 $('h1').innerHTML = hometitle(window.location.hostname);
 
-// Load the menu bar
-ui.loadwidget('menu', '/menu.html', ui.showbody);
+// Display the menu bar
+displaymenu();
 
-// Load the main page
-ui.loadiframe('main', 'main.html');
+$('maintitle').innerHTML = isNil(config.maintitle)? 'Simple App Builder' : config.maintitle;
+$('maindiagram').innerHTML = isNil(config.maindiagram)? '&lt;&lt insert diagram here &gt;&gt;' : config.maindiagram;
+$('getstarted').onclick = function() {
+    return window.open('/store/', '_self');
+};
 
+// Show the page
+ui.showbody();
 </script>
 
 </body>
 </html>
-

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/login/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/login/index.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/login/index.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/login/index.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -23,20 +24,19 @@
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
 <link rel="apple-touch-icon" href="/public/touchicon.png"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
-<script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript" src="/ui.js"></script>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
+<script type="text/javascript" src="/all-min.js"></script>
 </head>
-<body>
+<body onorientationchange="ui.reload();">
 <h1>Sign in</h1>
-<br/>
 
-<form name="formSignin" method="POST" action="/login/dologin/">
+<form name="formSignin" onsubmit="submitSignin();" method="POST" action="/login/dologin/">
 <table border="0">
-<tr><td>Username:</td><td><input type="text" id="httpd_username" name="httpd_username" value=""/></td></tr>
-<tr><td>Password:</td><td><input type="password" name="httpd_password" value=""/></td></tr>
-<tr><td><input type="submit" onclick="submitFormSignin()" value="Sign in"/></td><td></td></tr>
+<tr><td><b>Username:</b></td></tr>
+<tr><td><input type="text" id="httpd_username" name="httpd_username" value="" size="15" placeholder="Enter your user name" style="width: 300px;"/></td></tr>
+<tr><td><b>Password:</b></td></tr>
+<tr><td><input type="password" name="httpd_password" value="" size="15" placeholder="Enter your password" style="width: 300px;"/></td></tr>
+<tr><td><input type="submit" value="Sign in" class="greenbutton" style="font-weight: bold;"/></td><td></td></tr>
 </table>
 <input type="hidden" name="httpd_location" value="/"/>
 </form>
@@ -66,14 +66,13 @@ function oauthReferrer() {
     return r;
 }
 
-function submitFormSignin() {
+function submitSignin() {
     var reset = 'TuscanyOpenAuth=;expires=' + new Date(1970,01,01).toGMTString() + ';domain=.' + domainname(window.location.hostname) + ';path=/;secure=TRUE';
     document.cookie = reset;
     document.formSignin.httpd_location.value = oauthReferrer();
     document.formSignin.submit();
 }
 
-$('httpd_username').focus();
 </script>
 
 </body>

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/logout/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/logout/index.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/logout/index.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/logout/index.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -23,17 +24,14 @@
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
 <link rel="apple-touch-icon" href="/public/touchicon.png"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
-<script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript" src="/ui.js"></script>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
+<script type="text/javascript" src="/all-min.js"></script>
 </head>
-<body>
+<body onorientationchange="ui.reload();">
 <h1>Sign out</h1>
-<br/>
 
-<form name="signout" action="/" method="GET">
-<input type="submit" onclick="submitSignout()" id="signOut" value="Sign out"/>
+<form name="signout" onsubmit="submitSignout();" action="/" method="GET">
+<input type="submit" id="signOut" value="Sign out" class="greenbutton" style="font-weight: bold"/>
 </form>
 
 <script type="text/javascript">
@@ -44,7 +42,6 @@ function submitSignout() {
     return true;
 }
 
-$('signOut').focus();
 </script>
 
 </body>

Added: tuscany/sca-cpp/trunk/modules/edit/htdocs/menu.js
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/menu.js?rev=1098489&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/menu.js (added)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/menu.js Mon May  2 05:58:26 2011
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+var menuWidget = sca.component("MenuWidget");
+var userService = sca.defun(sca.reference(menuWidget, "user"), "id");
+
+/**
+ * Display the current signed in user.
+ */
+function userMenu() {
+    function UserMenu() {
+        this.content = function() {
+            u = userService.id()
+            return '<span>' + u + '</span>';
+        };
+    }
+    return new UserMenu();
+}
+
+/**
+ * Display the menu bar.
+ */
+function displaymenu() {
+    var mdiv = $('menu'); 
+    var name = ui.queryParams()['app'];
+
+    mdiv.innerHTML = ui.menubar(
+        append(mklist(ui.menu('Home', '/'), ui.menu('Store', '/store/')),
+                (isNil(name) || name == 'undefined')?
+                    mklist() :
+                    mklist(ui.menu('Page', '/page/?app=' + name),
+                    ui.menu(isNil(config.compose)? 'Composition' : config.compose, '/graph/?app=' + name),
+                    ui.menu('Stats', '/stats/?app=' + name))),
+        mklist(ui.menu('Account', '/public/notyet.html'), ui.menu('Sign out', '/logout/')));
+}
+

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/page/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/page/index.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/page/index.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/page/index.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -23,21 +24,78 @@
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
 <link rel="apple-touch-icon" href="/public/touchicon.png"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
 <script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript" src="/ui.js"></script>
+<script type="text/javascript" src="/all-min.js"></script>
+<script type="text/javascript" src="/menu.js"></script>
+<script type="text/javascript" src="page.js"></script>
 </head>
-<body class="delayed">
+<body class="delayed" onorientationchange="ui.reload();">
+<div id="bodydiv" class="devicewidth">
+
 <div id="menu"></div>
 
-<h1><span id="h1"></span><span id="appNameHeader"></span></h1>
-<br/>
+<table style="width: 100%;">
+<tr>
+<td><h1><span id="h1"></span><span id="appNameHeader"></span></h1></td>
+<td style="vertical-align: middle; text-align: right;"><span id="saveStatus" style="font-weight: bold; color: #808080;">Saved</span></td>
+</tr>
+</table>
+
+<table style="width: 100%;">
+<tr>
+<th class="thr thl" style="padding-left: 2px; padding-right: 2px;">
+<input id="widgetName" type="text" value="" title="Widget name" placeholder="Name" style="position: relative; width: 65px;"/>
+<input id="widgetText" type="text" value="" title="Widget text" placeholder="Text" style="position: relative; width: 120px;"/>
+<span id="deleteWidgetButton" title="Delete a Widget" class="redbutton" style="font-weight: bold; font-size: 16px; color: #808080; display: inline-block; width: 24px; height: 20px; padding-top: 0px; padding-bottom: 0px; vertical-align: middle; text-align: center; margin-left: 0px; margin-right: 0px;">-</span>
+<span id="addWidgetButton" title="Add a Widget" class="greenbutton" style="font-weight: bold; font-size: 16px; display: inline-block; width: 24px; height: 20px; padding-top: 0px; padding-bottom: 0px; vertical-align: middle; text-align: center; margin-left: 0px; margin-right: 0px;">+</span>
+<!--
+<span id="playWidgetButton" title="View" class="bluebutton" style="font-weight: bold; font-size: 16px; color: #808080; display: inline-block; width: 24px; height: 20px; padding-top: 0px; padding-bottom: 0px; vertical-align: middle; text-align: center; margin-left: 0px; margin-right: 0px;">&gt;</span>
+-->
+</th>
+</tr>
+</table>
+
+<div id="page" style="position: absolute; top: 95px; left: -2500px; right: 0px; height: 5000px;">
+
+<div style="position: absolute; left: 2500px; top: 0px; right: 0px; height: 5000px; border:1px; border-style: solid; border-color: #a2bae7; background: url(/public/grid72.png);"></div>
+<div class="guide" style="position: absolute; left: 2500px; top: 0px; width: 320px; height: 460px;"></div>
+<div class="guide" style="position: absolute; left: 2500px; top: 0px; width: 480px; height: 300px;"></div>
+<div class="guide" style="position: absolute; left: 2500px; top: 0px; width: 768px; height: 911px;"></div>
+<div class="guide" style="position: absolute; left: 2500px; top: 0px; width: 1024px; height: 655px;"></div>
+
+<span class="h1" id="palette:h1" style="position: absolute; left: 0px; top: 0px;"><h1>Header1</h1></span>
+<span class="h2" id="palette:h2" style="position: absolute; left: 0px; top: 30px;"><h2>Header2</h2></span>
+<span class="section" id="palette:section" style="position: absolute; left: 0px; top: 60px; width: 200px;"><span class="section">section</span></span>
+<span class="button" id="palette:button" style="position: absolute; left: 0px; top: 90px;"><input type="button" value="button" class="graybutton"/></span>
+<span class="entry" id="palette:entry" style="position: absolute; left: 0px; top: 120px;"><input type="text" value="field" size="20" autocapitalize="off"/></span>
+<span class="password" id="palette:password" style="position: absolute; left: 0px; top: 150px;"><input type="password" value="password" size="20"/></span>
+<span class="checkbox" id="palette:checkbox" style="position: absolute; left: 0px; top: 180px;"><input type="checkbox" value="checkbox"/><span>checkbox</span></span>
+<span class="select" id="palette:select" style="position: absolute; left: 0px; top: 210px;"><select><option value="select">select</option></select></span>
+<span class="list" id="palette:list" style="position: absolute; left: 0px; top: 240px; width: 200px;">
+<table class="datatable" style="width: 200px;"><tr><td class="datatd">list</td></tr><tr><td class="datatd">...</td></tr></table>
+</span>
+<span class="table" id="palette:table" style="position: absolute; left: 0px; top: 290px; width: 200px;">
+<table class="datatable" style="width: 200px;"><tr><td class="datatdl">table</td><td class="datatdr">...</td></tr><tr><td class="datatdl">...</td><td class="datatdr">...</td></tr></table>
+</span>
+<span class="link" id="palette:link" style="position: absolute; left: 0px; top: 340px;"><a href="/"><span>link</span></a></span>
+<span class="text" id="palette:text" style="position: absolute; left: 0px; top: 370px;"><span>text</span></span>
+<span class="iframe fakeframe" id="palette:iframe" style="position: absolute; left: 0px; top: 400px; width: 200px;"><a href="/public/iframe.html"><span class="fakeframe"><span>frame ...</span></span></a></span>
+<span class="img" id="palette:img" style="position: absolute; left: 0px; top: 430px;"><img src="/public/img.png"/></span>
+
+</div>
 
-<div id="page"></div>
+<div id="buffer" style="visibility: hidden; position: absolute; top: 0px; left: 0px; width: 0px; height: 0px"></div>
+
+</div>
 
 <script type="text/javascript">
 
+// Get the app name
+var appname = ui.queryParams()['app'];
+if (isNil(appname))
+    window.open('/', '_self');
+
 /**
  * Return the link to an app.
  */
@@ -51,30 +109,229 @@ function applink(appname) {
     return link;
 }
 
-// Get the app name
-var appname = ui.queryParams()['app'];
-
-// Update the window title
+// Set page titles
 document.title = windowtitle(window.location.hostname) + ' - Page - ' + appname;
 $('h1').innerHTML = hometitle(window.location.hostname);
 $('appNameHeader').innerHTML = ' - <a href=\"' + applink(appname) + '\" target=\"' + '_blank' + '\">' + appname + '</a>';
 
 // Load the menu bar
-ui.loadwidget('menu', '/menu.html?app=' + appname, ui.showbody);
+displaymenu();
+
+// Show the page
+ui.showbody();
+
+// Init component references
+var editWidget = sca.component("EditWidget");
+var pages = sca.reference(editWidget, "pages");
+
+/**
+ * Return the page in an ATOM entry.
+ */
+function atompage(doc) {
+    var entry = atom.readATOMEntry(mklist(doc));
+    if (isNil(entry))
+        return mklist();
+    var content = namedElementChild("'content", car(entry));
+    if (content == null)
+        return mklist();
+    return elementChildren(content);
+}
+
+/**
+ * Track the current widget and page saved XHTML content.
+ */
+var widgetname = '';
+var savedpagexhtml = '';
 
 /**
- * Display the page editor for an app.
+ * Get and display an app page.
  */
-function editapp(name) {
+function getpage(name, edit) {
     if (isNil(name))
+        return false;
+    return pages.get(name, function(doc) {
+
+        // Convert the page to XHTML and place it in a hidden buffer
+        var buffer = $('buffer');
+        var el = atompage(doc);
+
+        // Create a default empty page if necessary
+        if (isNil(el))
+            buffer.innerHTML = '<DIV id="page">\n</DIV>\n';
+        else
+            buffer.innerHTML = writeStrings(writeXML(atompage(doc), false));
+
+        // Append page nodes to editor
+        map(function(e) {
+                edit.appendChild(e);
+                if (!isNil(e.style))
+                    e.style.left = ui.pixpos(ui.numpos(e.style.left) + 2500);
+                return page.cover(e);
+            }, nodeList(buffer.childNodes[0].childNodes));
+
+        savedpagexhtml = pagexhtml();
+        return true;
+    });
+}
+
+/**
+ * Handle add widget button click event.
+ */
+$('addWidgetButton').onclick = function(e) {
+    // Show the widget palette
+    $('page').style.left = ui.pixpos(0);
+};
+
+/**
+ * Return the current page XHTML content.
+ */
+function pagexhtml() {
+
+    // Copy page DOM to hidden buffer
+    var edit = $('page');
+    var buffer = $('buffer');
+    buffer.innerHTML = '<DIV id="page">\n</DIV>\n'
+    var div = buffer.childNodes[0];
+    div.innerHTML = edit.innerHTML;
+
+    // Filter out palette and editor artifacts, which are not
+    // part of the page, as well as nodes positioned out the
+    // editing area
+    var fnodes = filter(function(e) {
+        if (isNil(e.id) || e.id == '' || e.id.substr(0, 8) == 'palette:')
+            return false;
+        var x = ui.numpos(e.style.left) - 2500;
+        if (x < 0 || ui.numpos(e.style.top) < 0)
+            return false;
+        return true;
+    }, nodeList(div.childNodes));
+
+    // Reposition nodes
+    map(function(e) {
+        var x = ui.numpos(e.style.left) - 2500;
+        e.style.left = ui.pixpos(x);
+        return e;
+    }, fnodes);
+
+    // Sort them by position
+    var snodes = fnodes.sort(function(a, b) {
+        var ay = ui.numpos(a.style.top);
+        var by = ui.numpos(b.style.top);
+        if (ay < by) return -1;
+        if (ay > by) return 1;
+        var ax = ui.numpos(a.style.left);
+        var bx = ui.numpos(b.style.left);
+        if (ax < bx) return -1;
+        if (ax > bx) return 1;
+        return 0;
+    });
+
+    // Append them back to the div in order
+    div.innerHTML = '';
+    map(function(e) {
+        div.appendChild(e);
+        return e;
+    }, snodes);
+
+    // Convert the page to XHTML
+    var lxhtml = readXHTMLElement(div);
+    var xhtml = writeStrings(writeXML(lxhtml, false));
+    return xhtml;
+}
+
+/**
+ * Save the current page.
+ */
+function save() {
+    $('saveStatus').innerHTML = 'Saving';
+
+    // Get the current page XHTML content
+    savedpagexhtml = pagexhtml();
+
+    // Update the page ATOM entry
+    var entry = '<entry xmlns="http://www.w3.org/2005/Atom">' +
+        '<title type="text">' + appname + '</title><id>' + appname + '</id><content type="application/xml">' +
+        savedpagexhtml + '</content></entry>';
+
+    pages.put(appname, entry);
+    if (savedpagexhtml == pagexhtml())
+        $('saveStatus').innerHTML = 'Saved';
+    return true;
+};
+
+/**
+ * Handle a page change event
+ */
+function onpagechange(prop) {
+    if (savedpagexhtml == pagexhtml())
+        return false;
+    $('saveStatus').innerHTML = 'Modified';
+
+    // Save property changes right away
+    if (prop)
+        return save();
+
+    // Autosave other changes after 3 seconds
+    setTimeout(function() {
+        if (savedpagexhtml == pagexhtml())
+            return false;
+        return save();
+    }, 1000);
+    return true;
+}
+
+/**
+ * Return the link to a component value.
+ */
+function compvaluelink(appname, cname) {
+    if (cname == '' || isNil(cname))
+        return '';
+    var protocol = window.location.protocol;
+    var host = window.location.hostname;
+    var port = ':' + window.location.port;
+    if (port == ':80' || port == ':443' || port == ':')
+        port = '';
+    var link = protocol + '//' + appname + '.' + host + port + '/data/?component=' + cname;
+    return link;
+}
+
+/**
+ * Handle a widget select event.
+ */
+function onwidgetselect(wname) {
+    if (wname == widgetname)
+        return true;
+    widgetname = wname;
+    var link = compvaluelink(appname, wname);
+
+    function updateButton(b, v) {
+        b.style.color = v? '#000000' : '#808080';
+    }
+
+    updateButton($('deleteWidgetButton'), link != '');
+    //updateButton($('playWidgetButton'), link != '');
+
+    return true;
+}
+
+/**
+ * Play the component associated with the current widget.
+ */
+/*
+$('playWidgetButton').onclick = function() {
+    var link = compvaluelink(appname, widgetname);
+    if (link == '')
         return;
-    $('page').innerHTML =
-        '<iframe id="pageFrame" style="height: 5000px; width: 100%; border: 0px;" scrolling="no" frameborder="0" src="page.html?' +
-        'app=' + name +
-        '"></iframe>';
+    return window.open(link, '_' + appname + '_' + widgetname);
 }
+*/
+
+// Initialize the page editor
+var edit = $('page');
+page.edit(edit, $('widgetName'), $('widgetText'), $('addWidgetButton'), $('deleteWidgetButton'), onpagechange, onwidgetselect);
 
-editapp(appname);
+// Get and display the current app page
+getpage(appname, edit);
 
 </script>
 </body>

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/page/page.js
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/page/page.js?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/page/page.js (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/page/page.js Mon May  2 05:58:26 2011
@@ -25,349 +25,252 @@ var page = {};
 /**
  * Default positions and sizes.
  */
-var palcx = 250;
-var trashcx = 230;
+var palcx = 2500;
+var trashcx = 2480;
 
-if (ui.isIE()) {
+/**
+ * Init a page editor. Works with all browsers except IE.
+ */
+page.edit = function(elem, wname, wtext, wadd, wdelete, onchange, onselect) {
+
+    // Track element dragging and selection
+    page.dragging = null;
+    page.selected = null;
+    wname.disabled = true;
+    wtext.disabled = true;
+    wdelete.disabled = true;
+
+    // Trigger widget select and page change events
+    page.onpagechange = onchange;
+    page.onwidgetselect = onselect;
 
     /**
-     * Init a page editor. IE-specific implementation.
+     * Handle a mouse down event.
      */
-    page.edit = function(elem, wname, wtext, onchange) {
-
-        // Track element dragging and selection
-        page.dragging = null;
-        page.selected = null;
-        wname.disabled = true;
-        wtext.disabled = true;
-
-        // Trigger page change events
-        page.onpagechange = onchange;
+    elem.onmousedown = function(e) {
 
-        /**
-         * Handle a mouse down event.
-         */
-        elem.onmousedown = function() {
-            window.event.returnValue = false;
-
-            // Find a draggable element
-            page.dragging = page.draggable(window.event.srcElement, elem);
+        // Find a draggable element
+        page.dragging = page.draggable(e.target, elem);
+        page.selected = page.dragging;
+        if (page.dragging == null) {
+
+            // Reset current selection
+            wname.value = '';
+            wname.disabled = true;
+            wtext.value = '';
+            wtext.disabled = true;
+            wdelete.disabled = true;
+
+            // Trigger widget select event
+            page.onwidgetselect('');
+            return true;
+        }
+
+        // Clone element dragged from palette
+        if (page.dragging.id.substring(0, 8) == 'palette:') {
+            page.dragging = page.clone(page.dragging);
             page.selected = page.dragging;
-            if (page.dragging == null) {
-
-                // Reset current selection
-                wname.value = '';
-                wname.disabled = true;
-                wtext.value = '';
-                wtext.disabled = true;
-                return false;
-            }
-
-            // Clone element dragged from palette
-            if (page.dragging.id.substring(0, 8) == 'palette:') {
-                page.dragging = page.clone(page.dragging);
-                page.selected = page.dragging;
-            }
 
+            // Move into the editing area and hide the palette
+            page.selected.style.left = ui.pixpos(ui.numpos(page.selected.style.left) + palcx);
+            elem.style.left = ui.pixpos(palcx * -1);
+        
             // Bring it to the top
             page.bringtotop(page.dragging);
 
-            // Save the mouse position
-            page.dragX = window.event.clientX;
-            page.dragY = window.event.clientY;
-            elem.setCapture();
-
-            // Update the widget name and text fields
-            wname.value = page.selected.id;
-            wname.disabled = false;
-            wtext.value = page.text(page.selected);
-            wtext.disabled = !page.hastext(page.selected);
-            return false;
-        };
-
-        /**
-         * Handle a mouse up event.
-         */
-        elem.onmouseup = function() {
-            if (page.dragging == null)
-                return false;
-
-            // Snap to grid
-            var newX = page.gridsnap(ui.csspos(page.dragging.style.left));
-            var newY = page.gridsnap(ui.csspos(page.dragging.style.top));
-            page.dragging.style.left = newX;
-            page.dragging.style.top = newY;
-            page.dragging.cover.style.left = newX;
-            page.dragging.cover.style.top = newY;
-
-            // Fixup widget style
-            page.fixupwidget(page.dragging);
-
-            // Discard element dragged out of page area
-            if (ui.csspos(page.dragging.style.left) < palcx && page.dragging.id.substring(0, 8) != 'palette:') {
-                if (ui.csspos(page.dragging.style.left) >= trashcx) {
-
-                    // Unless it's close enough to page area, then move it there
-                    page.dragging.style.left = palcx;
-                    page.dragging.cover.style.left = palcx;
-                } else {
-                    page.dragging.parentNode.removeChild(page.dragging);
-
-                    // Reset current selection
-                    page.selected = null;
-                    wname.value = '';
-                    wname.disabled = true;
-                    wtext.value = '';
-                    wtext.disabled = true;
-                }
-            }
-
-            // Forget current dragged element
-            page.dragging = null;
-            elem.releaseCapture();
-            
-            // Trigger page change event
-            page.onpagechange(false);
-            return false;
-        };
-
-        /**
-         * Handle a mouse move event.
-         */
-        elem.onmousemove = function() {
-            if (page.dragging == null)
-                return false;
-
-            // Compute dragged element position
-            var curX = ui.csspos(page.dragging.style.left);
-            var curY = ui.csspos(page.dragging.style.top);
-            var newX = curX + (window.event.clientX - page.dragX);
-            var newY = curY + (window.event.clientY - page.dragY);
-            if (newX >= 0)
-                page.dragX = window.event.clientX;
-            else
-                newX = 0;
-            if (newY >= 0)
-                page.dragY = window.event.clientY;
-            else
-                newY = 0;
-
-            // Move dragged element
-            page.dragging.style.left = newX;
-            page.dragging.style.top = newY;
-            page.dragging.cover.style.left = newX;
-            page.dragging.cover.style.top = newY;
-            return false;
-        };
-
-        /**
-         * Handle field on change events.
-         */
-        wname.onchange = wname.onblur = function() {
-            if (page.selected == null)
-                return false;
-            page.selected.id = wname.value;
-
             // Trigger page change event
             page.onpagechange(true);
-            return false;
-        };
-
-        wtext.onchange = wtext.onblur = function() {
-            if (page.selected == null)
-                return false;
-            page.settext(page.selected, wtext.value);
 
-            // Trigger page change event
-            page.onpagechange(true);
-            return false;
-        };
+        } else {
 
-        // Cover child elements with span elements to prevent
-        // any input events to reach them
-        map(page.cover, nodeList(elem.childNodes));
+            // Bring it to the top
+            page.bringtotop(page.dragging);
+        }
 
-        return elem;
+        // Remember mouse position
+        var pos = typeof e.touches != "undefined" ? e.touches[0] : e;
+        page.dragX = pos.screenX;
+        page.dragY = pos.screenY;
+
+        // Update the widget name and text fields
+        wname.value = page.selected.id;
+        wname.disabled = false;
+        wtext.value = page.text(page.selected);
+        wtext.disabled = !page.hastext(page.selected);
+        wdelete.disabled = false;
+
+        // Trigger widget select event
+        page.onwidgetselect(page.selected.id);
+
+        if (e.preventDefault)
+            e.preventDefault();
+        else
+            e.returnValue = false;
+        return true;
     };
 
-} else {
+    // Support touch devices
+    elem.ontouchstart = elem.onmousedown;
 
     /**
-     * Init a page editor. Generic implementation for all other browsers.
+     * Handle a mouse up event.
      */
-    page.edit = function(elem, wname, wtext, onchange) {
-
-        // Track element dragging and selection
-        page.dragging = null;
-        page.selected = null;
-        wname.disabled = true;
-        wtext.disabled = true;
-
-        // Trigger page change events
-        page.onpagechange = onchange;
-
-        /**
-         * Handle a mouse down event.
-         */
-        elem.onmousedown = function(e) {
-            if (e.preventDefault)
-                e.preventDefault();
-            else
-                e.returnValue = false;
-
-            // Find a draggable element
-            page.dragging = page.draggable(e.target, elem);
-            page.selected = page.dragging;
-            if (page.dragging == null) {
+    elem.onmouseup = function(e) {
+        if (page.dragging == null)
+            return true;
+
+        // Snap to grid
+        var newX = page.gridsnap(ui.numpos(page.dragging.style.left));
+        var newY = page.gridsnap(ui.numpos(page.dragging.style.top));
+        page.dragging.style.left = ui.pixpos(newX);
+        page.dragging.style.top = ui.pixpos(newY);
+        page.dragging.cover.style.left = ui.pixpos(newX);
+        page.dragging.cover.style.top = ui.pixpos(newY);
+
+        // Fixup widget style
+        page.fixupwidget(page.dragging);
+
+        // Discard element dragged out of page area
+        if (ui.numpos(page.dragging.style.left) < palcx && page.dragging.id.substring(0, 8) != 'palette:') {
+            if (ui.numpos(page.dragging.style.left) >= trashcx) {
+
+                // Unless it's close enough to page area, then move it there
+                page.dragging.style.left = ui.pixpos(palcx);
+                page.dragging.cover.style.left = ui.pixpos(palcx);
+            } else {
+                page.dragging.parentNode.removeChild(page.dragging);
 
                 // Reset current selection
+                page.selected = null;
                 wname.value = '';
                 wname.disabled = true;
                 wtext.value = '';
                 wtext.disabled = true;
-                return false;
-            }
+                wdelete.disabled = true;
 
-            // Clone element dragged from palette
-            if (page.dragging.id.substring(0, 8) == 'palette:') {
-                page.dragging = page.clone(page.dragging);
-                page.selected = page.dragging;
+                // Trigger widget select event
+                page.onwidgetselect('');
             }
+        }
 
-            // Bring it to the top
-            page.bringtotop(page.dragging);
+        // Forget dragged element
+        page.dragging = null;
 
-            // Remember mouse position
-            var pos = typeof e.touches != "undefined" ? e.touches[0] : e;
+        // Trigger page change event
+        page.onpagechange(false);
+        return true;
+    };
+
+    // Support touch devices
+    elem.ontouchend = elem.onmouseup;
+
+    /**
+     * Handle a mouse move event.
+     */
+    window.onmousemove = function(e) {
+        if (page.dragging == null)
+            return true;
+
+        // Compute position of dragged element
+        var curX = ui.numpos(page.dragging.style.left);
+        var curY = ui.numpos(page.dragging.style.top);
+        var pos = typeof e.touches != "undefined" ? e.touches[0] : e;
+        var newX = curX + (pos.screenX - page.dragX);
+        var newY = curY + (pos.screenY - page.dragY);
+        if (newX >= 0)
             page.dragX = pos.screenX;
+        else
+            newX = 0;
+        if (newY >= 0)
             page.dragY = pos.screenY;
+        else
+            newY = 0;
 
-            // Update the widget name and text fields
-            wname.value = page.selected.id;
-            wname.disabled = false;
-            wtext.value = page.text(page.selected);
-            wtext.disabled = !page.hastext(page.selected);
-            return false;
-        };
+        // Move the dragged element
+        page.dragging.style.left = ui.pixpos(newX);
+        page.dragging.style.top = ui.pixpos(newY);
+        page.dragging.cover.style.left = ui.pixpos(newX);
+        page.dragging.cover.style.top = ui.pixpos(newY);
+        return true;
+    };
 
-        // Support touch devices
-        elem.ontouchstart = elem.onmousedown;
+    // Support touch devices
+    elem.ontouchmove = window.onmousemove;
 
-        /**
-         * Handle a mouse up event.
-         */
-        window.onmouseup = function(e) {
-            if (page.dragging == null)
-                return false;
-
-            // Snap to grid
-            var newX = page.gridsnap(ui.csspos(page.dragging.style.left));
-            var newY = page.gridsnap(ui.csspos(page.dragging.style.top));
-            page.dragging.style.left = newX;
-            page.dragging.style.top = newY;
-            page.dragging.cover.style.left = newX;
-            page.dragging.cover.style.top = newY;
-
-            // Fixup widget style
-            page.fixupwidget(page.dragging);
-
-            // Discard element dragged out of page area
-            if (ui.csspos(page.dragging.style.left) < palcx && page.dragging.id.substring(0, 8) != 'palette:') {
-                if (ui.csspos(page.dragging.style.left) >= trashcx) {
-
-                    // Unless it's close enough to page area, then move it there
-                    page.dragging.style.left = palcx;
-                    page.dragging.cover.style.left = palcx;
-                } else {
-                    page.dragging.parentNode.removeChild(page.dragging);
-
-                    // Reset current selection
-                    page.selected = null;
-                    wname.value = '';
-                    wname.disabled = true;
-                    wtext.value = '';
-                    wtext.disabled = true;
-                }
-            }
+    /**
+     * Handle a mouse click event.
+     */
+    elem.onclick = function(e) {
+        if (page.dragging == null) {
 
-            // Forget dragged element
-            page.dragging = null;
+            // Dismiss the palette
+            if (ui.numpos(elem.style.left) != (palcx * -1))
+                elem.style.left = ui.pixpos(palcx * -1);
+        }
+        return true;
+    };
 
-            // Trigger page change event
-            page.onpagechange(false);
+    /**
+     * Handle field on change events.
+     */
+    wname.onchange = wname.onblur = function() {
+        if (page.selected == null)
             return false;
-        };
+        page.selected.id = wname.value;
 
-        // Support touch devices
-        window.top.onmouseup = window.onmouseup;
-        window.ontouchend = window.onmouseup;
-        window.top.ontouchend = window.onmouseup;
-
-        /**
-         * Handle a mouse move event.
-         */
-        window.onmousemove = function(e) {
-            if (page.dragging == null)
-                return false;
-
-            // Compute position of dragged element
-            var curX = ui.csspos(page.dragging.style.left);
-            var curY = ui.csspos(page.dragging.style.top);
-            var pos = typeof e.touches != "undefined" ? e.touches[0] : e;
-            var newX = curX + (pos.screenX - page.dragX);
-            var newY = curY + (pos.screenY - page.dragY);
-            if (newX >= 0)
-                page.dragX = pos.screenX;
-            else
-                newX = 0;
-            if (newY >= 0)
-                page.dragY = pos.screenY;
-            else
-                newY = 0;
-
-            // Move the dragged element
-            page.dragging.style.left = newX;
-            page.dragging.style.top = newY;
-            page.dragging.cover.style.left = newX;
-            page.dragging.cover.style.top = newY;
+        // Trigger page change event
+        page.onpagechange(true);
+        return false;
+    };
+
+    wtext.onchange = wtext.onblur = function() {
+        if (page.selected == null)
             return false;
-        };
+        page.settext(page.selected, wtext.value);
 
-        // Support touch devices
-        window.top.onmousemove = window.onmousemove;
-        window.ontouchmove = window.onmousemove;
-        window.top.ontouchmove = window.onmousemove;
-
-        /**
-         * Handle field on change events.
-         */
-        wname.onchange = wname.onblue = function() {
-            if (page.selected == null)
-                return false;
-            page.selected.id = wname.value;
+        // Trigger page change event
+        page.onpagechange(true);
+        return false;
+    };
 
-            // Trigger page change event
-            page.onpagechange(true);
-            return false;
-        };
+    // Handle add widget event.
+    wadd.onclick = function() {
 
-        wtext.onchange = wtext.onblur = function() {
-            if (page.selected == null)
-                return false;
-            page.settext(page.selected, wtext.value);
+        // Show the palette
+        elem.style.left = ui.pixpos(0);
+        return false;
+    };
 
-            // Trigger page change event
-            page.onpagechange(true);
+    // Handle delete event.
+    wdelete.onclick = function() {
+        if (page.selected == null)
             return false;
-        };
 
-        // Cover child elements with span elements to prevent
-        // any input events to reach them
-        map(page.cover, nodeList(elem.childNodes));
+        // Remove selected widget
+        page.selected.parentNode.removeChild(page.selected);
+
+        // Reset current selection
+        page.selected = null;
+        wname.value = '';
+        wname.disabled = true;
+        wtext.value = '';
+        wtext.disabled = true;
+        wdelete.disabled = true;
+
+        // Trigger widget select event
+        page.onwidgetselect('');
 
-        return elem;
+        // Trigger page change event
+        page.onpagechange(true);
+        return false;
     };
-}
+
+    // Cover child elements with span elements to prevent
+    // any input events to reach them
+    map(page.cover, nodeList(elem.childNodes));
+
+    return elem;
+};
 
 /**
  * Return the text of a widget.
@@ -532,8 +435,8 @@ page.cover = function(e) {
         return e;
     var cover = document.createElement('span');
     cover.style.position = 'absolute';
-    cover.style.left = ui.csspos(e.style.left) - 5;
-    cover.style.top = ui.csspos(e.style.top) - 5;
+    cover.style.left = ui.pixpos(ui.numpos(e.style.left) - 5);
+    cover.style.top = ui.pixpos(ui.numpos(e.style.top) - 5);
     cover.style.width = e.clientWidth + 10;
     cover.style.height = e.clientHeight + 10;
     cover.style.visibility = 'visible';
@@ -568,8 +471,8 @@ page.clone = function(e) {
      */
     function posclone(ne, e) {
         ne.style.position = 'absolute';
-        ne.style.left = ui.csspos(e.style.left);
-        ne.style.top = ui.csspos(e.style.top);
+        ne.style.left = ui.pixpos(ui.numpos(e.style.left));
+        ne.style.top = ui.pixpos(ui.numpos(e.style.top));
         e.parentNode.appendChild(ne);
         page.cover(ne);
         return ne;

Added: tuscany/sca-cpp/trunk/modules/edit/htdocs/public/delete.png
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/public/delete.png?rev=1098489&view=auto
==============================================================================
Files tuscany/sca-cpp/trunk/modules/edit/htdocs/public/delete.png (added) and tuscany/sca-cpp/trunk/modules/edit/htdocs/public/delete.png Mon May  2 05:58:26 2011 differ

Added: tuscany/sca-cpp/trunk/modules/edit/htdocs/public/delete.xcf
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/public/delete.xcf?rev=1098489&view=auto
==============================================================================
Files tuscany/sca-cpp/trunk/modules/edit/htdocs/public/delete.xcf (added) and tuscany/sca-cpp/trunk/modules/edit/htdocs/public/delete.xcf Mon May  2 05:58:26 2011 differ

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/public/iframe.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/public/iframe.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/public/iframe.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/public/iframe.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -22,7 +23,7 @@
 <meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/>
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
 </head>
 <body style="margin:3px; padding: 0px; background-color: #dcdcdc;">
 

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notauth.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notauth.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notauth.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notauth.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -22,42 +23,52 @@
 <meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/>
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
 <script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript" src="/ui.js"></script>
+<script type="text/javascript" src="/all-min.js"></script>
+<script type="text/javascript" src="/menu.js"></script>
 </head>
-<body class="delayed">
+<body class="delayed" onorientationchange="ui.reload();">
+<div id="bodydiv" class="devicewidth">
+
 <div id="menu"></div>
 
-<h1 id="h1"></h1>
+<table style="width: 100%;">
+<tr><td><h1><span id="h1"></span></h1></td></tr>
+</table>
 <br/>
 
+<div style="margin-left: auto; margin-right: auto; text-align: center;">
 <div class="hd2">Sorry, you're not authorized to view this page.</div>
+</div>
+
+</div>
 
 <form name="signout" action="/public/notauth.html" method="GET">
 </form>
 
 <script type="text/javascript">
+// Set page title
+$('h1').innerHTML = hometitle(window.location.hostname);
 
 // Load the menu bar
 if (!issubdomain(window.location.hostname))
-    ui.loadwidget('menu', '/menu.html', ui.showbody);
+    displaymenu();
 
-$('h1').innerHTML = hometitle(window.location.hostname);
+// Show the page
+ui.showbody();
 
-if (issubdomain(window.location.hostname))
-    ui.showbody();
+// Sign out
+if (window.top.location.pathname != '/public/notauth.html') {
+    function submitSignout() {
+        var reset = 'TuscanyOpenAuth=;expires=' + new Date(1970,01,01).toGMTString() + ';domain=.' + domainname(window.location.hostname) + ';path=/;secure=TRUE';
+        document.cookie = reset;
+        document.signout.submit();
+        return true;
+    }
 
-function submitSignout() {
-    var reset = 'TuscanyOpenAuth=;expires=' + new Date(1970,01,01).toGMTString() + ';domain=.' + domainname(window.location.hostname) + ';path=/;secure=TRUE';
-    document.cookie = reset;
-    document.signout.submit();
-    return true;
-}
-
-if (window.top.location.pathname != '/public/notauth.html')
     submitSignout();
+}
 </script>
 
 </body>

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notfound.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notfound.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notfound.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notfound.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -22,30 +23,38 @@
 <meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/>
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
 <script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript" src="/ui.js"></script>
+<script type="text/javascript" src="/all-min.js"></script>
+<script type="text/javascript" src="/menu.js"></script>
 </head>
-<body class="delayed">
+<body class="delayed" onorientationchange="ui.reload();">
+<div id="bodydiv" class="devicewidth">
+
 <div id="menu"></div>
 
-<h1 id="h1"></h1>
+<table style="width: 100%;">
+<tr><td><h1><span id="h1"></span></h1></td></tr>
+</table>
 <br/>
 
+<div style="margin-left: auto; margin-right: auto; text-align: center;">
 <div class="hd2">Sorry, that page was not found.</div>
 <div>You may have clicked an expired link or mistyped the address.</div>
+</div>
+
+</div>
 
 <script type="text/javascript">
+// Set page title
+$('h1').innerHTML = hometitle(window.location.hostname);
 
 // Load the menu bar
 if (!issubdomain(window.location.hostname))
-    ui.loadwidget('menu', '/menu.html', ui.showbody);
-
-$('h1').innerHTML = hometitle(window.location.hostname);
+    displaymenu();
 
-if (issubdomain(window.location.hostname))
-    ui.showbody();
+// Show the page
+ui.showbody();
 </script>
 
 </body>

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notyet.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notyet.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notyet.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/public/notyet.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -22,30 +23,38 @@
 <meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/>
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
 <script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript" src="/ui.js"></script>
+<script type="text/javascript" src="/all-min.js"></script>
+<script type="text/javascript" src="/menu.js"></script>
 </head>
-<body class="delayed">
+<body class="delayed" onorientationchange="ui.reload();">
+<div id="bodydiv" class="devicewidth">
+
 <div id="menu"></div>
 
-<h1 id="h1"></h1>
+<table style="width: 100%;">
+<tr><td><h1><span id="h1"></span></h1></td></tr>
+</table>
 <br/>
 
+<div style="margin-left: auto; margin-right: auto; text-align: center;">
 <div class="hd2">Sorry, that page is still under construction.</div>
 <div>Please check back later.</div>
+</div>
+
+</div>
 
 <script type="text/javascript">
+// Set page title
+$('h1').innerHTML = hometitle(window.location.hostname);
 
 // Load the menu bar
 if (!issubdomain(window.location.hostname))
-    ui.loadwidget('menu', '/menu.html', ui.showbody);
-
-$('h1').innerHTML = hometitle(window.location.hostname);
+    displaymenu();
 
-if (issubdomain(window.location.hostname))
-    ui.showbody();
+// Show the page
+ui.showbody();
 </script>
 
 </body>

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/public/oops.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/public/oops.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/public/oops.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/public/oops.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -22,29 +23,37 @@
 <meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/>
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
 <script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript" src="/ui.js"></script>
+<script type="text/javascript" src="/all-min.js"></script>
+<script type="text/javascript" src="/menu.js"></script>
 </head>
-<body class="delayed">
+<body class="delayed" onorientationchange="ui.reload();">
+<div id="bodydiv" class="devicewidth">
+
 <div id="menu"></div>
 
-<h1 id="h1"></h1>
+<table style="width: 100%;">
+<tr><td><h1><span id="h1"></span></h1></td></tr>
+</table>
 <br/>
 
+<div style="margin-left: auto; margin-right: auto; text-align: center;">
 <div class="hd2">Oops, something went wrong...</div>
+</div>
+
+</div>
 
 <script type="text/javascript">
+// Set page title
+$('h1').innerHTML = hometitle(window.location.hostname);
 
 // Load the menu bar
 if (!issubdomain(window.location.hostname))
-    ui.loadwidget('menu', '/menu.html', ui.showbody);
-
-$('h1').innerHTML = hometitle(window.location.hostname);
+    displaymenu();
 
-if (issubdomain(window.location.hostname))
-   ui.showbody();
+// Show the page
+ui.showbody();
 </script>
 
 </body>

Added: tuscany/sca-cpp/trunk/modules/edit/htdocs/stats/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/stats/index.html?rev=1098489&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/stats/index.html (added)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/stats/index.html Mon May  2 05:58:26 2011
@@ -0,0 +1,166 @@
+<!DOCTYPE html>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+<html>
+<head>
+<title>Stats</title>
+<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> 
+<meta name="apple-mobile-web-app-capable" content="yes"/>
+<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
+<link rel="apple-touch-icon" href="/public/touchicon.png"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
+<script type="text/javascript" src="/config.js"></script>
+<script type="text/javascript" src="/all-min.js"></script>
+<script type="text/javascript" src="/menu.js"></script>
+</head>
+<body class="delayed" onorientationchange="ui.reload();">
+<div id="bodydiv" class="devicewidth">
+
+<div id="menu"></div>
+
+<table style="width: 100%;">
+<tr>
+<td><h1><span id="h1"></span><span id="appNameHeader"></span></h1></td>
+<td style="vertical-align: middle; text-align: right;"><span id="saveStatus" style="font-weight: bold; color: #808080;">Saved</span></td>
+</tr>
+</table>
+
+<table style="width: 100%;">
+<tr>
+<th class="thl thr" style="padding-top: 4px; padding-bottom: 4px;">Stats</th>
+</tr>
+</table>
+
+<form id="appForm" style="position: absolute; top: 90px; left: 0px;">
+<table style="width: 100%;">
+<tr><tr><td><b>App Icon:</b></td></tr>
+<tr><td><img src="/public/app.png" style="width: 50px; height: 50px; vertical-align: top;"></td></tr>
+<tr><tr><td style="padding-top: 6px;"><b>Sharing:</b></td></tr>
+<tr><td><input type="checkbox" value="shared"/><span>Shared</span></td></tr>
+<tr><tr><td style="padding-top: 6px;"><b>App Title:</b></td></tr>
+<tr><td><input type="text" id="appTitle" size="30" placeholder="Enter the title of your app" style="width: 300px;"/></td></tr>
+<tr><tr><td style="padding-top: 6px;"><b>Updated:</b></td></tr>
+<tr><td><span id="appUpdated"></span></td></tr>
+<tr><tr><td style="padding-top: 6px;"><b>Description:</b></td></tr>
+<tr><td><textarea id="appDescription" cols="40" rows="3" placeholder="Enter a short description of your app" style="width: 300px;"></textarea></td></tr>
+</table>
+</form>
+
+</div>
+
+<script type="text/javascript">
+// Get the app name
+var appname = ui.queryParams()['app'];
+if (isNil(appname))
+    window.open('/', '_self');
+
+/**
+ * Return the link to an app.
+ */
+function applink(appname) {
+    var protocol = window.location.protocol;
+    var host = window.location.hostname;
+    var port = ':' + window.location.port;
+    if (port == ':80' || port == ':443' || port == ':')
+        port = '';
+    var link = protocol + '//' + appname + '.' + host + port + '/';
+    return link;
+}
+
+// Set page titles
+document.title = windowtitle(window.location.hostname) + ' - Stats - ' + appname;
+$('h1').innerHTML = hometitle(window.location.hostname);
+$('appNameHeader').innerHTML = ' - <a href=\"' + applink(appname) + '\" target=\"' + '_blank' + '\">' + appname + '</a>';
+
+// Load the menu bar
+displaymenu();
+
+// Show the page
+ui.showbody();
+
+// Init service references
+var editWidget = sca.component("EditWidget");
+var dashboard = sca.reference(editWidget, "dashboard");
+
+/**
+ * The current app entry and corresponding saved XML content.
+ */
+var appentry;
+var savedappentryxml = '';
+
+/**
+ * Get and display an app.
+ */
+function getapp(name) {
+    if (isNil(name))
+        return false;
+    return dashboard.get(name, function(doc) {
+        appentry = doc != null? car(elementsToValues(atom.readATOMEntry(mklist(doc)))) : mklist("'entry", mklist("'title", ''), mklist("'id", name));
+        var title = cadr(assoc("'title", cdr(appentry)));
+        $('appTitle').value = title;
+        $('appUpdated').innerHTML = 'Apr 24, 2011'
+        $('appDescription').innerHTML = '';
+        savedappentryxml = car(atom.writeATOMEntry(valuesToElements(mklist(appentry))));
+        return true;
+    });
+}
+
+/**
+ * Save the current app.
+ */
+function save(entryxml) {
+    $('saveStatus').innerHTML = 'Saving';
+    savedappentryxml = entryxml;
+    dashboard.put(appname, savedappentryxml);
+    $('saveStatus').innerHTML = 'Saved';
+    return true;
+}
+
+/**
+ * Handle a change event
+ */
+function onappchange() {
+    var title = $('appTitle').value;
+    var appentry = mklist("'entry", mklist("'title", title != ''? title : appname), mklist("'id", appname));
+    var entryxml = car(atom.writeATOMEntry(valuesToElements(mklist(appentry))));
+    if (savedappentryxml == entryxml)
+        return false;
+    $('saveStatus').innerHTML = 'Modified';
+    return save(entryxml);
+}
+
+$('appTitle').onchange = onappchange;
+$('appDescription').onchange = onappchange;
+
+/**
+ * Handle a form submit event.
+ */
+$('appForm').onsubmit = function() {
+    onappchange();
+    return false;
+};
+
+// Get the current app
+getapp(appname);
+
+</script>
+
+</body>
+</html>
+

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/store/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/store/index.html?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/store/index.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/store/index.html Mon May  2 05:58:26 2011
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -23,37 +24,162 @@
 <meta name="apple-mobile-web-app-capable" content="yes"/>
 <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
 <link rel="apple-touch-icon" href="/public/touchicon.png"/>
-<link rel="stylesheet" type="text/css" href="/ui.css"/>
+<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
 <script type="text/javascript" src="/config.js"></script>
-<script type="text/javascript" src="/util.js"></script>
-<script type="text/javascript" src="/ui.js"></script>
-<script type="text/javascript">
-document.title = windowtitle(window.location.hostname) + ' - Store';
-</script>
+<script type="text/javascript" src="/all-min.js"></script>
+<script type="text/javascript" src="/menu.js"></script>
 </head>
-<body class="delayed">
+<body class="delayed" onorientationchange="ui.reload();">
+<div id="bodydiv" class="devicewidth">
+
 <div id="menu"></div>
 
-<h1 id="h1"></h1>
-<br/>
+<table style="width: 100%;">
+<tr><td><h1><span id="h1"></span></h1></td></tr>
+</table>
 
-<div id="store"></div>
+<div id="catmenu"></div>
 
-<script type="text/javascript">
+<div id="apps"></div>
 
-// Load the menu bar
-ui.loadwidget('menu', '/menu.html', ui.showbody);
+</div>
 
+<script type="text/javascript">
+// Set page titles
+document.title = windowtitle(window.location.hostname) + ' - Store';
 $('h1').innerHTML = hometitle(window.location.hostname);
 
+// Display the menu bar
+displaymenu();
+
 // Get the store category
 var category = ui.queryParams()['category'];
 if (isNil(category))
     category = 'myapps';
 
-// Load the store
-$('store').innerHTML =
-    '<iframe id="storeFrame" style="height: 5000px; width: 100%; border: 0px;" scrolling="no" frameborder="0" src="store.html?category=' + category + '"></iframe>';
+/**
+ * Build store menu bar
+ */
+function catmenu() {
+    function catmenuitem(name, cat) {
+        var c = cat == category? 'smenu' : 'amenu';
+        return '<th class="thl thr" style="width: 10px; padding-top: 4px; padding-bottom: 4px; padding-right: 6px;">'
+                + ui.ahref('/store/?category=' + cat, '_self', '<span class="' + c + '">' + name + '</span>') + '</th>';
+    }
+
+    var m = '<table style="width: 100%;"><tr>';
+    m += catmenuitem('My Apps', 'myapps');
+    m += catmenuitem('New', 'new');
+    m += catmenuitem('Top', 'top');
+    m += catmenuitem('Featured', 'featured');
+    m += catmenuitem('All', 'all');
+    if (category == 'myapps') {
+        m += '<th class="thl thr" style="width: 100%; padding-top: 0px; padding-bottom: 0px; padding-right: 0px; text-align: right;">';
+        m += '<input type="button" class="greenbutton" id="createApp" title="Create a new app" style="font-weight: bold; margin-top: 0px; margin-bottom: 0px; height: 24px;" Value="New App"/>';
+        m += '</th></tr></table>';
+        return m;
+    }
+    m += '<th class="thl thr" style="width: 100%;"></th></tr></table>';
+    return m;
+}
+
+// Build store menu bar
+$('catmenu').innerHTML = catmenu();
+
+// Show the page
+ui.showbody();
+
+/**
+ * Service references.
+ */
+var editWidget = sca.component("EditWidget");
+var store = sca.reference(editWidget, "store");
+var dashboard = sca.reference(editWidget, "dashboard");
+
+/**
+ * Return the link to an app.
+ */
+function applink(appname) {
+    var protocol = window.location.protocol;
+    var host = window.location.hostname;
+    var port = ':' + window.location.port;
+    if (port == ':80' || port == ':443' || port == ':')
+        port = '';
+    var link = protocol + '//' + appname + '.' + host + port + '/';
+    return link;
+}
+
+/**
+ * Edit an app.
+ */
+function editApp(appname) {
+    return window.open('/page/?app=' + appname, '_self');
+}
+
+/**
+ * Create an app.
+ */
+if (category == 'myapps') {
+    $('createApp').onclick = function() {
+        return window.open('/create/', '_self');
+    }
+}
+
+/**
+ * Clone an app.
+ */
+function cloneApp(appname) {
+    return window.open('/clone/?app=' + appname, '_self');
+}
+
+/**
+ * Get and display list of apps.
+ */
+function getapps(category) {
+    function display(doc) {
+        var apps = '<div>';
+        var feed = car(elementsToValues(atom.readATOMFeed(mklist(doc))));
+        var entries = cadr(assoc("'entry", cdr(feed)));
+        for (var i = 0; i < length(entries); i++) {
+            var entry = entries[i];
+            var title = cadr(assoc("'title", entry))
+            var name = cadr(assoc("'id", entry))
+            var author = 'joe';
+            var clone = isNil(config.clone)? 'Clone' : config.clone;
+
+            apps += '<div class="box" style="width: 285px; display: inline-block; border: 1px; border-style: solid; border-color: #dcdcdc; border-collapse: collapse; margin: 5px; padding: 10px; vertical-align: top;">'
+            apps += '<table><tr>';
+            apps += '<td>';
+            apps += '<div>' + ui.ahref(applink(name), '_blank', '<img src="/public/app.png" width="50" height="50" style="height: 50px; width: 50px; vertical-align: top; margin-right: 10px; margin-bottom: 5px;"></img>') + '</div>';
+            apps += '<div><input type="button" class="greenbutton" id="cloneApp" value="' + clone + '" title="' + clone + ' this app" onclick="cloneApp(\'' + name + '\');"></div>';
+            if (category == 'myapps')
+                apps += '<div><input type="button" id="editApp" class="bluebutton" value="Edit" title="Edit this app" onclick="editApp(\'' + name + '\');"></div>';
+            apps += '</td>';
+            apps += '<td class="tdw">';
+            apps += '<div style="font-weight: bold">' + ui.ahref(applink(name), '_blank', name) + '</div>';
+            if (category == 'myapps')
+                apps += '<div style="color: #808080;">Shared</div>';
+            else
+                apps += '<div>' + 'by&nbsp;' + '<span style="font-weight: bold;">' + author + '</span></div>';
+            apps += '<div>Feb 4, 2011</div>';
+            apps += '<br/>';
+            apps += '<div>' + title + '</div>';
+            apps += '<br/>';
+            apps += '</td>';
+            apps += '</tr></table>';
+            apps += '</div>';
+        }
+        apps += '</div>';
+        $('apps').innerHTML = apps;
+    }
+
+    if (category == 'myapps')
+        return dashboard.get('', display);
+    return store.get(category, display);
+}
+
+// Get and display the list of apps
+getapps(category);
 
 </script>
 

Modified: tuscany/sca-cpp/trunk/modules/edit/mkapplinks
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/mkapplinks?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/mkapplinks (original)
+++ tuscany/sca-cpp/trunk/modules/edit/mkapplinks Mon May  2 05:58:26 2011
@@ -30,18 +30,3 @@ for n in `ls apps | awk '{ printf "apps/
     fi
 done
 
-for n in `ls apps | awk '{ printf "apps/%s/htdocs\n", $1 }'`; do
-    if [ ! -e "$n" ]; then
-        mkdir "$n"
-        ln -s ../../../htdocs/cache-manifest.cmf "$n/cache-manifest.cmf"
-        ln -s ../../../htdocs/login "$n/login"
-        ln -s ../../../htdocs/logout "$n/logout"
-        ln -s ../../../htdocs/public "$n/public"
-        ln -s ../../../htdocs/data "$n/data"
-        ln -s ../../../htdocs/app/index.html "$n/index.html"
-        ln -s ../../../htdocs/robots.txt "$n/robots.txt"
-        ln -s ../../../htdocs/favicon.ico "$n/favicon.ico"
-        ln -s ../app.html "$n/app.html"
-    fi
-done
-

Modified: tuscany/sca-cpp/trunk/modules/edit/ssl-start
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/ssl-start?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/ssl-start (original)
+++ tuscany/sca-cpp/trunk/modules/edit/ssl-start Mon May  2 05:58:26 2011
@@ -93,16 +93,25 @@ SCAVirtualComposite app.composite
 
 EOF
 
-# Configure look and feel
-cat >>tmp/conf/httpd.conf <<EOF
-# Override CSS
-#Alias /ui.css $jsprefix/htdocs/uicyan.css
-
-EOF
-
 # Create app links and sub-directories if needed
 ./mkapplinks
 
+# Configure app aliases
+cat >>tmp/conf/dvhost-ssl.conf <<EOF
+# Configure aliases
+Alias /cache-manifest.cmf $here/htdocs/app/cache-manifest.cmf
+Alias /data $here/htdocs/data
+Alias /favicon.ico $here/htdocs/favicon.ico
+Alias /login $here/htdocs/login
+Alias /logout $here/htdocs/logout
+Alias /public $here/htdocs/public
+Alias /robots.txt $here/htdocs/robots.txt
+Alias /index.html $here/htdocs/app/index.html
+Alias /menu.js $here/htdocs/menu.js
+Alias /config.js $here/htdocs/config.js
+
+EOF
+
 # Create application database directories
 mkdir -p tmp/appdata/filedb
 

Modified: tuscany/sca-cpp/trunk/modules/edit/start
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/start?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/start (original)
+++ tuscany/sca-cpp/trunk/modules/edit/start Mon May  2 05:58:26 2011
@@ -69,16 +69,25 @@ SCAVirtualComposite app.composite
 
 EOF
 
-# Configure look and feel
-cat >>tmp/conf/httpd.conf <<EOF
-# Override CSS
-#Alias /ui.css $jsprefix/htdocs/uicyan.css
-
-EOF
-
 # Create app links and sub-directories if needed
 ./mkapplinks
 
+# Configure app aliases
+cat >>tmp/conf/dvhost.conf <<EOF
+# Configure aliases
+Alias /cache-manifest.cmf $here/htdocs/app/cache-manifest.cmf
+Alias /data $here/htdocs/data
+Alias /favicon.ico $here/htdocs/favicon.ico
+Alias /login $here/htdocs/login
+Alias /logout $here/htdocs/logout
+Alias /public $here/htdocs/public
+Alias /robots.txt $here/htdocs/robots.txt
+Alias /index.html $here/htdocs/app/index.html
+Alias /menu.js $here/htdocs/menu.js
+Alias /config.js $here/htdocs/config.js
+
+EOF
+
 # Create application database directories
 mkdir -p tmp/appdata/filedb
 

Modified: tuscany/sca-cpp/trunk/modules/js/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/js/Makefile.am?rev=1098489&r1=1098488&r2=1098489&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/js/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/js/Makefile.am Mon May  2 05:58:26 2011
@@ -18,9 +18,15 @@
 incl_HEADERS = *.hpp
 incldir = $(prefix)/include/modules/js
 
+BUILT_SOURCES = htdocs/all.js
+htdocs/all.js: htdocs/util.js htdocs/elemutil.js htdocs/xmlutil.js htdocs/atomutil.js htdocs/jsonutil.js htdocs/scdl.js htdocs/ui.js htdocs/component.js
+	cat htdocs/util.js htdocs/elemutil.js htdocs/xmlutil.js htdocs/atomutil.js htdocs/jsonutil.js htdocs/scdl.js htdocs/ui.js htdocs/component.js >htdocs/all.js
+
+CLEANFILES = htdocs/all.js
+
 moddir = $(prefix)/modules/js
 nobase_dist_mod_DATA = htdocs/*.js htdocs/*.css
-EXTRA_DIST = htdocs/*.js htdocs/*.css
+EXTRA_DIST = htdocs/*.js htdocs/*.css htdocs/all.js
 
 js_test_SOURCES = js-test.cpp
 js_test_LDFLAGS = -lmozjs 



Mime
View raw message