]>
Commit | Line | Data |
---|---|---|
2f01fe57 | 1 | /* |
81bea17a | 2 | Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. |
2f01fe57 AD |
3 | Available via Academic Free License >= 2.1 OR the modified BSD license. |
4 | see: http://dojotoolkit.org/license for details | |
5 | */ | |
6 | ||
7 | ||
81bea17a AD |
8 | if(!dojo._hasResource["dijit.CheckedMenuItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
9 | dojo._hasResource["dijit.CheckedMenuItem"] = true; | |
2f01fe57 AD |
10 | dojo.provide("dijit.CheckedMenuItem"); |
11 | dojo.require("dijit.MenuItem"); | |
81bea17a AD |
12 | |
13 | ||
14 | dojo.declare("dijit.CheckedMenuItem", | |
15 | dijit.MenuItem, | |
16 | { | |
17 | // summary: | |
18 | // A checkbox-like menu item for toggling on and off | |
19 | ||
20 | templateString: dojo.cache("dijit", "templates/CheckedMenuItem.html", "<tr class=\"dijitReset dijitMenuItem\" dojoAttachPoint=\"focusNode\" role=\"menuitemcheckbox\" tabIndex=\"-1\"\n\t\tdojoAttachEvent=\"onmouseenter:_onHover,onmouseleave:_onUnhover,ondijitclick:_onClick\">\n\t<td class=\"dijitReset dijitMenuItemIconCell\" role=\"presentation\">\n\t\t<img src=\"${_blankGif}\" alt=\"\" class=\"dijitMenuItemIcon dijitCheckedMenuItemIcon\" dojoAttachPoint=\"iconNode\"/>\n\t\t<span class=\"dijitCheckedMenuItemIconChar\">✓</span>\n\t</td>\n\t<td class=\"dijitReset dijitMenuItemLabel\" colspan=\"2\" dojoAttachPoint=\"containerNode,labelNode\"></td>\n\t<td class=\"dijitReset dijitMenuItemAccelKey\" style=\"display: none\" dojoAttachPoint=\"accelKeyNode\"></td>\n\t<td class=\"dijitReset dijitMenuArrowCell\" role=\"presentation\"> </td>\n</tr>\n"), | |
21 | ||
22 | // checked: Boolean | |
23 | // Our checked state | |
24 | checked: false, | |
25 | _setCheckedAttr: function(/*Boolean*/ checked){ | |
26 | // summary: | |
27 | // Hook so attr('checked', bool) works. | |
28 | // Sets the class and state for the check box. | |
29 | dojo.toggleClass(this.domNode, "dijitCheckedMenuItemChecked", checked); | |
30 | dijit.setWaiState(this.domNode, "checked", checked); | |
31 | this._set("checked", checked); | |
32 | }, | |
33 | ||
34 | onChange: function(/*Boolean*/ checked){ | |
35 | // summary: | |
36 | // User defined function to handle check/uncheck events | |
37 | // tags: | |
38 | // callback | |
39 | }, | |
40 | ||
41 | _onClick: function(/*Event*/ e){ | |
42 | // summary: | |
43 | // Clicking this item just toggles its state | |
44 | // tags: | |
45 | // private | |
46 | if(!this.disabled){ | |
47 | this.set("checked", !this.checked); | |
48 | this.onChange(this.checked); | |
49 | } | |
50 | this.inherited(arguments); | |
51 | } | |
52 | }); | |
53 | ||
2f01fe57 | 54 | } |