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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions source/ouibounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


if (el) { el.style.display = 'block'; }

Expand Down Expand Up @@ -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.

function suppress(value) {
supressed = value;
}

return {
fire: fire,
disable: disable,
isDisabled: isDisabled
isDisabled: isDisabled,
suppress: suppress
};

}

/*exported ouibounce */