| 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 |
/** |
| 16 |
* @fileoverview A toolbar class that hosts {@link goog.ui.Control}s such as |
| 17 |
* buttons and menus, along with toolbar-specific renderers of those controls. |
| 18 |
* |
| 19 |
* @author [email protected] (Attila Bodis) |
| 20 |
* @see ../demos/toolbar.html |
| 21 |
*/ |
| 22 |
|
| 23 |
goog.provide('goog.ui.Toolbar'); |
| 24 |
|
| 25 |
goog.require('goog.ui.Container'); |
| 26 |
goog.require('goog.ui.ToolbarRenderer'); |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
/** |
| 31 |
* A toolbar class, implemented as a {@link goog.ui.Container} that defaults to |
| 32 |
* having a horizontal orientation and {@link goog.ui.ToolbarRenderer} as its |
| 33 |
* renderer. |
| 34 |
* @param {goog.ui.ToolbarRenderer=} opt_renderer Renderer used to render or |
| 35 |
* decorate the toolbar; defaults to {@link goog.ui.ToolbarRenderer}. |
| 36 |
* @param {?goog.ui.Container.Orientation=} opt_orientation Toolbar orientation; |
| 37 |
* defaults to {@code HORIZONTAL}. |
| 38 |
* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper. |
| 39 |
* @constructor |
| 40 |
* @extends {goog.ui.Container} |
| 41 |
*/ |
| 42 |
goog.ui.Toolbar = function(opt_renderer, opt_orientation, opt_domHelper) { |
| 43 |
goog.ui.Container.call( |
| 44 |
this, opt_orientation, |
| 45 |
opt_renderer || goog.ui.ToolbarRenderer.getInstance(), opt_domHelper); |
| 46 |
}; |
| 47 |
goog.inherits(goog.ui.Toolbar, goog.ui.Container); |
| 48 |
|
| 49 |
|
| 50 |
/** @override */ |
| 51 |
goog.ui.Toolbar.prototype.handleFocus = function(e) { |
| 52 |
goog.ui.Toolbar.base(this, 'handleFocus', e); |
| 53 |
// Highlight the first highlightable item on focus via the keyboard for ARIA |
| 54 |
// spec compliance. Do not highlight the item if the mouse button is pressed, |
| 55 |
// since this method is also called from handleMouseDown when a toolbar button |
| 56 |
// is clicked. |
| 57 |
if (!this.isMouseButtonPressed()) { |
| 58 |
this.highlightFirst(); |
| 59 |
} |
| 60 |
}; |