Bug 366174 - Open in Tabs context menu item is enabled for empty folders. r=sspitzer.

This commit is contained in:
mozilla.mano%sent.com 2007-01-08 23:03:20 +00:00
Родитель 1a44a5969f
Коммит 13315bf780
1 изменённых файлов: 28 добавлений и 13 удалений

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

@ -212,19 +212,34 @@ PlacesController.prototype = {
return this._view.selectedURINode && return this._view.selectedURINode &&
!this._selectionOverlapsSystemArea(); !this._selectionOverlapsSystemArea();
case "placesCmd_open:tabs": case "placesCmd_open:tabs":
// We can open multiple links in tabs if there is either: // We can open multiple links if the current selection is either:
// a) a single folder selected // a) a single folder which contains at least one link
// b) many links or folders selected // b) multiple links
// XXXben - inSysArea should be removed, and generally be replaced by var node = this._view.selectedNode;
// something that counts the number of selected links or the if (!node)
// number of links in the folder and enables the command only if return false;
// the number is less than some 'safe' amount.
var selectedNode = this._view.selectedNode; if (this._view.hasSingleSelection && PlacesUtils.nodeIsFolder(node)) {
var hasSingleSelection = this._view.hasSingleSelection; var contents = PlacesUtils.getFolderContents(asFolder(node).folderId,
var singleFolderSelected = hasSingleSelection && false, false);
PlacesUtils.nodeIsFolder(selectedNode); for (var i = 0; i < contents.childCount; ++i) {
return !this._selectionOverlapsSystemArea() && var child = contents.getChild(i);
(singleFolderSelected || !hasSingleSelection); if (PlacesUtils.nodeIsURI(child))
return true;
}
}
else {
var oneLinkIsSelected = false;
var nodes = this._view.getSelectionNodes();
for (var i = 0; i < nodes.length; ++i) {
if (PlacesUtils.nodeIsURI(nodes[i])) {
if (oneLinkIsSelected)
return true;
oneLinkIsSelected = true;
}
}
}
return false;
#ifdef MOZ_PLACES_BOOKMARKS #ifdef MOZ_PLACES_BOOKMARKS
case "placesCmd_new:folder": case "placesCmd_new:folder":
// New Folder - don't check selectionOverlapsSystemArea since we should // New Folder - don't check selectionOverlapsSystemArea since we should