$::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;
->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)
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");
}
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+)$/);
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 -------------------------------
// -------------------------------------------------------------------------