summaryrefslogtreecommitdiffstats
path: root/client/components/activities/events.js
blob: ea98e65fc008519879a5ceb6fbba14f9c71b40fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Template.cardActivities.events({
  'click .js-edit-action': function(evt) {
    var $this = $(evt.currentTarget);
    var container = $this.parents('.phenom-comment');

    // open and focus
    container.addClass('editing');
    container.find('textarea').focus();
  },
  'click .js-confirm-delete-action': function() {
    CardComments.remove(this._id);
  },
  'submit form': function(evt) {
    var $this = $(evt.currentTarget);
    var container = $this.parents('.phenom-comment');
    var text = container.find('textarea');

    if ($.trim(text.val())) {
      CardComments.update(this._id, {
        $set: {
          text: text.val()
        }
      });

      // reset editing class
      $('.editing').removeClass('editing');
    }
    evt.preventDefault();
  }
});