X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=scripts%2Fgenerate_client_js_actions.tpl;h=a29b3258785ef7874d651c157f9703ded212e894;hb=f16b77358a0cbedf9681c6ea95bd2a076b8b78a9;hp=55206ea6ac27d8a69536d7b58bc1921c093c3303;hpb=2738c03e1340255baade2fd357aafbbfd1347d5e;p=kivitendo-erp.git diff --git a/scripts/generate_client_js_actions.tpl b/scripts/generate_client_js_actions.tpl index 55206ea6a..a29b32587 100644 --- a/scripts/generate_client_js_actions.tpl +++ b/scripts/generate_client_js_actions.tpl @@ -4,20 +4,44 @@ // "scripts/generate_client_js_actions.pl". See the documentation for // SL/ClientJS.pm for instructions. -function display_flash(type, message) { +namespace("kivi", function(ns) { +ns.display_flash = function(type, message, noscroll) { $('#flash_' + type + '_content').text(message); $('#flash_' + type).show(); -} - -function eval_json_result(data) { + if (!noscroll) { + $('#frame-header')[0].scrollIntoView(); + } +}; + +ns.display_flash_detail = function(type, message) { + $('#flash_' + type + '_detail').html(message); + $('#flash_' + type + '_disp').show(); +}; + +ns.clear_flash = function(category , timeout) { + window.setTimeout(function(){ + $('#flash_' + category).hide(); + $('#flash_detail_' + category).hide(); + $('#flash_' + category + '_disp').hide(); + $('#flash_' + category + '_content').empty(); + $('#flash_' + category + '_detail').empty(); + }, timeout); +}; + +ns.eval_json_result = function(data) { if (!data) return; if (data.error) - return display_flash('error', data.error); + return ns.display_flash('error', data.error); - $('#flash_error').hide(); - $('#flash_error_content').empty(); + $(['info', 'warning', 'error']).each(function(idx, category) { + $('#flash_' + category).hide(); + $('#flash_detail_' + category).hide(); + $('#flash_' + category + '_disp').hide(); + $('#flash_' + category + '_content').empty(); + $('#flash_' + category + '_detail').empty(); + }); if ((data.js || '') != '') eval(data.js); @@ -30,13 +54,9 @@ function eval_json_result(data) { }); // console.log("current_content_type " + $('#current_content_type').val() + ' ID ' + $('#current_content_id').val()); -} +}; -function submit_ajax_form(url, form_selector, additional_data) { - var separator = /\?/.test(url) ? '&' : '?'; - $.post(url + separator + $(form_selector).serialize(), additional_data, eval_json_result); - return true; -} +}); // Local Variables: // mode: js