mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Use a pref to remember open close state between sessions.
This commit is contained in:
parent
692562586a
commit
4002a461df
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user