/hrms_core/Views/Shared/_CookieConsentPartial.cshtml
https://bitbucket.org/dotnetavis/hrms · Razor · 32 lines · 30 code · 2 blank · 0 comment · 0 complexity · 1e13fa5990fcdf6e46e4e6e107b1ab3e MD5 · raw file
- @using Microsoft.AspNetCore.Http.Features
- @{
- var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
- var showBanner = !consentFeature?.CanTrack ?? false;
- var cookieString = consentFeature?.CreateConsentCookie();
- }
- <style>
- .close {
- right: 0px !important;
- color: #d73434 !important;
- opacity: 0.5 !important;
- }
- </style>
- CookiePartial
- @if (showBanner)
- {
- <div id="cookieConsent" style="background-color:forestgreen" class="alert alert-info alert-dismissible show" role="alert">
- Use this space to summarize your privacy and cookie use policy. <a asp-area="" asp-controller="Home" asp-action="Privacy">Learn More</a>.
- <button type="button" class="accept-policy close" data-dismiss="alert" aria-label="Close" data-cookie-string="@cookieString">
- <span aria-hidden="true">Accept</span>
- </button>
- </div>
- <script>
- (function () {
- var button = document.querySelector("#cookieConsent button[data-cookie-string]");
- button.addEventListener("click", function (event) {
- document.cookie = button.dataset.cookieString;
- }, false);
- })();</script>
- }