| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<title>dojox.layout.ExpandoPane</title> |
| 5 |
|
| 6 |
|
| 7 |
<link rel="stylesheet" id="themeStyles" href="../../../dijit/themes/claro/claro.css"> |
| 8 |
|
| 9 |
<link rel="stylesheet" href="_expando.css"> |
| 10 |
|
| 11 |
|
| 12 |
<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug:true, parseOnLoad: true, popup:true"></script> |
| 13 |
|
| 14 |
|
| 15 |
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script> |
| 16 |
|
| 17 |
<script type="text/javascript"> |
| 18 |
dojo.require("dojox.layout.ExpandoPane"); |
| 19 |
dojo.require("dojo.data.ItemFileReadStore"); |
| 20 |
dojo.require("dijit.form.ComboBox"); |
| 21 |
dojo.require("dijit.Tree"); |
| 22 |
dojo.require("dijit.layout.AccordionContainer"); |
| 23 |
dojo.require("dijit.layout.TabContainer"); |
| 24 |
dojo.require("dijit.layout.ContentPane"); |
| 25 |
dojo.require("dijit.layout.BorderContainer"); |
| 26 |
dojo.require("dojox.layout.FloatingPane"); |
| 27 |
dojo.require("dojo.fx.easing"); |
| 28 |
dojo.require("dojox.rpc.Service"); |
| 29 |
dojo.require("dojo.io.script"); |
| 30 |
</script> |
| 31 |
|
| 32 |
<script type="text/javascript"> |
| 33 |
dojo.declare("demo.DemoPane",dijit.layout.ContentPane,{ |
| 34 |
|
| 35 |
startup: function(){ |
| 36 |
this.inherited(arguments); |
| 37 |
this.rpc.get({ name: this.title, |
| 38 |
attributes:["summary","type","source","description","examples"] |
| 39 |
}).addCallback(dojo.hitch(this,"_setSelf")); |
| 40 |
}, |
| 41 |
_setSelf:function(data){ |
| 42 |
var out = ""; |
| 43 |
dojo.forEach(data,function(d){ |
| 44 |
console.log(d); |
| 45 |
if(d.name){ |
| 46 |
out += "<h2>" + d.name + " <span class='itemType'>" + d.type +"</span></h2>"; |
| 47 |
} |
| 48 |
if(d.summary){ |
| 49 |
out += "<div class='summary'>" + d.summary + "</div>"; |
| 50 |
} |
| 51 |
}); |
| 52 |
this.setContent(out); |
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
}); |
| 57 |
|
| 58 |
var togglePane = function(e){ |
| 59 |
|
| 60 |
var lp = dijit.byId("leftPane"); |
| 61 |
var sel = dojo.byId("easingSelect"); |
| 62 |
var o = dojo.getObject("dojo.fx.easing."+sel.value); |
| 63 |
|
| 64 |
lp.easeIn = o; |
| 65 |
lp.easeOut = o; |
| 66 |
lp.duration = parseInt(dojo.byId("durationBox").value) || 1000; |
| 67 |
lp._setupAnims(); |
| 68 |
lp.toggle(); |
| 69 |
}; |
| 70 |
|
| 71 |
var easeSelectionCode = function(){ |
| 72 |
var sel = dojo.byId("easingSelect"); |
| 73 |
dojo.connect(sel,"onchange",togglePane); |
| 74 |
dojo.connect(dojo.byId("durationBox"),"onchange",togglePane); |
| 75 |
var opt = dojo.query("#easingSelect option")[0]; |
| 76 |
for(var i in dojo.fx.easing){ |
| 77 |
var n = dojo.clone(opt); |
| 78 |
n.value = i; |
| 79 |
n.innerHTML = i; |
| 80 |
sel.appendChild(n); |
| 81 |
} |
| 82 |
}; |
| 83 |
|
| 84 |
var _clearSearch = function(){ |
| 85 |
dojo.query("li","searchResults").forEach(dojo.destroy); |
| 86 |
}; |
| 87 |
|
| 88 |
var shifter = function(input){ |
| 89 |
// convert an array to a object, just that deep |
| 90 |
var last, output; |
| 91 |
last = output = {}; |
| 92 |
for(var i = 0; i < input.length; i++){ |
| 93 |
if(i == input.length - 2){ |
| 94 |
last[input[i]] = input[i + 1]; |
| 95 |
break; |
| 96 |
} |
| 97 |
last = last[input[i]] = {}; |
| 98 |
} |
| 99 |
return output; |
| 100 |
}; |
| 101 |
|
| 102 |
var makeTree = function(data){ |
| 103 |
var undata = { |
| 104 |
dojo:{}, dijit:{}, dojox:{} |
| 105 |
}; |
| 106 |
var items = []; |
| 107 |
dojo.forEach(data,function(item){ |
| 108 |
var foo = item.name.split("."); |
| 109 |
foo.push("_meta"); |
| 110 |
foo.push(item); |
| 111 |
//var ns = foo.shift(); |
| 112 |
var obj = shifter(foo); |
| 113 |
items.push(obj); |
| 114 |
}); |
| 115 |
return items; |
| 116 |
}; |
| 117 |
|
| 118 |
var runSearch = function(e){ |
| 119 |
dijit.byId("centerPane").selectChild(dijit.byId("resultsPane")); |
| 120 |
var val = dojo.byId("searchBox").value; |
| 121 |
var li = dojo.doc.createElement('li'); |
| 122 |
_clearSearch(); |
| 123 |
li.appendChild(dojo.clone(dojo.query(".cloneNode")[0])); |
| 124 |
dojo.byId("searchResults").appendChild(li); |
| 125 |
searchHistory.push(val); |
| 126 |
api.get({ name:val }).addCallback(function(data){ |
| 127 |
var tree = makeTree(data); |
| 128 |
|
| 129 |
_clearSearch(); |
| 130 |
|
| 131 |
dojo.forEach(data,function(item){ |
| 132 |
console.log(item); |
| 133 |
var list = dojo.byId("") |
| 134 |
var nli = dojo.doc.createElement('li'); |
| 135 |
nli.innerHTML = "<div class='inner'>" |
| 136 |
+"<a"+" hre"+"f='#"+ item.name +"'>"+item.name +"</a>" |
| 137 |
+"- <span class='itemType'>"+ item.type +"</span>" |
| 138 |
+"<div class='itty'>"+item.summary+"</div></div>"; |
| 139 |
dojo.byId("searchResults").appendChild(nli); |
| 140 |
}); |
| 141 |
}) |
| 142 |
}; |
| 143 |
|
| 144 |
var searchInteract = function(e){ |
| 145 |
e.preventDefault(); |
| 146 |
var v; |
| 147 |
if((v = dojo.attr(e.target,"href"))){ |
| 148 |
var tabs = dijit.byId("centerPane"); |
| 149 |
v = v.replace(/#/g,""); |
| 150 |
var cp = dijit.byId(v); |
| 151 |
if(!cp){ |
| 152 |
var cp = new demo.DemoPane({ |
| 153 |
title:v, |
| 154 |
closable:true, |
| 155 |
id:v, |
| 156 |
rpc:api |
| 157 |
}); |
| 158 |
cp.startup(); |
| 159 |
tabs.addChild(cp); |
| 160 |
} |
| 161 |
tabs.selectChild(cp); |
| 162 |
} |
| 163 |
}; |
| 164 |
|
| 165 |
var searchHistory = []; |
| 166 |
var rpc = null; |
| 167 |
var apiData = {}; |
| 168 |
var _clone = null; |
| 169 |
var searchCode = function(){ |
| 170 |
_clone = dojo.query(".cloneLoading")[0]; |
| 171 |
api = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc", "SMDLibrary/dojo-api.smd")); |
| 172 |
dojo.connect(dojo.byId("searchBox"),"onchange",runSearch); |
| 173 |
dojo.connect(dojo.byId("runSearchIcon"),"onclick",runSearch); |
| 174 |
dojo.connect(dojo.byId("searchResults"),"onclick",searchInteract); |
| 175 |
} |
| 176 |
|
| 177 |
dojo.addOnLoad(easeSelectionCode); |
| 178 |
dojo.addOnLoad(searchCode); |
| 179 |
|
| 180 |
</script> |
| 181 |
</head> |
| 182 |
<body class="claro" role="main"> |
| 183 |
<div id="bc" style="width:100%; height:100%; padding: 5px;" dojoType="dijit.layout.BorderContainer"> |
| 184 |
<div id="header" dojoType="dijit.layout.ContentPane" region="top" splitter="true">Dojo Expando Pane Test</div> |
| 185 |
<div dojoType="dojox.layout.ExpandoPane" |
| 186 |
splitter="true" |
| 187 |
duration="125" |
| 188 |
region="left" |
| 189 |
title="Left Section" |
| 190 |
previewOnDblClick="true" |
| 191 |
id="leftPane" |
| 192 |
maxWidth="275" |
| 193 |
style="width: 275px;"> |
| 194 |
<div dojoType="dijit.layout.TabContainer" attachParent="true" tabPosition="bottom" tabStrip="true"> |
| 195 |
<div dojoType="dijit.layout.ContentPane" title="Search"> |
| 196 |
<div class="searchBar"> |
| 197 |
<p> |
| 198 |
<label for="searchBox" style="float: left;">Search:</label> |
| 199 |
<input id="searchBox" name="searchBox" style="float: left;"> |
| 200 |
<span id="runSearchIcon" style="border: none; floast: left; padding: 3px;"> |
| 201 |
<img src="../../presentation/resources/icons/next.png" alt="run search" style="height:12px; width:12px;"> |
| 202 |
</span> |
| 203 |
</p> |
| 204 |
</div> |
| 205 |
|
| 206 |
</div> |
| 207 |
<div dojoType="dijit.layout.AccordionContainer" title="Panes" style="width:275px;" attachParent="true"> |
| 208 |
<div dojoType="dijit.layout.ContentPane" title="Dojo"> |
| 209 |
<ul id="dojoList"></ul> |
| 210 |
</div> |
| 211 |
<div dojoType="dijit.layout.ContentPane" title="Dijit"> |
| 212 |
<ul id="dijitList"></ul> |
| 213 |
</div> |
| 214 |
<div dojoType="dijit.layout.ContentPane" title="DojoX"> |
| 215 |
<ul id="dojoxList"></ul> |
| 216 |
</div> |
| 217 |
</div> |
| 218 |
<div dojoType="dijit.layout.ContentPane" title="Tree View"> |
| 219 |
<div dojoType="dojo.data.ItemFileReadStore" data-dojo-id="continentStore" |
| 220 |
url="../../../dijit/tests/_data/countries.json"></div> |
| 221 |
<div dojoType="dijit.Tree" store="continentStore" query="{type:'continent'}" |
| 222 |
labelAttr="name" typeAttr="type" label="Toolkit API"></div> |
| 223 |
</div> |
| 224 |
</div> |
| 225 |
</div> |
| 226 |
<div dojoType="dijit.layout.TabContainer" region="center" id="centerPane" tabStrip="true"> |
| 227 |
<div dojoType="dijit.layout.ContentPane" title="tab 1">a</div> |
| 228 |
<div dojoType="dijit.layout.ContentPane" title="tab 2"> |
| 229 |
<button dojoType="dijit.form.Button">Preview left |
| 230 |
<script type="dojo/method" data-dojo-event="onClick"> |
| 231 |
dijit.byId("leftPane").preview(); |
| 232 |
</script> |
| 233 |
</button> |
| 234 |
</div> |
| 235 |
<div dojoType="dijit.layout.ContentPane" title="Results" id="resultsPane"> |
| 236 |
<div class="wrap"> |
| 237 |
<div class="searchStuff"> |
| 238 |
<ul id="searchResults"></ul> |
| 239 |
</div> |
| 240 |
</div> |
| 241 |
</div> |
| 242 |
</div> |
| 243 |
<div dojoType="dojox.layout.ExpandoPane" |
| 244 |
splitter="true" |
| 245 |
title="Right Section" |
| 246 |
region="right" |
| 247 |
id="rightPane" |
| 248 |
maxWidth="275" |
| 249 |
style="width:275px" |
| 250 |
easeIn="dojo.fx.easing.backOut" |
| 251 |
easeOut="dojo.fx.easing.backInOut"> |
| 252 |
|
| 253 |
<div dojoType="dijit.layout.AccordionContainer" id="rightAccordion" style="width:275px;" attachParent="true"> |
| 254 |
<div dojoType="dijit.layout.ContentPane" title="Easing Selection"> |
| 255 |
<div class="wrap"> |
| 256 |
<p id="easingSelectLabel">This select modifies the left Expando's easing function. An Expando can have an easeIn and an easeOut parameter. This sets both.</p> |
| 257 |
<select id="easingSelect" name="easingSelect" aria-labelledby="easingSelectLabel"> |
| 258 |
<option value="dojo._DefaultEasing">Default</option> |
| 259 |
</select> |
| 260 |
<p><label for="durationBox">Duration: </label> <input id="durationBox" name="durationBox" value="1000" /></p> |
| 261 |
<p>Some easing functions break when used with width: (negative width? but how?). <em>Be warned.</em></p> |
| 262 |
</div> |
| 263 |
</div> |
| 264 |
<div dojoType="dijit.layout.ContentPane" title="Children"> |
| 265 |
<div class="wrap"> |
| 266 |
<p>This is a BorderContainer (the window). Each of the panes is set to one of |
| 267 |
"left", "right", or "center". The left and right panes are ExpandoPanes (they collapse). |
| 268 |
</p> |
| 269 |
<p>What does a FloatingPane look like here?</p> |
| 270 |
<p> |
| 271 |
<button dojoType="dijit.form.Button"> |
| 272 |
Make Floater |
| 273 |
<script type="dojo/connect" data-dojo-event="onClick"> |
| 274 |
var div = dojo.doc.createElement('div'); |
| 275 |
dojo.body().appendChild(div); |
| 276 |
var fp = new dojox.layout.FloatingPane({ |
| 277 |
title:"A Winder.", |
| 278 |
closeable:true, dockable:false, |
| 279 |
href:"_floating.html" |
| 280 |
},div); |
| 281 |
dojo.style(fp.domNode,{ |
| 282 |
width:"350px", |
| 283 |
height:"255px", |
| 284 |
top:"75px", left:"75px", |
| 285 |
position:"absolute", |
| 286 |
zIndex:"980" |
| 287 |
}); |
| 288 |
fp.startup(); |
| 289 |
fp.show(); |
| 290 |
</script> |
| 291 |
</button> |
| 292 |
</p> |
| 293 |
<p>the end</p> |
| 294 |
</div> |
| 295 |
</div> |
| 296 |
<div dojoType="dijit.layout.ContentPane" title="Acc 3">c</div> |
| 297 |
</div> |
| 298 |
</div> |
| 299 |
<div dojoType="dojox.layout.ExpandoPane" |
| 300 |
splitter="true" |
| 301 |
duration="125" |
| 302 |
region="bottom" |
| 303 |
title="Bottom Section" |
| 304 |
id="bottomPane" |
| 305 |
maxWidth="275" |
| 306 |
style="height: 100px;"> |
| 307 |
<div dojoType="dijit.layout.TabContainer" attachParent="true" tabPosition="bottom" tabStrip="true"> |
| 308 |
<div dojoType="dijit.layout.ContentPane" title="Search"> |
| 309 |
<button dojoType="dijit.form.Button"> |
| 310 |
Change Title |
| 311 |
<script type="dojo/method" data-dojo-event="onClick"> |
| 312 |
dijit.byId("bottomPane").set("title", new Date()) |
| 313 |
</script> |
| 314 |
</button> |
| 315 |
</div> |
| 316 |
<div dojoType="dijit.layout.AccordionContainer" title="Panes" style="width:275px;" attachParent="true"> |
| 317 |
|
| 318 |
</div> |
| 319 |
<div dojoType="dijit.layout.ContentPane" title="Tree View"> |
| 320 |
|
| 321 |
</div> |
| 322 |
</div> |
| 323 |
</div> |
| 324 |
</div> |
| 325 |
|
| 326 |
<div class="cloneNode">Loading <img style="width:17px; height:17px" src="../../image/resources/images/loading.gif" alt="progress" /></div> |
| 327 |
|
| 328 |
</body> |
| 329 |
</html> |