minicard.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Template.cards.events({
  2. // 'click .member': Popup.open('cardMember')
  3. // });
  4. BlazeComponent.extendComponent({
  5. template: function() {
  6. return 'minicard';
  7. },
  8. isSelected: function() {
  9. return Session.equals('currentCard', this.currentData()._id);
  10. },
  11. toggleMultiSelection: function(evt) {
  12. evt.stopPropagation();
  13. evt.preventDefault();
  14. MultiSelection.toogle(this.currentData()._id);
  15. },
  16. clickOnMiniCard: function(evt) {
  17. if (MultiSelection.isActive() || evt.shiftKey) {
  18. evt.stopImmediatePropagation();
  19. evt.preventDefault();
  20. var methodName = evt.shiftKey ? 'toogleRange' : 'toogle';
  21. MultiSelection[methodName](this.currentData()._id);
  22. // If the card is already selected, we want to de-select it.
  23. // XXX We should probably modify the minicard href attribute instead of
  24. // overwriting the event in case the card is already selected.
  25. } else if (Session.equals('currentCard', this.currentData()._id)) {
  26. evt.stopImmediatePropagation();
  27. evt.preventDefault();
  28. Utils.goBoardId(Session.get('currentBoard'));
  29. }
  30. },
  31. events: function() {
  32. return [{
  33. submit: this.addCard,
  34. 'click .js-toggle-multi-selection': this.toggleMultiSelection,
  35. 'click .js-minicard': this.clickOnMiniCard,
  36. 'click .open-minicard-composer': this.scrollToBottom
  37. }];
  38. }
  39. }).register('minicard');