您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Feedback.js 3.2KB

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