From 4b4674dcaaf0f107509a5af960ff20c6693eee9f Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Mon, 7 Jun 1999 22:21:53 +0000 Subject: [PATCH] Add SiteMap icon and relate-panel style sheet. Make code smarter so that it only fetches related links when the RL folder is open. --- suite/common/related/related-panel.js | 44 ++++++++++++++++--- suite/common/related/related-panel.xul | 28 ++++++++++-- xpfe/components/related/resources/MANIFEST | 2 - xpfe/components/related/resources/Makefile.in | 2 + .../components/related/resources/makefile.win | 2 + .../related/resources/related-panel.js | 44 ++++++++++++++++--- .../related/resources/related-panel.xul | 28 ++++++++++-- xpfe/components/related/resources/sitemap.gif | 0 8 files changed, 126 insertions(+), 24 deletions(-) create mode 100644 xpfe/components/related/resources/sitemap.gif diff --git a/suite/common/related/related-panel.js b/suite/common/related/related-panel.js index d5cceaae60c..cd4907d55cc 100644 --- a/suite/common/related/related-panel.js +++ b/suite/common/related/related-panel.js @@ -35,14 +35,19 @@ Handler = Handler.QueryInterface(Components.interfaces.nsIRelatedLinksHandler); // Our observer object var Observer = { Observe: function(subject, topic, data) { - //dump("_Observe(" + subject + ", " + topic + ", " + data + ")\n"); - + // Convert the subject to a nsIDOMWindow, which is what it should be. subject = subject.QueryInterface(Components.interfaces.nsIDOMWindow); - //dump("subject = " + subject + "\n"); - //dump("ContentWindow = " + ContentWindow + "\n"); // We can't use '==' until the DOM is converted to XPIDL. - if (subject.Equals(ContentWindow)) { + if (! subject.Equals(ContentWindow)) { + return; + } + + // Okay, it's a hit. Before we go out and fetch RL data, make sure that + // the RelatedLinks folder is open. + var root = document.getElementById('NC:RelatedLinks'); + + if (root.getAttribute('open') == 'true') { Handler.URL = data; } } @@ -55,8 +60,6 @@ function Init() { var Tree = document.getElementById("Tree"); Tree.database.AddDataSource(Handler.QueryInterface(Components.interfaces.nsIRDFDataSource)); - Handler.URL = ContentWindow.location; - // Install the observer so we'll be notified when new content is loaded. var ObserverService = Components.classes["component://netscape/observer-service"].getService(); ObserverService = ObserverService.QueryInterface(Components.interfaces.nsIObserverService); @@ -67,6 +70,33 @@ function Init() { } +function OnDblClick(treeitem) +{ + // Deal with a double-click + + // First, see if they're opening the related links node. If so, + // we'll need to go out and fetch related links _now_. + if (treeitem.getAttribute('id') == 'NC:RelatedLinks' && + treeitem.getAttribute('open') != 'true') { + Handler.URL = ContentWindow.location; + return; + } + + // Next, check to see if it's a container. If so, then just let + // the tree do its open and close stuff. + if (treeitem.getAttribute('container') == 'true') { + return; + } + + // Okay, it's not a container. See if it has a URL, and if so, open it. + var URL = treeitem.getAttribute('URL'); + if (URL) { + ContentWindow.location = URL; + return; + } +} + + function Boot() { // Kludge to deal with no onload in XUL. if (document.getElementById("Tree")) { diff --git a/suite/common/related/related-panel.xul b/suite/common/related/related-panel.xul index 66d72a237b6..3fe767958e0 100644 --- a/suite/common/related/related-panel.xul +++ b/suite/common/related/related-panel.xul @@ -1,5 +1,25 @@ - + + + + + ondblclick="return OnDblClick(event.target.parentNode);">