-
Notifications
You must be signed in to change notification settings - Fork 186
/
Copy path_Widget-deferredConnect.html
81 lines (72 loc) · 2.36 KB
/
_Widget-deferredConnect.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>_Widget deferred connection test</title>
<style type="text/css">
@import "../themes/claro/document.css";
@import "../themes/claro/claro.css";
@import "css/dijitTests.css";
</style>
<script type="text/javascript" src="../../dojo/dojo.js"
data-dojo-config="isDebug: true, parseOnLoad: true"></script>
<script>
dojo.require("dojo.parser");
dojo.require("dijit.form.Button");
overrodeMouseMoved = false;
bothOverrodeMouseMoved = false;
connectedMouseMoved = false;
bothConnectedMouseMoved = false;
function bothHandler(){
if(!bothOverrodeMouseMoved){
console.log("'both' button: overrode handler called");
}
bothOverrodeMouseMoved = true;
}
dojo.ready(function(){
dojo.connect(dijit.byId("connect"), "onMouseMove", function(){
if(!connectedMouseMoved){
console.log("'connect' button: mouse moved");
}
connectedMouseMoved = true;
});
dojo.connect(dijit.byId("both"), "onMouseMove", function(){
if(!bothConnectedMouseMoved){
console.log("'both' button: connected handler");
}
bothConnectedMouseMoved = true;
});
});
</script>
</head>
<body class="claro">
<h1>Test deferred connections</h1>
<p>
OnMouseMove is a deferred connection, _Widget only call dojo.connect()
(data-dojo-attach-event) to connect the onmousemove event on the focusNode to
the widget method if needed.
</p>
<p>
Mousing over the three buttons below should call the user-defined mouse-move
handlers. The "both" button has two handlers, and they should both be called.
</p>
<!--
"overrode" button specifies an onmousemove handler on initialization.
-->
<button id="overrode" data-dojo-type="dijit/form/Button"
data-dojo-props='onMouseMove:function(){ if(!overrodeMouseMoved){ console.log("\"overrode\" button: mouse moved"); } overrodeMouseMoved = true; }'>
overrode
</button>
<!--
"connect" button essentially is doing a dojo.connect("connect", "onMouseMove", myFunc).
This should trigger an additional dojo.connect() call from Button.focusNode.onmousemove
to the Button.onMouseMove empty function.
-->
<button id="connect" data-dojo-type="dijit/form/Button">
connected
</button>
<button id="both" data-dojo-type="dijit/form/Button" data-dojo-props='onMouseMove:bothHandler'>
both
</button>
</body>
</html>