Code

Made mail plugin w3c conform
[gosa.git] / html / include / focus.js
index cce26f4efedd62e56e15326f863d38d76db6d949..cc6bc15dff4cce53bcce59d4d18b70d27c7ff411 100644 (file)
@@ -152,7 +152,7 @@ function hide(element) {
      document.poppedLayer = document.all[element];
   else
      document.poppedLayer = document.layers[element];
-  document.poppedLayer.style.visibility = "hidden";
+       document.poppedLayer.style.visibility = "hidden";
 }
 
 function show(element) {
@@ -173,11 +173,11 @@ function toggle(element) {
   else
      document.poppedLayer = document.layers[element];
 
-  if (document.poppedLayer.style.visibility == "visible")
+  if (document.poppedLayer.style.visibility == "visible") {
          hide (element);
-  else
+       } else {
          show (element);
-
+       }
 }
 
 function popup(target, name) {
@@ -195,15 +195,139 @@ function js_check(form) {
        form.javascript.value = 'true';
 }
 
-window.onload = register;
-window.onresize = register;
+function divtoggle(element) {
+       var cell;
+       var cellname="tr_"+(element);
+
+       if (browserType == "gecko" ) {
+    document.poppedLayer = document.getElementById(element);
+               cell= document.getElementById(cellname);
+
+         if (document.poppedLayer.style.visibility == "visible") {
+                 hide (element);
+                       cell.style.height="0px";
+                       document.poppedLayer.style.height="0px";
+               } else {
+                 show (element);
+                       document.poppedLayer.style.height="";
+                       if(document.defaultView) {
+                               cell.style.height=document.defaultView.getComputedStyle(document.poppedLayer,"").getPropertyValue('height');
+                       }
+               }
+       } else if (browserType == "ie") {
+    document.poppedLayer = document.getElementById(element);
+               cell= document.getElementById(cellname);
+         if (document.poppedLayer.style.visibility == "visible") {
+                 hide (element);
+                       cell.style.height="0px";
+                       document.poppedLayer.style.height="0px";
+                       document.poppedLayer.style.position="absolute";
+               } else {
+                 show (element);
+                       cell.style.height="";
+                       document.poppedLayer.style.height="";
+                       document.poppedLayer.style.position="relative";
+               }
+       }
+}
+
+window.onload = adjust;
+window.onresize = adjust;
+
+function adjust (e) {
+       adjust_height(e);
+       adjust_width(e);
+}
 
-function register(e) {
+// Automatic resize (height) of divlists
+function adjust_height(e) {
        if (!e) e=window.event;
-       var px_height= window.innerHeight-220;
-       if(px_height >= 480) {
-               document.getElementById("d_scrollbody").style.height=px_height+"px";
+       if (document.getElementById("menucell") && document.getElementById("d_scrollbody")) {
+               var inner_height= window.innerHeight;
+               var min_height= 450;
+               var px_height= min_height;
+               var suggested= px_height;
+       
+               // document.defaultView allows access to the rendered size of elements and should be supported by modern browsers
+               if(document.defaultView) {
+                       var menu_height=parseInt(document.defaultView.getComputedStyle(document.getElementById("menucell"),"").getPropertyValue('height'));
+       
+                       // Minimum height for divlist should be the bottom edge of the menu
+                       min_height= menu_height-197;
+                       suggested= min_height;
+                       if((inner_height-230)-suggested>0) {
+                               suggested= inner_height-230;
+                       }
+       
+               } else if(px_height >= 450) {
+                               suggested= px_height-230;
+               }
+               document.getElementById("d_scrollbody").style.height=suggested+"px";
        }
        return true;
 }
+
+// Automatic resize (width) of divlists
+function adjust_width(e) {
+       if (!e) e=window.event;
+
+       // Known to not work with IE
+       if(document.defaultView && document.getElementById("t_scrolltable")) {
+               // 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-470;
+               
+               // 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";
+               }
+       } else if(document.defaultView && document.getElementById("t_scrolltable_onlywidth")) {
+               // Resize the div
+               var div_width=parseInt(document.defaultView.getComputedStyle(document.getElementById("t_scrolltable_onlywidth"),"").getPropertyValue('width'));
+               var width= parseInt(window.innerWidth);
+
+               // Resize the body cells
+               var diff= width-div_width-470;
+               
+               // window has been upscaled
+               if(div_width+diff>=600) {
+                       document.getElementById('d_scrollbody_onlywidth').style.width=div_width+diff+"px";
+                       document.getElementById('t_scrollbody_onlywidth').style.width=(div_width-19)+diff+"px";
+       
+                       // Resize the Header cells (only the relative-width ones)
+                       document.getElementById('t_scrollhead_onlywidth').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_onlywidth').style.width=div_width+"px";
+                       document.getElementById('t_scrollbody_onlywidth').style.width=(div_width-19)+"px";
+       
+                       // Resize the Header cells (only the relative-width ones)
+                       document.getElementById('t_scrollhead_onlywidth').style.width=div_width+"px";
+               }
+       } else {
+               // IE
+
+       }
+}
+
 // vim:ts=2:syntax