]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/baculum/protected/JavaScript/slide-window.js
baculum: Fix sorting with no impact on rows background colors
[bacula/bacula] / gui / baculum / protected / JavaScript / slide-window.js
index ed9857410e0876fb141e444f39b3172492dc486f..e8b1325c716497ace5c21a313e35579d12653d13 100644 (file)
@@ -7,20 +7,25 @@ var SlideWindowClass = Class.create({
        fullSizeEl : null,
        search: null,
        toolbar: null,
+       tools: null,
+       titlebar: null,
+       options: null,
        configurationObj: null,
        loadRequest : null,
        repeaterEl: null,
        gridEl: null,
        checked: [],
        objects: {},
+       windowSize: null,
 
        size: {
-               widthNormal : '437px',
+               widthNormal : '53%',
                heightNormal : '325px',
-               widthHalf : '437px',
+               widthHalf : '53%',
                heightHalf : '586px',
-               widthFull : '899px',
-               heightFull : '586px'
+               widthFull : '100%',
+               heightFull : '586px',
+               menuWidth: '75px'
        },
 
        elements : {
@@ -30,6 +35,7 @@ var SlideWindowClass = Class.create({
                contentItems : 'slide-window-element',
                contentAlternatingItems : 'slide-window-element-alternating',
                toolsButtonSuffix : '-slide-window-tools',
+               optionsButtonSuffix : '-slide-window-options',
                actionsSuffix : '-slide-window-actions',
                toolbarSuffix : '-slide-window-toolbar',
                titleSuffix : '-slide-window-title'
@@ -43,7 +49,9 @@ var SlideWindowClass = Class.create({
                this.windowId = windowId;
                this.window = $(this.windowId + this.elements.containerSuffix);
                this.tools = $(this.windowId + this.elements.toolsButtonSuffix);
-               
+               this.options = $(this.windowId + this.elements.optionsButtonSuffix);
+               this.titlebar = $(this.windowId + this.elements.titleSuffix);
+
                if(data.hasOwnProperty('showId')) {
                                this.showEl = $(data.showId);
                } else {
@@ -105,6 +113,10 @@ var SlideWindowClass = Class.create({
                        this.resetSize();
                }.bind(this));
 
+               this.titlebar.observe('dblclick', function() {
+                       this.resetSize();
+               }.bind(this));
+
                this.search.observe('keyup', function(){
                        this.setSearch();
                }.bind(this));
@@ -112,6 +124,10 @@ var SlideWindowClass = Class.create({
                this.tools.observe('click', function() {
                        this.toggleToolbar();
                }.bind(this));
+
+               this.options.observe('click', function() {
+                       this.toggleToolbar();
+               }.bind(this));
        },
        
        openWindow : function() {
@@ -128,6 +144,10 @@ var SlideWindowClass = Class.create({
                        }.bind(this)
                });
        },
+
+       isWindowOpen: function() {
+               return !(this.window.style.display === 'none');
+       },
        
        resetSize : function() {
                if(this.isConfigurationOpen()) {
@@ -150,27 +170,30 @@ var SlideWindowClass = Class.create({
        },
 
        isNormalSize: function() {
-               return (this.window.getWidth()  + 'px' == this.size.widthNormal && this.window.getHeight()  + 'px' == this.size.heightNormal);
+               return (this.windowSize == this.size.widthNormal && this.window.getHeight()  + 'px' == this.size.heightNormal);
        },
 
        isHalfSize: function() {
-               return (this.window.getWidth()  + 'px' == this.size.widthHalf && this.window.getHeight()  + 'px' == this.size.heightHalf);
+               return (this.windowSize == this.size.widthHalf && this.window.getHeight()  + 'px' == this.size.heightHalf);
        },
 
        isFullSize: function() {
-               return (this.window.getWidth()  + 'px' == this.size.widthFull && this.window.getHeight()  + 'px' == this.size.heightFull);
+               return (this.windowSize  == this.size.widthFull && this.window.getHeight()  + 'px' == this.size.heightFull);
        },
 
        normalSizeWindow: function() {
                        new Effect.Morph(this.window, {style : 'width: ' + this.size.widthNormal + '; height: ' + this.size.heightNormal + ';', duration : 0.4});
+                       this.windowSize = this.size.widthNormal;
        },
        
        halfSizeWindow: function() {
                        new Effect.Morph(this.window, {style : 'width: ' + this.size.widthHalf + '; height: ' + this.size.heightHalf + ';', duration : 0.4});
+                       this.windowSize = this.size.widthHalf;
        },
        
        fullSizeWindow: function() {
                        new Effect.Morph(this.window, {style : 'width: ' + this.size.widthFull + '; height: ' + this.size.heightFull + ';', duration : 0.4});
+                       this.windowSize = this.size.widthFull;
        },
 
        hideOtherWindows: function() {
@@ -251,7 +274,15 @@ var SlideWindowClass = Class.create({
                        }
                        return reverse * (val);
                });
-               for(i = 0; i < tr.length; ++i) tb.appendChild(tr[i]);
+               for(i = 0; i < tr.length; i++) {
+                       var even = ((i % 2) == 0);
+                       if (even) {
+                               tr[i].className = this.elements.contentItems;
+                       } else {
+                               tr[i].className = this.elements.contentAlternatingItems;
+                       }
+                       tb.appendChild(tr[i]);
+               }
        },
 
        makeSortable: function () {
@@ -265,7 +296,12 @@ var SlideWindowClass = Class.create({
                } else {
                        return;
                }
-               while (--i >= 1) (function (i) {
+               var downCounter = 0;
+               // skip first column if in column header is input (checkbox for elements mark)
+               if (th[0].childNodes[0].nodeName == "INPUT") {
+                       downCounter = 1;
+               }
+               while (--i >= downCounter) (function (i) {
                        var dir = 1;
                        th[i].addEventListener('click', function () {
                                self.sortTable(i, (dir = 1 - dir));
@@ -293,7 +329,6 @@ var SlideWindowClass = Class.create({
                        }.bind(search_pattern));
        },
        setElementsCount : function() {
-               var title_el = $(this.windowId + this.elements.titleSuffix);
                var elements_count = $$('div[id="' + this.windowId + this.elements.containerSuffix + '"] div.' + this.elements.contentItems).length || $$('div[id="' + this.windowId + this.elements.containerSuffix + '"] tr.' + this.elements.contentItems + ', div[id="' + this.windowId + this.elements.containerSuffix + '"] tr.' + this.elements.contentAlternatingItems).length;
                var count_el = $(this.windowId + this.elements.titleSuffix).getElementsByTagName('span')[0];
                $(count_el).update(' (' + elements_count + ')');
@@ -349,7 +384,9 @@ var SlideWindowClass = Class.create({
                                        this.markChecked(containerId, ch.checked, ch.value);
                                }
                        }.bind(this));
-                       this.packChecked(containerId);
+                       if (containerId) {
+                               this.packChecked(containerId);
+                       }
                }
 
                if(check) {
@@ -414,7 +451,7 @@ var SlideWindowClass = Class.create({
 var SlideWindow = new SlideWindowClass()
 
 document.observe("dom:loaded", function() {
-       if(Prototype.Browser.IE  || Prototype.Browser.Gecko) {
+       if(Prototype.Browser.IE  || Prototype.Browser.Gecko || Prototype.Browser.WebKit) {
                $$('input[type=checkbox], input[type=submit], input[type=radio], a').each(function(el) {
                        el.observe('focus', function() {
                                el.blur();
@@ -422,3 +459,17 @@ document.observe("dom:loaded", function() {
                });
        }
 });
+
+function setContentWidth() {
+       var content_width = $('container').getWidth() - $('menu-left').getWidth() - 1;
+       $('content').setStyle({'width': content_width + 'px'});
+}
+
+
+Event.observe(window, 'resize', function() {
+       setContentWidth();
+});
+
+document.observe("dom:loaded", function() {
+       setContentWidth();
+});