diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index feca1eb349c9..399675fffa3d 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -105,10 +105,13 @@ var PlacesCommandHook = { }, /** - * Adds a bookmark to the page loaded in the given browser + * Adds a bookmark to the page loaded in the given browser. * * @param aBrowser - * a element + * a element. + * @param [optional] aParent + * The folder in which to create a new bookmark if the page loaded in + * aBrowser isn't bookmarked yet, defaults to the places root. * @param [optional] aShowEditUI * whether or not to show the edit-bookmark UI for the bookmark item * @param [optional] aAnchorElement @@ -116,10 +119,9 @@ var PlacesCommandHook = { * @param [optional] aPosition * required if aShowEditUI is set, see popup's openPopup. */ - bookmarkPage: function PCH_bookmarkPage(aBrowser, aShowEditUI, + bookmarkPage: function PCH_bookmarkPage(aBrowser, aParent, aShowEditUI, aAnchorElement, aPosition) { var uri = aBrowser.currentURI; - var itemId = PlacesUtils.getMostRecentBookmarkForURI(uri); if (itemId == -1) { // Copied over from addBookmarkForBrowser: @@ -138,8 +140,9 @@ var PlacesCommandHook = { } catch (e) { } + var parent = aParent != undefined ? aParent : PlacesUtils.placesRootId; var descAnno = { name: DESCRIPTION_ANNO, value: description }; - var txn = PlacesUtils.ptm.createItem(uri, PlacesUtils.placesRootId, -1, + var txn = PlacesUtils.ptm.createItem(uri, parent, -1, title, null, [descAnno]); PlacesUtils.ptm.commitTransaction(txn); if (aShowEditUI) @@ -153,33 +156,36 @@ var PlacesCommandHook = { /** * Adds a bookmark to the page loaded in the current tab. */ - bookmarkCurrentPage: function PCH_bookmarkCurrentPage(aShowEditUI) { + bookmarkCurrentPage: function PCH_bookmarkCurrentPage(aShowEditUI, aParent) { // dock the panel to the star icon if it is visible, otherwise dock // it to the content area - var starIcon = document.getElementById("star-icon"); + var starIcon = document.getElementById("star-button"); if (starIcon && isElementVisible(starIcon)) { - this.bookmarkPage(getBrowser().selectedBrowser, aShowEditUI, starIcon, - "after_end"); + var dockTo = document.getElementById("go-button-bottom"); + this.bookmarkPage(getBrowser().selectedBrowser, aParent, aShowEditUI, + dockTo, "after_start"); } else { - this.bookmarkPage(getBrowser().selectedBrowser, aShowEditUI, getBrowser(), - "overlap"); + this.bookmarkPage(getBrowser().selectedBrowser, aParent, aShowEditUI, + getBrowser(), "overlap"); } }, /** * Adds a bookmark to the page targeted by a link. - * @param url - * The address of the link target - * @param title - * The link text + * @param aParent + * The folder in which to create a new bookmark if aURL isn't + * bookmarked. + * @param aURL (string) + * the address of the link target + * @param aTitle + * The link text */ - bookmarkLink: function PCH_bookmarkLink(url, title) { - var linkURI = IO.newURI(url) + bookmarkLink: function PCH_bookmarkLink(aParent, aURL, aTitle) { + var linkURI = IO.newURI(aURL) var itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI); if (itemId == -1) { - var txn = PlacesUtils.ptm.createItem(linkURI, PlacesUtils.placesRootId, -1, - title); + var txn = PlacesUtils.ptm.createItem(linkURI, aParent, -1, aTitle); PlacesUtils.ptm.commitTransaction(txn); itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI); } @@ -728,12 +734,12 @@ var PlacesStarButton = { _batching: false, updateState: function PSB_updateState() { - var starIcon = document.getElementById("star-icon"); + var starIcon = document.getElementById("star-button"); if (!starIcon) return; var uri = getBrowser().currentURI; - this._starred = uri && PlacesUtils.bookmarks.isBookmarked(uri); + this._starred = uri && (PlacesUtils.getMostRecentBookmarkForURI(uri) != -1); if (this._starred) starIcon.setAttribute("starred", "true"); else diff --git a/browser/base/content/browser-sets.inc b/browser/base/content/browser-sets.inc index 0878e2e142f7..2c4f17c7afd3 100644 --- a/browser/base/content/browser-sets.inc +++ b/browser/base/content/browser-sets.inc @@ -88,7 +88,7 @@ observes="isImage"/> + oncommand="PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksRootId);"/> #endif - @@ -284,15 +283,17 @@ chromedir="&locale.dir;" /> - + + + + diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index 648b7bbe167c..2bcf606a8f17 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -1123,17 +1123,13 @@ nsContextMenu.prototype = { }, bookmarkThisPage: function CM_bookmarkThisPage() { - // workaround bug 392512 - setTimeout(function(aSelf) { - PlacesCommandHook.bookmarkPage(aSelf.browser, true, aSelf.browser, - "overlap"); }, 0, this); + PlacesCommandHook.bookmarkPage(this.browser, PlacesUtils.bookmarksRootId, + true, this.browser, "overlap"); }, bookmarkLink: function CM_bookmarkLink() { - // workaround bug 392512 - setTimeout(function(aSelf) { - PlacesCommandHook.bookmarkLink(aSelf.linkURL, aSelf.linkText()); - }, 0, this); + PlacesCommandHook.bookmarkLink(PlacesUtils.bookmarksRootId, this.linkURL, + this.linkText()); }, addBookmarkForFrame: function CM_addBookmarkForFrame() { @@ -1146,16 +1142,13 @@ nsContextMenu.prototype = { var description = PlacesUtils.getDescriptionFromDocument(doc); var descAnno = { name: DESCRIPTION_ANNO, value: description }; - var txn = PlacesUtils.ptm.createItem(uri, PlacesUtils.placesRootId, -1, + var txn = PlacesUtils.ptm.createItem(uri, PlacesUtils.bookmarksRootId, -1, title, null, [descAnno]); PlacesUtils.ptm.commitTransaction(txn); itemId = PlacesUtils.getMostRecentBookmarkForURI(uri); } - // workaround bug 392512 - setTimeout(function(aSelf) { - PlacesCommandHook.showEditBookmarkPopup(itemId, aSelf.browser, "overlap"); - }, 0, this); + PlacesCommandHook.showEditBookmarkPopup(itemId, this.browser, "overlap"); }, savePageAs: function CM_savePageAs() { diff --git a/browser/components/places/content/editBookmarkOverlay.js b/browser/components/places/content/editBookmarkOverlay.js index 873a240f200d..f640c89f854f 100644 --- a/browser/components/places/content/editBookmarkOverlay.js +++ b/browser/components/places/content/editBookmarkOverlay.js @@ -348,7 +348,7 @@ var gEditItemOverlay = { // hide the tag selector if it was previously visible var tagsSelector = this._element("tagsSelector"); if (!tagsSelector.collapsed) - tagsSelector.collapsed = true; + this._toggleTagsSelector(); } if (this._observersAdded) { @@ -547,7 +547,7 @@ var gEditItemOverlay = { // Update folder-tree selection if (isElementVisible(this._folderTree)) { var selectedNode = this._folderTree.selectedNode; - if (selectedNode.itemId != container) + if (!selectedNode || selectedNode.itemId != container) this._folderTree.selectFolders([container]); } }, @@ -558,13 +558,7 @@ var gEditItemOverlay = { return; var folderId = selectedNode.itemId; - // Don't set the selected item if the static item for the folder is - // already selected - var oldSelectedItem = this._folderMenuList.selectedItem; - if ((oldSelectedItem.id == "editBMPanel_toolbarFolderItem" && - folderId == PlacesUtils.toolbarFolderId) || - (oldSelectedItem.id == "editBMPanel_bmRootItem" && - folderId == PlacesUtils.bookmarksRootId)) + if (this._getFolderIdFromMenuList() == folderId) return; var folderItem = this._getFolderMenuItem(folderId, false); diff --git a/browser/components/places/content/editBookmarkOverlay.xul b/browser/components/places/content/editBookmarkOverlay.xul index 8b4d928af56d..0fe726b5e542 100644 --- a/browser/components/places/content/editBookmarkOverlay.xul +++ b/browser/components/places/content/editBookmarkOverlay.xul @@ -74,12 +74,14 @@ + + + + - - -