Blame | Last modification | View Log | RSS feed
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test Dijit Internal Event: "ondijitclick"</title>
<script type="text/javascript" src="../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("doh.runner");
dojo.require("dijit._Widget");
dojo.require("dojo.parser");
dojo.declare("dijit.WidgetWithOndijitclick",
dijit._Widget,
{
clickCount: 0,
_onClick: function() {
this.clickCount++;
},
postCreate: function() {
this.connect(this.domNode, "ondijitclick", "_onClick");
}
}
);
dojo.addOnLoad(function(){
doh.register("ondijitclick",
[
{
name: "ondijitclick fires once on a space-key-up",
runTest: function(t){
var w = dijit.byId("widget1");
if (dojo.isSafari){ // safari has error
this.name += " * SKIPPED *";
return;
}
// simulate space up
if (document.createEvent){
var e = document.createEvent("KeyboardEvent");
e.initKeyEvent("keyup",true,true,null,false,false,false,false,32,0);
w.domNode.focus();
w.clickCount = 0;
w.domNode.dispatchEvent(e);
t.is(1, w.clickCount);
}
}
},
{
name: "ondijitclick fires once on an enter-key-down",
runTest: function(t){
var w = dijit.byId("widget1");
if (dojo.isSafari){ // safari has error
this.name += " * SKIPPED *";
return;
}
// simulate enter down
if (document.createEvent && !dojo.isSafari){
var e = document.createEvent("KeyboardEvent");
e.initKeyEvent("keydown",true,true,null,false,false,false,false,13,0);
w.domNode.focus();
w.clickCount = 0;
w.domNode.dispatchEvent(e);
t.is(1, w.clickCount);
}
}
},
{
name: "ondijitclick fires once on a mouse click",
runTest: function(t){
var w = dijit.byId("widget1");
// simulate enter up
if (document.createEvent){
var e = document.createEvent("MouseEvents");
e.initMouseEvent('click', true, true, document.defaultView, 1, 0, 0, 3, 3, false, false, false, false, 0, w.domNode);
w.clickCount = 0;
w.domNode.dispatchEvent(e);
t.is(1, w.clickCount);
}
}
}
]
);
doh.run();
});
</script>
</head>
<body class="tundra">
<div id="widget1" dojoType="dijit.WidgetWithOndijitclick"></div>
</body>
</html>