From 07afb167156be0cab7409d345eaeeec4078f1b87 Mon Sep 17 00:00:00 2001 From: curben Date: Thu, 25 Oct 2018 19:33:38 +1030 Subject: [PATCH] Use js standard style https://standardjs.com/ --- themes/typing/scripts/cloudinary.js | 6 +-- themes/typing/source/js/typing.js | 66 ++++++++++++++--------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/themes/typing/scripts/cloudinary.js b/themes/typing/scripts/cloudinary.js index 920c53c..5674b7a 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){ - return ''; -}); +hexo.extend.tag.register('cloudinary', function (fileName) { + return '' +}) diff --git a/themes/typing/source/js/typing.js b/themes/typing/source/js/typing.js index edbfce1..1e0aad8 100644 --- a/themes/typing/source/js/typing.js +++ b/themes/typing/source/js/typing.js @@ -23,56 +23,54 @@ $('.fancybox').fancybox() } - - //Add "Copy" button to code snippet - var code = document.getElementsByClassName('code'); + // Add "Copy" button to code snippet + var code = document.getElementsByClassName('code') for (var i = 0; i < code.length; i++) { - var button = document.createElement('button'); - button.className = 'copy-button'; - button.textContent = 'Copy'; + var button = document.createElement('button') + button.className = 'copy-button' + button.textContent = 'Copy' - code[i].appendChild(button); + code[i].appendChild(button) } - $(document).ready(function() { - + $(document).ready(function () { // Add copy to clipboard button for code snippet var copyCode = new ClipboardJS('.copy-button', { - target: function(trigger) { - return trigger.previousElementSibling; - } - }); + target: function (trigger) { + return trigger.previousElementSibling + } + }) - copyCode.on('success', function(event) { - event.clearSelection(); - event.trigger.textContent = 'Copied'; - window.setTimeout(function() { - event.trigger.textContent = 'Copy'; - }, 2000); - }); + copyCode.on('success', function (event) { + event.clearSelection() + event.trigger.textContent = 'Copied' + window.setTimeout(function () { + event.trigger.textContent = 'Copy' + }, 2000) + }) - copyCode.on('error', function(event) { - event.trigger.textContent = 'Press "Ctrl + C" to copy'; - window.setTimeout(function() { - event.trigger.textContent = 'Copy'; - }, 2000); - }); + copyCode.on('error', function (event) { + event.trigger.textContent = 'Press "Ctrl + C" to copy' + window.setTimeout(function () { + event.trigger.textContent = 'Copy' + }, 2000) + }) // Navigation menu $('#menu').click(function (event) { - var nav = $('#main-nav'); - nav.toggle('fast'); - }); + var nav = $('#main-nav') + nav.toggle('fast') + }) // Show navigation button for smaller screen $(window).resize(function () { - var viewportWidth = $(window).width(); + var viewportWidth = $(window).width() if (viewportWidth > 468) { - $('#main-nav').show('fast'); + $('#main-nav').show('fast') } else { - $('#main-nav').hide('fast'); + $('#main-nav').hide('fast') } - }); - }); + }) + }) })(jQuery)