Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
11
dojo.provide("dojo.widget.demoEngine.DemoNavigator");
12
dojo.require("dojo.widget.*");
13
dojo.require("dojo.widget.HtmlWidget");
14
dojo.require("dojo.widget.Button");
15
dojo.require("dojo.widget.demoEngine.DemoItem");
16
dojo.require("dojo.io.*");
17
dojo.require("dojo.lfx.*");
18
dojo.require("dojo.lang.common");
19
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 () {
20
	dojo.html.addClass(this.domNode, this.domNodeClass);
21
	dojo.html.addClass(this.demoListWrapperNode, this.demoListWrapperClass);
22
	dojo.html.addClass(this.demoListContainerNode, this.demoListContainerClass);
23
	if (dojo.render.html.ie) {
24
		dojo.debug("render ie");
25
		dojo.html.hide(this.demoListWrapperNode);
26
	} else {
27
		dojo.debug("render non-ie");
28
		dojo.lfx.html.fadeHide(this.demoListWrapperNode, 0).play();
29
	}
30
	this.getRegistry(this.demoRegistryUrl);
31
	this.demoContainer = dojo.widget.createWidget("DemoContainer", {returnImage:this.returnImage}, this.demoNode);
32
	dojo.event.connect(this.demoContainer, "returnToDemos", this, "returnToDemos");
33
	this.demoContainer.hide();
34
}, returnToDemos:function () {
35
	this.demoContainer.hide();
36
	if (dojo.render.html.ie) {
37
		dojo.debug("render ie");
38
		dojo.html.show(this.navigationContainer);
39
	} else {
40
		dojo.debug("render non-ie");
41
		dojo.lfx.html.fadeShow(this.navigationContainer, 250).play();
42
	}
43
	dojo.lang.forEach(this.categoriesChildren, dojo.lang.hitch(this, function (child) {
44
		child.checkSize();
45
	}));
46
	dojo.lang.forEach(this.demoListChildren, dojo.lang.hitch(this, function (child) {
47
		child.checkSize();
48
	}));
49
}, show:function () {
50
	dojo.html.show(this.domNode);
51
	dojo.html.setOpacity(this.domNode, 1);
52
	dojo.html.setOpacity(this.navigationContainer, 1);
53
	dojo.lang.forEach(this.categoriesChildren, dojo.lang.hitch(this, function (child) {
54
		child.checkSize();
55
	}));
56
	dojo.lang.forEach(this.demoListChildren, dojo.lang.hitch(this, function (child) {
57
		child.checkSize();
58
	}));
59
}, getRegistry:function (url) {
60
	dojo.io.bind({url:url, load:dojo.lang.hitch(this, this.processRegistry), mimetype:"text/json"});
61
}, processRegistry:function (type, registry, e) {
62
	dojo.debug("Processing Registry");
63
	this.registry = registry;
64
	dojo.lang.forEach(this.registry.navigation, dojo.lang.hitch(this, this.addCategory));
65
}, addCategory:function (category) {
66
	var newCat = dojo.widget.createWidget("Button", {caption:category.name});
67
	if (!dojo.lang.isObject(this.registry.categories)) {
68
		this.registry.categories = function () {
69
		};
70
	}
71
	this.registry.categories[category.name] = category;
72
	this.categoriesChildren.push(newCat);
73
	this.categoriesButtonsNode.appendChild(newCat.domNode);
74
	newCat.domNode.categoryName = category.name;
75
	dojo.event.connect(newCat, "onClick", this, "onSelectCategory");
76
}, addDemo:function (demoName) {
77
	var demo = this.registry.definitions[demoName];
78
	if (dojo.render.html.ie) {
79
		dojo.html.show(this.demoListWrapperNode);
80
	} else {
81
		dojo.lfx.html.fadeShow(this.demoListWrapperNode, 250).play();
82
	}
83
	var newDemo = dojo.widget.createWidget("DemoItem", {viewDemoImage:this.viewDemoImage, name:demoName, description:demo.description, thumbnail:demo.thumbnail});
84
	this.demoListChildren.push(newDemo);
85
	this.demoListContainerNode.appendChild(newDemo.domNode);
86
	dojo.event.connect(newDemo, "onSelectDemo", this, "onSelectDemo");
87
}, onSelectCategory:function (e) {
88
	catName = e.currentTarget.categoryName;
89
	dojo.debug("Selected Category: " + catName);
90
	dojo.lang.forEach(this.demoListChildren, function (child) {
91
		child.destroy();
92
	});
93
	this.demoListChildren = [];
94
	dojo.lang.forEach(this.registry.categories[catName].demos, dojo.lang.hitch(this, function (demoName) {
95
		this.addDemo(demoName);
96
	}));
97
}, onSelectDemo:function (e) {
98
	dojo.debug("Demo Selected: " + e.target.name);
99
	if (dojo.render.html.ie) {
100
		dojo.debug("render ie");
101
		dojo.html.hide(this.navigationContainer);
102
		this.demoContainer.show();
103
		this.demoContainer.showDemo();
104
	} else {
105
		dojo.debug("render non-ie");
106
		dojo.lfx.html.fadeHide(this.navigationContainer, 250, null, dojo.lang.hitch(this, function () {
107
			this.demoContainer.show();
108
			this.demoContainer.showDemo();
109
		})).play();
110
	}
111
	this.demoContainer.loadDemo(this.registry.definitions[e.target.name].url);
112
	this.demoContainer.setName(e.target.name);
113
	this.demoContainer.setSummary(this.registry.definitions[e.target.name].description);
114
}}, "", function () {
115
	this.demoRegistryUrl = "demoRegistry.json";
116
	this.registry = function () {
117
	};
118
	this.categoriesNode = "";
119
	this.categoriesButtonsNode = "";
120
	this.navigationContainer = "";
121
	this.domNodeClass = "demoNavigator";
122
	this.demoNode = "";
123
	this.demoContainer = "";
124
	this.demoListWrapperNode = "";
125
	this.demoListWrapperClass = "demoNavigatorListWrapper";
126
	this.demoListContainerClass = "demoNavigatorListContainer";
127
	this.returnImage = "images/dojoDemos.gif";
128
	this.viewDemoImage = "images/viewDemo.png";
129
	this.demoListChildren = [];
130
	this.categoriesChildren = [];
131
});
132