ClientJS: alle Flash-Kategorien nach nächstem Standard-AJAX-Call leeren
[kivitendo-erp.git] / scripts / generate_client_js_actions.tpl
1 // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE:
2
3 // This file is generated automatically by the script
4 // "scripts/generate_client_js_actions.pl". See the documentation for
5 // SL/ClientJS.pm for instructions.
6
7 function display_flash(type, message) {
8   $('#flash_' + type + '_content').text(message);
9   $('#flash_' + type).show();
10 }
11
12 function eval_json_result(data) {
13   if (!data)
14     return;
15
16   if (data.error)
17     return display_flash('error', data.error);
18
19   $(['info', 'warning', 'error']).each(function(idx, category) {
20     $('#flash_' + category).hide();
21     $('#flash_' + category + '_content').empty();
22   });
23
24   if ((data.js || '') != '')
25     eval(data.js);
26
27   if (data.eval_actions)
28     $(data.eval_actions).each(function(idx, action) {
29       // console.log("ACTION " + action[0] + " ON " + action[1]);
30
31 [% actions %]
32     });
33
34   // console.log("current_content_type " + $('#current_content_type').val() + ' ID ' + $('#current_content_id').val());
35 }
36
37 function submit_ajax_form(url, form_selector, additional_data) {
38   var separator = /\?/.test(url) ? '&' : '?';
39   $.post(url + separator + $(form_selector).serialize(), additional_data, eval_json_result);
40   return true;
41 }
42
43 // Local Variables:
44 // mode: js
45 // End: