]>
Commit | Line | Data |
---|---|---|
f0cfe83e AD |
1 | define("dijit/_OnDijitClickMixin", [ |
2 | "dojo/on", | |
3 | "dojo/_base/array", // array.forEach | |
4 | "dojo/keys", // keys.ENTER keys.SPACE | |
5 | "dojo/_base/declare", // declare | |
6 | "dojo/has", // has("dom-addeventlistener") | |
7 | "dojo/_base/unload", // unload.addOnWindowUnload | |
8 | "dojo/_base/window", // win.doc.addEventListener win.doc.attachEvent win.doc.detachEvent | |
9 | "./a11yclick" | |
10 | ], function(on, array, keys, declare, has, unload, win, a11yclick){ | |
11 | ||
12 | // module: | |
13 | // dijit/_OnDijitClickMixin | |
14 | ||
15 | var ret = declare("dijit._OnDijitClickMixin", null, { | |
16 | connect: function( | |
17 | /*Object|null*/ obj, | |
18 | /*String|Function*/ event, | |
19 | /*String|Function*/ method){ | |
20 | // summary: | |
21 | // Connects specified obj/event to specified method of this object | |
22 | // and registers for disconnect() on widget destroy. | |
23 | // description: | |
24 | // Provide widget-specific analog to connect.connect, except with the | |
25 | // implicit use of this widget as the target object. | |
26 | // This version of connect also provides a special "ondijitclick" | |
27 | // event which triggers on a click or space or enter keyup. | |
28 | // Events connected with `this.connect` are disconnected upon | |
29 | // destruction. | |
30 | // returns: | |
31 | // A handle that can be passed to `disconnect` in order to disconnect before | |
32 | // the widget is destroyed. | |
33 | // example: | |
34 | // | var btn = new Button(); | |
35 | // | // when foo.bar() is called, call the listener we're going to | |
36 | // | // provide in the scope of btn | |
37 | // | btn.connect(foo, "bar", function(){ | |
38 | // | console.debug(this.toString()); | |
39 | // | }); | |
40 | // tags: | |
41 | // protected | |
42 | ||
43 | return this.inherited(arguments, [obj, event == "ondijitclick" ? a11yclick : event, method]); | |
44 | } | |
45 | }); | |
46 | ||
47 | ret.a11yclick = a11yclick; // back compat | |
48 | ||
49 | return ret; | |
50 | }); |