]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #1004 and #999
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Sun, 21 Oct 2007 14:58:26 +0000 (14:58 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Sun, 21 Oct 2007 14:58:26 +0000 (14:58 +0000)
svn changeset:2570/svn branch:trunk

WebContent/ITMILL/themes/tests-featurebrowser/layouts/featurebrowser-mainlayout.html
src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java

index e859c763e07a6c5c3f17d2e9cf68ead9f5ae5a98..2483ca7013a74300c3a338c54450a92d66dd1515 100644 (file)
@@ -3,7 +3,7 @@
 <link REL="stylesheet" TYPE="text/css">
 </head>
 
-<body><div id="_UID_main" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"><img src="img/header.png" />
+<body><div id="_UID_main" style="display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%;"><img src="img/header.png" />
        
        <div id="_UID_features" style="top: 62px; width: 200px; position: absolute; overflow: auto; left: 0;" location="tree">
                <div style="width: 100%; height: 100%; border: 1px solid red;">tree</div>
 
 <script type="text/javascript">
 
+/** Recalculate tabs content width */
+_UID_updateTabs = function() {
+       try {
+               var tabsDiv = document.getElementById("_UID_tabs");
+               var tabsComponent = itmill.themes.Demo.prototype._UID_elemByIndex(tabsDiv.childNodes,0);
+               if (tabsComponent == null) return;
+               var tabs = itmill.themes.Demo.prototype._UID_elemByIndex(tabsComponent.childNodes,0);
+               if (tabs == null) return;
+               var content = itmill.themes.Demo.prototype._UID_elemByIndex(tabsComponent.childNodes,1);
+               if (content == null) return;
+               content.style.height="" + (tabsDiv.offsetHeight - tabs.offsetHeight-13) + "px";
+               content.style.borderBottom="0";
+               content.style.overflow='auto';
+               var iframe = content.getElementsByTagName("iframe").item(0);
+               if (iframe != null) { 
+                       content.style.overflow='hidden';
+                       content.style.padding='0';      
+                       content.style.height="" + (tabsDiv.offsetHeight - tabs.offsetHeight) + "px";
+                       iframe.height=content.style.height;
+                       iframe.style.border='0';
+               }
+       } catch (e) {}
+};
+
+/** Helper method. Get element from node array by index */
+_UID_elemByIndex = function(nodeArray, index) {
+       if (typeof nodeArray == 'undefined' || nodeArray == null) return null;
+       var i=0;
+       while (index>=0 && i < nodeArray.length) {
+               while(i < nodeArray.length && nodeArray[i].nodeType != Node.ELEMENT_NODE) i++;
+               if (index == 0) return nodeArray[i];
+               index--; i++;
+       }
+       return null;
+}
+
+_UID_dividerUpdate = function() {
+       var dividerDiv = document.getElementById("_UID_divider");
+       var div = document.getElementById("_UID_main");
+       dividerDiv.isActive = true;
+       div.onmouseup = function() {
+               dividerDiv.isActive = false;
+               div.onmouseup = null;
+               div.onmousemove = null;
+       }
+       div.onmousemove = function(e) {
+               dividerDiv.mouseY = typeof e != 'undefined' ? e.clientY : window.event.clientY;
+               _UID_layout();
+       }
+       return false;
+};
+
 /** Recalculate feature browser main layout dimensions for all components */
 _UID_layout = function() {
 
@@ -88,6 +140,7 @@ _UID_layout = function() {
        var height = document.body.offsetHeight;
        mainDiv.style.height = height + "px";
        mainDiv.style.width = width + "px";
+       mainDiv.style.display = "";
 
        // Recalc features div dimensions
        var featuresWidth = 200;
@@ -170,61 +223,9 @@ _UID_layout = function() {
        }
        
        /* call custom layouts bridge to notify sub components */
-       mainDiv.notifyChildrenOfSizeChange();
-       
+       mainDiv.notifyChildrenOfSizeChange();   
 };
 
-/** Recalculate tabs content width */
-_UID_updateTabs = function() {
-       try {
-               var tabsDiv = document.getElementById("_UID_tabs");
-               var tabsComponent = itmill.themes.Demo.prototype._UID_elemByIndex(tabsDiv.childNodes,0);
-               if (tabsComponent == null) return;
-               var tabs = itmill.themes.Demo.prototype._UID_elemByIndex(tabsComponent.childNodes,0);
-               if (tabs == null) return;
-               var content = itmill.themes.Demo.prototype._UID_elemByIndex(tabsComponent.childNodes,1);
-               if (content == null) return;
-               content.style.height="" + (tabsDiv.offsetHeight - tabs.offsetHeight-13) + "px";
-               content.style.borderBottom="0";
-               content.style.overflow='auto';
-               var iframe = content.getElementsByTagName("iframe").item(0);
-               if (iframe != null) { 
-                       content.style.overflow='hidden';
-                       content.style.padding='0';      
-                       content.style.height="" + (tabsDiv.offsetHeight - tabs.offsetHeight) + "px";
-                       iframe.height=content.style.height;
-                       iframe.style.border='0';
-               }
-       } catch (e) {}
-};
-
-/** Helper method. Get element from node array by index */
-_UID_elemByIndex = function(nodeArray, index) {
-       if (typeof nodeArray == 'undefined' || nodeArray == null) return null;
-       var i=0;
-       while (index>=0 && i < nodeArray.length) {
-               while(i < nodeArray.length && nodeArray[i].nodeType != Node.ELEMENT_NODE) i++;
-               if (index == 0) return nodeArray[i];
-               index--; i++;
-       }
-       return null;
-}
-
-_UID_dividerUpdate = function() {
-       var dividerDiv = document.getElementById("_UID_divider");
-       var div = document.getElementById("_UID_main");
-       dividerDiv.isActive = true;
-       div.onmouseup = function() {
-               dividerDiv.isActive = false;
-               div.onmouseup = null;
-               div.onmousemove = null;
-       }
-       div.onmousemove = function(e) {
-               dividerDiv.mouseY = typeof e != 'undefined' ? e.clientY : window.event.clientY;
-               _UID_layout();
-       }
-       return false;
-};
 
 _UID_initFeatureBrowserLayout = function() {
        var dividerDiv = document.getElementById("_UID_divider");
@@ -239,8 +240,7 @@ _UID_initFeatureBrowserLayout = function() {
                _UID_layout();
        };
        
-       
-       _UID_layout();
+//     _UID_layout();
 };
 
 _UID_initFeatureBrowserLayout();
index 5c077d090aa90527f0718d75c4ae990ef76cb0cf..c1841e08110dbf8d2512975c52dd2ed9f88e6f79 100644 (file)
@@ -104,6 +104,10 @@ public class ICustomLayout extends ComplexPanel implements Paintable,
                        initializeHTML(uidl, client);
                }
 
+               // Evaluate scripts
+               eval(scripts);
+               scripts = null;
+               
                // For all contained widgets
                for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
                        UIDL uidlForChild = (UIDL) i.next();
@@ -120,11 +124,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable,
                        }
                }
 
-               // Evaluate scripts only once
-               if (scripts != null) {
-                       eval(scripts);
-                       scripts = null;
-               }
+               iLayout();
        }
 
        /** Initialize HTML-layout. */
@@ -162,8 +162,9 @@ public class ICustomLayout extends ComplexPanel implements Paintable,
                        throw (new IllegalStateException(
                                        "Could not find IView; maybe updateFromUIDL() was called before attaching the widget?"));
                }
-
+               
                publishResizedFunction(DOM.getFirstChild(getElement()));
+               
        }
 
        private boolean hasTemplate() {
@@ -195,7 +196,8 @@ public class ICustomLayout extends ComplexPanel implements Paintable,
 
        /** Evaluate given script in browser document */
        private static native void eval(String script) /*-{
-        try { 
+        try {
+        if (script != null) 
         eval("{ var document = $doc; var window = $wnd; "+ script + "}");
         } catch (e) {
         }
@@ -270,6 +272,10 @@ public class ICustomLayout extends ComplexPanel implements Paintable,
                return res;
        }
 
+       protected void onAttach() {
+               super.onAttach();
+       }
+
        /** Replace child components */
        public void replaceChildComponent(Widget from, Widget to) {
                String location = getLocation(from);
@@ -389,7 +395,8 @@ public class ICustomLayout extends ComplexPanel implements Paintable,
        /*-{
                if(el && el.iLayoutJS) {
                        try {
-                               return el.iLayoutJS();
+                               el.iLayoutJS();
+                               return true;
                        } catch (e) {
                                return false;
                        }