aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/layout/tests/test_ExpandoPane.html
blob: ceaad50d682e30db0cd5b1f7b11177eedf699ec2 (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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>dojox.layout.ExpandoPane</title>
	<link rel="stylesheet" href="_expando.css" />	
	<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="parseOnLoad:true, isDebug:true"></script>
	<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
	<script src="../ExpandoPane.js" type="text/javascript"></script>
	<script type="text/javascript">
		dojo.require("dojo.data.ItemFileReadStore");
		dojo.require("dijit.form.ComboBox");
		dojo.require("dijit.Tree");
		dojo.require("dijit.layout.AccordionContainer");
		dojo.require("dijit.layout.TabContainer");
		dojo.require("dijit.layout.ContentPane");
		dojo.require("dijit.layout.BorderContainer");
		dojo.require("dojox.layout.FloatingPane");
		dojo.require("dojox.fx.easing");
		dojo.require("dojox.rpc.Service");
		dojo.require("dojo.io.script");
	</script>
	<script type="text/javascript">
		dojo.declare("demo.DemoPane",dijit.layout.ContentPane,{

			startup: function(){
				this.inherited(arguments);
				this.rpc.get({ name: this.title, 
					attributes:["summary","type","source","description","examples"]			 
				}).addCallback(dojo.hitch(this,"_setSelf"));
			},
			_setSelf:function(data){
				var out = "";
				dojo.forEach(data,function(d){
					console.log(d);
					if(d.name){
						out += "<h2>" + d.name + " <span class='itemType'>" + d.type +"</span></h2>";
					}
					if(d.summary){
						out += "<div class='summary'>" + d.summary + "</div>";
					}
				});
				this.setContent(out);

			}
			
		});
		
		var togglePane = function(e){
			
				var lp = dijit.byId("leftPane");
				var sel = dojo.byId("easingSelect");
				var o = dojo.getObject("dojox.fx.easing."+sel.value);
			
				lp.easeIn = o;
				lp.easeOut = o;
				lp.duration = parseInt(dojo.byId("durationBox").value) || 1000;
				lp._setupAnims();
				lp.toggle();
		};
		
		var easeSelectionCode = function(){
			var sel = dojo.byId("easingSelect");
			dojo.connect(sel,"onchange",togglePane);
			dojo.connect(dojo.byId("durationBox"),"onchange",togglePane);
			var opt = dojo.query("#easingSelect option")[0];
			for(var i in dojox.fx.easing){
				var n = dojo.clone(opt);
				n.value = i;
				n.innerHTML = i;
				sel.appendChild(n);
			}
		};

		var _clearSearch = function(){
			dojo.query("li","searchResults").forEach(dojo._destroyElement);
		};
		
		var shifter = function(input){
			// convert an array to a object, just that deep
			var last, output;
			last = output = {};
			for(var i = 0; i < input.length; i++){
			  if(i == input.length - 2){
			   last[input[i]] = input[i + 1];
			   break;
			 }
			 last = last[input[i]] = {};
			}
			return output;
		};
		
		var makeTree = function(data){
			var undata = {
				dojo:{}, dijit:{}, dojox:{}
			};
			var items = [];
			dojo.forEach(data,function(item){
				var foo = item.name.split(".");
				foo.push("_meta");
				foo.push(item);
				//var ns = foo.shift();
				var obj = shifter(foo);
				items.push(obj);
			});
			return items;
		};
		
		var runSearch = function(e){
			dijit.byId("centerPane").selectChild(dijit.byId("resultsPane"));
			var val = dojo.byId("searchBox").value;
			var li = dojo.doc.createElement('li');
			_clearSearch();
			li.appendChild(dojo.clone(dojo.query(".cloneNode")[0]));
			dojo.byId("searchResults").appendChild(li);
			searchHistory.push(val);
			api.get({ name:val }).addCallback(function(data){
				var tree = makeTree(data);
		
				_clearSearch();
				
				dojo.forEach(data,function(item){
					console.log(item);
					var list = dojo.byId("")
					var nli = dojo.doc.createElement('li');
					nli.innerHTML = "<div class='inner'>"
						+"<a"+" hre"+"f='#"+ item.name +"'>"+item.name +"</a>"
						+"- <span class='itemType'>"+ item.type +"</span>"
						+"<div class='itty'>"+item.summary+"</div></div>";
					dojo.byId("searchResults").appendChild(nli);
				});
			})
		};

		var searchInteract = function(e){
			e.preventDefault();
			var v;
			if((v = dojo.attr(e.target,"href"))){
				var tabs = dijit.byId("centerPane");
				v = v.replace(/#/g,"");
				var cp = dijit.byId(v);
				if(!cp){
					var cp = new demo.DemoPane({
						title:v,
						closable:true,
						id:v,
						rpc:api
					});
					cp.startup();
					tabs.addChild(cp);
				}
				tabs.selectChild(cp);
			}
		};

		var searchHistory = [];
		var rpc = null;
		var apiData = {};
		var _clone = null;
		var searchCode = function(){
			_clone = dojo.query(".cloneLoading")[0];
			api = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc", "documentation.smd"));
			dojo.connect(dojo.byId("searchBox"),"onchange",runSearch);
			dojo.connect(dojo.byId("runSearchIcon"),"onclick",runSearch);
			dojo.connect(dojo.byId("searchResults"),"onclick",searchInteract);
		}

		dojo.addOnLoad(easeSelectionCode);
		dojo.addOnLoad(searchCode);

	</script>
</head>
<body>
		<div id="bc" style="width:100%; height:100%;" dojoType="dijit.layout.BorderContainer">
			<div id="header" dojoType="dijit.layout.ContentPane" region="top">Dojo Expando Pane Test</div>
			<div dojoType="dojox.layout.ExpandoPane" 
				splitter="true" 
				duration="125" 
				region="left" 
				title="Left Section" 
				id="leftPane" 
				maxWidth="275" 
				style="width: 275px; background: #fafafa;">
				<div dojoType="dijit.layout.TabContainer" attachParent="true" tabPosition="bottom">
					<div dojoType="dijit.layout.ContentPane" title="Search">
						<div class="searchBar">
							<p>
								<span style="float: left;">Search:</span>
								<input id="searchBox" name="searchBox" style="float: left;">
								<span id="runSearchIcon" style="border: none; floast: left; padding: 3px;">
									<img src="../../presentation/resources/icons/next.png" style="height:12px; width:12px;">
								</span>
							</p>
						</div>
						
					</div>
					<div dojoType="dijit.layout.AccordionContainer" title="Panes" style="width:275px;" attachParent="true">
						<div dojoType="dijit.layout.AccordionPane" title="Dojo">
							<ul id="dojoList"></ul>
						</div>
						<div dojoType="dijit.layout.AccordionPane" title="Dijit">
							<ul id="dijitList"></ul>
						</div>
						<div dojoType="dijit.layout.AccordionPane" title="DojoX">
							<ul id="dojoxList"></ul>
						</div>
					</div>
					<div dojoType="dijit.layout.ContentPane" title="Tree View">
						<div dojoType="dojo.data.ItemFileReadStore" jsId="continentStore"
							url="../../../dijit/tests/_data/countries.json"></div>
						<div dojoType="dijit.Tree" store="continentStore" query="{type:'continent'}"
							labelAttr="name" typeAttr="type" label="Toolkit API"></div>
					</div>
				</div>
			</div>
			<div dojoType="dijit.layout.TabContainer" region="center" id="centerPane">
				<div dojoType="dijit.layout.ContentPane" title="tab 1">a</div>
				<div dojoType="dijit.layout.ContentPane" title="tab 2">b</div>
				<div dojoType="dijit.layout.ContentPane" title="Results" id="resultsPane">
					<div class="wrap">
						<div class="searchStuff">
							<ul id="searchResults"></ul>
						</div>
					</div>
				</div>
			</div>
			<div dojoType="dojox.layout.ExpandoPane" 
				splitter="true" 
				title="Right Section" 
				region="right" 
				id="rightPane" 
				maxWidth="275" 
				style="background:#fafafa; width:275px" 
				easeIn="dojox.fx.easing.backOut" 
				easeOut="dojox.fx.easing.backInOut">

				<div dojoType="dijit.layout.AccordionContainer" id="rightAccordion" style="width:275px;" attachParent="true">
					<div dojoType="dijit.layout.AccordionPane" title="Easing Selection">
						<div class="wrap">
							<p>This select modifies the left Expando's easing function. An Expando can have an easeIn and an easeOut parameter. This sets both.</p> 
							<select id="easingSelect" name="easingSelect">
								<option value="dojo._DefaultEasing">Default</option>
							</select>
							<p><label for="durationBox">Duration: </label> <input id="durationBox" name="durationBox" value="1000" /></p>
							<p>Some easing functions break when used with width: (negative width? but how?). <em>Be warned.</em></p>
						</div>
					</div>
					<div dojoType="dijit.layout.AccordionPane" title="Children">
						<div class="wrap">
							<p>This is a BorderContainer (the window). Each of the panes is set to one of
							"left", "right", or "center". The left and right panes are ExpandoPanes (they collapse).
							</p>
							<p>
							We can add other panes programatically:
							<br>
							<button dojoType="dijit.form.Button">
								Add "Bottom"
								<script type="dojo/method" event="onClick">
									// create and startup a new ContentPane
									var cp = new dijit.layout.ContentPane({
										region:"bottom",
										style:"height:65px",
										splitter:"true"
									});
									cp.startup();
									this.setAttribute("disabled",true);
									cp.setHref("_bottomPane.html");
									// add to our borderContainer
									var bc = dijit.byId("bc");
									bc.addChild(cp);
								</script>
							</button>
							</p>
							<p>What does a FloatingPane look like here?<br>
							<button dojoType="dijit.form.Button">
								Make Floater
								<script type="dojo/method" event="onClick">
									var div = dojo.doc.createElement('div');
									dojo.body().appendChild(div);
									var fp = new dojox.layout.FloatingPane({
										title:"A Winder.",
										closeable:true, dockable:false,
										href:"_floating.html"
									},div);
									dojo.style(fp.domNode,{
										width:"350px",
										height:"255px",
										top:"75px", left:"75px",
										position:"absolute",
										zIndex:"980"
									});
									fp.startup();
									fp.show();
								</script>
							</button>
							</p>
						</div>
					</div>
					<div dojoType="dijit.layout.AccordionPane" title="Acc 3">c</div>
				</div>
			</div>
		</div>

		<div class="cloneNode">Loading <img style="width:17px; height:17px" src="../../image/resources/images/loading.gif" alt="progress" /></div>

</body>
</html>