Mediawiki:common.js

Вернуться

Строка 7: Строка 7:
         break;
         break;
}
}
$(document).ready(function () {
    if (mw.cookie.get('videoPopupShown') === '1') {
        return;
    }
    var $overlay = $('<div>').css({
        position: 'fixed',
        top: 0, left: 0, right: 0, bottom: 0,
        background: 'rgba(0,0,0,0.9)',
        zIndex: 999999,
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center'
    });
    var $videoContainer = $('<div>').css({
        width: '90%',
        maxWidth: '800px',
        aspectRatio: '16 / 9'
    }).html(
        '<iframe width="100%" height="100%" ' +
        'src="https://www.youtube.com/embed/BXqLhBhQen4?autoplay=1&rel=0&modestbranding=1&showinfo=0" ' +
        'title="YouTube video" frameborder="0" ' +
        'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" ' +
        'allowfullscreen></iframe>'
    );
    $overlay.append($videoContainer).appendTo('body');
    $overlay.on('click', function(e) {
        if (e.target === this) {
            $overlay.remove();
            mw.cookie.set('videoPopupShown', '1', { expires: 60*60*24*14 });
        }
    });
    $(document).on('keydown.videoPopup', function(e) {
        if (e.key === 'Escape') {
            $overlay.remove();
            mw.cookie.set('videoPopupShown', '1', { expires: 60*60*24*14 });
            $(document).off('keydown.videoPopup');
        }
    });
});