/*
* Based on:
* Ext JS Library 1.1.1
* Copyright(c) 2006-2007, Ext JS, LLC.
*
* Originally Released Under LGPL - original licence link has changed is not relivant.
*
* Fork - LGPL
* <script type="text/javascript">
*/
/**
* @class Roo.menu.Adapter
* @extends Roo.menu.BaseItem
* 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.
* It provides basic rendering, activation management and enable/disable logic required to work in menus.
* @constructor
* Creates a new Adapter
* @param {Object} config Configuration options
*/
Roo.menu.Adapter = function(component, config){
Roo.menu.Adapter.superclass.constructor.call(this, config);
this.component = component;
};
Roo.extend(Roo.menu.Adapter, Roo.menu.BaseItem, {
// private
canActivate : true,
// private
onRender : function(container, position){
this.component.render(container);
this.el = this.component.getEl();
},
// private
activate : function(){
if(this.disabled){
return false;
}
this.component.focus();
this.fireEvent("activate", this);
return true;
},
// private
deactivate : function(){
this.fireEvent("deactivate", this);
},
// private
disable : function(){
this.component.disable();
Roo.menu.Adapter.superclass.disable.call(this);
},
// private
enable : function(){
this.component.enable();
Roo.menu.Adapter.superclass.enable.call(this);
}
});