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