зеркало из https://github.com/mozilla/pjs.git
Fix PDT bug # 40369 & 39029: search UI changes to enable mode switching, and proper alias resolution. r=pavlov, a=dveditz,don
This commit is contained in:
Родитель
3f2b5ac00f
Коммит
b4d53e437a
|
@ -142,6 +142,6 @@
|
|||
</tree>
|
||||
|
||||
<splitter id="gray_horizontal_splitter" persist="state" collapse="after" />
|
||||
<iframe id="content" type="content-primary" style="height: 100; width: 100%;" flex="100%" src="chrome://communicator/content/search/default.htm"/>
|
||||
<iframe id="content" style="height: 100; width: 100%;" flex="100%" src="chrome://communicator/content/search/default.htm"/>
|
||||
|
||||
</window>
|
||||
|
|
|
@ -32,6 +32,7 @@ var RDF = null;
|
|||
var RDFC = null;
|
||||
var RDFCUtils = null;
|
||||
var catDS = null;
|
||||
var internetSearchDS = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -74,6 +75,8 @@ function doLoad()
|
|||
if (internetSearch) internetSearch = internetSearch.QueryInterface(Components.interfaces.nsIInternetSearchService);
|
||||
if (internetSearch)
|
||||
{
|
||||
internetSearchDS = internetSearch.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
|
||||
catDS = internetSearch.GetCategoryDataSource();
|
||||
if (catDS) catDS = catDS.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
if (catDS)
|
||||
|
@ -279,6 +282,13 @@ function AddEngine()
|
|||
|
||||
RDFC.Init(catDS, categoryRes);
|
||||
|
||||
var urlRes = RDF.GetResource("http://home.netscape.com/NC-rdf#URL");
|
||||
if (!urlRes) return(false);
|
||||
var typeRes = RDF.GetResource("http://home.netscape.com/NC-rdf#searchtype");
|
||||
if (!typeRes) return(false);
|
||||
var engineRes = RDF.GetResource("http://home.netscape.com/NC-rdf#Engine");
|
||||
if (!engineRes) return(false);
|
||||
|
||||
for (var x = 0; x < select_list.length; x++)
|
||||
{
|
||||
var id = select_list[x].getAttribute("id");
|
||||
|
@ -286,6 +296,23 @@ function AddEngine()
|
|||
var idRes = RDF.GetResource(id);
|
||||
if (!idRes) return(false);
|
||||
|
||||
// try and find/use alias to search engine
|
||||
var privateEngineFlag = internetSearchDS.HasAssertion(idRes, typeRes, engineRes, true);
|
||||
if (privateEngineFlag == true)
|
||||
{
|
||||
var node = internetSearchDS.GetTarget(idRes, urlRes, true);
|
||||
if (node) node = node.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
if (node)
|
||||
{
|
||||
if (node.Value)
|
||||
{
|
||||
id = node.Value;
|
||||
idRes = RDF.GetResource(id);
|
||||
if (!idRes) return(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var nodeIndex = RDFC.IndexOf(idRes);
|
||||
if (nodeIndex < 1)
|
||||
{
|
||||
|
|
|
@ -164,11 +164,46 @@ function fillContextMenu(name, treeName)
|
|||
popupNode.removeChild(popupNode.childNodes[popupNode.childNodes.length - 1]);
|
||||
}
|
||||
|
||||
var searchMode = 0;
|
||||
if (pref) searchMode = pref.GetIntPref("browser.search.mode");
|
||||
if (pref && bundle)
|
||||
{
|
||||
// then add a menu separator (if necessary)
|
||||
if (popupNode.childNodes.length > 0)
|
||||
{
|
||||
if (popupNode.childNodes[popupNode.childNodes.length - 1].tagName != "menuseparator")
|
||||
{
|
||||
var menuSep = document.createElement("menuseparator");
|
||||
popupNode.appendChild(menuSep);
|
||||
}
|
||||
}
|
||||
// And then add a "Search Mode" menu item
|
||||
var propMenuName = (searchMode == 0) ? bundle.GetStringFromName("enableAdvanced") : bundle.GetStringFromName("disableAdvanced");
|
||||
var menuItem = document.createElement("menuitem");
|
||||
menuItem.setAttribute("value", propMenuName);
|
||||
popupNode.appendChild(menuItem);
|
||||
// Work around bug # 26402 by setting "oncommand" attribute
|
||||
// AFTER appending menuitem
|
||||
menuItem.setAttribute("oncommand", "return setSearchMode();");
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function setSearchMode()
|
||||
{
|
||||
var searchMode = 0;
|
||||
if (pref) searchMode = pref.GetIntPref("browser.search.mode");
|
||||
if (searchMode == 0) searchMode = 1;
|
||||
else searchMode = 0;
|
||||
if (pref) pref.SetIntPref("browser.search.mode", searchMode);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function doContextCmd(cmdName, treeName)
|
||||
{
|
||||
var treeNode = document.getElementById(treeName);
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
enterstringandlocation=Enter some text to search for and select at least one location to search.
|
||||
enterstringandlocation=Enter some text to search for and select at least one location to search.
|
||||
enableAdvanced=Enable advanced search options
|
||||
disableAdvanced=Disabled advanced search options
|
||||
|
|
Загрузка…
Ссылка в новой задаче