]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/baculum/protected/JavaScript/configuration-window.js
baculum: Add possibility to open configuration windows from URL
[bacula/bacula] / gui / baculum / protected / JavaScript / configuration-window.js
index 2bb7c6a17ebbb427482b5b0363811760320575d8..2acb06db4bf414c845fec5bb90cad303749fb0ae 100644 (file)
@@ -1,12 +1,19 @@
 var ConfigurationWindowClass = new Class.create({
+       objects: {},
+
        initialize: function(id) {
-               this.window_id = id + 'configuration';
-               this.progress_id = id + 'configuration-progress';
+               if(typeof(id) == "undefined") {
+                       return;
+               }
+               var prefix = id.replace('Window', 'Configuration');
+               this.window_id = prefix + 'configuration';
+               this.progress_id = 'configuration-progress';
                this.lock = false;
        },
 
        show: function() {
                this.hideAll();
+               this.initTabs();
                $(this.window_id).setStyle({'display' : 'block'});
                $$('div[id=' + this.window_id + '] input[type="submit"]').each(function(el) {
                        el.observe('click', function() {
@@ -15,6 +22,24 @@ var ConfigurationWindowClass = new Class.create({
                }.bind(this));
        },
 
+       objectExists: function(key) {
+               return this.objects.hasOwnProperty(key);
+       },
+
+       registerObj: function(key, obj) {
+               if(this.objectExists(key) === false) {
+                       this.objects[key] = obj;
+               }
+       },
+
+       getObj: function(key) {
+               var obj = null;
+               if(this.objectExists(key) === true) {
+                       obj = this.objects[key];
+               }
+               return obj;
+       },
+
        hide: function() {
                $(this.window_id).setStyle({'display' : 'none'});
        },
@@ -35,5 +60,62 @@ var ConfigurationWindowClass = new Class.create({
 
        is_progress: function() {
                return $(this.progress_id).getStyle('display') == 'block';
+       },
+
+       initTabs: function() {
+               var show_elements = [];
+               var element;
+               var tabs = $$('div[id=' + this.window_id + '] span.tab');
+               tabs.each(function(el) {
+                       element = el.readAttribute('rel');
+                       show_elements.push($(element));
+                       el.observe('click', function() {
+                               show_elements.invoke('hide');
+                               tabs.invoke('removeClassName', 'tab_active');
+                               el.addClassName('tab_active');
+                               var show_el = $(el.readAttribute('rel'));
+                               $(show_el).show();
+                       }.bind(this));
+               }.bind(this));
+       },
+
+       switchTab: function(tab_rel) {
+               var tabs = $$('div[id=' + this.window_id + '] span.tab');
+               tabs.each(function(el) {
+                       element = el.readAttribute('rel');
+                       if (element == tab_rel) {
+                               el.addClassName('tab_active');
+                       } else {
+                               el.removeClassName('tab_active');
+                       }
+                       $(element).hide();
+               });
+               $(tab_rel).show();
+       },
+
+       switchTabByNo: function(tab_no) {
+               var tab_rel;
+               var tabs = $$('div[id=' + this.window_id + '] span.tab');
+               for (var i = 0, j = 1; i < tabs.length; i++, j++) {
+                       if (tab_no === j) {
+                               tab_rel = tabs[i].readAttribute('rel');
+                               break;
+                       }
+               }
+
+               if (tab_rel) {
+                       this.switchTab(tab_rel);
+               }
+       },
+
+       openConfigurationWindow: function(slideWindowObj) {
+               if(this.is_progress() === false) {
+                       this.progress(true);
+                       if(slideWindowObj.isFullSize() === true) {
+                               slideWindowObj.resetSize();
+                       }
+               }
        }
-});
\ No newline at end of file
+});
+
+var ConfigurationWindow = new ConfigurationWindowClass();