1/*! 2 * Cookie Bar component (https://github.com/kovarp/jquery.cookieBar) 3 * Version 1.2.6 + Klondyke sticky preferences support 4 * 5 * Copyright 2020 Pavel Kovár - Frontend developer [www.pavelkovar.cz] 6 * @license: MIT 7 */ 8 9if (typeof jQuery === 'undefined') { 10 throw new Error('Cookie Bar component requires jQuery') 11} 12 13(function ( $ ) { 14 15 var cookieBar, config; 16 17 var translation = []; 18 19 translation['en'] = { 20 message: 'We use cookies to provide our services. By using this website, you agree to this.', 21 acceptText: 'OK', 22 infoText: 'More information', 23 privacyText: 'Privacy protection', 24 preferencesText: 'Cookie Preferences' 25 }; 26 27 translation['de'] = { 28 message: 'Zur Bereitstellung von Diensten verwenden wir Cookies. Durch die Nutzung dieser Website stimmen Sie zu.', 29 acceptText: 'OK', 30 infoText: 'Mehr Informationen', 31 privacyText: 'Datenschutz', 32 preferencesText: 'Cookie Preferences' 33 }; 34 35 translation['cs'] = { 36 message: 'K poskytování slueb vyuíváme soubory cookie. Pouíváním tohoto webu s tím souhlasíte.', 37 acceptText: 'V porádku', 38 infoText: 'Více informací', 39 privacyText: 'Ochrana soukromí', 40 preferencesText: 'Cookie Preferences' 41 }; 42 43 translation['sk'] = { 44 message: 'Na poskytovanie sluieb vyuívame súbory cookie. Pouívaním tohto webu s tým súhlasíte.', 45 acceptText: 'V poriadku', 46 infoText: 'Viac informácií', 47 privacyText: 'Ochrana súkromia', 48 preferencesText: 'Cookie Preferences' 49 }; 50 51 translation['ru'] = { 52 message: '?????? ???? ?????????? ??? ?????????????? ?????, ?????????????? ?????????? ? ??????? ??????? ???????. ????????? ???? ????, ?? ????????????.', 53 acceptText: '? ????????', 54 infoText: '?????? ??????????', 55 privacyText: '??????????????????', 56 preferencesText: 'Cookie Preferences' 57 }; 58 59 translation['ua'] = { 60 message: '?? ?????????????? ????? cookies ??? ??????? ??????. ?????????????? ??? ????, ?? ???????????? ?? ??.', 61 acceptText: '??????', 62 infoText: '?????? ??????????', 63 privacyText: '?????? ????????????????', 64 preferencesText: 'Cookie Preferences' 65 }; 66 67 translation['pl'] = { 68 message: 'Uzywamy plików cookie w celu swiadczenia naszych uslug. Korzystajac z tej strony, zgadzasz sie na to.', 69 acceptText: 'Dobrze', 70 infoText: 'Wiecej informacji', 71 privacyText: 'Ochrona prywatnosci', 72 preferencesText: 'Cookie Preferences' 73 }; 74 75 translation['es'] = { 76 message: 'Este sitio web utiliza cookies para mejorar su experiencia. Si continúas navegando, consideraremos que aceptas su uso.', 77 acceptText: 'Aceptar', 78 infoText: 'Más información', 79 privacyText: 'Protección de datos', 80 preferencesText: 'Cookie Preferences' 81 }; 82 83 var methods = { 84 init : function(options) { 85 cookieBar = '#cookie-bar'; 86 87 var pageLanguage = ($('html').attr('lang') || 'en').substring(0, 2).toLowerCase(); 88 89 var defaults = { 90 infoLink: 'https://www.klondyke.co.uk/privacy-policy/', 91 infoTarget: '_blank', 92 wrapper: 'body', 93 expireDays: 365, 94 style: 'top', 95 language: pageLanguage, 96 privacy: false, 97 privacyTarget: '_blank', 98 privacyContent: null, 99 preferences: true 100 }; 101 102 config = $.extend(defaults, options); 103 104 if(!translation[config.language]) { 105 config.language = 'en'; 106 } 107 108 if(methods.getCookie('cookies-state') !== 'accepted') { 109 methods.displayBar(); 110 } else { 111 // Already accepted: show sticky preferences button 112 if (typeof window.kgShowStickyCookieBtn === 'function') { 113 window.kgShowStickyCookieBtn(); 114 } 115 } 116 117 // Accept cookies (OK) 118 $(document).on('click', cookieBar + ' .cookie-bar__btn', function(e) { 119 e.preventDefault(); 120 121 if (typeof window.kgSaveCookiePreference === 'function') { 122 window.kgSaveCookiePreference(true); 123 return; 124 } 125 126 methods.setCookie('cookies-state', 'accepted', config.expireDays); 127 methods.hideBar(); 128 129 if (typeof window.kgShowStickyCookieBtn === 'function') { 130 window.kgShowStickyCookieBtn();
131 } 132 }); 133 134 // Open cookie preferences (bar link + sticky button) 135 $(document).on('click', '[data-toggle="cookieBarPreferences"]', function(e) { 136 e.preventDefault(); 137 138 if (typeof window.kgOpenCookiePreferences === 'function') { 139 window.kgOpenCookiePreferences(); 140 } else { 141 window.location.hash = 'cookie-preferences'; 142 } 143 }); 144 145 // Open privacy info popup 146 $(document).on('click', '[data-toggle="cookieBarPrivacyPopup"]', function(e) { 147 e.preventDefault(); 148 methods.showPopup(); 149 }); 150 151 // Close privacy info popup 152 $(document).on('click', '.cookie-bar-privacy-popup, .cookie-bar-privacy-popup__dialog__close', function(e) { 153 methods.hidePopup(); 154 }); 155 156 $(document).on('click', '.cookie-bar-privacy-popup__dialog', function(e) { 157 e.stopPropagation(); 158 }); 159 }, 160 displayBar : function() { 161 $(cookieBar).remove(); 162 163 if (!$.trim($(config.wrapper).html())) { 164 $(config.wrapper).empty(); 165 } 166 167 var acceptButton = '<button type="button" class="cookie-bar__btn">' + translation[config.language].acceptText + '</button>'; 168 var preferencesText = translation[config.language].preferencesText || translation['en'].preferencesText; 169 var preferencesLink = ''; 170 var infoLink = '<a href="' + config.infoLink + '" target="' + config.infoTarget + '" class="cookie-bar__link cookie-bar__link--cookies-info">' + translation[config.language].infoText + '</a>'; 171 172 if (config.preferences) { 173 preferencesLink = '<a href="#cookie-preferences" data-toggle="cookieBarPreferences" class="cookie-bar__link cookie-bar__link--preferences">' + preferencesText + '</a>'; 174 } 175 176 var privacyButton = ''; 177 if (config.privacy) { 178 if (config.privacy === 'link') { 179 privacyButton = '<a href="' + config.privacyContent + '" target="' + config.privacyTarget + '" class="cookie-bar__link cookie-bar__link--privacy-info">' + translation[config.language].privacyText + '</a>'; 180 } else if (config.privacy === 'bs_modal') { 181 privacyButton = '<a href="' + config.privacyContent + '" data-toggle="modal" class="cookie-bar__link cookie-bar__link--privacy-info">' + translation[config.language].privacyText + '</a>'; 182 } else if (config.privacy === 'popup') { 183 methods.renderPopup(); 184 privacyButton = '<a href="#" data-toggle="cookieBarPrivacyPopup" class="cookie-bar__link cookie-bar__link--privacy-info">' + translation[config.language].privacyText + '</a>'; 185 } 186 } 187 188 var template = '<div id="cookie-bar" class="cookie-bar cookie-bar--' + config.style + '"><div class="cookie-bar__inner"><span class="cookie-bar__message">' + translation[config.language].message + '</span><span class="cookie-bar__buttons">' + acceptButton + preferencesLink + infoLink + privacyButton + '</span></div></div>'; 189 190 if (config.style === 'top') { 191 $(config.wrapper).prepend(template); 192 } else { 193 $(config.wrapper).append(template); 194 } 195 196 $('body').addClass('has-cookie-bar'); 197 198 if (config.style === 'bottom') { 199 $(config.wrapper).css('padding-bottom', $('#cookie-bar').outerHeight()); 200 } 201 }, 202 hideBar : function() { 203 $(cookieBar).slideUp(); 204 $('body').removeClass('has-cookie-bar'); 205 206 if (config.style === 'bottom') { 207 $(config.wrapper).css('padding-bottom', ''); 208 } 209 210 if (typeof window.kgShowStickyCookieBtn === 'function') { 211 window.kgShowStickyCookieBtn(); 212 } 213 }, 214 renderPopup : function() { 215 var popup = $('<div id="cookieBarPrivacyPopup" class="cookie-bar-privacy-popup cookie-bar-privacy-popup--hidden"><div class="cookie-bar-privacy-popup__dialog"><button type="button" class="cookie-bar-privacy-popup__dialog__close"></button></div></div>'); 216 $('body').append(popup); 217 $('.cookie-bar-privacy-popup__dialog', popup).append(config.privacyContent); 218 }, 219 showPopup : function() { 220 $('#cookieBarPrivacyPopup').removeClass('cookie-bar-privacy-popup--hidden'); 221 }, 222 hidePopup : function() { 223 $('#cookieBarPrivacyPopup').addClass('cookie-bar-privacy-popup--hidden'); 224 }, 225 addTranslation : function(lang, translate) { 226 translation[lang] = translate; 227 }, 228 switchTranslation : function(lang) { 229 if(lang !== config.language && !config.privacy) { 230 if(!translation[lang]) { 231 config.language = 'en'; 232 } else { 233 config.language = lang; 234 } 235 if(methods.getCookie('cookies-state') !== 'accepted') { 236 methods.displayBar(); 237 } 238 } 239 }, 240 setCookie : function(cname, cvalue, exdays) { 241 var d = new Date(); 242 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 243 var expires = "expires="+ d.toUTCString(); 244 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 245 }, 246 getCookie : function(cname) { 247 var name = cname + "="; 248 var ca = document.cookie.split(';'); 249 250 for(var i = 0; i <ca.length; i++) { 251 var c = ca[i];
252 while (c.charAt(0) === ' ') { 253 c = c.substring(1); 254 } 255 if (c.indexOf(name) === 0) { 256 return c.substring(name.length, c.length); 257 } 258 } 259 return ''; 260 } 261 }; 262 263 $.cookieBar = function (methodOrOptions) { 264 if ( methods[methodOrOptions] ) { 265 return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 )); 266 } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) { 267 return methods.init.apply( this, arguments ); 268 } else { 269 $.error( 'Method ' + methodOrOptions + ' does not exist on Cookie Bar component' ); 270 } 271 }; 272}( jQuery ));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.