]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dijit/tests/_base/viewport.html
Comment class stub
[eow] / static / dojo-release-1.1.1 / dijit / tests / _base / viewport.html
1 <html>
2 <head>
3         <title>dijit.getViewport() test</title>
4         <style type="text/css">
5                 @import "../../../dojo/resources/dojo.css";
6                 @import "../css/dijitTests.css";
7                 html, body { margin: 0px; padding: 0px; }
8         </style>
9         <script type="text/javascript" src="../../../dojo/dojo.js"
10                 djConfig="isDebug: false, parseOnLoad: false"></script>
11         <script type="text/javascript" src="../_testCommon.js"></script>
12
13         <script type="text/javascript">
14                 dojo.require("doh.runner");
15                 dojo.require("dijit.dijit");
16
17                 function compute(){
18                         var d = dojo.marginBox(dojo.byId("documentBorder")),
19                                 v = dijit.getViewport();
20                         dojo.byId("results").innerHTML +=
21                                 "Document is " + d.w + "px x " + d.h + "px" +
22                                 ", viewport is " + v.w + "px x " + v.h + "px" +
23                                  ", with scroll offset of (" + v.l + ", " + v.t + ")<br>";
24                 }
25                 
26                 function addText(){
27                         dojo.byId("results").innerHTML += "Adding text...<br><br>";
28                         var text="";
29                         for(var i=0;i<100;i++){
30                                 text += "<span style='white-space: nowrap'>";
31                                 for(var j=0;j<3;j++){ text += "Now is the time for all good men to come to the aid of their country."; }
32                                 text += "</span><br>";
33                         }
34                         dojo.byId("documentBorder").innerHTML += text;
35                 }
36
37                 dojo.addOnLoad(function(){
38                         doh.register("dijit._base.manager",
39                                 [
40                                         function initial(t){
41                                                 console.log("calling compute");
42                                                 compute();
43                                                 console.log("called compute");
44                                                 var d = dojo.marginBox(dojo.byId("documentBorder")),
45                                                         v = dijit.getViewport();
46                                                 doh.t(v.h > d.h);
47                                         },
48                                         function expand(t){
49                                                 var v = dijit.getViewport();
50                                                 addText();
51                                                 compute();
52                                                 var v2 = dijit.getViewport();
53                                                 doh.t(v2.h <= v.h);
54                                                 doh.t(v2.h+20 >= v.h);
55                                         }
56                                 ]
57                         );
58                         doh.run();
59                 });
60
61         </script>
62 </head>
63 <body>
64         <div id="documentBorder" style="border: solid red 2px;">
65                 <h1>dijit.getViewport() test</h1>
66                 <div style="padding: 10px; border: solid blue 1px;">padding div</div>
67                 <button onclick="addText(); compute();">add text and compute size</button>
68                 <button onclick="compute();">recompute size</button>
69                 <ol>
70                         <li>check results div below to see that before adding text, document is smaller than viewport
71                         <li>after adding text, document should be bigger than viewport,and check that viewport size hasn't changed,
72                                 except maybe being a little bit smaller (about 15px) because of the size of the scrollbars
73                         <li>resize browser window and click the "recompute size" button; reported viewport size should change
74                         <li>scroll the window and click "recompute size" to see that the scroll position is taken into effect
75                 </ol>
76                 <div id=results style="border: 5px solid blue;">
77         </div>
78 </body>
79 </html>