From 392ff0e08b7447ee0e1827783b70ba20552d5f14 Mon Sep 17 00:00:00 2001 From: "mozilla.mano@sent.com" Date: Thu, 13 Mar 2008 11:20:49 -0700 Subject: [PATCH] Bug 411549 - place:folder=x shows next to Location line in Library. r=dietrich. --- .../places/content/editBookmarkOverlay.js | 22 ++++++++++++++----- browser/components/places/content/places.js | 16 ++++++++++++-- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/browser/components/places/content/editBookmarkOverlay.js b/browser/components/places/content/editBookmarkOverlay.js index d957f9f3a521..dac45b99b366 100644 --- a/browser/components/places/content/editBookmarkOverlay.js +++ b/browser/components/places/content/editBookmarkOverlay.js @@ -62,6 +62,8 @@ var gEditItemOverlay = { this._hiddenRows = aInfo.hiddenRows; else this._hiddenRows.splice(0); + // force-read-only + this._readOnly = aInfo && aInfo.forceReadOnly; }, _showHideRows: function EIO__showHideRows() { @@ -89,6 +91,17 @@ var gEditItemOverlay = { /** * Initialize the panel + * @param aItemId + * a places-itemId of a bookmark, folder or a live bookmark. + * @param [optional] aInfo + * JS object which stores additional info for the panel + * initialization. The following properties may bet set: + * * hiddenRows (Strings array): list of rows to be hidden regardless + * of the item edited. Possible values: "title", "location", + * "description", "keyword", "loadInSidebar", "feedLocation", + * "siteLocation", folderPicker" + * * forceReadOnly - set this flag to initialize the panel to its + * read-only (view) mode even if the given item is editable. */ initPanel: function EIO_initPanel(aItemId, aInfo) { const bms = PlacesUtils.bookmarks; @@ -103,10 +116,8 @@ var gEditItemOverlay = { if (this._itemType == Ci.nsINavBookmarksService.TYPE_BOOKMARK) { this._uri = bms.getBookmarkURI(this._itemId); this._isLivemark = false; - if (PlacesUtils.livemarks.isLivemark(container)) - this._readOnly = true; - else - this._readOnly = false; + if (!this._readOnly) // If readOnly wasn't forced through aInfo + this._readOnly = PlacesUtils.livemarks.isLivemark(container); this._initTextField("locationField", this._uri.spec); this._initTextField("tagsField", @@ -126,7 +137,8 @@ var gEditItemOverlay = { LOAD_IN_SIDEBAR_ANNO); } else { - this._readOnly = false; + if (!this._readOnly) // If readOnly wasn't forced through aInfo + this._readOnly = false; this._isLivemark = PlacesUtils.livemarks.isLivemark(this._itemId); if (this._isLivemark) { var feedURI = PlacesUtils.livemarks.getFeedURI(this._itemId); diff --git a/browser/components/places/content/places.js b/browser/components/places/content/places.js index 9bdcad656797..62b16ea73d4b 100755 --- a/browser/components/places/content/places.js +++ b/browser/components/places/content/places.js @@ -541,8 +541,20 @@ var PlacesOrganizer = { this._paneDisabled = false; } - gEditItemOverlay.initPanel(selectedNode.itemId, - { hiddenRows: ["folderPicker"] }); + // Using the concrete itemId is arguably wrong. The bookmarks API + // does allow setting properties for folder shortcuts as well, but since + // the UI does not distinct between the couple, we better just show + // the concrete item properties. + if (selectedNode.type == + Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT) { + gEditItemOverlay.initPanel(asQuery(selectedNode).folderItemId, + { hiddenRows: ["folderPicker"], + forceReadOnly: true }); + } + else { + gEditItemOverlay.initPanel(selectedNode.itemId, + { hiddenRows: ["folderPicker"] }); + } this._detectAndSetDetailsPaneMinimalState(selectedNode); return;