cardDescription.js 953 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const descriptionFormIsOpen = new ReactiveVar(false);
  2. BlazeComponent.extendComponent({
  3. onDestroyed() {
  4. descriptionFormIsOpen.set(false);
  5. $('.note-popover').hide();
  6. },
  7. descriptionFormIsOpen() {
  8. return descriptionFormIsOpen.get();
  9. },
  10. getInput() {
  11. return this.$('.js-new-description-input');
  12. },
  13. events() {
  14. return [
  15. {
  16. 'submit .js-card-description'(event) {
  17. event.preventDefault();
  18. const description = this.currentComponent().getValue();
  19. this.data().setDescription(description);
  20. },
  21. // Pressing Ctrl+Enter should submit the form
  22. 'keydown form textarea'(evt) {
  23. if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
  24. const submitButton = this.find('button[type=submit]');
  25. if (submitButton) {
  26. submitButton.click();
  27. }
  28. }
  29. },
  30. },
  31. ];
  32. },
  33. }).register('descriptionForm');