Add support for "Search Editor".

This commit is contained in:
rjc%netscape.com 2000-04-14 08:00:49 +00:00
Родитель 83d56c7a83
Коммит e06277db7b
13 изменённых файлов: 534 добавлений и 0 удалений

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

@ -2,6 +2,9 @@ default.htm
search.css
search.js
search.xul
search-editor.css
search-editor.js
search-editor.xul
search-panel.js
search-panel.xul
shared.js
@ -18,3 +21,4 @@ internetresults.js
internetresults.xul
category.gif
result.gif
search-editor.css

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

@ -8,6 +8,8 @@ internetresults.js
internetresults.xul
search.js
search.xul
search-editor.js
search-editor.xul
search-panel.js
search-panel.xul
shared.js

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

@ -3,5 +3,6 @@ icons.css
internet.css
internetresults.css
search.css
search-editor.css
category.gif
result.gif

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

@ -32,6 +32,8 @@ CHROME_CONTENT = \
default.htm \
search.js \
search.xul \
search-editor.js \
search-editor.xul \
search-panel.js \
search-panel.xul \
shared.js \
@ -46,6 +48,7 @@ CHROME_CONTENT = \
CHROME_SKIN = \
search.css \
search-editor.css \
findresults.css \
icons.css \
internet.css \
@ -60,6 +63,7 @@ CHROME_L10N = \
locale/en-US/internet.dtd \
locale/en-US/internetresults.dtd \
locale/en-US/search.dtd \
locale/en-US/search-editor.dtd \
locale/en-US/search-panel.dtd \
locale/en-US/search-panel.properties \
$(NULL)

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

@ -1,4 +1,5 @@
en-US:search.dtd
en-US:search-editor.dtd
en-US:search-panel.dtd
en-US:find.dtd
en-US:findresults.dtd

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

@ -0,0 +1,35 @@
<!--
- 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 Communicator.
-
- The Initial Developer of the Original Code is Netscape
- Communications Corp. Portions created by Netscape Communications
- Corp. are Copyright (C) 1999 Netscape Communications Corp. All
- Rights Reserved.
-
- Original Author(s):
- Robert John Churchill <rjc@netscape.com>
-
- Contributor(s):
-->
<!ENTITY window.title.label "Customize Search">
<!ENTITY allengines.label "All Engines">
<!ENTITY engine.column.label "Search Engines">
<!ENTITY category.label "Category:">
<!ENTITY add.label "&lt;-- Add --">
<!ENTITY remove.label "Remove">
<!ENTITY new.category.label "New...">
<!ENTITY rename.category.label "Rename...">
<!ENTITY remove.category.label "Delete">

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

@ -29,3 +29,4 @@
<!ENTITY checkbox.column.label "Use">
<!ENTITY stop.button.label "Stop">
<!ENTITY savesearch.button.label "Bookmark Search Query">
<!ENTITY customize.button.label "Customize...">

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

@ -32,6 +32,8 @@ CHROME_CONTENT = \
.\default.htm \
.\search.js \
.\search.xul \
.\search-editor.js \
.\search-editor.xul \
.\search-panel.js \
.\search-panel.xul \
.\shared.js \
@ -46,6 +48,7 @@ CHROME_CONTENT = \
CHROME_SKIN = \
.\search.css \
.\search-editor.css \
.\findresults.css \
.\icons.css \
.\internet.css \
@ -60,6 +63,7 @@ CHROME_L10N = \
.\locale\en-US\internet.dtd \
.\locale\en-US\internetresults.dtd \
.\locale\en-US\search.dtd \
.\locale\en-US\search-editor.dtd \
.\locale\en-US\search-panel.dtd \
.\locale\en-US\search-panel.properties \
$(NULL)

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

