linkbuttonrenderer.js 2.2 KB

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