Removing support for <outliner> tags
Removing <tree> layout code and moving <tree> tags to outliner layout
Convert all usage of <outliner> to tree tags
Convert all usage of <tree> tags to new <tree> syntax or <listbox>
r=cmanske,varga sr=hyatt,sspitzer a=asa

Also includes fixes by Jan Varga (varga@utcruk.sk) for bugs 132020, 133451, 131393, 115894, and 129327
This commit is contained in:
hewitt%netscape.com 2006-07-27 14:55:43 +00:00
Родитель 00adb77464
Коммит a376ddc053
12 изменённых файлов: 665 добавлений и 959 удалений

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

@ -21,6 +21,7 @@
*
* Contributor(s):
* Bradley Baetz <bbaetz@student.usyd.edu.au>
* Joe Hewitt <hewitt@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -40,8 +41,6 @@
Script for the directory window
*/
const RDFSERVICE_CONTRACTID = "@mozilla.org/rdf/rdf-service;1";
const DRAGSERVICE_CONTRACTID = "@mozilla.org/widget/dragservice;1";
const TRANSFERABLE_CONTRACTID = "@mozilla.org/widget/transferable;1";
@ -63,360 +62,245 @@ const nsIRDFLiteral = Components.interfaces.nsIRDFLiteral;
const nsISupportsArray = Components.interfaces.nsISupportsArray;
const nsISupportsWString = Components.interfaces.nsISupportsWString;
// By the time this runs, The 'HTTPIndex' variable will have been
// magically set on the global object by the native code.
function debug(msg)
{
// Uncomment to print out debug info.
//dump(msg);
// Uncomment to print out debug info.
//dump(msg);
}
var loadingArc = null;
var loadingLevel = 0;
var RDF_observer = new Object;
RDF_observer =
var RDF_observer =
{
onAssert : function(ds, src, prop, target)
{
if (prop == loadingArc)
{
if (loadingLevel++ == 0)
{
SetBusyCursor(window, true);
}
debug("Directory: assert: loading level is " + loadingLevel + " for " + src.Value + "\n");
}
},
onUnassert : function(ds, src, prop, target)
{
if (prop == loadingArc)
{
if (loadingLevel > 0)
{
if (--loadingLevel == 0)
{
SetBusyCursor(window, false);
}
}
debug("Directory: unassert: loading level is " + loadingLevel + " for " + src.Value + "\n");
}
},
onChange : function(ds, src, prop, old_target, new_target)
{
},
onMove : function(ds, old_src, new_src, prop, target)
{
},
beginUpdateBatch : function(ds)
{
},
endUpdateBatch : function(ds)
{
onAssert: function(ds, src, prop, target)
{
if (prop == loadingArc) {
if (loadingLevel++ == 0)
SetBusyCursor(window, true);
debug("Directory: assert: loading level is " + loadingLevel + " for " + src.Value + "\n");
}
}
},
onUnassert: function(ds, src, prop, target)
{
if (prop == loadingArc) {
if (loadingLevel > 0)
if (--loadingLevel == 0)
SetBusyCursor(window, false);
debug("Directory: unassert: loading level is " + loadingLevel + " for " + src.Value + "\n");
}
},
onChange: function(ds, src, prop, old_target, new_target) { },
onMove: function(ds, old_src, new_src, prop, target) { },
beginUpdateBatch: function(ds) { },
endUpdateBatch: function(ds) { }
};
function
SetBusyCursor(window, enable)
{
// Defensive check: setCursor() is only available for
// chrome windows. Since one of our frame might be a
// non-chrome window, make sure the window we treat has
// a setCursor method.
if("setCursor" in window)
{
if(enable == true)
{
window.setCursor("wait");
debug("Directory: cursor=busy\n");
}
else
{
window.setCursor("auto");
debug("Directory: cursor=notbusy\n");
}
// Defensive check: setCursor() is only available for
// chrome windows. Since one of our frame might be a
// non-chrome window, make sure the window we treat has
// a setCursor method.
if("setCursor" in window) {
if(enable == true) {
window.setCursor("wait");
debug("Directory: cursor=busy\n");
} else {
window.setCursor("auto");
debug("Directory: cursor=notbusy\n");
}
}
var numFrames = window.frames.length;
for(var i = 0; i < numFrames; i++)
{
SetBusyCursor(window.frames[i], enable);
}
var numFrames = window.frames.length;
for (var i = 0; i < numFrames; i++)
SetBusyCursor(window.frames[i], enable);
}
// We need this hack because we've completely circumvented the onload() logic.
function Boot()
{
if (document.getElementById('tree')) {
Init();
}
else {
setTimeout("Boot()", 500);
}
if (document.getElementById('tree'))
Init();
else
setTimeout("Boot()", 500);
}
setTimeout("Boot()", 0);
function Init()
{
debug("directory.js: Init()\n");
debug("directory.js: Init()\n");
var tree = document.getElementById('tree');
var tree = document.getElementById('tree');
// Initialize the tree's base URL to whatever the HTTPIndex is rooted at
var baseURI = HTTPIndex.BaseURL;
// Initialize the tree's base URL to whatever the HTTPIndex is rooted at
var baseURI = HTTPIndex.BaseURL;
if (baseURI && (baseURI.indexOf("ftp://") == 0))
{
// fix bug # 37102: if its a FTP directory
// ensure it ends with a trailing slash
if (baseURI.substr(baseURI.length - 1) != "/")
{
debug("append traiing slash to FTP directory URL\n");
baseURI += "/";
}
// Lets also enable the loggin window.
var node = document.getElementById("main-splitter");
node.setAttribute("hidden", false);
node = document.getElementById("logbox");
node.setAttribute("hidden", false);
if (baseURI && (baseURI.indexOf("ftp://") == 0)) {
// fix bug # 37102: if its a FTP directory
// ensure it ends with a trailing slash
if (baseURI.substr(baseURI.length - 1) != "/") {
debug("append traiing slash to FTP directory URL\n");
baseURI += "/";
}
if (baseURI && (baseURI.indexOf("file://") != 0)) {
// Note: DON'T add the HTTPIndex datasource into the tree
// for file URLs, only do it for FTP/Gopher/etc URLs; the "rdf:files"
// datasources handles file URLs
tree.database.AddDataSource(HTTPIndex);
// Lets also enable the loggin window.
var node = document.getElementById("main-splitter");
node.setAttribute("hidden", false);
node = document.getElementById("logbox");
node.setAttribute("hidden", false);
}
if (baseURI && (baseURI.indexOf("file://") != 0)) {
// Note: DON'T add the HTTPIndex datasource into the tree
// for file URLs, only do it for FTP/Gopher/etc URLs; the "rdf:files"
// datasources handles file URLs
tree.database.AddDataSource(HTTPIndex);
}
// Note: set encoding BEFORE setting "ref" (important!)
var RDF = Components.classes[RDFSERVICE_CONTRACTID].getService();
if (RDF) RDF = RDF.QueryInterface(nsIRDFService);
if (RDF) {
loadingArc = RDF.GetResource(NC_LOADING, true);
var httpDS = HTTPIndex.DataSource;
if (httpDS) httpDS = httpDS.QueryInterface(nsIHTTPIndex);
if (httpDS) {
httpDS.encoding = "ISO-8859-1";
// Use a default character set.
if (window._content.defaultCharacterset)
httpDS.encoding = window._content.defaultCharacterset;
}
}
// Note: set encoding BEFORE setting "ref" (important!)
var RDF = Components.classes[RDFSERVICE_CONTRACTID].getService();
if (RDF) RDF = RDF.QueryInterface(nsIRDFService);
if (RDF)
{
loadingArc = RDF.GetResource(NC_LOADING, true);
// set window title
document.title = baseURI;
var httpDS = HTTPIndex.DataSource;
if (httpDS) httpDS = httpDS.QueryInterface(nsIHTTPIndex);
if (httpDS)
{
httpDS.encoding = "ISO-8859-1";
tree.database.AddObserver(RDF_observer);
debug("Directory: added observer\n");
// Use a default character set.
if (window._content.defaultCharacterset)
{
httpDS.encoding = window._content.defaultCharacterset;
}
}
}
// set window title
document.title = baseURI;
tree.database.AddObserver(RDF_observer);
debug("Directory: added observer\n");
// root the tree (do this last)
tree.setAttribute("ref", baseURI);
// root the tree (do this last)
tree.setAttribute("ref", baseURI);
}
function DoUnload()
{
var tree = document.getElementById("tree");
if (tree)
{
if (tree) {
tree.database.RemoveDataSource(HTTPIndex);
tree.database.RemoveObserver(RDF_observer);
debug("Directory: removed observer\n");
debug("Directory: removed observer\n");
}
}
function OnClick(event, node)
function OnClick(event)
{
if( event.type == "click" &&
( event.button != 0 || event.detail != 2 || node.nodeName != "treeitem") )
return(false);
if( event.type == "keypress" && event.keyCode != 13 )
return(false);
if (event.target.localName != "treechildren")
return false;
if( event.type == "click" && (event.button != 0 || event.detail != 2))
return false;
if( event.type == "keypress" && event.keyCode != 13)
return false;
var tree = document.getElementById("tree");
if( tree.selectedItems.length == 1 ) {
var selectedItem = tree.selectedItems[0];
var url = selectedItem.getAttribute("URL");
window._content.location.href = url;
// set window title
document.title = url;
}
var tree = document.getElementById("tree");
if (tree.currentIndex >= 0) {
var item = tree.contentView.getItemAtIndex(tree.currentIndex);
window._content.location.href = item.getAttributeNS(NC_NS, "url");
}
}
function OnMouseOver(event, node)
function doSort(aTarget)
{
if (node.nodeName != "treeitem")
return false;
var url = node.getAttribute("URL");
window._content.status = url;
return true;
}
function OnMouseOut(event, node)
{
window._content.status = "";
return true;
}
function doSort(sortColName)
{
var node = document.getElementById(sortColName);
if (!node) return(false);
if (aTarget.localName != "treecol")
return;
// determine column resource to sort on
var sortResource = node.getAttribute('resource');
var sortResource = aTarget.getAttribute('resource');
// switch between ascending & descending sort (no natural order support)
var sortDirection="ascending";
var isSortActive = node.getAttribute('sortActive');
if (isSortActive == "true")
{
var currentDirection = node.getAttribute('sortDirection');
if (currentDirection == "ascending")
{
sortDirection = "descending";
}
}
var sortDirection = aTarget.getAttribute("sortDirection") == "ascending" ? "descending" : "ascending";
try
{
var isupports = Components.classes[XULSORTSERVICE_CONTRACTID].getService();
if (!isupports) return(false);
var xulSortService = isupports.QueryInterface(nsIXULSortService);
if (!xulSortService) return(false);
xulSortService.Sort(node, sortResource, sortDirection);
}
catch(ex)
{
}
return(false);
try {
var sortService = Components.classes[XULSORTSERVICE_CONTRACTID].getService(nsIXULSortService);
sortService.Sort(aTarget, sortResource, sortDirection);
} catch(ex) { }
}
function BeginDragTree ( event )
function BeginDragTree (event)
{
var tree = document.getElementById("tree");
if ( event.target == tree )
return(true); // continue propagating the event
// only <treeitem>s can be dragged out
if ( event.target.parentNode.parentNode.tagName != "treeitem")
return(false);
var database = tree.database;
if (!database) return(false);
var RDF =
Components.classes[RDFSERVICE_CONTRACTID].getService(nsIRDFService);
if (!RDF) return(false);
if (event.target.localName != "treechildren")
return true;
var dragStarted = false;
var transferable =
Components.classes[TRANSFERABLE_CONTRACTID].createInstance(nsITransferable);
if ( !transferable ) return(false);
try {
// determine which treeitem was dragged
var tree = document.getElementById("tree");
var row = {}, colId = {}, child = {};
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, colId, child);
var item = tree.contentView.getItemAtIndex(row.value);
var genDataURL =
Components.classes[WSTRING_CONTRACTID].createInstance(nsISupportsWString);
if (!genDataURL) return(false);
// get information from treeitem for drag
var url = item.getAttributeNS(NC_NS, "url");
var desc = item.getAttributeNS(NC_NS, "desc");
var RDF = Components.classes[RDFSERVICE_CONTRACTID].getService(nsIRDFService);
var transferable =
Components.classes[TRANSFERABLE_CONTRACTID].createInstance(nsITransferable);
var genDataURL =
Components.classes[WSTRING_CONTRACTID].createInstance(nsISupportsWString);
var genDataHTML =
Components.classes[WSTRING_CONTRACTID].createInstance(nsISupportsWString);
var genData =
Components.classes[WSTRING_CONTRACTID].createInstance(nsISupportsWString);
var genDataURL =
Components.classes[WSTRING_CONTRACTID].createInstance(nsISupportsWString);
var genDataHTML =
Components.classes[WSTRING_CONTRACTID].createInstance(nsISupportsWString);
if (!genDataHTML) return(false);
transferable.addDataFlavor("text/x-moz-url");
transferable.addDataFlavor("text/html");
transferable.addDataFlavor("text/unicode");
genDataURL.data = url + "\n" + desc;
genDataHTML.data = "<a href=\"" + url + "\">" + desc + "</a>";
genData.data = url;
var genData =
Components.classes[WSTRING_CONTRACTID].createInstance(nsISupportsWString);
if (!genData) return(false);
transferable.setTransferData("text/x-moz-url", genDataURL, genDataURL.data.length * 2);
transferable.setTransferData("text/html", genDataHTML, genDataHTML.data.length * 2);
transferable.setTransferData("text/unicode", genData, genData.data.length * 2);
var genDataURL =
Components.classes[WSTRING_CONTRACTID].createInstance(nsISupportsWString);
if (!genDataURL) return(false);
var transArray =
Components.classes[ARRAY_CONTRACTID].createInstance(nsISupportsArray);
transferable.addDataFlavor("text/x-moz-url");
transferable.addDataFlavor("text/html");
transferable.addDataFlavor("text/unicode");
// put it into the transferable as an |nsISupports|
var genTrans = transferable.QueryInterface(Components.interfaces.nsISupports);
transArray.AppendElement(genTrans);
var dragService =
Components.classes[DRAGSERVICE_CONTRACTID].getService(nsIDragService);
dragService.invokeDragSession(event.target, transArray, null, nsIDragService.DRAGDROP_ACTION_COPY +
nsIDragService.DRAGDROP_ACTION_MOVE);
// ref/id (url) is on the <treeitem> which is two levels above the <treecell> which is
// the target of the event.
var id = event.target.parentNode.parentNode.getAttribute("ref");
if (!id || id=="")
{
id = event.target.parentNode.parentNode.getAttribute("id");
}
var src = RDF.GetResource(id, true);
var urlProp = RDF.GetResource(NC_URL, true);
var url = database.GetTarget(src, urlProp, true);
if (url) url = url.QueryInterface(nsIRDFLiteral);
if (url) url = url.Value;
if (!url || url=="")
return false;
var descProp = RDF.GetResource(NC_NAME, true);
var desc = database.GetTarget(src, descProp, true);
if (desc) desc = desc.QueryInterface(nsIRDFLiteral);
if (desc) desc = desc.Value;
if (!desc || desc=="")
return false;
genDataURL.data = url + "\n" + desc;
genDataHTML.data = "<a href=\"" + url + "\">" + desc + "</a>";
genData.data = url;
transferable.setTransferData ( "text/x-moz-url", genDataURL, genDataURL.data.length * 2);
transferable.setTransferData ( "text/html", genDataHTML, genDataHTML.data.length * 2);
transferable.setTransferData ( "text/unicode", genData, genData.data.length * 2);
var transArray =
Components.classes[ARRAY_CONTRACTID].createInstance(nsISupportsArray);
if ( !transArray ) return(false);
// put it into the transferable as an |nsISupports|
var genTrans = transferable.QueryInterface(Components.interfaces.nsISupports);
transArray.AppendElement(genTrans);
dragStarted = true;
} catch (ex) { }
var dragService =
Components.classes[DRAGSERVICE_CONTRACTID].getService(nsIDragService);
if ( !dragService ) return(false);
dragService.invokeDragSession ( event.target, transArray, null, nsIDragService.DRAGDROP_ACTION_COPY +
nsIDragService.DRAGDROP_ACTION_MOVE );
dragStarted = true;
return(!dragStarted);
return !dragStarted;
}
function scrollDown()
{
window.frames[0].scrollTo(0, window.frames[0].document.height);
window.frames[0].scrollTo(0, window.frames[0].document.height);
}
function OnFTPControlLog( server, msg )

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

@ -19,83 +19,70 @@
Rights Reserved.
Contributor(s):
Joe Hewitt <hewitt@netscape.com>
Princess Marshmallow <yumminess@netscape.com>
-->
<?xml-stylesheet href="chrome://communicator/skin/directory/directory.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/directory/directory.dtd">
<window style="overflow: auto"
<page
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:nc="http://home.netscape.com/NC-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onunload="DoUnload();">
<script type="application/x-javascript" src="chrome://communicator/content/directory/directory.js"/>
<tree id="tree" datasources="rdf:files" flex="1" style="height:0px;"
container="true" open="true" flags="dont-test-empty"
<tree id="tree" flex="1" enableColumnDrag="true"
datasources="rdf:files" flags="dont-test-empty"
sortActive="true" sortDirection="ascending"
sortResource="http://home.netscape.com/NC-rdf#Name"
persist="sortDirection sortResource sortResource2"
onclick="OnClick(event);"
onkeypress="OnClick(event);"
ondraggesture="return BeginDragTree(event);">
<treecols onclick="doSort(event.target)">
<treecol id="FilenameColumn" flex="3" persist="ordinal hidden"
label="&directoryWindow.filename.label;"
primary="true" sortDirection="ascending"
resource="http://home.netscape.com/NC-rdf#Name"/>
<splitter class="tree-splitter"/>
<treecol id="ContentLengthColumn" flex="1" persist="ordinal hidden"
label="&directoryWindow.contentlength.label;"
resource="http://home.netscape.com/NC-rdf#Content-Length"
resource2="http://home.netscape.com/NC-rdf#Name"/>
<splitter class="tree-splitter"/>
<treecol id="LastModColumn" flex="1" persist="ordinal hidden"
label="&directoryWindow.lastmodified.label;"
resource="http://home.netscape.com/WEB-rdf#LastModifiedDate"
resource2="http://home.netscape.com/NC-rdf#Name"/>
</treecols>
<template>
<treechildren flex="1">
<treechildren>
<treeitem uri="..." persist="open"
URL="rdf:http://home.netscape.com/NC-rdf#URL"
type="rdf:http://home.netscape.com/NC-rdf#File-Type"
loading="rdf:http://home.netscape.com/NC-rdf#loading" >
nc:url="rdf:http://home.netscape.com/NC-rdf#URL"
nc:desc="rdf:http://home.netscape.com/NC-rdf#Name">
<treerow>
<treecell class="treecell-filename treecell-indent" indent="true"
src="rdf:http://home.netscape.com/NC-rdf#Icon"
validate="never"
type="rdf:http://home.netscape.com/NC-rdf#File-Type"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#Content-Length" />
<treecell label="rdf:http://home.netscape.com/WEB-rdf#LastModifiedDate" />
<treecell label="rdf:http://home.netscape.com/NC-rdf#Name"
src="rdf:http://home.netscape.com/NC-rdf#Icon"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#Content-Length"/>
<treecell label="rdf:http://home.netscape.com/WEB-rdf#LastModifiedDate"/>
</treerow>
</treeitem>
</treechildren>
</template>
<treecolgroup>
<treecol flex="3" id="FilenameColumn"
sortActive="true" sortDirection="ascending"
resource="http://home.netscape.com/NC-rdf#Name" />
<splitter class="tree-splitter"/>
<treecol flex="1" id="ContentLengthColumn"
resource="http://home.netscape.com/NC-rdf#Content-Length"
resource2="http://home.netscape.com/NC-rdf#Name"/>
<splitter class="tree-splitter"/>
<treecol flex="1" id="LastModColumn"
resource="http://home.netscape.com/WEB-rdf#LastModifiedDate"
resource2="http://home.netscape.com/NC-rdf#Name"/>
</treecolgroup>
<treehead>
<treerow>
<treecell class="treecell-header sortDirectionIndicator" label="&directoryWindow.filename.label;"
onclick="return doSort('FilenameColumn');" observes="FilenameColumn" sortActive="true" sortDirection="ascending" />
<treecell class="treecell-header sortDirectionIndicator" label="&directoryWindow.contentlength.label;"
onclick="return doSort('ContentLengthColumn');" observes="ContentLengthColumn" />
<treecell class="treecell-header sortDirectionIndicator" label="&directoryWindow.lastmodified.label;"
onclick="return doSort('LastModColumn');" observes="LastModColumn" />
</treerow>
</treehead>
<!-- Create the treechildren here so we can attach event handlers
at this level (rather than at the tree level -->
<treechildren flex="1" onclick="OnClick(event, event.target.parentNode.parentNode);"
onkeypress="OnClick(event, event.target.parentNode.parentNode);"
onmouseover="OnMouseOver(event, event.target.parentNode.parentNode);"
onmouseout="OnMouseOut(event, event.target.parentNode.parentNode);" />
</tree>
<splitter id="main-splitter" collapse="after" hidden="true" >
<splitter id="main-splitter" collapse="after" hidden="true">
<grippy/>
</splitter>
<vbox id="logbox" flex="1" collapsed="true" persist="height collapsed" hidden="true">
<iframe id="output-iframe" type="content" flex="1" src="chrome://communicator/content/directory/directory.html"/>
</vbox>
</window>
</page>

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

@ -37,7 +37,7 @@
* ***** END LICENSE BLOCK ***** */
// The history window uses JavaScript in bookmarks.js too.
var gHistoryOutliner;
var gHistoryTree;
var gLastHostname;
var gLastDomain;
var gGlobalHistory;
@ -51,20 +51,20 @@ var gWindowManager = null;
function HistoryInit()
{
gHistoryOutliner = document.getElementById("historyOutliner");
gHistoryTree = document.getElementById("historyTree");
gDeleteByHostname = document.getElementById("menu_deleteByHostname");
gDeleteByDomain = document.getElementById("menu_deleteByDomain");
gHistoryBundle = document.getElementById("historyBundle");
gHistoryStatus = document.getElementById("statusbar-display");
var outlinerController = new nsOutlinerController(gHistoryOutliner);
var treeController = new nsTreeController(gHistoryTree);
var historyController = new nsHistoryController;
gHistoryOutliner.controllers.appendController(historyController);
gHistoryTree.controllers.appendController(historyController);
if ("arguments" in window && window.arguments[0] && window.arguments.length >= 1) {
// We have been supplied a resource URI to root the tree on
var uri = window.arguments[0];
gHistoryOutliner.setAttribute("ref", uri);
gHistoryTree.setAttribute("ref", uri);
if (uri.substring(0,5) == "find:" &&
!(window.arguments.length > 1 && window.arguments[1] == "newWindow")) {
// Update the windowtype so that future searches are directed
@ -102,8 +102,8 @@ function HistoryInit()
pbi.addObserver("browser.history.grouping", groupObserver, false);
}
}
gHistoryOutliner.focus();
gHistoryOutliner.outlinerBoxObject.view.selection.select(0);
gHistoryTree.focus();
gHistoryTree.treeBoxObject.view.selection.select(0);
}
function updateHistoryCommands()
@ -118,13 +118,13 @@ function historyOnClick(aEvent)
// If a status bar is not present, assume we're in sidebar mode, and thus single clicks on containers
// will open the container. Single clicks on non-containers are handled below in historyOnSelect.
if (!gHistoryStatus) {
var currentIndex = gHistoryOutliner.currentIndex;
var currentIndex = gHistoryTree.currentIndex;
var row = { };
var col = { };
var elt = { };
gHistoryOutliner.outlinerBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, col, elt);
if (row.value >= 0 && isContainer(gHistoryOutliner, row.value))
gHistoryOutliner.outlinerBoxObject.view.toggleOpenState(row.value);
gHistoryTree.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, col, elt);
if (row.value >= 0 && isContainer(gHistoryTree, row.value))
gHistoryTree.treeBoxObject.view.toggleOpenState(row.value);
}
}
@ -139,9 +139,9 @@ function historyOnSelect()
gLastHostname = "";
gLastDomain = "";
var match;
var currentIndex = gHistoryOutliner.currentIndex;
var rowIsContainer = gHistoryGrouping == "day" ? isContainer(gHistoryOutliner, currentIndex) : false;
var url = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "URL");
var currentIndex = gHistoryTree.currentIndex;
var rowIsContainer = gHistoryGrouping == "day" ? isContainer(gHistoryTree, currentIndex) : false;
var url = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL");
if (url && !rowIsContainer) {
// matches scheme://(hostname)...
@ -218,14 +218,14 @@ nsHistoryController.prototype =
if (!gGlobalHistory)
gGlobalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIBrowserHistory);
gGlobalHistory.removePagesFromHost(gLastHostname, false)
gHistoryOutliner.builder.rebuild();
gHistoryTree.builder.rebuild();
return true;
case "cmd_deleteByDomain":
if (!gGlobalHistory)
gGlobalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIBrowserHistory);
gGlobalHistory.removePagesFromHost(gLastDomain, true)
gHistoryOutliner.builder.rebuild();
gHistoryTree.builder.rebuild();
return true;
default:
@ -237,11 +237,11 @@ nsHistoryController.prototype =
var historyDNDObserver = {
onDragStart: function (aEvent, aXferData, aDragAction)
{
var currentIndex = gHistoryOutliner.currentIndex;
if (isContainer(gHistoryOutliner, currentIndex))
var currentIndex = gHistoryTree.currentIndex;
if (isContainer(gHistoryTree, currentIndex))
return false;
var url = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "URL");
var title = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "Name");
var url = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL");
var title = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "Name");
var htmlString = "<A HREF='" + url + "'>" + title + "</A>";
aXferData.data = new TransferData();
@ -254,30 +254,30 @@ var historyDNDObserver = {
function validClickConditions(event)
{
var currentIndex = gHistoryOutliner.currentIndex;
var currentIndex = gHistoryTree.currentIndex;
if (currentIndex == -1) return false;
var container = isContainer(gHistoryOutliner, currentIndex);
var container = isContainer(gHistoryTree, currentIndex);
return (event.button == 0 &&
event.originalTarget.localName == 'outlinerchildren' &&
event.originalTarget.localName == 'treechildren' &&
!container && gHistoryStatus);
}
function collapseExpand()
{
var currentIndex = gHistoryOutliner.currentIndex;
gHistoryOutliner.outlinerBoxObject.view.toggleOpenState(currentIndex);
var currentIndex = gHistoryTree.currentIndex;
gHistoryTree.treeBoxObject.view.toggleOpenState(currentIndex);
}
function OpenURL(aInNewWindow)
{
var currentIndex = gHistoryOutliner.currentIndex;
var builder = gHistoryOutliner.builder.QueryInterface(Components.interfaces.nsIXULOutlinerBuilder);
var currentIndex = gHistoryTree.currentIndex;
var builder = gHistoryTree.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder);
var url = builder.getResourceAtIndex(currentIndex).Value;
if (aInNewWindow) {
var count = gHistoryOutliner.outlinerBoxObject.view.selection.count;
var count = gHistoryTree.treeBoxObject.view.selection.count;
if (count == 1) {
if (isContainer(gHistoryOutliner, currentIndex))
if (isContainer(gHistoryTree, currentIndex))
openDialog("chrome://communicator/content/history/history.xul",
"", "chrome,all,dialog=no", url, "newWindow");
else
@ -286,11 +286,11 @@ function OpenURL(aInNewWindow)
else {
var min = new Object();
var max = new Object();
var rangeCount = gHistoryOutliner.outlinerBoxObject.view.selection.getRangeCount();
var rangeCount = gHistoryTree.treeBoxObject.view.selection.getRangeCount();
for (var i = 0; i < rangeCount; ++i) {
gHistoryOutliner.outlinerBoxObject.view.selection.getRangeAt(i, min, max);
gHistoryTree.treeBoxObject.view.selection.getRangeAt(i, min, max);
for (var k = max.value; k >= min.value; --k) {
url = gHistoryOutliner.outlinerBoxObject.view.getCellText(k, "URL");
url = gHistoryTree.treeBoxObject.view.getCellText(k, "URL");
window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", url);
}
}
@ -303,18 +303,18 @@ function OpenURL(aInNewWindow)
function GroupBy(groupingType)
{
var outliner = document.getElementById("historyOutliner");
var tree = document.getElementById("historyTree");
switch(groupingType) {
case "none":
outliner.setAttribute("ref", "NC:HistoryRoot");
tree.setAttribute("ref", "NC:HistoryRoot");
break;
case "site":
// xxx for now
outliner.setAttribute("ref", "NC:HistoryByDate");
tree.setAttribute("ref", "NC:HistoryByDate");
break;
case "day":
default:
outliner.setAttribute("ref", "NC:HistoryByDate");
tree.setAttribute("ref", "NC:HistoryByDate");
break;
}
gPrefService.setCharPref("browser.history.grouping", groupingType);
@ -332,24 +332,24 @@ var groupObserver = {
function historyAddBookmarks()
{
var count = gHistoryOutliner.outlinerBoxObject.view.selection.count;
var count = gHistoryTree.treeBoxObject.view.selection.count;
var url;
var title;
if (count == 1) {
var currentIndex = gHistoryOutliner.currentIndex;
url = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "URL");
title = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "Name");
var currentIndex = gHistoryTree.currentIndex;
url = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL");
title = gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "Name");
BookmarksUtils.addBookmark(url, title, undefined, true);
}
else if (count > 1) {
var min = new Object();
var max = new Object();
var rangeCount = gHistoryOutliner.outlinerBoxObject.view.selection.getRangeCount();
var rangeCount = gHistoryTree.treeBoxObject.view.selection.getRangeCount();
for (var i = 0; i < rangeCount; ++i) {
gHistoryOutliner.outlinerBoxObject.view.selection.getRangeAt(i, min, max);
gHistoryTree.treeBoxObject.view.selection.getRangeAt(i, min, max);
for (var k = max.value; k >= min.value; --k) {
url = gHistoryOutliner.outlinerBoxObject.view.getCellText(k, "URL");
title = gHistoryOutliner.outlinerBoxObject.view.getCellText(k, "Name");
url = gHistoryTree.treeBoxObject.view.getCellText(k, "URL");
title = gHistoryTree.treeBoxObject.view.getCellText(k, "Name");
BookmarksUtils.addBookmark(url, title, undefined, false);
}
}
@ -359,7 +359,7 @@ function historyAddBookmarks()
function updateItems()
{
var count = gHistoryOutliner.outlinerBoxObject.view.selection.count;
var count = gHistoryTree.treeBoxObject.view.selection.count;
var openItem = document.getElementById("miOpen");
var bookmarkItem = document.getElementById("miAddBookmark");
var copyLocationItem = document.getElementById("miCopyLinkLocation");
@ -371,11 +371,11 @@ function updateItems()
if (gHistoryGrouping == "day") {
var min = new Object();
var max = new Object();
var rangeCount = gHistoryOutliner.outlinerBoxObject.view.selection.getRangeCount();
var rangeCount = gHistoryTree.treeBoxObject.view.selection.getRangeCount();
for (var i = 0; i < rangeCount; ++i) {
gHistoryOutliner.outlinerBoxObject.view.selection.getRangeAt(i, min, max);
gHistoryTree.treeBoxObject.view.selection.getRangeAt(i, min, max);
for (var k = max.value; k >= min.value; --k) {
if (isContainer(gHistoryOutliner, k)) {
if (isContainer(gHistoryTree, k)) {
hasContainer = true;
break;
}
@ -403,8 +403,8 @@ function updateItems()
}
else {
bookmarkItem.setAttribute("label", document.getElementById('oneBookmark').getAttribute("label"));
var currentIndex = gHistoryOutliner.currentIndex;
if (isContainer(gHistoryOutliner, currentIndex)) {
var currentIndex = gHistoryTree.currentIndex;
if (isContainer(gHistoryTree, currentIndex)) {
openItem.setAttribute("hidden", "true");
openItem.removeAttribute("default");
collapseExpandItem.removeAttribute("hidden");
@ -412,7 +412,7 @@ function updateItems()
bookmarkItem.setAttribute("hidden", "true");
copyLocationItem.setAttribute("hidden", "true");
sep1.setAttribute("hidden", "true");
if (isContainerOpen(gHistoryOutliner, currentIndex))
if (isContainerOpen(gHistoryTree, currentIndex))
collapseExpandItem.setAttribute("label", gHistoryBundle.getString("collapseLabel"));
else
collapseExpandItem.setAttribute("label", gHistoryBundle.getString("expandLabel"));

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

@ -20,8 +20,8 @@
* Contributor(s):
*/
function DeleteAllFromOutliner
(outliner, view, table, deletedTable, removeButton, removeAllButton) {
function DeleteAllFromTree
(tree, view, table, deletedTable, removeButton, removeAllButton) {
// remove all items from table and place in deleted table
for (var i=0; i<table.length; i++) {
@ -30,11 +30,11 @@ function DeleteAllFromOutliner
table.length = 0;
// clear out selections
outliner.outlinerBoxObject.view.selection.select(-1);
tree.treeBoxObject.view.selection.select(-1);
// redisplay
view.rowCount = 0;
outliner.outlinerBoxObject.invalidate();
tree.treeBoxObject.invalidate();
// disable buttons
@ -42,11 +42,11 @@ function DeleteAllFromOutliner
document.getElementById(removeAllButton).setAttribute("disabled","true");
}
function DeleteSelectedItemFromOutliner
(outliner, view, table, deletedTable, removeButton, removeAllButton) {
function DeleteSelectedItemFromTree
(tree, view, table, deletedTable, removeButton, removeAllButton) {
// remove selected items from list (by setting them to null) and place in deleted list
var selections = GetOutlinerSelections(outliner);
var selections = GetTreeSelections(tree);
for (var s=selections.length-1; s>= 0; s--) {
var i = selections[s];
deletedTable[deletedTable.length] = table[i];
@ -65,7 +65,7 @@ function DeleteSelectedItemFromOutliner
}
// redisplay
var box = outliner.outlinerBoxObject;
var box = tree.treeBoxObject;
var firstRow = box.getFirstVisibleRow();
if (firstRow > (table.length-1) ) {
firstRow = table.length-1;
@ -80,8 +80,8 @@ function DeleteSelectedItemFromOutliner
// update selection
// note: we need to deselect before reselecting in order to trigger ...Selected method
var nextSelection = (selections[0] < table.length) ? selections[0] : table.length-1;
outliner.outlinerBoxObject.view.selection.select(-1);
outliner.outlinerBoxObject.view.selection.select(nextSelection);
tree.treeBoxObject.view.selection.select(-1);
tree.treeBoxObject.view.selection.select(nextSelection);
} else {
@ -90,13 +90,13 @@ function DeleteSelectedItemFromOutliner
document.getElementById(removeAllButton).setAttribute("disabled","true");
// clear out selections
outliner.outlinerBoxObject.view.selection.select(-1);
tree.treeBoxObject.view.selection.select(-1);
}
}
function GetOutlinerSelections(outliner) {
function GetTreeSelections(tree) {
var selections = [];
var select = outliner.outlinerBoxObject.selection;
var select = tree.treeBoxObject.selection;
if (select) {
var count = select.getRangeCount();
var min = new Object();
@ -113,10 +113,10 @@ function GetOutlinerSelections(outliner) {
return selections;
}
function SortOutliner(outliner, view, table, column, lastSortColumn, lastSortAscending) {
function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending) {
// remember which item was selected so we can restore it after the sort
var selections = GetOutlinerSelections(outliner);
var selections = GetTreeSelections(tree);
var selectedNumber = selections.length ? table[selections[0]].number : -1;
// determine if sort is to be ascending or descending
@ -132,8 +132,8 @@ function SortOutliner(outliner, view, table, column, lastSortColumn, lastSortAsc
if (table[s].number == selectedNumber) {
// update selection
// note: we need to deselect before reselecting in order to trigger ...Selected()
outliner.outlinerBoxObject.view.selection.select(-1);
outliner.outlinerBoxObject.view.selection.select(s);
tree.treeBoxObject.view.selection.select(-1);
tree.treeBoxObject.view.selection.select(s);
selectedRow = s;
break;
}
@ -141,9 +141,9 @@ function SortOutliner(outliner, view, table, column, lastSortColumn, lastSortAsc
}
// display the results
outliner.outlinerBoxObject.invalidate();
tree.treeBoxObject.invalidate();
if (selectedRow>0) {
outliner.outlinerBoxObject.ensureRowIsVisible(selectedRow)
tree.treeBoxObject.ensureRowIsVisible(selectedRow)
}
return ascending;

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

@ -1,9 +1,8 @@
function searchResultsOpenURL(event)
{
var node = event.target.parentNode.parentNode;
if (node.localName != "treeitem" || node.getAttribute('container') == "true")
return false;
var tree = document.getElementById("resultsList");
var node = tree.contentView.getItemAtIndex(tree.currentIndex);
var url = node.id;
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
@ -42,7 +41,7 @@ function onLoadInternetResults()
.getService(Components.interfaces.nsIInternetSearchService);
iSearch.ClearResultSearchSites();
// the search URI is passed in as a parameter, so get it and them root the results tree
// the search URI is passed in as a parameter, so get it and them root the results list
var searchURI = top._content.location.href;
if (searchURI) {
const lastSearchURIPref = "browser.search.lastMultipleSearchURI";
@ -50,7 +49,7 @@ function onLoadInternetResults()
if (offset > 0) {
nsPreferences.setUnicharPref(lastSearchURIPref, searchURI); // evil
searchURI = searchURI.substr(offset+1);
loadResultsTree(searchURI);
loadResultsList(searchURI);
}
else {
searchURI = nsPreferences.copyUnicharPref(lastSearchURIPref, "");
@ -58,16 +57,16 @@ function onLoadInternetResults()
if (offset > 0) {
nsPreferences.setUnicharPref(lastSearchURIPref, searchURI); // evil
searchURI = searchURI.substr(offset+1);
loadResultsTree(searchURI);
loadResultsList(searchURI);
}
}
}
return true;
}
function loadResultsTree( aSearchURL )
function loadResultsList( aSearchURL )
{
var resultsTree = document.getElementById( "internetresultstree" );
var resultsTree = document.getElementById( "resultsList" );
if (!resultsTree) return false;
resultsTree.setAttribute("ref", unescape(aSearchURL));
return true;
@ -81,7 +80,7 @@ function doEngineClick( event, aNode )
var html = null;
var resultsTree = document.getElementById("internetresultstree");
var resultsTree = document.getElementById("resultsList");
var contentArea = document.getElementById("content");
var splitter = document.getElementById("results-splitter");
var engineURI = aNode.id;
@ -192,18 +191,17 @@ function doResultClick(node)
return(true);
}
function treeSelect(event)
function listSelect(event)
{
if (!event.target.selectedItems ||
event.target.selectedItems && event.target.selectedItems.length != 1)
var tree = document.getElementById("resultsList");
if (tree.view.selection.count != 1)
return false;
doResultClick(event.target.selectedItems[0]);
var selection = tree.contentView.getItemAtIndex(tree.currentIndex);
doResultClick(selection);
}
function treeClick(event)
function listClick(event)
{
if (event.detail == 2 && event.button == 0)
searchResultsOpenURL(event);
else
treeSelect(event);
}

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

@ -2,7 +2,6 @@
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/search/search.css" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/search/internetresults.css" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/search/icons.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/search/internetresults.dtd">
@ -43,122 +42,81 @@
<separator orient="vertical" class="thin"/>
</hbox>
<popupset>
<popup id="contextual" onpopupshowing="return fillContextMenu('contextual', 'internetresultstree');" >
<menu/>
</popup>
</popupset>
<tree id="internetresultstree" ref="" flex="1" datasources="rdf:internetsearch" context="contextual"
onselect="treeSelect(event);" onclick="treeClick(event);">
<menupopup id="contextual" onpopupshowing="return fillContextMenu('contextual', 'resultsList');"/>
<tree id="resultsList" flex="1" class="plain"
datasources="rdf:internetsearch" context="contextual"
onselect="listSelect(event);"
onclick="listClick(event);">
<treecolgroup>
<treecol id="NameColumn" resource="http://home.netscape.com/NC-rdf#Name" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="PageRankColumn" resource="http://home.netscape.com/NC-rdf#PageRank"
resource2="http://home.netscape.com/NC-rdf#Name" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="RelevanceColumn" resource="http://home.netscape.com/NC-rdf#Relevance"
resource2="http://home.netscape.com/NC-rdf#Name"
hidden="true" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="PriceColumn" resource="http://home.netscape.com/NC-rdf#Price"
resource2="http://home.netscape.com/NC-rdf#Availability"
hidden="true" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="AvailabilityColumn" resource="http://home.netscape.com/NC-rdf#Availability"
resource2="http://home.netscape.com/NC-rdf#Price"
hidden="true" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="DateColumn" resource="http://home.netscape.com/NC-rdf#Date"
resource2="http://home.netscape.com/NC-rdf#Name"
hidden="true" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="SiteColumn" resource="http://home.netscape.com/NC-rdf#Site"
resource2="http://home.netscape.com/NC-rdf#Name" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="EngineColumn" resource="http://home.netscape.com/NC-rdf#Engine"
resource2="http://home.netscape.com/NC-rdf#Name" flex="1"/>
</treecolgroup>
<treecols onclick="doSort(event.target.id, 'http://home.netscape.com/NC-rdf#PageRank');">
<treecol id="NameColumn" primary="true" label="&name.column.label;"
resource="http://home.netscape.com/NC-rdf#Name" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="PageRankColumn" label="&pagerank.column.label;"
resource="http://home.netscape.com/NC-rdf#PageRank"
resource2="http://home.netscape.com/NC-rdf#Name" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="RelevanceColumn" label="&relevance.column.label;"
resource="http://home.netscape.com/NC-rdf#Relevance"
resource2="http://home.netscape.com/NC-rdf#Name"
hidden="true" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="PriceColumn" label="&price.column.label;"
resource="http://home.netscape.com/NC-rdf#Price"
resource2="http://home.netscape.com/NC-rdf#Availability"
hidden="true" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="AvailabilityColumn" label="&availability.column.label;"
resource="http://home.netscape.com/NC-rdf#Availability"
resource2="http://home.netscape.com/NC-rdf#Price"
hidden="true" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="DateColumn" label="&date.column.label;"
resource="http://home.netscape.com/NC-rdf#Date"
resource2="http://home.netscape.com/NC-rdf#Name"
hidden="true" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="SiteColumn" label="&site.column.label;"
resource="http://home.netscape.com/NC-rdf#Site"
resource2="http://home.netscape.com/NC-rdf#Name" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="EngineColumn" label="&engine.column.label;"
resource="http://home.netscape.com/NC-rdf#Engine"
resource2="http://home.netscape.com/NC-rdf#Name" flex="1"/>
</treecols>
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
<treechildren flex="1">
<treeitem uri="..." rdf:type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type">
<treerow>
<treecell>
<separator class="groove"/>
</treecell>
</treerow>
</treeitem>
</treechildren>
<treeseparator uri="..."/>
</rule>
<rule>
<treechildren flex="1">
<treeitem uri="..." rdf:type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type">
<treechildren>
<treeitem uri="...">
<treerow>
<treecell class="treecell-iconic" crop="right"
src="rdf:http://home.netscape.com/NC-rdf#Icon"
<treecell src="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name" />
<treecell crop="right" label="rdf:http://home.netscape.com/NC-rdf#PageRank" />
<treecell>
<progressmeter orient="horizontal" value="rdf:http://home.netscape.com/NC-rdf#Relevance" mode="normal" />
<label crop="right" value="rdf:http://home.netscape.com/NC-rdf#Relevance"/>
</treecell>
<treecell crop="right" label="rdf:http://home.netscape.com/NC-rdf#Price" />
<treecell crop="right" label="rdf:http://home.netscape.com/NC-rdf#Availability" />
<treecell crop="right" label="rdf:http://home.netscape.com/NC-rdf#Date" />
<treecell crop="right" label="rdf:http://home.netscape.com/NC-rdf#Site" />
<treecell crop="right" label="rdf:http://home.netscape.com/NC-rdf#Engine" />
<treecell label="rdf:http://home.netscape.com/NC-rdf#PageRank"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#Relevance"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#Price"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#Availability"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#Date"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#Site"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#Engine"/>
</treerow>
</treeitem>
</treechildren>
</rule>
</template>
<treehead>
<treerow>
<treecell id="NameCell" class="treecell-header sortDirectionIndicator"
label="&name.column.label;" observes="NameColumn"
resource="http://home.netscape.com/NC-rdf#Name"
onclick="return doSort('NameColumn', null);" />
<treecell id="PageRankCell" class="treecell-header sortDirectionIndicator"
label="&pagerank.column.label;" observes="PageRankColumn"
resource="http://home.netscape.com/NC-rdf#PageRank"
onclick="return doSort('PageRankColumn', null);" />
<treecell id="RelevanceCell" class="treecell-header sortDirectionIndicator"
label="&relevance.column.label;" observes="RelevanceColumn"
resource="http://home.netscape.com/NC-rdf#Relevance"
onclick="return doSort('RelevanceColumn', null);" />
<treecell id="PriceCell" class="treecell-header sortDirectionIndicator"
label="&price.column.label;" observes="PriceColumn"
resource="http://home.netscape.com/NC-rdf#Price"
onclick="return doSort('PriceColumn', null);" />
<treecell id="AvailabilityCell" class="treecell-header sortDirectionIndicator"
label="&availability.column.label;" observes="AvailabilityColumn"
resource="http://home.netscape.com/NC-rdf#Availability"
onclick="return doSort('AvailabilityColumn', null);" />
<treecell id="DateCell" class="treecell-header sortDirectionIndicator"
label="&date.column.label;" observes="DateColumn"
resource="http://home.netscape.com/NC-rdf#Date"
onclick="return doSort('DateColumn', null);" />
<treecell id="SiteCell" class="treecell-header sortDirectionIndicator"
label="&site.column.label;" observes="SiteColumn"
resource="http://home.netscape.com/NC-rdf#Site"
onclick="return doSort('SiteColumn', null);" />
<treecell id="EngineCell" class="treecell-header sortDirectionIndicator"
label="&engine.column.label;" observes="EngineColumn"
resource="http://home.netscape.com/NC-rdf#Engine"
onclick="return doSort('EngineColumn', null);" />
</treerow>
</treehead>
</tree>
<splitter id="results-splitter" persist="state" collapse="after">
<grippy/>
</splitter>
<hbox class="double-box-top" flex="1">
<hbox flex="1">
<iframe id="content" flex="1" src="chrome://communicator/locale/search/default.htm"/>
</hbox>

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

@ -433,23 +433,29 @@ function MoveDelta(delta)
function doMoveDirectionEnabling()
{
var tree = document.getElementById("engineList")
var selectedItems = tree.selectedItems;
if (!selectedItems && selectedItems.length != 1)
return false;
var ref = tree.getAttribute("ref");
var categoryResource = RDF.GetResource(ref);
var elementResource = RDF.GetResource(selectedItems[0].id);
RDFC.Init(catDS, categoryResource);
var nodeIndex = RDFC.IndexOf(elementResource);
var engineList = document.getElementById("engineList")
var selectedItems = engineList.selectedItems;
var nodeIndex = -1;
if (selectedItems && selectedItems.length == 1) {
var ref = engineList.getAttribute("ref");
var categoryResource = RDF.GetResource(ref);
var elementResource = RDF.GetResource(selectedItems[0].id);
RDFC.Init(catDS, categoryResource);
nodeIndex = RDFC.IndexOf(elementResource);
}
var moveUpButton = document.getElementById("up");
var moveDownButton = document.getElementById("down");
moveUpButton.removeAttribute("disabled");
moveDownButton.removeAttribute("disabled");
if (nodeIndex <= 1)
moveUpButton.setAttribute("disabled", "true");
if (nodeIndex >= RDFC.GetCount())
else
moveUpButton.removeAttribute("disabled");
if (nodeIndex < 0 || nodeIndex >= RDFC.GetCount())
moveDownButton.setAttribute("disabled", "true");
else
moveDownButton.removeAttribute("disabled");
}
@ -596,15 +602,15 @@ function RemoveCategory()
function selectItems(treeRoot, containerID, targetID)
function selectItems(listbox, containerID, targetID)
{
var select_list = treeRoot.getElementsByAttribute("id", targetID);
var select_list = listbox.getElementsByAttribute("id", targetID);
for (var x=0; x<select_list.length; x++)
{
var node = select_list[x];
if (!node) continue;
var parent = node.parentNode.parentNode;
var parent = node.parentNode;
if (!parent) continue;
var id = parent.getAttribute("ref");
@ -616,7 +622,7 @@ function selectItems(treeRoot, containerID, targetID)
if (id == containerID)
{
treeRoot.selectItem(node);
listbox.selectItem(node);
break;
}
}

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

@ -47,34 +47,25 @@
<hbox flex="1">
<vbox flex="1">
<tree seltype="multiple" flex="1" id="allengines" ref="NC:SearchEngineRoot" datasources="rdf:internetsearch">
<template>
<treechildren>
<treeitem uri="..." loading="rdf:http://home.netscape.com/NC-rdf#loading">
<treerow>
<treecell class="treecell-indent" crop="right"
src="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name" />
</treerow>
</treeitem>
</treechildren>
</template>
<treecolgroup>
<treecol id="NameColumn" resource="http://home.netscape.com/NC-rdf#Name" sortActive="true" sortDirection="ascending" flex="1"/>
</treecolgroup>
<treehead>
<treerow>
<treecell class="treecell-header sortDirectionIndicator outset" observes="NameColumn"
label="&allengines.label;" resource="http://home.netscape.com/NC-rdf#Name"
<listbox id="allengines" seltype="multiple" flex="1"
datasources="rdf:internetsearch" ref="NC:SearchEngineRoot">
<listhead>
<listheader id="NameColumn" sortable="true"
label="&allengines.label;" flex="1"
resource="http://home.netscape.com/NC-rdf#Name"
sortActive="true" sortDirection="ascending"
onclick="return doSort('NameColumn', null);" />
</treerow>
</treehead>
</listhead>
<treechildren flex="1"/>
</tree>
<template>
<listitem uri="..." class="listitem-iconic"
loading="rdf:http://home.netscape.com/NC-rdf#loading"
image="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
</template>
</listbox>
<hbox>
<button id="add-button" oncommand="return AddEngine()" label="&add.label;" />
</hbox>
@ -106,32 +97,25 @@
<separator class="thin"/>
<hbox flex="1">
<tree seltype="multiple" flex="1" id="engineList" style="height: 0px;"
datasources="rdf:internetsearch" onselect="doMoveDirectionEnabling()">
<listbox id="engineList" seltype="multiple" flex="1"
style="height: 0px;"
datasources="rdf:internetsearch"
onselect="doMoveDirectionEnabling()">
<listhead>
<listheader id="EngineColumn" sortable="true"
label="&engine.column.label;" flex="1"
onclick="return doSort('EngineColumn', null);"
resource="http://home.netscape.com/NC-rdf#Name"/>
</listhead>
<template>
<treechildren>
<treeitem uri="...">
<treerow>
<treecell class="treecell-iconic" crop="right"
src="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name" flex="1" />
</treerow>
</treeitem>
</treechildren>
<listitem uri="..." class="listitem-iconic"
image="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
</template>
<treecol id="EngineColumn" resource="http://home.netscape.com/NC-rdf#Name" flex="1" />
<treehead>
<treerow>
<treecell class="treecell-header sortDirectionIndicator outset" observes="EngineColumn"
label="&engine.column.label;" onclick="return doSort('EngineColumn', null);"
resource="http://home.netscape.com/NC-rdf#Name" />
</treerow>
</treehead>
<treechildren flex="1"/>
</tree>
</listbox>
<vbox>
<spacer flex="1"/>
<button class="up" oncommand="MoveUp();" id="up" disabled="true"/>

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

@ -404,8 +404,8 @@ function SearchPanelStartup()
ensureSearchPref()
var tree = document.getElementById("Tree");
tree.database.AddObserver(RDF_observer);
var resultList = document.getElementById("resultList");
resultList.database.AddObserver(RDF_observer);
var categoryList = document.getElementById("categoryList");
var internetSearch = Components.classes[ISEARCH_CONTRACTID].getService(nsIInternetSearchService);
@ -416,11 +416,11 @@ function SearchPanelStartup()
var ref = categoryList.getAttribute("ref");
if (ref)
categoryList.setAttribute("ref", ref);
var engineTree = document.getElementById("searchengines");
engineTree.database.AddDataSource(catDS);
ref = engineTree.getAttribute("ref");
var engineList = document.getElementById("searchengines");
engineList.database.AddDataSource(catDS);
ref = engineList.getAttribute("ref");
if (ref)
engineTree.setAttribute("ref", ref);
engineList.setAttribute("ref", ref);
}
// try and determine last category name used
@ -471,7 +471,7 @@ function SearchPanelStartup()
function haveSearchResults()
{
var ds = document.getElementById("Tree").database;
var ds = document.getElementById("resultList").database;
if (!ds)
return false;
@ -494,8 +494,8 @@ function haveSearchResults()
function getNumEngines()
{
var treeChildrenNode = document.getElementById("engineKids");
return treeChildrenNode.childNodes.length;
var listbox = document.getElementById("searchengines");
return listbox.getElementsByTagName("listitem").length;
}
function chooseCategory(aNode)
@ -524,24 +524,20 @@ function saveEngines()
if (!localStore)
return;
var engineBox = document.getElementById("engineKids");
var engineItems = document.getElementById("searchengines").getElementsByTagName("listitem");
var checkedProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#checked", true);
var categorySRC = rdf.GetResource(category, true);
for (var x = 0; x < engineBox.childNodes.length; ++x) {
var treeitemNode = engineBox.childNodes[x];
for (var x = 0; x < engineItems.length; ++x) {
var itemNode = engineItems[x];
var engineURI = itemNode.getAttribute("id");
var engineSRC = rdf.GetResource(engineURI, true);
var checkboxNode = treeitemNode.firstChild.firstChild.firstChild;
if (checkboxNode) {
var engineURI = treeitemNode.getAttribute("id");
var engineSRC = rdf.GetResource(engineURI, true);
if (checkboxNode.checked)
localStore.Assert(categorySRC, checkedProperty, engineSRC, true);
else
localStore.Unassert(categorySRC, checkedProperty, engineSRC, true);
}
if (itemNode.checked)
localStore.Assert(categorySRC, checkedProperty, engineSRC, true);
else
localStore.Unassert(categorySRC, checkedProperty, engineSRC, true);
}
// save changes; flush out the localstore
@ -558,20 +554,19 @@ function loadEngines(aCategory)
var rdf = Components.classes[RDFSERVICE_CONTRACTID].getService(nsIRDFService);
var localStore = rdf.GetDataSource("rdf:local-store");
if (localStore) {
var engineBox = document.getElementById("engineKids");
var engineBox = document.getElementById("searchengines");
var numEngines = engineBox.childNodes.length;
var checkedProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#checked", true);
var categorySRC = rdf.GetResource(aCategory, true);
for (var x = 0; x < numEngines; ++x) {
var treeitemNode = engineBox.childNodes[x];
var engineURI = treeitemNode.getAttribute("id");
var engineSRC = rdf.GetResource(engineURI, true);
var checkboxNode = treeitemNode.firstChild.firstChild.firstChild;
if (checkboxNode) {
var listitemNode = engineBox.childNodes[x];
if (listitemNode.localName == "listitem") {
var engineURI = listitemNode.getAttribute("id");
var engineSRC = rdf.GetResource(engineURI, true);
var hasAssertion = localStore.HasAssertion(categorySRC, checkedProperty, engineSRC, true);
if (hasAssertion)
checkboxNode.checked = true;
listitemNode.checked = true;
}
}
}
@ -585,7 +580,7 @@ function focusTextBox()
function SearchPanelShutdown()
{
var tree = document.getElementById("Tree");
var tree = document.getElementById("resultList");
tree.database.RemoveObserver(RDF_observer);
}
@ -609,11 +604,11 @@ function doStop()
// show appropriate column(s)
var navWindow = getNavigatorWindow(false);
var resultsTree = navWindow ? navWindow._content.document.getElementById("internetresultstree") : null;
if (!resultsTree)
var resultsList = navWindow ? navWindow._content.document.getElementById("resultsList") : null;
if (!resultsList)
return;
var searchURL = resultsTree.getAttribute("ref");
var searchURL = resultsList.getAttribute("ref");
if (!searchURL)
return;
@ -709,24 +704,20 @@ function doSearch()
var engineURIs = [];
if (searchMode > 0) {
var foundEngine = false;
var treeitemNode;
var engineBox = document.getElementById("engineKids");
var itemNode;
var engineBox = document.getElementById("searchengines");
// in advanced search mode, get selected search engines
// (for the current search category)
for (var x = 0; x < engineBox.childNodes.length; x++) {
treeitemNode = engineBox.childNodes[x];
for (var x = 0; x < engineBox.childNodes.length; ++x) {
itemNode = engineBox.childNodes[x];
if (treeitemNode) {
var checkboxNode = treeitemNode.firstChild.firstChild.firstChild;
if (itemNode.localName == "listitem" && itemNode.checked) {
var engineURI = itemNode.id;
if (checkboxNode && checkboxNode.checked) {
var engineURI = treeitemNode.id;
if (engineURI) {
engineURIs[engineURIs.length] = engineURI;
foundEngine = true;
}
if (engineURI) {
engineURIs[engineURIs.length] = engineURI;
foundEngine = true;
}
}
}
@ -734,13 +725,13 @@ function doSearch()
if (!foundEngine) {
if (getNumEngines() == 1) {
// only one engine in this category, check it
treeitemNode = engineBox.firstChild;
engineURIs[engineURIs.length] = treeitemNode.id;
itemNode = engineBox.firstChild;
engineURIs[engineURIs.length] = itemNode.id;
}
else {
for (var i = 0; i < engineBox.childNodes.length; ++i) {
treeitemNode = engineBox.childNodes[i];
var theID = treeitemNode.id;
itemNode = engineBox.childNodes[i];
var theID = itemNode.id;
if (theID.indexOf("NetscapeSearch.src") != -1) {
engineURIs[engineURIs.length] = theID;
foundEngine = true;
@ -784,10 +775,10 @@ function checkSearchProgress()
var navWindow = getNavigatorWindow(false);
if (navWindow) {
var resultsTree = navWindow._content.document.getElementById("internetresultstree");
if (resultsTree) {
var treeref = resultsTree.getAttribute("ref");
var ds = resultsTree.database;
var resultsList = navWindow._content.document.getElementById("resultsList");
if (resultsList) {
var treeref = resultsList.getAttribute("ref");
var ds = resultsList.database;
if (ds && treeref) {
try {
var rdf = Components.classes[RDFSERVICE_CONTRACTID].getService(nsIRDFService);
@ -813,21 +804,16 @@ function checkSearchProgress()
return activeSearchFlag;
}
function sidebarOpenURL(treeitem)
function sidebarOpenURL(listitem)
{
if (treeitem.getAttribute("container") == "true" ||
treeitem.getAttribute("type") == "http://home.netscape.com/NC-rdf#BookmarkSeparator") {
return;
}
var id = treeitem.id;
var id = listitem.id;
if (!id)
return;
// rjc: add support for anonymous resources; if the node has
// a "#URL" property, use it, otherwise default to using the id
try {
var ds = document.getElementById("Tree").database;
var ds = document.getElementById("resultList").database;
if (ds) {
var rdf = Components.classes[RDFSERVICE_CONTRACTID].getService(nsIRDFService);
var src = rdf.GetResource(id, true);
@ -843,7 +829,7 @@ function sidebarOpenURL(treeitem)
}
// mark result as visited
treeitem.firstChild.firstChild.setAttribute("visited", "true");
listitem.setAttribute("visited", "true");
loadURLInContent(id);
}
@ -925,7 +911,7 @@ function switchTab(aPageIndex)
if (aPageIndex != 0)
return;
var ds = document.getElementById("Tree").database;
var ds = document.getElementById("resultList").database;
if (!ds)
return;
@ -945,7 +931,7 @@ function switchTab(aPageIndex)
function saveSearch()
{
var ds = document.getElementById("Tree").database;
var ds = document.getElementById("resultList").database;
if (!ds)
return;
@ -1138,7 +1124,7 @@ function getArcValueForID(aArc, aID)
try
{
var ds = document.getElementById("Tree").database;
var ds = document.getElementById("resultList").database;
if (ds)
{
var rdf = Components.classes[RDFSERVICE_CONTRACTID].
@ -1165,16 +1151,11 @@ function FillInDescTooltip(tipElement)
{
var retValue = false;
//Get the cell node and the tree item node of
//moused over sherlock result
var nodeTreeCell = getItemNode(tipElement, "treecell");
var nodeTreeitem = getItemNode(tipElement, "treeitem");
//Get the Name of the listitem for first item in the tooltip
var nodeLabel = tipElement.getAttribute("label");
var nodeID = tipElement.id;
//Get the Name of the tree cell for first item in the tooltip
var nodeLabel = nodeTreeCell.childNodes.item(1).getAttribute("value");
var nodeID = nodeTreeitem.id;
//Query RDF to get URL of tree item
//Query RDF to get URL of listitem
if (nodeID)
var url = getArcValueForID("URL", nodeID);
@ -1210,7 +1191,7 @@ var nsResultDNDObserver =
{
onDragStart: function(aEvent, aXferData, aDragAction)
{
var node = getItemNode(aEvent.target, "treeitem");
var node = getItemNode(aEvent.target, "listitem");
var URL = getArcValueForID("URL", node.id);
var title = getArcValueForID("Name", node.id);
var htmlString = "<a href=\"" + URL + "\">" + title + "</a>";

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

@ -26,7 +26,7 @@
<?xml-stylesheet href="chrome://communicator/skin/search/search.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/search/search-panel.dtd" >
<page id="searchPanel"
<window id="searchPanel"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
orient="vertical" onload="SearchPanelStartup();"
@ -45,7 +45,7 @@
<stringbundle id="regionalBundle" src="chrome://communicator-region/locale/region.properties"/>
<popupset>
<popup id="contextual" onpopupshowing="return fillContextMenu('contextual', 'Tree');" >
<popup id="contextual" onpopupshowing="return fillContextMenu('contextual', 'resultList');" >
<menu />
</popup>
</popupset>
@ -121,64 +121,32 @@
<deck class="outset-right" id="advancedDeck" flex="1">
<vbox class="searchpanel-outerbox" flex="1">
<tree id="Tree" ref="NC:LastSearchRoot" class="sidebarTree"
<listbox id="resultList" ref="NC:LastSearchRoot" class="plain"
resource="http://home.netscape.com/NC-rdf#PageRank"
resource2="http://home.netscape.com/NC-rdf#Name"
sortDirection="ascending" sortActive="true"
flex="1" datasources="rdf:internetsearch"
onclick="if (event.button == 0 &amp;&amp; event.target.localName == 'treecell') sidebarOpenURL(event.target.parentNode.parentNode);"
ondraggesture="if (event.target.localName == 'treecell') HandleResultDragGesture(event);"
onclick="if (event.button == 0 &amp;&amp; event.target.localName == 'listitem') sidebarOpenURL(event.target);"
ondraggesture="if (event.target.localName == 'listitem') HandleResultDragGesture(event);"
style="-moz-user-focus:ignore !important;">
<listhead>
<listheader id="SortNameColumn" label="&results.label;"
sortable="true" resource="http://home.netscape.com/NC-rdf#Name"
onclick="return doSort('SortNameColumn', 'http://home.netscape.com/NC-rdf#PageRank');" />
</listhead>
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
<treechildren flex="1">
<treeitem uri="...">
<treerow>
<treecell>
<separator class="groove"/>
</treecell>
</treerow>
</treeitem>
</treechildren>
</rule>
<rule>
<treechildren flex="1" context="contextual">
<treeitem uri="..." persist="open" class="searchresult-item"
loading="rdf:http://home.netscape.com/NC-rdf#loading"
searchtype="rdf:http://home.netscape.com/NC-rdf#SearchType"
type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type">
<treerow class="searchresult">
<treecell flex="0" class="text-link" tooltip="descTooltip">
<image class="tree-cell-icon"
src="rdf:http://home.netscape.com/NC-rdf#Icon"/>
<label value="rdf:http://home.netscape.com/NC-rdf#Name"/>
</treecell>
</treerow>
</treeitem>
</treechildren>
<listitem uri="..." class="listitem-iconic searchresult-item text-link"
context="contextual" flexlabel="0"
loading="rdf:http://home.netscape.com/NC-rdf#loading"
searchtype="rdf:http://home.netscape.com/NC-rdf#SearchType"
image="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name"
tooltip="descTooltip"/>
</rule>
</template>
<treehead>
<treerow>
<treecell class="treecell-header sortDirectionIndicator treecell-header-sidebarpanel"
observes="SortNameColumn" label="&results.label;"
resource="http://home.netscape.com/NC-rdf#Name"
onclick="return doSort('SortNameColumn', 'http://home.netscape.com/NC-rdf#PageRank');"
sortActive="true" sortDirection="ascending" flex="1"/>
</treerow>
</treehead>
<treecolgroup>
<treecol flex="1" id="SortNameColumn" resource="http://home.netscape.com/NC-rdf#Name"
resource2="http://home.netscape.com/NC-rdf#PageRank"/>
</treecolgroup>
</tree>
</listbox>
<hbox>
<button id="prev-results" label="&previous.button.label;"
@ -193,45 +161,26 @@
<vbox class="searchpanel-outerbox" flex="1">
<tree id="searchengines" datasources="rdf:internetsearch" flex="1" class="sidebarTree">
<listbox id="searchengines" flex="1" class="plain"
datasources="rdf:internetsearch"
onselect="saveEngines();">
<listhead>
<listheader id="EngineColumn" label="&engine.column.label;"
sortable="true" resource="http://home.netscape.com/NC-rdf#Name"
onclick="return doSort('EngineColumn', null);"/>
</listhead>
<template>
<rule>
<treechildren>
<treeitem uri="...">
<treerow>
<treecell align="center" flex="1">
<checkbox oncommand="saveEngines();" allowevents="true"
loading="rdf:http://home.netscape.com/NC-rdf#loading"
src="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name" flex="1"/>
</treecell>
</treerow>
</treeitem>
</treechildren>
<listitem uri="..." type="checkbox" class="listitem-iconic"
loading="rdf:http://home.netscape.com/NC-rdf#loading"
image="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
</rule>
</template>
<treecolgroup>
<treecol id="EngineColumn" resource="http://home.netscape.com/NC-rdf#Name" flex="1" />
</treecolgroup>
<treehead>
<treerow>
<treecell class="treecell-header sortDirectionIndicator treecell-header-sidebarpanel"
observes="EngineColumn" label="&engine.column.label;"
resource="http://home.netscape.com/NC-rdf#Name"
sortActive="true" sortDirection="ascending"
onclick="return doSort('EngineColumn', null);"/>
</treerow>
</treehead>
<treechildren flex="1" id="engineKids"/>
</tree>
</listbox>
</vbox>
</deck>
</vbox>
</page>
</window>

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

@ -43,8 +43,6 @@ var original_panels = new Array();
function sidebar_customize_init()
{
doSetOKCancel(Save);
allPanelsObj.datasources = window.arguments[0];
allPanelsObj.resource = window.arguments[1];
sidebarObj.datasource_uri = window.arguments[2];
@ -61,7 +59,6 @@ function sidebar_customize_init()
debug("Adding observer to all panels database.");
all_panels.database.AddObserver(panels_observer);
allPanelsObj.datasources = allPanelsObj.datasources.replace(/^\s+/,'');
allPanelsObj.datasources = allPanelsObj.datasources.replace(/\s+$/,'');
allPanelsObj.datasources = allPanelsObj.datasources.split(/\s+/);
@ -107,15 +104,20 @@ function sidebar_customize_init()
// the save button can be enabled when something changes.
function save_initial_panels()
{
var root = document.getElementById('current-panels-root');
for (var node = root.firstChild; node != null; node = node.nextSibling) {
original_panels[original_panels.length] = node.getAttribute('id');
var tree = document.getElementById('current-panels');
if (!tree.view) {
setTimeout(save_initial_panels, 0);
} else {
for (var i = 0; i < tree.view.rowCount; ++i) {
var item = tree.contentView.getItemAtIndex(i);
original_panels.push(item.id);
}
}
}
function sidebar_customize_destruct()
{
var all_panels = document.getElementById('other-panels');
var all_panels = document.getElementById('other-panels');
debug("Removing observer from all_panels database.");
all_panels.database.RemoveObserver(panels_observer);
}
@ -195,48 +197,26 @@ function SelectChangeForOtherPanels(event, target)
function ClickOnOtherPanels(event)
{
debug("ClickOnOtherPanels(...)");
var tree = document.getElementById("other-panels");
var rowIndex = -1;
if (event.type == "click" && event.button == 0) {
var row = {}, col = {}, obj = {};
var b = tree.treeBoxObject;
b.getCellAt(event.clientX, event.clientY, row, col, obj);
var t = event.originalTarget;
var treeitem = null;
var force_open = true;
if (t.getAttribute('twisty') == 'true') {
// The twisty is nested three below the treeitem:
// <treeitem>
// <treerow>
// <treecell>
// <image class="tree-cell-twisty"> <!-- anonymous -->
treeitem = t.parentNode.parentNode.parentNode;
force_open = false;
} else {
if (t.localName != "treecell" &&
t.localName != "treeitem")
return;
treeitem = t;
while (treeitem && treeitem.nodeName != 'treeitem') {
treeitem = treeitem.parentNode;
if (obj.value == "twisty" || event.detail == 2) {
rowIndex = row.value;
}
}
// Remove the selection in the "current" panels list
var current_panels = document.getElementById('current-panels');
current_panels.clearSelection();
enable_buttons_for_current_panels();
if (rowIndex < 0) return;
var treeitem = tree.contentView.getItemAtIndex(rowIndex);
var res = RDF.GetResource(treeitem.id);
if (treeitem.getAttribute('container') == 'true') {
if (treeitem.getAttribute('open') == 'true') {
if (force_open) {
debug("close the container");
treeitem.removeAttribute('open');
}
} else {
if (force_open) {
debug("open the container");
treeitem.setAttribute('open','true');
}
var link = treeitem.getAttribute('link');
var loaded_link = treeitem.getAttribute('loaded_link');
if (link != '' && !loaded_link) {
@ -248,6 +228,11 @@ function ClickOnOtherPanels(event)
}
}
}
// Remove the selection in the "current" panels list
var current_panels = document.getElementById('current-panels');
current_panels.treeBoxObject.selection.clearSelection();
enable_buttons_for_current_panels();
}
function add_datasource_to_other_panels(link) {
@ -275,7 +260,7 @@ function add_datasource_to_other_panels(link) {
function SelectChangeForCurrentPanels() {
// Remove the selection in the available panels list
var all_panels = document.getElementById('other-panels');
all_panels.clearSelection();
all_panels.treeBoxObject.selection.clearSelection();
enable_buttons_for_current_panels();
enable_buttons_for_other_panels();
@ -284,13 +269,15 @@ function SelectChangeForCurrentPanels() {
// Move the selected item up the the current panels list.
function MoveUp() {
var tree = document.getElementById('current-panels');
if (tree.selectedItems.length == 1) {
var selected = tree.selectedItems[0];
var before = selected.previousSibling
if (tree.treeBoxObject.selection.count == 1) {
var index = tree.currentIndex;
var selected = tree.contentView.getItemAtIndex(index);
var before = selected.previousSibling;
if (before) {
before.parentNode.removeChild(selected);
before.parentNode.insertBefore(selected, before);
tree.selectItem(selected);
tree.ensureElementIsVisible(selected);
tree.treeBoxObject.selection.select(index-1);
tree.treeBoxObject.ensureRowIsVisible(index-1);
}
}
enable_buttons_for_current_panels();
@ -299,17 +286,16 @@ function MoveUp() {
// Move the selected item down the the current panels list.
function MoveDown() {
var tree = document.getElementById('current-panels');
if (tree.selectedItems.length == 1) {
var selected = tree.selectedItems[0];
if (tree.treeBoxObject.selection.count == 1) {
var index = tree.currentIndex;
var selected = tree.contentView.getItemAtIndex(index);
if (selected.nextSibling) {
if (selected.nextSibling.nextSibling) {
if (selected.nextSibling.nextSibling)
selected.parentNode.insertBefore(selected, selected.nextSibling.nextSibling);
}
else {
else
selected.parentNode.appendChild(selected);
}
tree.selectItem(selected);
tree.ensureElementIsVisible(selected);
tree.treeBoxObject.selection.select(index+1);
tree.treeBoxObject.ensureRowIsVisible(index+1);
}
}
enable_buttons_for_current_panels();
@ -319,61 +305,58 @@ function PreviewPanel()
{
var tree = document.getElementById('other-panels');
var database = tree.database;
var select_list = tree.selectedItems
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++) {
var node = select_list[nodeIndex];
if (!node) break;
// Skip folders
if (node.getAttribute('container') == 'true') {
continue;
var sel = tree.treeBoxObject.selection;
var rangeCount = sel.getRangeCount();
for (var range = 0; range < rangeCount; ++range) {
var min = {}, max = {};
sel.getRangeAt(range, min, max);
for (var index = min.value; index <= max.value; ++index) {
var item = tree.contentView.getItemAtIndex(index);
var res = RDF.GetResource(item.id);
var preview_name = get_attr(database, res, 'title');
var preview_URL = get_attr(database, res, 'content');
if (!preview_URL || !preview_name) continue;
window.openDialog("chrome://communicator/content/sidebar/preview.xul",
"_blank", "chrome,resizable,close,dialog=no",
preview_name, preview_URL);
}
var id = node.getAttribute("id");
if (!id) break;
var rdfNode = RDF.GetResource(id);
if (!rdfNode) break;
var preview_name = get_attr(database, rdfNode, 'title');
var preview_URL = get_attr(database, rdfNode, 'content');
if (!preview_URL || !preview_name) break;
window.openDialog("chrome://communicator/content/sidebar/preview.xul",
"_blank", "chrome,resizable,close,dialog=no",
preview_name, preview_URL);
}
}
// Add the selected panel(s).
function AddPanel()
{
var added = 0;
var tree = document.getElementById('other-panels');
var database = tree.database;
var select_list = tree.selectedItems
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++) {
var node = select_list[nodeIndex];
if (!node) break;
// Skip folders.
if (node.getAttribute('container') == 'true') {
continue;
var sel = tree.treeBoxObject.selection;
var ranges = sel.getRangeCount();
for (var range = 0; range < ranges; ++range) {
var min = {}, max = {};
sel.getRangeAt(range, min, max);
for (var index = min.value; index <= max.value; ++index) {
var item = tree.contentView.getItemAtIndex(index);
if (item.getAttribute("container") != "true") {
var res = RDF.GetResource(item.id);
// Add the panel to the current list.
add_node_to_current_list(database, res);
++added;
}
}
var id = node.getAttribute("id");
// No id? Sorry. Only nodes with id's can get
// in the current panel list.
if (!id) break;
var rdfNode = RDF.GetResource(id);
// You need an rdf node too. Sorry, those are the rules.
if (!rdfNode) break;
// Add the panel to the current list.
add_node_to_current_list(database, rdfNode);
}
// Remove the selection in the other list.
// Selection will move to "current" list.
var all_panels = document.getElementById('other-panels');
all_panels.clearSelection();
if (added) {
// Remove the selection in the other list.
// Selection will move to "current" list.
var all_panels = document.getElementById('other-panels');
all_panels.treeBoxObject.selection.clearSelection();
enable_buttons_for_current_panels();
enable_buttons_for_other_panels();
enable_buttons_for_current_panels();
enable_buttons_for_other_panels();
}
}
// Copy a panel node into a database such as the current panel list.
@ -386,18 +369,20 @@ function add_node_to_current_list(registry, service)
var option_customize = get_attr(registry, service, 'customize');
var option_content = get_attr(registry, service, 'content');
var tree = document.getElementById('current-panels');
var treeroot = document.getElementById('current-panels-root');
var tree = document.getElementById('current-panels');
var tree_root = tree.getElementsByTagName("treechildren")[1];
// Check to see if the panel already exists...
for (var ii = treeroot.firstChild; ii != null; ii = ii.nextSibling) {
if (ii.getAttribute('id') == service.Value) {
var i = 0;
for (var treeitem = tree_root.firstChild; treeitem; treeitem = treeitem.nextSibling) {
if (treeitem.id == service.Value) {
// The panel is already in the current panel list.
// Avoid adding it twice.
tree.selectItem(ii);
tree.ensureElementIsVisible(ii);
tree.treeBoxObject.selection.select(i);
tree.treeBoxObject.ensureRowIsVisible(i);
return;
}
++i;
}
// Create a treerow for the new panel
@ -407,44 +392,40 @@ function add_node_to_current_list(registry, service)
// Copy over the attributes
item.setAttribute('id', service.Value);
if (option_customize && option_customize != '') {
item.setAttribute('customize', option_customize);
}
item.setAttribute('content', option_content);
cell.setAttribute('class', 'treecell-indent treecell-panel');
cell.setAttribute('label', option_title);
// Add it to the current panels tree
item.appendChild(row);
row.appendChild(cell);
treeroot.appendChild(item);
tree_root.appendChild(item);
// Select is only if the caller wants to.
tree.selectItem(item);
tree.ensureElementIsVisible(item);
var newIndex = tree_root.getElementsByTagName("treeitem").length - 1;
tree.treeBoxObject.selection.select(newIndex);
tree.treeBoxObject.ensureRowIsVisible(newIndex);
}
// Remove the selected panel(s) from the current list tree.
function RemovePanel()
{
var tree = document.getElementById('current-panels');
var nextNode = null;
var numToRemove = tree.selectedItems.length;
while (numToRemove > 0) {
var selectedNode = tree.selectedItems[0];
nextNode = selectedNode.nextSibling;
if (!nextNode) {
nextNode = selectedNode.previousSibling;
var sel = tree.treeBoxObject.selection;
var nextNode = -1;
var rangeCount = sel.getRangeCount();
for (var range = rangeCount-1; range >= 0; --range) {
var min = {}, max = {};
sel.getRangeAt(range, min, max);
for (var index = max.value; index >= min.value; --index) {
var item = tree.contentView.getItemAtIndex(index);
var nextNode = item.nextSibling ? index : -1;
item.parentNode.removeChild(item);
}
selectedNode.parentNode.removeChild(selectedNode);
numToRemove--;
}
if (nextNode) {
tree.selectItem(nextNode)
}
if (nextNode >= 0)
sel.select(nextNode);
enable_buttons_for_current_panels();
}
@ -505,28 +486,23 @@ function Save()
var current_panels = document.getElementById('current-panels');
// See if list membership has changed
var root = document.getElementById('current-panels-root');
var root = current_panels.getElementsByTagName("treechildren")[1];
var panels = root.childNodes;
var list_unchanged = (panels.length == original_panels.length);
for (var i = 0; i < panels.length && list_unchanged; i++) {
if (original_panels[i] != panels.item(i).getAttribute('id')) {
if (original_panels[i] != panels[i].id)
list_unchanged = false;
}
}
if (list_unchanged) {
window.close();
if (list_unchanged)
return;
}
// Iterate through the 'current-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!
panels = new Array();
root = document.getElementById('current-panels-root');
for (var node = root.firstChild; node != null; node = node.nextSibling) {
panels[panels.length] = node.getAttribute('id');
}
panels = [];
for (var node = root.firstChild; node != null; node = node.nextSibling)
panels.push(node.id);
// Cut off the connection between the dialog and the datasource.
// The dialog is closed at the end of this function.
@ -548,7 +524,7 @@ function Save()
container.Init(sidebarObj.datasource, panel_list);
// Remove all the current panels from the datasource.
var have_panel_attributes = new Array();
var have_panel_attributes = [];
current_panels = container.GetElements();
while (current_panels.hasMoreElements()) {
panel = current_panels.getNext();
@ -576,21 +552,12 @@ function Save()
copy_resource_deeply(all_panels.database, resource, container);
}
}
refresh_all_sidebars();
// Write the modified panels out.
sidebarObj.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
window.close();
}
function Cancel() {
persist_dialog_dimensions();
window.close();
}
// Search for an element in an array
function has_element(array, element) {
for (var ii=0; ii < array.length; ii++) {
@ -653,21 +620,26 @@ function enable_buttons_for_other_panels()
var preview_button = document.getElementById('preview_button');
var all_panels = document.getElementById('other-panels');
var num_selected = 0;
// Only count non-folders as selected for button enabling
for (var ii=0; ii<all_panels.selectedItems.length; ii++) {
debug("counting selected items...");
var node = all_panels.selectedItems[ii];
if (node.getAttribute('container') != 'true') {
num_selected++;
var sel = all_panels.treeBoxObject.selection;
var num_selected = sel ? sel.count : 0;
if (sel) {
var ranges = sel.getRangeCount();
for (var range = 0; range < ranges; ++range) {
var min = {}, max = {};
sel.getRangeAt(range, min, max);
for (var index = min; index <= max; ++index) {
var node = all_panels.contentView.getItemAtIndex(index);
if (node.getAttribute('container') != 'true') {
++num_selected;
}
}
}
}
debug("num_selected="+num_selected);
if (num_selected > 0) {
add_button.removeAttribute('disabled');
preview_button.removeAttribute('disabled');
}
else {
} else {
add_button.setAttribute('disabled','true');
preview_button.setAttribute('disabled','true');
}
@ -680,12 +652,12 @@ function enable_buttons_for_current_panels() {
var customize = document.getElementById('customize-button');
var remove = document.getElementById('remove-button');
var numSelected = tree.selectedItems.length;
var numSelected = tree.treeBoxObject.selection ? tree.treeBoxObject.selection.count : 0;
var noneSelected, isFirst, isLast, selectedNode
if (numSelected > 0) {
selectedNode = tree.selectedItems[0]
selectedNode = tree.contentView.getItemAtIndex(tree.currentIndex);
isFirst = selectedNode == selectedNode.parentNode.firstChild
isLast = selectedNode == selectedNode.parentNode.lastChild
}

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

@ -22,7 +22,6 @@
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/sidebar/customize.css"
type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window [
<!ENTITY % customizeDTD SYSTEM "chrome://communicator/locale/sidebar/customize.dtd" >
@ -31,70 +30,59 @@
%brandDTD;
]>
<window
<dialog
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="main-window"
class="dialog"
title="&sidebar.customize.title.label;"
windowtype="sidebar:customize"
width="450" height="400"
persist="screenX screenY width height">
persist="screenX screenY width height"
ondialogaccept="return Save();">
<script type="application/x-javascript"
src="chrome://communicator/content/sidebar/customize.js"/>
<keyset id="dialogKeys"/>
<hbox flex="1">
<vbox flex="1">
<label value="&sidebar.customize.additional.label;"
crop="right"/>
<tree id="other-panels" flex="1"
datasources="rdf:null"
<label value="&sidebar.customize.additional.label;" crop="right"/>
<tree id="other-panels" flex="1" seltype="multiple"
datasources="rdf:null" hidecolumnpicker="true"
containment="http://home.netscape.com/NC-rdf#panel-list"
indent="true" seltype="multiple"
onselect="SelectChangeForOtherPanels(event, event.target.parentNode.parentNode)"
onclick="if (event.detail == 2) { AddPanel(); }"
>
onselect="SelectChangeForOtherPanels(event, event.target.parentNode.parentNode);"
onclick="if (event.detail == 2) { AddPanel(); } ClickOnOtherPanels(event);">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<triple subject="?uri" object="?panel-list"
predicate="http://home.netscape.com/NC-rdf#panel-list" />
predicate="http://home.netscape.com/NC-rdf#panel-list"/>
<member container="?panel-list" child="?panel"/>
</conditions>
<bindings>
<binding subject="?panel" object="?title"
predicate="http://home.netscape.com/NC-rdf#title" />
<binding subject="?panel" object="?content"
predicate="http://home.netscape.com/NC-rdf#content" />
<binding subject="?panel" object="?link"
predicate="http://home.netscape.com/NC-rdf#link" />
<binding subject="?panel" object="?open"
predicate="http://home.netscape.com/NC-rdf#open" />
<binding subject="?panel" object="?exclude"
predicate="http://home.netscape.com/NC-rdf#exclude" />
predicate="http://home.netscape.com/NC-rdf#title"/>
<binding subject="?panel" object="?link"
predicate="http://home.netscape.com/NC-rdf#link"/>
</bindings>
<action>
<treechildren>
<treeitem uri="?panel" title="?title" content="?content"
link="?link" open="?open"
exclude="?exclude">
<treeitem uri="?panel" link="?link">
<treerow>
<treecell class="treecell-indent treecell-panel"
label="?title"/>
<treecell label="?title"/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
<treecolgroup>
<treecol flex="1"/>
</treecolgroup>
<treechildren onclick="ClickOnOtherPanels(event)"
flex="1"/>
<treecols>
<treecol id="AvailNameCol" flex="1" primary="true" hideheader="true"/>
</treecols>
</tree>
<!-- xxxslamm Need to add descriptive panel text here -->
@ -115,8 +103,9 @@
<vbox flex="1">
<label value="&sidebar.customize.current.label;"
crop="right"/>
<tree id="current-panels" onclick="SelectChangeForCurrentPanels();"
datasources="rdf:null" flex="1" seltype="multiple">
<tree id="current-panels" flex="1" seltype="multiple"
datasources="rdf:null" hidecolumnpicker="true"
onclick="SelectChangeForCurrentPanels();">
<template>
<rule>
<conditions>
@ -124,35 +113,32 @@
<triple subject="?uri" object="?panel-list"
predicate="http://home.netscape.com/NC-rdf#panel-list"/>
<member container="?panel-list" child="?panel"/>
<triple subject="?panel" object="?title"
predicate="http://home.netscape.com/NC-rdf#title"/>
<triple subject="?panel" object="?content"
predicate="http://home.netscape.com/NC-rdf#content"/>
</conditions>
<bindings>
<binding subject="?panel" object="?title"
predicate="http://home.netscape.com/NC-rdf#title"/>
<binding subject="?panel" object="?customize"
predicate="http://home.netscape.com/NC-rdf#customize" />
predicate="http://home.netscape.com/NC-rdf#customize"/>
</bindings>
<action>
<treechildren>
<treeitem uri="?panel" title="?title" customize="?customize"
content="?content">
<treeitem uri="?panel" customize="?customize">
<treerow>
<treecell class="treecell-indent treecell-panel"
label="?title" />
<treecell label="?title"/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
<treecolgroup>
<treecol flex="1"/>
</treecolgroup>
<!-- We explicitly create a 'treechildren' so we can refer
to it from the script -->
<treechildren id="current-panels-root"/>
<treecols>
<treecol id="CurrentNameCol" flex="1" hideheader="true"/>
</treecols>
</tree>
<hbox class="button-group">
<button id="customize-button"
oncommand="CustomizePanel();"
@ -181,8 +167,9 @@
<hbox>
<button id="more-panels-link" label="&sidebar.more.label;" oncommand="BrowseMorePanels()"/>
<spacer flex="1"/>
<hbox id="okCancelButtonsRight" />
<button dlgtype="accept"/>
<button dlgtype="cancel"/>
</hbox>
</window>
</dialog>