diff --git a/mozilla/xpfe/browser/src/contentframe.css b/mozilla/xpfe/browser/src/contentframe.css index 60f44aa7756..95fdc2818c8 100644 --- a/mozilla/xpfe/browser/src/contentframe.css +++ b/mozilla/xpfe/browser/src/contentframe.css @@ -4,7 +4,7 @@ iframe { } iframe[class=sidebarframe] { - width: 180px; + width: 0px; } titledbutton[class=grippy] { diff --git a/mozilla/xpfe/browser/src/contentframe.js b/mozilla/xpfe/browser/src/contentframe.js index ad009c86c72..7cb04dd401e 100644 --- a/mozilla/xpfe/browser/src/contentframe.js +++ b/mozilla/xpfe/browser/src/contentframe.js @@ -1,15 +1,42 @@ // -*- Mode: Java -*- -var isSidebarOpen = true; +var sidebarURI = 'resource:/res/rdf/sidebar-browser.xul'; +var isSidebarOpen = false; + +function Init() { + var pref = Components.classes['component://netscape/preferences'].getService(); + pref = pref.QueryInterface(Components.interfaces.nsIPref); + + if (pref) { + pref.SetDefaultIntPref('sidebar.width', 170); + // pref.SetIntPref(pref.GetIntPref('sidebar.width')); + pref.SetDefaultBoolPref('sidebar.open', true); + pref.SavePrefFile(); + if (pref.GetBoolPref('sidebar.open')) { + toggleOpenClose(); + } + } +} + +function toggleOpenClose() { + // Get the open width and update the pref state + var pref = Components.classes['component://netscape/preferences'].getService(); + pref = pref.QueryInterface(Components.interfaces.nsIPref); + var width = 0; + + if (pref) { + pref.SetBoolPref('sidebar.open', !isSidebarOpen); + width = pref.GetIntPref('sidebar.width'); + pref.SavePrefFile(); + } -function resize() { - dump("Resize()\n"); if (isSidebarOpen) { + // Close it var container = document.getElementById('container'); var sidebar = container.firstChild; sidebar.setAttribute('style','width:0px; visibility:hidden'); - + sidebar.setAttribute('src','about:blank'); //container.removeChild(container.firstChild); var grippy = document.getElementById('grippy'); @@ -19,10 +46,11 @@ function resize() { } else { + // Open it var container = document.getElementById('container'); var sidebar = container.firstChild; - sidebar.setAttribute('style','width:200px; visibility:visible'); - isSidebarOpen = false; + sidebar.setAttribute('style','width:' + width + 'px; visibility:visible'); + sidebar.setAttribute('src',sidebarURI); //var sidebar = document.createElement('html:iframe'); //sidebar.setAttribute('src','resource:/res/rdf/sidebar-browser.xul'); @@ -35,4 +63,18 @@ function resize() { isSidebarOpen = true; } + } + +// To get around "window.onload" not working in viewer. +function Boot() +{ + var root = document.documentElement; + if (root == null) { + setTimeout(Boot, 0); + } else { + Init(); + } +} + +setTimeout('Boot()', 0); diff --git a/mozilla/xpfe/browser/src/contentframe.xul b/mozilla/xpfe/browser/src/contentframe.xul index 838e2904822..169655e12ec 100644 --- a/mozilla/xpfe/browser/src/contentframe.xul +++ b/mozilla/xpfe/browser/src/contentframe.xul @@ -11,11 +11,11 @@ - + - +