Bug 1543121 - Add buttons for toggling FxA message (in bookmark panel) r=k88hudson

Differential Revision: https://phabricator.services.mozilla.com/D28165
This commit is contained in:
Danny Coates
2019-04-25 14:47:24 +00:00
parent f747c310f1
commit f086f3cf64
5 changed files with 328 additions and 7 deletions

View File

@@ -8,6 +8,9 @@
XPCOMUtils.defineLazyScriptGetter(this, ["PlacesToolbar", "PlacesMenu",
"PlacesPanelview", "PlacesPanelMenuView"],
"chrome://browser/content/places/browserPlacesViews.js");
XPCOMUtils.defineLazyModuleGetters(this, {
BookmarkPanelHub: "resource://activity-stream/lib/BookmarkPanelHub.jsm",
});
var StarUI = {
_itemGuids: null,
@@ -182,6 +185,21 @@ var StarUI = {
}
},
getRecommendation(data) {
return BookmarkPanelHub.messageRequest(data, window);
},
toggleRecommendation(visible) {
const info = this._element("editBookmarkPanelInfoButton");
info.checked = visible !== undefined ? !!visible : !info.checked;
const recommendation = this._element("editBookmarkPanelRecommendation");
if (info.checked) {
recommendation.removeAttribute("disabled");
} else {
recommendation.setAttribute("disabled", "disabled");
}
},
async showEditBookmarkPopup(aNode, aIsNewBookmark, aUrl) {
// Slow double-clicks (not true double-clicks) shouldn't
// cause the panel to flicker.
@@ -223,6 +241,21 @@ var StarUI = {
this._setIconAndPreviewImage();
const showRecommendation = await this.getRecommendation({
container: this._element("editBookmarkPanelRecommendation"),
createElement: elem => document.createElementNS("http://www.w3.org/1999/xhtml", elem),
url: aUrl.href,
close: e => {
e.stopPropagation();
this.toggleRecommendation(false);
},
hidePopup: () => {
this.panel.hidePopup();
},
});
this._element("editBookmarkPanelInfoButton").disabled = !showRecommendation;
this.toggleRecommendation(showRecommendation);
this.beginBatch();
this._anchorElement = BookmarkingUI.anchor;