Keep the size of the sidebar while replacing the menu.
authorJan Schneider <jan@horde.org>
Fri, 25 Jun 2010 17:28:35 +0000 (19:28 +0200)
committerJan Schneider <jan@horde.org>
Fri, 25 Jun 2010 17:41:35 +0000 (19:41 +0200)
Use dom:loaded.

framework/Tree/lib/Horde/Tree/Javascript.php
horde/js/sidebar.js
horde/services/portal/sidebar.php

index 6a4f8d7..74a3bae 100644 (file)
@@ -115,7 +115,7 @@ class Horde_Tree_Javascript extends Horde_Tree
     {
         $this->_buildIndents($this->_root_nodes);
 
-        return 'window.' . $this->_instance . '.renderTree(' . Horde_Serialize::serialize($this->_nodes, Horde_Serialize::JSON, Horde_Nls::getCharset()) . ',' . Horde_Serialize::serialize($this->_root_nodes, Horde_Serialize::JSON, Horde_Nls::getCharset()) . ',' . ($this->_static ? 'true' : 'false') . ')';
+        return 'window.' . $this->_instance . '.renderTree(' . Horde_Serialize::serialize($this->_nodes, Horde_Serialize::JSON, Horde_Nls::getCharset()) . ',' . Horde_Serialize::serialize($this->_root_nodes, Horde_Serialize::JSON, Horde_Nls::getCharset()) . ',' . ($this->_static ? 'true' : 'false') . ');';
     }
 
 }
index 5449d9c..ea501c2 100644 (file)
@@ -45,16 +45,26 @@ var HordeSidebar = {
         new Ajax.PeriodicalUpdater(
             'horde_menu',
             horde_sidebar_url,
-            { parameters: { httpclient: 1 },
-              method: 'get',
-              evalScripts: true,
-              frequency: horde_sidebar_refresh }
+            {
+                parameters: { httpclient: 1 },
+                method: 'get',
+                evalScripts: true,
+                frequency: horde_sidebar_refresh,
+                onSuccess: function ()
+                {
+                    var layout = $('horde_menu').getLayout();
+                    $('horde_menu').setStyle({
+                        width: layout.get('width') + 'px',
+                        height: layout.get('height') + 'px'
+                    });
+                }
+            }
         );
     }
 
 };
 
-Event.observe(window, 'load', function() {
+document.observe('dom:loaded', function() {
     $('hiddenSidebar').hide();
     if (HordeSidebar.getCookie('horde_sidebar_expanded', true).toString() != $('expandedSidebar').visible().toString()) {
         HordeSidebar.toggleMenuFrame();
index c5ed37d..3de1d64 100644 (file)
@@ -266,7 +266,10 @@ foreach ($menu as $app => $params) {
 // updated node javascript.
 if (Horde_Util::getFormData('httpclient')) {
     header('Content-Type: application/json; charset=' . Horde_Nls::getCharset());
-    echo Horde::wrapInlineScript(array($tree->renderNodeDefinitions()));
+    $scripts = array(
+        $tree->renderNodeDefinitions(),
+        '$(\'horde_menu\').setStyle({ width: \'auto\', height: \'auto\' });');
+    echo Horde::wrapInlineScript($scripts);
     exit;
 }