]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/media/js/osqa.main.js
be able to execute JavaScript post-action commands even if the success status equals...
[osqa.git] / forum / skins / default / media / js / osqa.main.js
index 18bd941ab36f9a9a59b5053311487973a11407cd..8fb4d6369347b49a0e36b60f4eb9e17d15eeb259 100644 (file)
@@ -19,10 +19,12 @@ $('html').ajaxSend(function(event, xhr, settings) {
         }\r
         return cookieValue;\r
     }\r
-    if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {\r
-        // Only send the token to relative URLs i.e. locally.\r
-        xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));\r
-    }\r
+    try {\r
+        if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {\r
+            // Only send the token to relative URLs i.e. locally.\r
+            xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));\r
+        }\r
+    } catch (e) {}\r
 });\r
 \r
 var response_commands = {\r
@@ -329,7 +331,8 @@ function process_ajax_response(data, evt, callback) {
     if (!data.success && data['error_message'] != undefined) {\r
         show_message(evt, data.error_message, function() {if (callback) callback(true);});\r
         end_command(false);\r
-    } else if (typeof data['commands'] != undefined){\r
+    }\r
+    if (typeof data['commands'] != undefined){\r
         for (var command in data.commands) {\r
             response_commands[command].apply(null, data.commands[command])\r
 \r
@@ -607,6 +610,14 @@ $(function() {
                 return false;\r
             });\r
 \r
+            // Submit comment with CTRL + Enter\r
+            $textarea.keydown(function(e) {\r
+                if (e.ctrlKey && e.keyCode == 13 && !$button.attr('disabled')) {\r
+                    // console.log('submit');\r
+                    $(this).parent().find('input.comment-submit').click();\r
+                }\r
+            });\r
+\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