diff options
author | somratpro <abdulmonnafsomrat@gmail.com> | 2020-10-08 07:48:09 +0300 |
---|---|---|
committer | somratpro <abdulmonnafsomrat@gmail.com> | 2020-10-08 07:48:09 +0300 |
commit | 0814e2a2f7ed8e5c2466ab96c9c43717a10bb2db (patch) | |
tree | 389029971c30316605731210742008eaf0b2f366 | |
parent | 8e46799d1772fea5f8222e482e1e990477d0fec6 (diff) |
added cookie popup
-rw-r--r-- | exampleSite/config.toml | 18 | ||||
-rw-r--r-- | layouts/partials/footer.html | 43 |
2 files changed, 54 insertions, 7 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 078312e..179b3ba 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -76,15 +76,19 @@ googleAnalitycsID = "" # Your ID # copyright copyright = "Copyright © 2019 [GetHugoThemes](https://gethugothemes.com) All Rights Reserved" - # Preloader - [params.preloader] - enable = true - preloader = "" # use .png , .svg or .gif format +# Preloader +[params.preloader] +enable = true +preloader = "" # use .png , .svg or .gif format - # Navigation get start button - [params.navButton] - enable = true +# Navigation get start button +[params.navButton] +enable = true +# cookies +[params.cookies] +enable = true +expire_days = 2 ############################# Footer ######################## [params.footer] diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 6a9cba5..f619fe9 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -75,4 +75,47 @@ ga('create', '{{ . }}', 'auto'); ga('send', 'pageview'); </script> +{{ end }} + +<!-- cookie --> +{{ if site.Params.cookies.enable }} +<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js"></script> +<div id="js-cookie-box" class="cookie-box cookie-box-hide"> + This site uses cookies. By continuing to use this website, you agree to their use. <span id="js-cookie-button" class="btn btn-sm btn-main ml-2">I Accept</span> +</div> +<script> + (function ($) { + const cookieBox = document.getElementById('js-cookie-box'); + const cookieButton = document.getElementById('js-cookie-button'); + if (!Cookies.get('cookie-box')) { + cookieBox.classList.remove('cookie-box-hide'); + cookieButton.onclick = function () { + Cookies.set('cookie-box', true, { + expires: {{ site.Params.cookies.expire_days }} + }); + cookieBox.classList.add('cookie-box-hide'); + }; + } + })(jQuery); +</script> + +<!-- cookie style --> +<style> +.cookie-box { + position: fixed; + left: 0; + right: 0; + bottom: 0; + text-align: center; + z-index: 9999; + padding: 1rem 2rem; + background: rgb(71, 71, 71); + transition: all .75s cubic-bezier(.19, 1, .22, 1); + color: #fdfdfd; +} + +.cookie-box-hide { + display: none; +} +</style> {{ end }}
\ No newline at end of file |