-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjGrowl.min.js
1 lines (1 loc) · 5.32 KB
/
jGrowl.min.js
1
!function(e){e.jGrowl=function(t,i){0===e("#jGrowl").length&&e('<div id="jGrowl"></div>').addClass(i&&i.position?i.position:e.jGrowl.defaults.position).appendTo(i&&i.appendTo?i.appendTo:e.jGrowl.defaults.appendTo),e("#jGrowl").jGrowl(t,i)},e.fn.jGrowl=function(t,i){if(void 0===i&&e.isPlainObject(t)&&(t=(i=t).message),e.isFunction(this.each)){var n=arguments;return this.each((function(){void 0===e(this).data("jGrowl.instance")&&(e(this).data("jGrowl.instance",e.extend(new e.fn.jGrowl,{notifications:[],element:null,interval:null})),e(this).data("jGrowl.instance").startup(this)),e.isFunction(e(this).data("jGrowl.instance")[t])?e(this).data("jGrowl.instance")[t].apply(e(this).data("jGrowl.instance"),e.makeArray(n).slice(1)):e(this).data("jGrowl.instance").create(t,i)}))}},e.extend(e.fn.jGrowl.prototype,{defaults:{pool:0,header:"",group:"",sticky:!1,position:"top-right",appendTo:"body",glue:"after",theme:"default",themeState:"highlight",corners:"10px",check:250,life:3e3,closeDuration:"normal",openDuration:"normal",easing:"swing",closer:!0,closeTemplate:"×",closerTemplate:"<div>[ close all ]</div>",log:function(){},beforeOpen:function(){},afterOpen:function(){},open:function(){},beforeClose:function(){},close:function(){},click:function(){},animateOpen:{opacity:"show"},animateClose:{opacity:"hide"}},notifications:[],element:null,interval:null,create:function(t,i){var n=e.extend({},this.defaults,i);void 0!==n.speed&&(n.openDuration=n.speed,n.closeDuration=n.speed),this.notifications.push({message:t,options:n}),n.log.apply(this.element,[this.element,t,n])},render:function(t){var i=this,n=t.message,o=t.options;o.themeState=""===o.themeState?"":"ui-state-"+o.themeState;var a=e("<div/>").addClass("jGrowl-notification alert "+o.themeState+" ui-corner-all"+(void 0!==o.group&&""!==o.group?" "+o.group:"")).append(e("<button/>").addClass("jGrowl-close").html(o.closeTemplate)).append(e("<div/>").addClass("jGrowl-header").html(o.header)).append(e("<div/>").addClass("jGrowl-message").html(n)).data("jGrowl",o).addClass(o.theme).children(".jGrowl-close").bind("click.jGrowl",(function(){return e(this).parent().trigger("jGrowl.beforeClose"),!1})).parent();e(a).bind("mouseover.jGrowl",(function(){e(".jGrowl-notification",i.element).data("jGrowl.pause",!0)})).bind("mouseout.jGrowl",(function(){e(".jGrowl-notification",i.element).data("jGrowl.pause",!1)})).bind("jGrowl.beforeOpen",(function(){!1!==o.beforeOpen.apply(a,[a,n,o,i.element])&&e(this).trigger("jGrowl.open")})).bind("jGrowl.open",(function(){!1!==o.open.apply(a,[a,n,o,i.element])&&("after"==o.glue?e(".jGrowl-notification:last",i.element).after(a):e(".jGrowl-notification:first",i.element).before(a),e(this).animate(o.animateOpen,o.openDuration,o.easing,(function(){!1===e.support.opacity&&this.style.removeAttribute("filter"),null!==e(this).data("jGrowl")&&void 0!==e(this).data("jGrowl")&&(e(this).data("jGrowl").created=new Date),e(this).trigger("jGrowl.afterOpen")})))})).bind("jGrowl.afterOpen",(function(){o.afterOpen.apply(a,[a,n,o,i.element])})).bind("click",(function(){o.click.apply(a,[a.message,o,i.element])})).bind("jGrowl.beforeClose",(function(){!1!==o.beforeClose.apply(a,[a,n,o,i.element])&&e(this).trigger("jGrowl.close")})).bind("jGrowl.close",(function(){e(this).data("jGrowl.pause",!0),e(this).animate(o.animateClose,o.closeDuration,o.easing,(function(){e.isFunction(o.close)?!1!==o.close.apply(a,[a,n,o,i.element])&&e(this).remove():e(this).remove()}))})).trigger("jGrowl.beforeOpen"),""!==o.corners&&void 0!==e.fn.corner&&e(a).corner(o.corners),e(".jGrowl-notification:parent",i.element).length>1&&0===e(".jGrowl-closer",i.element).length&&!1!==this.defaults.closer&&e(this.defaults.closerTemplate).addClass("jGrowl-closer "+this.defaults.themeState+" ui-corner-all").addClass(this.defaults.theme).appendTo(i.element).animate(this.defaults.animateOpen,this.defaults.speed,this.defaults.easing).bind("click.jGrowl",(function(){e(this).siblings().trigger("jGrowl.beforeClose"),e.isFunction(i.defaults.closer)&&i.defaults.closer.apply(e(this).parent()[0],[e(this).parent()[0]])}))},update:function(){e(this.element).find(".jGrowl-notification:parent").each((function(){void 0!==e(this).data("jGrowl")&&void 0!==e(this).data("jGrowl").created&&e(this).data("jGrowl").created.getTime()+parseInt(e(this).data("jGrowl").life,10)<(new Date).getTime()&&!0!==e(this).data("jGrowl").sticky&&(void 0===e(this).data("jGrowl.pause")||!0!==e(this).data("jGrowl.pause"))&&e(this).trigger("jGrowl.beforeClose")})),this.notifications.length>0&&(0===this.defaults.pool||e(this.element).find(".jGrowl-notification:parent").length<this.defaults.pool)&&this.render(this.notifications.shift()),e(this.element).find(".jGrowl-notification:parent").length<2&&e(this.element).find(".jGrowl-closer").animate(this.defaults.animateClose,this.defaults.speed,this.defaults.easing,(function(){e(this).remove()}))},startup:function(t){this.element=e(t).addClass("jGrowl").append('<div class="jGrowl-notification"></div>'),this.interval=setInterval((function(){e(t).data("jGrowl.instance").update()}),parseInt(this.defaults.check,10))},shutdown:function(){e(this.element).removeClass("jGrowl").find(".jGrowl-notification").trigger("jGrowl.close").parent().empty(),clearInterval(this.interval)},close:function(){e(this.element).find(".jGrowl-notification").each((function(){e(this).trigger("jGrowl.beforeClose")}))}}),e.jGrowl.defaults=e.fn.jGrowl.prototype.defaults}(jQuery);