menuheader.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2007 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview A class for representing menu headers.
  16. * @see goog.ui.Menu
  17. *
  18. */
  19. goog.provide('goog.ui.MenuHeader');
  20. goog.require('goog.ui.Component');
  21. goog.require('goog.ui.Control');
  22. goog.require('goog.ui.MenuHeaderRenderer');
  23. goog.require('goog.ui.registry');
  24. /**
  25. * Class representing a menu header.
  26. * @param {goog.ui.ControlContent} content Text caption or DOM structure to
  27. * display as the content of the item (use to add icons or styling to
  28. * menus).
  29. * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper used for
  30. * document interactions.
  31. * @param {goog.ui.MenuHeaderRenderer=} opt_renderer Optional renderer.
  32. * @constructor
  33. * @extends {goog.ui.Control}
  34. */
  35. goog.ui.MenuHeader = function(content, opt_domHelper, opt_renderer) {
  36. goog.ui.Control.call(
  37. this, content, opt_renderer || goog.ui.MenuHeaderRenderer.getInstance(),
  38. opt_domHelper);
  39. this.setSupportedState(goog.ui.Component.State.DISABLED, false);
  40. this.setSupportedState(goog.ui.Component.State.HOVER, false);
  41. this.setSupportedState(goog.ui.Component.State.ACTIVE, false);
  42. this.setSupportedState(goog.ui.Component.State.FOCUSED, false);
  43. // Headers are always considered disabled.
  44. this.setStateInternal(goog.ui.Component.State.DISABLED);
  45. };
  46. goog.inherits(goog.ui.MenuHeader, goog.ui.Control);
  47. // Register a decorator factory function for goog.ui.MenuHeaders.
  48. goog.ui.registry.setDecoratorByClassName(
  49. goog.ui.MenuHeaderRenderer.CSS_CLASS, function() {
  50. // MenuHeader defaults to using MenuHeaderRenderer.
  51. return new goog.ui.MenuHeader(null);
  52. });