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.

UserMediaPermissionsGuidanceOverlay.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* global $, APP */
  2. let $overlay;
  3. /**
  4. * Internal function that constructs overlay with guidance how to proceed with
  5. * gUM prompt.
  6. * @param {string} browser - name of browser for which to construct the
  7. * guidance overlay.
  8. */
  9. function buildOverlayHtml(browser) {
  10. $overlay = $(`
  11. <div class='overlay_container'>
  12. <div class='overlay_content'>
  13. <span class="overlay_icon icon-microphone"></span>
  14. <span class="overlay_icon icon-camera"></span>
  15. <span data-i18n='[html]userMedia.${browser}GrantPermissions'
  16. class='overlay_text_small'></span>
  17. </div>
  18. </div>`);
  19. APP.translation.translateElement($overlay);
  20. }
  21. export default {
  22. /**
  23. * Checks whether the overlay is currently visible.
  24. * @return {boolean} <tt>true</tt> if the overlay is visible
  25. * or <tt>false</tt> otherwise.
  26. */
  27. isVisible () {
  28. return $overlay && $overlay.parents('body').length > 0;
  29. },
  30. /**
  31. * Shows browser-specific overlay with guidance how to proceed with
  32. * gUM prompt.
  33. * @param {string} browser - name of browser for which to show the
  34. * guidance overlay.
  35. */
  36. show(browser) {
  37. !$overlay && buildOverlayHtml(browser);
  38. !this.isVisible() && $overlay.appendTo('body');
  39. },
  40. /**
  41. * Hides browser-specific overlay with guidance how to proceed with
  42. * gUM prompt.
  43. */
  44. hide() {
  45. $overlay && $overlay.detach();
  46. }
  47. };