ClientJS: Unterstützung für Browser-Redirects ("$js->redirect_to")
[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   $('#flash_error').hide();
20   $('#flash_error_content').empty();
21
22   if ((data.js || '') != '')
23     eval(data.js);
24
25   if (data.eval_actions)
26     $(data.eval_actions).each(function(idx, action) {
27       // console.log("ACTION " + action[0] + " ON " + action[1]);
28
29 [% actions %]
30     });
31
32   // console.log("current_content_type " + $('#current_content_type').val() + ' ID ' + $('#current_content_id').val());
33 }
34
35 function submit_ajax_form(url, form_selector, additional_data) {
36   var separator = /\?/.test(url) ? '&' : '?';
37   $.post(url + separator + $(form_selector).serialize(), additional_data, eval_json_result);
38   return true;
39 }
40
41 // Local Variables:
42 // mode: js
43 // End: