jiti-meet/modules/UI/feedback/Feedback.js

96 lines
2.4 KiB
JavaScript
Raw Normal View History

/* global $, APP, JitsiMeetJS */
import FeedbackWindow from "./FeedbackWindow";
2016-09-14 15:11:53 +00:00
/**
* Defines all methods in connection to the Feedback window.
*
* @type {{openFeedbackWindow: Function}}
*/
2016-11-04 13:58:43 +00:00
const Feedback = {
2016-09-14 15:11:53 +00:00
/**
* Initialise the Feedback functionality.
* @param emitter the EventEmitter to associate with the Feedback.
*/
init: function (emitter) {
// CallStats is the way we send feedback, so we don't have to initialise
// if callstats isn't enabled.
if (!APP.conference.isCallstatsEnabled())
return;
// If enabled property is still undefined, i.e. it hasn't been set from
// some other module already, we set it to true by default.
if (typeof this.enabled == "undefined")
this.enabled = true;
this.window = new FeedbackWindow();
2016-11-04 13:58:43 +00:00
this.emitter = emitter;
2016-09-14 15:11:53 +00:00
$("#feedbackButton").click(Feedback.openFeedbackWindow);
},
/**
* Enables/ disabled the feedback feature.
*/
enableFeedback: function (enable) {
this.enabled = enable;
},
/**
* Indicates if the feedback functionality is enabled.
*
* @return true if the feedback functionality is enabled, false otherwise.
*/
isEnabled: function() {
return this.enabled && APP.conference.isCallstatsEnabled();
},
/**
* Returns true if the feedback window is currently visible and false
* otherwise.
* @return {boolean} true if the feedback window is visible, false
* otherwise
*/
isVisible: function() {
return $(".feedback").is(":visible");
},
2016-09-27 02:15:24 +00:00
/**
* Indicates if the feedback is submitted.
*
* @return {boolean} {true} to indicate if the feedback is submitted,
* {false} - otherwise
*/
isSubmitted: function() {
return Feedback.window.submitted;
},
2016-09-14 15:11:53 +00:00
/**
* Opens the feedback window.
*/
openFeedbackWindow: function (callback) {
Feedback.window.show(callback);
JitsiMeetJS.analytics.sendEvent('feedback.open');
},
2016-09-27 02:15:24 +00:00
/**
* Returns the feedback score.
*
* @returns {*}
*/
2016-09-14 15:11:53 +00:00
getFeedbackScore: function() {
2016-09-27 02:15:24 +00:00
return Feedback.window.feedbackScore;
},
2016-09-14 15:11:53 +00:00
2016-09-27 02:15:24 +00:00
/**
* Returns the feedback free text.
*
* @returns {null|*|message}
*/
getFeedbackText: function() {
return Feedback.window.feedbackText;
}
2016-09-14 15:11:53 +00:00
};
2016-11-04 13:58:43 +00:00
export default Feedback;