205440 patch by kd-moz@tprac.de r=shliang sr=jag JavaScript error in internetresults.xul/.js

This commit is contained in:
cbiesinger%web.de 2003-07-01 20:04:30 +00:00
Родитель c4c528ea38
Коммит 02dd545de1
4 изменённых файлов: 131 добавлений и 62 удалений

Просмотреть файл

@ -1,3 +1,48 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Robert John Churchill.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert John Churchill <rjc@netscape.com> (Original Author)
* Ben Goodger <ben@netscape.com>
* Daniel Matejka <danm@netscape.com>
* Eric Pollmann <pollmann@netscape.com>
* Ray Whitmer <rayw@netscape.com>
* Peter Annema <disttsc@bart.nl>
* Blake Ross <blakeross@telocity.com>
* Joe Hewitt <hewitt@netscape.com>
* Jan Varga <varga@utcruk.sk>
* Karsten Duesterloh <kd-moz@tprac.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function searchResultsOpenURL(event)
{
var tree = document.getElementById("resultsList");
@ -209,11 +254,12 @@ function listSelect(event)
if (tree.view.selection.count != 1)
return false;
var selection = tree.contentView.getItemAtIndex(tree.currentIndex);
doResultClick(selection);
return doResultClick(selection);
}
function listClick(event)
{
{ // left double click opens URL
if (event.detail == 2 && event.button == 0)
searchResultsOpenURL(event);
return true; // always allow further click processing
}

Просмотреть файл

@ -49,8 +49,8 @@
<tree id="resultsList" flex="1" class="plain"
datasources="rdf:internetsearch" context="contextual"
onselect="listSelect(event);"
onclick="listClick(event);">
onselect="return listSelect(event);"
onclick ="return listClick (event);">
<treecols onclick="doSort(event.target.id, 'http://home.netscape.com/NC-rdf#PageRank');">
<treecol id="NameColumn" primary="true" label="&name.column.label;"

Просмотреть файл

@ -42,13 +42,11 @@
*
* ***** END LICENSE BLOCK ***** */
const WMEDIATOR_CONTRACTID = "@mozilla.org/appshell/window-mediator;1";
const ISEARCH_CONTRACTID = "@mozilla.org/rdf/datasource;1?name=internetsearch";
const RDFSERVICE_CONTRACTID = "@mozilla.org/rdf/rdf-service;1";
const BMARKS_CONTRACTID = "@mozilla.org/browser/bookmarks-service;1";
const nsIBookmarksService = Components.interfaces.nsIBookmarksService;
const nsIWindowMediator = Components.interfaces.nsIWindowMediator;
const nsIRDFService = Components.interfaces.nsIRDFService;
const nsIRDFLiteral = Components.interfaces.nsIRDFLiteral;
const nsIRDFDataSource = Components.interfaces.nsIRDFDataSource;
@ -903,33 +901,6 @@ function OpenSearch(aSearchStr, engineURIs)
setTimeout("checkSearchProgress()", 1000);
}
function switchTab(aPageIndex)
{
var deck = document.getElementById("advancedDeck");
deck.setAttribute("selectedIndex", aPageIndex);
// decide whether to show/hide/enable/disable save search query button
if (aPageIndex != 0)
return;
var ds = document.getElementById("resultList").database;
if (!ds)
return;
var haveSearchRef = false;
var rdf = Components.classes[RDFSERVICE_CONTRACTID].getService(nsIRDFService);
// look for last search URI
var source = rdf.GetResource("NC:LastSearchRoot", true);
var childProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#ref", true);
var target = ds.GetTarget(source, childProperty, true);
if (target) {
target = target.QueryInterface(nsIRDFLiteral).Value;
if (target)
haveSearchRef = true;
}
}
function saveSearch()
{
var ds = document.getElementById("resultList").database;
@ -1070,33 +1041,6 @@ function loadURLInContent(url)
navigatorWindow.loadURI(url);
}
// retrieves the most recent navigator window
function getNavigatorWindow(aOpenFlag)
{
var navigatorWindow;
// if this is a browser window, just use it
if ("document" in top) {
var possibleNavigator = top.document.getElementById("main-window");
if (possibleNavigator &&
possibleNavigator.getAttribute("windowtype") == "navigator:browser")
navigatorWindow = top;
}
// if not, get the most recently used browser window
if (!navigatorWindow) {
var wm = Components.classes[WMEDIATOR_CONTRACTID].getService(nsIWindowMediator);
navigatorWindow = wm.getMostRecentWindow("navigator:browser");
}
// if no browser window available and it's ok to open a new one, do so
if (!navigatorWindow && aOpenFlag) {
var navigatorChromeURL = search_getBrowserURL();
navigatorWindow = openDialog(navigatorChromeURL, "_blank", "chrome,all,dialog=no");
}
return navigatorWindow;
}
function search_getBrowserURL()
{
return nsPreferences.copyUnicharPref("browser.chromeURL", "chrome://navigator/content/navigator.xul");

Просмотреть файл

@ -1,5 +1,39 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Robert John Churchill.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert John Churchill <rjc@netscape.com> (Original Author)
* Karsten Duesterloh <kd-moz@tprac.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function fillContextMenu(name, treeName)
{
@ -367,3 +401,48 @@ function setInitialSort(node, sortDirection)
}
return(true);
}
function switchTab(aPageIndex)
{
var deck = document.getElementById("advancedDeck");
if (!deck)
{ // get the search-panel deck the hard way
// otherwise the switchTab call from internetresults.xul would fail
var oSearchPanel = getNavigatorWindow(false).sidebarObj.panels.get_panel_from_id("urn:sidebar:panel:search");
if (!oSearchPanel)
return;
deck = oSearchPanel.get_iframe().contentDocument.getElementById("advancedDeck")
}
deck.setAttribute("selectedIndex", aPageIndex);
}
// retrieves the most recent navigator window
function getNavigatorWindow(aOpenFlag)
{
var navigatorWindow;
// if this is a browser window, just use it
if ("document" in top) {
var possibleNavigator = top.document.getElementById("main-window");
if (possibleNavigator &&
possibleNavigator.getAttribute("windowtype") == "navigator:browser")
navigatorWindow = top;
}
// if not, get the most recently used browser window
if (!navigatorWindow) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
navigatorWindow = wm.getMostRecentWindow("navigator:browser");
}
// if no browser window available and it's ok to open a new one, do so
if (!navigatorWindow && aOpenFlag) {
var navigatorChromeURL = search_getBrowserURL();
navigatorWindow = openDialog(navigatorChromeURL, "_blank", "chrome,all,dialog=no");
}
return navigatorWindow;
}