source: Dev/branches/rest-dojo-ui/client/dijit/tests/_Widget-deferredConnect.html @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

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