791ad4e97a993dd99d2b9b7f024d733b8d3133e6.svn-base 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. /**
  7. * @class Ext.menu.Adapter
  8. * @extends Ext.menu.BaseItem A base utility class that adapts a non-menu
  9. * component so that it can be wrapped by a menu item and added to a
  10. * menu. It provides basic rendering, activation management and
  11. * enable/disable logic required to work in menus.
  12. * @constructor Creates a new Adapter
  13. * @param {Ext.Component}
  14. * component The component being adapted to render into a menu
  15. * @param {Object}
  16. * config Configuration options
  17. */
  18. Ext.menu.Adapter = function(component, config) {
  19. Ext.menu.Adapter.superclass.constructor.call(this, config);
  20. this.component = component;
  21. };
  22. Ext.extend(Ext.menu.Adapter, Ext.menu.BaseItem, {
  23. // private
  24. canActivate : true,
  25. // private
  26. onRender : function(container, position) {
  27. this.component.render(container);
  28. this.el = this.component.getEl();
  29. },
  30. // private
  31. activate : function() {
  32. if (this.disabled) {
  33. return false;
  34. }
  35. this.component.focus();
  36. this.fireEvent("activate", this);
  37. return true;
  38. },
  39. // private
  40. deactivate : function() {
  41. this.fireEvent("deactivate", this);
  42. },
  43. // private
  44. disable : function() {
  45. this.component.disable();
  46. Ext.menu.Adapter.superclass.disable.call(this);
  47. },
  48. // private
  49. enable : function() {
  50. this.component.enable();
  51. Ext.menu.Adapter.superclass.enable.call(this);
  52. }
  53. });