]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/templates/question.html
disabling the submit buttons for question and answers.
[osqa.git] / forum / skins / default / templates / question.html
index 430a304156e8069aa3677d417be0dd6d4b4b85c2..a9a170608a036ac8df4d873040d8ff655adf3eab 100644 (file)
@@ -30,7 +30,7 @@
             }\r
 \r
             $('#editor').TextAreaResizer();\r
-            \r
+\r
             //toggle preview of editor\r
             var display = true;\r
             var txt = "[{% trans "hide preview" %}]";\r
                 $('#previewer').toggle();\r
                 $('#pre-collapse').text(txt);\r
             });\r
+\r
         });\r
-        </script>\r
+\r
+        function beforeUnload(e) {\r
+            if($("textarea#editor")[0].value != "") {\r
+               yourWorkWillBeLost(e);\r
+            }\r
+\r
+            $("textarea.commentBox").each(function() {\r
+               if(this.value != "") {\r
+                   yourWorkWillBeLost(e);\r
+               }\r
+            });\r
+\r
+            return false;\r
+        }\r
+        window.addEventListener('beforeunload', beforeUnload, true);\r
+\r
+        function submitClicked() {\r
+             window.removeEventListener('beforeunload', beforeUnload, true);\r
+             $("input.submit").each(function() {\r
+                 this.disabled=true;\r
+             });\r
+         }\r
+\r
+         </script>\r
         <noscript>\r
             <style>\r
                 .comment.not_top_scorer {\r
                     <div id="previewer" class="wmd-preview"></div>                    \r
                 </div>\r
                 <p><span class="form-error"></span></p>\r
-                <input type="submit" \r
+                <input type="submit"\r
                     {% if user.is_anonymous %}\r
                         value="{% trans "Login/Signup to Post Your Answer" %}" \r
                     {% else %}\r
                         value="{% trans "Answer the question" %}" \r
                         {% endif %}\r
                     {% endif %}\r
-                    class="submit" style="float:left"/>\r
+                    class="submit" style="float:left" onclick="submitClicked()" />\r
             {% endif %}\r
         </form>\r
     </div>\r