Add support for search modes.

This commit is contained in:
rjc%netscape.com 2006-09-14 05:50:09 +00:00
parent 36a767f197
commit bdfe16dab8
3 changed files with 55 additions and 10 deletions

View File

@ -29,12 +29,14 @@ var startPageDefault = "about:blank";
// in case we fail to get the home page, load this
var homePageDefault = bundle.GetStringFromName( "homePageDefault" );
try {
pref = Components.classes['component://netscape/preferences'];
pref = pref.getService();
pref = pref.QueryInterface(Components.interfaces.nsIPref);
try
{
pref = Components.classes["component://netscape/preferences"];
if (pref) pref = pref.getService();
if (pref) pref = pref.QueryInterface(Components.interfaces.nsIPref);
}
catch (ex) {
catch (ex)
{
dump("failed to get prefs service!\n");
pref = null;
}
@ -353,6 +355,15 @@ function Startup()
}
}
try
{
var searchMode = pref.GetIntPref("browser.search.mode");
setBrowserSearchMode(searchMode);
}
catch(ex)
{
}
// Check for window.arguments[0]. If present, go to that url.
if ( window.arguments && window.arguments[0] ) {
// Load it using yet another psuedo-onload handler.
@ -983,6 +994,30 @@ function OpenSearch(tabName, forceDialogFlag, searchStr)
}
}
function setBrowserSearchMode(searchMode)
{
// set search mode preference
try
{
pref.SetIntPref("browser.search.mode", searchMode);
}
catch(ex)
{
}
// update search menu
var simpleMenuItem = document.getElementById("simpleSearch");
if (simpleMenuItem)
{
simpleMenuItem.setAttribute("checked", (searchMode == 0) ? "true" : "false");
}
var advancedMenuItem = document.getElementById("advancedSearch");
if (advancedMenuItem)
{
advancedMenuItem.setAttribute("checked", (searchMode == 1) ? "true" : "false");
}
}
function RevealSearchPanel()
{
// rjc Note: the following is all a hack until the sidebar has appropriate APIs
@ -1004,7 +1039,7 @@ function RevealSearchPanel()
if (splitter_state && splitter_state == "collapsed") {
sidebar_splitter.removeAttribute("state");
}
// SidebarSelectPanel() lives in sidebarOverlay.js
// SidebarSelectPanel() lives in sidebarOverlay.js
SidebarSelectPanel(searchPanel);
}
}

View File

@ -331,12 +331,19 @@ END of Deprecated -->
<menupopup id="searchMenu">
<menuitem accesskey="&findOnCmd.accesskey;" key="key_find" observes="Browser:Find"/>
<menuitem accesskey="&findAgainCmd.accesskey;" key="key_findAgain" observes="Browser:FindAgain"/>
<menuseparator />
<menuseparator />
<menuitem value="&searchInternetCmd.label;" accesskey="&searchInternetCmd.accesskey;" oncommand="openTopWin('http://search.netscape.com/')"/>
<menuitem value="&searchAllMailCmd.label;" accesskey="&searchAllMailCmd.accesskey;" disabled="true" oncommand=""/>
<menu value="&searchOptions.label;">
<menupopup>
<menuitem id="simpleSearch" value="&simpleMode.label;" oncommand="setBrowserSearchMode(0);" />
<menuitem id="advancedSearch" value="&advancedMode.label;" oncommand="setBrowserSearchMode(1);" />
</menupopup>
</menu>
<menuseparator />
<menuitem value="&searchBookmarksHistoryCmd.label;" accesskey="&searchBookmarksHistoryCmd.accesskey;" oncommand="window.openDialog('chrome://communicator/content/bookmarks/bm-find.xul', 'FindBookmarksWindow', 'centerscreen,dialog=no,close,chrome,resizable');"/>
<menuitem value="&searchAllMailCmd.label;" accesskey="&searchAllMailCmd.accesskey;" disabled="true" oncommand=""/>
<menuitem value="&searchAddressbookCmd.label;" accesskey="&searchAddressbookCmd.accesskey;" disabled="true" oncommand="OpenSearch('addressbook', true, null);"/>
</menupopup>
</menupopup>
</menu>
<menu accesskey="&goMenu.accesskey;" id="gomenu" value="&goMenu.label;" oncommand="gotoHistoryIndex(event);">

View File

@ -130,11 +130,14 @@
<!ENTITY findAgainCmd.label "Find Again">
<!ENTITY findAgainCmd.accesskey "g">
<!ENTITY findAgainCmd.commandkey "g">
<!ENTITY searchOptions.label "Search options">
<!ENTITY simpleMode.label "Simple">
<!ENTITY advancedMode.label "Advanced">
<!ENTITY searchBookmarksHistoryCmd.label "Search Bookmarks/History">
<!ENTITY searchBookmarksHistoryCmd.accesskey "b">
<!ENTITY searchInternetCmd.label "Search the Web">
<!ENTITY searchInternetCmd.accesskey "w">
<!ENTITY searchAllMailCmd.label "Search all Mail">
<!ENTITY searchAllMailCmd.label "Search Mail">
<!ENTITY searchAllMailCmd.accesskey "m">
<!ENTITY searchAddressbookCmd.label "Search Addressbook">
<!ENTITY searchAddressbookCmd.accesskey "a">