1318 |
alexandre_ |
1 |
/*
|
|
|
2 |
Copyright (c) 2004-2006, The Dojo Foundation
|
|
|
3 |
All Rights Reserved.
|
|
|
4 |
|
|
|
5 |
Licensed under the Academic Free License version 2.1 or above OR the
|
|
|
6 |
modified BSD license. For more information on Dojo licensing, see:
|
|
|
7 |
|
|
|
8 |
http://dojotoolkit.org/community/licensing.shtml
|
|
|
9 |
*/
|
|
|
10 |
|
1422 |
alexandre_ |
11 |
|
|
|
12 |
|
1318 |
alexandre_ |
13 |
dojo.provide("dojo.widget.demoEngine.DemoNavigator");
|
|
|
14 |
dojo.require("dojo.widget.*");
|
|
|
15 |
dojo.require("dojo.widget.HtmlWidget");
|
|
|
16 |
dojo.require("dojo.widget.Button");
|
|
|
17 |
dojo.require("dojo.widget.demoEngine.DemoItem");
|
|
|
18 |
dojo.require("dojo.io.*");
|
|
|
19 |
dojo.require("dojo.lfx.*");
|
|
|
20 |
dojo.require("dojo.lang.common");
|
|
|
21 |
dojo.widget.defineWidget("my.widget.demoEngine.DemoNavigator", dojo.widget.HtmlWidget, {templateString:"<div dojoAttachPoint=\"domNode\">\n\t<table width=\"100%\" cellspacing=\"0\" cellpadding=\"5\">\n\t\t<tbody>\n\t\t\t<tr dojoAttachPoint=\"navigationContainer\">\n\t\t\t\t<td dojoAttachPoint=\"categoriesNode\" valign=\"top\" width=\"1%\">\n\t\t\t\t\t<h1>Categories</h1>\n\t\t\t\t\t<div dojoAttachPoint=\"categoriesButtonsNode\"></div>\n\t\t\t\t</td>\n\n\t\t\t\t<td dojoAttachPoint=\"demoListNode\" valign=\"top\">\n\t\t\t\t\t<div dojoAttachPoint=\"demoListWrapperNode\">\n\t\t\t\t\t\t<div dojoAttachPoint=\"demoListContainerNode\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan=\"2\">\n\t\t\t\t\t<div dojoAttachPoint=\"demoNode\"></div>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n", templateCssString:".demoNavigatorListWrapper {\n\tborder:1px solid #dcdbdb;\n\tbackground-color:#f8f8f8;\n\tpadding:2px;\n}\n\n.demoNavigatorListContainer {\n\tborder:1px solid #f0f0f0;\n\tbackground-color:#fff;\n\tpadding:1em;\n}\n\n.demoNavigator h1 {\n\tmargin-top: 0px;\n\tmargin-bottom: 10px;\n\tfont-size: 1.2em;\n\tborder-bottom:1px dotted #a9ccf5;\n}\n\n.demoNavigator .dojoButton {\n\tmargin-bottom: 5px;\n}\n\n.demoNavigator .dojoButton .dojoButtonContents {\n\tfont-size: 1.1em;\n\twidth: 100px;\n\tcolor: black;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "demoEngine/templates/DemoNavigator.css"), postCreate:function () {
|
|
|
22 |
dojo.html.addClass(this.domNode, this.domNodeClass);
|
|
|
23 |
dojo.html.addClass(this.demoListWrapperNode, this.demoListWrapperClass);
|
|
|
24 |
dojo.html.addClass(this.demoListContainerNode, this.demoListContainerClass);
|
|
|
25 |
if (dojo.render.html.ie) {
|
|
|
26 |
dojo.debug("render ie");
|
|
|
27 |
dojo.html.hide(this.demoListWrapperNode);
|
|
|
28 |
} else {
|
|
|
29 |
dojo.debug("render non-ie");
|
|
|
30 |
dojo.lfx.html.fadeHide(this.demoListWrapperNode, 0).play();
|
|
|
31 |
}
|
|
|
32 |
this.getRegistry(this.demoRegistryUrl);
|
|
|
33 |
this.demoContainer = dojo.widget.createWidget("DemoContainer", {returnImage:this.returnImage}, this.demoNode);
|
|
|
34 |
dojo.event.connect(this.demoContainer, "returnToDemos", this, "returnToDemos");
|
|
|
35 |
this.demoContainer.hide();
|
|
|
36 |
}, returnToDemos:function () {
|
|
|
37 |
this.demoContainer.hide();
|
|
|
38 |
if (dojo.render.html.ie) {
|
|
|
39 |
dojo.debug("render ie");
|
|
|
40 |
dojo.html.show(this.navigationContainer);
|
|
|
41 |
} else {
|
|
|
42 |
dojo.debug("render non-ie");
|
|
|
43 |
dojo.lfx.html.fadeShow(this.navigationContainer, 250).play();
|
|
|
44 |
}
|
|
|
45 |
dojo.lang.forEach(this.categoriesChildren, dojo.lang.hitch(this, function (child) {
|
|
|
46 |
child.checkSize();
|
|
|
47 |
}));
|
|
|
48 |
dojo.lang.forEach(this.demoListChildren, dojo.lang.hitch(this, function (child) {
|
|
|
49 |
child.checkSize();
|
|
|
50 |
}));
|
|
|
51 |
}, show:function () {
|
|
|
52 |
dojo.html.show(this.domNode);
|
|
|
53 |
dojo.html.setOpacity(this.domNode, 1);
|
|
|
54 |
dojo.html.setOpacity(this.navigationContainer, 1);
|
|
|
55 |
dojo.lang.forEach(this.categoriesChildren, dojo.lang.hitch(this, function (child) {
|
|
|
56 |
child.checkSize();
|
|
|
57 |
}));
|
|
|
58 |
dojo.lang.forEach(this.demoListChildren, dojo.lang.hitch(this, function (child) {
|
|
|
59 |
child.checkSize();
|
|
|
60 |
}));
|
|
|
61 |
}, getRegistry:function (url) {
|
|
|
62 |
dojo.io.bind({url:url, load:dojo.lang.hitch(this, this.processRegistry), mimetype:"text/json"});
|
|
|
63 |
}, processRegistry:function (type, registry, e) {
|
|
|
64 |
dojo.debug("Processing Registry");
|
|
|
65 |
this.registry = registry;
|
|
|
66 |
dojo.lang.forEach(this.registry.navigation, dojo.lang.hitch(this, this.addCategory));
|
|
|
67 |
}, addCategory:function (category) {
|
|
|
68 |
var newCat = dojo.widget.createWidget("Button", {caption:category.name});
|
|
|
69 |
if (!dojo.lang.isObject(this.registry.categories)) {
|
|
|
70 |
this.registry.categories = function () {
|
|
|
71 |
};
|
|
|
72 |
}
|
|
|
73 |
this.registry.categories[category.name] = category;
|
|
|
74 |
this.categoriesChildren.push(newCat);
|
|
|
75 |
this.categoriesButtonsNode.appendChild(newCat.domNode);
|
|
|
76 |
newCat.domNode.categoryName = category.name;
|
|
|
77 |
dojo.event.connect(newCat, "onClick", this, "onSelectCategory");
|
|
|
78 |
}, addDemo:function (demoName) {
|
|
|
79 |
var demo = this.registry.definitions[demoName];
|
|
|
80 |
if (dojo.render.html.ie) {
|
|
|
81 |
dojo.html.show(this.demoListWrapperNode);
|
|
|
82 |
} else {
|
|
|
83 |
dojo.lfx.html.fadeShow(this.demoListWrapperNode, 250).play();
|
|
|
84 |
}
|
|
|
85 |
var newDemo = dojo.widget.createWidget("DemoItem", {viewDemoImage:this.viewDemoImage, name:demoName, description:demo.description, thumbnail:demo.thumbnail});
|
|
|
86 |
this.demoListChildren.push(newDemo);
|
|
|
87 |
this.demoListContainerNode.appendChild(newDemo.domNode);
|
|
|
88 |
dojo.event.connect(newDemo, "onSelectDemo", this, "onSelectDemo");
|
|
|
89 |
}, onSelectCategory:function (e) {
|
|
|
90 |
catName = e.currentTarget.categoryName;
|
|
|
91 |
dojo.debug("Selected Category: " + catName);
|
|
|
92 |
dojo.lang.forEach(this.demoListChildren, function (child) {
|
|
|
93 |
child.destroy();
|
|
|
94 |
});
|
|
|
95 |
this.demoListChildren = [];
|
|
|
96 |
dojo.lang.forEach(this.registry.categories[catName].demos, dojo.lang.hitch(this, function (demoName) {
|
|
|
97 |
this.addDemo(demoName);
|
|
|
98 |
}));
|
|
|
99 |
}, onSelectDemo:function (e) {
|
|
|
100 |
dojo.debug("Demo Selected: " + e.target.name);
|
|
|
101 |
if (dojo.render.html.ie) {
|
|
|
102 |
dojo.debug("render ie");
|
|
|
103 |
dojo.html.hide(this.navigationContainer);
|
|
|
104 |
this.demoContainer.show();
|
|
|
105 |
this.demoContainer.showDemo();
|
|
|
106 |
} else {
|
|
|
107 |
dojo.debug("render non-ie");
|
|
|
108 |
dojo.lfx.html.fadeHide(this.navigationContainer, 250, null, dojo.lang.hitch(this, function () {
|
|
|
109 |
this.demoContainer.show();
|
|
|
110 |
this.demoContainer.showDemo();
|
|
|
111 |
})).play();
|
|
|
112 |
}
|
|
|
113 |
this.demoContainer.loadDemo(this.registry.definitions[e.target.name].url);
|
|
|
114 |
this.demoContainer.setName(e.target.name);
|
|
|
115 |
this.demoContainer.setSummary(this.registry.definitions[e.target.name].description);
|
|
|
116 |
}}, "", function () {
|
|
|
117 |
this.demoRegistryUrl = "demoRegistry.json";
|
|
|
118 |
this.registry = function () {
|
|
|
119 |
};
|
|
|
120 |
this.categoriesNode = "";
|
|
|
121 |
this.categoriesButtonsNode = "";
|
|
|
122 |
this.navigationContainer = "";
|
|
|
123 |
this.domNodeClass = "demoNavigator";
|
|
|
124 |
this.demoNode = "";
|
|
|
125 |
this.demoContainer = "";
|
|
|
126 |
this.demoListWrapperNode = "";
|
|
|
127 |
this.demoListWrapperClass = "demoNavigatorListWrapper";
|
|
|
128 |
this.demoListContainerClass = "demoNavigatorListContainer";
|
|
|
129 |
this.returnImage = "images/dojoDemos.gif";
|
|
|
130 |
this.viewDemoImage = "images/viewDemo.png";
|
|
|
131 |
this.demoListChildren = [];
|
|
|
132 |
this.categoriesChildren = [];
|
|
|
133 |
});
|
|
|
134 |
|