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 callKeyFunctions flag to conditionally let the user use the enter/escape key to submit #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 dist/notie.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,19 @@ var getTransition = function getTransition() {
};

var enterClicked = function enterClicked(event) {
return event.keyCode === 13;
if (callKeyFunctions) {
return event.keyCode === 13;
}
return false;
};
var escapeClicked = function escapeClicked(event) {
return event.keyCode === 27;
if (callKeyFunctions) {
return event.keyCode === 27;
}
return false;
};


var addToDocument = function addToDocument(element, position) {
element.classList.add(options.classes.container);
element.style[position] = '-10000px';
Expand Down
2 changes: 1 addition & 1 deletion src/notie.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,4 +668,4 @@ export default {
date,
setOptions,
hideAlerts
}
}
3 changes: 2 additions & 1 deletion test.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
</div>

<!-- JavaScript -->
<script>window.callKeyFunctions = true;</script> <!-- Set this variable to true or false depending on whether you want to call the key functions -->
<script src="dist/notie.js"></script>
<script>
notie.setOptions({
Expand Down Expand Up @@ -189,4 +190,4 @@
}
</script>
</body>
</html>
</html>