Skip to content

Latest commit

 

History

History
69 lines (67 loc) · 3.65 KB

README.md

File metadata and controls

69 lines (67 loc) · 3.65 KB

cookie-z

A jquery plugin that shows a GDPR compliant cookie warning according to the language set on the users device.

License: MIT

Setting up cookie-z

  1. Import the jQuery library
  2. Load the cookie-z script in your HTML after the body
<script type="text/javascript" src="jquery.cookie-z.min.js"></script>
  1. Create the template for the cookie warning on your page. Example:
<div class="cookie-warning">
  <div class="cookie-warning-inner">
    <p class="cookie-warning-text"></p>
    <button class="cookie-warning-close"></button>
  </div>
</div>
  1. Call the cookie-z plugin on the wrapper of your cookie warning
$('.cookie-warning').cookiez();

Changing defaults

  1. Use JSON to change the options
    1. Example of disabling automated language detection, setting the default language and changing the animation to fade:
      $('.cookie-warning').cookiez({
        autoLang: false,
        defaultLang: 'en',
        animation: 'fade',
      });

Available options

NOTE: if you set autoLang to false it will use the default language's text

NOTE: if you want to overwrite a language use the customLanguages JSON Array

Option Description Default value Var type
autoLang Turning automated language detection on or off. true boolean
defaultLang Locale of the language to use if the detected language is not found en string
animation Change the animation of toggling the cookie warning (slide or fade) slide string
fadeTime Speed of the fade animation (in miliseconds) 350 integer
cookieConfName Name of the cookie to set when the user has confirmed cookie-warning-confirmed string
customLanguages.[locale].cookieWarning Cookie warning text for a custom language (v1.1.0 supports HTML) null string
customLanguages.[locale].btnClose Confirm button Text for a custom language (v1.1.0 supports HTML) null string
elements.selectors.wrapper Selector for the cookie warning wrapper .cookie-warning string
elements.selectors.text Selector for the element to place the warning into .cookie-warning-text string
elements.selectors.btnClose Selector for the element the user clicks on to confirm .cookie-warning-close string

Predefined languages

  1. English
  2. German

Adding your own language

  1. When calling the cookie-z plugin add the customLanguages JSON Array to the parameters as follows:
  $('.cookie-warning').cookiez({
      customLanguages: {
        fb: {
          cookieWarning: "foo",
          btnClose: "bar"
        }
      }
    });

NOTE: the locale of the language in this example is fb. After defining the custom language, you can use it as a default language with the defaultLang option.


forthebadge forthebadge