Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / BaseItem.html
diff --git a/docs/source/BaseItem.html b/docs/source/BaseItem.html
new file mode 100644 (file)
index 0000000..266b2f5
--- /dev/null
@@ -0,0 +1,163 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js"><div id="cls-Ext.menu.BaseItem"></div>/**
+ * @class Ext.menu.BaseItem
+ * @extends Ext.Component
+ * The base class for all items that render into menus.  BaseItem provides default rendering, activated state
+ * management and base configuration options shared by all menu components.
+ * @constructor
+ * Creates a new BaseItem
+ * @param {Object} config Configuration options
+ * @xtype menubaseitem
+ */
+Ext.menu.BaseItem = function(config){
+    Ext.menu.BaseItem.superclass.constructor.call(this, config);
+
+    this.addEvents(
+        <div id="event-Ext.menu.BaseItem-click"></div>/**
+         * @event click
+         * Fires when this item is clicked
+         * @param {Ext.menu.BaseItem} this
+         * @param {Ext.EventObject} e
+         */
+        'click',
+        <div id="event-Ext.menu.BaseItem-activate"></div>/**
+         * @event activate
+         * Fires when this item is activated
+         * @param {Ext.menu.BaseItem} this
+         */
+        'activate',
+        <div id="event-Ext.menu.BaseItem-deactivate"></div>/**
+         * @event deactivate
+         * Fires when this item is deactivated
+         * @param {Ext.menu.BaseItem} this
+         */
+        'deactivate'
+    );
+
+    if(this.handler){
+        this.on("click", this.handler, this.scope);
+    }
+};
+
+Ext.extend(Ext.menu.BaseItem, Ext.Component, {
+    <div id="prop-Ext.menu.BaseItem-parentMenu"></div>/**
+     * @property parentMenu
+     * @type Ext.menu.Menu
+     * The parent Menu of this Item.
+     */
+    <div id="cfg-Ext.menu.BaseItem-handler"></div>/**
+     * @cfg {Function} handler
+     * A function that will handle the click event of this menu item (optional).
+     * The handler is passed the following parameters:<div class="mdetail-params"><ul>
+     * <li><code>b</code> : Item<div class="sub-desc">This menu Item.</div></li>
+     * <li><code>e</code> : EventObject<div class="sub-desc">The click event.</div></li>
+     * </ul></div>
+     */
+    <div id="cfg-Ext.menu.BaseItem-scope"></div>/**
+     * @cfg {Object} scope
+     * The scope (<tt><b>this</b></tt> reference) in which the handler function will be called.
+     */
+    <div id="cfg-Ext.menu.BaseItem-canActivate"></div>/**
+     * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to false)
+     */
+    canActivate : false,
+    <div id="cfg-Ext.menu.BaseItem-activeClass"></div>/**
+     * @cfg {String} activeClass The CSS class to use when the item becomes activated (defaults to "x-menu-item-active")
+     */
+    activeClass : "x-menu-item-active",
+    <div id="cfg-Ext.menu.BaseItem-hideOnClick"></div>/**
+     * @cfg {Boolean} hideOnClick True to hide the containing menu after this item is clicked (defaults to true)
+     */
+    hideOnClick : true,
+    <div id="cfg-Ext.menu.BaseItem-clickHideDelay"></div>/**
+     * @cfg {Number} clickHideDelay Length of time in milliseconds to wait before hiding after a click (defaults to 100)
+     */
+    clickHideDelay : 1,
+
+    // private
+    ctype : "Ext.menu.BaseItem",
+
+    // private
+    actionMode : "container",
+
+    // private
+    onRender : function(container, position){
+        Ext.menu.BaseItem.superclass.onRender.apply(this, arguments);
+        if(this.ownerCt && this.ownerCt instanceof Ext.menu.Menu){
+            this.parentMenu = this.ownerCt;
+        }else{
+            this.container.addClass('x-menu-list-item');
+            this.mon(this.el, 'click', this.onClick, this);
+            this.mon(this.el, 'mouseenter', this.activate, this);
+            this.mon(this.el, 'mouseleave', this.deactivate, this);
+        }
+    },
+
+    <div id="method-Ext.menu.BaseItem-setHandler"></div>/**
+     * Sets the function that will handle click events for this item (equivalent to passing in the {@link #handler}
+     * config property).  If an existing handler is already registered, it will be unregistered for you.
+     * @param {Function} handler The function that should be called on click
+     * @param {Object} scope The scope that should be passed to the handler
+     */
+    setHandler : function(handler, scope){
+        if(this.handler){
+            this.un("click", this.handler, this.scope);
+        }
+        this.on("click", this.handler = handler, this.scope = scope);
+    },
+
+    // private
+    onClick : function(e){
+        if(!this.disabled && this.fireEvent("click", this, e) !== false
+                && (this.parentMenu && this.parentMenu.fireEvent("itemclick", this, e) !== false)){
+            this.handleClick(e);
+        }else{
+            e.stopEvent();
+        }
+    },
+
+    // private
+    activate : function(){
+        if(this.disabled){
+            return false;
+        }
+        var li = this.container;
+        li.addClass(this.activeClass);
+        this.region = li.getRegion().adjust(2, 2, -2, -2);
+        this.fireEvent("activate", this);
+        return true;
+    },
+
+    // private
+    deactivate : function(){
+        this.container.removeClass(this.activeClass);
+        this.fireEvent("deactivate", this);
+    },
+
+    // private
+    shouldDeactivate : function(e){
+        return !this.region || !this.region.contains(e.getPoint());
+    },
+
+    // private
+    handleClick : function(e){
+        if(this.hideOnClick){
+            this.parentMenu.hide.defer(this.clickHideDelay, this.parentMenu, [true]);
+        }
+    },
+
+    // private. Do nothing
+    expandMenu : Ext.emptyFn,
+
+    // private. Do nothing
+    hideMenu : Ext.emptyFn
+});
+Ext.reg('menubaseitem', Ext.menu.BaseItem);</pre>    \r
+</body>\r
+</html>
\ No newline at end of file