Small jQuery plugin, which adds a simple Cookie Bar with info about cookies using. Plugin is simply modified and contains clever multilingual function.
The simplest ways to download and install this plugin.
###Step 1: Install
$ npm i kovarp-jquery-cookiebar
$ git clone https://github.com/kovarp/jquery.cookieBar
Download this plugin direct in latest version from GitHub repository or from the plugin page
###Step 2: Add to page
<link rel="stylesheet" href="jquery.cookieBar.min.css">
<script src="jquery.min.js"></script>
<script src="jquery.cookieBar.js"></script>
Examples of plugin using.
$(function() {
$.cookieBar();
});
$(function() {
$.cookieBar({
style: 'bottom'
});
});
style - Define style of display cookie bar on page
default: 'top'
options: 'top', 'bottom', 'bottom-left', 'bottom-right'
wrapper - Wrapper, where the cookie bar will prepended
default: 'body'
options: string
expireDays - Number of days, when the cookies will expires
default: 365
options: integer
infoLink - URL for "more info link"
default: 'https://www.google.com/policies/technologies/cookies/'
options: string
infoTarget - Target attribute for "more info link"
default: '_blank'
options: '_blank', '_self', '_parent', '_top'
language - Language of the cookie bar
default: $('html').attr('lang') || 'en'
options: 'ISO 639-1 Language Code'
The default value means, that the plugin detect automatically language from html lang attribute.
privacy - Show privacy protection button (GDPR)
default: false
options: false, 'popup', 'bs_modal', 'link'
privacyTarget - Target attribute for "privacy button link"
default: '_blank'
options: '_blank', '_self', '_parent', '_top'
privacyContent - Content for privacy button
default: null
options: null, 'custom HTML', 'Bootstrap modal ID', 'url'
You can simply add new language for Cookie Bar. Just use addTranslation method.
$(function() {
$.cookieBar('addTranslation', 'de', {
message: 'Zur Bereitstellung von Diensten verwenden wir Cookies. Durch die Nutzung dieser Website stimmen Sie zu.',
acceptText: 'OK',
infoText: 'Mehr Informationen'
});
});
Then, you can initialize the Cookie Bar with your own language.
$(function() {
$.cookieBar({
language: 'de'
});
});
Feel free to make pull request with your new language. ;)
You can detect, if user agreed with cookies using. The plugin save this information in cookie with name cookies-state. So, you can just read this value by JS or PHP and check, if the value equals accepted.