diff options
author | somratpro <abdulmonnafsomrat@gmail.com> | 2020-10-18 10:31:03 +0300 |
---|---|---|
committer | somratpro <abdulmonnafsomrat@gmail.com> | 2020-10-18 10:31:03 +0300 |
commit | 1f3760ef85dc51ec0dfa5fa756fcc53c12405ec9 (patch) | |
tree | 16ab9e53418cd91454f0c3dd97e4b639a2e360de | |
parent | da924364374aa21238874c9e42a1b34dac1a3390 (diff) |
added js-cookies
-rw-r--r-- | exampleSite/config.toml | 5 | ||||
-rw-r--r-- | layouts/partials/footer.html | 44 |
2 files changed, 49 insertions, 0 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 4c4dba5..9b7d187 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -82,6 +82,11 @@ copyright = "Designed By [Themefisher](https://themefisher.com/) & Developed By enable = true preloader = "" # use jpg, png, svg or gif format. +# cookies +[params.cookies] +enable = true +expire_days = 2 + ############################# social site ######################## [[params.social]] diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index e51ea0b..4d63180 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -38,4 +38,48 @@ 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-primary 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 |