Bug 405887 - library search should default to Selected Folder (for mak77@supereva.it, r=mano)

This commit is contained in:
dietrich%mozilla.com 2008-04-07 15:59:30 +00:00
Родитель 8407bc4101
Коммит 87c70dead6
5 изменённых файлов: 109 добавлений и 17 удалений

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

@ -223,14 +223,61 @@ var PlacesOrganizer = {
searchFilter.reset();
}
// Update the "Find in <current collection>" command and the gray text in
// the search box in the toolbar if the active collection is the current
// collection.
this._setSearchScopeForNode(node);
},
/**
* Sets the search scope based on node's properties
* @param aNode
* the node to set up scope from
*/
_setSearchScopeForNode: function PO__setScopeForNode(aNode) {
var scopeBarFolder = document.getElementById("scopeBarFolder");
var itemId = aNode.itemId;
if (PlacesUtils.nodeIsHistoryContainer(aNode) ||
itemId == PlacesUIUtils.leftPaneQueries["History"]) {
scopeBarFolder.disabled = true;
var folders = [];
var filterCollection = "history";
var scopeButton = "scopeBarHistory";
}
else if (PlacesUtils.nodeIsFolder(aNode) &&
itemId != PlacesUIUtils.leftPaneQueries["AllBookmarks"] &&
itemId != PlacesUIUtils.leftPaneQueries["Tags"] &&
aNode.parent.itemId != PlacesUIUtils.leftPaneQueries["Tags"]) {
// enable folder scope
scopeBarFolder.disabled = false;
var folders = [PlacesUtils.getConcreteItemId(aNode)];
var filterCollection = "collection";
var scopeButton = "scopeBarFolder";
}
else {
// default to All Bookmarks
scopeBarFolder.disabled = true;
var folders = [];
var filterCollection = "bookmarks";
var scopeButton = "scopeBarAll";
}
// set search scope
PlacesSearchBox.folders = folders;
PlacesSearchBox.filterCollection = filterCollection;
// update scope bar active child
var scopeBar = document.getElementById("organizerScopeBar");
var child = scopeBar.firstChild;
while (child) {
if (child.getAttribute("id") != scopeButton)
child.removeAttribute("checked");
else
child.setAttribute("checked", "true");
child = child.nextSibling;
}
// Update the "Find in <current collection>" command
var findCommand = document.getElementById("OrganizerCommand_find:current");
var findLabel = PlacesUIUtils.getFormattedString("findInPrefix", [node.title]);
var findLabel = PlacesUIUtils.getFormattedString("findInPrefix", [aNode.title]);
findCommand.setAttribute("label", findLabel);
if (PlacesSearchBox.filterCollection == "collection")
PlacesSearchBox.updateCollectionTitle(node.title);
},
/**
@ -817,10 +864,13 @@ var PlacesSearchBox = {
* The title of the current collection.
*/
updateCollectionTitle: function PSB_updateCollectionTitle(title) {
this.searchFilter.emptyText =
title ?
PlacesUIUtils.getFormattedString("searchCurrentDefault", [title]) :
PlacesUIUtils.getString("searchBookmarks");
if (title)
this.searchFilter.emptyText =
PlacesUIUtils.getFormattedString("searchCurrentDefault", [title]);
else
this.searchFilter.emptyText = this.filterCollection == "history" ?
PlacesUIUtils.getString("searchHistory") :
PlacesUIUtils.getString("searchBookmarks");
},
/**

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

@ -422,12 +422,6 @@
oncommand="PlacesQueryBuilder.onScopeSelected(this);"
label="&search.scopeAll.label;"
checked="true"/>
<toolbarbutton id="scopeBarMenu" type="radio" group="scopeBar"
oncommand="PlacesQueryBuilder.onScopeSelected(this);"
label="&search.scopeMenu.label;"/>
<toolbarbutton id="scopeBarToolbar" type="radio" group="scopeBar"
oncommand="PlacesQueryBuilder.onScopeSelected(this);"
label="&search.scopeToolbar.label;"/>
<!--
<toolbarbutton id="scopeBarDownloads" type="radio" group="scopeBar"
oncommand="PlacesQueryBuilder.onScopeSelected(this);"

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

@ -344,7 +344,7 @@
padding: 0 5px !important;
}
#organizerScopeBar> toolbarbutton:hover {
#organizerScopeBar> toolbarbutton:not([disabled="true"]):hover {
color: #fff;
background: url("chrome://global/skin/20pct_transparent_pixel.png") repeat;
}

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

@ -241,3 +241,34 @@
padding-right: 3px;
}
#organizerScopeBar {
background-color: Window;
padding: 2px 0;
}
#organizerScopeBar > toolbarbutton {
-moz-appearance: none;
border: 1px solid transparent;
-moz-border-radius: 2px;
padding: 0 !important;
margin: 0 1px;
}
#organizerScopeBar > toolbarbutton > label,
#organizerScopeBar > toolbarbutton > image {
padding: 0;
margin: 0;
}
#organizerScopeBar .toolbarbutton-text {
margin: 0;
padding: 2px 5px;
}
#organizerScopeBar> toolbarbutton:not([disabled="true"]):hover {
border-color: ThreeDShadow;
}
#organizerScopeBar > toolbarbutton[checked="true"] {
border-color: ThreeDDarkShadow !important;
}

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

@ -302,6 +302,23 @@ var PlacesUtils = {
return this.containerTypes.indexOf(aNode.type) != -1;
},
/**
* Determines whether or not a ResultNode is an history related container.
* @param node
* A result node
* @returns true if the node is an history related container, false otherwise
*/
nodeIsHistoryContainer: function PU_nodeIsHistoryContainer(aNode) {
var resultType;
return this.nodeIsQuery(aNode) &&
((resultType = asQuery(aNode).queryOptions.resultType) ==
Ci.nsINavHistoryQueryOptions.RESULTS_AS_DATE_SITE_QUERY ||
resultType == Ci.nsINavHistoryQueryOptions.RESULTS_AS_DATE_QUERY ||
resultType == Ci.nsINavHistoryQueryOptions.RESULTS_AS_SITE_QUERY ||
this.nodeIsDay(aNode) ||
this.nodeIsHost(aNode));
},
/**
* Determines whether or not a result-node is a dynamic-container item.
* The dynamic container result node type is for dynamically created