50a427c458964ff2c1decd910140a24fed5e2fbf
[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 namespace("kivi", function(ns) {
8 ns.display_flash = function(type, message) {
9   $('#flash_' + type + '_content').text(message);
10   $('#flash_' + type).show();
11   $('#frame-header')[0].scrollIntoView();
12 };
13
14 ns.display_flash_detail = function(type, message) {
15   $('#flash_' + type + '_detail').html(message);
16   $('#flash_' + type + '_disp').show();
17 };
18
19 ns.eval_json_result = function(data) {
20   if (!data)
21     return;
22
23   if (data.error)
24     return ns.display_flash('error', data.error);
25
26   $(['info', 'warning', 'error']).each(function(idx, category) {
27     $('#flash_' + category).hide();
28     $('#flash_detail_' + category).hide();
29     $('#flash_' + category + '_disp').hide();
30     $('#flash_' + category + '_content').empty();
31     $('#flash_' + category + '_detail').empty();
32   });
33
34   if ((data.js || '') != '')
35     eval(data.js);
36
37   if (data.eval_actions)
38     $(data.eval_actions).each(function(idx, action) {
39       // console.log("ACTION " + action[0] + " ON " + action[1]);
40
41 [% actions %]
42     });
43
44   // console.log("current_content_type " + $('#current_content_type').val() + ' ID ' + $('#current_content_id').val());
45 };
46
47 });
48
49 // Local Variables:
50 // mode: js
51 // End: