| 1 |
// Copyright 2008 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 {@link goog.ui.Button}s in App style. This |
| 17 |
* type of button is typically used for an application's "primary action," eg |
| 18 |
* in Gmail, it's "Compose," in Calendar, it's "Create Event". |
| 19 |
* |
| 20 |
*/ |
| 21 |
|
| 22 |
goog.provide('goog.ui.style.app.PrimaryActionButtonRenderer'); |
| 23 |
|
| 24 |
goog.require('goog.ui.Button'); |
| 25 |
goog.require('goog.ui.registry'); |
| 26 |
goog.require('goog.ui.style.app.ButtonRenderer'); |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
/** |
| 31 |
* Custom renderer for {@link goog.ui.Button}s. This renderer supports the |
| 32 |
* "primary action" style for buttons. |
| 33 |
* |
| 34 |
* @constructor |
| 35 |
* @extends {goog.ui.style.app.ButtonRenderer} |
| 36 |
* @final |
| 37 |
*/ |
| 38 |
goog.ui.style.app.PrimaryActionButtonRenderer = function() { |
| 39 |
goog.ui.style.app.ButtonRenderer.call(this); |
| 40 |
}; |
| 41 |
goog.inherits( |
| 42 |
goog.ui.style.app.PrimaryActionButtonRenderer, |
| 43 |
goog.ui.style.app.ButtonRenderer); |
| 44 |
goog.addSingletonGetter(goog.ui.style.app.PrimaryActionButtonRenderer); |
| 45 |
|
| 46 |
|
| 47 |
/** |
| 48 |
* Default CSS class to be applied to the root element of components rendered |
| 49 |
* by this renderer. |
| 50 |
* @type {string} |
| 51 |
*/ |
| 52 |
goog.ui.style.app.PrimaryActionButtonRenderer.CSS_CLASS = |
| 53 |
'goog-primaryactionbutton'; |
| 54 |
|
| 55 |
|
| 56 |
/** |
| 57 |
* Array of arrays of CSS classes that we want composite classes added and |
| 58 |
* removed for in IE6 and lower as a workaround for lack of multi-class CSS |
| 59 |
* selector support. |
| 60 |
* @type {Array<Array<string>>} |
| 61 |
*/ |
| 62 |
goog.ui.style.app.PrimaryActionButtonRenderer.IE6_CLASS_COMBINATIONS = [ |
| 63 |
['goog-button-base-disabled', 'goog-primaryactionbutton'], |
| 64 |
['goog-button-base-focused', 'goog-primaryactionbutton'], |
| 65 |
['goog-button-base-hover', 'goog-primaryactionbutton'] |
| 66 |
]; |
| 67 |
|
| 68 |
|
| 69 |
/** @override */ |
| 70 |
goog.ui.style.app.PrimaryActionButtonRenderer.prototype.getCssClass = |
| 71 |
function() { |
| 72 |
return goog.ui.style.app.PrimaryActionButtonRenderer.CSS_CLASS; |
| 73 |
}; |
| 74 |
|
| 75 |
|
| 76 |
/** @override */ |
| 77 |
goog.ui.style.app.PrimaryActionButtonRenderer.prototype |
| 78 |
.getIe6ClassCombinations = function() { |
| 79 |
return goog.ui.style.app.PrimaryActionButtonRenderer.IE6_CLASS_COMBINATIONS; |
| 80 |
}; |
| 81 |
|
| 82 |
|
| 83 |
// Register a decorator factory function for |
| 84 |
// goog.ui.style.app.PrimaryActionButtonRenderer. |
| 85 |
goog.ui.registry.setDecoratorByClassName( |
| 86 |
goog.ui.style.app.PrimaryActionButtonRenderer.CSS_CLASS, function() { |
| 87 |
return new goog.ui.Button( |
| 88 |
null, goog.ui.style.app.PrimaryActionButtonRenderer.getInstance()); |
| 89 |
}); |