(function ($) { $('.article img:not(".not-gallery-item")').each(function () { // wrap images with link and add caption if possible if ($(this).parent('a').length === 0) { $(this).wrap(''); if (this.alt) { $(this).after('
' + this.alt + '
'); } } }); if (typeof (moment) === 'function') { $('.article-meta time').each(function () { $(this).text(moment($(this).attr('datetime')).fromNow()); }); } $('.article > .content > table').each(function () { if ($(this).width() > $(this).parent().width()) { $(this).wrap('
'); } }); function adjustNavbar() { const navbarWidth = $('.navbar-main .navbar-start').outerWidth() + $('.navbar-main .navbar-end').outerWidth(); if ($(document).outerWidth() < navbarWidth) { $('.navbar-main .navbar-menu').addClass('is-flex-start'); } else { $('.navbar-main .navbar-menu').removeClass('is-flex-start'); } } adjustNavbar(); $(window).resize(adjustNavbar); $('figure.highlight table').wrap('
'); if (typeof (IcarusThemeSettings) !== 'undefined' && typeof (IcarusThemeSettings.article) !== 'undefined' && typeof (IcarusThemeSettings.article.highlight) !== 'undefined') { $('figure.highlight').addClass('hljs'); $('figure.highlight .code .line span').each(function () { const classes = $(this).attr('class').split(/\s+/); if (classes.length === 1) { $(this).addClass('hljs-' + classes[0]); $(this).removeClass(classes[0]); } }); if (typeof (ClipboardJS) !== 'undefined' && IcarusThemeSettings.article.highlight.clipboard) { $('figure.highlight').each(function () { var id = 'code-' + Date.now() + (Math.random() * 1000 | 0); var button = ''; $(this).attr('id', id); if ($(this).find('figcaption').length) { $(this).find('figcaption').prepend(button); } else { $(this).prepend('
' + button + '
'); } }); new ClipboardJS('.highlight .copy'); } var fold = IcarusThemeSettings.article.highlight.fold; if (fold.trim()) { var button = '' + (fold === 'unfolded' ? '' : '') + ''; $('figure.highlight').each(function () { if ($(this).find('figcaption').length) { $(this).find('figcaption').prepend(button); } else { $(this).prepend('
' + button + '
'); } }); function toggleFold(codeBlock, isFolded) { var $toggle = $(codeBlock).find('.fold i'); !isFolded ? $(codeBlock).removeClass('folded') : $(codeBlock).addClass('folded'); !isFolded ? $toggle.removeClass('fa-angle-right') : $toggle.removeClass('fa-angle-down'); !isFolded ? $toggle.addClass('fa-angle-down') : $toggle.addClass('fa-angle-right'); } $('figure.highlight').each(function () { toggleFold(this, fold === 'folded'); }); $('figure.highlight figcaption .fold').click(function () { var $code = $(this).closest('figure.highlight'); toggleFold($code.eq(0), !$code.hasClass('folded')); }); } } var $toc = $('#toc'); if ($toc.length > 0) { var $mask = $('
'); $mask.attr('id', 'toc-mask'); $('body').append($mask); function toggleToc() { $toc.toggleClass('is-active'); $mask.toggleClass('is-active'); } $toc.on('click', toggleToc); $mask.on('click', toggleToc); $('.navbar-main .catalogue').on('click', toggleToc); } })(jQuery);