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

This commit is contained in:
Dão Gottwald 2016-01-06 14:29:36 +01:00
parent f687e44fa0
commit 471b6ce73e
2 changed files with 43 additions and 0 deletions

View File

@ -1815,3 +1815,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);
@ -1486,6 +1487,7 @@ var gBrowserInit = {
IndexedDBPromptHelper.uninit();
LightweightThemeListener.uninit();
PanelUI.uninit();
AutoShowBookmarksToolbar.uninit();
}
// Final window teardown, do this last.