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