Debian Codegraph @

closure-library/closure/goog/ui/togglebutton.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 toggle button control. Extends {@link goog.ui.Button} by
17 * providing checkbox-like semantics.
18 *
19 * @author [email protected] (Attila Bodis)
20 */
21
22 goog.provide('goog.ui.ToggleButton');
23
24 goog.require('goog.ui.Button');
25 goog.require('goog.ui.Component');
26 goog.require('goog.ui.CustomButtonRenderer');
27 goog.require('goog.ui.registry');
28
29
30
31 /**
32 * A toggle button, with checkbox-like semantics. Rendered using
33 * {@link goog.ui.CustomButtonRenderer} by default, though any
34 * {@link goog.ui.ButtonRenderer} would work.
35 *
36 * @param {goog.ui.ControlContent} content Text caption or existing DOM
37 * structure to display as the button's caption.
38 * @param {goog.ui.ButtonRenderer=} opt_renderer Renderer used to render or
39 * decorate the button; defaults to {@link goog.ui.CustomButtonRenderer}.
40 * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper, used for
41 * document interaction.
42 * @constructor
43 * @extends {goog.ui.Button}
44 */
45 goog.ui.ToggleButton = function(content, opt_renderer, opt_domHelper) {
46 goog.ui.Button.call(
47 this, content, opt_renderer || goog.ui.CustomButtonRenderer.getInstance(),
48 opt_domHelper);
49 this.setSupportedState(goog.ui.Component.State.CHECKED, true);
50 };
51 goog.inherits(goog.ui.ToggleButton, goog.ui.Button);
52
53
54 // Register a decorator factory function for goog.ui.ToggleButtons.
55 goog.ui.registry.setDecoratorByClassName(
56 goog.getCssName('goog-toggle-button'), function() {
57 // ToggleButton defaults to using CustomButtonRenderer.
58 return new goog.ui.ToggleButton(null);
59 });