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