Improve sidebar discoverability.

b=134345; r=morse; sr=jag
This commit is contained in:
sgehani%netscape.com 2006-07-27 14:56:52 +00:00
Родитель 0fd8e0abd7
Коммит 0ea73965c0
3 изменённых файлов: 78 добавлений и 4 удалений

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

@ -704,9 +704,15 @@ function refresh_all_sidebars() {
// Sidebar Init // Sidebar Init
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
function sidebar_overlay_init() { function sidebar_overlay_init() {
// do we have a sidebar?
if (!document.getElementById("sidebar-panels-splitter-box"))
return;
if (sidebar_is_collapsed() && !gAboutToUncollapse) if (sidebar_is_collapsed() && !gAboutToUncollapse)
return; return;
gMustInit = false; gMustInit = false;
sidebarObj.panels = new sbPanelList('sidebar-panels'); sidebarObj.panels = new sbPanelList('sidebar-panels');
sidebarObj.datasource_uri = get_sidebar_datasource_uri(); sidebarObj.datasource_uri = get_sidebar_datasource_uri();
sidebarObj.resource = 'urn:sidebar:current-panel-list'; sidebarObj.resource = 'urn:sidebar:current-panel-list';
@ -733,6 +739,9 @@ function sidebar_overlay_init() {
if (sidebarObj.never_built) { if (sidebarObj.never_built) {
sidebarObj.never_built = false; sidebarObj.never_built = false;
// set personal toolbar sidebar icon to correct state
SidebarToggleIcon();
debug("sidebar = " + sidebarObj); debug("sidebar = " + sidebarObj);
debug("sidebarObj.resource = " + sidebarObj.resource); debug("sidebarObj.resource = " + sidebarObj.resource);
debug("sidebarObj.datasource_uri = " + sidebarObj.datasource_uri); debug("sidebarObj.datasource_uri = " + sidebarObj.datasource_uri);
@ -780,9 +789,14 @@ function sidebar_overlay_init() {
} }
function sidebar_overlay_destruct() { function sidebar_overlay_destruct() {
var panels = document.getElementById('sidebar-panels');
debug("Removing observer from database."); // do we have a sidebar?
panels.database.RemoveObserver(panel_observer); if (!document.getElementById("sidebar-panels-splitter-box"))
return;
var panels = document.getElementById('sidebar-panels');
debug("Removing observer from database.");
panels.database.RemoveObserver(panel_observer);
} }
function sidebar_open_default_panel(wait, tries) { function sidebar_open_default_panel(wait, tries) {
@ -1091,6 +1105,7 @@ function sidebar_is_collapsed() {
} }
function SidebarExpandCollapse() { function SidebarExpandCollapse() {
SidebarToggleIcon();
var sidebar_splitter = document.getElementById('sidebar-splitter'); var sidebar_splitter = document.getElementById('sidebar-splitter');
var sidebar_box = document.getElementById('sidebar-box'); var sidebar_box = document.getElementById('sidebar-box');
if (sidebar_splitter.getAttribute('state') == 'collapsed') { if (sidebar_splitter.getAttribute('state') == 'collapsed') {
@ -1117,6 +1132,7 @@ function sidebar_is_hidden() {
// Show/Hide the entire sidebar. // Show/Hide the entire sidebar.
// Invoked by the "View / Sidebar" menu option. // Invoked by the "View / Sidebar" menu option.
function SidebarShowHide() { function SidebarShowHide() {
SidebarToggleIcon();
var sidebar_box = document.getElementById('sidebar-box'); var sidebar_box = document.getElementById('sidebar-box');
var title_box = document.getElementById('sidebar-title-box'); var title_box = document.getElementById('sidebar-title-box');
var sidebar_panels_splitter = document.getElementById('sidebar-panels-splitter'); var sidebar_panels_splitter = document.getElementById('sidebar-panels-splitter');
@ -1299,6 +1315,27 @@ function SidebarTogglePanel(panel_menuitem) {
sidebarObj.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush(); sidebarObj.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
} }
function SidebarToggleIcon()
{
var sidebarButton = document.getElementById("sidebar-button");
if (sidebarButton)
{
var newValue = false;
if (sidebarButton.getAttribute("sbopen") == "false")
newValue = true;
sidebarButton.setAttribute("sbopen", newValue);
var tooltipText;
if (newValue) // it's open so show action ``<== Close Sidebar''
tooltipText = sidebarButton.getAttribute("sbclosetooltip");
else // it's closed so show action ``==> Open Sidebar''
tooltipText = sidebarButton.getAttribute("sbopentooltip");
sidebarButton.setAttribute("tooltiptext", tooltipText);
}
}
function SidebarNavigate(aDirection) function SidebarNavigate(aDirection)
{ {
debug("SidebarNavigate " + aDirection); debug("SidebarNavigate " + aDirection);

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

@ -54,6 +54,42 @@
oncommand="SidebarCustomize();"/> oncommand="SidebarCustomize();"/>
</popup> </popup>
<!-- insert the sidebar toggle button in the personal toolbar -->
<toolbar id="PersonalToolbar">
<toolbarbutton id="sidebar-button" position="1"
sbopen="false"
tooltiptext="&sidebar.open.tooltip;"
sbopentooltip="&sidebar.open.tooltip;"
sbclosetooltip="&sidebar.close.tooltip;"
oncommand="if (sidebar_is_hidden()) SidebarShowHide(); else SidebarExpandCollapse(); event.preventBubble();"/>
<toolbarseparator persist="hidden"/>
</toolbar>
<!-- add a pref for the sidebar toggle button -->
<vbox id="prefShowButtonsBox1">
<checkbox id="sidebarToggleButton"
label="&sidebar.panels.label;"
insertafter="homeButton"
pref="true"
preftype="bool"
prefstring="browser.toolbars.showbutton.sidebar"
prefattribute="checked"/>
</vbox>
<script type="application/x-javascript">
if (this._elementIDs)
{
this._elementIDs.push("sidebarToggleButton");
// add a popupset to quiesce complaints from the cookie context menus
const kXULNS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var popupset = document.createElementNS(kXULNS, "popupset");
popupset.setAttribute("id", "contentAreaContextSet");
document.documentElement.appendChild(popupset);
}
</script>
<!-- Overlay the sidebar panels --> <!-- Overlay the sidebar panels -->
<vbox id="sidebar-box" persist="hidden width collapsed"> <vbox id="sidebar-box" persist="hidden width collapsed">
<splitter id="sidebar-panels-splitter" collapse="after" persist="state" <splitter id="sidebar-panels-splitter" collapse="after" persist="state"

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

@ -45,4 +45,5 @@
<!ENTITY sidebar.pagenotfound.label "This tab is not available right now."> <!ENTITY sidebar.pagenotfound.label "This tab is not available right now.">
<!ENTITY sidebar.close.tooltip "Close Sidebar"> <!ENTITY sidebar.close.tooltip "Close Sidebar">
<!ENTITY sidebar.open.tooltip "Open Sidebar">