/*-----------------------------------------------------------*/ // Scripts for Layout Notifications Components /*-----------------------------------------------------------*/ /** * Bar Layout */ //Notifications - Title & CTA layout jQuery(document).ready(function() { var notificationBars = jQuery('.ad-layout-notifications.bar'); notificationBars.each(function() { var notification = jQuery(this); notification.closest('.col-sm-12').css('min-height','0px'); var notificationsClose = notification.find('.notifications-bar-close'); notificationsClose.on('click', function(event) { event.preventDefault(); notification.toggleClass('putaway'); var dismissID = jQuery(this).parent().attr('data-notification-id'); if (dismissID) { var expires = new Date(); expires.setTime(expires.getTime()+(30*24*60*60*1000)); document.cookie = 'notification'+dismissID+'=closed; path=/; expires='+ expires.toUTCString(); } }); var notificationsSliders = jQuery(notification).find('.flexslider'); notificationsSliders.each(function() { var notificationsSlider = jQuery(this); var notificationsSliderID = jQuery(this).attr('data-slider-id'); var dismissID = jQuery(this).parent().attr('data-notification-id'); notificationsSlider.flexslider({ animation: 'fade', slideshow: false, multipleKeyboard: true, pauseOnAction: false, controlsContainer: '.controls-'+notificationsSliderID, controlNav: false, start:function(slider) { var post_id = slider.find('.flex-active-slide .ad-layout-notification').data('notification-id'); if (getCookie('notification'+dismissID) != '') { slider.closest('.ad-layout-notifications').remove(); } else { slider.closest('.ad-layout-notifications').removeClass('dismissed'); } } }); }); }); }); /** * Popover Layout */ jQuery(document).ready(function() { var notificationPopovers = jQuery('.ad-layout-notifications.notifications-popover'); notificationPopovers.each(function() { var notification = jQuery(this); notification.closest('.col-sm-12').css('min-height','0px'); var notificationsClose = notification.find('.notifications-popover-close'); notificationsClose.on('click', function(event) { event.preventDefault(); notification.addClass('dismissed'); setTimeout(function() { notification.parents('.ad-layout-notification-container').remove(); }, 300); var dismissID = jQuery(this).parent().attr('data-notification-id'); if (dismissID) { var expires = new Date(); expires.setTime(expires.getTime()+(30*24*60*60*1000)); document.cookie = 'notification'+dismissID+'=closed; path=/; expires='+ expires.toUTCString(); } }); var notificationsSliders = jQuery(notification).find('.flexslider'); notificationsSliders.each(function() { var notificationsSlider = jQuery(this); var notificationsSliderID = jQuery(this).attr('data-slider-id'); var dismissID = jQuery(this).parent().attr('data-notification-id'); notificationsSlider.flexslider({ animation: 'fade', slideshow: false, multipleKeyboard: true, pauseOnAction: false, directionNav: false, controlNav: true, start:function(slider) { var post_id = slider.find('.flex-active-slide .ad-layout-notification').data('notification-id'); if (getCookie('notification'+dismissID) != '') { slider.closest('.ad-layout-notification-container').remove(); } else { var popoverDelay = notification.data('popoverDelay') * 1000; setTimeout(function() { slider.closest('.ad-layout-notifications').removeClass('dismissed'); }, popoverDelay); } } }); }); }); }); /** * Get Cookie */ function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i