$(document).ready(function() { /*Adding elements*/ $('body').append(""); $('body').append("
"); $("#alert-customer-order").append("
close
"); $("#alert-customer-order").append("
"); $("#alert-customer-order").append("
"); /*End - adding elements*/ function getCookie(name) {var cookie = document.cookie;var prefix = name + "=";var begin = cookie.indexOf("; " + prefix);if (begin == -1) {begin = cookie.indexOf(prefix);if (begin != 0) return null;} else {begin += 2;var end = document.cookie.indexOf(";", begin);if (end == -1) {end = cookie.length;}}return unescape(cookie.substring(begin + prefix.length, end));} var posTop = getCookie("customerBoxPositionTop"); var posLeft = getCookie("customerBoxPositionLeft"); var posTopString = ""; var posLeftString = ""; if(posTop != null && posLeft != null){ //$("#alert-customer-order").css({"top": posTop, "left": posLeft}); posTopString = posTop + "px"; posLeftString = posLeft + "px"; $('#alert-customer-order').css({ transform: "none", top: posTopString, left: posLeftString }); $('#alert-customer-order').addClass("highestZ"); //console.log(posTopString + " " + posLeftString); } /*Close button*/ $(".close-customer-order a").on('click', function(){ event.preventDefault(); $("#alert-customer-order").fadeOut(500).delay(12000); var d = new Date(); d.setTime(d.getTime() + 1800000); document.cookie = 'noalert=true;path=/;expires='+d.toGMTString()+';'; }); /*End- Close Button*/ $('#alert-customer-order').draggable( { start: function() { if(posTop != null && posLeft != null){ $(this).css({ transform: "none", top: posTopString, left: posLeftString, }); $('#alert-customer-order').addClass("highestZ"); }else{ $(this).css({ transform: "none", top: $(this).offset().top + "px", left: $(this).offset().left + "px" }); } }, drag: function(event, ui){ }, stop: function( event, ui ) { $('#alert-customer-order').addClass("highestZ"); var pos = ui.position; var left = pos['left']; var top = pos['top']; //console.log(left + " " + top); var d = new Date(); d.setTime(d.getTime() + 2592000000); document.cookie = 'customerBoxPositionTop='+top+';path=/;expires='+d.toGMTString()+';'; document.cookie = 'customerBoxPositionLeft='+left+';path=/;expires='+d.toGMTString()+';'; } } ); if (getCookie("noalert") == null) { /*Main func*/ var alertDiv = $("#alert-customer-order"); alertDiv.css("visibility", "hidden"); var timeforAlerts, duration=10000; var countOfAlerts = 0; var alertsArray = ["
Sneha from Kolkata, West Bengal, India bought MarketWatch + Benzinga Distribution
1 year ago","
Onor from Marietta, Ga, United States bought PR Distribution Web Distribution
1 year ago","
Howard from Mission Viejo , CA, United States bought PR Distribution Multi-Wire Pro Distribution
1 year ago","
Laura from Dallas, TX, United States bought PR Distribution Web Plus Distribution
1 year ago","
Sam from London, London, United Kingdom bought Single PR Multi-Wire Concierge Distribution
1 year ago","
Kris from London, UK, United Kingdom bought Bing News + Google News & Bing News Distribution
1 year ago","
Kris from London, UK, United Kingdom bought PR Distribution Web Plus Distribution
1 year ago","
Kris from London, UK, United Kingdom bought PR Distribution Web Plus + Bing News Distribution
1 year ago"] function showAlertBoxNow() { if (getCookie("noalert") == null){ if (countOfAlerts === alertsArray.length) {countOfAlerts = 0;} if(alertDiv.css('opacity') == 0) { alertDiv.css("visibility", "visible").animate({bottom:20, opacity:1, visibility: "visible"}, 1500, "easeInQuart"); } if(countOfAlerts > 0){ //alertDiv.fadeOut(300).fadeIn(200); setTimeout(function(){ alertDiv.find(".container-customer-order").html(alertsArray[countOfAlerts]); }, 200); }else{ alertDiv.find(".container-customer-order").html(alertsArray[countOfAlerts]); } clearInterval(timeforAlerts); timeforAlerts = setInterval(showAlertBoxNow, duration); countOfAlerts++; } } timeforAlerts = setInterval(showAlertBoxNow, 5000); /*End- Main Func*/ } });