Subversion Repositories Applications.papyrus

Rev

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

Rev Author Line No. Line
2150 mathias 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
		"http://www.w3.org/TR/html4/strict.dtd">
3
<html>
4
<head>
5
 
6
	<title>Test Dijit Internal Event: "ondijitclick"</title>
7
 
8
	<script type="text/javascript" src="../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
9
	<script type="text/javascript">
10
		dojo.require("doh.runner");
11
		dojo.require("dijit._Widget");
12
		dojo.require("dojo.parser");
13
 
14
		dojo.declare("dijit.WidgetWithOndijitclick",
15
			dijit._Widget,
16
			{
17
				clickCount: 0,
18
				_onClick: function() {
19
					this.clickCount++;
20
				},
21
				postCreate: function() {
22
					this.connect(this.domNode, "ondijitclick", "_onClick");
23
				}
24
			}
25
		);
26
 
27
		dojo.addOnLoad(function(){
28
			doh.register("ondijitclick",
29
				[
30
					{
31
						name: "ondijitclick fires once on a space-key-up",
32
						runTest: function(t){
33
							var w = dijit.byId("widget1");
34
							if (dojo.isSafari){ // safari has error
35
								this.name += " * SKIPPED *";
36
								return;
37
							}
38
 
39
							// simulate space up
40
							if (document.createEvent){
41
								var e = document.createEvent("KeyboardEvent");
42
								e.initKeyEvent("keyup",true,true,null,false,false,false,false,32,0);
43
								w.domNode.focus();
44
								w.clickCount = 0;
45
								w.domNode.dispatchEvent(e);
46
								t.is(1, w.clickCount);
47
							}
48
						}
49
					},
50
					{
51
						name: "ondijitclick fires once on an enter-key-down",
52
						runTest: function(t){
53
							var w = dijit.byId("widget1");
54
							if (dojo.isSafari){ // safari has error
55
								this.name += " * SKIPPED *";
56
								return;
57
							}
58
 
59
							// simulate enter down
60
							if (document.createEvent && !dojo.isSafari){
61
								var e = document.createEvent("KeyboardEvent");
62
								e.initKeyEvent("keydown",true,true,null,false,false,false,false,13,0);
63
								w.domNode.focus();
64
								w.clickCount = 0;
65
								w.domNode.dispatchEvent(e);
66
								t.is(1, w.clickCount);
67
							}
68
						}
69
					},
70
					{
71
						name: "ondijitclick fires once on a mouse click",
72
						runTest: function(t){
73
							var w = dijit.byId("widget1");
74
 
75
							// simulate enter up
76
							if (document.createEvent){
77
								var e = document.createEvent("MouseEvents");
78
								e.initMouseEvent('click', true, true, document.defaultView, 1, 0, 0, 3, 3, false, false, false, false, 0, w.domNode);
79
								w.clickCount = 0;
80
								w.domNode.dispatchEvent(e);
81
								t.is(1, w.clickCount);
82
							}
83
						}
84
					}
85
				]
86
			);
87
			doh.run();
88
		});
89
 
90
	</script>
91
</head>
92
<body class="tundra">
93
	<div id="widget1" dojoType="dijit.WidgetWithOndijitclick"></div>
94
</body>
95
</html>