jquery.toaster.js 2.0 KB

1
  1. !function(){"function"!=typeof Array.prototype.indexOf&&(Array.prototype.indexOf=function(t,e){for(var s=e||0,i=this.length;s<i;s+=1)if(void 0===t||null===t){if(this[s]===t)return s}else if(this[s]===t)return s;return-1})}(),function(t,e){var s={gettoaster:function(){var e=t("#"+o.toaster.id);return e.length<1&&(e=t(o.toaster.template).attr("id",o.toaster.id).css(o.toaster.css).addClass(o.toaster.class),o.stylesheet&&!t("link[href="+o.stylesheet+"]").length&&t("head").appendTo('<link rel="stylesheet" href="'+o.stylesheet+'">'),t(o.toaster.container).append(e)),e},notify:function(e,s,i){var a=this.gettoaster(),n=t(o.toast.template.replace("%priority%",i)).hide().css(o.toast.css).addClass(o.toast.class);if(t(".title",n).css(o.toast.csst).html(e),t(".message",n).css(o.toast.cssm).html(s),o.debug&&window.console,a.append(o.toast.display(n)),o.donotdismiss.indexOf(i)===-1){var r="number"==typeof o.timeout?o.timeout:"object"==typeof o.timeout&&i in o.timeout?o.timeout[i]:1500;setTimeout(function(){o.toast.remove(n,function(){n.remove()})},r)}}},i={toaster:{id:"toaster",container:"body",template:"<div></div>",class:"toaster",css:{position:"fixed",top:"10px",right:"10px",width:"300px",zIndex:5e4}},toast:{template:'<div class=" alert-%priority% alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button><span class="title"></span>: <span class="message"></span></div>',css:{},cssm:{},csst:{fontWeight:"bold"},fade:"slow",display:function(t){return t.fadeIn(o.toast.fade)},remove:function(t,e){return t.animate({opacity:"0",padding:"0px",margin:"0px",height:"0px"},{duration:o.toast.fade,complete:e})}},debug:!1,timeout:1500,stylesheet:null,donotdismiss:[]},o={};t.extend(o,i),t.toaster=function(e){if("object"==typeof e){"settings"in e&&(o=t.extend(o,e.settings));var i="title"in e?e.title:"Notice",a="message"in e?e.message:null,n="priority"in e?e.priority:"success";null!==a&&s.notify(i,a,n)}},t.toaster.reset=function(){o={},t.extend(o,i)}}(jQuery);