summaryrefslogtreecommitdiff
path: root/assets/js/components/modal.js
blob: ce6f34deb0c5b1f1573beab0910d4e81edb94dc8 (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
37
38
39
(function () {
    function getLink(e) {
        if (e.target.tagName === 'I') {
            return e.target.parentNode.getAttribute('href');
        }

        return e.target.getAttribute('href');
    }

    KB.onClick('.js-modal-large', function (e) {
        KB.modal.open(getLink(e), 'large', false);
    });

    KB.onClick('.js-modal-medium', function (e) {
        KB.modal.open(getLink(e), 'medium', false);
    });

    KB.onClick('.js-modal-small', function (e) {
        KB.modal.open(getLink(e), 'small', false);
    });

    KB.onClick('.js-modal-confirm', function (e) {
        KB.modal.open(getLink(e), 'small');
    });

    KB.onClick('.js-modal-close', function () {
        KB.modal.close();
    });

    KB.onClick('.js-modal-replace', function (e) {
        var link = getLink(e);

        if (KB.modal.isOpen()) {
            KB.modal.replace(link);
        } else {
            window.location.href = link;
        }
    });
}());