X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9cddaf376822b4229457212a27d5d98958f11368..786437b68e64cc7c8496792b2a34717f60ca3a22:/js/requirement_spec.js diff --git a/js/requirement_spec.js b/js/requirement_spec.js index 2d86dec89..ccc452536 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+)$/); @@ -243,6 +234,20 @@ ns.text_block_picture_popup_menu_hidden = function(opt) { return ns.handle_text_block_picture_popup_menu_markings(opt, false); }; +ns.make_text_block_picture_lists_sortable = function() { + kivi.run_once_for(".requirement-spec-text-block-picture-list", 'make-text-block-picture-list-sortable', function($elt) { + $elt.sortable({ + stop: function(event, ui) { + $.post('controller.pl?action=RequirementSpecTextBlock/reorder_pictures', { + 'picture_id[]': $($elt.sortable('toArray')).map(function(idx, str) { return str.replace('text-block-picture-', ''); }).toArray() + }); + return ui; + } + , distance: 5 + }); + }); +}; + // -------------------------------------------------------------------------------- // ------------------------------ sections and items ------------------------------ // -------------------------------------------------------------------------------- @@ -336,6 +341,23 @@ ns.item_popup_menu_hidden = function(opt) { return ns.handle_item_popup_menu_markings(opt, false); }; +ns.submit_function_block = function(event, shift_in_out) { + event.preventDefault(); + + var prefix = $(this).attr('id').match("^(?:edit|new)_function_block_[\\d_]+\\d")[0]; + var action = $('#' + prefix + '_id').val() ? 'update' : 'create'; + kivi.submit_ajax_form('controller.pl?action=RequirementSpecItem/ajax_' + action, '#' + prefix + '_form', { shift_in_out: !!shift_in_out }); + + return false; +}; + +ns.init_function_block_keypress_events = function(form_id) { + $("#" + form_id + " INPUT[type=text]").bind("keypress", "return", ns.submit_function_block); + + $('#' + form_id + ' INPUT[type=text],#' + form_id + ' TEXTAREA,#' + form_id + ' INPUT[type=button]') + .bind('keypress', 'shift+return', function(event) { return ns.submit_function_block.apply(this, [ event, true ]); }); +}; + // ------------------------------------------------------------------------- // ------------------------------- templates ------------------------------- // ------------------------------------------------------------------------- @@ -660,6 +682,9 @@ ns.create_context_menus = function(is_template) { , edit_picture: { name: kivi.t8('Edit picture'), icon: "edit", callback: kivi.requirement_spec.add_edit_text_block_picture_ajax_call } , delete_picture: { name: kivi.t8('Delete picture'), icon: "delete", callback: kivi.requirement_spec.ask_delete_text_block_picture } , download_picture: { name: kivi.t8('Download picture'), icon: "download", callback: kivi.requirement_spec.standard_text_block_picture_ajax_call } + , sep2: "---------" + , copy_picture: { name: kivi.t8('Copy'), icon: "copy", callback: kivi.requirement_spec.standard_text_block_picture_ajax_call } + , paste_picture: { name: kivi.t8('Paste'), icon: "paste", callback: kivi.requirement_spec.standard_text_block_picture_ajax_call } }, general_actions) });