From 44a27265fb2aed8ce976aa6cd5875faaa5aec4d9 Mon Sep 17 00:00:00 2001 From: Deryck Hodge Date: Fri, 26 Aug 2005 13:22:56 +0000 Subject: r9651: Start to group all SWAT specific windowing, widgets, etc. in one file. This allows basic style and event code to be set in one place, though we'll still have to override for a specific position or look. More to come... deryck (This used to be commit 9d5482d2aaff2082d85d626c288f2ad16e20b6ae) --- swat/scripting/client/swat.js | 99 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 swat/scripting/client/swat.js (limited to 'swat/scripting') 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; +} + + -- cgit