curben 2019-05-21 11:02:49 +09:30
parent e7a6071d08
commit 2ac754fa4d
2 changed files with 12 additions and 12 deletions

View File

@ -8,6 +8,6 @@
* https://hexo.io/api/tag * https://hexo.io/api/tag
* https://cloudinary.com/documentation/responsive_images * https://cloudinary.com/documentation/responsive_images
*/ */
hexo.extend.tag.register('cloudinary', function (fileName) { hexo.extend.tag.register('cloudinary', (fileName) => {
return '<img class="cld-responsive" data-src="https://res.cloudinary.com/curben/image/upload/w_auto,f_auto,q_auto,c_scale/c_limit,w_500/' + fileName + '" src="/loading.svg" />' return '<img class="cld-responsive" data-src="https://res.cloudinary.com/curben/image/upload/w_auto,f_auto,q_auto,c_scale/c_limit,w_500/' + fileName + '" src="/loading.svg" />'
}) })

View File

@ -1,7 +1,7 @@
(function ($) { (($) => {
// Fancybox caption // Fancybox caption
$('.article-entry').each(function (i) { $('.article-entry').each((i) => {
$(this).find('img').each(function () { $(this).find('img').each(() => {
// Don't insert fancybox element to cloudinary's cld-responsive img class // Don't insert fancybox element to cloudinary's cld-responsive img class
if ($(this).hasClass('cld-responsive') || $(this).parent().hasClass('fancybox')) return if ($(this).hasClass('cld-responsive') || $(this).parent().hasClass('fancybox')) return
@ -14,7 +14,7 @@
$(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>') $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>')
}) })
$(this).find('.fancybox').each(function () { $(this).find('.fancybox').each(() => {
$(this).attr('rel', 'article' + i) $(this).attr('rel', 'article' + i)
}) })
}) })
@ -34,31 +34,31 @@
code[i].appendChild(button) code[i].appendChild(button)
} }
$(document).ready(function () { $(document).ready(() => {
// Add copy to clipboard button for code snippet // Add copy to clipboard button for code snippet
const copyCode = new ClipboardJS('.copy-button', { const copyCode = new ClipboardJS('.copy-button', {
target: function (trigger) { target: (trigger) => {
return trigger.previousElementSibling return trigger.previousElementSibling
} }
}) })
copyCode.on('success', function (event) { copyCode.on('success', (event) => {
event.clearSelection() event.clearSelection()
event.trigger.textContent = 'Copied' event.trigger.textContent = 'Copied'
window.setTimeout(function () { window.setTimeout(() => {
event.trigger.textContent = 'Copy' event.trigger.textContent = 'Copy'
}, 2000) }, 2000)
}) })
copyCode.on('error', function (event) { copyCode.on('error', (event) => {
event.trigger.textContent = 'Press "Ctrl + C" to copy' event.trigger.textContent = 'Press "Ctrl + C" to copy'
window.setTimeout(function () { window.setTimeout(() => {
event.trigger.textContent = 'Copy' event.trigger.textContent = 'Copy'
}, 2000) }, 2000)
}) })
// Initialize Cloudinary responsive function // Initialize Cloudinary responsive function
const cl = cloudinary.Cloudinary.new({cloud_name: "curben"}) const cl = cloudinary.Cloudinary.new({ cloud_name: 'curben' })
cl.responsive() cl.responsive()
}) })
})(jQuery) })(jQuery)