source: Dev/branches/rest-dojo-ui/client/dijit/CheckedMenuItem.js @ 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: 1.4 KB
RevLine 
[256]1define([
2        "dojo/_base/declare", // declare
3        "dojo/dom-class", // domClass.toggle
4        "./MenuItem",
5        "dojo/text!./templates/CheckedMenuItem.html",
6        "./hccss"
7], function(declare, domClass, MenuItem, template){
8
9/*=====
10        var MenuItem = dijit.MenuItem;
11=====*/
12
13        // module:
14        //              dijit/CheckedMenuItem
15        // summary:
16        //              A checkbox-like menu item for toggling on and off
17
18        return declare("dijit.CheckedMenuItem", MenuItem, {
19                // summary:
20                //              A checkbox-like menu item for toggling on and off
21
22                templateString: template,
23
24                // checked: Boolean
25                //              Our checked state
26                checked: false,
27                _setCheckedAttr: function(/*Boolean*/ checked){
28                        // summary:
29                        //              Hook so attr('checked', bool) works.
30                        //              Sets the class and state for the check box.
31                        domClass.toggle(this.domNode, "dijitCheckedMenuItemChecked", checked);
32                        this.domNode.setAttribute("aria-checked", checked);
33                        this._set("checked", checked);
34                },
35
36                iconClass: "",  // override dijitNoIcon
37
38                onChange: function(/*Boolean*/ /*===== checked =====*/){
39                        // summary:
40                        //              User defined function to handle check/uncheck events
41                        // tags:
42                        //              callback
43                },
44
45                _onClick: function(/*Event*/ e){
46                        // summary:
47                        //              Clicking this item just toggles its state
48                        // tags:
49                        //              private
50                        if(!this.disabled){
51                                this.set("checked", !this.checked);
52                                this.onChange(this.checked);
53                        }
54                        this.inherited(arguments);
55                }
56        });
57});
Note: See TracBrowser for help on using the repository browser.