toolbarselect.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 select control.
  16. *
  17. * @author attila@google.com (Attila Bodis)
  18. */
  19. goog.provide('goog.ui.ToolbarSelect');
  20. goog.require('goog.ui.Select');
  21. goog.require('goog.ui.ToolbarMenuButtonRenderer');
  22. goog.require('goog.ui.registry');
  23. /**
  24. * A select control for a toolbar.
  25. *
  26. * @param {goog.ui.ControlContent} caption Default caption or existing DOM
  27. * structure to display as the button's caption when nothing is selected.
  28. * @param {goog.ui.Menu=} opt_menu Menu containing selection options.
  29. * @param {goog.ui.MenuButtonRenderer=} opt_renderer Renderer used to
  30. * render or decorate the control; defaults to
  31. * {@link goog.ui.ToolbarMenuButtonRenderer}.
  32. * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper, used for
  33. * document interaction.
  34. * @constructor
  35. * @extends {goog.ui.Select}
  36. */
  37. goog.ui.ToolbarSelect = function(
  38. caption, opt_menu, opt_renderer, opt_domHelper) {
  39. goog.ui.Select.call(
  40. this, caption, opt_menu,
  41. opt_renderer || goog.ui.ToolbarMenuButtonRenderer.getInstance(),
  42. opt_domHelper);
  43. };
  44. goog.inherits(goog.ui.ToolbarSelect, goog.ui.Select);
  45. // Registers a decorator factory function for select controls used in toolbars.
  46. goog.ui.registry.setDecoratorByClassName(
  47. goog.getCssName('goog-toolbar-select'),
  48. function() { return new goog.ui.ToolbarSelect(null); });