primaryactionbuttonrenderer.js 2.9 KB

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