Bug 1219788 - Show bookmarks toolbar when adding a bookmark to the bookmarks toolbar folder. r=mak

This commit is contained in:
Dão Gottwald 2015-12-31 11:01:09 +01:00
parent 62ead7eab4
commit 3ca1388e6a
2 changed files with 44 additions and 2 deletions

View File

@ -1817,3 +1817,44 @@ var BookmarkingUI = {
Ci.nsINavBookmarkObserver
])
};
var AutoShowBookmarksToolbar = {
init() {
PlacesUtils.addLazyBookmarkObserver(this, false);
},
uninit() {
PlacesUtils.removeLazyBookmarkObserver(this);
},
onItemAdded(aItemId, aParentId, aIndex, aItemType, aURI, aTitle, aDateAdded,
aGuid, aParentGuid) {
this._autoshow(aParentGuid);
},
onBeginUpdateBatch() {},
onEndUpdateBatch() {},
onItemRemoved() {},
onItemChanged() {},
onItemVisited() {},
onItemMoved(aItemId, aOldParent, aOldIndex, aNewParent, aNewIndex, aItemType,
aGuid, aOldParentGuid, aNewParentGuid) {
this._autoshow(aNewParentGuid);
},
_autoshow(aParentGuid) {
if (aParentGuid != PlacesUtils.bookmarks.toolbarGuid)
return;
let toolbar = document.getElementById("PersonalToolbar");
if (!toolbar.collapsed)
return;
let placement = CustomizableUI.getPlacementOfWidget("personal-bookmarks");
let area = placement && placement.area;
if (area != CustomizableUI.AREA_BOOKMARKS)
return;
setToolbarVisibility(toolbar, true);
}
};

View File

@ -1188,6 +1188,7 @@ var gBrowserInit = {
gBrowser.tabContainer.updateVisibility();
BookmarkingUI.init();
AutoShowBookmarksToolbar.init();
gPrefService.addObserver(gHomeButton.prefDomain, gHomeButton, false);
@ -1422,8 +1423,6 @@ var gBrowserInit = {
PlacesToolbarHelper.uninit();
BookmarkingUI.uninit();
TabsInTitlebar.uninit();
ToolbarIconColor.uninit();
@ -1484,6 +1483,8 @@ var gBrowserInit = {
IndexedDBPromptHelper.uninit();
LightweightThemeListener.uninit();
PanelUI.uninit();
BookmarkingUI.uninit();
AutoShowBookmarksToolbar.uninit();
}
// Final window teardown, do this last.