Instantly share code, notes, and snippets.
Created
October 17, 2019 10:18
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save yogeshdubey2006/e07824655c53169e9cd8e5a481c88b86 to your computer and use it in GitHub Desktop.
Magento 2 - EU Cookie Law Notice custom code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* CSS.less************************************/ | |
#band-cookies { | |
position:fixed; | |
bottom:0; | |
left:0; | |
z-index:200; | |
width:100%; | |
padding:10px 0; | |
text-align:center; | |
font-size:14px; | |
line-height:1.1; | |
box-shadow: 0 -5px 5px rgba(0, 0, 0, 0.15); | |
p { | |
margin:0; | |
padding:0 50px; | |
font-size: 17px; | |
} | |
#band-cookies-info, | |
#band-cookies-ok { | |
display: inline-block; | |
/*color:#EF3D22;*/ | |
margin-left: 10px; | |
cursor: pointer; | |
padding: 0 12px; | |
border-radius: 22px; | |
background-color: #fff; | |
border: 1px solid #fff; | |
font-weight: 600; | |
font-family: "NeoTech", Sans-Serif; | |
font-size: 13px; | |
height: 24px; | |
font-style: italic; | |
line-height: 24px; | |
&:hover { | |
background-color: transparent; | |
color: #fff !important; | |
border: 1px solid #fff; | |
} | |
} | |
#band-cookies-close { | |
height:16px; | |
width:16px; | |
padding:8px; | |
position:absolute; | |
right:20px; | |
top: 12%; | |
background-color:transparent !important; | |
} | |
@media (max-width:991px) { | |
padding-bottom: 20px; | |
p { | |
padding:20px 15px 0 | |
} | |
#band-cookies-info, | |
#band-cookies-ok { | |
display:block; | |
text-decoration:none; | |
margin: 15px 0 0; | |
width: 100%; | |
} | |
#band-cookies-close { | |
left: 50%; | |
top: -19px; | |
margin-left: -15px; | |
background-color: #000 !important; | |
right: auto; | |
border-radius: 100%; | |
width: 40px; | |
height: 40px; | |
line-height: 26px; | |
font-size: 13px !important; | |
border: 3px solid #DBDBDB; | |
svg { | |
width: 12px; | |
} | |
} | |
} | |
} | |
/*************************************/ | |
/*************************************/ | |
/**EU Cookie Law Notice Plugin - Cookies Message START******************************/ | |
require([ | |
'jquery' | |
], function(jQuery){ | |
jQuery(function($) { | |
!function(e){e.CookiesMessage=function(o){function n(o){var i="";1==o.closeEnable&&(i+='<a href="#" id="band-cookies-close" style="background-color:'+o.closeBgColor+';"><svg version="1.1" id="band-cookies-close-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="16px" height="16px" viewBox="248.5 248.5 15 15" enable-background="new 248.5 248.5 15 15" xml:space="preserve" ><polygon id="x-mark-icon" points="263.5,260.876 258.621,255.999 263.499,251.121 260.876,248.5 256,253.377 251.122,248.5 248.5,251.121 253.378,255.999 248.5,260.878 251.121,263.5 256,258.62 260.879,263.499" style="fill:'+o.closeColor+';"/></svg></a>');var n="";1==o.acceptEnable&&(n+='<a href="#" id="band-cookies-ok">'+o.acceptText+"</a>"),1==o.infoEnable&&(n+='<a href="'+o.infoUrl+'" id="band-cookies-info">'+o.infoText+"</a>");var c='<div id="band-cookies"><p>'+o.messageText+n+"</p>"+i+"</div>";e("body").prepend(c),e("#band-cookies").hide().slideDown(),e("#band-cookies").css({"background-color":o.messageBg,color:o.messageColor}),e("#band-cookies p a").css({color:o.messageLinkColor})}function c(e){return e.replace(/^\s+|\s+$/g,"")}function s(e){var o=!1;if(document.cookie){var n=document.cookie.split(";");for(i=0;i<n.length;i++){var s=n[i].split("=");c(s[0])==e&&(o=s[1])}}return o}function a(e,o,i,n){var c=new Date;c.setTime(c.getTime()+24*i*60*60*1e3);var s="expires="+c.toUTCString();document.cookie=e+"="+o+"; "+s+"; path="+n+";"}; | |
var l={ | |
messageText:"By continuing to use this site, you agree to the use of cookies.", | |
messageBg:"#151515", | |
messageColor:"#FFFFFF", | |
messageLinkColor:"#000", | |
closeEnable:!0, | |
closeColor:"#FFF", | |
closeBgColor:"#DDD", | |
acceptEnable:!0, | |
acceptText:"Accept & Close", | |
infoEnable:!0, | |
infoText:"More Info", | |
infoUrl:"#", | |
cookieExpire:30 | |
};o=e.extend(l,o);var t=location.host,r="Cookies policy accepted",d="/",g=s(t);g||n(o),e("#band-cookies-ok").on("click",function(i){i.preventDefault(),a(t,r,o.cookieExpire,d),e("#band-cookies").slideToggle()}),e("#band-cookies-close").on("click",function(o){o.preventDefault(),e("#band-cookies").slideToggle()})}}(jQuery); | |
$(document).ready(function() { | |
$.CookiesMessage({ | |
messageText: "By continuing to use this site, you agree to the use of cookies.", | |
messageBg: "#000", // Message box background color | |
messageColor: "#FFFFFF", // Message box text color | |
messageLinkColor: "#000", // Message box links color | |
closeEnable: true, // Show the close icon | |
closeColor: "#FFF", // Close icon color | |
closeBgColor: "#DDD", // Close icon background color | |
acceptEnable: true, // Show the Accept button | |
acceptText: "Accept & Close", // Accept button text | |
infoEnable: true, // Show the More Info button | |
infoText: "More Info", // More Info button text | |
infoUrl: "/cookie-policy", // More Info button URL | |
cookieExpire: 30 // Cookie expire time (days) | |
}); | |
}); | |
}); | |
}); | |
/**EU Cookie Law Notice Plugin - Cookies Message END******************************/ | |
/*************************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment