summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mail_view/ui/recipients/recipient.js
blob: 967ff61be10f113a954a8e92de3eb09034084960 (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
31
32
33
34
35
36
'use strict';

define(
  [
    'flight/lib/component',
    'views/templates'
  ],

  function (defineComponent, templates) {

    return defineComponent(recipient);

    function recipient() {
      this.renderAndPrepend = function (nodeToPrependTo, recipient) {
        var html = $(templates.compose.fixedRecipient(recipient));
        html.insertBefore(nodeToPrependTo.children().last());
        var component = new this.constructor();
        component.initialize(html, recipient);
        return component;
      };

      this.destroy = function () {
        this.$node.remove();
        this.teardown();
      };

      this.select = function () {
        this.$node.find('.recipient-value').addClass('selected');
      };

      this.unselect = function () {
        this.$node.find('.recipient-value').removeClass('selected');
      };
    }
  }
);