From 4002a461df612a0320b657ce3c187584a737322c Mon Sep 17 00:00:00 2001 From: "slamm%netscape.com" Date: Tue, 8 Jun 1999 00:56:06 +0000 Subject: [PATCH] Use a pref to remember open close state between sessions. --- xpfe/browser/src/contentframe.css | 2 +- xpfe/browser/src/contentframe.js | 54 +++++++++++++++++++++++++++---- xpfe/browser/src/contentframe.xul | 8 ++--- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/xpfe/browser/src/contentframe.css b/xpfe/browser/src/contentframe.css index 60f44aa77568..95fdc2818c80 100644 --- a/xpfe/browser/src/contentframe.css +++ b/xpfe/browser/src/contentframe.css @@ -4,7 +4,7 @@ iframe { } iframe[class=sidebarframe] { - width: 180px; + width: 0px; } titledbutton[class=grippy] { diff --git a/xpfe/browser/src/contentframe.js b/xpfe/browser/src/contentframe.js index ad009c86c72d..7cb04dd401e4 100644 --- a/xpfe/browser/src/contentframe.js +++ b/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/xpfe/browser/src/contentframe.xul b/xpfe/browser/src/contentframe.xul index 838e29048226..169655e12ecb 100644 --- a/xpfe/browser/src/contentframe.xul +++ b/xpfe/browser/src/contentframe.xul @@ -11,11 +11,11 @@ - + - +