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.

Feedback.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* global $, APP, JitsiMeetJS */
  2. import FeedbackWindow from "./FeedbackWindow";
  3. /**
  4. * Defines all methods in connection to the Feedback window.
  5. *
  6. * @type {{openFeedbackWindow: Function}}
  7. */
  8. const Feedback = {
  9. /**
  10. * Initialise the Feedback functionality.
  11. * @param emitter the EventEmitter to associate with the Feedback.
  12. */
  13. init: function (emitter) {
  14. // CallStats is the way we send feedback, so we don't have to initialise
  15. // if callstats isn't enabled.
  16. if (!APP.conference.isCallstatsEnabled())
  17. return;
  18. // If enabled property is still undefined, i.e. it hasn't been set from
  19. // some other module already, we set it to true by default.
  20. if (typeof this.enabled == "undefined")
  21. this.enabled = true;
  22. this.window = new FeedbackWindow();
  23. this.emitter = emitter;
  24. $("#feedbackButton").click(Feedback.openFeedbackWindow);
  25. },
  26. /**
  27. * Enables/ disabled the feedback feature.
  28. */
  29. enableFeedback: function (enable) {
  30. this.enabled = enable;
  31. },
  32. /**
  33. * Indicates if the feedback functionality is enabled.
  34. *
  35. * @return true if the feedback functionality is enabled, false otherwise.
  36. */
  37. isEnabled: function() {
  38. return this.enabled && APP.conference.isCallstatsEnabled();
  39. },
  40. /**
  41. * Returns true if the feedback window is currently visible and false
  42. * otherwise.
  43. * @return {boolean} true if the feedback window is visible, false
  44. * otherwise
  45. */
  46. isVisible: function() {
  47. return $(".feedback").is(":visible");
  48. },
  49. /**
  50. * Indicates if the feedback is submitted.
  51. *
  52. * @return {boolean} {true} to indicate if the feedback is submitted,
  53. * {false} - otherwise
  54. */
  55. isSubmitted: function() {
  56. return Feedback.window.submitted;
  57. },
  58. /**
  59. * Opens the feedback window.
  60. */
  61. openFeedbackWindow: function (callback) {
  62. Feedback.window.show(callback);
  63. JitsiMeetJS.analytics.sendEvent('feedback.open');
  64. },
  65. /**
  66. * Returns the feedback score.
  67. *
  68. * @returns {*}
  69. */
  70. getFeedbackScore: function() {
  71. return Feedback.window.feedbackScore;
  72. },
  73. /**
  74. * Returns the feedback free text.
  75. *
  76. * @returns {null|*|message}
  77. */
  78. getFeedbackText: function() {
  79. return Feedback.window.feedbackText;
  80. }
  81. };
  82. export default Feedback;