summaryrefslogtreecommitdiff
path: root/assets/js/components/autocomplete-email.js
blob: 8e46e1d36e57b4f15b2ccaf7082e1a74abe3e15c (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
KB.onClick('.js-autocomplete-email', function (e) {
    var email = e.target.dataset.email;
    var emailField = document.querySelector('.js-mail-form input[name="emails"]');

    if (!email || !emailField) {
        return;
    }

    if (emailField.value !== '') {
        emailField.value += ', ' + email;
    } else {
        emailField.value = email;
    }

    _KB.controllers.Dropdown.close();
});

KB.onClick('.js-autocomplete-subject', function (e) {
    var subject = KB.dom(e.target).data('subject');
    var subjectField = KB.find('.js-mail-form input[name="subject"]');

    if (subject && subjectField) {
        subjectField.build().value = subject;
    }

    _KB.controllers.Dropdown.close();
});