Debian Codegraph @

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

raw
1 // Copyright 2010 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 Similar to {@link goog.ui.FlatButtonRenderer},
17 * but underlines text instead of adds borders.
18 *
19 * For accessibility reasons, it is best to use this with a goog.ui.Button
20 * instead of an A element for links that perform actions in the page. Links
21 * that have an href and open a new page can and should remain as A elements.
22 *
23 * @author [email protected] (Robby Walker)
24 */
25
26 goog.provide('goog.ui.LinkButtonRenderer');
27
28 goog.require('goog.ui.Button');
29 goog.require('goog.ui.FlatButtonRenderer');
30 goog.require('goog.ui.registry');
31
32
33
34 /**
35 * Link renderer for {@link goog.ui.Button}s. Link buttons can contain
36 * almost arbitrary HTML content, will flow like inline elements, but can be
37 * styled like block-level elements.
38 * @constructor
39 * @extends {goog.ui.FlatButtonRenderer}
40 */
41 goog.ui.LinkButtonRenderer = function() {
42 goog.ui.FlatButtonRenderer.call(this);
43 };
44 goog.inherits(goog.ui.LinkButtonRenderer, goog.ui.FlatButtonRenderer);
45 goog.addSingletonGetter(goog.ui.LinkButtonRenderer);
46
47
48 /**
49 * Default CSS class to be applied to the root element of components rendered
50 * by this renderer.
51 * @type {string}
52 */
53 goog.ui.LinkButtonRenderer.CSS_CLASS = goog.getCssName('goog-link-button');
54
55
56 /** @override */
57 goog.ui.LinkButtonRenderer.prototype.getCssClass = function() {
58 return goog.ui.LinkButtonRenderer.CSS_CLASS;
59 };
60
61
62 // Register a decorator factory function for Link Buttons.
63 goog.ui.registry.setDecoratorByClassName(
64 goog.ui.LinkButtonRenderer.CSS_CLASS, function() {
65 // Uses goog.ui.Button, but with LinkButtonRenderer.
66 return new goog.ui.Button(null, goog.ui.LinkButtonRenderer.getInstance());
67 });