Debian Codegraph @

closure-library/closure/goog/ui/menuheader.js

raw
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 class for representing menu headers.
17 * @see goog.ui.Menu
18 *
19 */
20
21 goog.provide('goog.ui.MenuHeader');
22
23 goog.require('goog.ui.Component');
24 goog.require('goog.ui.Control');
25 goog.require('goog.ui.MenuHeaderRenderer');
26 goog.require('goog.ui.registry');
27
28
29
30 /**
31 * Class representing a menu header.
32 * @param {goog.ui.ControlContent} content Text caption or DOM structure to
33 * display as the content of the item (use to add icons or styling to
34 * menus).
35 * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper used for
36 * document interactions.
37 * @param {goog.ui.MenuHeaderRenderer=} opt_renderer Optional renderer.
38 * @constructor
39 * @extends {goog.ui.Control}
40 */
41 goog.ui.MenuHeader = function(content, opt_domHelper, opt_renderer) {
42 goog.ui.Control.call(
43 this, content, opt_renderer || goog.ui.MenuHeaderRenderer.getInstance(),
44 opt_domHelper);
45
46 this.setSupportedState(goog.ui.Component.State.DISABLED, false);
47 this.setSupportedState(goog.ui.Component.State.HOVER, false);
48 this.setSupportedState(goog.ui.Component.State.ACTIVE, false);
49 this.setSupportedState(goog.ui.Component.State.FOCUSED, false);
50
51 // Headers are always considered disabled.
52 this.setStateInternal(goog.ui.Component.State.DISABLED);
53 };
54 goog.inherits(goog.ui.MenuHeader, goog.ui.Control);
55
56
57 // Register a decorator factory function for goog.ui.MenuHeaders.
58 goog.ui.registry.setDecoratorByClassName(
59 goog.ui.MenuHeaderRenderer.CSS_CLASS, function() {
60 // MenuHeader defaults to using MenuHeaderRenderer.
61 return new goog.ui.MenuHeader(null);
62 });