Current File : /pages/54/47/d0016649/home/htdocs/cd24/wp-content/themes/dreier/cloudfw/js/notifications.js |
!function(a){jQuery(document).ready(function(){jQuery('<div id="overlays"></div>').appendTo("body")}),a.notification=function(b){function l(a){var b=[[2,"One second","1 second from now"],[60,"seconds",1],[120,"One minute","1 minute from now"],[3600,"minutes",60],[7200,"One hour","1 hour from now"],[86400,"hours",3600],[172800,"One day","tomorrow"],[604800,"days",86400],[1209600,"One week","next week"],[2419200,"weeks",604800],[4838400,"One month","next month"],[29030400,"months",2419200],[58060800,"One year","next year"],[290304e4,"years",29030400],[580608e4,"One century","next century"],[580608e5,"centuries",290304e4]],c=(new Date-a)/1e3,d="ago",e=1;0>c&&(c=Math.abs(c),d="from now",e=1);for(var g,f=0;g=b[f++];)if(c<g[0])return"string"==typeof g[2]?g[e]:Math.floor(c/g[2])+" "+g[1];return a}var c,d,e,f,g,h,i;if(b=a.extend({title:void 0,content:void 0,timeout:0,img:void 0,border:!0,fill:!1,showTime:!1,click:void 0,icon:void 0,color:void 0,type:void 0,error:!1},b),c=a("#notifications"),c.length||(c=a("<div>",{id:"notifications"}).appendTo(a("#overlays"))),c.show(),d=a("<div>"),d.addClass("notification"),void 0!=b.type&&d.addClass(b.type),1==b.error&&d.addClass("notification-error"),a("#notifications .notification").length>0?d.addClass("more"):c.addClass("animated flipInX").delay(1e3).queue(function(){c.removeClass("animated flipInX"),c.clearQueue()}),e=a("<div>",{click:function(){var b=a(this);b.parent().is(":last-child")&&a("#notifications .notification:last-child").removeClass("more"),1==a("#notifications .notification").length?c.addClass("animated fadeOutDown fast").delay(1e3).queue(function(){c.removeClass("animated fadeOutDown fast"),c.clearQueue(),b.parent().remove(),c.remove()}):b.parent().addClass("animated fadeOutRightBig").delay(200).queue(function(){jQuery(this).removeClass("animated fadeOutRightBig").css("visibility","hidden").clearQueue().slideUp(function(){jQuery(this).remove()})})}}),e.addClass("hide"),h=a("<div class='left'>"),g=a("<div class='right'>"),void 0!=b.title)var j="<h2>"+b.title+"</h2>";else var j="";if(void 0!=b.content)var k=b.content;else var k="";if(i=a("<div>",{html:j+k}),i.addClass("inner"),i.appendTo(g),void 0!=b.img?(f=a("<div>",{style:"background-image: url('"+b.img+"')"}),f.addClass("img"),f.appendTo(h),0==b.border&&f.addClass("border"),1==b.fill&&f.addClass("fill")):(icon=a('<div class="icon">'),void 0!=b.color&&icon.css("color",b.color),icon.appendTo(h)),h.appendTo(d),g.appendTo(d),e.appendTo(d),0!=b.showTime){var m=Number(new Date);timeHTML=a("<div>",{html:"<strong>"+l(m)+"</strong> ago"}),timeHTML.addClass("time").attr("data-title",m),timeHTML.appendTo(g),setInterval(function(){a(".time").each(function(){var b=a(this).attr("data-title");a(this).html("<strong>"+l(b)+"</strong> ago")})},4e3)}return d.hover(function(){e.show()},function(){e.hide()}),d.prependTo(c),d.show(),b.timeout&&setTimeout(function(){d.find(".hide").click()},b.timeout),void 0!=b.click&&(d.addClass("click"),d.bind("click",function(c){var d=a(c.target);d.is(".hide")||b.click.call(this)})),this}}(jQuery);