Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 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>dojox.layout.SizingPane</title>
6
 
7
	<script type="text/javascript" src="../../../dojo/dojo.js"></script>
8
	<script type="text/javascript">
9
		dojo.require("dijit.dijit");
10
		dojo.require("dojo.fx");
11
	</script>
12
	<style type="text/css">
13
		@import "../../../dojo/resources/dojo.css";
14
		@import "../../../dijit/themes/dijit.css";
15
		@import "../../../dijit/themes/tundra/tundra.css";
16
		@import "../../../dijit/tests/css/dijitTests.css";
17
 
18
	body { background:#ededed; color:#666; }
19
 
20
	#nav {
21
		position:absolute;
22
		top:100px;
23
		left:10px;
24
		width:200px;
25
		-moz-border-radius:8pt 8pt;
26
		background:#fff;
27
		border:2px solid #ccc;
28
	}
29
 
30
	#box1 {
31
		overflow:hidden;
32
		position:absolute;
33
		display:block;
34
		width:25px;
35
		height:25px;
36
		-moz-border-radius:8pt 8pt;
37
		radius:8pt;
38
		-webkit-border-radius:8pt 8pt;
39
		background:#fff;
40
		border:2px solid #ccc;
41
		padding:7px;
42
	}
43
 
44
	</style>
45
	<script>
46
		var animationMethod = "chain";  // || combine
47
		var _showing = false;
48
		var animG, offsetW, offsetH = null;
49
		var box1 = null;
50
		var boxMixin = {
51
			startWidth: 25,
52
			startHeight: 25,
53
			endWidth: 320,
54
			endHeight: 320,
55
			duration: 300
56
		};
57
 
58
		dojo.addOnLoad(function() {
59
			box1 = dojo.byId('box1');
60
			centerNode(box1);
61
			dojo.connect(box1,"onmouseover",null,"show");
62
			dojo.connect(box1,"onmouseout",null,"hideCheck");
63
			//dojo.connect(box1,"onmouseout",null,"hideCheck");
64
			//dojo.connect(but1,"onclick",null,"show");
65
		});
66
 
67
		function hideCheck(node) {
68
			if (_showing) {
69
			setTimeout("hide('box1')",125);
70
			}
71
		}
72
 
73
		function centerNode(node) {
74
			var viewport = dijit.getViewport();
75
			var mb = dojo.marginBox(node);
76
			var style = node.style;
77
			offsetW = mb.w - style.width;
78
			offsetH = mb.h - style.height;
79
			style.left = (viewport.l + (viewport.w - mb.w)/2) + "px";
80
			style.top = (viewport.t + (viewport.h - mb.h)/2) + "px";
81
		}
82
 
83
		function doUnderlay() {
84
			console.debug('make underlay');
85
 
86
		}
87
 
88
		function show() {
89
			if (_showing) { return; }
90
			if (animG && animG.status == "playing") { animG.stop(); }
91
			_showing = true;
92
			var viewport = dijit.getViewport();
93
 
94
			var newLeft = (viewport.l + (viewport.w - boxMixin.endWidth)/2);
95
			var newTop = (viewport.t + (viewport.h - boxMixin.endHeight)/2);
96
 
97
			var style = box1.style;
98
			var anim1 = dojo.animateProperty({
99
				node: box1,
100
				duration: boxMixin.duration/2,
101
				properties: {
102
					width: { /* start: boxMixin.startWidth, */ end: boxMixin.endWidth, unit:"px" },
103
					left: { end: newLeft, unit:"px" }
104
				},
105
				beforeBegin: doUnderlay()
106
			});
107
			var anim2 = dojo.animateProperty({
108
				node: box1,
109
				duration: boxMixin.duration/2,
110
				properties: {
111
					height: { /*start: boxMixin.startHeight, */ end: boxMixin.endHeight, unit:"px" },
112
					top: { end: newTop, unit: "px" }
113
				},
114
				onEnd: function() { _showing = true; }
115
 
116
			});
117
			animG = dojo.fx[animationMethod]([anim1,anim2]).play();
118
			// chain:
119
 
120
				// animate width / left position
121
				// animate height / top position
122
			// onend: fadeIn content?
123
		}
124
 
125
		function hide(node) {
126
			if (!_showing) return;
127
			if (animG && animG.status() == "playing") { animG.stop(); }
128
 
129
			var viewport = dijit.getViewport();
130
			var newLeft = (viewport.l + (viewport.w - boxMixin.startWidth)/2);
131
			var newTop = (viewport.t + (viewport.h - boxMixin.startHeight)/2);
132
 
133
			var style = node.style;
134
			var anim1 = dojo.animateProperty({
135
				node: box1,
136
				duration: boxMixin.duration/2,
137
				properties: {
138
					width: { end: boxMixin.startWidth, unit:"px" },
139
					left: { end: newLeft, unit:"px" }
140
				}
141
			});
142
			var anim2 = dojo.animateProperty({
143
					node: box1,
144
				duration: boxMixin.duration/2,
145
				properties: {
146
					height: { end: boxMixin.startHeight, unit:"px" },
147
					top: { end: newTop, unit: "px" }
148
				},
149
				onEnd: function() { _showing = false; }
150
			});
151
			// if we chain, do anim2 first [because height/top is how anim2 in show() ends]
152
			animG = dojo.fx[animationMethod]([anim2,anim1]).play();
153
		}
154
	</script>
155
 
156
</head>
157
<body class="tundra">
158
 
159
	<h1 class="testTitle">dojox.layout.SizingPane</h1>
160
 
161
	<p>This is simply a test / example. There is no <i>real</i> dojox.layout.SizingPane, but this code
162
	should/might become part of a dojox.fx.toggle class ... it's just "neat", isn't it?</p>
163
 
164
	<div id="box1">
165
	lorem. lorem. lorem.
166
	</div>
167
 
168
 
169
</body>
170
</html>