[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - sitesmanager.js:1.14
Paul Everitt
paul@zope.com
Sun, 23 Mar 2003 16:09:46 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv4608/lib
Modified Files:
sitesmanager.js
Log Message:
Started on add folder, turned toolbar button into a pulldown menu
=== Packages/Moztop/moztop/content/lib/sitesmanager.js 1.13 => 1.14 ===
--- Packages/Moztop/moztop/content/lib/sitesmanager.js:1.13 Sun Mar 23 11:34:38 2003
+++ Packages/Moztop/moztop/content/lib/sitesmanager.js Sun Mar 23 16:09:16 2003
@@ -245,6 +245,61 @@
}
+SitesManager.prototype.createResource = function(newtypeurn) {
+
+ /* This function "opens" the selected Tree resource. */
+ var rdf = this.getSelectedResource();
+
+ // We're going to make up a URN, it doesn't get set until the user
+ // saves it. todo: save this in a temp datasource, like Drafts
+ var resourcetitle = "Untitled-1";
+ var urn = "urn:localsite:drafts:untitled1";
+
+ // Find viewer containers
+ var tabs = document.getElementById("active-contents-tabs");
+ var panels = document.getElementById("active-contents-tabpanels");
+
+ // Do not open resource if already opened.
+ for (var i = 0; i < panels.childNodes.length; i++) {
+ if (panels.childNodes[i].getAttribute('urn') == urn)
+ return;
+ }
+
+ // Make an appropriate log entry
+ logmanager.addMessage("Opening " + resourcetitle,
+ 'SiteManager.openSelectedResource',
+ "Opening " + resourcetitle);
+
+ // Retrieving resource type resource for chosen resource type
+ type = this.getResource(newtypeurn);
+ // XXX: The type registry should really have an attribute for this.
+ typeViewerName = type.getTarget(this.styleidprop).getValue() + "viewer";
+
+ // Creating resource viewer
+ var viewer = document.createElement(typeViewerName);
+
+ // Setting initialization attributes
+ viewer.id = typeViewerName + "-" + new Date().getTime();
+ viewer.setAttribute("urn", urn);
+ viewer.setAttribute("resourcetitle", resourcetitle);
+
+ // Prepare tabs
+ var tab = document.createElement("tab");
+ tab.setAttribute("label", resourcetitle);
+ tab.setAttribute("id", resourcetitle + "-tab");
+
+ // Add new viewer to opened resources tabs
+ tabs.appendChild(tab);
+ panels.appendChild(viewer);
+
+ // Make the new tab/panel the active one
+ tabs.selectedItem = tab;
+ panels.selectedPanel = viewer;
+
+ return;
+}
+
+
DataSourceManager.prototype.removeSelectedResource = function() {
/* This function deletes the selected Tree resource. */
resource = this.getSelectedResource();