Skip to content
Snippets Groups Projects
Select Git revision
  • 044134b190155bae9dffb9b137cb950c9fe59e67
  • 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

opengraph.js

Blame
  • Forked from Stud.IP / Stud.IP
    3740 commits behind the upstream repository.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    opengraph.js 1.93 KiB
    function handleOpenGraphSections() {
        $('.opengraph-area:not(.handled)').each(function() {
            var items = $('.opengraph', this),
                switcher;
            if (items.length > 1) {
                items.filter(':gt(0)').addClass('hidden');
    
                switcher = $('<ul class="switcher">');
                $('<li><button class="switch-left" disabled>&lt;</button></li>').appendTo(switcher);
                $('<li><button class="switch-right">&gt;</button></li>').appendTo(switcher);
                switcher.prependTo(this);
            }
    
            $(this).addClass('handled');
        });
    }
    
    STUDIP.ready(handleOpenGraphSections);
    $(document).on('ajaxComplete', handleOpenGraphSections);
    
    $(document).on('click', '.opengraph-area .switcher button', function (event) {
        var direction = $(this).is('.switch-left') ? 'left' : 'right',
            current = $(this)
                .closest('.opengraph-area')
                .find('.opengraph:visible'),
            switcher = $(this).closest('.switcher'),
            buttons = {
                left: $('.switch-left', switcher),
                right: $('.switch-right', switcher)
            };
    
        if (direction === 'left') {
            current = current
                .addClass('hidden')
                .prev()
                .removeClass('hidden');
            buttons.left.attr('disabled', current.prev('.opengraph').length === 0);
            buttons.right.attr('disabled', false);
        } else {
            current = current
                .addClass('hidden')
                .next()
                .removeClass('hidden');
            buttons.left.attr('disabled', false);
            buttons.right.attr('disabled', current.next('.opengraph').length === 0);
        }
    
        event.preventDefault();
    }).on('click', '.opengraph a.flash-embedder', function (event) {
        let url = $(this).attr('href');
        let template = _.template('<iframe width="100%" height="200px" frameborder="0" src="<%= url %>" allowfullscreen></iframe>');
        $(this).replaceWith(template({ url: url }));
    
        event.preventDefault();
    });