making directory viewer skinnable

This commit is contained in:
ben%netscape.com 2006-07-27 14:50:16 +00:00
Родитель 589249567c
Коммит f8959d7a9d
2 изменённых файлов: 24 добавлений и 31 удалений

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

@ -54,36 +54,27 @@ function Init()
baseURI += "/";
}
debug("base URL = " + baseURI + "\n");
tree.setAttribute("ref", baseURI);
}
function OnClick(event)
{
debug('OnClick()\n');
// This'll be set to 'twisty' on the twisty icon, and 'filename'
// if they're over the filename link.
var targetclass = event.target.getAttribute('class');
debug('targetclass = ' + targetclass + '\n');
if (targetclass != 'twisty') {
// The click'll have hit a cell, which is nested two below the
// treeitem.
var treeitem = event.target.parentNode.parentNode;
// This'll be set to 'FILE' for files and 'DIRECTORY' for
// directories.
var type = treeitem.getAttribute('type');
if (targetclass.indexOf('filename') >= 0)
{
var url = treeitem.getAttribute('id');
debug('navigating to ' + url + '\n');
window.content.location.href = url;
}
}
if( event.type == "click" &&
( event.button != 1 || event.clickCount != 2 ) )
return false;
if( event.type == "keypress" && event.which != 13 )
return false;
var tree = document.getElementById("tree");
if( tree.selectedItems.length == 1 )
{
var selectedItem = tree.selectedItems[0];
//if( selectedItem.getAttribute( "type" ) == "FILE" )
window.content.location.href = selectedItem.getAttribute('id');
}
}

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

@ -22,6 +22,7 @@
-->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/directory/directory.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/directory/directory.dtd">
@ -31,17 +32,19 @@
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"
align="vertical">
orient="vertical">
<html:script src="directory.js" />
<script src="chrome://communicator/content/directory/directory.js"></script>
<tree id="tree" datasources="rdf:files rdf:httpindex" flex="1" style="height:0px;" container="true" open="true" >
<template>
<treechildren>
<treeitem uri="..." type="rdf:http://home.netscape.com/NC-rdf#File-Type" persist="open"
<treeitem uri="..." persist="open"
type="rdf:http://home.netscape.com/NC-rdf#File-Type"
loading="rdf:http://home.netscape.com/NC-rdf#loading" >
<treerow>
<treecell class="filename treecell-indent" indent="true"
<treecell class="treecell-filename treecell-indent" indent="true"
type="rdf:http://home.netscape.com/NC-rdf#File-Type"
value="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell value="rdf:http://home.netscape.com/NC-rdf#Content-Length" />
<treecell value="rdf:http://home.netscape.com/WEB-rdf#LastModifiedDate" />
@ -56,7 +59,7 @@
<treehead>
<treerow>
<treecell class="treecell-header sortDirectionIndicator" value="&directoryWindow.filename.label;"
<treecell class="treecell-header sortDirectionIndicator" value="&directoryWindow.filename.label;"
onclick="return doSort('FilenameColumn');" observes="FilenameColumn" sortActive="true" sortDirection="ascending" />
<treecell class="treecell-header sortDirectionIndicator" value="&directoryWindow.contentlength.label;"
onclick="return doSort('ContentLengthColumn');" observes="ContentLengthColumn" />
@ -67,8 +70,7 @@
<!-- Create the treechildren here so we can attach event handlers
at this level (rather than at the tree level -->
<treechildren
onclick="OnClick(event);" />
<treechildren onclick="OnClick(event);" onkeypress="OnClick(event);"/>
</tree>
</window>