cardDescription.js 827 B

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