| 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 |
/** |
| 16 |
* @fileoverview A toolbar menu button control. |
| 17 |
* |
| 18 |
* @author [email protected] (Attila Bodis) |
| 19 |
*/ |
| 20 |
|
| 21 |
goog.provide('goog.ui.ToolbarMenuButton'); |
| 22 |
|
| 23 |
goog.require('goog.ui.MenuButton'); |
| 24 |
goog.require('goog.ui.ToolbarMenuButtonRenderer'); |
| 25 |
goog.require('goog.ui.registry'); |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
/** |
| 30 |
* A menu button control for a toolbar. |
| 31 |
* |
| 32 |
* @param {goog.ui.ControlContent} content Text caption or existing DOM |
| 33 |
* structure to display as the button's caption. |
| 34 |
* @param {goog.ui.Menu=} opt_menu Menu to render under the button when clicked. |
| 35 |
* @param {goog.ui.ButtonRenderer=} opt_renderer Optional renderer used to |
| 36 |
* render or decorate the button; defaults to |
| 37 |
* {@link goog.ui.ToolbarMenuButtonRenderer}. |
| 38 |
* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper, used for |
| 39 |
* document interaction. |
| 40 |
* @constructor |
| 41 |
* @extends {goog.ui.MenuButton} |
| 42 |
*/ |
| 43 |
goog.ui.ToolbarMenuButton = function( |
| 44 |
content, opt_menu, opt_renderer, opt_domHelper) { |
| 45 |
goog.ui.MenuButton.call( |
| 46 |
this, content, opt_menu, |
| 47 |
opt_renderer || goog.ui.ToolbarMenuButtonRenderer.getInstance(), |
| 48 |
opt_domHelper); |
| 49 |
}; |
| 50 |
goog.inherits(goog.ui.ToolbarMenuButton, goog.ui.MenuButton); |
| 51 |
|
| 52 |
|
| 53 |
// Registers a decorator factory function for toolbar menu buttons. |
| 54 |
goog.ui.registry.setDecoratorByClassName( |
| 55 |
goog.ui.ToolbarMenuButtonRenderer.CSS_CLASS, |
| 56 |
function() { return new goog.ui.ToolbarMenuButton(null); }); |