Source: ui/spacer.js

  1. /*! @license
  2. * Shaka Player
  3. * Copyright 2016 Google LLC
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. goog.provide('shaka.ui.Spacer');
  7. goog.require('shaka.ui.Controls');
  8. goog.require('shaka.ui.Element');
  9. goog.require('shaka.util.Dom');
  10. /**
  11. * @extends {shaka.ui.Element}
  12. * @final
  13. * @export
  14. */
  15. shaka.ui.Spacer = class extends shaka.ui.Element {
  16. /**
  17. * @param {!HTMLElement} parent
  18. * @param {!shaka.ui.Controls} controls
  19. */
  20. constructor(parent, controls) {
  21. super(parent, controls);
  22. /** @private {!HTMLElement} */
  23. const div = shaka.util.Dom.createHTMLElement('div');
  24. div.classList.add('shaka-spacer');
  25. // Make screen readers ignore the spacer
  26. div.ariaHidden = 'true';
  27. this.parent.appendChild(div);
  28. }
  29. };
  30. /**
  31. * @implements {shaka.extern.IUIElement.Factory}
  32. * @final
  33. */
  34. shaka.ui.Spacer.Factory = class {
  35. /** @override */
  36. create(rootElement, controls) {
  37. return new shaka.ui.Spacer(rootElement, controls);
  38. }
  39. };
  40. shaka.ui.Controls.registerElement(
  41. 'spacer', new shaka.ui.Spacer.Factory());