зеркало из https://github.com/mozilla/pjs.git
Add SiteMap icon and relate-panel style sheet. Make code smarter so that it only fetches related links when the RL folder is open.
This commit is contained in:
Родитель
29acb92d6c
Коммит
4b4674dcaa
|
@ -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")) {
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml version="1.0"?> <!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
|
||||
<!--
|
||||
|
||||
The contents of this file are subject to the Netscape Public License
|
||||
Version 1.0 (the "NPL"); you may not use this file except in
|
||||
compliance with the NPL. You may obtain a copy of the NPL at
|
||||
http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
for the specific language governing rights and limitations under the
|
||||
NPL.
|
||||
|
||||
The Initial Developer of this code under the NPL is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
Reserved.
|
||||
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="resource:/res/rdf/sidebar.css" type="text/css"?>
|
||||
<?xml-stylesheet href="related-panel.css" type="text/css"?>
|
||||
|
||||
<window
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
|
@ -16,7 +36,7 @@
|
|||
<tree id="Tree"
|
||||
flex="100%"
|
||||
datasources="rdf:null"
|
||||
ondblclick="return OpenuRL(event.target.parentNode);">
|
||||
ondblclick="return OnDblClick(event.target.parentNode);">
|
||||
|
||||
<template>
|
||||
<!-- XXX need a rule for separators -->
|
||||
|
@ -44,12 +64,12 @@
|
|||
|
||||
<treebody>
|
||||
<treeitem id="NC:RelatedLinks">
|
||||
<treecell><treeindentation/>Related Links</treecell>
|
||||
<treecell><treeindentation/><titledbutton />Related Links</treecell>
|
||||
<treecell></treecell>
|
||||
</treeitem>
|
||||
|
||||
<treeitem id="NC:SiteMapRoot">
|
||||
<treecell><treeindentation/>Site Map</treecell>
|
||||
<treecell><treeindentation/><titledbutton />Site Map</treecell>
|
||||
<treecell></treecell>
|
||||
</treeitem>
|
||||
</treebody>
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
related-panel.xul
|
||||
related-panel.js
|
|
@ -26,7 +26,9 @@ include $(topsrcdir)/config/rules.mk
|
|||
|
||||
FILES = \
|
||||
related-panel.xul \
|
||||
related-panel.css \
|
||||
related-panel.js \
|
||||
sitemap.gif \
|
||||
$(NULL)
|
||||
|
||||
FILES := $(addprefix $(srcdir)/, $(FILES))
|
||||
|
|
|
@ -19,7 +19,9 @@ DEPTH=..\..\..\..
|
|||
|
||||
FILES=\
|
||||
related-panel.xul \
|
||||
related-panel.css \
|
||||
related-panel.js \
|
||||
sitemap.gif \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -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")) {
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml version="1.0"?> <!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
|
||||
<!--
|
||||
|
||||
The contents of this file are subject to the Netscape Public License
|
||||
Version 1.0 (the "NPL"); you may not use this file except in
|
||||
compliance with the NPL. You may obtain a copy of the NPL at
|
||||
http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
for the specific language governing rights and limitations under the
|
||||
NPL.
|
||||
|
||||
The Initial Developer of this code under the NPL is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
Reserved.
|
||||
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="resource:/res/rdf/sidebar.css" type="text/css"?>
|
||||
<?xml-stylesheet href="related-panel.css" type="text/css"?>
|
||||
|
||||
<window
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
|
@ -16,7 +36,7 @@
|
|||
<tree id="Tree"
|
||||
flex="100%"
|
||||
datasources="rdf:null"
|
||||
ondblclick="return OpenuRL(event.target.parentNode);">
|
||||
ondblclick="return OnDblClick(event.target.parentNode);">
|
||||
|
||||
<template>
|
||||
<!-- XXX need a rule for separators -->
|
||||
|
@ -44,12 +64,12 @@
|
|||
|
||||
<treebody>
|
||||
<treeitem id="NC:RelatedLinks">
|
||||
<treecell><treeindentation/>Related Links</treecell>
|
||||
<treecell><treeindentation/><titledbutton />Related Links</treecell>
|
||||
<treecell></treecell>
|
||||
</treeitem>
|
||||
|
||||
<treeitem id="NC:SiteMapRoot">
|
||||
<treecell><treeindentation/>Site Map</treecell>
|
||||
<treecell><treeindentation/><titledbutton />Site Map</treecell>
|
||||
<treecell></treecell>
|
||||
</treeitem>
|
||||
</treebody>
|
||||
|
|
Загрузка…
Ссылка в новой задаче