From feeaca491f9094cc2635396abb3569af780fbc8a Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Fri, 20 Dec 2019 02:44:20 +0000 Subject: [PATCH] fix(js): load copy button script in post only --- .../layout/_partial/after-footer.ejs | 5 ++- themes/chameleon/source/js/chameleon.js | 31 ------------------- themes/chameleon/source/js/copy-button.js | 29 +++++++++++++++++ 3 files changed, 33 insertions(+), 32 deletions(-) create mode 100644 themes/chameleon/source/js/copy-button.js diff --git a/themes/chameleon/layout/_partial/after-footer.ejs b/themes/chameleon/layout/_partial/after-footer.ejs index 6085256..2b8ee81 100644 --- a/themes/chameleon/layout/_partial/after-footer.ejs +++ b/themes/chameleon/layout/_partial/after-footer.ejs @@ -1,5 +1,8 @@ <% if (is_post()) { %> -<%- js({ src: '/libs/clipboard.js/2.0.4/clipboard.min.js', 'data-sri-fallback': '/js/clipboard.min.js', integrity: 'sha384-8CYhPwYlLELodlcQV713V9ZikA3DlCVaXFDpjHfP8Z36gpddf/Vrt47XmKDsCttu', crossorigin: 'anonymous', defer: true}) %> +<%- js([ + { src: '/libs/clipboard.js/2.0.4/clipboard.min.js', 'data-sri-fallback': '/js/clipboard.min.js', integrity: 'sha384-8CYhPwYlLELodlcQV713V9ZikA3DlCVaXFDpjHfP8Z36gpddf/Vrt47XmKDsCttu', crossorigin: 'anonymous', defer: true }, + '/js/copy-button.js' + ]) %> <% } %> <%/* javascript of Chameleon theme */%> diff --git a/themes/chameleon/source/js/chameleon.js b/themes/chameleon/source/js/chameleon.js index 75cc3e8..f5be359 100644 --- a/themes/chameleon/source/js/chameleon.js +++ b/themes/chameleon/source/js/chameleon.js @@ -6,34 +6,3 @@ document.getElementById('searchClick').addEventListener('click', () => { document.getElementById('searchClickMob').addEventListener('click', () => { searchFormMob.submit() }, false) - -/* -* Copy button -* Following functions only execute after -* the 'document' is ready or -*