+++ /dev/null
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.menu.CheckItem\r
- * @extends Ext.menu.Item\r
- * Adds a menu item that contains a checkbox by default, but can also be part of a radio group.\r
- * @constructor\r
- * Creates a new CheckItem\r
- * @param {Object} config Configuration options\r
- */\r
-Ext.menu.CheckItem = function(config){\r
- Ext.menu.CheckItem.superclass.constructor.call(this, config);\r
- this.addEvents(\r
- /**\r
- * @event beforecheckchange\r
- * Fires before the checked value is set, providing an opportunity to cancel if needed\r
- * @param {Ext.menu.CheckItem} this\r
- * @param {Boolean} checked The new checked value that will be set\r
- */\r
- "beforecheckchange" ,\r
- /**\r
- * @event checkchange\r
- * Fires after the checked value has been set\r
- * @param {Ext.menu.CheckItem} this\r
- * @param {Boolean} checked The checked value that was set\r
- */\r
- "checkchange"\r
- );\r
- /**\r
- * A function that handles the checkchange event. The function is undefined by default, but if an implementation\r
- * is provided, it will be called automatically when the checkchange event fires.\r
- * @param {Ext.menu.CheckItem} this\r
- * @param {Boolean} checked The checked value that was set\r
- * @method checkHandler\r
- */\r
- if(this.checkHandler){\r
- this.on('checkchange', this.checkHandler, this.scope);\r
- }\r
- Ext.menu.MenuMgr.registerCheckable(this);\r
-};\r
-Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {\r
- /**\r
- * @cfg {String} group\r
- * All check items with the same group name will automatically be grouped into a single-select\r
- * radio button group (defaults to '')\r
- */\r
- /**\r
- * @cfg {String} itemCls The default CSS class to use for check items (defaults to "x-menu-item x-menu-check-item")\r
- */\r
- itemCls : "x-menu-item x-menu-check-item",\r
- /**\r
- * @cfg {String} groupClass The default CSS class to use for radio group check items (defaults to "x-menu-group-item")\r
- */\r
- groupClass : "x-menu-group-item",\r
-\r
- /**\r
- * @cfg {Boolean} checked True to initialize this checkbox as checked (defaults to false). Note that\r
- * if this checkbox is part of a radio group (group = true) only the last item in the group that is\r
- * initialized with checked = true will be rendered as checked.\r
- */\r
- checked: false,\r
-\r
- // private\r
- ctype: "Ext.menu.CheckItem",\r
-\r
- // private\r
- onRender : function(c){\r
- Ext.menu.CheckItem.superclass.onRender.apply(this, arguments);\r
- if(this.group){\r
- this.el.addClass(this.groupClass);\r
- }\r
- if(this.checked){\r
- this.checked = false;\r
- this.setChecked(true, true);\r
- }\r
- },\r
-\r
- // private\r
- destroy : function(){\r
- Ext.menu.MenuMgr.unregisterCheckable(this);\r
- Ext.menu.CheckItem.superclass.destroy.apply(this, arguments);\r
- },\r
-\r
- /**\r
- * Set the checked state of this item\r
- * @param {Boolean} checked The new checked value\r
- * @param {Boolean} suppressEvent (optional) True to prevent the checkchange event from firing (defaults to false)\r
- */\r
- setChecked : function(state, suppressEvent){\r
- if(this.checked != state && this.fireEvent("beforecheckchange", this, state) !== false){\r
- if(this.container){\r
- this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");\r
- }\r
- this.checked = state;\r
- if(suppressEvent !== true){\r
- this.fireEvent("checkchange", this, state);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- handleClick : function(e){\r
- if(!this.disabled && !(this.checked && this.group)){// disable unselect on radio item\r
- this.setChecked(!this.checked);\r
- }\r
- Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);\r
- }\r
-});
\ No newline at end of file