source: Dev/branches/rest-dojo-ui/client/dojox/image/tests/Lightbox.html @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 4.6 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html>
3<head>
4       
5        <title>Sample Dojo / Dijit Page</title>
6        <style type="text/css">
7                @import "../../../dijit/themes/tundra/tundra.css";
8                @import "../resources/Lightbox.css";
9                #container {
10                        position:absolute;
11                        left:-9999px;
12                        width:9000px;
13                        overflow:hidden;
14                }
15                #randomimage {
16                        height:100px;
17                }
18        </style>
19        <script>var djConfig = { isDebug:true, parseOnLoad:true }</script>
20        <script src="../../../dojo/dojo.js"></script>
21        <script type="text/javascript">
22                dojo.require("doh.runner");
23                dojo.require("dojo.parser");
24                dojo.require("dojox.image.Lightbox");
25               
26                dojo.addOnLoad(function(){
27                       
28                        doh.register("testUi",
29                                [
30                                        {
31                                                name:"basic lightbox",
32                                                timeout:7000,
33                                                runTest: function(t){
34                                                        var d = new doh.Deferred();
35                                                       
36                                                        var lb = dijit.byId("parsed");
37                                                        t.is("dojox.image.Lightbox", lb.declaredClass);
38
39                                                        setTimeout(function(){
40                                                                lb.show();
41                                                        }, 300);
42                                               
43                                                        setTimeout(function(){
44                                                                lb.hide();
45                                                                d.callback(true);
46                                                        }, lb.duration + 1700);
47
48                                                        return d;
49                                                }
50                                        },
51                                        {
52                                                name:"basic onclick",
53                                                timeout:7000,
54                                                runTest: function(t){
55                                                        var d = new doh.Deferred();
56                                                        var lb = dijit.byId("parsed");
57                                                       
58                                                        t.is("basic title", lb.title);
59                                                        var c = dojo.connect(lb, "show", function(){
60                                                                lb.hide();
61                                                                dojo.disconnect(c);
62                                                                d.callback(true);
63                                                        });
64                                                       
65                                                        dojo.query("a").at(0).forEach(function(n){
66                                                                dojo._triggerEvent(n, "click");
67                                                        });
68                                                       
69                                                        return d;
70                                                }
71                                        },
72                                        {
73                                                name:"basic programatic",
74                                                timeout:7000,
75                                                runTest: function(t){
76                                                        var d = new doh.Deferred();
77                                                       
78                                                        var lb = new dojox.image.Lightbox({
79                                                                href:"images/square.png",
80                                                                title:"A square image"
81                                                        }).placeAt(dojo.body());
82                                                       
83                                                        lb.startup();
84                                                        lb.show();
85                                                       
86                                                        t.is("A square image", lb.title);
87                                                        t.is("dojox.image.LightboxDialog", dijit.byId("dojoxLightboxDialog").declaredClass);
88                                                       
89                                                        setTimeout(function(){
90                                                                lb.hide();
91                                                                d.callback(true);
92                                                        }, lb.duration + 500);
93                                                       
94                                                        return d;
95                                                }
96                                        },
97                                        {
98                                                name:"show single in master",
99                                                timeout:5000,
100                                                runTest: function(t){
101                                                        var d = new doh.Deferred();
102                                                       
103                                                        var lb = dijit.byId("dojoxLightboxDialog");
104                                                        lb.show({
105                                                                href:"images/extraWide.jpg",
106                                                                title:"Wiiiide"
107                                                        });
108                                                       
109                                                        setTimeout(function(){
110                                                                lb.hide();
111                                                                d.callback(true);
112                                                        }, lb.duration + 1500);
113                                                       
114                                                        return d;
115                                                }
116                                        },
117                                        {
118                                                name:"basic group ui",
119                                                timeout:15000,
120                                                runTest: function(t){
121                                                        var d = new doh.Deferred();
122                                                        var l = dijit.byId("grouper"),
123                                                                lb = l._attachedDialog;
124                                                       
125                                                        t.is("bar", l.group);
126                                                        l.show();
127                                                       
128                                                        var next = lb.nextButtonNode, prev = lb.prevButtonNode,
129                                                                close = lb.closeButtonNode;
130                                                       
131                                                        var c = dojo.connect(lb, "hide", function(){
132                                                                dojo.disconnect(c);
133                                                                d.callback(true);
134                                                        });
135                                                               
136                                                        setTimeout(function(){
137                                                                dojo._triggerEvent(next, "click");
138                                                                setTimeout(function(){
139                                                                        dojo._triggerEvent(prev, "click");
140                                                                        setTimeout(function(){
141                                                                                // note: calling trigger("click") on closeNode
142                                                                                // makes hide() called out of scope?
143                                                                                l.hide();
144                                                                        }, l.duration)
145                                                                }, l.duration);
146                                                       
147                                                        }, l.duration + 400);
148                                                       
149                                                        return d;
150                                                }
151                                        }
152                                ]
153                        );
154                       
155                        doh.run();             
156               
157                });
158               
159                // stolen from plugd (http://code.google.com/p/plugd/) to trigger basic events:
160                (function(d){
161                        d._triggerEvent = function(node, event){
162                                // summary: Helper for `dojo.trigger`, which handles the DOM cases. We should never
163                                // be here without a nodeNode reference and a string eventname.
164                                node = d.byId(node);
165                                event = event && event.slice(0, 2) == "on" ? event.slice(2) : event;
166                                if(d.doc.createEvent){
167                                        var evObj = d.doc.createEvent("HTMLEvents");
168                                        evObj.initEvent(event, true, true);
169                                        node.dispatchEvent(evObj);
170                                }else if(d.doc.createEventObject){
171                                        node.fireEvent("on" + event);
172                                }
173                        }
174                })(dojo);
175               
176        </script>
177
178</head>
179<body class="tundra">
180        <a href="images/square.jpg" id="parsed" title="basic title" dojoType="dojox.image.Lightbox">test</a>
181        <a href="images/square.jpg" id="grouper" group="bar" dojoType="dojox.image.Lightbox">testgroup</a>
182        <a href="images/square.jpg" group="bar" dojoType="dojox.image.Lightbox">testgroup</a>
183</body>
184</html>
Note: See TracBrowser for help on using the repository browser.