Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
<html>
2
	<head>
3
		<title>testing widgetsInTemplate support</title>
4
		<script type="text/javascript" src="../../dojo/dojo.js"
5
			djConfig="parseOnLoad: true, isDebug: true"></script>
6
		<script type="text/javascript">
7
			dojo.require("doh.runner");
8
 
9
			dojo.require("dijit.form.Button");
10
			dojo.require("dijit.form.CheckBox");
11
			dojo.require("dijit.ProgressBar");
12
 
13
			dojo.addOnLoad(function(){
14
				var testW;
15
				doh.register("t",
16
					[
17
						{
18
							name: "dojoAttachPoint",
19
							runTest: function(t){
20
								var testW = dijit.byId("test1Widget");
21
								t.t(testW.normalNode);
22
								t.f(isNaN(testW.normalNode.nodeType));
23
								t.t(testW.buttonWidget instanceof dijit.form.Button);
24
								t.t(testW.checkboxWidget instanceof dijit.form.CheckBox);
25
								t.t(testW.progressBarWidget instanceof dijit.ProgressBar);
26
//								alert((testW.buttonWidget instanceof dijit.form.Button)+(testW.checkboxWidget instanceof dijit.form.CheckBox)+(testW.progressBarWidget instanceof dijit.ProgressBar)+
27
//								(testW.buttonWidget._counter==1)+(testW.checkboxWidget._counter==1)+(testW.progressBarWidget._counter==1));
28
								testW = dijit.byId("test2Widget");
29
								t.t(testW.containerNode);
30
								t.f(isNaN(testW.containerNode.nodeType));
31
								t.is(undefined,testW.buttonWidget);
32
								t.t(testW.checkboxWidget instanceof dijit.form.CheckBox);
33
							}
34
						},
35
						{
36
							name: "dojoAttachEvent",
37
							runTest: function(t){
38
								var testW = dijit.byId("test1Widget");
39
								testW.buttonWidget._counter=0;
40
								testW.buttonWidget.onClick(testW.buttonWidget);
41
								testW.checkboxWidget._counter=0;
42
								testW.checkboxWidget.onClick(testW.checkboxWidget);
43
								testW.progressBarWidget._counter=0;
44
								testW.progressBarWidget.onChange(testW.progressBarWidget);
45
								t.is(1,testW.buttonWidget._counter);
46
								t.is(1,testW.checkboxWidget._counter);
47
								t.is(1,testW.progressBarWidget._counter);
48
							}
49
						}
50
					]
51
				);
52
				doh.run();
53
			});
54
		</script>
55
	<style type="text/css">
56
		@import "../themes/tundra/tundra.css";
57
	</style>
58
	</head>
59
	<body>
60
		<h1>testing widgetsInTemplate support</h1>
61
		<xmp id="Test1Template" style="display:none;">
62
			<div>
63
				<div dojoAttachPoint="normalNode" >normal node</div>
64
				<button dojoAttachPoint="buttonWidget" dojoAttachEvent="onClick:onClick" dojoType="dijit.form.Button">button #1</button>
65
				<div dojoAttachPoint="checkboxWidget" dojoAttachEvent="onClick:onClick" dojoType="dijit.form.CheckBox"></div> checkbox #1
66
				<div dojoAttachPoint="progressBarWidget" dojoAttachEvent="onChange:onClick" style="width:400px" annotate="true"
67
					maximum="200" progress="20" dojoType="dijit.ProgressBar"></div>
68
			</div>
69
		</xmp>
70
		<script>
71
			dojo.declare('Test1Widget',
72
				[dijit._Widget, dijit._Templated],
73
			{
74
				widgetsInTemplate: true,
75
		//		isContainer: true,
76
 
77
				templateString: dojo.byId('Test1Template').textContent || dojo.byId('Test1Template').innerText,
78
				onClick: function(e){
79
					if(e.target){
80
						alert('onClick widgetId='+e.target.id);
81
					}else{
82
						if(e._counter == undefined){
83
							e._counter = 1;
84
						}else{
85
							e._counter++;
86
						}
87
					}
88
				}
89
			});
90
		</script>
91
	<!-- can use widget immediately in markup - no parsing occurs until document loaded and scripts run -->
92
	<div dojoType="Test1Widget" id="test1Widget" ></div>
93
 
94
 
95
	<xmp id="Test2Template" style="display:none;">
96
		<div>
97
			<div dojoAttachPoint="containerNode" ><div dojoAttachPoint="checkboxWidget" dojoType="dijit.form.CheckBox"></div> checkbox #2</div>
98
		</div>
99
	</xmp>
100
		<script>
101
			dojo.declare('Test2Widget',
102
				[dijit._Widget, dijit._Templated],
103
			{
104
				widgetsInTemplate: true,
105
 
106
				templateString: dojo.byId('Test2Template').textContent || dojo.byId('Test2Template').innerText
107
			});
108
		</script>
109
	<div dojoType="Test2Widget" id="test2Widget" ><button dojoAttachPoint="buttonWidget" dojoType="dijit.form.Button">button #2</button></div>
110
	</body>
111
</html>
112