summaryrefslogtreecommitdiff
path: root/swat/apps/qooxdoo-examples/test/Pollution_1.html
blob: 8651282b544778e742a82e54683a706d22e4a37c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>qooxdoo &raquo; Demo</title>
  <link type="text/css" rel="stylesheet" href="../../resource/css/layout.css"/>
  <!--[if IE]>
  <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
  <![endif]-->
  <script type="text/javascript" src="../../script/qx.js"></script>
</head>
<body>
  <script type="text/javascript" src="../../script/layout.js"></script>

  <div id="demoDescription">
    <p>Test global namespace pollution through qooxdoo.</p>
  </div>

  <script type="text/javascript">
    qx.core.Init.getInstance().defineMain(function()
    {
      var d = qx.ui.core.ClientDocument.getInstance();

      var tb = new qx.ui.toolbar.ToolBar;
      with(tb)
      {
        setTop(48);
        setLeft(20);
        setRight(335);

        // setWidth("auto");
      };

      var btns1 = [
        { type : "button", icon : "file-new", text : "New" },
        { type : "separator" },
        { type : "button", icon : "edit-copy", text : "Copy" },
        { type : "button", icon : "edit-cut", text : "Cut" },
        { type : "button", icon : "edit-paste", text : "Paste" }
      ];

      var btns2 = [
        { type : "button", icon : "up", text : "Upload" },
        { type : "button", icon : "down", text : "Download" }
      ];

      var btns3 = [
        { type : "button", icon : "help", text : "Help" }
      ];

      var bars = [ btns1, btns2, btns3 ];

      function changeLayout(e) {
        this.setShow(e.getData());
      };

      function changeSize(e) {
        var v = e.getData();
        var o = v == 22 ? 32 : 22;

        this.setIcon(this.getIcon().replace(o, v));
      };

      function buttonExecute() { this.debug("Executed: " + this.getLabel()); };

      var useParts = true;


      for (var j=0; j<bars.length; j++)
      {
        var btns = bars[j];

        if (useParts) {
          var tbp = new qx.ui.toolbar.ToolBarPart;
        };

        for (var i=0; i<btns.length; i++)
        {
          var btn = btns[i];

          switch(btn.type)
          {
            case "separator":
              var o = new qx.ui.toolbar.ToolBarSeparator;
              break;

            case "button":
              var o = new qx.ui.toolbar.ToolBarButton(btn.text, "icon/22/" + btn.icon + ".png");

              // beautiful decoupling: toolbar buttons don't know about radio boxes

              d.addEventListener("changeLayout", changeLayout, o);
              d.addEventListener("changeSize", changeSize, o);

              o.addEventListener("execute", buttonExecute);
              break;
          };

          if (useParts)
          {
            tbp.add(o);
          }
          else
          {
            tb.add(o);
          };
        };

        if (useParts) {
          tb.add(tbp);
        };
      };

      d.add(tb);






      var rd1 = new qx.ui.form.RadioButton("Show Icons and Label", "both");
      var rd2 = new qx.ui.form.RadioButton("Show Icons", "icon");
      var rd3 = new qx.ui.form.RadioButton("Show Label", "label");

      with(rd1)
      {
        setTop(140);
        setLeft(20);
        setChecked(true);
      };

      with(rd2)
      {
        setTop(160);
        setLeft(20);
      };

      with(rd3)
      {
        setTop(180);
        setLeft(20);
      };


      var rbm = new qx.manager.selection.RadioManager();

      rbm.add(rd1);
      rbm.add(rd2);
      rbm.add(rd3);


      // beautiful decoupling: radio boxes don't know about toolbar buttons
      rbm.addEventListener("changeSelected", function(e) {
        d.dispatchEvent( new qx.event.type.DataEvent("changeLayout", e.getData().getValue() ) );
      });

      d.add(rd1, rd2, rd3);



      // Alignment
      var ra1 = new qx.ui.form.RadioButton("Left Aligned", "left");
      var ra2 = new qx.ui.form.RadioButton("Centered", "center");
      var ra3 = new qx.ui.form.RadioButton("Right Aligned", "right");

      with(ra1)
      {
        setTop(140);
        setLeft(220);
        setChecked(true);
      };

      with(ra2)
      {
        setTop(160);
        setLeft(220);
      };

      with(ra3)
      {
        setTop(180);
        setLeft(220);
      };


      var ram = new qx.manager.selection.RadioManager();

      ram.add(ra1);
      ram.add(ra2);
      ram.add(ra3);

      d.add(ra1, ra2, ra3);

      ram.addEventListener("changeSelected", function(e) {
        tb.setHorizontalChildrenAlign(e.getData().getValue());
      });




      // Icon Sizes
      var b3 = new qx.ui.form.Button("Icons: 22 Pixel", "icon/16/colors.png");

      with(b3)
      {
        setTop(140);
        setLeft(420);
        setHorizontalAlign("center");
      };

      b3.addEventListener("execute", function(e) {
        d.dispatchEvent(new qx.event.type.DataEvent("changeSize", 22));
      });

      var b4 = new qx.ui.form.Button("Icons: 32 Pixel", "icon/16/colors.png");

      with(b4)
      {
        setTop(170);
        setLeft(420);
        setHorizontalAlign("center");
      };

      b4.addEventListener("execute", function(e) {
        d.dispatchEvent(new qx.event.type.DataEvent("changeSize", 32));
      });

      d.add(b3, b4);





      var pollTxt = new qx.ui.embed.HtmlEmbed;
      pollTxt.setLocation(20, 300);
      pollTxt.setRight(450);
      pollTxt.setBottom(48);
      pollTxt.setOverflow("auto");
      pollTxt.setBorder("1px solid black");
      pollTxt.setBackgroundColor("white");
      qx.ui.core.ClientDocument.getInstance().add(pollTxt);

      var pollWinBtn = new qx.ui.form.Button("Print Window");
      pollWinBtn.setTop(300);
      pollWinBtn.setRight(335);
      qx.ui.core.ClientDocument.getInstance().add(pollWinBtn);

      var pollDocBtn = new qx.ui.form.Button("Print Document");
      pollDocBtn.setTop(330);
      pollDocBtn.setRight(335);
      qx.ui.core.ClientDocument.getInstance().add(pollDocBtn);

      var pollBodyBtn = new qx.ui.form.Button("Print Body");
      pollBodyBtn.setTop(360);
      pollBodyBtn.setRight(335);
      qx.ui.core.ClientDocument.getInstance().add(pollBodyBtn);

      pollWinBtn.addEventListener("execute", function(e) {
        pollTxt.setHtml(qx.dev.Pollution.getHtmlTable("window"));
      });

      pollDocBtn.addEventListener("execute", function(e) {
        pollTxt.setHtml(qx.dev.Pollution.getHtmlTable("document"));
      });

      pollBodyBtn.addEventListener("execute", function(e) {
        pollTxt.setHtml(qx.dev.Pollution.getHtmlTable("body"));
      });
    });
  </script>
</body>
</html>