Debian Codegraph @

closure-library/closure/goog/ui/toolbarseparatorrenderer.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 Renderer for toolbar separators.
17 *
18 * @author [email protected] (Attila Bodis)
19 */
20
21 goog.provide('goog.ui.ToolbarSeparatorRenderer');
22
23 goog.require('goog.asserts');
24 goog.require('goog.dom.TagName');
25 goog.require('goog.dom.classlist');
26 goog.require('goog.ui.INLINE_BLOCK_CLASSNAME');
27 goog.require('goog.ui.MenuSeparatorRenderer');
28
29
30
31 /**
32 * Renderer for toolbar separators.
33 * @constructor
34 * @extends {goog.ui.MenuSeparatorRenderer}
35 */
36 goog.ui.ToolbarSeparatorRenderer = function() {
37 goog.ui.MenuSeparatorRenderer.call(this);
38 };
39 goog.inherits(goog.ui.ToolbarSeparatorRenderer, goog.ui.MenuSeparatorRenderer);
40 goog.addSingletonGetter(goog.ui.ToolbarSeparatorRenderer);
41
42
43 /**
44 * Default CSS class to be applied to the root element of components rendered
45 * by this renderer.
46 * @type {string}
47 */
48 goog.ui.ToolbarSeparatorRenderer.CSS_CLASS =
49 goog.getCssName('goog-toolbar-separator');
50
51
52 /**
53 * Returns a styled toolbar separator implemented by the following DOM:
54 *
55 * <div class="goog-toolbar-separator goog-inline-block">&nbsp;</div>
56 *
57 * Overrides {@link goog.ui.MenuSeparatorRenderer#createDom}.
58 * @param {goog.ui.Control} separator goog.ui.Separator to render.
59 * @return {!Element} Root element for the separator.
60 * @override
61 */
62 goog.ui.ToolbarSeparatorRenderer.prototype.createDom = function(separator) {
63 // 00A0 is &nbsp;
64 return separator.getDomHelper().createDom(
65 goog.dom.TagName.DIV, this.getClassNames(separator).join(' ') + ' ' +
66 goog.ui.INLINE_BLOCK_CLASSNAME,
67 '\u00A0');
68 };
69
70
71 /**
72 * Takes an existing element, and decorates it with the separator. Overrides
73 * {@link goog.ui.MenuSeparatorRenderer#decorate}.
74 * @param {goog.ui.Control} separator goog.ui.Separator to decorate the element.
75 * @param {Element} element Element to decorate.
76 * @return {!Element} Decorated element.
77 * @override
78 */
79 goog.ui.ToolbarSeparatorRenderer.prototype.decorate = function(
80 separator, element) {
81 element = goog.ui.ToolbarSeparatorRenderer.superClass_.decorate.call(
82 this, separator, element);
83 goog.asserts.assert(element);
84 goog.dom.classlist.add(element, goog.ui.INLINE_BLOCK_CLASSNAME);
85 return element;
86 };
87
88
89 /**
90 * Returns the CSS class to be applied to the root element of components
91 * rendered using this renderer.
92 * @return {string} Renderer-specific CSS class.
93 * @override
94 */
95 goog.ui.ToolbarSeparatorRenderer.prototype.getCssClass = function() {
96 return goog.ui.ToolbarSeparatorRenderer.CSS_CLASS;
97 };