/* eslint-disable node/no-unsupported-features/node-builtins */ (function($, moment, ClipboardJS, config) { $('.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 $.fn.lightGallery === 'function') { $('.article').lightGallery({ selector: '.gallery-item' }); } if (typeof $.fn.justifiedGallery === 'function') { if ($('.justified-gallery > p > .gallery-item').length) { $('.justified-gallery > p > .gallery-item').unwrap(); } $('.justified-gallery').justifiedGallery(); } 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('justify-content-start'); } else { $('.navbar-main .navbar-menu').removeClass('justify-content-start'); } } adjustNavbar(); $(window).resize(adjustNavbar); function toggleFold(codeBlock, isFolded) { const $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'); } function createFoldButton(fold) { return '' + (fold === 'unfolded' ? '' : '') + ''; } $('figure.highlight table').wrap('
'); if (typeof config !== 'undefined' && typeof config.article !== 'undefined' && typeof config.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]); } }); const clipboard = config.article.highlight.clipboard; const fold = config.article.highlight.fold.trim(); $('figure.highlight').each(function() { if ($(this).find('figcaption').length) { $(this).find('figcaption').addClass('level is-mobile'); $(this).find('figcaption').append('
'); $(this).find('figcaption').append('
'); $(this).find('figcaption div.level-left').append($(this).find('figcaption').find('span')); $(this).find('figcaption div.level-right').append($(this).find('figcaption').find('a')); } else { if (clipboard || fold) { $(this).prepend('
'); } } }); if (typeof ClipboardJS !== 'undefined' && clipboard) { $('figure.highlight').each(function() { const id = 'code-' + Date.now() + (Math.random() * 1000 | 0); const button = ''; $(this).attr('id', id); $(this).find('figcaption div.level-right').append(button); }); new ClipboardJS('.highlight .copy'); // eslint-disable-line no-new } if (fold) { $('figure.highlight').each(function() { if ($(this).find('figcaption').find('span').length > 0) { const span = $(this).find('figcaption').find('span'); if (span[0].innerText.indexOf('>folded') > -1) { span[0].innerText = span[0].innerText.replace('>folded', ''); $(this).find('figcaption div.level-left').prepend(createFoldButton('folded')); toggleFold(this, true); return; } } $(this).find('figcaption div.level-left').prepend(createFoldButton(fold)); toggleFold(this, fold === 'folded'); }); $('figure.highlight figcaption').click(function() { const $code = $(this).closest('figure.highlight'); toggleFold($code.eq(0), !$code.hasClass('folded')); }); } } const $toc = $('#toc'); if ($toc.length > 0) { const $mask = $('
'); $mask.attr('id', 'toc-mask'); $('body').append($mask); function toggleToc() { // eslint-disable-line no-inner-declarations $toc.toggleClass('is-active'); $mask.toggleClass('is-active'); } $toc.on('click', toggleToc); $mask.on('click', toggleToc); $('.navbar-main .catalogue').on('click', toggleToc); } }(jQuery, window.moment, window.ClipboardJS, window.IcarusThemeSettings));