From 2ac754fa4d15c5f72f15af7accb067648cb5436f Mon Sep 17 00:00:00 2001 From: curben Date: Tue, 21 May 2019 11:02:49 +0930 Subject: [PATCH] style: arrow function https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions --- themes/typing/scripts/cloudinary.js | 2 +- themes/typing/source/js/typing.js | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/themes/typing/scripts/cloudinary.js b/themes/typing/scripts/cloudinary.js index c5b3ad9..e3a16c6 100644 --- a/themes/typing/scripts/cloudinary.js +++ b/themes/typing/scripts/cloudinary.js @@ -8,6 +8,6 @@ * https://hexo.io/api/tag * https://cloudinary.com/documentation/responsive_images */ -hexo.extend.tag.register('cloudinary', function (fileName) { +hexo.extend.tag.register('cloudinary', (fileName) => { return '' }) diff --git a/themes/typing/source/js/typing.js b/themes/typing/source/js/typing.js index d353a48..b44fed4 100644 --- a/themes/typing/source/js/typing.js +++ b/themes/typing/source/js/typing.js @@ -1,7 +1,7 @@ -(function ($) { +(($) => { // Fancybox caption - $('.article-entry').each(function (i) { - $(this).find('img').each(function () { + $('.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 @@ -14,7 +14,7 @@ $(this).wrap('') }) - $(this).find('.fancybox').each(function () { + $(this).find('.fancybox').each(() => { $(this).attr('rel', 'article' + i) }) }) @@ -34,31 +34,31 @@ code[i].appendChild(button) } - $(document).ready(function () { + $(document).ready(() => { // Add copy to clipboard button for code snippet const copyCode = new ClipboardJS('.copy-button', { - target: function (trigger) { + target: (trigger) => { return trigger.previousElementSibling } }) - copyCode.on('success', function (event) { + copyCode.on('success', (event) => { event.clearSelection() event.trigger.textContent = 'Copied' - window.setTimeout(function () { + window.setTimeout(() => { event.trigger.textContent = 'Copy' }, 2000) }) - copyCode.on('error', function (event) { + copyCode.on('error', (event) => { event.trigger.textContent = 'Press "Ctrl + C" to copy' - window.setTimeout(function () { + window.setTimeout(() => { event.trigger.textContent = 'Copy' }, 2000) }) // Initialize Cloudinary responsive function - const cl = cloudinary.Cloudinary.new({cloud_name: "curben"}) + const cl = cloudinary.Cloudinary.new({ cloud_name: 'curben' }) cl.responsive() }) })(jQuery)