First Checked In.

This commit is contained in:
brade%netscape.com 1999-08-27 13:04:03 +00:00
parent 16b23b760e
commit d61e59824e
11 changed files with 1908 additions and 0 deletions

View File

@ -0,0 +1,98 @@
<?xml version="1.0"?>
<!--
- 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) 1999 Netscape Communications Corporation. All
- Rights Reserved.
-
- Contributor(s):
- Ben Goodger
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://navigator/skin/contentframe.css" type="text/css"?>
<!DOCTYPE window>
<window style="height:100%;width:100%"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="init_sidebar('editor',
'chrome://editor/content/sidebar-editor.xul',
170);" align="horizontal">
<!-- use navigator's contentframe.js... ideally we only
need one... not many -->
<html:script src="chrome://navigator/content/contentframe.js" />
<html:iframe id="sidebarframe" class="sidebarframe" src="chrome://editor/content/sidebar-editor.xul" />
<titledbutton id="grippy" class="grippy" onclick="toggle_open_close();"/>
<!-- type attribute is used by frame construction to locate iframes
intended to hold (html) content -->
<!-- id's use is a mystery -->
<html:iframe type="content-primary" id="content-frame" src="about:blank" flex="100%"/>
</window>

View File

@ -0,0 +1,67 @@
/*
* 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.
*
* Contributor(s):
* Ben Goodger
*/
function EditorAutoInsertImage(url)
{
var imageElement = top.editorShell.CreateElementWithDefaults("img");
// TODO: do some smartass string parsing to find relative file
// location so we don't need this big chunky URLs..
// must utilize document dirty flag.
imageElement.setAttribute("src",url);
// TODO: make this show the file name and size in bytes.
var altString = url.substring(url.lastIndexOf("/")+1,url.length);
imageElement.setAttribute("alt",altString);
imageElement.setAttribute("border","0");
// TODO: collect width and height attributes and insert those
// also.
// insert the image
top.editorShell.InsertElement(imageElement,true);
}
function EditorInsertBackgroundImage(url)
{
}
function EditorInsertJSFile(url)
{
var scriptElement = top.editorShell.CreateElementWithDefaults("script");
// TODO: do some smartass string parsing to find relative file
// location so we don't need this big chunky URLs..
// must utilize document dirty flag.
scriptElement.setAttribute("src",url);
scriptElement.setAttribute("language","JavaScript");
top.editorShell.InsertElement(scriptElement,true);
}
function EditorInsertCSSFile(url)
{
var cssElement = top.editorShell.CreateElementWithDefaults("link");
// TODO: do some smartass string parsing to find relative file
// location so we don't need this big chunky URLs..
// must utilize document dirty flag.
cssElement.setAttribute("href",url);
cssElement.setAttribute("type","text/css");
cssElement.setAttribute("rel","stylesheet");
top.editorShell.InsertElement(cssElement,true);
}

View File

@ -0,0 +1,156 @@
<?xml version="1.0"?> <!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!--
- 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) 1999 Netscape Communications Corporation. All
- Rights Reserved.
-
- Contributor(s):
- Ben Goodger
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://sidebar/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://bookmarks/skin/" type="text/css"?>
<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">
<html:script src="chrome://editor/content/sb-bookmarks.js"/>
<popup id="contextual" oncreate="return fillContextMenu('contextual');" >
<menu />
</popup>
<tree id="bookmarksTree" context="contextual" ref="NC:BookmarksRoot"
flex="100%" style="height: 100%"
datasources="rdf:bookmarks rdf:files rdf:ftp rdf:find rdf:internetsearch"
ondblclick="return OpenURL(event, event.target.parentNode.parentNode);">
<!-- Commented out until new tree content model and template builder can play nice -->
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
<treechildren>
<treeitem uri="...">
<treerow>
<treecell>
<html:hr width="75%" align="center" size="1" />
</treecell>
</treerow>
</treeitem>
</treechildren>
</rule>
<rule>
<treechildren>
<treeitem uri="...">
<treerow>
<treecell>
<treeindentation />
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Name"
align="left" />
</treecell>
</treerow>
</treeitem>
</treechildren>
</rule>
</template>
<treecol id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
</tree>
</window>

View File

@ -0,0 +1,579 @@
/*
* 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) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Ben Goodger
*/
/*
Script for the bookmarks properties window
*/
function BookmarkProperties()
{
var tree = document.getElementById('bookmarksTree');
var select_list = tree.getElementsByAttribute("selected", "true");
if (select_list.length >= 1) {
// don't bother showing properties on bookmark separators
var type = select_list[0].getAttribute('type');
if (type != "http://home.netscape.com/NC-rdf#BookmarkSeparator")
{
var props = window.open("chrome://bookmarks/content/bm-props.xul",
"BookmarkProperties", "chrome,menubar,resizable");
props.BookmarkURL = select_list[0].getAttribute("id");
}
} else {
dump("nothing selected!\n");
}
}
function OpenSearch(tabName)
{
window.openDialog("resource:/res/samples/search.xul", "SearchWindow", "dialog=no,close,chrome,resizable", tabName);
}
function OpenURL(event, node)
{
// clear any single-click/edit timeouts
if (timerID != null)
{
gEditNode = null;
clearTimeout(timerID);
timerID = null;
}
if (node.getAttribute('container') == "true")
{
return(false);
}
var url = node.getAttribute('id');
// Ignore "NC:" urls.
if (url.substring(0, 3) == "NC:")
{
return(false);
}
try
{
// add support for IE favorites under Win32, and NetPositive URLs under BeOS
if (url.indexOf("file://") == 0)
{
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var fileSys = rdf.GetDataSource("rdf:files");
if (fileSys)
{
var src = rdf.GetResource(url, true);
var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true);
var target = fileSys.GetTarget(src, prop, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target) url = target;
}
}
}
}
catch(ex)
{
}
if(top.isEditor != undefined) {
dump("yay, top.isEditor is defined\n");
if(top.editorShell) {
dump("yay yay, top.editorShell exists, loading URL...\n");
toEditor(url);
}
} else {
dump("reg'lar bm window\n");
window.open(url,'bookmarks');
}
dump("OpenURL(" + url + ")\n");
return(true);
}
var htmlInput = null;
var saveNode = null;
var newValue = "";
var timerID = null;
var gEditNode = null;
function DoSingleClick(event, node)
{
var type = node.parentNode.parentNode.getAttribute('type');
var selected = node.parentNode.parentNode.getAttribute('selected');
if (gEditNode == node) {
// Only start an inline edit if it is the second consecutive click
// on the same node that is not already editing or a separator.
if (!htmlInput &&
type != "http://home.netscape.com/NC-rdf#BookmarkSeparator") {
// Edit node if we don't get a double-click in less than 1/2 second
timerID = setTimeout("OpenEditNode()", 500);
}
} else {
if (htmlInput) {
// Clicked during an edit
// Save the changes and move on
CloseEditNode(true);
}
gEditNode = node;
}
return false;
}
function OpenEditNode()
{
dump("OpenEditNode entered.\n");
// clear any single-click/edit timeouts
if (timerID != null)
{
clearTimeout(timerID);
timerID = null;
}
// XXX uncomment the following line to replace the whole input row we do this
// (and, therefore, only allow editing on the name column) until we can
// arbitrarily change the content model (bugs prevent this at the moment)
gEditNode = gEditNode.parentNode;
var name = gEditNode.parentNode.getAttribute("Name");
dump("Single click on '" + name + "'\n");
var theParent = gEditNode.parentNode;
dump("Parent node is a " + theParent.nodeName + "\n\n");
saveNode = gEditNode;
// unselect all nodes!
var select_list = document.getElementsByAttribute("selected", "true");
dump("# of Nodes selected: " + select_list.length + "\n\n");
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
var node = select_list[nodeIndex];
if (node)
{
dump("Unselecting node "+node.getAttribute("Name") + "\n");
node.removeAttribute("selected");
}
}
// XXX for now, just remove the child from the parent
// optimally, we'd like to not remove the child-parent relationship
// and instead just set a "display: none;" attribute on the child node
// gEditNode.setAttribute("style", "display: none;");
// dump("gEditNode hidden.\n");
theParent.removeChild(gEditNode);
gEditNode = null;
dump("gEditNode removed.\n");
// create the html:input node
htmlInput = document.createElement("html:input");
htmlInput.setAttribute("value", name);
htmlInput.setAttribute("onkeydown", "return EditNodeKeyDown(event)");
htmlInput.setAttribute("onkeyup", "return EditNodeKeyUp(event)");
theParent.appendChild(htmlInput);
dump("html:input node added.\n");
htmlInput.focus();
dump("OpenEditNode done.\n");
return(true);
}
function CloseEditNode(saveChangeFlag)
{
dump("CloseEditNode entered.\n");
if (htmlInput)
{
if (saveChangeFlag)
{
newValue = htmlInput.value;
}
dump(" Got html input: "+newValue+" \n");
var theParent = htmlInput.parentNode;
theParent.removeChild(htmlInput);
theParent.appendChild(saveNode);
dump(" child node appended.\n");
if (saveNode && saveChangeFlag)
{
var RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
var Bookmarks = RDF.GetDataSource("rdf:bookmarks");
dump("Got bookmarks datasource.\n");
// XXX once we support multi-column editing, get the property
// from the column in the content model
var propertyName = "http://home.netscape.com/NC-rdf#Name";
var propertyNode = RDF.GetResource(propertyName, true);
dump(" replacing value of property '" + propertyName + "'\n");
// get the URI
var theNode = saveNode;
var bookmarkURL = "";
while(true)
{
var tag = theNode.nodeName;
if (tag == "treeitem")
{
bookmarkURL = theNode.getAttribute("id");
break;
}
theNode = theNode.parentNode;
}
dump(" uri is '" + bookmarkURL + "'\n");
if (bookmarkURL == "") return(false);
var bookmarkNode = RDF.GetResource(bookmarkURL, true);
dump(" newValue = '" + newValue + "'\n");
newValue = (newValue != "") ? RDF.GetLiteral(newValue) : null;
var oldValue = Bookmarks.GetTarget(bookmarkNode, propertyNode, true);
if (oldValue)
{
oldValue = oldValue.QueryInterface(Components.interfaces.nsIRDFLiteral);
dump(" oldValue = '" + oldValue + "'\n");
}
if (oldValue != newValue)
{
if (oldValue && !newValue)
{
Bookmarks.Unassert(bookmarkNode, propertyNode, oldValue);
dump(" Unassert used.\n");
}
else if (!oldValue && newValue)
{
Bookmarks.Assert(bookmarkNode, propertyNode, newValue, true);
dump(" Assert used.\n");
}
else if (oldValue && newValue)
{
Bookmarks.Change(bookmarkNode, propertyNode, oldValue, newValue);
dump(" Change used.\n");
}
dump("re-writing bookmarks.html\n");
var remote = Bookmarks.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
remote.Flush();
}
newValue = "";
saveNode = null;
}
else dump("saveNode was null?\n");
htmlInput = null;
}
else dump("htmlInput was null?\n");
dump("CloseEditNode done.\n");
}
function EditNodeKeyDown(event)
{
if (event.which == 27)
{
CloseEditNode(false);
return(false);
}
return(true);
}
function EditNodeKeyUp(event)
{
if (event.which == 13 || event.which == 10)
{
CloseEditNode(true);
return(false);
}
return(true);
}
function doSort(sortColName)
{
var node = document.getElementById(sortColName);
// determine column resource to sort on
var sortResource = node.getAttribute('resource');
if (!node) return(false);
var sortDirection="ascending";
var isSortActive = node.getAttribute('sortActive');
if (isSortActive == "true") {
var currentDirection = node.getAttribute('sortDirection');
if (currentDirection == "ascending")
sortDirection = "descending";
else if (currentDirection == "descending")
sortDirection = "natural";
else
sortDirection = "ascending";
}
// get RDF Core service
var rdfCore = XPAppCoresManager.Find("RDFCore");
if (!rdfCore) {
rdfCore = new RDFCore();
if (!rdfCore) {
return(false);
}
rdfCore.Init("RDFCore");
// XPAppCoresManager.Add(rdfCore);
}
// sort!!!
rdfCore.doSort(node, sortResource, sortDirection);
return(false);
}
function fillContextMenu(name)
{
if (!name) return(false);
var popupNode = document.getElementById(name);
if (!popupNode) return(false);
// remove the menu node (which tosses all of its kids);
// do this in case any old command nodes are hanging around
var menuNode = popupNode.childNodes[0];
popupNode.removeChild(menuNode);
// create a new menu node
menuNode = document.createElement("menu");
popupNode.appendChild(menuNode);
var treeNode = document.getElementById("bookmarksTree");
if (!treeNode) return(false);
var db = treeNode.database;
if (!db) return(false);
var compositeDB = db.QueryInterface(Components.interfaces.nsIRDFDataSource);
if (!compositeDB) return(false);
var isupports = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (!isupports) return(false);
var rdf = isupports.QueryInterface(Components.interfaces.nsIRDFService);
if (!rdf) return(false);
var select_list = treeNode.getElementsByAttribute("selected", "true");
if (select_list.length < 1) return(false);
dump("# of Nodes selected: " + select_list.length + "\n\n");
// perform intersection of commands over selected nodes
var cmdArray = new Array();
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
var node = select_list[nodeIndex];
if (!node) break;
var id = node.getAttribute("id");
if (!id) break;
var rdfNode = rdf.GetResource(id);
if (!rdfNode) break;
var cmdEnum = db.GetAllCmds(rdfNode);
if (!cmdEnum) break;
var nextCmdArray = new Array();
while (cmdEnum.HasMoreElements())
{
var cmd = cmdEnum.GetNext();
if (!cmd) break;
if (nodeIndex == 0)
{
cmdArray[cmdArray.length] = cmd;
}
else
{
nextCmdArray[cmdArray.length] = cmd;
}
}
if (nodeIndex > 0)
{
// perform command intersection calculation
for (var cmdIndex = 0; cmdIndex < cmdArray.length; cmdIndex++)
{
var cmdFound = false;
for (var nextCmdIndex = 0; nextCmdIndex < nextCmdArray.length; nextCmdIndex++)
{
if (nextCmdArray[nextCmdIndex] == cmdArray[cmdIndex])
{
cmdFound = true;
break;
}
}
if (cmdFound == false)
{
cmdArray[cmdIndex] = null;
}
}
}
}
// need a resource to ask RDF for each command's name
var rdfNameResource = rdf.GetResource("http://home.netscape.com/NC-rdf#Name");
if (!rdfNameResource) return(false);
// build up menu items
if (cmdArray.length < 1) return(false);
for (var cmdIndex = 0; cmdIndex < cmdArray.length; cmdIndex++)
{
var cmd = cmdArray[cmdIndex];
if (!cmd) continue;
var cmdResource = cmd.QueryInterface(Components.interfaces.nsIRDFResource);
if (!cmdResource) break;
var cmdNameNode = compositeDB.GetTarget(cmdResource, rdfNameResource, true);
if (!cmdNameNode) break;
cmdNameLiteral = cmdNameNode.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (!cmdNameLiteral) break;
cmdName = cmdNameLiteral.Value;
if (!cmdName) break;
dump("Command #" + cmdIndex + ": id='" + cmdResource.Value + "' name='" + cmdName + "'\n\n");
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("value", cmdName);
menuItem.setAttribute("onaction", "return doContextCmd('" + cmdResource.Value + "');");
menuNode.appendChild(menuItem);
}
return(true);
}
function doContextCmd(cmdName)
{
dump("doContextCmd start: cmd='" + cmdName + "'\n");
var treeNode = document.getElementById("bookmarksTree");
if (!treeNode) return(false);
var db = treeNode.database;
if (!db) return(false);
var compositeDB = db.QueryInterface(Components.interfaces.nsIRDFDataSource);
if (!compositeDB) return(false);
var isupports = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (!isupports) return(false);
var rdf = isupports.QueryInterface(Components.interfaces.nsIRDFService);
if (!rdf) return(false);
// need a resource for the command
var cmdResource = rdf.GetResource(cmdName);
if (!cmdResource) return(false);
cmdResource = cmdResource.QueryInterface(Components.interfaces.nsIRDFResource);
if (!cmdResource) return(false);
var select_list = treeNode.getElementsByAttribute("selected", "true");
if (select_list.length < 1) return(false);
dump("# of Nodes selected: " + select_list.length + "\n\n");
// set up selection nsISupportsArray
var selectionInstance = Components.classes["component://netscape/supports-array"].createInstance();
var selectionArray = selectionInstance.QueryInterface(Components.interfaces.nsISupportsArray);
// set up arguments nsISupportsArray
var argumentsInstance = Components.classes["component://netscape/supports-array"].createInstance();
var argumentsArray = argumentsInstance.QueryInterface(Components.interfaces.nsISupportsArray);
// get argument (parent)
var parentArc = rdf.GetResource("http://home.netscape.com/NC-rdf#parent");
if (!parentArc) return(false);
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
var node = select_list[nodeIndex];
if (!node) break;
var uri = node.getAttribute("ref");
if ((uri) || (uri == ""))
{
uri = node.getAttribute("id");
}
if (!uri) return(false);
var rdfNode = rdf.GetResource(uri);
if (!rdfNode) break;
// add node into selection array
selectionArray.AppendElement(rdfNode);
// get the parent's URI
var parentURI="";
var theParent = node;
while (theParent)
{
theParent = theParent.parentNode;
parentURI = theParent.getAttribute("ref");
if ((!parentURI) || (parentURI == ""))
{
parentURI = theParent.getAttribute("id");
}
if (parentURI != "") break;
}
if (parentURI == "") return(false);
var parentNode = rdf.GetResource(parentURI, true);
if (!parentNode) return(false);
// add parent arc and node into arguments array
argumentsArray.AppendElement(parentArc);
argumentsArray.AppendElement(parentNode);
}
// do the command
compositeDB.DoCommand( selectionArray, cmdResource, argumentsArray );
dump("doContextCmd ends.\n\n");
return(true);
}
// ripped from tasksOverlay.js.. ideally we should
// put it back there (eventually).
function toEditor(url)
{
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore) {
toolkitCore = new ToolkitCore();
if (toolkitCore) {
toolkitCore.Init("ToolkitCore");
}
}
if (toolkitCore) {
toolkitCore.ShowWindowWithArgs("chrome://editor/content/EditorAppShell.xul",window,url);
}
}

View File

@ -0,0 +1,106 @@
/*
* 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) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Ben Goodger
*/
function fillContextMenu(name,node)
{
if (!name) return(false);
var popupNode = document.getElementById(name);
if (!popupNode) return(false);
var url = GetFileURL(node); // get the URL of the selected file
var ext = getFileExtension(url); // get the extension (type) of file
// remove the menu node (which tosses all of its kids);
// do this in case any old command nodes are hanging around
var menuNode = popupNode.childNodes[0];
popupNode.removeChild(menuNode);
// create a new menu node
menuNode = document.createElement("menu");
popupNode.appendChild(menuNode);
switch(ext) {
case "gif":
case "jpg":
case "jpeg":
case "png":
isImageFile(menuNode,url);
break;
case "htm":
case "html":
isHTMLFile(menuNode,url);
break;
default:
break;
}
return(true);
}
function GetFileURL(node)
{
var url = node.getAttribute('id');
// Ignore "NC:" urls.
if (url.substring(0, 3) == "NC:")
{
return(false);
}
try
{
// add support for IE favorites under Win32, and NetPositive URLs under BeOS
if (url.indexOf("file://") == 0)
{
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var fileSys = rdf.GetDataSource("rdf:files");
if (fileSys)
{
var src = rdf.GetResource(url, true);
var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true);
var target = fileSys.GetTarget(src, prop, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target) url = target;
}
}
}
}
catch(ex)
{
}
return url;
}
function isImageFile(parent,url)
{
// note: deleted all the doContextCmd stuff from bookmarks.
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("value","Insert Image");
// menuItem.setAttribute("onaction","AutoInsertImage(\'" + url + "\')");
parent.appendChild(menuItem);
}

View File

@ -0,0 +1,550 @@
/*
* 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.
*
* Contributor(s):
* Ben Goodger
*/
/*
Script for the file properties window
*/
function FileProperties()
{
var tree = document.getElementById('fileTree');
if (tree.selectedItems.length >= 1) {
// don't bother showing properties on bookmark separators
var type = tree.selectedItems[0].getAttribute('type');
if (type != "http://home.netscape.com/NC-rdf#BookmarkSeparator") {
var props = window.open("chrome://bookmarks/content/bm-props.xul",
"BookmarkProperties", "chrome,menubar,resizable");
props.BookmarkURL = tree.selectedItems[0].getAttribute("id");
}
} else {
dump("nothing selected!\n");
}
}
function OpenSearch(tabName)
{
window.openDialog("resource:/res/samples/search.xul", "SearchWindow", "dialog=no,close,chrome,resizable", tabName);
}
function OpenURL(event, node)
{
// clear any single-click/edit timeouts
if (timerID != null)
{
gEditNode = null;
clearTimeout(timerID);
timerID = null;
}
if (node.getAttribute('container') == "true")
{
return(false);
}
var url = node.getAttribute('id');
// Ignore "NC:" urls.
if (url.substring(0, 3) == "NC:")
{
return(false);
}
try
{
// add support for IE favorites under Win32, and NetPositive URLs under BeOS
if (url.indexOf("file://") == 0)
{
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var fileSys = rdf.GetDataSource("rdf:files");
if (fileSys)
{
var src = rdf.GetResource(url, true);
var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true);
var target = fileSys.GetTarget(src, prop, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target) url = target;
}
}
}
}
catch(ex)
{
}
if(top.isEditor != undefined) {
if(top.editorShell) {
var ext = getFileExtension(url);
// look at the extension of the file to see what should be done
// with it. Note that this is a typically windowsey approach. will
// rdf:files hold a reference to the actual file type? (Mac?)
switch(ext) {
// XXX Crude, but it will do for now.
case "gif":
case "jpeg":
case "jpg":
case "png":
// just insert the image
EditorAutoInsertImage(url);
break;
case "htm":
case "html":
case "xul":
toEditor(url);
break;
case "js":
EditorInsertJSFile(url);
break;
case "css":
EditorInsertCSSFile(url);
break;
default:
// load the file in the editor
dump("Editor Message: Weirdo File Format\n");
toEditor(url);
break;
}
}
} else {
window.open(url,'bookmarks');
}
dump("OpenURL(" + url + ")\n");
return(true);
}
// returns the extension of a specified file URL
function getFileExtension(url)
{
return url.substring(url.lastIndexOf(".")+1,url.length).toLowerCase();
}
var htmlInput = null;
var saveNode = null;
var newValue = "";
var timerID = null;
var gEditNode = null;
function DoSingleClick(event, node)
{
var type = node.parentNode.parentNode.getAttribute('type');
var selected = node.parentNode.parentNode.getAttribute('selected');
if (gEditNode == node) {
// Only start an inline edit if it is the second consecutive click
// on the same node that is not already editing or a separator.
if (!htmlInput &&
type != "http://home.netscape.com/NC-rdf#BookmarkSeparator") {
// Edit node if we don't get a double-click in less than 1/2 second
timerID = setTimeout("OpenEditNode()", 500);
}
} else {
if (htmlInput) {
// Clicked during an edit
// Save the changes and move on
CloseEditNode(true);
}
gEditNode = node;
}
return false;
}
function OpenEditNode()
{
dump("OpenEditNode entered.\n");
// clear any single-click/edit timeouts
if (timerID != null)
{
clearTimeout(timerID);
timerID = null;
}
// XXX uncomment the following line to replace the whole input row we do this
// (and, therefore, only allow editing on the name column) until we can
// arbitrarily change the content model (bugs prevent this at the moment)
gEditNode = gEditNode.parentNode;
var name = gEditNode.parentNode.getAttribute("Name");
dump("Single click on '" + name + "'\n");
var theParent = gEditNode.parentNode;
dump("Parent node is a " + theParent.nodeName + "\n\n");
saveNode = gEditNode;
// unselect all nodes!
var select_list = document.getElementsByAttribute("selected", "true");
dump("# of Nodes selected: " + select_list.length + "\n\n");
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
var node = select_list[nodeIndex];
if (node)
{
dump("Unselecting node "+node.getAttribute("Name") + "\n");
node.removeAttribute("selected");
}
}
// XXX for now, just remove the child from the parent
// optimally, we'd like to not remove the child-parent relationship
// and instead just set a "display: none;" attribute on the child node
// gEditNode.setAttribute("style", "display: none;");
// dump("gEditNode hidden.\n");
theParent.removeChild(gEditNode);
gEditNode = null;
dump("gEditNode removed.\n");
// create the html:input node
htmlInput = document.createElement("html:input");
htmlInput.setAttribute("value", name);
htmlInput.setAttribute("onkeydown", "return EditNodeKeyDown(event)");
htmlInput.setAttribute("onkeyup", "return EditNodeKeyUp(event)");
theParent.appendChild(htmlInput);
dump("html:input node added.\n");
htmlInput.focus();
dump("OpenEditNode done.\n");
return(true);
}
function CloseEditNode(saveChangeFlag)
{
dump("CloseEditNode entered.\n");
if (htmlInput)
{
if (saveChangeFlag)
{
newValue = htmlInput.value;
}
dump(" Got html input: "+newValue+" \n");
var theParent = htmlInput.parentNode;
theParent.removeChild(htmlInput);
theParent.appendChild(saveNode);
dump(" child node appended.\n");
if (saveNode && saveChangeFlag)
{
var RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
var Bookmarks = RDF.GetDataSource("rdf:bookmarks");
dump("Got bookmarks datasource.\n");
// XXX once we support multi-column editing, get the property
// from the column in the content model
var propertyName = "http://home.netscape.com/NC-rdf#Name";
var propertyNode = RDF.GetResource(propertyName, true);
dump(" replacing value of property '" + propertyName + "'\n");
// get the URI
var theNode = saveNode;
var bookmarkURL = "";
while(true)
{
var tag = theNode.nodeName;
if (tag == "treeitem")
{
bookmarkURL = theNode.getAttribute("id");
break;
}
theNode = theNode.parentNode;
}
dump(" uri is '" + bookmarkURL + "'\n");
if (bookmarkURL == "") return(false);
var bookmarkNode = RDF.GetResource(bookmarkURL, true);
dump(" newValue = '" + newValue + "'\n");
newValue = (newValue != "") ? RDF.GetLiteral(newValue) : null;
var oldValue = Bookmarks.GetTarget(bookmarkNode, propertyNode, true);
if (oldValue)
{
oldValue = oldValue.QueryInterface(Components.interfaces.nsIRDFLiteral);
dump(" oldValue = '" + oldValue + "'\n");
}
if (oldValue != newValue)
{
if (oldValue && !newValue)
{
Bookmarks.Unassert(bookmarkNode, propertyNode, oldValue);
dump(" Unassert used.\n");
}
else if (!oldValue && newValue)
{
Bookmarks.Assert(bookmarkNode, propertyNode, newValue, true);
dump(" Assert used.\n");
}
else if (oldValue && newValue)
{
Bookmarks.Change(bookmarkNode, propertyNode, oldValue, newValue);
dump(" Change used.\n");
}
dump("re-writing bookmarks.html\n");
var remote = Bookmarks.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
remote.Flush();
}
newValue = "";
saveNode = null;
}
else dump("saveNode was null?\n");
htmlInput = null;
}
else dump("htmlInput was null?\n");
dump("CloseEditNode done.\n");
}
function EditNodeKeyDown(event)
{
if (event.which == 27)
{
CloseEditNode(false);
return(false);
}
return(true);
}
function EditNodeKeyUp(event)
{
if (event.which == 13 || event.which == 10)
{
CloseEditNode(true);
return(false);
}
return(true);
}
function doSort(sortColName)
{
var node = document.getElementById(sortColName);
// determine column resource to sort on
var sortResource = node.getAttribute('resource');
if (!node) return(false);
var sortDirection="ascending";
var isSortActive = node.getAttribute('sortActive');
if (isSortActive == "true") {
var currentDirection = node.getAttribute('sortDirection');
if (currentDirection == "ascending")
sortDirection = "descending";
else if (currentDirection == "descending")
sortDirection = "natural";
else
sortDirection = "ascending";
}
// get RDF Core service
var rdfCore = XPAppCoresManager.Find("RDFCore");
if (!rdfCore) {
rdfCore = new RDFCore();
if (!rdfCore) {
return(false);
}
rdfCore.Init("RDFCore");
// XPAppCoresManager.Add(rdfCore);
}
// sort!!!
rdfCore.doSort(node, sortResource, sortDirection);
return(false);
}
function fillContextMenu(name,node)
{
if (!name) return(false);
var popupNode = document.getElementById(name);
if (!popupNode) return(false);
var url = GetFileURL(node);
var ext = getFileExtension(url);
// remove the menu node (which tosses all of its kids);
// do this in case any old command nodes are hanging around
var menuNode = popupNode.childNodes[0];
popupNode.removeChild(menuNode);
// create a new menu node
menuNode = document.createElement("menu");
popupNode.appendChild(menuNode);
dump("mwa");
if(ext == "gif")
{
// note: deleted all the doContextCmd stuff from bookmarks.
menuItem = document.createElement("menuitem");
menuItem.setAttribute("value","Insert Image");
// menuItem.setAttribute("onaction","AutoInsertImage(\'" + url + "\')");
parent.appendChild(menuItem);
}
return(true);
}
function isImageFile(parent,url)
{
}
function GetFileURL(node)
{
var url = node.getAttribute('id');
// Ignore "NC:" urls.
if (url.substring(0, 3) == "NC:")
{
return(false);
}
try
{
// add support for IE favorites under Win32, and NetPositive URLs under BeOS
if (url.indexOf("file://") == 0)
{
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var fileSys = rdf.GetDataSource("rdf:files");
if (fileSys)
{
var src = rdf.GetResource(url, true);
var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true);
var target = fileSys.GetTarget(src, prop, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target) url = target;
}
}
}
}
catch(ex)
{
}
return url;
}
function doContextCmd(cmdName)
{
dump("doContextCmd start: cmd='" + cmdName + "'\n");
var treeNode = document.getElementById("bookmarksTree");
if (!treeNode) return(false);
var db = treeNode.database;
if (!db) return(false);
var compositeDB = db.QueryInterface(Components.interfaces.nsIRDFDataSource);
if (!compositeDB) return(false);
var isupports = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (!isupports) return(false);
var rdf = isupports.QueryInterface(Components.interfaces.nsIRDFService);
if (!rdf) return(false);
// need a resource for the command
var cmdResource = rdf.GetResource(cmdName);
if (!cmdResource) return(false);
cmdResource = cmdResource.QueryInterface(Components.interfaces.nsIRDFResource);
if (!cmdResource) return(false);
var select_list = treeNode.getElementsByAttribute("selected", "true");
if (select_list.length < 1) return(false);
dump("# of Nodes selected: " + select_list.length + "\n\n");
// set up selection nsISupportsArray
var selectionInstance = Components.classes["component://netscape/supports-array"].createInstance();
var selectionArray = selectionInstance.QueryInterface(Components.interfaces.nsISupportsArray);
// set up arguments nsISupportsArray
var argumentsInstance = Components.classes["component://netscape/supports-array"].createInstance();
var argumentsArray = argumentsInstance.QueryInterface(Components.interfaces.nsISupportsArray);
// get argument (parent)
var parentArc = rdf.GetResource("http://home.netscape.com/NC-rdf#parent");
if (!parentArc) return(false);
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
var node = select_list[nodeIndex];
if (!node) break;
var uri = node.getAttribute("ref");
if ((uri) || (uri == ""))
{
uri = node.getAttribute("id");
}
if (!uri) return(false);
var rdfNode = rdf.GetResource(uri);
if (!rdfNode) break;
// add node into selection array
selectionArray.AppendElement(rdfNode);
// get the parent's URI
var parentURI="";
var theParent = node;
while (theParent)
{
theParent = theParent.parentNode;
parentURI = theParent.getAttribute("ref");
if ((!parentURI) || (parentURI == ""))
{
parentURI = theParent.getAttribute("id");
}
if (parentURI != "") break;
}
if (parentURI == "") return(false);
var parentNode = rdf.GetResource(parentURI, true);
if (!parentNode) return(false);
// add parent arc and node into arguments array
argumentsArray.AppendElement(parentArc);
argumentsArray.AppendElement(parentNode);
}
// do the command
compositeDB.DoCommand( selectionArray, cmdResource, argumentsArray );
dump("doContextCmd ends.\n\n");
return(true);
}

View File

@ -0,0 +1,136 @@
<?xml version="1.0"?> <!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!--
- 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) 1999 Netscape Communications Corporation. All
- Rights Reserved.
-
- Contributor(s):
- Ben Goodger
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://sidebar/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://bookmarks/skin/" type="text/css"?>
<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">
<html:script src="chrome://global/content/tasksOverlay.js"/>
<html:script src="chrome://editor/content/sb-file-panel.js"/>
<html:script src="chrome://editor/content/sb-FileWidgetFileHandler.js"/>
<popup id="contextual" oncreate="return fillContextMenu('contextual',event.target.parentNode.parentNode);" >
<menu />
</popup>
<tree id="fileTree" context="contextual" ref="NC:FilesRoot"
flex="100%" style="height: 100%"
datasources="rdf:files"
ondblclick="return OpenURL(event, event.target.parentNode.parentNode);">
<!-- Commented out until new tree content model and template builder can play nice -->
<template>
<rule>
<treechildren>
<treeitem uri="...">
<treerow>
<treecell>
<treeindentation />
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Name"
align="left" />
</treecell>
</treerow>
</treeitem>
</treechildren>
</rule>
</template>
<treecol id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
</tree>
</window>

View File

@ -0,0 +1,112 @@
<?xml version="1.0"?>
<!--
- 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) 1999 Netscape Communications Corporation. All
- Rights Reserved.
-
- Contributor(s):
- Ben Goodger
-->
<!DOCTYPE RDF SYSTEM "chrome://editor/locale/sidebar-editor-rdf.dtd" >
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:NC="http://home.netscape.com/NC-rdf#">
<RDF:Seq about="NC:EditorSidebarRoot">
<RDF:li>
<RDF:Description ID="files">
<NC:title>&sidebar.files.label;</NC:title>
<NC:content>chrome://editor/content/sb-file-panel.xul</NC:content>
<NC:height>200px</NC:height>
</RDF:Description>
</RDF:li>
<RDF:li>
<RDF:Description ID="bookmarks">
<NC:title>&sidebar.bookmarks.label;</NC:title>
<NC:content>chrome://editor/content/sb-bookmarks-panel.xul</NC:content>
</RDF:Description>
</RDF:li>
<!-- remove flash for now
<RDF:li>
<RDF:Description ID="flash">
<NC:title>&sidebar.flash.label;</NC:title>
<NC:content>chrome://sidebar/content/flash.xul</NC:content>
<NC:height>5em</NC:height>
</RDF:Description>
</RDF:li>
-->
</RDF:Seq>
</RDF:RDF>

View File

@ -0,0 +1,49 @@
<?xml version="1.0"?>
<!--
- 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) 1999 Netscape Communications Corporation. All
- Rights Reserved.
-
- Contributor(s):
- Ben Goodger
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://sidebar/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://editor/locale/sidebar-editor.dtd" >
<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('chrome://editor/content/sidebar-editor.rdf',
'NC:EditorSidebarRoot');" align="vertical">
<html:script src="chrome://sidebar/content/sidebar.js" />
<box id="sidebox" align="vertical" flex="100%">
<box class="sidebartitle">
<spring flex="100%"/>
<titledbutton class="borderless paneltitle"
value="&sidebar.reload.label;"
onclick="window.location.reload()" />
<titledbutton class="borderless paneltitle"
value="&sidebar.customize.label;"
onclick="var dialogWindow=customize();" />
</box>
</box>
</window>

View File

@ -0,0 +1,28 @@
<!--
- 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.
-
- Contributor(s):
- Ben Goodger
-->
<!-- extracted from ./sidebar-browser.rdf -->
<!ENTITY sidebar.flash.label "Flashes">
<!ENTITY sidebar.bookmarks.label "Bookmarks">
<!ENTITY sidebar.files.label "Files">

View File

@ -0,0 +1,27 @@
<!--
- 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.
-
- Contributor(s):
- Ben Goodger
-->
<!-- extracted from ./sidebar-browser.xul -->
<!ENTITY sidebar.reload.label "reload">
<!ENTITY sidebar.customize.label "customize...">