Path: blob/trunk/third_party/closure/goog/ui/custombutton.js
4506 views
/**1* @license2* Copyright The Closure Library Authors.3* SPDX-License-Identifier: Apache-2.04*/56/**7* @fileoverview A button rendered via {@link goog.ui.CustomButtonRenderer}.8*/910goog.provide('goog.ui.CustomButton');1112goog.require('goog.ui.Button');13goog.require('goog.ui.CustomButtonRenderer');14goog.require('goog.ui.registry');15goog.requireType('goog.dom.DomHelper');16goog.requireType('goog.ui.ButtonRenderer');17goog.requireType('goog.ui.ControlContent');18192021/**22* A custom button control. Identical to {@link goog.ui.Button}, except it23* defaults its renderer to {@link goog.ui.CustomButtonRenderer}. One could24* just as easily pass `goog.ui.CustomButtonRenderer.getInstance()` to25* the {@link goog.ui.Button} constructor and get the same result. Provided26* for convenience.27*28* @param {goog.ui.ControlContent} content Text caption or existing DOM29* structure to display as the button's caption.30* @param {goog.ui.ButtonRenderer=} opt_renderer Optional renderer used to31* render or decorate the button; defaults to32* {@link goog.ui.CustomButtonRenderer}.33* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper, used for34* document interaction.35* @constructor36* @extends {goog.ui.Button}37*/38goog.ui.CustomButton = function(content, opt_renderer, opt_domHelper) {39'use strict';40goog.ui.Button.call(41this, content, opt_renderer || goog.ui.CustomButtonRenderer.getInstance(),42opt_domHelper);43};44goog.inherits(goog.ui.CustomButton, goog.ui.Button);454647// Register a decorator factory function for goog.ui.CustomButtons.48goog.ui.registry.setDecoratorByClassName(49goog.ui.CustomButtonRenderer.CSS_CLASS, function() {50'use strict';51// CustomButton defaults to using CustomButtonRenderer.52return new goog.ui.CustomButton(null);53});545556