-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HDX-9438 & HDX-9420 build a warning for users navigating away from on…
…boarding flow
- Loading branch information
Showing
5 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
ckanext-hdx_theme/ckanext/hdx_theme/fanstatic/onboarding/confirm-page-leave.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
$(document).ready(function () { | ||
var shouldPreventBeforeUnload = false; | ||
var requiredInputs = $('#user-info-form input[required]'); | ||
|
||
function checkInputs() { | ||
requiredInputs.each(function() { | ||
if ($(this).val().trim() !== '') { | ||
shouldPreventBeforeUnload = true; | ||
return false; | ||
} | ||
}); | ||
} | ||
|
||
$(window).on('beforeunload', function (e) { | ||
if (shouldPreventBeforeUnload) { | ||
e.preventDefault(); | ||
e.returnValue = ''; | ||
} | ||
}); | ||
|
||
$('#user-info-cancel-button, #user-info-submit-button').on('click', function () { | ||
shouldPreventBeforeUnload = false; | ||
}); | ||
|
||
requiredInputs.on('input', function () { | ||
shouldPreventBeforeUnload = false; | ||
checkInputs(); | ||
}); | ||
|
||
checkInputs(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters