]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #1444
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 25 Feb 2008 10:59:18 +0000 (10:59 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 25 Feb 2008 10:59:18 +0000 (10:59 +0000)
svn changeset:3912/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/Caption.java
src/com/itmill/toolkit/terminal/gwt/client/Util.java

index 06d502696f0ddd5d720071123dcd6317053a2d2e..36de42b33845a00cc05861f0d843afe9c1c37f35 100644 (file)
@@ -38,7 +38,10 @@ public class Caption extends HTML {
 
         setStyleName(getElement(), "i-disabled", uidl.hasAttribute("disabled"));
 
+        boolean isEmpty = true;
+
         if (uidl.hasAttribute("error")) {
+            isEmpty = false;
             final UIDL errorUidl = uidl.getErrors();
 
             if (errorIndicatorElement == null) {
@@ -64,6 +67,7 @@ public class Caption extends HTML {
                 DOM.appendChild(getElement(), icon.getElement());
             }
             icon.setUri(uidl.getStringAttribute("icon"));
+            isEmpty = false;
         } else {
             if (icon != null) {
                 DOM.removeChild(getElement(), icon.getElement());
@@ -77,7 +81,13 @@ public class Caption extends HTML {
                 captionText = DOM.createSpan();
                 DOM.appendChild(getElement(), captionText);
             }
-            DOM.setInnerText(captionText, uidl.getStringAttribute("caption"));
+            String c = uidl.getStringAttribute("caption");
+            if (c == null) {
+                c = "";
+            } else {
+                isEmpty = false;
+            }
+            DOM.setInnerText(captionText, c);
         } else {
             // TODO should span also be removed
         }
@@ -90,6 +100,13 @@ public class Caption extends HTML {
                 setTitle(uidl.getStringAttribute("description"));
             }
         }
+        // Workaround for IE7 weirdness, returns bad height in some
+        // circumstances when Caption is empty. See #1444
+        // IE6 works perfectly without them. I wonder what happens when
+        // IE8 arrives...
+        if (isEmpty && Util.isIE7()) {
+            setHeight("0px");
+        }
 
     }
 
index 4e1e125a876620fd4002088ebc08764e709b30f0..5ada1ee52ee4227fd7d1d44fdd8788b1ac008d14 100644 (file)
@@ -18,40 +18,43 @@ public class Util {
      * Stops execution on firefox browsers on a breakpoint.
      * 
      */
-    public static native void browserDebugger() /*-{
-                                       if(window.console)
-                                               debugger;
-                               }-*/;
+    public static native void browserDebugger()
+    /*-{
+        if(window.console)
+            debugger;
+    }-*/;
 
     /**
      * Detects if current browser is IE.
      * 
      * @return true if IE
      */
-    public static native boolean isIE() /*-{
-                                       var browser=$wnd.navigator.appName;
-                                       if (browser=="Microsoft Internet Explorer") {
-                                               return true;
-                                       }
-                                       return false;
-                               }-*/;
+    public static native boolean isIE()
+    /*-{
+       var browser=$wnd.navigator.appName;
+       if (browser=="Microsoft Internet Explorer") {
+           return true;
+       }
+       return false;
+    }-*/;
 
     /**
      * Detects if current browser is IE6.
      * 
      * @return true if IE6
      */
-    public static native boolean isIE6() /*-{
-                                       var browser=$wnd.navigator.appName;
-                                       if (browser=="Microsoft Internet Explorer") {
-                                               var ua = navigator.userAgent;
-                                               var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
-                                               if (re.exec(ua) != null)
-                                               rv = parseFloat(RegExp.$1);
-                                               if(rv == 6) return true;
-                                       }
-                                       return false;
-                               }-*/;
+    public static native boolean isIE6()
+    /*-{
+    var browser=$wnd.navigator.appName;
+    if (browser=="Microsoft Internet Explorer") {
+       var ua = navigator.userAgent;
+               var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+               if (re.exec(ua) != null)
+                       rv = parseFloat(RegExp.$1);
+                       if(rv == 6) return true;
+    }
+    return false;
+    }-*/;
 
     /**
      * Nulls oncontextmenu function on given element. We need to manually clear
@@ -60,9 +63,10 @@ public class Util {
      * 
      * @param el
      */
-    public native static void removeContextMenuEvent(Element el) /*-{
-                                       el.oncontextmenu = null;
-                               }-*/;
+    public native static void removeContextMenuEvent(Element el)
+    /*-{
+       el.oncontextmenu = null;
+    }-*/;
 
     /**
      * Traverses recursively ancestors until ContainerResizedListener child
@@ -100,4 +104,8 @@ public class Util {
         }
         return null;
     }
+
+    public static boolean isIE7() {
+        return isIE() && !isIE6();
+    }
 }