@ -0,0 +1,50 @@
/* -*- Mode: C; c-basic-offset: 2 -*-
*
* 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):
*/
@import url(chrome://global/skin/);
box#reorder
{
text-align: center;
}
.up
{
list-style-image:url("chrome://global/skin/scroll-up.gif");
min-width: 0px;
}
.up[disabled="true"]
{
list-style-image:url("chrome://global/skin/scroll-up-disabled.gif");
}
.down
{
min-width: 0px;
list-style-image:url("chrome://global/skin/scroll-down.gif");
}
.down[disabled="true"]
{
list-style-image:url("chrome://global/skin/scroll-down-disabled.gif");
}

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

@ -0,0 +1,275 @@
/* -*- Mode: Java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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.
*
* Original Author(s):
* Robert John Churchill <rjc@netscape.com>
*
* Contributor(s):
*/
// global(s)
var pref = null;
try
{
pref = Components.classes["component://netscape/preferences"].getService();
if (pref) pref = pref.QueryInterface( Components.interfaces.nsIPref );
}
catch(e)
{
pref = null;
}
function debug(msg)
{
// uncomment for noise
// dump(msg+"\n");
}
function doLoad()
{
// set up action buttons
doSetOKCancel(Commit, Cancel);
// adjust category popup
var internetSearch = Components.classes["component://netscape/rdf/datasource?name=internetsearch"].getService();
if (internetSearch) internetSearch = internetSearch.QueryInterface(Components.interfaces.nsIInternetSearchService);
if (internetSearch)
{
var catDS = internetSearch.GetCategoryDataSource();
if (catDS) catDS = catDS.QueryInterface(Components.interfaces.nsIRDFDataSource);
if (catDS)
{
var categoryList = document.getElementById("categoryList");
if (categoryList)
{
categoryList.database.AddDataSource(catDS);
var ref = categoryList.getAttribute("ref");
if (ref) categoryList.setAttribute("ref", ref);
}
var engineList = document.getElementById("engineList");
if (engineList)
{
engineList.database.AddDataSource(catDS);
}
}
}
// try and determine last category name used
var lastCategoryName = "";
try
{
var pref = Components.classes["component://netscape/preferences"].getService();
if (pref) pref = pref.QueryInterface( Components.interfaces.nsIPref );
if (pref) lastCategoryName = pref.CopyCharPref( "browser.search.last_search_category" );
if (lastCategoryName != "")
{
// strip off the prefix if necessary
var prefix="NC:SearchCategory?category=";
if (lastCategoryName.indexOf(prefix) == 0)
{
lastCategoryName = lastCategoryName.substr(prefix.length);
}
}
}
catch( e )
{
debug("Exception in SearchPanelStartup\n");
lastCategoryName = "";
}
debug("\nSearchPanelStartup: lastCategoryName = '" + lastCategoryName + "'\n");
// select the appropriate category
var categoryList = document.getElementById( "categoryList" );
var categoryPopup = document.getElementById( "categoryPopup" );
if( categoryList && categoryPopup )
{
var found = false;
for( var i = 0; i < categoryPopup.childNodes.length; i++ )
{
if( ( lastCategoryName == "" && categoryPopup.childNodes[i].getAttribute("data") == "NC:SearchEngineRoot" ) ||
( categoryPopup.childNodes[i].getAttribute("id") == lastCategoryName ) )
{
categoryList.selectedItem = categoryPopup.childNodes[i];
found = true;
break;
}
}
if (found == false)
{
categoryList.selectedItem = categoryPopup.childNodes[0];
}
chooseCategory(categoryList.selectedItem);
}
}
function Cancel()
{
// Ignore any changes.
window.close();
}
function Commit()
{
}
function doUnload()
{
// Get the current window position/size.
var x = window.screenX;
var y = window.screenY;
var h = window.outerHeight;
var w = window.outerWidth;
// Store these into the window attributes (for persistence).
var win = document.getElementById( "search-editor-window" );
win.setAttribute( "x", x );
win.setAttribute( "y", y );
win.setAttribute( "height", h );
win.setAttribute( "width", w );
}
/* Note: doSort() does NOT support natural order sorting, unless naturalOrderResource is valid,
in which case we sort ascending on naturalOrderResource
*/
function doSort(sortColName, naturalOrderResource)
{
var node = document.getElementById(sortColName);
// determine column resource to sort on
var sortResource = node.getAttribute('resource');
if (!sortResource) return(false);
var sortDirection="ascending";
var isSortActive = node.getAttribute('sortActive');
if (isSortActive == "true")
{
sortDirection = "ascending";
var currentDirection = node.getAttribute('sortDirection');
if (currentDirection == "ascending")
{
if (sortResource != naturalOrderResource)
{
sortDirection = "descending";
}
}
else if (currentDirection == "descending")
{
if (naturalOrderResource != null && naturalOrderResource != "")
{
sortResource = naturalOrderResource;
}
}
}
var isupports = Components.classes["component://netscape/rdf/xul-sort-service"].getService();
if (!isupports) return(false);
var xulSortService = isupports.QueryInterface(Components.interfaces.nsIXULSortService);
if (!xulSortService) return(false);
try
{
xulSortService.Sort(node, sortResource, sortDirection);
}
catch(ex)
{
debug("Exception calling xulSortService.Sort()");
}
return(true);
}
function chooseCategory( aNode )
{
var category = "NC:SearchCategory?category=" + aNode.getAttribute("id");
debug("chooseCategory: '" + category + "'\n");
var treeNode = document.getElementById("engineList");
if (treeNode)
{
dump("\nSet search engine list to category='" + category + "'\n\n");
treeNode.setAttribute( "ref", category );
}
return(true);
}
function AddEngine()
{
return(true);
}
function RemoveEngine()
{
return(true);
}
function MoveUp()
{
return(true);
}
function MoveDown()
{
return(true);
}
function NewCategory()
{
return(true);
}
function RenameCategory()
{
return(true);
}
function RemoveCategory()
{
return(true);
}

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

@ -0,0 +1,143 @@
<?xml version="1.0"?> <!-- -*- Mode: SGML; 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.
Original Author(s):
Robert John Churchill <rjc@netscape.com>
Contributor(s):
-->
<?xml-stylesheet href="chrome://search/skin/search-editor.css" type="text/css"?>
<?xml-stylesheet href="chrome://search/skin/" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://search/locale/search-editor.dtd">
<window title="&window.title.label;" id="search-editor-window"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:web="http://home.netscape.com/WEB-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
width="500" height="300" x="20" y="20" persist="width height x y" align="vertical"
windowtype="internetsearch:editor" class="dialog"
onload="doLoad()" onunload="doUnload()"
>
<html:script src="chrome://search/content/search-editor.js" />
<titledbox orient="vertical" flex="1" >
<box align="horizontal" flex="100%" autostretch="never">
<text value="&category.label;" />
<menulist id="categoryList" ref="NC:SearchCategoryRoot" datasources="rdf:null" >
<template>
<menupopup>
<menuitem uri="rdf:*" oncommand="return chooseCategory(this);"
data="rdf:http://home.netscape.com/NC-rdf#category"
value="rdf:http://home.netscape.com/NC-rdf#title" />
</menupopup>
</template>
<menupopup id="categoryPopup" />
</menulist>
<spring align="horizontal" flex="100%" />
</box>
<box align="horizontal" flex="100%">
<tree id="engineList" flex="1" datasources="rdf:internetsearch" class="inset">
<template>
<treechildren>
<treeitem uri="...">
<treerow>
<treecell class="iconic" flex="1" crop="right" align="left"
src="rdf:http://home.netscape.com/NC-rdf#Icon" value="rdf:http://home.netscape.com/NC-rdf#Name" />
</treerow>
</treeitem>
</treechildren>
</template>
<treecol id="EngineColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name" sortActive="true" sortDirection="ascending" />
<treehead>
<treerow>
<treecell observes="EngineColumn" align="center" value="&engine.column.label;" resource="http://home.netscape.com/NC-rdf#Name" onclick="return doSort('EngineColumn', null);" sortActive="true" sortDirection="ascending" flex="1"/>
</treerow>
</treehead>
</tree>
<box align="vertical" flex="100%" class="button-group">
<spring align="vertical" flex="100%" />
<button id="add-button" onclick="return AddEngine()" value="&add.label;" />
<button id="remove-button" onclick="return RemoveEngine()" value="&remove.label;" />
<spring align="vertical" flex="100%" />
<!-- The 'reorder' buttons -->
<box id="reorder" align="vertical" autostretch="never">
<spring flex="1"/>
<button oncommand="MoveUp();" id="up" class="up small" />
<button oncommand="MoveDown();" id="down" class="down small" />
<spring flex="1"/>
</box>
<spring align="vertical" flex="100%" />
</box>
<tree class="inset" id="allengines" ref="NC:SearchEngineRoot" datasources="rdf:internetsearch">
<template>
<treechildren>
<treeitem uri="..." loading="rdf:http://home.netscape.com/NC-rdf#loading">
<treerow>
<treecell class="iconic" flex="1" crop="right" align="left"
src="rdf:http://home.netscape.com/NC-rdf#Icon" value="rdf:http://home.netscape.com/NC-rdf#Name" />
</treerow>
</treeitem>
</treechildren>
</template>
<treecol id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name" sortActive="true" sortDirection="ascending" />
<treehead>
<treerow>
<treecell observes="NameColumn" align="center" value="&allengines.label;" resource="http://home.netscape.com/NC-rdf#Name" onclick="return doSort('NameColumn', null);" sortActive="true" sortDirection="ascending" flex="1"/>
</treerow>
</treehead>
</tree>
</box>
<box align="horizontal" class="button-group">
<button id="new-category-button" onclick="NewCategory()" value="&new.category.label;" />
<button id="rename-category-button" onclick="RenameCategory()" value="&rename.category.label;" />
<button id="remove-category.buttom" onclick="RemoveCategory()" value="&remove.category.label;" />
<spring align="horizontal" flex="100%" />
</box>
</titledbox>
<box autostretch="never">
<spring flex="1"/>
<box id="okCancelButtons"/>
</box>
</window>

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

@ -988,3 +988,10 @@ function saveSearch()
return(true);
}
function doCustomize()
{
window.openDialog("chrome://search/content/search-editor.xul", "_blank", "centerscreen,chrome,resizable");
}

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

@ -166,6 +166,13 @@
</treerow>
</treehead>
</tree>
<box align="horizontal">
<spring flex="1" />
<titledbutton id="customizeButton" value="&customize.button.label;" onclick="return doCustomize();" class="dialog toolbar-non-iconic"/>
<spring flex="1" />
</box>
</box>
</deck>
</window>