From f7b26a1e4e3b392ec90d0ffe84e69ea74599b9fb Mon Sep 17 00:00:00 2001 From: "rjc%netscape.com" Date: Thu, 27 Jul 2000 07:47:36 +0000 Subject: [PATCH] Fixes for various sidebar panels for bug # 42718. Also, set page title for FTP/FILE displays. Finally, fix a bug (can't remember the bug # at the moment) with clicking on the scrollbar... basically, make sure the click is on a before processing the click. r=me --- xpfe/browser/resources/content/navigator.js | 1 + .../bookmarks/resources/bm-panel.js | 14 +++-- .../bookmarks/resources/bookmarks.js | 9 ++- xpfe/components/directory/directory.js | 55 +++++++++++++++---- xpfe/components/directory/directory.xul | 2 +- .../related/resources/related-panel.js | 20 ++++++- 6 files changed, 80 insertions(+), 21 deletions(-) diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index 0cb344428dee..087cbfbfc03c 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -1608,6 +1608,7 @@ function checkForDirectoryListing() { !window._content.HTTPIndex.constructor ) { // Give directory .xul/.js access to browser instance. window._content.defaultCharacterset = appCore.GetDocumentCharset(); + window._content.parentWindow = window; } } diff --git a/xpfe/components/bookmarks/resources/bm-panel.js b/xpfe/components/bookmarks/resources/bm-panel.js index 4aa0e0189bdd..3f26eabe1a35 100644 --- a/xpfe/components/bookmarks/resources/bm-panel.js +++ b/xpfe/components/bookmarks/resources/bm-panel.js @@ -83,12 +83,14 @@ function OpenBookmarkURL(node, datasources) else { if(appCore) - appCore.loadUrl(url); - else { - // May be it s'd look for a Browser window or create one - // and redirect this to the browser. - dump("BrowserAppCore is not initialised\n"); + { + // support session history (if appCore is available) + appCore.loadUrl(url); + } + else + { + // fallback case (if appCore isn't available) + window._content.location = url; } - } } diff --git a/xpfe/components/bookmarks/resources/bookmarks.js b/xpfe/components/bookmarks/resources/bookmarks.js index 965f6e01759a..099174cfdbb7 100644 --- a/xpfe/components/bookmarks/resources/bookmarks.js +++ b/xpfe/components/bookmarks/resources/bookmarks.js @@ -610,11 +610,18 @@ function OpenURL(event, node, root) } -function update_sort_menuitems(column, direction) { +function update_sort_menuitems(column, direction) +{ var unsorted_menuitem = document.getElementById("unsorted_menuitem"); var sort_ascending = document.getElementById('sort_ascending'); var sort_descending = document.getElementById('sort_descending'); + // as this function may be called from various places, including the + // bookmarks sidebar panel (which doesn't have any menu items) + // ensure that the document contains the elements + if ((!unsorted_menuitem) || (!sort_ascending) || (!sort_descending)) + return; + if (direction == "natural") { unsorted_menuitem.setAttribute('checked','true'); sort_ascending.setAttribute('disabled','true'); diff --git a/xpfe/components/directory/directory.js b/xpfe/components/directory/directory.js index 24f9015d1cb9..72a19a330755 100644 --- a/xpfe/components/directory/directory.js +++ b/xpfe/components/directory/directory.js @@ -21,20 +21,29 @@ */ /* - Script for the directory window - */ + + // By the time this runs, The 'HTTPIndex' variable will have been // magically set on the global object by the native code. + + function debug(msg) { // Uncomment to print out debug info. dump(msg); } + + +// get handle to the BrowserAppCore in the content area. +var appCore = window._content.appCore; + + + function Init() { debug("directory.js: Init()\n"); @@ -68,31 +77,57 @@ function Init() // Use a default character set. if (window._content.defaultCharacterset) - httpDS.encoding = window._content.defaultCharacterset; + { + httpDS.encoding = window._content.defaultCharacterset; + } } } + // set window title + var theWindow = window._content.parentWindow; + if (theWindow) + { + theWindow.title = baseURI; + } + // root the tree (do this last) tree.setAttribute("ref", baseURI); } -function OnClick(event) +function OnClick(event, node) { if( event.type == "click" && - ( event.button != 1 || event.detail != 2 ) ) - return false; + ( event.button != 1 || event.detail != 2 || node.nodeName != "treeitem") ) + return(false); if( event.type == "keypress" && event.which != 13 ) - return false; - + return(false); + var tree = document.getElementById("tree"); if( tree.selectedItems.length == 1 ) { var selectedItem = tree.selectedItems[0]; - + var theID = selectedItem.getAttribute("id"); + //if( selectedItem.getAttribute( "type" ) == "FILE" ) - window._content.location.href = selectedItem.getAttribute('id'); + if(appCore) + { + // support session history (if appCore is available) + appCore.loadUrl(theID); + } + else + { + // fallback case (if appCore isn't available) + window._content.location.href = theID; + } + + // set window title + var theWindow = window._content.parentWindow; + if (theWindow) + { + theWindow.title = baseURI; + } } } diff --git a/xpfe/components/directory/directory.xul b/xpfe/components/directory/directory.xul index fc45a0b12107..dc5b60acbff0 100644 --- a/xpfe/components/directory/directory.xul +++ b/xpfe/components/directory/directory.xul @@ -72,7 +72,7 @@ - + diff --git a/xpfe/components/related/resources/related-panel.js b/xpfe/components/related/resources/related-panel.js index 69f06d5cda6b..1d46df7f03c0 100644 --- a/xpfe/components/related/resources/related-panel.js +++ b/xpfe/components/related/resources/related-panel.js @@ -21,17 +21,22 @@ */ /* - Code for the Related Links Sidebar Panel - */ + + function debug(msg) { // uncomment for noise // dump(msg); } + + +// get handle to the BrowserAppCore in the content area. +var appCore = window._content.appCore; + // The content window that we're supposed to be observing. var ContentWindow = window._content; @@ -270,7 +275,16 @@ function openURL(event, root) { } - ContentWindow.location = id; + if(appCore) + { + // support session history (if appCore is available) + appCore.loadUrl(id); + } + else + { + // fallback case (if appCore isn't available) + ContentWindow.location = id; + } } addEventListener("load", Init, false);