Code

Removed debug output
[gosa.git] / gosa-core / html / include / gosa.js
index ac561233fb5de3f9ebba3e0d7b35b6ae25fdc7d8..182617c5700afb5d10981e4f5c7ec30976fe546e 100644 (file)
@@ -221,20 +221,6 @@ if (Prototype.Browser.Gecko){
        document.onkeydown= keyHandler;
 }
 
-function GOsa_toggle(element) {
-       if (Prototype.Browser.Gecko)
-               document.poppedLayer = document.getElementById(element);
-       else if (Prototype.Browser.IE)
-               document.poppedLayer = document.all[element];
-       else
-               document.poppedLayer = document.layers[element];
-
-       if (document.poppedLayer.style.visibility == "visible") {
-               hide (element);
-       } else {
-               show (element);
-       }
-}
 
 function popup(target, name) {
        var mypopup= 
@@ -260,11 +246,11 @@ function divGOsa_toggle(element) {
                cell= document.getElementById(cellname);
 
                if (document.poppedLayer.style.visibility == "visible") {
-                       hide (element);
+                        $(element).hide();
                        cell.style.height="0px";
                        document.poppedLayer.style.height="0px";
                } else {
-                       show (element);
+                        $(element).show();
                        document.poppedLayer.style.height="";
                        if(document.defaultView) {
                                cell.style.height=document.defaultView.getComputedStyle(document.poppedLayer,"").getPropertyValue('height');
@@ -274,12 +260,12 @@ function divGOsa_toggle(element) {
                document.poppedLayer = document.getElementById(element);
                cell= document.getElementById(cellname);
                if (document.poppedLayer.style.visibility == "visible") {
-                       hide (element);
+                       $(element).hide();
                        cell.style.height="0px";
                        document.poppedLayer.style.height="0px";
                        document.poppedLayer.style.position="absolute";
                } else {
-                       show (element);
+                        $(element).show();
                        cell.style.height="";
                        document.poppedLayer.style.height="";
                        document.poppedLayer.style.position="relative";
@@ -289,57 +275,11 @@ function divGOsa_toggle(element) {
 
 function resizeHandler (e) {
        if (!e) e=window.event;
-       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= 0;
-                       if (document.getElementById("d_height")){
-                               suggested= parseInt(document.getElementById("d_height").value);
-                       } else {
-                               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;
-                               }
-
-                       }
-
-                       // IE uses other height specifications
-               } else if (Prototype.Browser.IE) {
-                       suggested= document.all.menucell.offsetHeight;
-                       offset= absTop(d_scrollbody);
-                       suggested-= offset;
-                       if((inner_height-230)-suggested>0) {
-                               suggested= inner_height-230;
-                       }
-               }
-
-               /* Reduce height if a list footer is set */
-               if(document.getElementById("t_scrollfoot")){
-                       suggested = suggested -20;
-               }
-
-               if (!document.getElementById("list_workaround")) {
-                       document.getElementById("d_scrollbody").style.height=suggested+"px";
-               } else {
-                       if (!Prototype.Browser.IE) {
-                               current_height= parseInt(document.defaultView.getComputedStyle(document.getElementById("t_nscrollbody"),"").getPropertyValue('height'));
-                               if (current_height < menu_height) {
-                                       document.getElementById("d_scrollbody").style.height=suggested+20+"px";
-                               }
-                       }
-               }
-               if (document.getElementById("t_nscrollbody")) {
-                       document.getElementById("t_nscrollbody").style.height=(suggested-22)+"px";
-               }
-       }
+       if ($("d_scrollbody") && $("t_nscrollbody")) {
+          var contentHeight= document.viewport.getHeight() - 216;
+          document.getElementById('d_scrollbody').style.height = contentHeight+23+'px';
+          document.getElementById('t_nscrollbody').style.height = contentHeight+'px';
+        }
        return true;
 }
 
@@ -363,7 +303,7 @@ function focus_field()
                var tmp = document.getElementsByName(focus_field.arguments[i]);
                for(e = 0 ; e < tmp.length ; e ++ ){
 
-                       if(tmp[e].disabled != true &&  tmp[e].type != "none" && tmp[e].type != "hidden" ){
+                       if(isVisible(tmp[e])){
                                found = true;
                                element = tmp[e];
                                break;
@@ -404,7 +344,7 @@ function next_msg_dialog()
                if(cur_id != ""){
                        ele = document.getElementById('e_layer' + cur_id);
                        ele.onmousemove = "";
-                       hide('e_layer' + cur_id);       
+                       $('e_layer' + cur_id).hide();
                        document.getElementById('closed_msg_dialogs').value += "," + cur_id;
                        document.getElementById('current_msg_dialogs').value= ""; 
                }
@@ -553,15 +493,35 @@ function move_div_by_cursor(e)
 }
 
 
-function hide(element) {
-  document.poppedLayer = document.getElementById(element);
-  document.poppedLayer.style.visibility = "hidden";
+function isVisible(obj)
+{
+    if (obj == document) return true
+
+    if (!obj) return false
+    if (!obj.parentNode) return false
+    if (obj.style) {
+        if (obj.style.display == 'none') return false
+        if (obj.style.visibility == 'hidden') return false
+    }
+
+    //Try the computed style in a standard way
+    if (window.getComputedStyle) {
+        var style = window.getComputedStyle(obj, "")
+        if (style.display == 'none') return false
+        if (style.visibility == 'hidden') return false
+    }
+
+    //Or get the computed style using IE's silly proprietary way
+    var style = obj.currentStyle
+    if (style) {
+        if (style['display'] == 'none') return false
+        if (style['visibility'] == 'hidden') return false
+    }
+
+    return isVisible(obj.parentNode)
 }
 
-function show(element) {
-  document.poppedLayer = document.getElementById(element);
-  document.poppedLayer.style.visibility = "visible";
-}
+
 
 // Global storage for baseSelector timer
 var rtimer;