Skip to content

Commit

Permalink
Closes #108.
Browse files Browse the repository at this point in the history
Confirmed that clicking the close button in some browsers (FireFox, IE10) was not closing the toast. The problem was that the focus was still on the toast, and we want to toast to hang around normally when it has focus. So we need the focus code. But when we click the close button, now we explictly tell it to ignore the focus code.
  • Loading branch information
johnpapa committed Sep 5, 2013
1 parent fb34ff9 commit a7d5d3e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 7 additions & 3 deletions tests/toastr.js
Expand Up @@ -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();
});
}

Expand All @@ -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]({
Expand Down
10 changes: 7 additions & 3 deletions toastr.js
Expand Up @@ -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();
});
}

Expand All @@ -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]({
Expand Down
2 changes: 1 addition & 1 deletion toastr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a7d5d3e

Please sign in to comment.