toolbartogglebutton.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2008 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 toolbar toggle button control.
  16. *
  17. * @author attila@google.com (Attila Bodis)
  18. */
  19. goog.provide('goog.ui.ToolbarToggleButton');
  20. goog.require('goog.ui.ToggleButton');
  21. goog.require('goog.ui.ToolbarButtonRenderer');
  22. goog.require('goog.ui.registry');
  23. /**
  24. * A toggle button control for a toolbar.
  25. *
  26. * @param {goog.ui.ControlContent} content Text caption or existing DOM
  27. * structure to display as the button's caption.
  28. * @param {goog.ui.ToolbarButtonRenderer=} opt_renderer Optional renderer used
  29. * to render or decorate the button; defaults to
  30. * {@link goog.ui.ToolbarButtonRenderer}.
  31. * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper, used for
  32. * document interaction.
  33. * @constructor
  34. * @extends {goog.ui.ToggleButton}
  35. */
  36. goog.ui.ToolbarToggleButton = function(content, opt_renderer, opt_domHelper) {
  37. goog.ui.ToggleButton.call(
  38. this, content,
  39. opt_renderer || goog.ui.ToolbarButtonRenderer.getInstance(),
  40. opt_domHelper);
  41. };
  42. goog.inherits(goog.ui.ToolbarToggleButton, goog.ui.ToggleButton);
  43. // Registers a decorator factory function for toggle buttons in toolbars.
  44. goog.ui.registry.setDecoratorByClassName(
  45. goog.getCssName('goog-toolbar-toggle-button'),
  46. function() { return new goog.ui.ToolbarToggleButton(null); });