cardDescription.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. // was keydown
  23. // extraevent for saving input. buffer of keydown vs buffer time
  24. 'keyup form textarea'(evt) {
  25. const description = this.getInput()[0].value;
  26. this.data().setDescription(description);
  27. if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
  28. const submitButton = this.find('button[type=submit]');
  29. if (submitButton) {
  30. submitButton.click();
  31. }
  32. }
  33. },
  34. },
  35. ];
  36. },
  37. }).register('descriptionForm');