Skip to content

Instantly share code, notes, and snippets.

@mateuszwrobel
Created April 3, 2013 12:01
Show Gist options
  • Save mateuszwrobel/5300609 to your computer and use it in GitHub Desktop.
Save mateuszwrobel/5300609 to your computer and use it in GitHub Desktop.
Popup for cookie policy Required jquery.cookie
$( function () {
var CookiePolicy = ( function () {
var policyLink = '/polityka-prywatonosci';
var wrapper = document.createElement( 'div' );
wrapper.id = 'cookie-info';
$( wrapper ).css( {
position: 'fixed',
zIndex: '1000',
backgroundColor: '#ffffff',
borderBottom: '2px solid #000',
color: '#000',
textAlign: 'center',
width: '100%',
padding: '10px 0',
top: '0'
} );
var header = document.createElement( 'p' );
$( header ).css( {
fontWeight: 'bold',
marginBottom: '5px'
} );
header.innerHTML = 'Korzystanie z witryny oznacza zgodę na wykorzystywanie plików cookie. Więcej informacji można znaleźć w <a href="' + policyLink + '" style="color: #000">polityce plików cookie</a>';
var textInfo = document.createElement( 'p' );
textInfo.innerHTML = 'Możesz określić warunki przechowywania lub dostępu do plików cookies w Twojej przeglądarce.';
var closeButton = document.createElement( 'p' );
closeButton.innerHTML = '<a href="#" class="close" style="color: #000; padding-right: 20px;">Zamknij</a>';
$( closeButton ).css( {
float: 'right',
position: 'absolute',
bottom: '10px',
right: '20px'
} );
if ( $.cookie( 'cookie-policy-displayed') != 'true' ) {
wrapper.appendChild( header );
wrapper.appendChild( textInfo );
wrapper.appendChild( closeButton );
document.body.appendChild( wrapper );
$.cookie( 'cookie-policy-displayed', true);
}
$( '.close' ).click( function ( e ) {
e.preventDefault();
$( '#cookie-info' ).remove();
} );
} )();
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment