Revert to old sidebar ui (bug 26075). Changes for remote folders in customize (bug 23357). More changes for 23357 are coming...

This commit is contained in:
slamm%netscape.com 2000-02-02 00:28:00 +00:00
parent c04c4d51f9
commit cd58e3cb00
6 changed files with 205 additions and 177 deletions

View File

@ -66,6 +66,11 @@ treeitem > treerow > treecell > .tree-icon
list-style-image: url("chrome://bookmarks/skin/bookmark-item.gif");
}
treeitem[haslink="true"] > treerow > treecell > .tree-icon
{
list-style-image: url("chrome://bookmarks/skin/bookmark-folder-closed.gif");
}
treeitem[container="true"] > treerow > treecell > .tree-icon
{
list-style-image: url("chrome://bookmarks/skin/bookmark-folder-closed.gif");

View File

@ -41,31 +41,34 @@ function Init()
sidebar.datasource_uri = window.arguments[2];
sidebar.resource = window.arguments[3];
debug("all panels datasources = " + all_panels_datasources);
debug("all panels resource = " + all_panels_resource);
debug("sidebar.datasource_uri = " + sidebar.datasource_uri);
debug("sidebar.resource = " + sidebar.resource);
debug("Init: all panels datasources = " + all_panels_datasources);
debug("Init: all panels resource = " + all_panels_resource);
debug("Init: sidebar.datasource_uri = " + sidebar.datasource_uri);
debug("Init: sidebar.resource = " + sidebar.resource);
var all_panels = document.getElementById('other-panels');
var current_panels = document.getElementById('current-panels');
all_panels_datasources = all_panels_datasources.split(/\s+/);
for (var ii = 0; ii < all_panels_datasources.length; ii++) {
debug("Adding "+all_panels_datasources[ii]);
debug("Init: Adding "+all_panels_datasources[ii]);
// This will load the datasource, if it isn't already.
var datasource = RDF.GetDataSource(all_panels_datasources[ii]);
all_panels.database.AddDataSource(datasource);
current_panels.database.AddDataSource(datasource);
}
// Add the datasource for current list of panels. It selects panels out
// of the other datasources.
debug("Init: Adding current panels, "+sidebar.datasource_uri);
sidebar.datasource = RDF.GetDataSource(sidebar.datasource_uri);
current_panels.database.AddDataSource(sidebar.datasource);
// Root the customize dialog at the correct place.
debug("Init: reset all panels ref, "+all_panels_resource);
all_panels.setAttribute('ref', all_panels_resource);
debug("Init: reset current panels ref, "+sidebar.resource);
current_panels.setAttribute('ref', sidebar.resource);
saveInitialPanels();
@ -95,20 +98,48 @@ function getAttr(registry,service,attr_name) {
function SelectChangeForOtherPanels(event, target)
{
// Remove the selection in the "current" panels list
var current_panels = document.getElementById('current-panels');
current_panels.clearItemSelection();
enableButtonsForCurrentPanels();
// Remove the selection in the "current" panels list
var current_panels = document.getElementById('current-panels');
current_panels.clearItemSelection();
enableButtonsForCurrentPanels();
if (target.getAttribute('container') == 'true') {
if (target.getAttribute('open') == 'true') {
target.removeAttribute('open');
} else {
target.setAttribute('open','true');
}
return;
}
enableButtonsForOtherPanels();
if (target.getAttribute('container') == 'true') {
if (target.getAttribute('open') == 'true') {
target.removeAttribute('open');
} else {
target.setAttribute('open','true');
}
} else {
link = target.getAttribute('link');
if (link && link != '') {
debug("Has remote datasource: "+link);
addDatasourceToOtherPanels(link);
target.setAttribute('container', 'true');
target.setAttribute('open', 'true');
}
enableButtonsForOtherPanels();
}
}
function addDatasourceToOtherPanels(link) {
// Convert the |link| attribute into a URL
var url = document.location;
debug("Current URL: " +url);
debug("Current link: " +link);
uri = Components.classes['component://netscape/network/standard-url'].createInstance();
uri = uri.QueryInterface(Components.interfaces.nsIURI);
uri.spec = url;
uri = uri.resolve(link);
debug("New URL: " +uri);
// Add the datasource to the tree
var all_panels = document.getElementById('other-panels');
all_panels.database.AddDataSource(RDF.GetDataSource(uri));
// XXX This is a hack to force re-display
all_panels.setAttribute('ref', 'urn:blah:main-root');
}
// Handle a selection change in the current panels.
@ -385,10 +416,9 @@ function enableButtonsForOtherPanels()
num_selected++;
}
}
if (num_selected > 0) {
add_button.setAttribute('disabled','');
preview_button.setAttribute('disabled','');
add_button.removeAttribute('disabled');
preview_button.removeAttribute('disabled');
}
else {
add_button.setAttribute('disabled','true');
@ -417,13 +447,13 @@ function enableButtonsForCurrentPanels() {
if (numSelected != 1 || isFirst) {
up.setAttribute('disabled', 'true');
} else {
up.setAttribute('disabled', '');
up.removeAttribute('disabled');
}
// down \/ button
if (numSelected != 1 || isLast) {
down.setAttribute('disabled', 'true');
} else {
down.setAttribute('disabled', '');
down.removeAttribute('disabled');
}
// "Customize..." button
var customizeURL = null;
@ -433,13 +463,13 @@ function enableButtonsForCurrentPanels() {
if (customizeURL == null || customizeURL == '') {
customize.setAttribute('disabled','true');
} else {
customize.setAttribute('disabled','');
customize.removeAttribute('disabled');
}
// "Remove" button
if (numSelected == 0) {
remove.setAttribute('disabled','true');
} else {
remove.setAttribute('disabled','');
remove.removeAttribute('disabled');
}
}
@ -465,7 +495,7 @@ function enableSave() {
if (list_unchanged) {
save_button.setAttribute('disabled','true');
} else {
save_button.setAttribute('disabled','');
save_button.removeAttribute('disabled');
}
}

View File

@ -53,30 +53,31 @@
&sidebar.customize.additional.label;
</html:div>
<html:div style="width:15em;height:15em" flex="1*">
<tree id="other-panels" size="10"
datasources="rdf:null"
indent="true"
style="width:100%;height:100%">
<template>
<treechildren onclick="SelectChangeForOtherPanels(event, event.target.parentNode.parentNode)">
<treeitem uri="rdf:*"
title="rdf:http://home.netscape.com/NC-rdf#title"
content="rdf:http://home.netscape.com/NC-rdf#content"
open="rdf:http://home.netscape.com/NC-rdf#open"
persist="open">
<treerow>
<treecell indent="true"
value="rdf:http://home.netscape.com/NC-rdf#title"/>
</treerow>
</treeitem>
</treechildren>
</template>
<treecol />
</tree>
</html:div>
<tree id="other-panels" flex="1"
datasources="rdf:null"
indent="true"
multiple="true"
style="height:15em">
<template>
<treechildren>
<treeitem uri="rdf:*"
title="rdf:http://home.netscape.com/NC-rdf#title"
content="rdf:http://home.netscape.com/NC-rdf#content"
link="rdf:http://home.netscape.com/NC-rdf#link"
haslink="rdf:http://home.netscape.com/NC-rdf#haslink"
open="rdf:http://home.netscape.com/NC-rdf#open"
persist="open">
<treerow>
<treecell indent="true"
value="rdf:http://home.netscape.com/NC-rdf#title"/>
</treerow>
</treeitem>
</treechildren>
</template>
<treecol />
<treechildren onclick="SelectChangeForOtherPanels(event, event.target.parentNode.parentNode)" />
</tree>
<!-- xxxslamm Need to add descriptive panel text here -->
<box align="horizontal" class="button-group">
@ -102,33 +103,28 @@
</html:div>
<box align="horizontal" class="box-group" flex="1*">
<html:div style="width:15em;height:15em" flex="1*">
<tree id="current-panels" onclick="SelectChangeForCurrentPanels();"
datasources="rdf:null"
style="width:100%;height:100%">
<template>
<treechildren>
<treeitem uri="rdf:*"
title="rdf:http://home.netscape.com/NC-rdf#title"
customize="rdf:http://home.netscape.com/NC-rdf#customize"
content="rdf:http://home.netscape.com/NC-rdf#content"
persist="open">
<treerow>
<treecell
value="rdf:http://home.netscape.com/NC-rdf#title" />
</treerow>
</treeitem>
</treechildren>
</template>
<treecol />
<!-- We explicitly create a 'treechildren' so we can refer
to it from the script -->
<treechildren id="current-panels-root"/>
</tree>
</html:div>
<tree id="current-panels" onclick="SelectChangeForCurrentPanels();"
datasources="rdf:null"
multiple="true"
style="height:0px">
<template>
<treechildren>
<treeitem uri="rdf:*"
title="rdf:http://home.netscape.com/NC-rdf#title"
customize="rdf:http://home.netscape.com/NC-rdf#customize"
content="rdf:http://home.netscape.com/NC-rdf#content">
<treerow>
<treecell
value="rdf:http://home.netscape.com/NC-rdf#title" />
</treerow>
</treeitem>
</treechildren>
</template>
<treecol />
<!-- We explicitly create a 'treechildren' so we can refer
to it from the script -->
<treechildren id="current-panels-root"/>
</tree>
<!-- Spacing between the right selector and "Reorder" -->
<spring style="width:5px"/>

View File

@ -75,7 +75,6 @@ box#sidebar-box {
box#sidebar-panels {
min-width: 1px;
min-height: 1px;
border-bottom: 2px solid #003366;
}
box#sidebar-box[hidden="true"] {
@ -126,7 +125,7 @@ titledbutton.panel-bar {
padding: 0px;
margin: 0px;
min-width: 1px;
padding-left: 15px;
padding-left: 5px;
border-top: 1px solid white;
background-color: #CCCCCC;
font-size: smaller;
@ -134,7 +133,6 @@ titledbutton.panel-bar {
titledbutton.panel-bar[selected="true"] {
background-color: #98CCF8;
padding-left: 5px;
margin: 0px;
border-bottom: 1px solid #808080;
}

View File

@ -90,9 +90,10 @@ function getSidebarDatasourceURI(panels_file_id) {
}
function sidebarOverlayInit() {
sidebar.datasource_uri = getSidebarDatasourceURI(PANELS_RDF_FILE);
sidebar.resource = 'urn:sidebar:current-panel-list';
sidebar.master_resource = 'urn:sidebar:master-panel-list';
sidebar.datasource_uri = getSidebarDatasourceURI(PANELS_RDF_FILE);
sidebar.resource = 'urn:sidebar:current-panel-list';
sidebar.master_datasources = 'chrome://sidebar/content/local-panels.rdf chrome://sidebar/content/remote-panels.rdf';
sidebar.master_resource = 'urn:sidebar:master-panel-list';
// Initialize the display
var sidebar_element = document.getElementById('sidebar-box')
@ -116,136 +117,126 @@ function sidebarOverlayInit() {
var panels = document.getElementById('sidebar-panels');
panels.database.AddDataSource(RDF.GetDataSource(sidebar.datasource_uri));
// The stuff on the bottom
var panels_bottom = document.getElementById('sidebar-panels-bottom');
panels_bottom.database.AddDataSource(RDF.GetDataSource(sidebar.datasource_uri));
debug("Adding observer to database.");
panels.database.AddObserver(panel_observer);
// XXX This is a hack to force re-display
panels.setAttribute('ref', sidebar.resource);
// XXX This is a hack to force re-display
panels_bottom.setAttribute('ref', sidebar.resource);
sidebarOpenDefaultPanel(100, 0);
}
}
/* BEGIN: old sidebar layout code
function sidebarOpenDefaultPanel(wait, tries) {
var parent = document.getElementById('sidebar-panels');
var target = parent.getAttribute('open-panel-src');
var children = parent.childNodes;
var panels_top = document.getElementById('sidebar-panels');
var target = panels_top.getAttribute('open-panel-src');
var top_headers = panels_top.childNodes;
debug("sidebarOpenDefaultPanel("+wait+","+tries+")");
debug(" target="+target);
debug("\nsidebarOpenDefaultPanel("+wait+","+tries+")\n");
if (children.length < 3) {
if (tries < 5) {
// No children yet, try again later
setTimeout('sidebarOpenDefaultPanel('+(wait*2)+','+(tries+1)+')',wait);
}
return;
}
if (target && target != '') {
for (var ii=0; ii < children.length; ii++) {
if (children.item(ii).getAttribute('src') == target) {
children.item(ii).removeAttribute('collapsed');
return;
}
}
}
// Pick the first one
var first_iframe = children.item(2);
if (first_iframe) {
first_iframe.removeAttribute('collapsed');
parent.setAttribute('open-panel-src',first_iframe.getAttribute('src'));
}
}
END: old sidebar layout code */
function sidebarOpenDefaultPanel(wait, tries) {
var parent = document.getElementById('sidebar-panels');
var target = parent.getAttribute('open-panel-src');
var children = parent.childNodes;
var iframe = document.getElementById('sidebar-content');
debug("sidebarOpenDefaultPanel("+wait+","+tries+")");
debug(" target="+target);
if (children.length <= 1) {
if (top_headers.length <= 1) {
if (tries < 5) {
// No children yet, try again later
setTimeout('sidebarOpenDefaultPanel('+(wait*2)+','+(tries+1)+')',wait);
} else {
// No panels.
// XXX This should load some help page instead of about:blank.
var iframe = document.getElementById('sidebar-content');
iframe.setAttribute('src', 'about:blank');
}
return;
}
selectPanel(target);
}
function selectPanel(target) {
var panels_top = document.getElementById('sidebar-panels');
var iframe = document.getElementById('sidebar-content');
var top_headers = panels_top.childNodes;
debug("selectPanel("+target+")");
var select_index = findPanel(top_headers, target);
if (!select_index) {
// Target not found. Pick the first panel by default.
// It is at index 1 because the template is at index 0.
select_index = 1;
target = top_headers.item(1).getAttribute('iframe-src');
}
// Update the content area if necessary.
if (iframe.getAttribute('src') != target) {
iframe.setAttribute('src', target);
}
if (panels_top.getAttribute('open-panel-src') != target) {
panels_top.setAttribute('open-panel-src', target);
}
updateHeaders(select_index);
}
function findPanel(panels, target) {
if (target && target != '') {
// Try to select the prefered panel
if (iframe.getAttribute('src') != target) {
iframe.setAttribute('src', target);
}
for (var ii=0; ii < children.length; ii++) {
if (children.item(ii).getAttribute('iframe-src') == target) {
// Find the index of the selected panel
for (var ii=1; ii < panels.length; ii++) {
var item = panels.item(ii);
if (item.getAttribute('iframe-src') == target) {
// Found it!
children.item(ii).setAttribute('selected','true');
return;
return ii;
}
}
}
// Pick the first panel
var first_button = children.item(1);
if (first_button) {
first_button.setAttribute('selected','true');
target = first_button.getAttribute('iframe-src');
parent.setAttribute('open-panel-src', target);
iframe.setAttribute('src', target);
}
return 0;
}
/* BEGIN: old sidebar layout code
function SidebarSelectPanel(titledbutton) {
var target = titledbutton.getAttribute('iframe-src');
var last_src = titledbutton.parentNode.getAttribute('open-panel-src');
var children = titledbutton.parentNode.childNodes;
function updateHeaders(index) {
var top_headers = document.getElementById('sidebar-panels').childNodes;
var bottom_headers = document.getElementById('sidebar-panels-bottom').childNodes;
if (target == last_src) {
return;
}
for (var ii=1; ii < top_headers.length; ii++) {
var top_item = top_headers.item(ii);
var bottom_item = bottom_headers.item(ii);
for (var ii=0; ii < children.length; ii++) {
var src = children.item(ii).getAttribute('src')
if (src == target) {
children.item(ii).removeAttribute('collapsed');
titledbutton.parentNode.setAttribute('open-panel-src',target);
}
if (src == last_src) {
children.item(ii).setAttribute('collapsed','true');
if (ii < index) {
top_item.removeAttribute('selected');
top_item.removeAttribute('style');
bottom_item.setAttribute('style','display:none');
} else if (ii == index) {
top_item.setAttribute('selected','true');
top_item.removeAttribute('style');
bottom_item.setAttribute('style','display:none');
} else {
top_item.setAttribute('style','display:none');
bottom_item.removeAttribute('style');
bottom_item.removeAttribute('selected');
}
}
}
END: old sidebar layout code */
// Change the sidebar content to the selected panel.
// Called when a panel title is clicked.
function SidebarSelectPanel(titledbutton) {
var target = titledbutton.getAttribute('iframe-src');
var last_src = titledbutton.parentNode.getAttribute('open-panel-src');
var children = titledbutton.parentNode.childNodes;
var iframe = document.getElementById('sidebar-content');
if (target == last_src) {
// XXX Maybe this should reload the content?
return;
}
titledbutton.parentNode.setAttribute('open-panel-src',target);
titledbutton.setAttribute('selected','true');
iframe.setAttribute('src',target);
for (var ii=0; ii < children.length; ii++) {
if (children.item(ii).getAttribute('iframe-src') == last_src) {
children.item(ii).removeAttribute('selected');
}
}
selectPanel(target);
}
// No one is calling this right now.
@ -279,13 +270,14 @@ function SidebarCustomize() {
gDisableCustomize = true;
var panels = document.getElementById('sidebar-panels');
var datasources = panels.getAttribute('datasources');
customizeWindow = window.openDialog(
'chrome://sidebar/content/customize.xul',
'_blank','chrome,resizable',
datasources, sidebar.master_resource,
sidebar.datasource_uri, sidebar.resource);
sidebar.master_datasources,
sidebar.master_resource,
sidebar.datasource_uri,
sidebar.resource);
setTimeout(enableCustomize, 2000);
}
}

View File

@ -41,8 +41,7 @@
</splitter>
<box align="vertical" flex="1*">
<box id="sidebar-panels" align="vertical"
datasources="chrome://sidebar/content/local-panels.rdf
chrome://sidebar/content/remote-panels.rdf"
datasources="chrome://sidebar/content/local-panels.rdf chrome://sidebar/content/remote-panels.rdf"
ref="urn:sidebar:current-panel-list"
persist='open-panel-src'>
<template>
@ -52,15 +51,23 @@
class="panel-bar borderless"
onclick="SidebarSelectPanel(this)"
iframe-src="rdf:http://home.netscape.com/NC-rdf#content" />
<!-- <html:iframe uri="rdf:*" content="true"
src="rdf:http://home.netscape.com/NC-rdf#content"
class="panel-frame" collapsed='true' flex='1*'/>
-->
</rule>
</template>
</box>
<html:iframe id="sidebar-content" content="true" src="about:blank"
class="panel-frame" flex='1*'/>
<box id="sidebar-panels-bottom" align="vertical"
datasources="chrome://sidebar/content/local-panels.rdf chrome://sidebar/content/remote-panels.rdf">
<template>
<rule>
<titledbutton uri="rdf:*" align="left"
value="rdf:http://home.netscape.com/NC-rdf#title"
class="panel-bar borderless"
onclick="SidebarSelectPanel(this)"
iframe-src="rdf:http://home.netscape.com/NC-rdf#content" />
</rule>
</template>
</box>
</box>
</box>