initial import
[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  * 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.
16  * It provides basic rendering, activation management and enable/disable logic required to work in menus.
17  * @constructor
18  * Creates a new Adapter
19  * @param {Object} config Configuration options
20  */
21 Roo.menu.Adapter = function(component, config){
22     Roo.menu.Adapter.superclass.constructor.call(this, config);
23     this.component = component;
24 };
25 Roo.extend(Roo.menu.Adapter, Roo.menu.BaseItem, {
26     // private
27     canActivate : true,
28
29     // private
30     onRender : function(container, position){
31         this.component.render(container);
32         this.el = this.component.getEl();
33     },
34
35     // private
36     activate : function(){
37         if(this.disabled){
38             return false;
39         }
40         this.component.focus();
41         this.fireEvent("activate", this);
42         return true;
43     },
44
45     // private
46     deactivate : function(){
47         this.fireEvent("deactivate", this);
48     },
49
50     // private
51     disable : function(){
52         this.component.disable();
53         Roo.menu.Adapter.superclass.disable.call(this);
54     },
55
56     // private
57     enable : function(){
58         this.component.enable();
59         Roo.menu.Adapter.superclass.enable.call(this);
60     }
61 });