summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeryck Hodge <deryck@samba.org>2005-08-30 03:55:08 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:35:00 -0500
commit37db11885d4a15be1afcfe868b73ebfaa44a8a61 (patch)
tree70e689188f8edbc969e8c0a9a8f0a7c2381db70b
parent24dd21c498efd67054620d900d3358bcf0085cab (diff)
downloadsamba-37db11885d4a15be1afcfe868b73ebfaa44a8a61.tar.gz
samba-37db11885d4a15be1afcfe868b73ebfaa44a8a61.tar.bz2
samba-37db11885d4a15be1afcfe868b73ebfaa44a8a61.zip
r9779: Add a contextmenu function to be used by all window/widget objects.
deryck (This used to be commit f0c7b43767b713f15d9c50fc744da0a6582618b2)
-rw-r--r--swat/desktop/index.esp66
-rw-r--r--swat/scripting/client/desktop.js37
2 files changed, 57 insertions, 46 deletions
diff --git a/swat/desktop/index.esp b/swat/desktop/index.esp
index ee4290f234..0714a2d038 100644
--- a/swat/desktop/index.esp
+++ b/swat/desktop/index.esp
@@ -51,30 +51,6 @@ function blankW()
blank.setVisible(true);
}
-function showContextMenu(e)
-{
- var aboutCmd = new QxCommand();
- aboutCmd.addEventListener("execute", function() {
- showMessage("SWAT, the Samba Web Administration Tool.<br/>This tool is currently under development.");
- });
-
- 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("New Window", null, newWin);
-
- cmenu.add(sub1, sep, sub2);
-
- cmenu.setLeft(e.getClientX());
- cmenu.setTop(e.getClientY());
- w.add(cmenu);
- cmenu.setVisible(true);
-}
-
// Always open with stats
var win = new QxWindow();
document.js.add('/scripting/client/status.js');
@@ -116,6 +92,48 @@ function showReg()
regWin.setVisible('true');
}
+function clientContextMenu(e)
+{
+ var aboutCmd = new QxCommand();
+ aboutCmd.addEventListener("execute", function() {
+ showMessage("SWAT, the Samba Web Administration Tool.<br/>This tool is currently under development.");
+ });
+
+ var newWin = new QxCommand();
+ newWin.addEventListener("execute", blankW);
+
+ var cmenu = new QxMenu;
+
+ var sub1 = new QxMenuButton("About SWAT", null, aboutCmd);
+ var sep = new QxMenuSeparator();
+ var sub2 = new QxMenuButton("New Window", null, newWin);
+
+ cmenu.add(sub1, sep, sub2);
+
+ cmenu.setLeft(e.getClientX());
+ cmenu.setTop(e.getClientY());
+ w.add(cmenu);
+ cmenu.setVisible(true);
+}
+
+function windowContextMenu(t, e)
+{
+ var WinWin = new QxCommand();
+ WinWin.addEventListener("execute", function() {
+ var blank = new QxWindow();
+ t.add(blank);
+ blank.setVisible(true);
+ });
+
+ var inset = new QxMenu;
+ var sub1 = new QxMenuButton("Open window in a window", null, WinWin);
+
+ inset.add(sub1);
+ t.add(inset)
+
+ inset.setVisible(true);
+}
+
function startMenu()
{
var sMenu = new QxMenu;
diff --git a/swat/scripting/client/desktop.js b/swat/scripting/client/desktop.js
index 6383e58bda..bddd38b60c 100644
--- a/swat/scripting/client/desktop.js
+++ b/swat/scripting/client/desktop.js
@@ -89,26 +89,6 @@ function openIn(e)
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(h, src, s)
{
this.self = new QxWindow(h);
@@ -121,7 +101,7 @@ function Window(h, src, s)
this.self.setTop(getPosX(this.self));
this.self.setLeft(getPosY(this.self));
- this.self.addEventListener("contextmenu", winMenu);
+ this.self.addEventListener("contextmenu", contextMenu);
return this.self;
}
@@ -148,10 +128,23 @@ Window.small = SmallWindow;
Window.standard = StandardWindow;
Window.large = LargeWindow;
+function contextMenu(e)
+{
+ var t = e.getTarget()
+ var tObj = t.getHtmlAttribute("class")
+
+ if (tObj == 'QxWidget') {
+ clientContextMenu(e);
+ } else if (tObj == 'QxWindowPane') {
+ windowContextMenu(t, e);
+ }
+}
+
+
window.application.main = function()
{
var doc = this.getClientWindow().getClientDocument();
- doc.addEventListener("contextmenu", showContextMenu);
+ doc.addEventListener("contextmenu", contextMenu);
doc.add(w);
var bar = new QxMenuBar;