]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Web/JavaScript/configuration-window.js
baculum: Enlarge interface height to 100%
[bacula/bacula] / gui / baculum / protected / Web / JavaScript / configuration-window.js
1 var ConfigurationWindowClass = jQuery.klass({
2         objects: {},
3
4         initialize: function(id) {
5                 if(typeof(id) == "undefined") {
6                         return;
7                 }
8                 var prefix = id.replace('Window', 'Configuration');
9                 this.window_id = prefix + 'configuration';
10                 this.progress_id = 'configuration-progress';
11                 this.lock = false;
12         },
13
14         show: function() {
15                 this.hideAll();
16                 this.initTabs();
17                 document.getElementById(this.window_id).style.display = 'block';
18                 $('div[id=' + this.window_id + '] input[type="submit"]').each(function(index, el) {
19                         $(el).on('click', function() {
20                                 this.progress(true);
21                         }.bind(this));
22                 }.bind(this));
23         },
24
25         objectExists: function(key) {
26                 return this.objects.hasOwnProperty(key);
27         },
28
29         registerObj: function(key, obj) {
30                 if(this.objectExists(key) === false) {
31                         this.objects[key] = obj;
32                 }
33         },
34
35         getObj: function(key) {
36                 var obj = null;
37                 if(this.objectExists(key) === true) {
38                         obj = this.objects[key];
39                 }
40                 return obj;
41         },
42
43         hide: function() {
44                 document.getElementById(this.window_id).style.display = 'none';
45         },
46
47         hideAll: function() {
48                 $('div.configuration').css({'display' : 'none'});
49         },
50
51         progress: function(show) {
52                 if(show) {
53                         document.getElementById(this.progress_id).style.display = 'block';
54                 } else {
55                         document.getElementById(this.progress_id).style.display = 'none';
56                 }
57         },
58
59         is_progress: function() {
60                 return (document.getElementById(this.progress_id).style.display == 'block');
61         },
62
63         initTabs: function() {
64                 var show_elements = [];
65                 var element;
66                 var tabs = $('div[id=' + this.window_id + '] span.tab');
67                 tabs.each(function(index, el) {
68                         element = $(el).attr('rel');
69                         show_elements.push($('#' + element));
70                         $(el).on('click', function() {
71                                 for (var i = 0; i < show_elements.length; i++) {
72                                         show_elements[i].hide();
73                                 }
74                                 tabs.removeClass('tab_active');
75                                 $(el).addClass('tab_active');
76                                 var show_el = $('#' + el.getAttribute('rel'));
77                                 show_el.show();
78                         }.bind(this));
79                 }.bind(this));
80         },
81
82         switchTab: function(tab_rel) {
83                 var tabs = $('div[id=' + this.window_id + '] span.tab');
84                 tabs.each(function(index, el) {
85                         element = $(el).attr('rel');
86                         if (element == tab_rel) {
87                                 $(el).addClass('tab_active');
88                         } else {
89                                 $(el).removeClass('tab_active');
90                         }
91                         $('#' + element).hide();
92                 });
93                 $('#' + tab_rel).show();
94         },
95
96         switchTabByNo: function(tab_no) {
97                 var tab_rel;
98                 var tabs = $('div[id=' + this.window_id + '] span.tab');
99                 for (var i = 0, j = 1; i < tabs.length; i++, j++) {
100                         if (tab_no === j) {
101                                 tab_rel = tabs[i].getAttribute('rel');
102                                 break;
103                         }
104                 }
105
106                 if (tab_rel) {
107                         this.switchTab(tab_rel);
108                 }
109         },
110
111         openConfigurationWindow: function(slideWindowObj) {
112                 if(this.is_progress() === false) {
113                         this.progress(true);
114                         if(slideWindowObj.isFullSize() === true) {
115                                 slideWindowObj.resetSize();
116                         }
117                 }
118         }
119 });
120
121 var ConfigurationWindow = new ConfigurationWindowClass();
122
123 function setContentWidth() {
124         var content_width = $('#container').width() - $('#workspace-menu-left').width() - 1;
125         $('#content').css({'width': content_width + 'px'});
126 }
127
128 $(window).resize(function() {
129         setContentWidth();
130 });
131
132 $(function() {
133         setContentWidth();
134 });