jQuery(document).ready(function($){ function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i 1) { var anb_current_limitation_times = anb_limitation_cookie -1; var d = new Date(); var n = d.setTime(d.getTime() + (anb_limitations_days*24*60*60*1000)); document.cookie = anb_limitation_name + "=" + anb_current_limitation_times + "; expires=" + d.toUTCString(); } else { $(this).parent().remove(); var anb_show = false; } } else { var d = new Date(); var n = d.setTime(d.getTime() + (anb_limitations_days*24*60*60*1000)); document.cookie = anb_limitation_name + "=" + anb_limitations_times + "; expires=" + d.toUTCString(); } } if (anb_show) { var anb_delay = $(this).data("anb-delay"); if (anb_delay > 0) { setTimeout(function(){ $('#anb-id-'+anb_id).removeClass('delay'); }, anb_delay*1000); } var anb_show_time = ($(this).data("anb-show-time") + anb_delay)*1000; if (anb_show_time > 0) { var anb_animation_out_class = $(this).data("anb-animation-out-class"); var anb_animation_out_speed = $(this).data("anb-animation-out-speed")*1000; setTimeout(function(){ $('#anb-id-'+anb_id).addClass(anb_animation_out_class); setTimeout(function(){ $('#anb-id-'+anb_id).parent().fadeOut( 400, function() { $(this).remove(); }); }, anb_animation_out_speed); }, anb_show_time); } } }); $('body').on("click", ".anb-close", function(e){ var anb_alert = $(this).closest(".anb"); var anb_id = $(anb_alert).data("anb-id"); var anb_close_days = $(anb_alert).data("anb-close-button"); if (anb_close_days > 0) { var anb_close_status = true; var d = new Date(); var n = d.setTime(d.getTime() + (anb_close_days*24*60*60*1000)); document.cookie = "anb_close_" + anb_id + "=" + anb_close_status + "; expires=" + d.toUTCString() ; } var anb_animation_out_class = $(anb_alert).data("anb-animation-out-class"); var anb_animation_out_speed = $(anb_alert).data("anb-animation-out-speed")*1000; $(anb_alert).addClass(anb_animation_out_class); setTimeout(function(){ $('#anb-id-'+anb_id).parent().fadeOut( 400, function() { $(this).remove(); }); }, anb_animation_out_speed); }); });