major doc changes
[roojs1] / Roo / menu / Adapter.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11  
12 /**
13  * @class Roo.menu.Adapter
14  * @extends Roo.menu.BaseItem
15  * @abstract
16  * A base utility class that adapts a non-menu component so that it can be wrapped by a menu item and added to a menu.
17  * It provides basic rendering, activation management and enable/disable logic required to work in menus.
18  * @constructor
19  * Creates a new Adapter
20  * @param {Object} config Configuration options
21  */
22 Roo.menu.Adapter = function(component, config){
23     Roo.menu.Adapter.superclass.constructor.call(this, config);
24     this.component = component;
25 };
26 Roo.extend(Roo.menu.Adapter, Roo.menu.BaseItem, {
27     // private
28     canActivate : true,
29
30     // private
31     onRender : function(container, position){
32         this.component.render(container);
33         this.el = this.component.getEl();
34     },
35
36     // private
37     activate : function(){
38         if(this.disabled){
39             return false;
40         }
41         this.component.focus();
42         this.fireEvent("activate", this);
43         return true;
44     },
45
46     // private
47     deactivate : function(){
48         this.fireEvent("deactivate", this);
49     },
50
51     // private
52     disable : function(){
53         this.component.disable();
54         Roo.menu.Adapter.superclass.disable.call(this);
55     },
56
57     // private
58     enable : function(){
59         this.component.enable();
60         Roo.menu.Adapter.superclass.enable.call(this);
61     }
62 });