Skip to content
Snippets Groups Projects
Select Git revision
  • 855bde5580816f3ab5ad4661ae41fe8c86e53a70
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

qr_code.js

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    qr_code.js 1.49 KiB
    jQuery(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 () {
            let content = $(this).text().trim();
            let code    = $('<div class="qrcode">').hide();
            STUDIP.QRCode.generate(code[0], content, {
                width: 1024,
                height: 1024
            });
            $(this).replaceWith(code);
            setTimeout(() => code.show(), 0);
        });
        jQuery(document).on(
            'click',
            '#qr_code .PrintAction',
            function() {
                //We must hide the other page elements for the print view functionality.
                //Furthermore we must set the width and height of the qr-code.
                jQuery('#layout_wrapper').css(
                    {
                        display: 'none'
                    }
                );
                jQuery('#qr_code').addClass('print-view');
    
                //Now we can print:
                window.print();
            }
        );
    
        jQuery(document).on(
            'fullscreenchange webkitfullscreenchange mozfullscreenchange MSFullscreenChange',
            function(event) {
                //After the print action is called
                //we must reset the style changes made above:
                jQuery('#layout_wrapper').removeAttr('style');
            }
        );
    });