home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2001 December / VPR0112B.ISO / NETSCAPE6 / N6Setup.exe / bin / chrome / comm.jar / content / communicator / bookmarks / bookmarks.js < prev   
Text File  |  2001-05-09  |  4KB  |  94 lines

  1. /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public
  4.  * License Version 1.1 (the "License"); you may not use this file
  5.  * except in compliance with the License. You may obtain a copy of
  6.  * the License at http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the License is distributed on an "AS
  9.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10.  * implied. See the License for the specific language governing
  11.  * rights and limitations under the License.
  12.  *
  13.  * The Original Code is mozilla.org code.
  14.  *
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation.  Portions created by Netscape are
  17.  * Copyright (C) 1998 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  *
  20.  * Contributor(s):
  21.  *   Ben Goodger <ben@netscape.com> (Original Author, v2.0)
  22.  *   Peter Annema <disttsc@bart.nl>
  23.  *   Blake Ross   <blakeross@telocity.com>
  24.  */
  25.  
  26. ////////////////////////////////////////////////////////////////////////////////
  27. // Get the two bookmarks utility libraries running, attach controllers, focus
  28. // tree widget, etc.
  29. function Startup()
  30. {
  31.   // Create the Bookmarks Shell
  32.   var bookmarksTree = document.getElementById("bookmarksTree");
  33.   gBookmarksShell = new BookmarksWindowTree (bookmarksTree.database);
  34.  
  35.   // Set up the tree controller
  36.   bookmarksTree.controllers.appendController(gBookmarksShell.controller);
  37.  
  38.   const windowNode = document.getElementById("bookmark-window");
  39.   // If we've been opened with a parameter, root the tree on it.
  40.   if ("arguments" in window && window.arguments[0]) {
  41.     var uri = window.arguments[0];
  42.     bookmarksTree.setAttribute("ref", uri);
  43.     var title = "";
  44.     if (uri.substring(0,5) == "find:") {
  45.       title = gBookmarksShell.getLocaleString("search_results_title");
  46.       // Update the windowtype so that future searches are directed 
  47.       // there and the window is not re-used for bookmarks. 
  48.       windowNode.setAttribute("windowtype", "bookmarks:searchresults");
  49.     }
  50.     else {
  51.       const krNameArc = gBookmarksShell.RDF.GetResource(NC_NS + "Name");
  52.       const krRoot = gBookmarksShell.RDF.GetResource(window.arguments[0]);
  53.       var rName = gBookmarksShell.db.GetTarget(krRoot, krNameArc, true);
  54.       title = rName.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  55.     }
  56.     const titleString = gBookmarksShell.getLocaleString("window_title");
  57.     windowNode.setAttribute("title", titleString.replace(/%folder_name%/gi, title));
  58.   }
  59.   else {
  60.     var rootfoldername = gBookmarksShell.getLocaleString("bookmarks_root");
  61.     const kProfileContractID = "@mozilla.org/profile/manager;1";
  62.     const kProfileIID = Components.interfaces.nsIProfile;
  63.     const kProfile = Components.classes[kProfileContractID].getService(kProfileIID);
  64.     rootfoldername = rootfoldername.replace(/%user_name%/, kProfile.currentProfile);
  65.     windowNode.setAttribute("title", rootfoldername);
  66.   }
  67.  
  68.   // Update to the last sort.
  69.   RefreshSort();
  70.  
  71.   var kids = document.getElementById("treechildren-bookmarks");
  72.   if (kids.firstChild)
  73.     bookmarksTree.selectItem(kids.firstChild);
  74.  
  75.   bookmarksTree.focus();
  76. }
  77.  
  78. function Shutdown ()
  79. {
  80.   // Store current window position and size in window attributes (for persistence).
  81.   var win = document.getElementById("bookmark-window");
  82.   win.setAttribute("x", screenX);
  83.   win.setAttribute("y", screenY);
  84.   win.setAttribute("height", outerHeight);
  85.   win.setAttribute("width", outerWidth);
  86.  
  87.   gBookmarksShell.flushDataSource();
  88. }
  89.  
  90. ////////////////////////////////////////////////////////////////////////////////
  91. // Class representing the bookmarks window's tree. This subclasses BookmarksTree,
  92. // which contains methods generic to any tree-like bookmarks UI representation.
  93. // This class contains data specific to the tree in this window, e.g. number of
  94. // clicks required to load a bookmark, which difSs wcli.a bDodi(to load a booae