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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* global $, APP, JitsiMeetJS */
  2. import UIEvents from "../../../service/UI/UIEvents";
  3. import FeedbackWindow from "./FeedbackWindow";
  4. /**
  5. * Shows / hides the feedback button.
  6. * @private
  7. */
  8. function _toggleFeedbackIcon() {
  9. document.querySelector('#feedbackButton').classList.toggle('hidden');
  10. }
  11. /**
  12. * Shows / hides the feedback button.
  13. * @param {show} set to {true} to show the feedback button or to {false}
  14. * to hide it
  15. * @private
  16. */
  17. function _showFeedbackButton (show) {
  18. document.querySelector('#feedbackButton').classList.toggle('hide', !show);
  19. }
  20. /**
  21. * Defines all methods in connection to the Feedback window.
  22. *
  23. * @type {{openFeedbackWindow: Function}}
  24. */
  25. var Feedback = {
  26. /**
  27. * Initialise the Feedback functionality.
  28. * @param emitter the EventEmitter to associate with the Feedback.
  29. */
  30. init: function (emitter) {
  31. // CallStats is the way we send feedback, so we don't have to initialise
  32. // if callstats isn't enabled.
  33. if (!APP.conference.isCallstatsEnabled())
  34. return;
  35. // If enabled property is still undefined, i.e. it hasn't been set from
  36. // some other module already, we set it to true by default.
  37. if (typeof this.enabled == "undefined")
  38. this.enabled = true;
  39. _showFeedbackButton(this.enabled);
  40. this.window = new FeedbackWindow();
  41. $("#feedbackButton").click(Feedback.openFeedbackWindow);
  42. // Show / hide the feedback button whenever the film strip is
  43. // shown / hidden.
  44. emitter.addListener(UIEvents.TOGGLE_FILM_STRIP, function () {
  45. _toggleFeedbackIcon();
  46. });
  47. },
  48. /**
  49. * Enables/ disabled the feedback feature.
  50. */
  51. enableFeedback: function (enable) {
  52. if (this.enabled !== enable)
  53. _showFeedbackButton(enable);
  54. this.enabled = enable;
  55. },
  56. /**
  57. * Indicates if the feedback functionality is enabled.
  58. *
  59. * @return true if the feedback functionality is enabled, false otherwise.
  60. */
  61. isEnabled: function() {
  62. return this.enabled && APP.conference.isCallstatsEnabled();
  63. },
  64. /**
  65. * Returns true if the feedback window is currently visible and false
  66. * otherwise.
  67. * @return {boolean} true if the feedback window is visible, false
  68. * otherwise
  69. */
  70. isVisible: function() {
  71. return $(".feedback").is(":visible");
  72. },
  73. /**
  74. * Indicates if the feedback is submitted.
  75. *
  76. * @return {boolean} {true} to indicate if the feedback is submitted,
  77. * {false} - otherwise
  78. */
  79. isSubmitted: function() {
  80. return Feedback.window.submitted;
  81. },
  82. /**
  83. * Opens the feedback window.
  84. */
  85. openFeedbackWindow: function (callback) {
  86. Feedback.window.show(callback);
  87. JitsiMeetJS.analytics.sendEvent('feedback.open');
  88. },
  89. /**
  90. * Returns the feedback score.
  91. *
  92. * @returns {*}
  93. */
  94. getFeedbackScore: function() {
  95. return Feedback.window.feedbackScore;
  96. },
  97. /**
  98. * Returns the feedback free text.
  99. *
  100. * @returns {null|*|message}
  101. */
  102. getFeedbackText: function() {
  103. return Feedback.window.feedbackText;
  104. }
  105. };
  106. module.exports = Feedback;