You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AudioOnlyLabel.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import React, { Component } from 'react';
  2. import UIUtil from '../../../../modules/UI/util/UIUtil';
  3. import { translate } from '../../base/i18n';
  4. /**
  5. * React {@code Component} for displaying a message to indicate audio only mode
  6. * is active and for triggering a tooltip to provide more information about
  7. * audio only mode.
  8. *
  9. * @extends Component
  10. */
  11. export class AudioOnlyLabel extends Component {
  12. /**
  13. * {@code AudioOnlyLabel}'s property types.
  14. *
  15. * @static
  16. */
  17. static propTypes = {
  18. /**
  19. * Invoked to obtain translated strings.
  20. */
  21. t: React.PropTypes.func
  22. }
  23. /**
  24. * Initializes a new {@code AudioOnlyLabel} instance.
  25. *
  26. * @param {Object} props - The read-only properties with which the new
  27. * instance is to be initialized.
  28. */
  29. constructor(props) {
  30. super(props);
  31. /**
  32. * The internal reference to the DOM/HTML element at the top of the
  33. * React {@code Component}'s DOM/HTML hierarchy. It is necessary for
  34. * setting a tooltip to display when hovering over the component.
  35. *
  36. * @private
  37. * @type {HTMLDivElement}
  38. */
  39. this._rootElement = null;
  40. // Bind event handlers so they are only bound once for every instance.
  41. this._setRootElement = this._setRootElement.bind(this);
  42. }
  43. /**
  44. * Sets a tooltip on the component to display on hover.
  45. *
  46. * @inheritdoc
  47. * @returns {void}
  48. */
  49. componentDidMount() {
  50. this._setTooltip();
  51. }
  52. /**
  53. * Implements React's {@link Component#render()}.
  54. *
  55. * @inheritdoc
  56. * @returns {ReactElement}
  57. */
  58. render() {
  59. return (
  60. <div
  61. className = 'audio-only-label'
  62. ref = { this._setRootElement }>
  63. <i className = 'icon-visibility-off' />
  64. </div>
  65. );
  66. }
  67. /**
  68. * Sets the instance variable for the component's root element so it can be
  69. * accessed directly.
  70. *
  71. * @param {HTMLDivElement} element - The topmost DOM element of the
  72. * component's DOM/HTML hierarchy.
  73. * @private
  74. * @returns {void}
  75. */
  76. _setRootElement(element) {
  77. this._rootElement = element;
  78. }
  79. /**
  80. * Sets the tooltip on the component's root element.
  81. *
  82. * @private
  83. * @returns {void}
  84. */
  85. _setTooltip() {
  86. UIUtil.setTooltip(
  87. this._rootElement,
  88. 'audioOnly.howToDisable',
  89. 'left'
  90. );
  91. }
  92. }
  93. export default translate(AudioOnlyLabel);