]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/media/js/osqa.main.js
warning users that edits will be lost if they navigate away from the page.
[osqa.git] / forum / skins / default / media / js / osqa.main.js
index c5d0a43e2c6f56e82a0ffa69eec70323c183ebc7..4b07d9b914d2703f32252a24158f62a4483768aa 100644 (file)
@@ -510,11 +510,14 @@ $(function() {
                 return false;\r
             });\r
 \r
-            $cancel.click(function() {\r
-                if (comment_in_form) {\r
-                    $comment = $('#comment-' + comment_in_form).slideDown('slow');\r
+            $cancel.click(function(event) {\r
+                if (confirm("You will lose all of your changes in this comment.  Do you still wish to proceed?")){\r
+                    if (comment_in_form) {\r
+                        $comment = $('#comment-' + comment_in_form).slideDown('slow');\r
+                    }\r
+                    hide_comment_form();\r
+                    cleanup_form();\r
                 }\r
-                hide_comment_form();\r
                 return false;\r
             });\r
         }\r
@@ -1053,3 +1056,14 @@ $(document).ready( function(){
     });\r
 });\r
 \r
+function yourWorkWillBeLost(e) {\r
+       if(!e) e = window.event;\r
+       e.cancelBubble = true;\r
+       e.returnValue = 'You sure you want to leave?  Your work will be lost.';\r
+\r
+       if (e.stopPropagation) {\r
+               e.stopPropagation();\r
+               e.preventDefault();\r
+       }\r
+    return e;\r
+}
\ No newline at end of file