source: branches/samba-3.5.x/swat2/scripting/client/desktop.js

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 2.1 KB
Line 
1/*
2 Windows, tabs, and general widgetry for SWAT.
3
4 Copyright (C) Deryck Hodge 2005
5 released under the GNU GPL Version 3 or later
6*/
7
8/* Qooxdoo's browser sniffer doesn't distinguish IE version.
9We'll cover IE 6 for now, but these checks need to be
10revisited for fuller browser coverage. */
11var browser = QxClient().engine;
12
13// DocX/Y returns the width/height of the page in browser
14function docX()
15{
16 var x;
17 if (browser != "mshtml") {
18 x = window.innerWidth;
19 } else {
20 x = document.documentElement.clientWidth;
21 }
22 return x;
23}
24
25function docY()
26{
27 var y;
28 if (browser != "mshtml") {
29 y = window.innerHeight;
30 } else {
31 y = document.documentElement.clientHeight;
32 }
33 return y;
34}
35
36// If given a number, sizeX/Y returns in pixels a percentage of the browser
37// window. If given a Window object, sizeX/Y returns the size of that object.
38function sizeX(s)
39{
40 var sX;
41
42 if (typeof(s) == 'number') {
43 sX = Math.floor(docX() * s);
44 } else {
45 sX = s.getMinWidth();
46 }
47
48 return sX;
49}
50
51function sizeY(s)
52{
53 var sY;
54 if (typeof(s) == 'number') {
55 sY = Math.floor(docY() * s);
56 } else {
57 sY = s.getMinHeight();
58 }
59
60 return sY;
61}
62
63function getPosX(win)
64{
65 var y = Math.floor( (docY() - sizeY(win)) * Math.random() );
66 return y;
67}
68
69function getPosY(win)
70{
71 var x = Math.floor( (docX() - sizeX(win)) * Math.random() );
72 return x;
73}
74
75function openIn(e)
76{
77 var blank = new Window("New Menu");
78 e.add(blank);
79 blank.setVisible(true);
80}
81
82function Window(h, src, s)
83{
84 this.self = new QxWindow(h);
85
86 // Settings for all windows
87 if (s) {
88 this.self.setMinWidth(sizeX(s));
89 this.self.setMinHeight(sizeY(s));
90 }
91 this.self.setTop(getPosX(this.self));
92 this.self.setLeft(getPosY(this.self));
93
94 this.self.addEventListener("contextmenu", contextMenu);
95
96 return this.self;
97}
98
99function SmallWindow(h, src)
100{
101 this.self = new Window(h, src, .20);
102 return this.self;
103}
104
105function StandardWindow(h, src)
106{
107 this.self = new Window(h, src, .45);
108 return this.self;
109}
110
111function LargeWindow(h, src)
112{
113 this.self = new Window(h, src, .70);
114 return this.self;
115}
116
117Window.small = SmallWindow;
118Window.standard = StandardWindow;
119Window.large = LargeWindow;
120
121
Note: See TracBrowser for help on using the repository browser.