summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--swat/desktop/index.esp92
-rw-r--r--swat/scripting/client/swat.js99
2 files changed, 150 insertions, 41 deletions
diff --git a/swat/desktop/index.esp b/swat/desktop/index.esp
index f688850851..cd52f27d24 100644
--- a/swat/desktop/index.esp
+++ b/swat/desktop/index.esp
@@ -6,37 +6,10 @@ libinclude("base.js");
<script type="text/javascript" src="/scripting/client/encoder.js"></script>
<script type="text/javascript" src="/scripting/client/call.js"></script>
<script type="text/javascript" src="/scripting/client/js_scripts.js"></script>
+<script type="text/javascript" src="/scripting/client/swat.js"></script>
<script type="text/javascript">
-/* Qooxdoo's browser sniffer doesn't distinguish IE version.
-We'll cover IE 6 for now, but these checks need to be
-revisited for fuller browser coverage. */
-var browser = QxClient().engine;
-
-function docWidth()
-{
- var x;
- if (browser != "mshtml") {
- x = window.innerWidth;
- } else {
- x = document.documentElement.clientWidth;
- }
- return x;
-}
-
-function docHeight()
-{
- var y;
- // Less 25px to not cover the toolbar
- if (browser != "mshtml") {
- y = window.innerHeight - 25;
- } else {
- y = document.documentElement.clientHeight;
- }
- return y;
-}
-
function showMessage(m)
{
var message = new QxWindow();
@@ -69,6 +42,13 @@ function showMessage(m)
message.setVisible(true);
}
+function blankW()
+{
+ var blank = new Window("SWAT");
+ w.add(blank);
+ blank.setVisible(true);
+}
+
function showContextMenu(e)
{
var aboutCmd = new QxCommand();
@@ -76,18 +56,21 @@ function showContextMenu(e)
showMessage("SWAT, the Samba Web Administration Tool.<br/>This tool is currently under development.");
});
- var menu = new QxMenu;
+ var newWin = new QxCommand();
+ newWin.addEventListener("execute", blankW);
+
+ cmenu = new QxMenu;
var sub1 = new QxMenuButton("About SWAT", null, aboutCmd);
var sep = new QxMenuSeparator();
- var sub2 = new QxMenuButton("More menu later...", null);
+ var sub2 = new QxMenuButton("New Window", null, newWin);
- menu.add(sub1, sep, sub2);
+ cmenu.add(sub1, sep, sub2);
- menu.setLeft(e.getClientX());
- menu.setTop(e.getClientY());
- w.add(menu);
- menu.setVisible(true);
+ cmenu.setLeft(e.getClientX());
+ cmenu.setTop(e.getClientY());
+ w.add(cmenu);
+ cmenu.setVisible(true);
}
/*** init the page for qooxdoo ***/
@@ -100,8 +83,8 @@ window.application.main = function()
with(w) {
setTop(0);
setLeft(0);
- setWidth(docWidth());
- setHeight(docHeight());
+ setWidth(docX());
+ setHeight(docY());
}
doc.addEventListener("contextmenu", showContextMenu);
doc.add(w);
@@ -127,8 +110,8 @@ window.application.main = function()
window.onresize = function()
{
- w.setWidth(docWidth());
- w.setHeight(docHeight());
+ w.setWidth(docX());
+ w.setHeight(docY());
}
function showReg()
@@ -192,8 +175,22 @@ function startSwat()
srvMenu.setTop(this.getComputedPageBoxTop() - 3);
if (espMenu.getVisible()) {
espMenu.setVisible(false);
+ } else if (newMenu.getVisible()) {
+ newMenu.setVisible(false);
}
});
+
+ var openWin = new QxCommand;
+ openWin.addEventListener("execute", function() {
+ blankW();
+ });
+
+ var newMenu = new QxMenu;
+ var new1 = new QxMenuButton("Window", null, openWin);
+ newMenu.add(new1);
+ w.add(newMenu);
+ newMenu.setVisible(false);
+
var opt2 = new QxMenuButton("Installation", null);
var opt3 = new QxMenuButton("Configuration", null);
var opt4 = new QxMenuButton("ESP Tests", null);
@@ -203,15 +200,28 @@ function startSwat()
espMenu.setTop(this.getComputedPageBoxTop() - 3);
if (srvMenu.getVisible()) {
srvMenu.setVisible(false);
+ } else if (newMenu.getVisible()) {
+ newMenu.setVisible(false);
}
});
var opt5 = new QxMenuButton("Documentation", null);
+ var opt6 = new QxMenuButton("New", null);
+ opt6.addEventListener("mouseover", function() {
+ newMenu.setVisible(true);
+ newMenu.setLeft(this.getComputedPageBoxRight() + 4);
+ newMenu.setTop(this.getComputedPageBoxTop() - 3);
+ if (srvMenu.getVisible()) {
+ srvMenu.setVisible(false);
+ } else if (espMenu.getVisible()) {
+ espMenu.setVisible(false);
+ }
+ });
var sep1 = new QxMenuSeparator();
var sep2 = new QxMenuSeparator();
- sMenu.add(opt1, opt2, opt3, sep1, opt4, sep2, opt5);
+ sMenu.add(opt1, opt2, opt3, sep1, opt4, sep2, opt5, opt6);
sMenu.setLeft(0);
- sMenu.setTop(docHeight() - 150);
+ sMenu.setTop(docY() - 150);
w.add(sMenu);
sMenu.setVisible(true);
}
diff --git a/swat/scripting/client/swat.js b/swat/scripting/client/swat.js
new file mode 100644
index 0000000000..e6a4230f10
--- /dev/null
+++ b/swat/scripting/client/swat.js
@@ -0,0 +1,99 @@
+/*
+ Windows, tabs, and general widgetry for SWAT.
+
+ Copyright (C) Deryck Hodge 2005
+ released under the GNU GPL Version 2 or later
+*/
+
+
+/* Qooxdoo's browser sniffer doesn't distinguish IE version.
+We'll cover IE 6 for now, but these checks need to be
+revisited for fuller browser coverage. */
+var browser = QxClient().engine;
+
+function docX()
+{
+ var x;
+ if (browser != "mshtml") {
+ x = window.innerWidth;
+ } else {
+ x = document.documentElement.clientWidth;
+ }
+ return x;
+}
+
+function docY()
+{
+ var y;
+ // Less 25px to not cover the toolbar
+ if (browser != "mshtml") {
+ y = window.innerHeight - 25;
+ } else {
+ y = document.documentElement.clientHeight;
+ }
+ return y;
+}
+
+function sizeX()
+{
+ var sX = Math.floor(docX() * .45);
+ return sX;
+}
+
+function sizeY()
+{
+ var sY = Math.floor(docY() * .45);
+ return sY;
+}
+
+function getPosX()
+{
+ var y = Math.floor( (docY() - sizeY()) * Math.random() );
+ return y;
+}
+
+function getPosY()
+{
+ var x = Math.floor( (docX() - sizeX()) * Math.random() );
+ return x;
+}
+
+function openIn(e)
+{
+ var blank = new Window("New Menu");
+ e.add(blank);
+ blank.setVisible(true);
+}
+
+function winMenu(e)
+{
+ var self = this;
+ var WinWin = new QxCommand();
+ WinWin.addEventListener("execute", function() {
+ var blank = new QxWindow();
+ self.add(blank);
+ blank.setVisible(true);
+ });
+
+ var inset = new QxMenu;
+ var sub1 = new QxMenuButton("Open window in a window", null, WinWin);
+
+ inset.add(sub1);
+ self.add(inset)
+
+ cmenu.setVisible(false);
+ inset.setVisible(true);
+}
+
+function Window(title)
+{
+ var self = new QxWindow(title);
+ self.setTop(getPosX());
+ self.setLeft(getPosY());
+ self.setMinWidth(sizeX());
+ self.setMinHeight(sizeY());
+ self.addEventListener("contextmenu", winMenu);
+ return self;
+}
+
+