1999-07-02 02:56:04 +04:00
|
|
|
// -*- Mode: Java -*-
|
|
|
|
|
1999-07-14 04:03:57 +04:00
|
|
|
var sidebar_name = ''; // Name for preferences (e.g. 'sidebar.<name>.foo')
|
|
|
|
var sidebar_uri = ''; // Content to load in sidebar frame
|
|
|
|
var sidebar_width = 0; // Desired width of sidebar
|
|
|
|
var sidebar_pref = ''; // Base for preferences (e.g. 'sidebar.browser')
|
|
|
|
var is_sidebar_open = false;
|
|
|
|
var prefs = null; // Handle to preference interface
|
1999-07-02 02:56:04 +04:00
|
|
|
|
1999-07-14 04:03:57 +04:00
|
|
|
function init_sidebar(name, uri, width) {
|
|
|
|
sidebar_name = name;
|
|
|
|
sidebar_uri = uri;
|
|
|
|
sidebar_width = width;
|
|
|
|
sidebar_pref = 'sidebar.' + name;
|
|
|
|
|
|
|
|
// Open/close sidebar based on saved pref.
|
|
|
|
// This may be replaced by another system by hyatt.
|
|
|
|
prefs = Components.classes['component://netscape/preferences'];
|
|
|
|
if (prefs) {
|
|
|
|
prefs = prefs.getService();
|
1999-07-02 02:56:04 +04:00
|
|
|
}
|
1999-07-14 04:03:57 +04:00
|
|
|
if (prefs) {
|
|
|
|
prefs = prefs.QueryInterface(Components.interfaces.nsIPref);
|
1999-07-02 02:56:04 +04:00
|
|
|
}
|
1999-07-14 04:03:57 +04:00
|
|
|
if (prefs) {
|
|
|
|
// The sidebar is closed by default, so open it only if the
|
|
|
|
// preference is set to true.
|
1999-07-28 01:48:08 +04:00
|
|
|
try {
|
|
|
|
if (prefs.GetBoolPref(sidebar_pref + '.open')) {
|
|
|
|
toggle_open_close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("failed to get sidebar_pref\n");
|
1999-07-02 02:56:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-14 04:03:57 +04:00
|
|
|
function toggle_open_close() {
|
1999-07-02 02:56:04 +04:00
|
|
|
|
1999-07-14 04:03:57 +04:00
|
|
|
var sidebar = document.getElementById('sidebarframe');
|
|
|
|
var grippy = document.getElementById('grippy');
|
1999-07-02 02:56:04 +04:00
|
|
|
|
1999-07-14 04:03:57 +04:00
|
|
|
if (is_sidebar_open)
|
1999-07-02 02:56:04 +04:00
|
|
|
{
|
|
|
|
// Close it
|
1999-08-20 01:59:37 +04:00
|
|
|
sidebar.setAttribute('style','visibility: hidden; width: 1px');
|
1999-07-02 02:56:04 +04:00
|
|
|
sidebar.setAttribute('src','about:blank');
|
|
|
|
|
|
|
|
grippy.setAttribute('open','');
|
|
|
|
|
1999-07-14 04:03:57 +04:00
|
|
|
is_sidebar_open = false;
|
1999-07-02 02:56:04 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-08-20 01:59:37 +04:00
|
|
|
dump("Open it\n");
|
|
|
|
|
|
|
|
sidebar.setAttribute('style', 'visibility: visible;width:' + sidebar_width + 'px');
|
1999-07-14 04:03:57 +04:00
|
|
|
sidebar.setAttribute('src', sidebar_uri);
|
1999-07-02 02:56:04 +04:00
|
|
|
|
|
|
|
grippy.setAttribute('open','true');
|
|
|
|
|
1999-07-14 04:03:57 +04:00
|
|
|
is_sidebar_open = true;
|
1999-07-02 02:56:04 +04:00
|
|
|
}
|
|
|
|
|
1999-07-28 01:48:08 +04:00
|
|
|
try {
|
|
|
|
// Save new open/close state in prefs
|
|
|
|
if (prefs) {
|
|
|
|
prefs.SetBoolPref(sidebar_pref + '.open', is_sidebar_open);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("failed to set the sidebar pref\n");
|
1999-07-02 02:56:04 +04:00
|
|
|
}
|
|
|
|
}
|