~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to swat2/scripting/client/desktop.js

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
9
We'll cover IE 6 for now, but these checks need to be
 
10
revisited for fuller browser coverage. */
 
11
var browser = QxClient().engine;
 
12
 
 
13
// DocX/Y returns the width/height of the page in browser
 
14
function 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
 
 
25
function 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. 
 
38
function 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
 
 
51
function 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
 
 
63
function getPosX(win)
 
64
{
 
65
        var y = Math.floor( (docY() - sizeY(win)) * Math.random() );
 
66
        return y;
 
67
}
 
68
 
 
69
function getPosY(win)
 
70
{
 
71
        var x = Math.floor( (docX() - sizeX(win)) * Math.random() );
 
72
        return x;
 
73
}
 
74
 
 
75
function openIn(e)
 
76
{
 
77
        var blank = new Window("New Menu");
 
78
        e.add(blank);
 
79
        blank.setVisible(true);
 
80
}
 
81
        
 
82
function 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
 
 
99
function SmallWindow(h, src)
 
100
{
 
101
        this.self = new Window(h, src, .20);
 
102
        return this.self;
 
103
}
 
104
 
 
105
function StandardWindow(h, src)
 
106
{
 
107
        this.self = new Window(h, src, .45);
 
108
        return this.self;
 
109
}
 
110
 
 
111
function LargeWindow(h, src)
 
112
{
 
113
        this.self = new Window(h, src, .70);
 
114
        return this.self;
 
115
}
 
116
 
 
117
Window.small = SmallWindow;
 
118
Window.standard = StandardWindow;
 
119
Window.large = LargeWindow;
 
120
 
 
121