forked from stanlemon/jGrowl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.jgrowl.min.js
2 lines (2 loc) · 5.64 KB
/
jquery.jgrowl.min.js
1
2
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=function(t,o){return void 0===o&&(o="undefined"!=typeof window?require("jquery"):require("jquery")(t)),e(o),o}:e(jQuery)}(function(e){e.jGrowl=function(t,o){0===e("#jGrowl").length&&e('<div id="jGrowl"></div>').addClass(o&&o.position?o.position:e.jGrowl.defaults.position).appendTo(o&&o.appendTo?o.appendTo:e.jGrowl.defaults.appendTo),e("#jGrowl").jGrowl(t,o)},e.fn.jGrowl=function(t,o){if(void 0===o&&e.isPlainObject(t)&&(t=(o=t).message),"function"==typeof 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)),"function"==typeof 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,o)})}},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,o){var n=e.extend({},this.defaults,o);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 o=this,n=t.message,i=t.options;i.themeState=""===i.themeState?"":"ui-state-"+i.themeState;var a=e("<div/>").addClass("jGrowl-notification alert "+i.themeState+" ui-corner-all"+(void 0!==i.group&&""!==i.group?" "+i.group:"")).append(e("<button/>").addClass("jGrowl-close").html(i.closeTemplate)).append(e("<div/>").addClass("jGrowl-header").html(i.header)).append(e("<div/>").addClass("jGrowl-message").html(n)).data("jGrowl",i).addClass(i.theme).children(".jGrowl-close").on("click.jGrowl",function(){return e(this).parent().trigger("jGrowl.beforeClose"),!1}).parent();e(a).on("mouseover.jGrowl",function(){e(".jGrowl-notification",o.element).data("jGrowl.pause",!0)}).on("mouseout.jGrowl",function(){e(".jGrowl-notification",o.element).data("jGrowl.pause",!1)}).on("jGrowl.beforeOpen",function(){!1!==i.beforeOpen.apply(a,[a,n,i,o.element])&&e(this).trigger("jGrowl.open")}).on("jGrowl.open",function(){!1!==i.open.apply(a,[a,n,i,o.element])&&("after"==i.glue?e(".jGrowl-notification:last",o.element).after(a):e(".jGrowl-notification:first",o.element).before(a),e(this).animate(i.animateOpen,i.openDuration,i.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")}))}).on("jGrowl.afterOpen",function(){i.afterOpen.apply(a,[a,n,i,o.element])}).on("click",function(){i.click.apply(a,[a,n,i,o.element])}).on("jGrowl.beforeClose",function(){!1!==i.beforeClose.apply(a,[a,n,i,o.element])&&e(this).trigger("jGrowl.close")}).on("jGrowl.close",function(){e(this).data("jGrowl.pause",!0),e(this).animate(i.animateClose,i.closeDuration,i.easing,function(){"function"==typeof i.close?!1!==i.close.apply(a,[a,n,i,o.element])&&e(this).remove():e(this).remove()})}).trigger("jGrowl.beforeOpen"),""!==i.corners&&void 0!==e.fn.corner&&e(a).corner(i.corners),e(".jGrowl-notification:parent",o.element).length>1&&0===e(".jGrowl-closer",o.element).length&&!1!==this.defaults.closer&&e(this.defaults.closerTemplate).addClass("jGrowl-closer "+this.defaults.themeState+" ui-corner-all").addClass(this.defaults.theme).appendTo(o.element).animate(this.defaults.animateOpen,this.defaults.speed,this.defaults.easing).on("click.jGrowl",function(){e(this).siblings().trigger("jGrowl.beforeClose"),"function"==typeof o.defaults.closer&&o.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(){var o=e(t).data("jGrowl.instance");if(void 0!==o)try{o.update()}catch(e){throw o.shutdown(),e}},parseInt(this.defaults.check,10))},shutdown:function(){try{e(this.element).removeClass("jGrowl").find(".jGrowl-notification").trigger("jGrowl.close").parent().empty()}catch(e){throw e}finally{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});
//# sourceMappingURL=jquery.jgrowl.map