]> source.dussan.org Git - vaadin-framework.git/commitdiff
Now customlayout loading __seems__ to work with ff, ie6, ie7, safari...
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Mon, 18 Jun 2007 15:54:57 +0000 (15:54 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Mon, 18 Jun 2007 15:54:57 +0000 (15:54 +0000)
svn changeset:1763/svn branch:trunk

WebContent/theme/demo/layout/featurebrowser-mainlayout.html
src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java

index d39d9cd3e66ba230e7556e6c81f1ba62628db8b5..ac0623983ce83bb00c0ba0f8dc9fe9ca75e1168b 100644 (file)
@@ -4,7 +4,7 @@
 </head>
 
 <body>
-<div id="featurebrowser-mainlayout" style="position: absolute; top: 0pt; left: 0pt;"><img src="img/header.png" />
+<div id="featurebrowser-mainlayout" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"><img src="img/header.png" />
 
 <div id="featurebrowser-features" style="top: 62px; width: 200px;">
        <div location="tree">puu</div>
@@ -65,7 +65,7 @@
 </div>
 
 <div id="featurebrowser-divider"
-       style="overflow: hidden; position: absolute; width: 137px; height: 17px;" /></div>
+       style="overflow: hidden; position: absolute; width: 137px; height: 17px;" />
 </div>
 
 <script type="text/javascript">
@@ -92,13 +92,13 @@ recalcFeatureBrowserLayout = function() {
        // Get whole window contents size
        document.body.style.padding = 0;
        document.body.style.margin = 0; 
-       mainDiv.style.width="100%";
-       mainDiv.style.height="100%";
-       
-       var width = mainDiv.offsetWidth;
-       var height = mainDiv.offsetHeight;
-       if (document.body.offsetWidth > mainDiv.offsetWidth) width = document.body.offsetWidth;
-       if (document.body.offsetHeight > mainDiv.offsetHeight) height = document.body.offsetHeight;
+       document.body.style.position = "absolute";
+       document.body.style.height = "100%";
+       document.body.style.width = "100%";
+       var width = document.body.offsetWidth;
+       var height = document.body.offsetHeight;
+       mainDiv.style.height = height + "px";
+       mainDiv.style.width = width + "px";
 
        // Recalc features div dimensions
        var featuresWidth = 200;
index a24779125a4e746561954512b186ccd3763e9803..43dedca116e9c765b7c956ad24e2b5908c4e9743 100644 (file)
@@ -81,12 +81,15 @@ public class ICustomLayout extends SimplePanel implements Paintable, Layout {
        /** Scripts must be evaluated when the document has been rendered */
        protected void onLoad() {
                super.onLoad();
-               eval(scripts);
+               if (scripts != null) {
+                       eval(scripts);
+                       scripts = null;
+               }
        }
 
        /** Evaluate given script in browser document */
        private native void eval(String script) /*-{
-        try {
+        try { 
         eval("{ var document = $doc; var window = $wnd; "+ script + "}");
         } catch (e) {
         }
@@ -94,7 +97,7 @@ public class ICustomLayout extends SimplePanel implements Paintable, Layout {
 
        /** Scan for location divs and add unique ids for them */
        private native void addUniqueIdsForLocations(Element e, String idPrefix) /*-{
-       try {
+        try {
         var divs = e.getElementsByTagName("div"); 
         for (var i = 0; i < divs.length; i++) {
         var div = divs[i];
@@ -104,13 +107,13 @@ public class ICustomLayout extends SimplePanel implements Paintable, Layout {
         div.innerHTML="";
         }
         }      
-                } catch (e) {}
-               
+        } catch (e) {}
+        
         }-*/;
 
        /** Prefix all img tag srcs with given prefix. */
        private native void prefixImgSrcs(Element e, String srcPrefix) /*-{
-       try {
+        try {
         var divs = e.getElementsByTagName("img"); 
         var base = "" + $doc.location;
         var l = base.length-1;
@@ -125,18 +128,20 @@ public class ICustomLayout extends SimplePanel implements Paintable, Layout {
         } catch (e) { alert(e + " " + srcPrefix);}
         }-*/;
 
-       /** Exctract body part and script tags from raw html-template.
+       /**
+        * Exctract body part and script tags from raw html-template.
         * 
-        * Saves contents of all script-tags to private property: scripts.
-        * Returns contents of the body part for the html without script-tags.
+        * Saves contents of all script-tags to private property: scripts. Returns
+        * contents of the body part for the html without script-tags.
         * 
-        * @param html Original HTML-template received from server
+        * @param html
+        *            Original HTML-template received from server
         * @return html that is used to create the HTMLPanel.
         */
        private String extractBodyAndScriptsFromTemplate(String html) {
-               
+
                // Exctract script-tags
-               scripts ="";
+               scripts = "";
                int endOfPrevScript = 0;
                int nextPosToCheck = 0;
                String lc = html.toLowerCase();
@@ -145,13 +150,13 @@ public class ICustomLayout extends SimplePanel implements Paintable, Layout {
                while (scriptStart > 0) {
                        res += html.substring(endOfPrevScript, scriptStart);
                        scriptStart = lc.indexOf(">", scriptStart);
-                       int j = lc.indexOf("</script>",scriptStart);
-                       scripts += html.substring(scriptStart+1,j) + ";";
+                       int j = lc.indexOf("</script>", scriptStart);
+                       scripts += html.substring(scriptStart + 1, j) + ";";
                        nextPosToCheck = endOfPrevScript = j + "</script>".length();
                        scriptStart = lc.indexOf("<script", nextPosToCheck);
                }
                res += html.substring(endOfPrevScript);
-               
+
                // Extract body
                html = res;
                lc = html.toLowerCase();
@@ -160,14 +165,14 @@ public class ICustomLayout extends SimplePanel implements Paintable, Layout {
                        res = html;
                } else {
                        res = "";
-                       startOfBody = lc.indexOf(">",startOfBody)+1;
-                       int endOfBody = lc.indexOf("</body>",startOfBody);
+                       startOfBody = lc.indexOf(">", startOfBody) + 1;
+                       int endOfBody = lc.indexOf("</body>", startOfBody);
                        if (endOfBody > startOfBody)
-                               res = html.substring(startOfBody,endOfBody);
-                       else 
+                               res = html.substring(startOfBody, endOfBody);
+                       else
                                res = html.substring(startOfBody);
-               }               
-               
+               }
+
                return res;
        }