]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/media/js/osqa.main.js
OSQA-313
[osqa.git] / forum / skins / default / media / js / osqa.main.js
index b5aee403eefdd95b373462b3c55c12ab4f3feb01..8326eb0f2de5b1ab6922239de3134d70b543911f 100644 (file)
@@ -229,10 +229,14 @@ function load_prompt(evt, url) {
     $.get(url, function(data) {\r
         var $dialog = show_dialog({\r
             html: data,\r
-            //extra_class: 'warning',\r
+            extra_class: 'prompt',\r
             event: evt,\r
             yes_callback: function() {\r
-                $.post(url, {prompt: $dialog.find('.prompt-return').val()}, function(data) {\r
+                var postvars = {};\r
+                $dialog.find('input, textarea, select').each(function() {\r
+                    postvars[$(this).attr('name')] = $(this).val();\r
+                });\r
+                $.post(url, postvars, function(data) {\r
                     $dialog.fadeOut('fast', function() {\r
                         $dialog.remove();\r
                     });\r
@@ -290,6 +294,24 @@ $(function() {
 \r
         if (el.is('.withprompt')) {\r
             load_prompt(evt, el.attr('href'));\r
+        } else if(el.is('.confirm')) {\r
+            $dialog = show_dialog({\r
+                html: messages.confirm,\r
+                extra_class: 'confirm',\r
+                event: evt,\r
+                yes_callback: function() {\r
+                    start_command();\r
+                    $.getJSON(el.attr('href'), function(data) {\r
+                        process_ajax_response(data, evt);\r
+                        $dialog.fadeOut('fast', function() {\r
+                            $dialog.remove();\r
+                        });\r
+                    });\r
+                },\r
+                yes_text: messages.yes,\r
+                show_no: true,\r
+                no_text: messages.no\r
+            });\r
         } else {\r
             start_command();\r
             $.getJSON(el.attr('href'), function(data) {\r
@@ -300,6 +322,22 @@ $(function() {
         return false\r
     });\r
 \r
+    $('.context-menu').each(function() {\r
+        var $menu = $(this);\r
+        var $trigger = $menu.find('.context-menu-trigger');\r
+        var $dropdown = $menu.find('.context-menu-dropdown');\r
+\r
+        $trigger.click(function() {\r
+            $dropdown.slideToggle('fast', function() {\r
+                if ($dropdown.is(':visible')) {\r
+                   $dropdown.one('clickoutside', function() {\r
+                        $dropdown.slideUp('fast')\r
+                    });\r
+                }\r
+            });    \r
+        });\r
+    });\r
+\r
     $('div.comment-form-container').each(function() {\r
         var $container = $(this);\r
         var $form = $container.find('form');\r
@@ -352,7 +390,7 @@ $(function() {
         cleanup_form();\r
 \r
         function process_form_changes() {\r
-            var length = $textarea.val().length;\r
+            var length = $textarea.val().replace(/[ ]{2,}/g," ").length;\r
 \r
             if (current_length == length)\r
                 return;\r
@@ -368,6 +406,7 @@ $(function() {
                 $chars_togo_message.show();\r
                 $chars_counter.html(min_length - length);\r
             } else {\r
+                length = $textarea.val().length;\r
                 $chars_togo_message.hide();\r
                 $chars_left_message.show();\r
                 $chars_counter.html(max_length - length);\r