insert-bbb.js.es6 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import Controller from "@ember/component";
  2. import discourseComputed from "discourse-common/utils/decorators";
  3. import { isEmpty } from "@ember/utils";
  4. export default Controller.extend(ModalFunctionality, {
  5. keyDown(e) {
  6. if (e.keyCode === 13) {
  7. e.preventDefault();
  8. e.stopPropagation();
  9. return false;
  10. }
  11. },
  12. init() {
  13. this.setProperties({
  14. meetingID: "",
  15. attendeePW: "",
  16. moderatorPW: "",
  17. buttonText: "",
  18. mobileIframe: false,
  19. desktopIframe: true,
  20. });
  21. },
  22. randomID() {
  23. return Math.random().toString(36).slice(-8);
  24. },
  25. @discourseComputed("meetingID")
  26. insertDisabled(meetingID) {
  27. return isEmpty(meetingID);
  28. },
  29. actions: {
  30. insert() {
  31. const btnTxt = this.buttonText ? ` label="${this.buttonText}"` : "";
  32. this.toolbarEvent.addText(
  33. `[wrap=discourse-bbb meetingID="${
  34. this.meetingID
  35. }"${btnTxt} attendeePW="${this.randomID()}" moderatorPW="${this.randomID()}" mobileIframe="${
  36. this.mobileIframe
  37. }" desktopIframe="${this.desktopIframe}"][/wrap]`
  38. );
  39. this.send("closeModal");
  40. },
  41. cancel() {
  42. this.send("closeModal");
  43. },
  44. },
  45. });