checkboxmenuitem.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 menu item class that supports checkbox semantics.
  16. *
  17. * @author attila@google.com (Attila Bodis)
  18. */
  19. goog.provide('goog.ui.CheckBoxMenuItem');
  20. goog.require('goog.ui.MenuItem');
  21. goog.require('goog.ui.registry');
  22. /**
  23. * Class representing a checkbox menu item. This is just a convenience class
  24. * that extends {@link goog.ui.MenuItem} by making it checkable.
  25. *
  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 {*=} opt_model Data/model associated with the menu item.
  30. * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper used for
  31. * document interactions.
  32. * @constructor
  33. * @extends {goog.ui.MenuItem}
  34. */
  35. goog.ui.CheckBoxMenuItem = function(content, opt_model, opt_domHelper) {
  36. goog.ui.MenuItem.call(this, content, opt_model, opt_domHelper);
  37. this.setCheckable(true);
  38. };
  39. goog.inherits(goog.ui.CheckBoxMenuItem, goog.ui.MenuItem);
  40. // Register a decorator factory function for goog.ui.CheckBoxMenuItems.
  41. goog.ui.registry.setDecoratorByClassName(
  42. goog.getCssName('goog-checkbox-menuitem'), function() {
  43. // CheckBoxMenuItem defaults to using MenuItemRenderer.
  44. return new goog.ui.CheckBoxMenuItem(null);
  45. });