diff options
author | Dimitri Staessens <[email protected]> | 2019-10-06 21:10:46 +0200 |
---|---|---|
committer | Dimitri Staessens <[email protected]> | 2019-10-06 21:10:46 +0200 |
commit | 568553394d0a8b34668a75c9839a0f1f426469b2 (patch) | |
tree | 175c08844f05611b059ba6900fb6519dbbc735d2 /themes/docsy/layouts/partials/feedback.html | |
parent | d5d6f70371958eec0679831abd283498ff2731e5 (diff) | |
download | website-568553394d0a8b34668a75c9839a0f1f426469b2.tar.gz website-568553394d0a8b34668a75c9839a0f1f426469b2.zip |
theme: Switch to docsy theme
Diffstat (limited to 'themes/docsy/layouts/partials/feedback.html')
-rw-r--r-- | themes/docsy/layouts/partials/feedback.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/themes/docsy/layouts/partials/feedback.html b/themes/docsy/layouts/partials/feedback.html new file mode 100644 index 0000000..0978321 --- /dev/null +++ b/themes/docsy/layouts/partials/feedback.html @@ -0,0 +1,57 @@ +<style> + .feedback--answer { + display: inline-block; + } + .feedback--answer-no { + margin-left: 1em; + } + .feedback--response { + display: none; + margin-top: 1em; + } + .feedback--response__visible { + display: block; + } +</style> +<h2 class="feedback--title">Feedback</h2> +<p class="feedback--question">Was this page helpful?</p> +<button class="feedback--answer feedback--answer-yes">Yes</button> +<button class="feedback--answer feedback--answer-no">No</button> +<p class="feedback--response feedback--response-yes"> + {{ .yes | safeHTML }} +</p> +<p class="feedback--response feedback--response-no"> + {{ .no | safeHTML }} +</p> +<script> + const yesButton = document.querySelector('.feedback--answer-yes'); + const noButton = document.querySelector('.feedback--answer-no'); + const yesResponse = document.querySelector('.feedback--response-yes'); + const noResponse = document.querySelector('.feedback--response-no'); + const disableButtons = () => { + yesButton.disabled = true; + noButton.disabled = true; + }; + const sendFeedback = (value) => { + if (typeof ga !== 'function') return; + const args = { + command: 'send', + hitType: 'event', + category: 'Helpful', + action: 'click', + label: window.location.pathname, + value: value + }; + ga(args.command, args.hitType, args.category, args.action, args.label, args.value); + }; + yesButton.addEventListener('click', () => { + yesResponse.classList.add('feedback--response__visible'); + disableButtons(); + sendFeedback(1); + }); + noButton.addEventListener('click', () => { + noResponse.classList.add('feedback--response__visible'); + disableButtons(); + sendFeedback(0); + }); +</script> |