forked from CodeSeven/toastr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toastr.min.js
2 lines (2 loc) · 2.82 KB
/
toastr.min.js
1
2
(function(n){n(["jquery"],function(n){return function(){function h(n){e&&e(n)}function u(r){function l(){if(!(n(":focus",e).length>0))return e.fadeOut(u.fadeOut,function(){c(e),u.onFadeOut&&u.onFadeOut(),s.state="hidden",s.endTime=new Date,h(s)})}function w(){(u.timeOut>0||u.extendedTimeOut>0)&&(v=setTimeout(l,u.extendedTimeOut))}function b(){clearTimeout(v),e.stop(!0,!0).fadeIn(u.fadeIn)}var u=i(),a=r.iconClass||u.iconClass;typeof r.optionsOverride!="undefined"&&(u=n.extend(u,r.optionsOverride),a=r.optionsOverride.iconClass||a),o++,t=f(u);var v=null,e=n("<div/>"),y=n("<div/>"),p=n("<div/>"),s={toastId:o,state:"visible",startTime:new Date,options:u,map:r};return r.iconClass&&e.addClass(u.toastClass).addClass(a),r.title&&(y.append(r.title).addClass(u.titleClass),e.append(y)),r.message&&(p.append(r.message).addClass(u.messageClass),e.append(p)),e.hide(),u.newestOnTop?t.prepend(e):t.append(e),e.fadeIn(u.fadeIn,u.onFadeIn),u.timeOut>0&&(v=setTimeout(l,u.timeOut)),e.hover(b,w),!u.onclick&&u.tapToDismiss&&e.click(l),u.onclick&&e.click(function(){u.onclick()&&l()}),h(s),u.debug&&console&&console.log(s),e}function f(r){return(r||(r=i()),t=n("#"+r.containerId),t.length)?t:(t=n("<div/>").attr("id",r.containerId).addClass(r.positionClass),t.appendTo(n(r.target)),t)}function i(){return n.extend({},l,s.options)}function c(n){(t||(t=f()),n.is(":visible"))||(n.remove(),n=null,t.children().length===0&&t.remove())}var t,r={error:"error",info:"info",success:"success",warning:"warning"},e,o=0,l={tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,fadeIn:300,onFadeIn:undefined,fadeOut:1e3,onFadeOut:undefined,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",target:"body",newestOnTop:!0},a=function(n,t,f){return u({type:r.error,iconClass:i().iconClasses.error,message:n,optionsOverride:f,title:t})},v=function(n,t,f){return u({type:r.info,iconClass:i().iconClasses.info,message:n,optionsOverride:f,title:t})},y=function(n){e=n},p=function(n,t,f){return u({type:r.success,iconClass:i().iconClasses.success,message:n,optionsOverride:f,title:t})},w=function(n,t,f){return u({type:r.warning,iconClass:i().iconClasses.warning,message:n,optionsOverride:f,title:t})},b=function(r){var u=i();if(t||f(u),r&&n(":focus",r).length===0){r.fadeOut(u.fadeOut,function(){c(r)});return}t.children().length&&t.fadeOut(u.fadeOut,function(){t.remove()})},s={clear:b,error:a,getContainer:f,info:v,options:{},subscribe:y,success:p,version:"1.3.1",warning:w};return s}()})})(typeof define=="function"&&define.amd?define:function(n,t){typeof module!="undefined"&&module.exports?module.exports=t(require(n[0])):window.toastr=t(window.jQuery)});
//@ sourceMappingURL=toastr.min.js.map