From 2015b4b39c078152726dfd57215f602e4a4ce668 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 15 Aug 2013 15:55:52 +0200 Subject: [PATCH] =?utf8?q?Pflichtenheftitems:=20RETURN=20in=20Zeitsch?= =?utf8?q?=C3=A4tzungs-Input=20via=20AJAX=20submitten=20gefixt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/RequirementSpec.pm | 2 +- SL/Controller/RequirementSpecItem.pm | 3 ++- js/requirement_spec.js | 22 +++++++++++++--------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index 944e9ddbe..f99e0bf4d 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -261,7 +261,7 @@ sub setup { $::auth->assert('sales_quotation_edit'); $::request->{layout}->use_stylesheet("${_}.css") for qw(jquery.contextMenu requirement_spec); - $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu requirement_spec); + $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu jquery/jquery.hotkeys requirement_spec); $self->init_visible_section; return 1; diff --git a/SL/Controller/RequirementSpecItem.pm b/SL/Controller/RequirementSpecItem.pm index 7b1ed8194..0f7d66f22 100644 --- a/SL/Controller/RequirementSpecItem.pm +++ b/SL/Controller/RequirementSpecItem.pm @@ -258,7 +258,7 @@ sub action_ajax_edit { ->hide($content_top_id) ->remove("#${id_base}_form") ->insertAfter($html, $content_top_id) - ->on("#${id_base}_form INPUT[type=text]", "keydown", "kivi.requirement_spec.text_block_input_key_down") + ->run('kivi.requirement_spec.init_function_block_keypress_events', "${id_base}_form") ->jstree->select_node('#tree', '#fb-' . $self->item->id) ->focus("#${id_base}_description") ->val('#current_content_type', $self->item->item_type) @@ -601,6 +601,7 @@ sub add_new_item_form { return $self->js ->action($params{insert_position}, $html, $params{display_reference}) + ->run('kivi.requirement_spec.init_function_block_keypress_events', "${id_base}_form") ->focus("#${id_base}_description"); } diff --git a/js/requirement_spec.js b/js/requirement_spec.js index f33e52e5a..11bab3693 100644 --- a/js/requirement_spec.js +++ b/js/requirement_spec.js @@ -178,15 +178,6 @@ ns.ask_delete_text_block = function(key, opt) { return true; }; -ns.text_block_input_key_down = function(event) { - if(event.keyCode == 13) { - event.preventDefault(); - var prefix = $(this).attr('id').match("^edit_function_block_\\d+")[0]; - $("#" + prefix + "_submit").click(); - return false; - } -}; - ns.find_text_block_picture_id = function(clicked_elt) { var id = $(clicked_elt).attr('id'); var match = id.match(/^text-block-picture-(\d+)$/); @@ -350,6 +341,19 @@ ns.item_popup_menu_hidden = function(opt) { return ns.handle_item_popup_menu_markings(opt, false); }; +ns.submit_function_block = function(event) { + event.preventDefault(); + + var prefix = $(this).attr('id').match("^(?:edit|new)_function_block_[\\d_]+\\d")[0]; + kivi.submit_ajax_form('controller.pl?action=RequirementSpecItem/ajax_update', '#' + prefix + '_form'); + + return false; +}; + +ns.init_function_block_keypress_events = function(form_id) { + $("#" + form_id + " INPUT[type=text]").bind("keypress", "return", ns.submit_function_block); +}; + // ------------------------------------------------------------------------- // ------------------------------- templates ------------------------------- // ------------------------------------------------------------------------- -- 2.20.1