aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/bootstrap/qr_code.js
blob: 9ed0b211e159d0613991aaa76c4b1510d1522dba (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
$(document).on('click', 'a[data-qr-code]', function (event) {
    const data = $(this).data();
    STUDIP.QRCode.show(this.href, {
        print: data.qrCodePrint ?? false,
        title: data.qrTitle ?? null,
        description: data.qrCode || null,
    });

    event.preventDefault();
});

STUDIP.ready(event => {
    $('code.qr', event.target).each(function () {
        const text = $(this).text().trim();
        if ($(this).hasClass('hide-text')) {
            $(this).text('');
        }

        $(this).qrcode({
            text: text,
            width: 1280,
            height: 1280,
            correctLevel: 3
        }).addClass('has-qr-code');
    });
});