Code

Automatic resizing of divlists (height+width).
authorjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 3 Apr 2006 13:00:02 +0000 (13:00 +0000)
committerjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 3 Apr 2006 13:00:02 +0000 (13:00 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2955 594d385d-05f5-0310-b6e9-bd551577e9d8

html/include/focus.js
include/class_divlist.inc

index cce26f4efedd62e56e15326f863d38d76db6d949..4e68a3718c3c040324acd655653bcb42595867e8 100644 (file)
@@ -195,15 +195,52 @@ function js_check(form) {
        form.javascript.value = 'true';
 }
 
-window.onload = register;
-window.onresize = register;
+window.onload = adjust;
+window.onresize = adjust;
 
-function register(e) {
+function adjust(e) {
+       adjust_height(e);
+       adjust_width(e);
+}
+
+// Automatic resize (height) of divlists
+function adjust_height(e) {
        if (!e) e=window.event;
-       var px_height= window.innerHeight-220;
+       var px_height= window.innerHeight-230;
        if(px_height >= 480) {
                document.getElementById("d_scrollbody").style.height=px_height+"px";
        }
        return true;
 }
+
+// Automatic resize (width) of divlists
+function adjust_width(e) {
+       if (!e) e=window.event;
+
+       // Resize the div
+       var div_width=parseInt(document.defaultView.getComputedStyle(document.getElementById("t_scrolltable"),"").getPropertyValue('width'));
+       var width= parseInt(window.innerWidth);
+
+       // Resize the body cells
+               var diff= width-div_width-430;
+
+       // window has been upscaled
+       if(div_width+diff>=600) {
+               document.getElementById('d_scrollbody').style.width=div_width+diff+"px";
+               document.getElementById('t_scrollbody').style.width=(div_width-19)+diff+"px";
+       
+               // Resize the Header cells (only the relative-width ones)
+               document.getElementById('t_scrollhead').style.width=div_width+diff+"px";
+
+       // window has been downscaled, we must reset the div to 600px
+       } else if (width < 930) {
+               // Reset layout (set width to 600px)
+               div_width=600;
+               document.getElementById('d_scrollbody').style.width=div_width+"px";
+               document.getElementById('t_scrollbody').style.width=(div_width-19)+"px";
+       
+               // Resize the Header cells (only the relative-width ones)
+               document.getElementById('t_scrollhead').style.width=div_width+"px";
+       }
+}
 // vim:ts=2:syntax
index 62a4dd31e322a2e6341916e3f7e5798e9cc4bc86..fe836f4531b89b4429171f0f68c6dfea21d5e8b4 100644 (file)
@@ -58,7 +58,7 @@ class divlist {
        
        function DrawList(){
                $s_return = "";
-               $s_return.= "<table summary='".$this->s_summary."' style='width:".$this->s_width."px;height:".$this->s_height."px;' cellspacing='0'>";
+               $s_return.= "<table summary='".$this->s_summary."' style='width:".$this->s_width."px;height:".$this->s_height."px;' cellspacing='0' id='t_scrolltable'>";
 
     $s_return.= $this->_generateHeader();
     $s_return.=$this->_generatePage();
@@ -91,7 +91,7 @@ class divlist {
                
     // Using scrolltable?
     if($this->i_entriesPerPage == 0) {
-      $s_return .= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width."px;' cellspacing='0'>";
+      $s_return .= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width."px;' cellspacing='0' id='t_scrollhead'>";
     }
 
                $s_return .= "\n<tr>";
@@ -108,7 +108,7 @@ class divlist {
 
                }
                
-    // Attach a 18px-wide column (used as scrollbar space in body-table),
+    // Attach a 13px-wide column (used as scrollbar space in body-table),
     // but do this only if we are really using scrolltables.
     if($this->i_entriesPerPage == 0) {
       $s_return .= "\n<td class='listheader' style='width:13px;border-right:0px;'>&nbsp;</td>";
@@ -132,7 +132,7 @@ class divlist {
     if($this->i_entriesPerPage == 0) {
       // We need to construct a "body"-table that is width-of-scrollbar thinner than the "head"-table.
       $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width."px;height:".($this->s_height-20)."px;' id='d_scrollbody' class='scrollbody'>";
-      $s_return .= "<table summary='' style='height:100%;width:581px;' cellspacing='0'>";
+      $s_return .= "<table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody'>";
        }
  
     $i_alternate=0;