зеркало из https://github.com/mozilla/gecko-dev.git
Fix for 81575, Implement a new find in history dialog. This replaces the ugly old dual Bookmarks/History search, which had problems.
- Duplicate bookmarks find dialog code (since it's so small it's not worth factoring) - Make the history window know how to root its tree on a given URI - Add Find in History dialog XUL, JS, etc
This commit is contained in:
Родитель
461681bc41
Коммит
1980e31d1b
|
@ -0,0 +1,63 @@
|
|||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
*/
|
||||
|
||||
function Startup()
|
||||
{
|
||||
doSetOKCancel(find);
|
||||
var bundle = document.getElementById("historyBundle");
|
||||
document.getElementById("ok").label = bundle.getString("search_button_label");
|
||||
document.getElementById("searchField").focus();
|
||||
}
|
||||
|
||||
function find()
|
||||
{
|
||||
// Build up a find URI from the search fields and open a new window
|
||||
// rooted on the URI.
|
||||
var match = document.getElementById("matchList");
|
||||
var method = document.getElementById("methodList");
|
||||
var field = document.getElementById("searchField");
|
||||
var searchURI = "find:datasource=rdf:history"
|
||||
searchURI += "&match=" + match.selectedItem.value;
|
||||
searchURI += "&method=" + method.selectedItem.value;
|
||||
searchURI += "&text=" + escape(field.value);
|
||||
var hstWindow = findMostRecentWindow("history:searchresults", "chrome://communicator/content/history/history.xul", searchURI);
|
||||
|
||||
// Update the root of the tree if we're using an existing search window.
|
||||
if (!gCreatingNewWindow)
|
||||
hstWindow.setRoot(searchURI);
|
||||
|
||||
hstWindow.focus();
|
||||
close();
|
||||
}
|
||||
|
||||
var gCreatingNewWindow = false;
|
||||
function findMostRecentWindow(aType, aURI, aParam)
|
||||
{
|
||||
var WM = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
|
||||
WM = WM.QueryInterface(Components.interfaces.nsIWindowMediator);
|
||||
var topWindow = WM.getMostRecentWindow(aType);
|
||||
if (!topWindow) gCreatingNewWindow = true;
|
||||
return topWindow || openDialog("chrome://communicator/content/history/history.xul",
|
||||
"", "chrome,all,dialog=no", aParam);
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0"?> <!-- -*- Mode: HTML; indent-tabs-mode: nil; -*- -->
|
||||
<!--
|
||||
|
||||
The contents of this file are subject to the Netscape 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/NPL/
|
||||
|
||||
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 Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Ben Goodger <ben@netscape.com> (Original Author)
|
||||
-->
|
||||
|
||||
<!--
|
||||
"Find in History" window
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://communicator/locale/history/findHistory.dtd">
|
||||
|
||||
<window id="findHistoryWindow" style="width: 36em;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&findHistory.title;"
|
||||
orient="vertical" class="dialog"
|
||||
onload="Startup();">
|
||||
|
||||
<keyset id="dialogKeys"/>
|
||||
|
||||
<stringbundle id="historyBundle" src="chrome://communicator/locale/history/history.properties"/>
|
||||
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/history/findHistory.js"/>
|
||||
|
||||
<text class="label" value="&search.for.label;"/>
|
||||
<hbox autostretch="never" valign="middle">
|
||||
<menulist id="matchList">
|
||||
<menupopup>
|
||||
<menuitem value="http://home.netscape.com/NC-rdf#Name" label="&search.name.label;"/>
|
||||
<menuitem value="http://home.netscape.com/NC-rdf#URL" label="&search.url.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<menulist id="methodList">
|
||||
<menupopup>
|
||||
<menuitem value="contains" label="&search.contains.label;"/>
|
||||
<menuitem value="startswith" label="&search.startswith.label;"/>
|
||||
<menuitem value="endswith" label="&search.endswith.label;"/>
|
||||
<menuitem value="is" label="&search.is.label;"/>
|
||||
<menuitem value="isnot" label="&search.isnot.label;"/>
|
||||
<menuitem value="doesntcontain" label="&search.doesntcontain.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<textbox id="searchField" onkeypress="if (event.keyCode == 13) find();" flex="1"/>
|
||||
</hbox>
|
||||
|
||||
<separator/>
|
||||
|
||||
<box id="okCancelButtonsRight"/>
|
||||
|
||||
</window>
|
||||
|
|
@ -53,6 +53,11 @@ function HistoryInit() {
|
|||
|
||||
gGlobalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIBrowserHistory);
|
||||
|
||||
if ("arguments" in window && window.arguments && window.arguments.length >= 1) {
|
||||
// We have been supplied a resource URI to root the tree on
|
||||
setRoot(window.arguments[0]);
|
||||
}
|
||||
|
||||
var children = document.getElementById('treechildren-bookmarks');
|
||||
if (children.firstChild)
|
||||
gHistoryTree.selectItem(children.firstChild);
|
||||
|
@ -206,3 +211,14 @@ function OpenURL(event, node, root)
|
|||
openTopWin(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Root the tree on a given URI (used for displaying search results)
|
||||
*/
|
||||
function setRoot(root)
|
||||
{
|
||||
var windowNode = document.getElementById("history-window");
|
||||
windowNode.setAttribute("title", gHistoryBundle.getString("search_results_title"));
|
||||
gHistoryTree.setAttribute("ref", root);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
<!DOCTYPE window SYSTEM "chrome://communicator/locale/history/history.dtd" >
|
||||
|
||||
<window title="&historyWindowTitle.label;" id="bookmark-window"
|
||||
<window title="&historyWindowTitle.label;" id="history-window"
|
||||
onload="HistoryInit();"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="500" height="400"
|
||||
|
@ -56,7 +56,7 @@
|
|||
commandupdater="true"
|
||||
events="select"
|
||||
oncommandupdate="updateHistoryCommands()"/>
|
||||
<command id="cmd_searchHistory" oncommand="window.openDialog('chrome://communicator/content/bookmarks/bm-find.xul', 'FindBookmarksWindow', 'dialog=no,close,chrome,resizable', 'history');"/>
|
||||
<command id="cmd_searchHistory" oncommand="window.openDialog('chrome://communicator/content/history/findHistory.xul', 'FindHistoryWindow', 'dialog=no,centerscreen,resizable=no,chrome,dependent');"/>
|
||||
|
||||
<!-- File Menu -->
|
||||
<command id="cmd_newNavigator"/>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
<!ENTITY search.name.label "name">
|
||||
<!ENTITY search.url.label "location">
|
||||
<!ENTITY search.startswith.label "starts with">
|
||||
<!ENTITY search.endswith.label "ends with">
|
||||
<!ENTITY search.is.label "is">
|
||||
<!ENTITY search.isnot.label "is not">
|
||||
<!ENTITY search.contains.label "contains">
|
||||
<!ENTITY search.doesntcontain.label "doesn't contain">
|
||||
<!ENTITY search.for.label "Find visited documents whose">
|
||||
<!ENTITY findHistory.title "Find in History">
|
||||
|
|
@ -9,3 +9,6 @@ finduri-AgeInDays-is=%S days ago
|
|||
finduri-AgeInDays-isgreater=Older than %S days
|
||||
|
||||
finduri-Hostname-is-=(no host)
|
||||
|
||||
search_button_label=Find
|
||||
search_results_title=Search Results
|
Загрузка…
Ссылка в новой задаче