A customizable jQuery plugin to add a banner and block scripts, compliant with EU Cookie law.
<!-- Cookie Banner core CSS file -->
<link rel="stylesheet" href="cookie-banner.css">
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Cookie Banner core JS file -->
<script src="jquery.cookie-banner.min.js"></script>
$(document).ready(function() {
$.cookieBanner({
culture: 'it',
cookiePageUrl: {
it: '/privacy/',
en: '/en/privacy/',
...
}
});
});
String: Banner class
Default: cookie-banner
Object: Policy page link text
Default: { it: 'Approfondisci', en: 'Learn more', de: 'Mehr dazu', es: 'Descubre más', ru: 'Узнайте больше' },
Object: Banner text
Default: { it: 'Questo sito utilizza cookie, anche di terze parti, per migliorare la tua esperienza di navigazione. Chiudendo questo banner, scorrendo questa pagina o cliccando qualunque suo elemento acconsenti all\'uso dei cookie.', en: 'This website uses cookies (also third-party cookies) to provide you a better navigation experience. By closing this banner, scrolling this page or by clicking any of its elements, you agree to the use of cookies.', de: 'Diese Website verwendet Cookies, auch von Dritten, um Ihre Browser-Erfahrung zu verbessern. Durch das Schließen dieses Banners, das Scrollen durch diese Seite oder einen Klick auf deren Elemente, erklären Sie sich mit der Verwendung der Cookies einverstanden.', es: 'Este sitio web utiliza cookies propias y de terceros para mejorar tu experiencia de navegación. Cerrando este banner, recorriendo esta página o haciendo clic en cualquier elemento, autorizas el uso de cookies.', ru: 'Этот Сайт использует собственные и сторонние cookie-файлы для того, чтобы предоставить Вам больше возможностей при использовании сайта. Продолжая посещение веб-сайта, вы соглашаетесь на использование cookie-файлов.' },
Boolean: Run blocked elements on consent (iframe, js, img ... )
Default: true
String: Attribute name for the original src (iframe, img ...)
Default: data-src
String: Class to identify locked items (iframe, js, img ...)
Default: block-cookie
String: Class for explicit consent button (Close X)
Default: cookie-banner__button
String: Consent button Text
Object: { it: 'Chiudi', en: 'Close', de: 'Schließen', es: 'Cerrar', ru: 'Закрыть' },
String: Class for explicit consent text
Default: cookie-banner__close
Boolean: Implicit consent on site navigation
Default: true
Boolean: Implicit consent on page scroll
Default: true
integer: Cookie expiry in days
Default: 365
String: Cookie name
Default: consentCookie
String: Privacy page url
Object: { it: '', en: '', de: '', es: '', ru: '' }
String: Specify in which language display the message
Default: en
boolean: Hide banner on page scroll. ( consentOnScroll option must be true )
Default: true
Function: Callback when cookie are accepted
Default: function() {}
String: Inserts banner at the beginning of this selector/class.
Default: body
Boolean: Reload page when button ("consentClass") is accepted
Default: false
This event is triggered when cookie are accepted
cookieConsent
Example:
$( document ).on( "cookieConsent", function() {
console.log('Cookie accepted');
});
This method return true if cookie are accepted
$.cookieBanner.consent();
if ( $.cookieBanner.consent() ) {
// Your scripts ( Run only if consent is true)
}
Original
<script type="text/javascript" src="scripts.js"></script>
Blocked
<script type="text/plain" src="scripts.js" class="block-cookie"></script>
Original
<script type="text/javascript">
// Your scripts
</script>
Blocked
<script type="text/plain" class="block-cookie">
// Your scripts ( Run only if consent is true)
</script>
Original
<iframe src="https://www.youtube.com/embed/kxopViU98Xo"></iframe>
Modified
<iframe data-src="https://www.youtube.com/embed/kxopViU98Xo" class="block-cookie"></iframe>
Copyright (c) Fabio Quarantini