diff --git a/tests/toastr.js b/tests/toastr.js index e4d192b1..2ef8d1c2 100644 --- a/tests/toastr.js +++ b/tests/toastr.js @@ -209,10 +209,14 @@ if (!options.onclick && options.tapToDismiss) { $toastElement.click(hideToast); } + if(options.closeButton && $closeElement){ + $closeElement.click(function(){ hideToast(true); }); + } if (options.onclick) { $toastElement.click(function () { - options.onclick() && hideToast(); + options.onclick(); + hideToast(); }); } @@ -224,8 +228,8 @@ return $toastElement; - function hideToast() { - if ($(':focus', $toastElement).length > 0) { + function hideToast(override) { + if ($(':focus', $toastElement).length && !override) { return; } return $toastElement[options.hideMethod]({ diff --git a/toastr.js b/toastr.js index e4d192b1..2ef8d1c2 100644 --- a/toastr.js +++ b/toastr.js @@ -209,10 +209,14 @@ if (!options.onclick && options.tapToDismiss) { $toastElement.click(hideToast); } + if(options.closeButton && $closeElement){ + $closeElement.click(function(){ hideToast(true); }); + } if (options.onclick) { $toastElement.click(function () { - options.onclick() && hideToast(); + options.onclick(); + hideToast(); }); } @@ -224,8 +228,8 @@ return $toastElement; - function hideToast() { - if ($(':focus', $toastElement).length > 0) { + function hideToast(override) { + if ($(':focus', $toastElement).length && !override) { return; } return $toastElement[options.hideMethod]({ diff --git a/toastr.min.js b/toastr.min.js index dd170bb8..d90f1bf4 100644 --- a/toastr.min.js +++ b/toastr.min.js @@ -1,2 +1,2 @@ -(function(n){n(["jquery"],function(n){return function(){function l(n,t,f){return u({type:r.error,iconClass:i().iconClasses.error,message:n,optionsOverride:f,title:t})}function a(n,t,f){return u({type:r.info,iconClass:i().iconClasses.info,message:n,optionsOverride:f,title:t})}function v(n){e=n}function y(n,t,f){return u({type:r.success,iconClass:i().iconClasses.success,message:n,optionsOverride:f,title:t})}function p(n,t,f){return u({type:r.warning,iconClass:i().iconClasses.warning,message:n,optionsOverride:f,title:t})}function w(r){var u=i();if(t||f(u),r&&n(":focus",r).length===0){r[u.hideMethod]({duration:u.hideDuration,easing:u.hideEasing,complete:function(){c(r)}});return}t.children().length&&t[u.hideMethod]({duration:u.hideDuration,easing:u.hideEasing,complete:function(){t.remove()}})}function b(){return{tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:undefined,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden: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",closeHtml:"