attachments.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. Template.attachmentsGalery.events({
  2. 'click .js-add-attachment': Popup.open('cardAttachments'),
  3. 'click .js-confirm-delete': Popup.afterConfirm('attachmentDelete',
  4. function() {
  5. Attachments.remove(this._id);
  6. Popup.close();
  7. }
  8. ),
  9. // If we let this event bubble, Iron-Router will handle it and empty the
  10. // page content, see #101.
  11. 'click .js-open-viewer, click .js-download': function(event) {
  12. event.stopPropagation();
  13. },
  14. 'click .js-add-cover': function() {
  15. Cards.update(this.cardId, { $set: { coverId: this._id } });
  16. },
  17. 'click .js-remove-cover': function() {
  18. Cards.update(this.cardId, { $unset: { coverId: '' } });
  19. }
  20. });
  21. Template.cardAttachmentsPopup.events({
  22. 'change .js-attach-file': function(evt) {
  23. var card = this;
  24. FS.Utility.eachFile(evt, function(f) {
  25. var file = new FS.File(f);
  26. file.boardId = card.boardId;
  27. file.cardId = card._id;
  28. Attachments.insert(file);
  29. Popup.close();
  30. });
  31. },
  32. 'click .js-computer-upload': function(evt, tpl) {
  33. tpl.find('.js-attach-file').click();
  34. evt.preventDefault();
  35. }
  36. });