diff options
author | somratpro <abdulmonnafsomrat@gmail.com> | 2020-10-08 07:52:15 +0300 |
---|---|---|
committer | somratpro <abdulmonnafsomrat@gmail.com> | 2020-10-08 07:52:15 +0300 |
commit | 30d9e7e593ec5d64d1b454fccd0698cf6b64a33e (patch) | |
tree | 9c2e0b08fcd2877ba531cb4aa0aa2c56f39931b5 | |
parent | 27067d42f74eaa74d8cccf593abf763dcac7edf3 (diff) |
added cookie popup
-rw-r--r-- | exampleSite/config.toml | 5 | ||||
-rw-r--r-- | layouts/partials/footer.html | 46 |
2 files changed, 50 insertions, 1 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index db3ae26..bc65b77 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -86,6 +86,11 @@ map_latitude = "51.5223477" map_longitude = "-0.1622023" map_marker = "images/marker.png" +# cookies +[params.cookies] +enable = true +expire_days = 2 + # social site [[params.social]] icon = "ti-facebook" diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 2c2ec7e..7d01134 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -70,4 +70,48 @@ {{ "<!-- Main Script -->" | safeHTML }} {{ $script := resources.Get "js/script.js" | minify}} -<script src="{{ $script.Permalink }}"></script>
\ No newline at end of file +<script src="{{ $script.Permalink }}"></script> + + +<!-- 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 |