(($) => {
// Fancybox caption
$('.article-entry').each((i) => {
$(this).find('img').each(() => {
// Don't insert fancybox element to cloudinary's cld-responsive img class
if ($(this).hasClass('cld-responsive') || $(this).parent().hasClass('fancybox')) return
const alt = this.alt
if (alt) {
$(this).after('' + alt + '')
}
$(this).wrap('')
})
$(this).find('.fancybox').each(() => {
$(this).attr('rel', 'article' + i)
})
})
if ($.fancybox) {
$('.fancybox').fancybox()
}
})(jQuery)
// Search button function
const searchClick = document.getElementById('searchClick')
searchClick.onclick = function() {
window.open('https://gitlab.com/search?utf8=%E2%9C%93&search=' +
document.getElementById('searchTxt').value +
'&group_id=&project_id=8306723&search_code=true&repository_ref=master')
}
// Add "Copy" button to code snippet
const code = document.getElementsByClassName('code')
for (let i = 0; i < code.length; i++) {
const button = document.createElement('button')
button.className = 'copy-button'
button.textContent = 'Copy'
code[i].appendChild(button)
}
/*
* Copy button and Cloudinary functions.
* Following functions only execute after
* the 'document' is ready or
*