Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added suppress function to temporary prevent the fire function. #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thdk
Copy link

@thdk thdk commented Mar 2, 2016

Added suppress function. The fire function won't be executed when ouibounce is suppressed untill suppress(false) is called.

In my case I did not want to fire function to trigger when another dialog was open on my page. However, I wanted the fire function to be triggered again once that dialog is closed.
Calling suppress(true) when opening the dialog and suppres(false) when closing this dialog does the trick now.

…bounce is suppress untill suppress(false) is called.
@@ -82,7 +82,7 @@ function ouibounce(el, custom_config) {
// You can use ouibounce without passing an element
// https://github.com/carlsednaoui/ouibounce/issues/30
function fire() {
if (isDisabled()) { return; }
if (isDisabled() || supressed) { return; }
Copy link

@patrick-mcdougle patrick-mcdougle Apr 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, supressed should be a part of the isDisabled function. It's easier to read that way.

function isDisabled() {
    return supressed || (checkCookieValue(cookieName, 'true') && !aggressive);
}

@@ -123,11 +123,18 @@ function ouibounce(el, custom_config) {
_html.removeEventListener('keydown', handleKeydown);
}

var supressed;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be up with the other variables near the top and initialized to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants