[Zope-CVS] CVS: Packages/Moztop/moztop/content/navigation - navigation.js:1.1 navigationoverlay.xul:1.1
Stephan Richter
srichter@cbu.edu
Thu, 20 Mar 2003 11:30:24 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/navigation
In directory cvs.zope.org:/tmp/cvs-serv6680/navigation
Added Files:
navigation.js navigationoverlay.xul
Log Message:
Renaming explorer --> navigation
=== Added File Packages/Moztop/moztop/content/navigation/navigation.js ===
/*****************************************************************************
*
* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
* All Rights Reserved.
*
* This software is subject to the provisions of the Zope Public License,
* Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
******************************************************************************
Navigation library; here to manage Content Object Tree.
$Id: navigation.js,v 1.1 2003/03/20 16:30:22 srichter Exp $
******************************************************************************/
var xmlRpcClient;
function getXmlRpc() {
if (!xmlRpcClient) xmlRpcClient = getClient();
return xmlRpcClient;
}
var Listener = {
onResult: function(client, ctxt, result) {
result = result.QueryInterface(
Components.interfaces.nsISupportsCString);
alert(result.toString());
},
onFault: function(client, ctxt, fault) {
alert('Fault! ' + fault + '\n');
},
onError: function(client, ctxt, status, errorMsg) {
alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
}
};
/* Send the Add request via XML-RPC and handle the result. */
function add(parent, obj_type, obj_name) {
var xmlRpc = getXmlRpc();
xmlRpc.init(XMLRPC_BASE + parent);
var type = xmlRpc.createType(xmlRpc.STRING, {});
type.data = obj_type;
var name = xmlRpc.createType(xmlRpc.STRING, {});
name.data = obj_name;
xmlRpc.asyncCall(Listener, null, 'createAndAdd', [type, name], 2);
}
/* Add a content object to the folder that is selected in the tree. */
function addContentObject() {
var type = document.getElementById("field_obj_type").selectedItem.label;
var name = document.getElementById("field_obj_name").value;
var tree = document.getElementById("navigationtree");
var parent = getContainerPath()
add(parent, type, name);
}
/* Delete a content object from the folder that is selected in the tree. */
function deleteContentObject() {
var obj_name = getObjectName();
var parent = getContainerPath();
var xmlRpc = getXmlRpc();
xmlRpc.init(XMLRPC_BASE + parent);
var name = xmlRpc.createType(xmlRpc.STRING, {});
name.data = obj_name;
xmlRpc.asyncCall(Listener, null, 'deleteObject', [name], 1);
}
/* Rename a content object in the folder that is selected in the tree. */
function renameContentObject() {
var new_name = document.getElementById("field_obj_name").value;
var old_name = getObjectName();
var parent = getContainerPath();
rename(parent, old_name, new_name);
}
function rename(parent, old_name, new_name) {
var xmlRpc = getXmlRpc();
xmlRpc.init(XMLRPC_BASE + parent);
var oldName = xmlRpc.createType(xmlRpc.STRING, {});
oldName.data = old_name;
var newName = xmlRpc.createType(xmlRpc.STRING, {});
newName.data = new_name;
xmlRpc.asyncCall(Listener, null, 'renameObject', [oldName, newName], 2);
}
function cutContentObject() {
var obj_name = getObjectName();
var path = getContainerPath();
alert('Called cutContentObject for ' + obj_name + ' on ' + path +'.');
}
function copyContentObject() {
var obj_name = getObjectName();
var parent = getContainerPath();
var xmlRpc = getXmlRpc();
xmlRpc.init(XMLRPC_BASE + parent);
var name = xmlRpc.createType(xmlRpc.STRING, {});
name.data = obj_name;
xmlRpc.asyncCall(Listener, null, 'copyObject', [name], 1);
}
function pasteContentObject() {
var path = getContainerPath();
alert('Called pasteContentObject on ' + path +'.');
}
/* Utility functions */
function getPath() {
var tree = document.getElementById("navigationtree");
var index = tree.view.selection.currentIndex;
var rdf = tree.view.getItemAtIndex(index).resource;
var path = rdf.Value.replace('urn:navigation:data', '');
while (path.indexOf(":") > -1)
path = path.replace(":", "/");
return path
}
function getContainerPath() {
var path = getPath()
var obj_name = getObjectName()
var container = path.substring(0, path.length-obj_name.length);
return container
}
function getObjectName() {
var path = getPath();
var parts = path.split('/');
var obj_name = parts[parts.length-1];
return obj_name
}
=== Added File Packages/Moztop/moztop/content/navigation/navigationoverlay.xul ===
<?xml version="1.0"?>
<overlay id="NavigationOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="navigation.js"/>
<vbox id="navigation" flex="3">
<label flex="1" id="navigation-ishidden"
value="No sites defined in this Moztop" hidden="true"/>
<tree flex="1" hidden="false"
id="navigationtree" ref="urn:moztop:sites"
datasources="rdf:null"
ondblclick="sitesmanager.openSelectedResource();"
containment="http://home.netscape.com/NC-rdf#subitems">
<treecols>
<treecol id="ResourceNameColumn" label="Name" primary="true" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="TypeColumn" label="Type" flex="1" hidden="true"/>
</treecols>
<template>
<rule>
<conditions>
<content uri="?uri" />
<triple subject="?uri"
predicate="http://home.netscape.com/NC-rdf#subitems"
object="?subitems" />
<member container="?subitems" child="?subitem" />
</conditions>
<bindings>
<binding subject="?subitem"
predicate="http://www.zope.org/rdf#resourcetype"
object="?resourcetype" />
<binding subject="?subitem"
predicate="http://www.purl.org/dc/1.1#title"
object="?name" />
<binding subject="?resourcetype"
predicate="http://www.purl.org/dc/1.1#title"
object="?resourcetypetitle"/>
<binding subject="?resourcetype"
predicate="http://www.zope.org/rdf#styleid"
object="?styleid"/>
</bindings>
<action>
<treechildren flex="1">
<treeitem uri="?subitem">
<treerow>
<treecell properties="zope-?styleid" label="?name"/>
<treecell label="?resourcetypetitle"/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
</tree>
</vbox>
</overlay>