Landing of SIDEBAR_19991007_BRANCH. r=waterson

This commit is contained in:
slamm%netscape.com 1999-10-18 19:21:52 +00:00
Родитель 27ffdf6482
Коммит 64d8fa3b2f
23 изменённых файлов: 720 добавлений и 1033 удалений

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

@ -1 +1,2 @@
bookmarks.html
panels.rdf

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

@ -26,4 +26,4 @@ include $(topsrcdir)/config/rules.mk
install::
$(INSTALL) $(srcdir)/bookmarks.html $(DIST)/bin/defaults/profile
$(INSTALL) $(srcdir)/panels.rdf $(DIST)/bin/defaults/profile

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

@ -22,6 +22,7 @@ include <$(DEPTH)\config\rules.mak>
FILES=\
bookmarks.html \
panels.rdf \
$(NULL)
install::

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

@ -1,95 +1,94 @@
// -*- Mode: Java -*-
/* -*- Mode: Java; tab-width: 4; insert-tabs-mode: nil; c-basic-offset: 2 -*-
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
*/
// the rdf service
var RDF;
var RDF = 'component://netscape/rdf/rdf-service'
RDF = Components.classes[RDF].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
var NC = "http://home.netscape.com/NC-rdf#";
var sidebar;
var sidebar = new Object;
function debug(msg)
{
//dump(msg);
}
function Init()
{
RDF=Components.classes['component://netscape/rdf/rdf-service'].getService();
RDF=RDF.QueryInterface(Components.interfaces.nsIRDFService);
sidebar = new Object;
sidebar.db = window.arguments[0];
sidebar.resource = window.arguments[1];
debug("sidebar.db = " + sidebar.db + "\n");
debug("sidebar.resource = " + sidebar.resource + "\n");
var registry;
try {
// First try to construct a new one and load it
// synchronously. nsIRDFService::GetDataSource() loads RDF/XML
// asynchronously by default.
registry = Components.classes['component://netscape/rdf/datasource?name=xml-datasource'].createInstance();
registry = registry.QueryInterface(Components.interfaces.nsIRDFDataSource);
// This will load the datasource, if it isn't already.
sidebar.datasource = RDF.GetDataSource(sidebar.db);
var remote = registry.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
remote.Init(sidebar.db); // this will throw if it's already been opened and registered.
// Add the necessary datasources to the select list
var select_list = document.getElementById('selected-panels');
select_list.database.AddDataSource(sidebar.datasource);
// read it in synchronously.
remote.Refresh(true);
}
catch (ex) {
// if we get here, then the RDF/XML has been opened and read
// once. We just need to grab the datasource.
registry = RDF.GetDataSource(sidebar.db);
}
// Root the customize dialog at the correct place.
select_list.setAttribute('ref', sidebar.resource);
// Create a 'container' wrapper around the sidebar.resources
// resource so we can use some utility routines that make access a
// bit easier.
var sb_datasource = Components.classes['component://netscape/rdf/container'].createInstance();
sb_datasource = sb_datasource.QueryInterface(Components.interfaces.nsIRDFContainer);
sb_datasource.Init(registry, RDF.GetResource(sidebar.resource));
// Now enumerate all of the flash datasources.
var enumerator = sb_datasource.GetElements();
var count = 0;
while (enumerator.HasMoreElements()) {
count = ++count;
var service = enumerator.GetNext();
service = service.QueryInterface(Components.interfaces.nsIRDFResource);
addOption(registry, service, false);
}
enableButtons();
}
function addOption(registry, service, selectIt) {
var option_title = getAttr(registry, service, 'title');
function addOption(registry, service, selectIt)
{
dump("Adding "+service.Value+"\n");
var option_title = getAttr(registry, service, 'title');
var option_customize = getAttr(registry, service, 'customize');
var option_content = getAttr(registry, service, 'content');
// Check to see if the panel already exists
var list = document.getElementById('selectList');
var list_length = list.childNodes.length;
for (var ii=0; ii < list_length; ii++) {
//dump(list.childNodes.item(ii).getAttribute('title') + '\n');
var tree = document.getElementById('selected-panels');
var treeroot = document.getElementById('selected-panels-root');
var content = list.childNodes.item(ii).getAttribute('content');
if (content == option_content) {
if (selectIt) {
list.selectedIndex = ii;
}
// Check to see if the panel already exists...
for (var ii = treeroot.firstChild; ii != null; ii = ii.nextSibling) {
if (ii.getAttribute('id') == service.Value) {
// we already had the panel installed
tree.selectItem(ii);
return;
}
}
}
var optionSelect = createOptionTitle(option_title);
var option = document.createElement('html:option');
option.setAttribute('title', option_title);
option.setAttribute('customize', option_customize);
option.setAttribute('content', option_content);
option.appendChild(optionSelect);
list.appendChild(option);
var item = document.createElement('treeitem');
var row = document.createElement('treerow');
var cell = document.createElement('treecell');
item.setAttribute('id', service.Value);
item.setAttribute('customize', option_customize);
item.setAttribute('content', option_content);
cell.setAttribute('value', option_title);
item.appendChild(row);
row.appendChild(cell);
treeroot.appendChild(item);
if (selectIt) {
list.selectedIndex = list_length;
dump("Selecting new item\n");
tree.selectItem(item)
}
}
@ -118,82 +117,93 @@ function selectChange() {
}
function moveUp() {
var list = document.getElementById('selectList');
var index = list.selectedIndex;
if (index > 0) {
var optionBefore = list.childNodes.item(index-1);
var selectedOption = list.childNodes.item(index);
list.remove(index);
list.insertBefore(selectedOption, optionBefore);
list.selectedIndex = index - 1;
enableButtons();
enableSave();
var tree = document.getElementById('selected-panels');
if (tree.selectedItems.length == 1) {
var selected = tree.selectedItems[0];
if (selected.previousSibling) {
selected.parentNode.insertBefore(selected, selected.previousSibling);
tree.selectItem(selected);
}
}
enableButtons();
}
function moveDown() {
var list = document.getElementById('selectList');
var index = list.selectedIndex;
if (index != -1 &&
index != list.options.length - 1) {
var selectedOption = list.childNodes.item(index);
var optionAfter = list.childNodes.item(index+1);
list.remove(index+1);
list.insertBefore(optionAfter, selectedOption);
list.selectedIndex = index + 1;
enableButtons();
enableSave();
var tree = document.getElementById('selected-panels');
if (tree.selectedItems.length == 1) {
var selected = tree.selectedItems[0];
if (selected.nextSibling) {
if (selected.nextSibling.nextSibling) {
selected.parentNode.insertBefore(selected, selected.nextSibling.nextSibling);
}
else {
selected.parentNode.appendChild(selected);
}
tree.selectItem(selected);
}
}
enableButtons();
}
function enableButtons() {
var up = document.getElementById('up');
var down = document.getElementById('down');
var list = document.getElementById('selectList');
var tree = document.getElementById('selected-panels');
var customize = document.getElementById('customize-button');
var index = list.selectedIndex;
var noneSelected = (index == -1);
var isFirst = (index == 0);
var isLast = (index == list.options.length - 1);
var remove = document.getElementById('remove-button');
var numSelected = tree.selectedItems.length;
var noneSelected, isFirst, isLast, selectedNode
if (numSelected > 0) {
selectedNode = tree.selectedItems[0]
isFirst = selectedNode == selectedNode.parentNode.firstChild
isLast = selectedNode == selectedNode.parentNode.lastChild
}
// up /\ button
if (noneSelected || isFirst) {
if (numSelected != 1 || isFirst) {
up.setAttribute('disabled', 'true');
} else {
up.setAttribute('disabled', '');
}
// down \/ button
if (noneSelected || isLast) {
if (numSelected != 1 || isLast) {
down.setAttribute('disabled', 'true');
} else {
down.setAttribute('disabled', '');
}
// "Customize..." button
var customizeURL = null;
if (!noneSelected) {
var option = list.childNodes.item(index);
customizeURL = option.getAttribute('customize');
if (selectedNode) {
customizeURL = selectedNode.getAttribute('customize');
}
if (customizeURL == 'null') {
if (customizeURL == null || customizeURL == '') {
customize.setAttribute('disabled','true');
} else {
customize.setAttribute('disabled','');
}
// "Remove" button
if (numSelected == 0) {
remove.setAttribute('disabled','true');
} else {
remove.setAttribute('disabled','');
}
}
function CustomizePanel()
{
var list = document.getElementById('selectList');
var index = list.selectedIndex;
var tree = document.getElementById('selected-panels');
var index = tree.selectedIndex;
if (index != -1) {
var title = list.childNodes.item(index).getAttribute('title');
var customize_URL = list.childNodes.item(index).getAttribute('customize');
var title = tree.childNodes.item(index).getAttribute('title');
var customize_URL = tree.childNodes.item(index).getAttribute('customize');
if (!title || !customize_URL) return;
var customize = window.open("chrome://sidebar/content/customize-panel.xul",
"PanelPreview", "chrome");
"_blank", "chrome");
customize.panel_name = title;
customize.panel_customize_URL = customize_URL;
@ -203,20 +213,23 @@ function CustomizePanel()
function RemovePanel()
{
var list = document.getElementById('selectList');
var index = list.selectedIndex;
var tree = document.getElementById('selected-panels');
if (index != -1) {
// XXX prompt user
list.options[index] = null;
// Clean up the selection
if (index == list.length) {
list.selectedIndex = index - 1;
} else {
list.selectedIndex = index;
var nextNode = null;
var numSelected = tree.selectedItems.length
while (tree.selectedItems.length > 0) {
var selectedNode = tree.selectedItems[0]
nextNode = selectedNode.nextSibling;
if (!nextNode) {
nextNode = selectedNode.previousSibling;
}
selectedNode.parentNode.removeChild(selectedNode)
}
if (nextNode) {
tree.selectItem(nextNode)
}
enableButtons();
enableSave();
}
@ -226,110 +239,62 @@ var FileURL = "file:////u/slamm/tt/sidebar-browser.rdf";
// var the "NC" namespace. Used to construct resources
function Save()
{
// Open the RDF file synchronously. This is tricky, because
// GetDataSource() will do it asynchronously. So, what we do is
// this. First try to manually construct the RDF/XML datasource
// and read it in. This might throw an exception if the datasource
// has already been read in once. In which case, we'll just get
// the existing datasource from the RDF service.
var datasource;
// Iterate through the 'selected-panels' tree to collect the panels
// that the user has chosen. We need to do this _before_ we remove
// the panels from the datasource, because the act of removing them
// from the datasource will change the tree!
var panels = new Array();
var root = document.getElementById('selected-panels-root');
for (var node = root.firstChild; node != null; node = node.nextSibling) {
panels[panels.length] = node.getAttribute('id');
}
try {
datasource = Components.classes["component://netscape/rdf/datasource?name=xml-datasource"].createInstance();
datasource = datasource.QueryInterface(Components.interfaces.nsIRDFXMLDataSource);
//datasource.Init(FileURL);
datasource.Init(sidebar.db);
datasource.Open(true);
//dump("datasource = " + datasource + ", opened for the first time.\n");
}
catch (ex) {
//datasource = RDF.GetDataSource(FileURL);
datasource = RDF.GetDataSource(sidebar.db);
//dump("datasource = " + datasource + ", using registered datasource.\n");
}
// Now remove all the current panels from the datasource.
// Create a "container" wrapper around the "NC:BrowserSidebarRoot"
// object. This makes it easier to manipulate the RDF:Seq correctly.
var container = Components.classes["component://netscape/rdf/container"].createInstance();
container = container.QueryInterface(Components.interfaces.nsIRDFContainer);
container.Init(sidebar.datasource, RDF.GetResource(sidebar.resource));
container.Init(datasource, RDF.GetResource(sidebar.resource));
//dump("initialized container " + container + " on " + sidebar.resource+"\n");
// Remove all the current panels
//
var enumerator = container.GetElements();
while (enumerator.HasMoreElements()) {
var service = enumerator.GetNext();
service = service.QueryInterface(Components.interfaces.nsIRDFResource);
container.RemoveElement(service, true);
for (var ii = container.GetCount(); ii >= 1; --ii) {
dump('removing panel ' + ii + '\n');
container.RemoveElementAt(ii, true);
}
// Add the new panel list
//
var count = container.GetCount();
//dump("container has " + count + " elements\n");
var list = document.getElementById('selectList');
var list_length = list.childNodes.length;
for (var ii=0; ii < list_length; ii++, count++) {
//dump(list.childNodes.item(ii).getAttribute('title') + '\n');
var title = list.childNodes.item(ii).getAttribute('title');
var content = list.childNodes.item(ii).getAttribute('content');
var customize = list.childNodes.item(ii).getAttribute('customize');
var element = RDF.GetResource(FileURL + "#" + count);
//dump(FileURL + "#" + count + "\n");
container.AppendElement(element);
//dump("appended " + element + " to the container\n");
// Now make some sidebar-ish assertions about it...
datasource.Assert(element,
RDF.GetResource(NC + "title"),
RDF.GetLiteral(title + ' ' + count),
true);
datasource.Assert(element,
RDF.GetResource(NC + "content"),
RDF.GetLiteral(content),
true);
datasource.Assert(element,
RDF.GetResource(NC + "customize"),
RDF.GetLiteral(customize),
true);
//dump("added assertions about " + element + "\n");
// Now iterate through the panels, and re-add them to the datasource
for (var ii = 0; ii < panels.length; ++ii) {
debug('adding ' + panels[ii] + '\n');
container.AppendElement(RDF.GetResource(panels[ii]));
}
// Now serialize it back to disk
datasource.Flush();
//dump("wrote " + FileURL + " back to disk.\n");
// Write the modified panels out.
sidebar.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
//window.close();
window.close();
}
function selected()
function otherPanelSelected()
{
var add_button = document.getElementById('add_button');
var preview_button = document.getElementById('preview_button');
var select_list = document.getElementsByAttribute("selected", "true");
if (select_list.length >= 1) {
add_button.setAttribute('disabled','');
preview_button.setAttribute('disabled','');
} else {
add_button.setAttribute('disabled','true');
preview_button.setAttribute('disabled','true');
}
var add_button = document.getElementById('add_button');
var preview_button = document.getElementById('preview_button');
var other_panels = document.getElementById('other-panels');
if (other_panels.selectedItems.length > 0) {
add_button.setAttribute('disabled','');
preview_button.setAttribute('disabled','');
}
else {
add_button.setAttribute('disabled','true');
preview_button.setAttribute('disabled','true');
}
}
function AddPanel()
{
var tree = document.getElementById('other-panels');
var database = tree.database;
var select_list = document.getElementsByAttribute("selected", "true");
var select_list = tree.selectedItems
var isFirstAddition = true;
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++) {
var node = select_list[nodeIndex];
@ -341,6 +306,7 @@ function AddPanel()
addOption(database, rdfNode, isFirstAddition);
isFirstAddition = false;
}
enableButtons();
enableSave();
}
@ -348,7 +314,7 @@ function PreviewPanel()
{
var tree = document.getElementById('other-panels');
var database = tree.database;
var select_list = document.getElementsByAttribute("selected", "true");
var select_list = tree.selectedItems
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++) {
var node = select_list[nodeIndex];
if (!node) break;
@ -362,11 +328,10 @@ function PreviewPanel()
if (!preview_URL || !preview_name) break;
var preview = window.open("chrome://sidebar/content/preview.xul",
"PanelPreview", "chrome");
"_blank", "chrome");
preview.panel_name = preview_name;
preview.panel_URL = preview_URL;
}
enableSave();
}
function enableSave() {

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

@ -24,14 +24,13 @@
<window
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Init();">
<html:script src="chrome://sidebar/content/customize.js" />
<box align="vertical" flex="100%" id="main-box">
onload="Init();"
id="main-box"
align="vertical">
<!-- Dialog title -->
<html:script src="chrome://sidebar/content/customize.js" />
<html:div class="title">
&sidebar.customize.title.label;
</html:div>
@ -40,83 +39,111 @@
<html:hr />
</html:div>
<html:div class="subtitle">
&sidebar.customize.current.label;
</html:div>
<!-- The two-pane -->
<box align="horizontal">
<box align="horizontal" class="box-group">
<!-- All of the panels that are available -->
<box align="vertical" flex="1*">
<box align="vertical">
<spring flex="50%"/>
<titledbutton onclick="moveUp();" id="up" class="borderless up" />
<titledbutton onclick="moveDown();" id="down" class="borderless down" />
<spring flex="50%"/>
</box>
<html:div class="subtitle">
&sidebar.customize.additional.label;
</html:div>
<html:form>
<html:select id="selectList" size="10" onclick="selectChange();">
</html:select>
</html:form>
<html:div style="width:15em;height:15em" flex="1*">
<tree id="other-panels" size="10" onclick="otherPanelSelected()"
datasources="chrome://sidebar/content/local-panels.rdf
chrome://sidebar/content/remote-panels.rdf"
ref="urn:sidebar:master-panel-list"
style="width:100%;height:100%">
<template>
<treechildren>
<treeitem uri="rdf:*"
title="rdf:http://home.netscape.com/NC-rdf#title"
content="rdf:http://home.netscape.com/NC-rdf#content">
<treerow>
<treecell value="rdf:http://home.netscape.com/NC-rdf#title"/>
</treerow>
</treeitem>
</treechildren>
</template>
</tree>
</html:div>
<box align="vertical" class="button-group" flex="100%">
<titledbutton id="customize-button" onclick="CustomizePanel();"
value="&sidebar.customize.customize.label;" />
<titledbutton onclick="RemovePanel()"
value="&sidebar.customize.remove.label;" />
</box>
<!-- xxxslamm Need to add descriptive panel text here -->
<box align="horizontal" class="button-group">
<titledbutton id="add_button" onclick="AddPanel()"
value="&sidebar.customize.add.label;"
disabled="true"/>
<titledbutton id="preview_button" onclick="PreviewPanel()"
value="&sidebar.customize.preview.label;"
disabled="true"/>
</box>
</box>
<!-- The panels that the user currently has chosen -->
<box align="vertical" flex="1*">
<html:div class="subtitle">
&sidebar.customize.current.label;
</html:div>
<box align="horizontal" class="box-group" flex="1*">
<html:div style="width:15em;height:15em" flex="1*">
<tree id="selected-panels" onclick="selectChange();"
datasources="chrome://sidebar/content/local-panels.rdf
chrome://sidebar/content/remote-panels.rdf"
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">
<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="selected-panels-root"/>
</tree>
</html:div>
<!-- The 'reorder' buttons -->
<box align="vertical">
<spring flex="50%"/>
<titledbutton onclick="moveUp();" id="up" class="borderless up" />
<html:div>
&sidebar.customize.reorder.label;
</html:div>
<titledbutton onclick="moveDown();" id="down"
class="borderless down" />
<spring flex="50%"/>
</box>
</box>
<box align="horizontal" class="button-group" flex="100%">
<titledbutton id="customize-button" onclick="CustomizePanel();"
value="&sidebar.customize.customize.label;" />
<titledbutton id="remove-button" onclick="RemovePanel()"
value="&sidebar.customize.remove.label;" />
</box>
</box>
</box>
<html:div>
<html:hr />
</html:div>
<html:div class="subtitle">
&sidebar.customize.additional.label;
</html:div>
<box align="horizontal" class="box-group">
<!-- datasources="chrome://sidebar/content/sidebar-registry.rdf"-->
<tree id="other-panels" flex='100%'
datasources="resource:/chrome/sidebar/content/default/sidebar-registry.rdf"
onclick="selected()"
ref="NC:SidebarRoot" >
<!-- The template we'll use to build rows in the content model. -->
<template>
<rule>
<treechildren>
<treeitem uri="..." type="rdf:http://home.netscape.com/NC-rdf#type">
<treerow>
<treecell>
<treeindentation />
<titledbutton align="right"
value="rdf:http://home.netscape.com/NC-rdf#title" />
</treecell>
</treerow>
</treeitem>
</treechildren>
</rule>
</template>
</tree>
<box align="vertical" class="button-group">
<titledbutton id="add_button" onclick="AddPanel()"
value="&sidebar.customize.add.label;"
disabled="true"/>
<titledbutton id="preview_button" onclick="PreviewPanel()"
value="&sidebar.customize.preview.label;"
disabled="true"/>
</box>
</box>
<html:div>
<html:hr />
</html:div>
<!-- The 'Save' and 'Cancel' buttons -->
<box align="horizontal">
<spring flex="48%"/>
<titledbutton onclick="window.close()"
@ -127,7 +154,5 @@
disabled="true"/>
<spring flex="48%"/>
</box>
</box>
</window>

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

@ -36,11 +36,13 @@
&sidebar.preview.title.label;
</html:div>
<html:hr/>
<html:div>
<html:hr />
</html:div>
<box align="horizontal" class="panelbar">
<html:img src="chrome://sidebar/skin/corner.gif" />
<titledbutton id="paneltitle" class="borderless paneltitle" />
<titledbutton id="paneltitle" class="plain paneltitle" />
<spring flex="100%" />
</box>

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

@ -73,11 +73,15 @@ splitter.panel-bar titledbutton
splitter > titledbutton.show-hide
{
padding: 0px;
margin: 0px;
list-style-image:url(chrome://sidebar/skin/panel-collapse.gif);
}
splitter[state="collapsed"] > titledbutton.show-hide
{
padding: 0px;
margin: 0px;
list-style-image:url(chrome://sidebar/skin/panel-expand.gif);
}

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

@ -10,22 +10,13 @@
* the License for the specific language governing rights and
* limitations under the License.
*
* The Original Code is ______________________________________.
* The Initial Developer of the Original Code is ________________________.
* Portions created by ______________________ are Copyright (C) ______
* _______________________. All Rights Reserved.
* Contributor(s): ______________________________________.
*
* Alternatively, the contents of this file may be used under the terms
* of the _____ license (the ?[___] License?), in which case the
* provisions of [______] License are applicable instead of those above.
* If you wish to allow use of your version of this file only under the
* terms of the [____] License and not to allow others to use your
* version of this file under the MPL, indicate your decision by
* deleting the provisions above and replace them with the notice and
* other provisions required by the [___] License. If you do not delete
* the provisions above, a recipient may use your version of this file
* under either the MPL or the [___] License.
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*/
// the rdf service
@ -34,47 +25,39 @@ var RDF = Components.classes[rdf_uri].getService()
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService)
// the default sidebar:
var defaultsidebar = new Object
defaultsidebar.db = 'chrome://sidebar/content/sidebar.rdf'
defaultsidebar.resource = 'NC:SidebarRoot'
var sidebar = new Object;
// the current sidebar:
var sidebar = null
function sidebarOverlayInit(usersidebar)
function debug(msg)
{
// load up user-specified sidebar
if (usersidebar) {
//dump("usersidebar = " + usersidebar + "\n")
//dump("usersidebar.resource = " + usersidebar.resource + "\n")
//dump("usersidebar.db = " + usersidebar.db + "\n")
sidebar = usersidebar
}
else {
try
{
var profileInterface = Components.interfaces.nsIProfile
var profileURI = 'component://netscape/profile/manager'
var profileService = Components.classes[profileURI].getService()
profileService = profileService.QueryInterface(profileInterface)
var sidebar_url = profileService.getCurrentProfileDirFromJS()
sidebar_url.URLString += "sidebar.rdf"
// uncomment for noise
//dump(msg);
}
if (!(sidebar_url.exists())) {
//dump("using " + defaultsidebar.db + " because " +
//sidebar_url.URLString + " does not exist\n")
} else {
//dump("sidebar url is " + sidebar_url.URLString + "\n")
defaultsidebar.db = sidebar_url.URLString
}
}
catch (ex)
{
//dump("failed to get sidebar url, using default\n")
}
sidebar = defaultsidebar
function sidebarOverlayInit()
{
// Look in the profile directory to find 'panels.rdf', which is the
// database of the user's currently selected panels.
var profileInterface = Components.interfaces.nsIProfile;
var profileURI = 'component://netscape/profile/manager';
var profileService = Components.classes[profileURI].getService();
profileService = profileService.QueryInterface(profileInterface);
var sidebar_url = profileService.getCurrentProfileDirFromJS();
sidebar_url.URLString += "panels.rdf";
if (sidebar_url.exists()) {
debug("sidebar url is " + sidebar_url.URLString + "\n");
sidebar.db = sidebar_url.URLString;
}
else {
// XXX What we should _really_ do here is copy the default panels
// into the profile directory and then try again.
sidebar.db = 'chrome://sidebar/content/default-panels.rdf'
debug("using " + sidebar.db + " because " + sidebar_url.URLString + " does not exist\n");
}
sidebar.resource = 'urn:sidebar:current-panel-list';
// Initialize the display
var sidebar_element = document.getElementById('sidebar-box')
var sidebar_menuitem = document.getElementById('menu_sidebar')
if (sidebar_element.getAttribute('hidden') == 'true') {
@ -82,130 +65,20 @@ function sidebarOverlayInit(usersidebar)
sidebar_menuitem.setAttribute('checked', 'false')
return
}
sidebar_menuitem.setAttribute('checked', 'true')
//dump("sidebar = " + sidebar + "\n")
//dump("sidebar.resource = " + sidebar.resource + "\n")
//dump("sidebar.db = " + sidebar.db + "\n")
//var panelsbox = document.getElementById('sidebar-panels')
//panelsbox.setAttribute('datasources',sidebar.db);
//panelsbox.setAttribute('datasource',sidebar.db);
//return;
debug("sidebar = " + sidebar + "\n");
debug("sidebar.resource = " + sidebar.resource + "\n");
debug("sidebar.db = " + sidebar.db + "\n");
var registry
try {
// First try to construct a new one and load it
// synchronously. nsIRDFService::GetDataSource() loads RDF/XML
// asynchronously by default.
var xmlsrc = 'component://netscape/rdf/datasource?name=xml-datasource'
registry = Components.classes[xmlsrc].createInstance()
registry = registry.QueryInterface(Components.interfaces.nsIRDFDataSource)
// Add the user's current panel choices to the template builder,
// which will aggregate it with the other datasources that describe
// the individual panel's title, customize URL, and content URL.
var panels = document.getElementById('sidebar-panels');
panels.database.AddDataSource(RDF.GetDataSource(sidebar.db));
var remote = Components.interfaces.nsIRDFRemoteDataSource
remote = registry.QueryInterface(remote)
// this will throw if it's already been opened and registered.
remote.Init(sidebar.db)
// XXX This is a hack to force re-display
panels.setAttribute('ref', 'urn:sidebar:current-panel-list');
// read it in synchronously.
remote.Refresh(true)
}
catch (ex) {
// if we get here, then the RDF/XML has been opened and read
// once. We just need to grab the datasource.
registry = RDF.GetDataSource(sidebar.db)
}
// Create a 'container' wrapper around the sidebar.resources
// resource so we can use some utility routines that make access a
// bit easier.
var sb_datasource = Components.classes['component://netscape/rdf/container']
var container = Components.interfaces.nsIRDFContainer
try {
sb_datasource = sb_datasource.createInstance()
sb_datasource = sb_datasource.QueryInterface(container)
sb_datasource.Init(registry, RDF.GetResource(sidebar.resource))
}
catch (ex) {
dump("failed to init sb_datasource\n")
}
var mypanelsbox = document.getElementById('sidebar-panels')
if (!mypanelsbox) {
dump("Unable to find sidebar panels\n")
return;
}
// Now enumerate all of the datasources.
var enumerator = null
try {
enumerator = sb_datasource.GetElements()
}
catch (ex) {
dump("sb_datasource has no elements.\n")
}
if (!enumerator) return
while (enumerator.HasMoreElements()) {
var service = enumerator.GetNext()
service = service.QueryInterface(Components.interfaces.nsIRDFResource)
var is_last = !enumerator.HasMoreElements()
var new_panel = sidebarAddPanel(mypanelsbox, registry, service, is_last)
}
}
function sidebarAddPanel(parent, registry, service, is_last) {
var panel_title = sidebarGetAttr(registry, service, 'title')
var panel_content = sidebarGetAttr(registry, service, 'content')
var panel_height = sidebarGetAttr(registry, service, 'height')
var iframe = document.createElement('html:iframe')
iframe.setAttribute('src', panel_content)
if (panel_height) iframe.setAttribute('height', panel_height)
iframe.setAttribute('class','panel-frame')
sidebarAddPanelTitle(parent, panel_title, is_last)
if (parent) parent.appendChild(iframe)
}
function sidebarAddPanelTitle(parent, titletext, is_last)
{
var splitter = document.createElement('splitter')
splitter.setAttribute('class', 'panel-bar')
splitter.setAttribute('resizeafter', 'grow')
splitter.setAttribute('collapse', 'after')
splitter.setAttribute('onclick', 'sidebarSavePanelState(this)')
var label = document.createElement('html:div')
var text = document.createTextNode(titletext)
label.appendChild(text)
label.setAttribute('class','panel-bar')
var spring = document.createElement('spring')
spring.setAttribute('flex','100%')
var titledbutton = document.createElement('titledbutton')
titledbutton.setAttribute('class', 'borderless show-hide')
titledbutton.setAttribute('onclick','sidebarOpenClosePanel(this.parentNode)')
splitter.appendChild(label)
splitter.appendChild(spring)
splitter.appendChild(titledbutton)
if (parent) parent.appendChild(splitter)
}
function sidebarGetAttr(registry,service,attr_name) {
var attr = registry.GetTarget(service,
RDF.GetResource('http://home.netscape.com/NC-rdf#' + attr_name),
true)
if (attr)
attr = attr.QueryInterface(
Components.interfaces.nsIRDFLiteral)
if (attr)
attr = attr.Value
return attr
}
function sidebarOpenClosePanel(splitter) {
@ -224,19 +97,13 @@ function sidebarOpenClosePanel(splitter) {
}
function sidebarReload() {
var panelsparent = document.getElementById('sidebar-panels')
var panel = panelsparent.firstChild
while (panel) {
var next = panel.nextSibling
panelsparent.removeChild(panel)
panel = next
}
sidebarOverlayInit(sidebar)
}
function sidebarCustomize() {
var newWin = window.openDialog('chrome://sidebar/content/customize.xul','New','chrome', sidebar.db, sidebar.resource)
var newWin = window.openDialog('chrome://sidebar/content/customize.xul',
'New','chrome',
sidebar.db, sidebar.resource)
return newWin
}
@ -246,40 +113,26 @@ function sidebarShowHide() {
var is_hidden = sidebar.getAttribute('hidden')
if (is_hidden && is_hidden == "true") {
//dump("Showing the sidebar\n")
debug("Showing the sidebar\n")
sidebar.setAttribute('hidden','')
sidebar_splitter.setAttribute('hidden','')
sidebarOverlayInit()
} else {
//dump("Hiding the sidebar\n")
debug("Hiding the sidebar\n")
sidebar.setAttribute('hidden','true')
sidebar_splitter.setAttribute('hidden','true')
}
}
function sidebarSavePanelState(splitter) {
}
function sidebarSaveState(splitter) {
/* Do nothing for now */
return;
if (splitter.getAttribute('state') == "collapse") {
dump("Expanding the sidebar\n")
} else {
dump("Collapsing the sidebar\n")
}
dumpStats()
}
function dumpAttributes(node) {
var attributes = node.attributes
if (!attributes || attributes.length == 0) {
dump("no attributes")
debug("no attributes")
}
for (var ii=0; ii < attributes.length; ii++) {
var attr = attributes.item(ii)
dump("attr "+ii+": "+ attr.name +"="+attr.value+"\n")
debug("attr "+ii+": "+ attr.name +"="+attr.value+"\n")
}
}
@ -292,24 +145,24 @@ function dumpStats() {
if (visibility) {
visibility = visibility[1]
}
dump("sidebar-box.style="+style+"\n")
dump("sidebar-box.visibility="+visibility+"\n")
dump('sidebar-box.width='+box.getAttribute('width')+'\n')
dump('sidebar-box attrs\n---------------------\n')
debug("sidebar-box.style="+style+"\n")
debug("sidebar-box.visibility="+visibility+"\n")
debug('sidebar-box.width='+box.getAttribute('width')+'\n')
debug('sidebar-box attrs\n---------------------\n')
dumpAttributes(box)
dump('sidebar-splitter attrs\n--------------------------\n')
debug('sidebar-splitter attrs\n--------------------------\n')
dumpAttributes(splitter)
}
function dumpTree(node, depth) {
var indent = "| | | | | | | | | | | | | | | | | | | | | | | | | | | | | + "
var kids = node.childNodes
dump(indent.substr(indent.length - depth*2))
debug(indent.substr(indent.length - depth*2))
// Print your favorite attributes here
dump(node.nodeName)
dump(" "+node.getAttribute('id'))
dump("\n")
debug(node.nodeName)
debug(" "+node.getAttribute('id'))
debug("\n")
for (var ii=0; ii < kids.length; ii++) {
dumpTree(kids[ii], depth + 1)

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

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0"?> <!-- -*- Mode: SGML; indent-tabs-mode: nil -*- -->
<!DOCTYPE window SYSTEM "chrome://sidebar/locale/sidebarOverlay.dtd">
@ -8,7 +8,7 @@
<!-- Overlay the sidebar panels -->
<box id="sidebar-box" align="vertical" persist="hidden width">
<splitter id="title-box" collapse="after"
<splitter id="title-box" collapse="after" persist="state"
onclick="sidebarOpenClosePanel(this)">
<html:div class="panel-bar">
&sidebar.panels.label;
@ -19,31 +19,27 @@
onclick="sidebarCustomize();" />
</splitter>
<box id="sidebar-panels" align="vertical" flex="100%">
<!--
datasources="chrome://sidebar/content/sidebar.rdf"
ref="NC:SidebarRoot">
<box id="sidebar-panels" align="vertical" flex="100%"
datasources="chrome://sidebar/content/local-panels.rdf
chrome://sidebar/content/remote-panels.rdf"
ref="urn:sidebar:current-panel-list">
<template>
<rule>
<box uri="rdf:*" align="vertical">
<splitter class="panel-bar"
collapse="after" resizeafter="grow"
onclick="sidebarSavePanelState(this)">
<splitter class="panel-bar" uri="rdf:*"
collapse="after" resizeafter="grow" persist="state">
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#title"
class="panel-bar"/>
class="panel-bar plain"/>
<spring flex="100%"/>
<titledbutton class="borderless show-hide"
onclick="sidebarOpenClosePanel(this.parentNode)"/>
</splitter>
<html:iframe class="panel-frame"
<html:iframe class="panel-frame" uri="rdf:*" persist="height"
src="rdf:http://home.netscape.com/NC-rdf#content"/>
</box>
</rule>
</template>
-->
</box>
<splitter id="alerts-splitter" class="panel-bar"
<splitter id="alerts-splitter" class="panel-bar" persist="state"
collapse="after" chromeclass="extrachrome"
onclick="sidebarOpenClosePanel(this)">
<html:div class="panel-bar">
@ -51,7 +47,8 @@
</html:div>
</splitter>
<box id="alerts-panel" align="vertical" chromeclass="extrachrome">
<box id="alerts-panel" align="vertical" chromeclass="extrachrome"
persist="height">
<html:div flex="1">
<tree id="flash-tree"
ref="NC:FlashRoot"
@ -76,7 +73,7 @@
<!-- Some splitter attritutes -->
<splitter id="sidebar-splitter" collapse="before" persist="state hidden"
chromeclass="extrachrome" onclick="sidebarSaveState(this)"/>
chromeclass="extrachrome" />
<!-- Scripts go last, because they peek at state to tweak menus -->
<html:script language="JavaScript"

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

@ -3,8 +3,9 @@
<!-- LOCALIZATION NOTE sidebar.customize.title.label: Do NOT localize the term "Sidebar" -->
<!ENTITY sidebar.customize.title.label "Customize Sidebar">
<!ENTITY sidebar.customize.current.label "Panels currently in Sidebar">
<!ENTITY sidebar.customize.reorder.label "Reorder">
<!ENTITY sidebar.customize.customize.label "Customize Panel...">
<!ENTITY sidebar.customize.remove.label "Remove Panel">
<!ENTITY sidebar.customize.remove.label "Remove">
<!ENTITY sidebar.customize.additional.label "Add these Panels to your Sidebar">
<!ENTITY sidebar.customize.add.label "Add">
<!ENTITY sidebar.customize.preview.label "Preview...">

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

@ -9,7 +9,8 @@ flash.xul
preview.css
preview.js
preview.xul
sidebar-registry.rdf
sidebar.rdf
sidebarOverlay.js
sidebarOverlay.xul
local-panels.rdf
remote-panels.rdf
default-panels.rdf

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

@ -39,10 +39,11 @@ CHROME_CONTENT = \
preview.css \
preview.js \
preview.xul \
sidebar-registry.rdf \
sidebar.rdf \
sidebarOverlay.js \
sidebarOverlay.xul \
local-panels.rdf \
remote-panels.rdf \
default-panels.rdf \
$(NULL)
CHROME_SKIN = \

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

@ -32,7 +32,7 @@ div.title {
}
div.subtitle {
font: 4mm tahoma,arial,helvetica,sans-serif;
font: 3mm tahoma,arial,helvetica,sans-serif;
margin: 2px;
}
@ -43,31 +43,19 @@ box.button-group {
padding: 1mm;
}
#selectList {
width: 12em;
}
#tree {
width: 17em;
}
/* These rules apply appropriate images to the 'reorder' buttons */
titledbutton.up {
list-style-image:url(chrome://sidebar/skin/list-up.gif);
list-style-image:url("chrome://sidebar/skin/list-up.gif");
}
titledbutton.up[disabled="true"] {
list-style-image:url(chrome://sidebar/skin/list-up-dis.gif);
list-style-image:url("chrome://sidebar/skin/list-up-dis.gif");
}
titledbutton.down {
list-style-image:url(chrome://sidebar/skin/list-down.gif);
list-style-image:url("chrome://sidebar/skin/list-down.gif");
}
titledbutton.down[disabled="true"] {
list-style-image:url(chrome://sidebar/skin/list-down-dis.gif);
}
tree#other-panels {
width: 15em;
height: 15em;
list-style-image:url("chrome://sidebar/skin/list-down-dis.gif");
}

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

@ -1,95 +1,94 @@
// -*- Mode: Java -*-
/* -*- Mode: Java; tab-width: 4; insert-tabs-mode: nil; c-basic-offset: 2 -*-
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
*/
// the rdf service
var RDF;
var RDF = 'component://netscape/rdf/rdf-service'
RDF = Components.classes[RDF].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
var NC = "http://home.netscape.com/NC-rdf#";
var sidebar;
var sidebar = new Object;
function debug(msg)
{
//dump(msg);
}
function Init()
{
RDF=Components.classes['component://netscape/rdf/rdf-service'].getService();
RDF=RDF.QueryInterface(Components.interfaces.nsIRDFService);
sidebar = new Object;
sidebar.db = window.arguments[0];
sidebar.resource = window.arguments[1];
debug("sidebar.db = " + sidebar.db + "\n");
debug("sidebar.resource = " + sidebar.resource + "\n");
var registry;
try {
// First try to construct a new one and load it
// synchronously. nsIRDFService::GetDataSource() loads RDF/XML
// asynchronously by default.
registry = Components.classes['component://netscape/rdf/datasource?name=xml-datasource'].createInstance();
registry = registry.QueryInterface(Components.interfaces.nsIRDFDataSource);
// This will load the datasource, if it isn't already.
sidebar.datasource = RDF.GetDataSource(sidebar.db);
var remote = registry.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
remote.Init(sidebar.db); // this will throw if it's already been opened and registered.
// Add the necessary datasources to the select list
var select_list = document.getElementById('selected-panels');
select_list.database.AddDataSource(sidebar.datasource);
// read it in synchronously.
remote.Refresh(true);
}
catch (ex) {
// if we get here, then the RDF/XML has been opened and read
// once. We just need to grab the datasource.
registry = RDF.GetDataSource(sidebar.db);
}
// Root the customize dialog at the correct place.
select_list.setAttribute('ref', sidebar.resource);
// Create a 'container' wrapper around the sidebar.resources
// resource so we can use some utility routines that make access a
// bit easier.
var sb_datasource = Components.classes['component://netscape/rdf/container'].createInstance();
sb_datasource = sb_datasource.QueryInterface(Components.interfaces.nsIRDFContainer);
sb_datasource.Init(registry, RDF.GetResource(sidebar.resource));
// Now enumerate all of the flash datasources.
var enumerator = sb_datasource.GetElements();
var count = 0;
while (enumerator.HasMoreElements()) {
count = ++count;
var service = enumerator.GetNext();
service = service.QueryInterface(Components.interfaces.nsIRDFResource);
addOption(registry, service, false);
}
enableButtons();
}
function addOption(registry, service, selectIt) {
var option_title = getAttr(registry, service, 'title');
function addOption(registry, service, selectIt)
{
dump("Adding "+service.Value+"\n");
var option_title = getAttr(registry, service, 'title');
var option_customize = getAttr(registry, service, 'customize');
var option_content = getAttr(registry, service, 'content');
// Check to see if the panel already exists
var list = document.getElementById('selectList');
var list_length = list.childNodes.length;
for (var ii=0; ii < list_length; ii++) {
//dump(list.childNodes.item(ii).getAttribute('title') + '\n');
var tree = document.getElementById('selected-panels');
var treeroot = document.getElementById('selected-panels-root');
var content = list.childNodes.item(ii).getAttribute('content');
if (content == option_content) {
if (selectIt) {
list.selectedIndex = ii;
}
// Check to see if the panel already exists...
for (var ii = treeroot.firstChild; ii != null; ii = ii.nextSibling) {
if (ii.getAttribute('id') == service.Value) {
// we already had the panel installed
tree.selectItem(ii);
return;
}
}
}
var optionSelect = createOptionTitle(option_title);
var option = document.createElement('html:option');
option.setAttribute('title', option_title);
option.setAttribute('customize', option_customize);
option.setAttribute('content', option_content);
option.appendChild(optionSelect);
list.appendChild(option);
var item = document.createElement('treeitem');
var row = document.createElement('treerow');
var cell = document.createElement('treecell');
item.setAttribute('id', service.Value);
item.setAttribute('customize', option_customize);
item.setAttribute('content', option_content);
cell.setAttribute('value', option_title);
item.appendChild(row);
row.appendChild(cell);
treeroot.appendChild(item);
if (selectIt) {
list.selectedIndex = list_length;
dump("Selecting new item\n");
tree.selectItem(item)
}
}
@ -118,82 +117,93 @@ function selectChange() {
}
function moveUp() {
var list = document.getElementById('selectList');
var index = list.selectedIndex;
if (index > 0) {
var optionBefore = list.childNodes.item(index-1);
var selectedOption = list.childNodes.item(index);
list.remove(index);
list.insertBefore(selectedOption, optionBefore);
list.selectedIndex = index - 1;
enableButtons();
enableSave();
var tree = document.getElementById('selected-panels');
if (tree.selectedItems.length == 1) {
var selected = tree.selectedItems[0];
if (selected.previousSibling) {
selected.parentNode.insertBefore(selected, selected.previousSibling);
tree.selectItem(selected);
}
}
enableButtons();
}
function moveDown() {
var list = document.getElementById('selectList');
var index = list.selectedIndex;
if (index != -1 &&
index != list.options.length - 1) {
var selectedOption = list.childNodes.item(index);
var optionAfter = list.childNodes.item(index+1);
list.remove(index+1);
list.insertBefore(optionAfter, selectedOption);
list.selectedIndex = index + 1;
enableButtons();
enableSave();
var tree = document.getElementById('selected-panels');
if (tree.selectedItems.length == 1) {
var selected = tree.selectedItems[0];
if (selected.nextSibling) {
if (selected.nextSibling.nextSibling) {
selected.parentNode.insertBefore(selected, selected.nextSibling.nextSibling);
}
else {
selected.parentNode.appendChild(selected);
}
tree.selectItem(selected);
}
}
enableButtons();
}
function enableButtons() {
var up = document.getElementById('up');
var down = document.getElementById('down');
var list = document.getElementById('selectList');
var tree = document.getElementById('selected-panels');
var customize = document.getElementById('customize-button');
var index = list.selectedIndex;
var noneSelected = (index == -1);
var isFirst = (index == 0);
var isLast = (index == list.options.length - 1);
var remove = document.getElementById('remove-button');
var numSelected = tree.selectedItems.length;
var noneSelected, isFirst, isLast, selectedNode
if (numSelected > 0) {
selectedNode = tree.selectedItems[0]
isFirst = selectedNode == selectedNode.parentNode.firstChild
isLast = selectedNode == selectedNode.parentNode.lastChild
}
// up /\ button
if (noneSelected || isFirst) {
if (numSelected != 1 || isFirst) {
up.setAttribute('disabled', 'true');
} else {
up.setAttribute('disabled', '');
}
// down \/ button
if (noneSelected || isLast) {
if (numSelected != 1 || isLast) {
down.setAttribute('disabled', 'true');
} else {
down.setAttribute('disabled', '');
}
// "Customize..." button
var customizeURL = null;
if (!noneSelected) {
var option = list.childNodes.item(index);
customizeURL = option.getAttribute('customize');
if (selectedNode) {
customizeURL = selectedNode.getAttribute('customize');
}
if (customizeURL == 'null') {
if (customizeURL == null || customizeURL == '') {
customize.setAttribute('disabled','true');
} else {
customize.setAttribute('disabled','');
}
// "Remove" button
if (numSelected == 0) {
remove.setAttribute('disabled','true');
} else {
remove.setAttribute('disabled','');
}
}
function CustomizePanel()
{
var list = document.getElementById('selectList');
var index = list.selectedIndex;
var tree = document.getElementById('selected-panels');
var index = tree.selectedIndex;
if (index != -1) {
var title = list.childNodes.item(index).getAttribute('title');
var customize_URL = list.childNodes.item(index).getAttribute('customize');
var title = tree.childNodes.item(index).getAttribute('title');
var customize_URL = tree.childNodes.item(index).getAttribute('customize');
if (!title || !customize_URL) return;
var customize = window.open("chrome://sidebar/content/customize-panel.xul",
"PanelPreview", "chrome");
"_blank", "chrome");
customize.panel_name = title;
customize.panel_customize_URL = customize_URL;
@ -203,20 +213,23 @@ function CustomizePanel()
function RemovePanel()
{
var list = document.getElementById('selectList');
var index = list.selectedIndex;
var tree = document.getElementById('selected-panels');
if (index != -1) {
// XXX prompt user
list.options[index] = null;
// Clean up the selection
if (index == list.length) {
list.selectedIndex = index - 1;
} else {
list.selectedIndex = index;
var nextNode = null;
var numSelected = tree.selectedItems.length
while (tree.selectedItems.length > 0) {
var selectedNode = tree.selectedItems[0]
nextNode = selectedNode.nextSibling;
if (!nextNode) {
nextNode = selectedNode.previousSibling;
}
selectedNode.parentNode.removeChild(selectedNode)
}
if (nextNode) {
tree.selectItem(nextNode)
}
enableButtons();
enableSave();
}
@ -226,110 +239,62 @@ var FileURL = "file:////u/slamm/tt/sidebar-browser.rdf";
// var the "NC" namespace. Used to construct resources
function Save()
{
// Open the RDF file synchronously. This is tricky, because
// GetDataSource() will do it asynchronously. So, what we do is
// this. First try to manually construct the RDF/XML datasource
// and read it in. This might throw an exception if the datasource
// has already been read in once. In which case, we'll just get
// the existing datasource from the RDF service.
var datasource;
// Iterate through the 'selected-panels' tree to collect the panels
// that the user has chosen. We need to do this _before_ we remove
// the panels from the datasource, because the act of removing them
// from the datasource will change the tree!
var panels = new Array();
var root = document.getElementById('selected-panels-root');
for (var node = root.firstChild; node != null; node = node.nextSibling) {
panels[panels.length] = node.getAttribute('id');
}
try {
datasource = Components.classes["component://netscape/rdf/datasource?name=xml-datasource"].createInstance();
datasource = datasource.QueryInterface(Components.interfaces.nsIRDFXMLDataSource);
//datasource.Init(FileURL);
datasource.Init(sidebar.db);
datasource.Open(true);
//dump("datasource = " + datasource + ", opened for the first time.\n");
}
catch (ex) {
//datasource = RDF.GetDataSource(FileURL);
datasource = RDF.GetDataSource(sidebar.db);
//dump("datasource = " + datasource + ", using registered datasource.\n");
}
// Now remove all the current panels from the datasource.
// Create a "container" wrapper around the "NC:BrowserSidebarRoot"
// object. This makes it easier to manipulate the RDF:Seq correctly.
var container = Components.classes["component://netscape/rdf/container"].createInstance();
container = container.QueryInterface(Components.interfaces.nsIRDFContainer);
container.Init(sidebar.datasource, RDF.GetResource(sidebar.resource));
container.Init(datasource, RDF.GetResource(sidebar.resource));
//dump("initialized container " + container + " on " + sidebar.resource+"\n");
// Remove all the current panels
//
var enumerator = container.GetElements();
while (enumerator.HasMoreElements()) {
var service = enumerator.GetNext();
service = service.QueryInterface(Components.interfaces.nsIRDFResource);
container.RemoveElement(service, true);
for (var ii = container.GetCount(); ii >= 1; --ii) {
dump('removing panel ' + ii + '\n');
container.RemoveElementAt(ii, true);
}
// Add the new panel list
//
var count = container.GetCount();
//dump("container has " + count + " elements\n");
var list = document.getElementById('selectList');
var list_length = list.childNodes.length;
for (var ii=0; ii < list_length; ii++, count++) {
//dump(list.childNodes.item(ii).getAttribute('title') + '\n');
var title = list.childNodes.item(ii).getAttribute('title');
var content = list.childNodes.item(ii).getAttribute('content');
var customize = list.childNodes.item(ii).getAttribute('customize');
var element = RDF.GetResource(FileURL + "#" + count);
//dump(FileURL + "#" + count + "\n");
container.AppendElement(element);
//dump("appended " + element + " to the container\n");
// Now make some sidebar-ish assertions about it...
datasource.Assert(element,
RDF.GetResource(NC + "title"),
RDF.GetLiteral(title + ' ' + count),
true);
datasource.Assert(element,
RDF.GetResource(NC + "content"),
RDF.GetLiteral(content),
true);
datasource.Assert(element,
RDF.GetResource(NC + "customize"),
RDF.GetLiteral(customize),
true);
//dump("added assertions about " + element + "\n");
// Now iterate through the panels, and re-add them to the datasource
for (var ii = 0; ii < panels.length; ++ii) {
debug('adding ' + panels[ii] + '\n');
container.AppendElement(RDF.GetResource(panels[ii]));
}
// Now serialize it back to disk
datasource.Flush();
//dump("wrote " + FileURL + " back to disk.\n");
// Write the modified panels out.
sidebar.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
//window.close();
window.close();
}
function selected()
function otherPanelSelected()
{
var add_button = document.getElementById('add_button');
var preview_button = document.getElementById('preview_button');
var select_list = document.getElementsByAttribute("selected", "true");
if (select_list.length >= 1) {
add_button.setAttribute('disabled','');
preview_button.setAttribute('disabled','');
} else {
add_button.setAttribute('disabled','true');
preview_button.setAttribute('disabled','true');
}
var add_button = document.getElementById('add_button');
var preview_button = document.getElementById('preview_button');
var other_panels = document.getElementById('other-panels');
if (other_panels.selectedItems.length > 0) {
add_button.setAttribute('disabled','');
preview_button.setAttribute('disabled','');
}
else {
add_button.setAttribute('disabled','true');
preview_button.setAttribute('disabled','true');
}
}
function AddPanel()
{
var tree = document.getElementById('other-panels');
var database = tree.database;
var select_list = document.getElementsByAttribute("selected", "true");
var select_list = tree.selectedItems
var isFirstAddition = true;
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++) {
var node = select_list[nodeIndex];
@ -341,6 +306,7 @@ function AddPanel()
addOption(database, rdfNode, isFirstAddition);
isFirstAddition = false;
}
enableButtons();
enableSave();
}
@ -348,7 +314,7 @@ function PreviewPanel()
{
var tree = document.getElementById('other-panels');
var database = tree.database;
var select_list = document.getElementsByAttribute("selected", "true");
var select_list = tree.selectedItems
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++) {
var node = select_list[nodeIndex];
if (!node) break;
@ -362,11 +328,10 @@ function PreviewPanel()
if (!preview_URL || !preview_name) break;
var preview = window.open("chrome://sidebar/content/preview.xul",
"PanelPreview", "chrome");
"_blank", "chrome");
preview.panel_name = preview_name;
preview.panel_URL = preview_URL;
}
enableSave();
}
function enableSave() {

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

@ -24,14 +24,13 @@
<window
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Init();">
<html:script src="chrome://sidebar/content/customize.js" />
<box align="vertical" flex="100%" id="main-box">
onload="Init();"
id="main-box"
align="vertical">
<!-- Dialog title -->
<html:script src="chrome://sidebar/content/customize.js" />
<html:div class="title">
&sidebar.customize.title.label;
</html:div>
@ -40,83 +39,111 @@
<html:hr />
</html:div>
<html:div class="subtitle">
&sidebar.customize.current.label;
</html:div>
<!-- The two-pane -->
<box align="horizontal">
<box align="horizontal" class="box-group">
<!-- All of the panels that are available -->
<box align="vertical" flex="1*">
<box align="vertical">
<spring flex="50%"/>
<titledbutton onclick="moveUp();" id="up" class="borderless up" />
<titledbutton onclick="moveDown();" id="down" class="borderless down" />
<spring flex="50%"/>
</box>
<html:div class="subtitle">
&sidebar.customize.additional.label;
</html:div>
<html:form>
<html:select id="selectList" size="10" onclick="selectChange();">
</html:select>
</html:form>
<html:div style="width:15em;height:15em" flex="1*">
<tree id="other-panels" size="10" onclick="otherPanelSelected()"
datasources="chrome://sidebar/content/local-panels.rdf
chrome://sidebar/content/remote-panels.rdf"
ref="urn:sidebar:master-panel-list"
style="width:100%;height:100%">
<template>
<treechildren>
<treeitem uri="rdf:*"
title="rdf:http://home.netscape.com/NC-rdf#title"
content="rdf:http://home.netscape.com/NC-rdf#content">
<treerow>
<treecell value="rdf:http://home.netscape.com/NC-rdf#title"/>
</treerow>
</treeitem>
</treechildren>
</template>
</tree>
</html:div>
<box align="vertical" class="button-group" flex="100%">
<titledbutton id="customize-button" onclick="CustomizePanel();"
value="&sidebar.customize.customize.label;" />
<titledbutton onclick="RemovePanel()"
value="&sidebar.customize.remove.label;" />
</box>
<!-- xxxslamm Need to add descriptive panel text here -->
<box align="horizontal" class="button-group">
<titledbutton id="add_button" onclick="AddPanel()"
value="&sidebar.customize.add.label;"
disabled="true"/>
<titledbutton id="preview_button" onclick="PreviewPanel()"
value="&sidebar.customize.preview.label;"
disabled="true"/>
</box>
</box>
<!-- The panels that the user currently has chosen -->
<box align="vertical" flex="1*">
<html:div class="subtitle">
&sidebar.customize.current.label;
</html:div>
<box align="horizontal" class="box-group" flex="1*">
<html:div style="width:15em;height:15em" flex="1*">
<tree id="selected-panels" onclick="selectChange();"
datasources="chrome://sidebar/content/local-panels.rdf
chrome://sidebar/content/remote-panels.rdf"
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">
<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="selected-panels-root"/>
</tree>
</html:div>
<!-- The 'reorder' buttons -->
<box align="vertical">
<spring flex="50%"/>
<titledbutton onclick="moveUp();" id="up" class="borderless up" />
<html:div>
&sidebar.customize.reorder.label;
</html:div>
<titledbutton onclick="moveDown();" id="down"
class="borderless down" />
<spring flex="50%"/>
</box>
</box>
<box align="horizontal" class="button-group" flex="100%">
<titledbutton id="customize-button" onclick="CustomizePanel();"
value="&sidebar.customize.customize.label;" />
<titledbutton id="remove-button" onclick="RemovePanel()"
value="&sidebar.customize.remove.label;" />
</box>
</box>
</box>
<html:div>
<html:hr />
</html:div>
<html:div class="subtitle">
&sidebar.customize.additional.label;
</html:div>
<box align="horizontal" class="box-group">
<!-- datasources="chrome://sidebar/content/sidebar-registry.rdf"-->
<tree id="other-panels" flex='100%'
datasources="resource:/chrome/sidebar/content/default/sidebar-registry.rdf"
onclick="selected()"
ref="NC:SidebarRoot" >
<!-- The template we'll use to build rows in the content model. -->
<template>
<rule>
<treechildren>
<treeitem uri="..." type="rdf:http://home.netscape.com/NC-rdf#type">
<treerow>
<treecell>
<treeindentation />
<titledbutton align="right"
value="rdf:http://home.netscape.com/NC-rdf#title" />
</treecell>
</treerow>
</treeitem>
</treechildren>
</rule>
</template>
</tree>
<box align="vertical" class="button-group">
<titledbutton id="add_button" onclick="AddPanel()"
value="&sidebar.customize.add.label;"
disabled="true"/>
<titledbutton id="preview_button" onclick="PreviewPanel()"
value="&sidebar.customize.preview.label;"
disabled="true"/>
</box>
</box>
<html:div>
<html:hr />
</html:div>
<!-- The 'Save' and 'Cancel' buttons -->
<box align="horizontal">
<spring flex="48%"/>
<titledbutton onclick="window.close()"
@ -127,7 +154,5 @@
disabled="true"/>
<spring flex="48%"/>
</box>
</box>
</window>

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

@ -3,8 +3,9 @@
<!-- LOCALIZATION NOTE sidebar.customize.title.label: Do NOT localize the term "Sidebar" -->
<!ENTITY sidebar.customize.title.label "Customize Sidebar">
<!ENTITY sidebar.customize.current.label "Panels currently in Sidebar">
<!ENTITY sidebar.customize.reorder.label "Reorder">
<!ENTITY sidebar.customize.customize.label "Customize Panel...">
<!ENTITY sidebar.customize.remove.label "Remove Panel">
<!ENTITY sidebar.customize.remove.label "Remove">
<!ENTITY sidebar.customize.additional.label "Add these Panels to your Sidebar">
<!ENTITY sidebar.customize.add.label "Add">
<!ENTITY sidebar.customize.preview.label "Preview...">

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

@ -35,10 +35,11 @@ CHROME_CONTENT = \
.\preview.css \
.\preview.js \
.\preview.xul \
.\sidebar-registry.rdf \
.\sidebar.rdf \
.\sidebarOverlay.js \
.\sidebarOverlay.xul \
.\local-panels.rdf \
.\remote-panels.rdf \
.\default-panels.rdf \
$(NULL)
CHROME_SKIN = \

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

@ -36,11 +36,13 @@
&sidebar.preview.title.label;
</html:div>
<html:hr/>
<html:div>
<html:hr />
</html:div>
<box align="horizontal" class="panelbar">
<html:img src="chrome://sidebar/skin/corner.gif" />
<titledbutton id="paneltitle" class="borderless paneltitle" />
<titledbutton id="paneltitle" class="plain paneltitle" />
<spring flex="100%" />
</box>

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

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

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

@ -73,11 +73,15 @@ splitter.panel-bar titledbutton
splitter > titledbutton.show-hide
{
padding: 0px;
margin: 0px;
list-style-image:url(chrome://sidebar/skin/panel-collapse.gif);
}
splitter[state="collapsed"] > titledbutton.show-hide
{
padding: 0px;
margin: 0px;
list-style-image:url(chrome://sidebar/skin/panel-expand.gif);
}

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

@ -10,22 +10,13 @@
* the License for the specific language governing rights and
* limitations under the License.
*
* The Original Code is ______________________________________.
* The Initial Developer of the Original Code is ________________________.
* Portions created by ______________________ are Copyright (C) ______
* _______________________. All Rights Reserved.
* Contributor(s): ______________________________________.
*
* Alternatively, the contents of this file may be used under the terms
* of the _____ license (the ?[___] License?), in which case the
* provisions of [______] License are applicable instead of those above.
* If you wish to allow use of your version of this file only under the
* terms of the [____] License and not to allow others to use your
* version of this file under the MPL, indicate your decision by
* deleting the provisions above and replace them with the notice and
* other provisions required by the [___] License. If you do not delete
* the provisions above, a recipient may use your version of this file
* under either the MPL or the [___] License.
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*/
// the rdf service
@ -34,47 +25,39 @@ var RDF = Components.classes[rdf_uri].getService()
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService)
// the default sidebar:
var defaultsidebar = new Object
defaultsidebar.db = 'chrome://sidebar/content/sidebar.rdf'
defaultsidebar.resource = 'NC:SidebarRoot'
var sidebar = new Object;
// the current sidebar:
var sidebar = null
function sidebarOverlayInit(usersidebar)
function debug(msg)
{
// load up user-specified sidebar
if (usersidebar) {
//dump("usersidebar = " + usersidebar + "\n")
//dump("usersidebar.resource = " + usersidebar.resource + "\n")
//dump("usersidebar.db = " + usersidebar.db + "\n")
sidebar = usersidebar
}
else {
try
{
var profileInterface = Components.interfaces.nsIProfile
var profileURI = 'component://netscape/profile/manager'
var profileService = Components.classes[profileURI].getService()
profileService = profileService.QueryInterface(profileInterface)
var sidebar_url = profileService.getCurrentProfileDirFromJS()
sidebar_url.URLString += "sidebar.rdf"
// uncomment for noise
//dump(msg);
}
if (!(sidebar_url.exists())) {
//dump("using " + defaultsidebar.db + " because " +
//sidebar_url.URLString + " does not exist\n")
} else {
//dump("sidebar url is " + sidebar_url.URLString + "\n")
defaultsidebar.db = sidebar_url.URLString
}
}
catch (ex)
{
//dump("failed to get sidebar url, using default\n")
}
sidebar = defaultsidebar
function sidebarOverlayInit()
{
// Look in the profile directory to find 'panels.rdf', which is the
// database of the user's currently selected panels.
var profileInterface = Components.interfaces.nsIProfile;
var profileURI = 'component://netscape/profile/manager';
var profileService = Components.classes[profileURI].getService();
profileService = profileService.QueryInterface(profileInterface);
var sidebar_url = profileService.getCurrentProfileDirFromJS();
sidebar_url.URLString += "panels.rdf";
if (sidebar_url.exists()) {
debug("sidebar url is " + sidebar_url.URLString + "\n");
sidebar.db = sidebar_url.URLString;
}
else {
// XXX What we should _really_ do here is copy the default panels
// into the profile directory and then try again.
sidebar.db = 'chrome://sidebar/content/default-panels.rdf'
debug("using " + sidebar.db + " because " + sidebar_url.URLString + " does not exist\n");
}
sidebar.resource = 'urn:sidebar:current-panel-list';
// Initialize the display
var sidebar_element = document.getElementById('sidebar-box')
var sidebar_menuitem = document.getElementById('menu_sidebar')
if (sidebar_element.getAttribute('hidden') == 'true') {
@ -82,130 +65,20 @@ function sidebarOverlayInit(usersidebar)
sidebar_menuitem.setAttribute('checked', 'false')
return
}
sidebar_menuitem.setAttribute('checked', 'true')
//dump("sidebar = " + sidebar + "\n")
//dump("sidebar.resource = " + sidebar.resource + "\n")
//dump("sidebar.db = " + sidebar.db + "\n")
//var panelsbox = document.getElementById('sidebar-panels')
//panelsbox.setAttribute('datasources',sidebar.db);
//panelsbox.setAttribute('datasource',sidebar.db);
//return;
debug("sidebar = " + sidebar + "\n");
debug("sidebar.resource = " + sidebar.resource + "\n");
debug("sidebar.db = " + sidebar.db + "\n");
var registry
try {
// First try to construct a new one and load it
// synchronously. nsIRDFService::GetDataSource() loads RDF/XML
// asynchronously by default.
var xmlsrc = 'component://netscape/rdf/datasource?name=xml-datasource'
registry = Components.classes[xmlsrc].createInstance()
registry = registry.QueryInterface(Components.interfaces.nsIRDFDataSource)
// Add the user's current panel choices to the template builder,
// which will aggregate it with the other datasources that describe
// the individual panel's title, customize URL, and content URL.
var panels = document.getElementById('sidebar-panels');
panels.database.AddDataSource(RDF.GetDataSource(sidebar.db));
var remote = Components.interfaces.nsIRDFRemoteDataSource
remote = registry.QueryInterface(remote)
// this will throw if it's already been opened and registered.
remote.Init(sidebar.db)
// XXX This is a hack to force re-display
panels.setAttribute('ref', 'urn:sidebar:current-panel-list');
// read it in synchronously.
remote.Refresh(true)
}
catch (ex) {
// if we get here, then the RDF/XML has been opened and read
// once. We just need to grab the datasource.
registry = RDF.GetDataSource(sidebar.db)
}
// Create a 'container' wrapper around the sidebar.resources
// resource so we can use some utility routines that make access a
// bit easier.
var sb_datasource = Components.classes['component://netscape/rdf/container']
var container = Components.interfaces.nsIRDFContainer
try {
sb_datasource = sb_datasource.createInstance()
sb_datasource = sb_datasource.QueryInterface(container)
sb_datasource.Init(registry, RDF.GetResource(sidebar.resource))
}
catch (ex) {
dump("failed to init sb_datasource\n")
}
var mypanelsbox = document.getElementById('sidebar-panels')
if (!mypanelsbox) {
dump("Unable to find sidebar panels\n")
return;
}
// Now enumerate all of the datasources.
var enumerator = null
try {
enumerator = sb_datasource.GetElements()
}
catch (ex) {
dump("sb_datasource has no elements.\n")
}
if (!enumerator) return
while (enumerator.HasMoreElements()) {
var service = enumerator.GetNext()
service = service.QueryInterface(Components.interfaces.nsIRDFResource)
var is_last = !enumerator.HasMoreElements()
var new_panel = sidebarAddPanel(mypanelsbox, registry, service, is_last)
}
}
function sidebarAddPanel(parent, registry, service, is_last) {
var panel_title = sidebarGetAttr(registry, service, 'title')
var panel_content = sidebarGetAttr(registry, service, 'content')
var panel_height = sidebarGetAttr(registry, service, 'height')
var iframe = document.createElement('html:iframe')
iframe.setAttribute('src', panel_content)
if (panel_height) iframe.setAttribute('height', panel_height)
iframe.setAttribute('class','panel-frame')
sidebarAddPanelTitle(parent, panel_title, is_last)
if (parent) parent.appendChild(iframe)
}
function sidebarAddPanelTitle(parent, titletext, is_last)
{
var splitter = document.createElement('splitter')
splitter.setAttribute('class', 'panel-bar')
splitter.setAttribute('resizeafter', 'grow')
splitter.setAttribute('collapse', 'after')
splitter.setAttribute('onclick', 'sidebarSavePanelState(this)')
var label = document.createElement('html:div')
var text = document.createTextNode(titletext)
label.appendChild(text)
label.setAttribute('class','panel-bar')
var spring = document.createElement('spring')
spring.setAttribute('flex','100%')
var titledbutton = document.createElement('titledbutton')
titledbutton.setAttribute('class', 'borderless show-hide')
titledbutton.setAttribute('onclick','sidebarOpenClosePanel(this.parentNode)')
splitter.appendChild(label)
splitter.appendChild(spring)
splitter.appendChild(titledbutton)
if (parent) parent.appendChild(splitter)
}
function sidebarGetAttr(registry,service,attr_name) {
var attr = registry.GetTarget(service,
RDF.GetResource('http://home.netscape.com/NC-rdf#' + attr_name),
true)
if (attr)
attr = attr.QueryInterface(
Components.interfaces.nsIRDFLiteral)
if (attr)
attr = attr.Value
return attr
}
function sidebarOpenClosePanel(splitter) {
@ -224,19 +97,13 @@ function sidebarOpenClosePanel(splitter) {
}
function sidebarReload() {
var panelsparent = document.getElementById('sidebar-panels')
var panel = panelsparent.firstChild
while (panel) {
var next = panel.nextSibling
panelsparent.removeChild(panel)
panel = next
}
sidebarOverlayInit(sidebar)
}
function sidebarCustomize() {
var newWin = window.openDialog('chrome://sidebar/content/customize.xul','New','chrome', sidebar.db, sidebar.resource)
var newWin = window.openDialog('chrome://sidebar/content/customize.xul',
'New','chrome',
sidebar.db, sidebar.resource)
return newWin
}
@ -246,40 +113,26 @@ function sidebarShowHide() {
var is_hidden = sidebar.getAttribute('hidden')
if (is_hidden && is_hidden == "true") {
//dump("Showing the sidebar\n")
debug("Showing the sidebar\n")
sidebar.setAttribute('hidden','')
sidebar_splitter.setAttribute('hidden','')
sidebarOverlayInit()
} else {
//dump("Hiding the sidebar\n")
debug("Hiding the sidebar\n")
sidebar.setAttribute('hidden','true')
sidebar_splitter.setAttribute('hidden','true')
}
}
function sidebarSavePanelState(splitter) {
}
function sidebarSaveState(splitter) {
/* Do nothing for now */
return;
if (splitter.getAttribute('state') == "collapse") {
dump("Expanding the sidebar\n")
} else {
dump("Collapsing the sidebar\n")
}
dumpStats()
}
function dumpAttributes(node) {
var attributes = node.attributes
if (!attributes || attributes.length == 0) {
dump("no attributes")
debug("no attributes")
}
for (var ii=0; ii < attributes.length; ii++) {
var attr = attributes.item(ii)
dump("attr "+ii+": "+ attr.name +"="+attr.value+"\n")
debug("attr "+ii+": "+ attr.name +"="+attr.value+"\n")
}
}
@ -292,24 +145,24 @@ function dumpStats() {
if (visibility) {
visibility = visibility[1]
}
dump("sidebar-box.style="+style+"\n")
dump("sidebar-box.visibility="+visibility+"\n")
dump('sidebar-box.width='+box.getAttribute('width')+'\n')
dump('sidebar-box attrs\n---------------------\n')
debug("sidebar-box.style="+style+"\n")
debug("sidebar-box.visibility="+visibility+"\n")
debug('sidebar-box.width='+box.getAttribute('width')+'\n')
debug('sidebar-box attrs\n---------------------\n')
dumpAttributes(box)
dump('sidebar-splitter attrs\n--------------------------\n')
debug('sidebar-splitter attrs\n--------------------------\n')
dumpAttributes(splitter)
}
function dumpTree(node, depth) {
var indent = "| | | | | | | | | | | | | | | | | | | | | | | | | | | | | + "
var kids = node.childNodes
dump(indent.substr(indent.length - depth*2))
debug(indent.substr(indent.length - depth*2))
// Print your favorite attributes here
dump(node.nodeName)
dump(" "+node.getAttribute('id'))
dump("\n")
debug(node.nodeName)
debug(" "+node.getAttribute('id'))
debug("\n")
for (var ii=0; ii < kids.length; ii++) {
dumpTree(kids[ii], depth + 1)

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

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0"?> <!-- -*- Mode: SGML; indent-tabs-mode: nil -*- -->
<!DOCTYPE window SYSTEM "chrome://sidebar/locale/sidebarOverlay.dtd">
@ -8,7 +8,7 @@
<!-- Overlay the sidebar panels -->
<box id="sidebar-box" align="vertical" persist="hidden width">
<splitter id="title-box" collapse="after"
<splitter id="title-box" collapse="after" persist="state"
onclick="sidebarOpenClosePanel(this)">
<html:div class="panel-bar">
&sidebar.panels.label;
@ -19,31 +19,27 @@
onclick="sidebarCustomize();" />
</splitter>
<box id="sidebar-panels" align="vertical" flex="100%">
<!--
datasources="chrome://sidebar/content/sidebar.rdf"
ref="NC:SidebarRoot">
<box id="sidebar-panels" align="vertical" flex="100%"
datasources="chrome://sidebar/content/local-panels.rdf
chrome://sidebar/content/remote-panels.rdf"
ref="urn:sidebar:current-panel-list">
<template>
<rule>
<box uri="rdf:*" align="vertical">
<splitter class="panel-bar"
collapse="after" resizeafter="grow"
onclick="sidebarSavePanelState(this)">
<splitter class="panel-bar" uri="rdf:*"
collapse="after" resizeafter="grow" persist="state">
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#title"
class="panel-bar"/>
class="panel-bar plain"/>
<spring flex="100%"/>
<titledbutton class="borderless show-hide"
onclick="sidebarOpenClosePanel(this.parentNode)"/>
</splitter>
<html:iframe class="panel-frame"
<html:iframe class="panel-frame" uri="rdf:*" persist="height"
src="rdf:http://home.netscape.com/NC-rdf#content"/>
</box>
</rule>
</template>
-->
</box>
<splitter id="alerts-splitter" class="panel-bar"
<splitter id="alerts-splitter" class="panel-bar" persist="state"
collapse="after" chromeclass="extrachrome"
onclick="sidebarOpenClosePanel(this)">
<html:div class="panel-bar">
@ -51,7 +47,8 @@
</html:div>
</splitter>
<box id="alerts-panel" align="vertical" chromeclass="extrachrome">
<box id="alerts-panel" align="vertical" chromeclass="extrachrome"
persist="height">
<html:div flex="1">
<tree id="flash-tree"
ref="NC:FlashRoot"
@ -76,7 +73,7 @@
<!-- Some splitter attritutes -->
<splitter id="sidebar-splitter" collapse="before" persist="state hidden"
chromeclass="extrachrome" onclick="sidebarSaveState(this)"/>
chromeclass="extrachrome" />
<!-- Scripts go last, because they peek at state to tweak menus -->
<html:script language="JavaScript"