diff --git a/src/Auth/Dummy.hs b/src/Auth/Dummy.hs index 2edb89350..5987caa4f 100644 --- a/src/Auth/Dummy.hs +++ b/src/Auth/Dummy.hs @@ -57,7 +57,7 @@ dummyLogin = AuthPlugin{..} { formMethod = POST , formAction = Just . SomeRoute . toMaster $ PluginR "dummy" [] , formEncoding = loginEnctype - , formAttrs = [] + , formAttrs = [("uw-no-navigate-away-prompt","")] , formSubmit = FormSubmit , formAnchor = Just "login--dummy" :: Maybe Text } diff --git a/src/Auth/LDAP.hs b/src/Auth/LDAP.hs index e4c5aee74..9ea9d02e5 100644 --- a/src/Auth/LDAP.hs +++ b/src/Auth/LDAP.hs @@ -117,7 +117,7 @@ campusLogin conf@LdapConf{..} pool = AuthPlugin{..} { formMethod = POST , formAction = Just . SomeRoute . toMaster $ PluginR "LDAP" [] , formEncoding = loginEnctype - , formAttrs = [] + , formAttrs = [("uw-no-navigate-away-prompt","")] , formSubmit = FormSubmit , formAnchor = Just "login--campus" :: Maybe Text } diff --git a/src/Auth/PWHash.hs b/src/Auth/PWHash.hs index cc50b9415..a4eb42057 100644 --- a/src/Auth/PWHash.hs +++ b/src/Auth/PWHash.hs @@ -93,7 +93,7 @@ hashLogin pwHashAlgo = AuthPlugin{..} { formMethod = POST , formAction = Just . SomeRoute . toMaster $ PluginR "PWHash" [] , formEncoding = loginEnctype - , formAttrs = [] + , formAttrs = [("uw-no-navigate-away-prompt","")] , formSubmit = FormSubmit , formAnchor = Just "login--hash" :: Maybe Text } diff --git a/static/js/utils/form.js b/static/js/utils/form.js index ed8b0fa9a..c545caa93 100644 --- a/static/js/utils/form.js +++ b/static/js/utils/form.js @@ -257,6 +257,7 @@ * * Attribute: [none] * (automatically setup on all form tags that dont automatically submit, see AutoSubmitButtonUtil) + * Does not setup on forms that have uw-no-navigate-away-prompt * * Example usage: * (any page with a form) @@ -264,6 +265,7 @@ var NAVIGATE_AWAY_PROMPT_UTIL_NAME = 'navigateAwayPrompt'; var NAVIGATE_AWAY_PROMPT_UTIL_SELECTOR = 'form'; + var NAVIGATE_AWAY_PROMPT_UTIL_OPTOUT = '[uw-no-navigate-away-prompt]'; var NAVIGATE_AWAY_PROMPT_INITIALIZED_CLASS = 'navigate-away-prompt--initialized'; @@ -285,6 +287,10 @@ return false; } + if (element.matches(NAVIGATE_AWAY_PROMPT_UTIL_OPTOUT)) { + return false; + } + window.addEventListener('beforeunload', beforeUnloadHandler); element.addEventListener('submit', function() {