CLI_ACCEPT_COOKIE_NAME =(typeof CLI_ACCEPT_COOKIE_NAME !== 'undefined' ? CLI_ACCEPT_COOKIE_NAME : 'viewed_cookie_policy'); CLI_PREFERNCE_COOKIE =(typeof CLI_PREFERNCE_COOKIE !== 'undefined' ? CLI_PREFERNCE_COOKIE : 'CookieLawInfoConsent'); CLI_ACCEPT_COOKIE_EXPIRE =(typeof CLI_ACCEPT_COOKIE_EXPIRE !== 'undefined' ? CLI_ACCEPT_COOKIE_EXPIRE : 365); CLI_COOKIEBAR_AS_POPUP=(typeof CLI_COOKIEBAR_AS_POPUP !== 'undefined' ? CLI_COOKIEBAR_AS_POPUP : false); var CLI_Cookie={ set: function (name, value, days) { var secure = ""; if ( true === Boolean( Cli_Data.secure_cookies ) ) secure = ";secure"; var domain = ( Cli_Data.cookieDomain !== '' ? ";domain=" + Cli_Data.cookieDomain : '' ); var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = ";expires=" + date.toGMTString(); if( days < 1 ){ this.eraseCookie(name,expires); } else { document.cookie = name + "=" + value + secure + expires + domain + ";path=/"; } }, read: function (name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1, c.length); } if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length, c.length); } } return null; }, erase: function (name) { this.set(name, "", -10); }, eraseCookie: function( name, expires, index ){ if( this.cookieExist(name) === false ) { return false; } var _hostname = window.location.hostname; var value = ""; if (typeof index === 'undefined') { index = 0; } if( index === 0 ){ _hostname = _hostname.substring(_hostname.lastIndexOf(".", _hostname.lastIndexOf(".")-1)); } else if( index === 1 ){ _hostname = ( Cli_Data.cookieDomain !== '' ? Cli_Data.cookieDomain : '' ); } else if( index === 2 ) { if(_hostname.indexOf("www") != 1) { _hostname = _hostname.replace('www',''); } } index = index + 1; document.cookie = name + "=" + value + expires + ";domain="+ _hostname + ";path=/"; if (index <= 2 ) { this.eraseCookie( name, expires, index); } }, exists: function (name) { return (this.read(name) !== null); }, getallcookies:function() { var pairs = document.cookie.split(";"); var cookieslist = {}; for (var i = 0; i < pairs.length; i++) { var pair = pairs[i].split("="); cookieslist[(pair[0] + '').trim()] = unescape(pair[1]); } return cookieslist; }, cookieExist: function( name ){ cookie_pattern = new RegExp("^(.*;)?\\s*"+name+"\\s*=\\s*[^;]+(.*)?$"); if(!document.cookie.match(cookie_pattern)) { return false; } return true; } } var CLI= { bar_config:{}, consent:{}, allowedCategories:[], showagain_config:{}, set:function(args) { if(typeof JSON.parse !== "function") { console.log("CookieLawInfo requires JSON.parse but your browser doesn't support it"); return; } if(typeof args.settings!=='object') { this.settings = JSON.parse(args.settings); }else { this.settings = args.settings; } this.bar_elm=jQuery(this.settings.notify_div_id); this.showagain_elm = jQuery(this.settings.showagain_div_id); this.banner_heading = jQuery('#wt-cli-cookie-banner-title'); //buttons this.main_button = jQuery('.cli-plugin-main-button'); this.main_link = jQuery('.cli-plugin-main-link'); this.reject_link = jQuery('.cookie_action_close_header_reject'); this.settings_link = jQuery('.cli_settings_button'); this.delete_link=jQuery(".cookielawinfo-cookie-delete"); this.accept_all_button = jQuery('.wt-cli-accept-all-btn'); if(this.settings.cookie_bar_as=='popup') { CLI_COOKIEBAR_AS_POPUP=true; } this.mayBeSetPreferenceCookie(); this.cliRenewConsent(); this.configBar(); this.toggleBar(); this.attachDelete(); this.attachEvents(); this.configButtons(); this.addStyleAttribute(); this.settingsPopUp(); this.cookieLawInfoRunCallBacks(); this.acceptPageNavigation(); var cli_hidebar_on_readmore=this.hideBarInReadMoreLink(); if(this.settings.scroll_close===true && cli_hidebar_on_readmore===false) { window.addEventListener("scroll",CLI.closeOnScroll, false); } }, hideBarInReadMoreLink:function() { if(CLI.settings.button_2_hidebar===true && this.main_link.length>0 && this.main_link.hasClass('cli-minimize-bar')) { jQuery('.wt-cli-cookie-bar-container').addClass('wt-cli-hide-bar'); this.hideHeader(); this.showagain_elm.slideDown(this.settings.animate_speed_show); return true; } return false; }, settingsPopUp:function() { jQuery(document).on('click keypress','.cli_settings_button',function(e){ var key = e.which; e.preventDefault(); if(key === 1 || key === 13) { if(CLI.settings.cookie_setting_popup==true) { jQuery('#cliSettingsPopup').addClass("cli-show").css({'opacity':0}).animate({'opacity':1}); jQuery('#cliSettingsPopup').removeClass('cli-blowup cli-out').addClass("cli-blowup"); jQuery('#cliSettingsPopup').attr('aria-hidden', false); jQuery('body').addClass("cli-modal-open"); jQuery(".cli-settings-overlay").addClass("cli-show"); jQuery("#cookie-law-info-bar").css({'opacity':.1}); jQuery("#cliModalClose").focus(); if(!jQuery('.cli-settings-mobile').is(':visible')) { jQuery('#cliSettingsPopup').find('.cli-nav-link:eq(0)').click(); } } else { jQuery('#cookie-law-info-bar .cli-tab-container').slideToggle(CLI.settings.animate_speed_show); } } }); jQuery('#cliModalClose').click(function(){ CLI.settingsPopUpClose(); }); jQuery('#cliModalClose').keydown(function(e) { var key = e.which if(key === 9) { if(e.shiftKey === true) { e.preventDefault() jQuery('#wt-cli-privacy-save-btn').focus() } } }); document.addEventListener('keydown', function(e) { var key = e.which; if(key === 27 && jQuery('#cliSettingsPopup').hasClass('cli-show')) { CLI.settingsPopUpClose(); } }); jQuery("#cliSettingsPopup").click(function(e){ if(!(document.getElementsByClassName('cli-modal-dialog')[0].contains(e.target))) { CLI.settingsPopUpClose(); } }); jQuery('.cli_enable_all_btn').click(function(){ var cli_toggle_btn = jQuery(this); var enable_text = cli_toggle_btn.attr('data-enable-text'); var disable_text= cli_toggle_btn.attr('data-disable-text'); if(cli_toggle_btn.hasClass('cli-enabled')){ CLI.disableAllCookies(); cli_toggle_btn.html(enable_text); } else { CLI.enableAllCookies(); cli_toggle_btn.html(disable_text); } jQuery(this).toggleClass('cli-enabled'); }); this.settingsTabbedAccordion(); this.toggleUserPreferenceCheckBox(); this.privacyReadmore(); }, settingsTabbedAccordion:function() { jQuery(document).on('click keypress','.cli-tab-header',function(e){ if (!(jQuery(e.target).hasClass('cli-slider') || jQuery(e.target).hasClass('cli-user-preference-checkbox'))) { var key = e.which; e.preventDefault(); if (key === 1 || key === 13) { var currentElement = jQuery(this); var tabLink = currentElement.closest('.cli-tab-header').find('.cli-nav-link'); if (currentElement.hasClass("cli-tab-active")) { currentElement.removeClass("cli-tab-active"); currentElement.siblings(".cli-tab-content").slideUp(200); tabLink.attr('aria-expanded', false); } else { jQuery(".cli-tab-header").removeClass("cli-tab-active"); currentElement.addClass("cli-tab-active"); jQuery(".cli-tab-content").slideUp(200); currentElement.siblings(".cli-tab-content").slideDown(200); tabLink.attr('aria-expanded', true); } } } }); }, settingsPopUpClose:function() { jQuery('#cliSettingsPopup').removeClass('cli-show'); jQuery('#cliSettingsPopup').addClass('cli-out'); jQuery('#cliSettingsPopup').attr('aria-hidden', true); jQuery('body').removeClass("cli-modal-open"); jQuery(".cli-settings-overlay").removeClass("cli-show"); jQuery("#cookie-law-info-bar").css({'opacity':1}); jQuery("#cookie-law-info-bar .cli_settings_button").focus(); }, toggleUserPreferenceCheckBox:function() { jQuery('.cli-user-preference-checkbox').each(function(){ var categoryCookie = 'cookielawinfo-'+jQuery(this).attr('data-id'); var categoryCookieValue = CLI_Cookie.read(categoryCookie); if( categoryCookieValue == null ) { if(jQuery(this).is(':checked')) { CLI_Cookie.set(categoryCookie,'yes',CLI_ACCEPT_COOKIE_EXPIRE); }else { CLI_Cookie.set(categoryCookie,'no',CLI_ACCEPT_COOKIE_EXPIRE); } } else { if(categoryCookieValue == "yes") { jQuery(this).prop("checked",true); } else { jQuery(this).prop("checked",false); } } }); jQuery('.cli-user-preference-checkbox').click(function(){ var dataID = jQuery(this).attr('data-id'); var currentToggleElm = jQuery('.cli-user-preference-checkbox[data-id='+dataID+']'); if(jQuery(this).is(':checked')) { CLI_Cookie.set('cookielawinfo-'+dataID,'yes',CLI_ACCEPT_COOKIE_EXPIRE); currentToggleElm.prop('checked',true); }else { CLI_Cookie.set('cookielawinfo-'+dataID,'no',CLI_ACCEPT_COOKIE_EXPIRE); currentToggleElm.prop('checked',false); } CLI.checkCategories(); CLI.generate_user_preference_cookie(); CLI.generateConsent(); }); }, attachEvents:function() { jQuery(document).on('click keypress','.wt-cli-privacy-btn',function(e){ var key = e.which; e.preventDefault(); if(key === 1 || key === 13) { var action = jQuery(this).attr('data-cli-action'); if( action === 'accept_all') { CLI.enableAllCookies(); } CLI.accept_close(); CLI.saveLog('accept'); CLI.settingsPopUpClose(); } }); jQuery('.wt-cli-privacy-overview-actions').find('a').last().keydown(function(e) { var key = e.which if(key === 9) { if(e.shiftKey === false) { e.preventDefault() jQuery('#cliModalClose').focus() } } }); jQuery(document).on('click keypress','.cli_action_button',function(e){ var key = e.which; e.preventDefault(); if(key === 1 || key === 13) { var elm=jQuery(this); var button_action=elm.attr('data-cli_action'); var open_link=elm[0].hasAttribute("href") && elm.attr("href").charAt(0) !== '#' ? true : false; var new_window=false; if(button_action=='accept') { if (e.originalEvent !== undefined) { if(CLI.settings.accept_all==true) { CLI.enableAllCookies(); } } else { CLI.settingsPopUpClose(); } CLI.accept_close(); new_window=CLI.settings.button_1_new_win ? true : false; } else if( button_action == 'accept_all') { CLI.enableAllCookies(); CLI.accept_close(); new_window=CLI.settings.button_7_new_win ? true : false; } else if(button_action=='reject') { CLI.disableAllCookies(); CLI.reject_close(); new_window=CLI.settings.button_3_new_win ? true : false; } CLI.saveLog(button_action); if(open_link) { if(new_window) { window.open(elm.attr("href"),'_blank'); }else { window.location.href =elm.attr("href"); } } } }); jQuery(document).on('click','.cli_cookie_close_button',function(e){ e.preventDefault(); var elm=jQuery(this); var button_action=elm.attr('data-cli_action'); if(CLI.settings.accept_all==true) { CLI.enableAllCookies(); } CLI.accept_close(); CLI.saveLog(button_action); }); }, saveLog:function(button_action) { if(CLI.settings.logging_on) { var ccpaOptedOut = cliBlocker.ccpaOptedOut(); cookies = CLI_Cookie.getallcookies(); cookies.ccpaOptout = ccpaOptedOut; jQuery.ajax({ url: log_object.ajax_url, type: 'POST', data:{ action: 'wt_log_visitor_action', wt_clicked_button_id: '', wt_user_action:button_action, cookie_list:cookies }, success:function (response) { } }); } }, attachDelete:function() { this.delete_link.click(function () { CLI_Cookie.erase(CLI_ACCEPT_COOKIE_NAME); for(var k in Cli_Data.nn_cookie_ids) { CLI_Cookie.erase(Cli_Data.nn_cookie_ids[k]); } CLI.generate_user_preference_cookie(); CLI.generateConsent(); window.location.reload(); return false; }); }, configButtons:function() { //[cookie_button] this.main_button.css('color',this.settings.button_1_link_colour); if(this.settings.button_1_as_button) { this.main_button.css('background-color',this.settings.button_1_button_colour); this.main_button.hover(function () { jQuery(this).css('background-color',CLI.settings.button_1_button_hover); },function (){ jQuery(this).css('background-color',CLI.settings.button_1_button_colour); }); } //[cookie_link] this.main_link.css('color',this.settings.button_2_link_colour); if(this.settings.button_2_as_button) { this.main_link.css('background-color',this.settings.button_2_button_colour); this.main_link.hover(function () { jQuery(this).css('background-color',CLI.settings.button_2_button_hover); },function (){ jQuery(this).css('background-color',CLI.settings.button_2_button_colour); }); } //[cookie_reject] this.reject_link.css('color',this.settings.button_3_link_colour); if(this.settings.button_3_as_button) { this.reject_link.css('background-color',this.settings.button_3_button_colour); this.reject_link.hover(function () { jQuery(this).css('background-color',CLI.settings.button_3_button_hover); },function () { jQuery(this).css('background-color',CLI.settings.button_3_button_colour); }); } //[cookie_settings] this.settings_link.css('color',this.settings.button_4_link_colour); if(this.settings.button_4_as_button) { this.settings_link.css('background-color',this.settings.button_4_button_colour); this.settings_link.hover(function () { jQuery(this).css('background-color',CLI.settings.button_4_button_hover); },function () { jQuery(this).css('background-color',CLI.settings.button_4_button_colour); }); } //[cookie_accept_all] this.accept_all_button.css('color',this.settings.button_7_link_colour); if(this.settings.button_7_as_button) { this.accept_all_button.css('background-color',this.settings.button_7_button_colour); this.accept_all_button.hover(function () { jQuery(this).css('background-color',CLI.settings.button_7_button_hover); },function (){ jQuery(this).css('background-color',CLI.settings.button_7_button_colour); }); } }, toggleBar:function() { if(CLI_COOKIEBAR_AS_POPUP) { this.barAsPopUp(1); } if(CLI.settings.cookie_bar_as=='widget') { this.barAsWidget(1); } if(this.settings.show_once_yn) { setTimeout(function(){ if(!CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)) { CLI.close_header(); } },CLI.settings.show_once); } this.showagain_elm.on('click keypress', function (e) { var key = e.which; if(key === 1 || key === 13) { e.preventDefault(); CLI.showagain_elm.slideUp(CLI.settings.animate_speed_hide, function() { CLI.bar_elm.slideDown(CLI.settings.animate_speed_show); CLI.refocusElement(); if(CLI_COOKIEBAR_AS_POPUP) { CLI.showPopupOverlay(); } }); } }); }, configShowAgain:function() { this.showagain_config = { 'background-color': this.settings.background, 'color':this.settings.text, 'position': 'fixed', 'font-family': this.settings.font_family }; if(this.settings.border_on) { var border_to_hide = 'border-' + this.settings.notify_position_vertical; this.showagain_config['border'] = '1px solid ' + this.l1hs(this.settings.border); this.showagain_config[border_to_hide] = 'none'; } var cli_win=jQuery(window); var cli_winw=cli_win.width(); var showagain_x_pos=this.settings.showagain_x_position; if(cli_winw<300) { showagain_x_pos=10; this.showagain_config.width=cli_winw-20; }else { this.showagain_config.width='auto'; } var cli_defw=cli_winw>400 ? 500 : cli_winw-20; if(CLI_COOKIEBAR_AS_POPUP) //cookie bar as popup { var sa_pos=this.settings.popup_showagain_position; var sa_pos_arr=sa_pos.split('-'); if(sa_pos_arr[1]=='left') { this.showagain_config.left=showagain_x_pos; }else if(sa_pos_arr[1]=='right') { this.showagain_config.right=showagain_x_pos; } if(sa_pos_arr[0]=='top') { this.showagain_config.top=0; }else if(sa_pos_arr[0]=='bottom') { this.showagain_config.bottom=0; } this.bar_config['position'] = 'fixed'; }else if(this.settings.cookie_bar_as=='widget') { this.showagain_config.bottom=0; if(this.settings.widget_position=='left') { this.showagain_config.left=showagain_x_pos; }else if(this.settings.widget_position=='right') { this.showagain_config.right=showagain_x_pos; } } else { if(this.settings.notify_position_vertical == "top") { this.showagain_config.top = '0'; } else if(this.settings.notify_position_vertical == "bottom") { this.bar_config['position'] = 'fixed'; this.bar_config['bottom'] = '0'; this.showagain_config.bottom = '0'; } if(this.settings.notify_position_horizontal == "left") { this.showagain_config.left =showagain_x_pos; }else if(this.settings.notify_position_horizontal == "right") { this.showagain_config.right =showagain_x_pos; } } this.showagain_elm.css(this.showagain_config); }, configBar:function() { var templateID = ''; this.bar_config = { 'background-color':this.settings.background, 'color':this.settings.text, 'font-family':this.settings.font_family }; if (jQuery(".wt-cli-template")[0]) { var templateElm = jQuery(".wt-cli-template"); var templateClasses = templateElm.attr('class'); var templateClasses = templateClasses.split(" "); var matchingID = templateClasses.filter(function (value) { return value.match(/\bcli-style/); }); templateID = matchingID[0]; this.bar_elm.attr('data-template-id',templateID); } if(jQuery(".wt-cli-category-widget")[0]) { this.bar_elm.addClass('wt-cli-category-widget-active'); } if(this.settings.cookie_setting_popup===false) { this.barPopupStyle(); } if(this.settings.notify_position_vertical=="top") { this.bar_config['top'] = '0'; if(this.settings.header_fix === true) { this.bar_config['position'] = 'fixed'; } }else { this.bar_config['bottom'] = '0'; } this.configShowAgain(); this.bar_elm.css(this.bar_config).hide(); }, l1hs:function(str) { if (str.charAt(0) == "#") { str = str.substring(1, str.length); } else { return "#" + str; } return this.l1hs(str); }, close_header:function() { CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME,'yes',CLI_ACCEPT_COOKIE_EXPIRE); if(CLI.settings.accept_all==true) { CLI.enableAllCookies(); } CLI.accept_close(); this.hideHeader(); CLI.saveLog('accept'); }, accept_close:function() { this.hidePopupOverlay(); CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME,'yes',CLI_ACCEPT_COOKIE_EXPIRE); if(this.settings.notify_animate_hide) { this.bar_elm.slideUp(this.settings.animate_speed_hide,cliBlocker.runScripts); }else { this.bar_elm.hide(0,cliBlocker.runScripts); } if(this.settings.showagain_tab) { this.showagain_elm.slideDown(this.settings.animate_speed_show); } this.generate_user_preference_cookie(); this.generateConsent(); CLI.cookieLawInfoRunCallBacks(); if(this.settings.accept_close_reload === true) { this.reload_current_page(); } return false; }, reject_close:function() { this.hidePopupOverlay(); for(var k in Cli_Data.nn_cookie_ids) { CLI_Cookie.erase(Cli_Data.nn_cookie_ids[k]); } CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME,'no',CLI_ACCEPT_COOKIE_EXPIRE); if(this.settings.notify_animate_hide) { this.bar_elm.slideUp(this.settings.animate_speed_hide,cliBlocker.runScripts); }else { this.bar_elm.hide(0,cliBlocker.runScripts); } if(this.settings.showagain_tab) { this.showagain_elm.slideDown(this.settings.animate_speed_show); } this.generate_user_preference_cookie(); CLI.generateConsent(); if(this.settings.reject_close_reload === true) { this.reload_current_page(); } return false; }, generate_user_preference_cookie:function() { var cli_user_preference_arr=new Array(); var cli_user_preference_val=''; if(CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)) { cli_user_preference_arr.push('cli-'+CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)); } jQuery('.cli-user-preference-checkbox').each(function(){ if(jQuery(this).is(':checked')) { cli_user_preference_arr.push(jQuery(this).attr('data-id')+'-yes'); }else { cli_user_preference_arr.push(jQuery(this).attr('data-id')+'-no'); } }); if(cli_user_preference_arr.length>0) { cli_user_preference_val=Cli_Data.current_lang+'-'+cli_user_preference_arr.join('-'); } CLI_Cookie.set('cli_user_preference',cli_user_preference_val,CLI_ACCEPT_COOKIE_EXPIRE); }, isBase64:function(str) { if (str ==='' || str.trim() ===''){ return false; } try { return btoa(atob(str)) == str; } catch (err) { return false; } }, generateConsent:function() { var preferenceCookie = CLI_Cookie.read(CLI_PREFERNCE_COOKIE); cliConsent = {}; if(preferenceCookie !== null) { if(CLI.isBase64(preferenceCookie)) { cliConsent = window.atob(preferenceCookie); } else { cliConsent = decodeURIComponent(preferenceCookie); } cliConsent = JSON.parse(cliConsent); } cliConsent.ver = Cli_Data.consentVersion; categories = []; jQuery('.cli-user-preference-checkbox').each(function(){ categoryVal = ''; cli_chkbox_data_id = jQuery(this).attr('data-id'); cli_chkbox_data_id = cli_chkbox_data_id.replace('checkbox-',''); if(jQuery(this).is(':checked')) { categoryVal = 'true'; } else { categoryVal = 'false'; } cliConsent[cli_chkbox_data_id] = categoryVal; }); cliConsent = JSON.stringify(cliConsent); cliConsent = window.btoa(cliConsent); CLI_Cookie.set(CLI_PREFERNCE_COOKIE,cliConsent,CLI_ACCEPT_COOKIE_EXPIRE); }, cliRenewConsent:function() { var preferenceCookie = CLI_Cookie.read(CLI_PREFERNCE_COOKIE); if(preferenceCookie !== null) { if(CLI.isBase64(preferenceCookie)) { cliConsent = window.atob(preferenceCookie); } else { cliConsent = decodeURIComponent(preferenceCookie); } cliConsent = JSON.parse(cliConsent); consentCurrentVersion = parseInt(cliConsent.ver); consentRenewVersion = parseInt(Cli_Data.consentVersion); if( typeof(cliConsent.ver) !== 'undefined') { if(cliConsent.ver !== Cli_Data.consentVersion) { CLI_Cookie.erase(CLI_ACCEPT_COOKIE_NAME); CLI_Cookie.erase(CLI_PREFERNCE_COOKIE); CLI_Cookie.erase('cli_user_preference'); for(var k in Cli_Data.nn_cookie_ids) { CLI_Cookie.erase(Cli_Data.nn_cookie_ids[k]); } } } } }, reload_current_page:function() { window.location.reload(); }, add_clear_cache_url_query:function() { var cli_rand=new Date().getTime()/1000; var cli_url=window.location.href; var cli_hash_arr=cli_url.split('#'); var cli_urlparts= cli_hash_arr[0].split('?'); if(cli_urlparts.length>=2) { var cli_url_arr=cli_urlparts[1].split('&'); cli_url_temp_arr=new Array(); for(var cli_i=0; cli_i0 ? '&': '')+'cli_action='; }else { cli_url=cli_hash_arr[0]+'?cli_action='; } cli_url+=cli_rand; if(cli_hash_arr.length>1) { cli_url+='#'+cli_hash_arr[1]; } return cli_url; }, closeOnScroll:function() { if(window.pageYOffset > 100 && !CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)) { if(CLI.settings.accept_all==true) { CLI.enableAllCookies(); } CLI.accept_close(); CLI.saveLog('accept'); if(CLI.settings.scroll_close_reload === true) { window.location.reload(); } window.removeEventListener("scroll",CLI.closeOnScroll,false); } }, displayHeader:function() { if(this.settings.notify_animate_show) { this.bar_elm.slideDown(this.settings.animate_speed_show); }else { this.bar_elm.show(); CLI.refocusElement(); } this.showagain_elm.hide(); if(CLI_COOKIEBAR_AS_POPUP) { this.showPopupOverlay(); } }, hideHeader:function() { if(this.settings.showagain_tab) { if(this.settings.notify_animate_show) { this.showagain_elm.slideDown(this.settings.animate_speed_show); } else { this.showagain_elm.show(); } }else { this.showagain_elm.hide(); } this.bar_elm.slideUp(this.settings.animate_speed_show); this.hidePopupOverlay(); }, hidePopupOverlay:function() { jQuery('body').removeClass("cli-barmodal-open"); jQuery(".cli-popupbar-overlay").removeClass("cli-show"); }, showPopupOverlay:function() { if( this.bar_elm.length ) { if(this.settings.popup_overlay) { if( ! ( this.main_link.hasClass('cli-minimize-bar') )) { jQuery('body').addClass("cli-barmodal-open"); jQuery(".cli-popupbar-overlay").addClass("cli-show"); } } } }, barAsWidget:function(a) { var cli_elm=this.bar_elm; cli_elm.attr('data-cli-type','widget'); var cli_win=jQuery(window); var cli_winh=cli_win.height()-40; var cli_winw=cli_win.width(); var cli_defw=cli_winw>465 ? 445 : cli_winw-60; cli_elm.css({ 'width':cli_defw,'height':'auto','max-height':cli_winh,'overflow':'auto','position':'fixed','box-shadow':'rgba(0,0,0,.5) 0px 5px 10px','box-sizing':'border-box' }); if(this.settings.widget_position=='left') { cli_elm.css({ 'left':'30px','right':'auto','bottom':'30px','top':'auto' }); }else { cli_elm.css({ 'left':'auto','right':'30px','bottom':'30px','top':'auto' }); } if(a) { this.setResize(); } }, barAsPopUp:function(a) { if(typeof cookie_law_info_bar_as_popup==='function') { return false; } var cli_elm=this.bar_elm; cli_elm.attr('data-cli-type','popup'); var cli_win=jQuery(window); var cli_winh=cli_win.height(); var cli_defh = cli_winh > 500 ? 500 : cli_winh; var cli_winw=cli_win.width(); var cli_defw=cli_winw>700 ? 500 : cli_winw-20; //var cli_defw=cli_defw<500 ? 500 : cli_defw; cli_elm.css({ 'width':cli_defw,'height':'auto','max-height':cli_defh,'bottom':'','top':'50%','left':'50%','transform':'translate(-50%, -50%)','overflow':'auto' }); if(a) { this.setResize(); } }, setResize:function() { var resizeTmr=null; jQuery(window).resize(function() { clearTimeout(resizeTmr); resizeTmr=setTimeout(function() { if(CLI_COOKIEBAR_AS_POPUP) { CLI.barAsPopUp(); } if(CLI.settings.cookie_bar_as=='widget') { CLI.barAsWidget(); } CLI.configShowAgain(); },500); }); }, isValidHex:function(color) { if(!color || typeof color !== 'string') return false; // Validate hex values if(color.substring(0, 1) === '#') color = color.substring(1); switch(color.length) { case 3: return /^[0-9A-F]{3}$/i.test(color); case 6: return /^[0-9A-F]{6}$/i.test(color); case 8: return /^[0-9A-F]{8}$/i.test(color); default: return false; } return false; }, ColorLuminance:function(hex, lum) { // validate hex string hex = String(hex).replace(/[^0-9a-f]/gi, ''); if (hex.length < 6) { hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]; } lum = lum || 0; // convert to decimal and change luminosity var rgb = "#", c, i; for (i = 0; i < 3; i++) { c = parseInt(hex.substr(i*2,2), 16); c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16); rgb += ("00"+c).substr(c.length); } return rgb; }, rgb2hex:function(rgb){ rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i); return (rgb && rgb.length === 4) ? "#" + ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : ''; }, lightOrDark:function(color) { // Variables for red, green, blue values var r, g, b, hsp; // Check the format of the color, HEX or RGB? if (color.match(/^rgb/)) { // If HEX --> store the red, green, blue values in separate variables color = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/); r = color[1]; g = color[2]; b = color[3]; } else { // If RGB --> Convert it to HEX: http://gist.github.com/983661 color = +("0x" + color.slice(1).replace( color.length < 5 && /./g, '$&$&')); r = color >> 16; g = color >> 8 & 255; b = color & 255; } // HSP (Highly Sensitive Poo) equation from http://alienryderflex.com/hsp.html hsp = Math.sqrt( 0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b) ); // Using the HSP value, determine whether the color is light or dark if (hsp>127.5) { return 'light'; } else { return 'dark'; } }, barPopupStyle:function() { var acceptBtn = jQuery('.cli_action_button[data-cli_action=accept]'); var primaryColor = this.settings.button_1_button_colour; var primaryLinkColor = this.settings.button_1_link_colour; var barColor = this.settings.background; var extractedStyle = ''; var primaryBtnStyle = this.settings.button_1_style; Object.keys(primaryBtnStyle).forEach(function(element) { extractedStyle+=primaryBtnStyle[element][0]+':'+primaryBtnStyle[element][1]+';'; }); var shadeColor; if(!CLI.isValidHex(barColor)) { barColor=CLI.rgb2hex(barColor); } if(barColor=="#000000") { shadeColor='#191919'; } else { var intensity=CLI.lightOrDark(barColor); if(intensity=='light') { shadeColor = CLI.ColorLuminance(barColor, -0.05); } else { shadeColor = CLI.ColorLuminance(barColor, 0.4); } } jQuery("