Use a pref to remember open close state between sessions.

This commit is contained in:
slamm%netscape.com 1999-06-08 00:56:06 +00:00
Родитель ddb51a591e
Коммит 23524362a0
3 изменённых файлов: 53 добавлений и 11 удалений

Просмотреть файл

@ -4,7 +4,7 @@ iframe {
}
iframe[class=sidebarframe] {
width: 180px;
width: 0px;
}
titledbutton[class=grippy] {

Просмотреть файл

@ -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);

Просмотреть файл

@ -11,11 +11,11 @@
<html:script src="contentframe.js" />
<box id="container" align="horizontal" style="height: 100%; width: 100%">
<html:iframe class="sidebarframe"
src="resource:/res/rdf/sidebar-browser.xul" />
<html:iframe id="sidebarframe" class="sidebarframe"
src="about:blank" />
<box align="vertical" style="height: 100%;">
<titledbutton id="grippy" class="grippy" open='true'
onclick="resize();" flex="100%"/>
<titledbutton id="grippy" class="grippy" onclick="toggleOpenClose();"
flex="100%" />
</box>
<html:iframe type="content" id="content" src="about:blank" flex="100%" />
</box>