2
* Ext JS Library 3.0 RC2
3
* Copyright(c) 2006-2009, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.menu.CheckItem
11
* @extends Ext.menu.Item
12
* Adds a menu item that contains a checkbox by default, but can also be part of a radio group.
14
* Creates a new CheckItem
15
* @param {Object} config Configuration options
16
* @xtype menucheckitem
18
Ext.menu.CheckItem = function(config){
19
Ext.menu.CheckItem.superclass.constructor.call(this, config);
22
* @event beforecheckchange
23
* Fires before the checked value is set, providing an opportunity to cancel if needed
24
* @param {Ext.menu.CheckItem} this
25
* @param {Boolean} checked The new checked value that will be set
30
* Fires after the checked value has been set
31
* @param {Ext.menu.CheckItem} this
32
* @param {Boolean} checked The checked value that was set
37
* A function that handles the checkchange event. The function is undefined by default, but if an implementation
38
* is provided, it will be called automatically when the checkchange event fires.
39
* @param {Ext.menu.CheckItem} this
40
* @param {Boolean} checked The checked value that was set
41
* @method checkHandler
43
if(this.checkHandler){
44
this.on('checkchange', this.checkHandler, this.scope);
46
Ext.menu.MenuMgr.registerCheckable(this);
48
Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {
51
* All check items with the same group name will automatically be grouped into a single-select
52
* radio button group (defaults to '')
55
* @cfg {String} itemCls The default CSS class to use for check items (defaults to "x-menu-item x-menu-check-item")
57
itemCls : "x-menu-item x-menu-check-item",
59
* @cfg {String} groupClass The default CSS class to use for radio group check items (defaults to "x-menu-group-item")
61
groupClass : "x-menu-group-item",
64
* @cfg {Boolean} checked True to initialize this checkbox as checked (defaults to false). Note that
65
* if this checkbox is part of a radio group (group = true) only the last item in the group that is
66
* initialized with checked = true will be rendered as checked.
71
ctype: "Ext.menu.CheckItem",
74
onRender : function(c){
75
Ext.menu.CheckItem.superclass.onRender.apply(this, arguments);
77
this.el.addClass(this.groupClass);
81
this.setChecked(true, true);
87
Ext.menu.MenuMgr.unregisterCheckable(this);
88
Ext.menu.CheckItem.superclass.destroy.apply(this, arguments);
92
* Set the checked state of this item
93
* @param {Boolean} checked The new checked value
94
* @param {Boolean} suppressEvent (optional) True to prevent the checkchange event from firing (defaults to false)
96
setChecked : function(state, suppressEvent){
97
if(this.checked != state && this.fireEvent("beforecheckchange", this, state) !== false){
99
this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");
101
this.checked = state;
102
if(suppressEvent !== true){
103
this.fireEvent("checkchange", this, state);
109
handleClick : function(e){
110
if(!this.disabled && !(this.checked && this.group)){// disable unselect on radio item
111
this.setChecked(!this.checked);
113
Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
116
Ext.reg('menucheckitem', Ext.menu.CheckItem);
b'\\ No newline at end of file'