]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Web/JavaScript/bacula-config.js
baculum: Fix incorrect table name error during restore start
[bacula/bacula] / gui / baculum / protected / Web / JavaScript / bacula-config.js
1 var BaculaConfigClass = jQuery.klass({
2         show_item: function(element, show) {
3                 var el = $(element);
4                 var duration;
5                 if (show === true && el.is(':visible') === false) {
6                         el.slideDown({duration: 400});
7                 } else if (show === false && el.is(':visible') === true) {
8                         el.slideUp({duration: 500});
9                 }
10         },
11         show_items: function(selector, show) {
12                 $(selector).each(function(index, el) {
13                         this.show_item(el, show);
14                 }.bind(this));
15         },
16         show_new_config: function(sender, component_type, component_name, resource_type) {
17                 var container = $('div.config_directives[rel="' + sender + '"]');
18                 var h2 = container.find('h2');
19                 var text = h2[0].getAttribute('rel');
20                 text = text.replace('%component_type', component_type);
21                 text = text.replace('%component_name', component_name);
22                 text = text.replace('%resource_type', resource_type);
23                 h2[0].textContent = text;
24                 container.find('div.config_directives').show();
25                 this.show_item(container, true);
26                 this.scroll_to_element(container);
27         },
28         scroll_to_element: function(selector) {
29                 $('html,body').animate({scrollTop: $(selector).offset().top}, 'slow');
30         },
31         get_child_container: function(sender) {
32                 var child_container = $('#' + sender).closest('table').next('div');
33                 return child_container;
34         },
35         get_element_sender: function(el) {
36                 var element_sender = el.closest('table').prev('a');
37                 return element_sender;
38         },
39         set_config_items(id) {
40                 var child_container = this.get_child_container(id);
41                 var show = !child_container.is(':visible');
42                 this.show_item(child_container, show);
43                 this.loader_stop(id);
44         },
45         unset_config_items: function(id) {
46                 var child_container = this.get_child_container(id);
47                 var selector = [child_container[0].nodeName.toLowerCase(), child_container[0].className].join('.');
48                 this.show_items(selector, false);
49                 /**
50                  * Send request about items only if items are invisible to avoid
51                  * asking about items when they are visible already.
52                  */
53                 var send = !child_container.is(':visible');
54                 return send;
55         },
56         get_loader: function(id) {
57                 var loader = $('#' + id).next('img');
58                 return loader;
59         },
60         loader_start: function(id) {
61                 var loader = this.get_loader(id);
62                 $(loader).show();
63         },
64         loader_stop: function(id) {
65                 var loader = this.get_loader(id);
66                 $(loader).hide();
67         }
68 });
69
70 var BaculaConfigOptionsClass = jQuery.klass({
71         css: {
72                 options_container: 'directive_setting'
73         },
74         options_id: null,
75         action_obj: null,
76         initialize: function(opts) {
77                 if (opts.hasOwnProperty('options_id')) {
78                         this.options_id = opts.options_id;
79                 }
80                 if (opts.hasOwnProperty('action_obj')) {
81                         this.action_obj = opts.action_obj;
82                 }
83                 this.set_events();
84         },
85         set_events: function() {
86                 var element = document.getElementById(this.options_id);
87                 var opts = element.getElementsByTagName('LI');
88                 for (var i = 0; i < opts.length; i++) {
89                         opts[i].addEventListener('click', function(e) {
90                                 var el = e.srcElement || e.target;
91                                 var action = el.getAttribute('rel');
92                                 this.do_action(action);
93                         }.bind(this));
94                 }
95         },
96         get_options: function() {
97                 ;
98         },
99         do_action: function(param) {
100                 if (typeof(this.action_obj) === "object") {
101                         this.action_obj.setCallbackParameter(param);
102                         this.action_obj.dispatch();
103                 }
104         }
105 });
106
107 var BaculaConfig = new BaculaConfigClass();