gecko/browser/base/content/browser-fxaccounts.js

60 lines
1.4 KiB
JavaScript
Raw Normal View History

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function () {
return Cu.import("resource://gre/modules/FxAccountsCommon.js", {});
});
let gFxAccounts = {
_initialized: false,
get topics() {
delete this.topics;
return this.topics = [
FxAccountsCommon.ONVERIFIED_NOTIFICATION
];
},
init: function () {
if (this._initialized) {
return;
}
for (let topic of this.topics) {
Services.obs.addObserver(this, topic, false);
}
this._initialized = true;
},
uninit: function () {
if (!this._initialized) {
return;
}
for (let topic of this.topics) {
Services.obs.removeObserver(this, topic);
}
this._initialized = false;
},
observe: function (subject, topic) {
this.showDoorhanger();
},
showDoorhanger: function () {
let panel = document.getElementById("sync-popup");
let anchor = document.getElementById("PanelUI-menu-button");
let iconAnchor =
document.getAnonymousElementByAttribute(anchor, "class",
"toolbarbutton-icon");
panel.hidden = false;
panel.openPopup(iconAnchor || anchor, "bottomcenter topright");
}
};