зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551902 - Hide protections panel when focus is lost. r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D32980 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7dd46fed20
Коммит
1ba48c2d75
|
@ -50,6 +50,33 @@ var gProtectionsHandler = {
|
|||
}).catch(Cu.reportError);
|
||||
},
|
||||
|
||||
onPopupShown(event) {
|
||||
if (event.target == this._protectionsPopup) {
|
||||
window.addEventListener("focus", this, true);
|
||||
}
|
||||
},
|
||||
|
||||
onPopupHidden(event) {
|
||||
if (event.target == this._protectionsPopup) {
|
||||
window.removeEventListener("focus", this, true);
|
||||
this._protectionsPopup.removeAttribute("open");
|
||||
}
|
||||
},
|
||||
|
||||
handleEvent(event) {
|
||||
let elem = document.activeElement;
|
||||
let position = elem.compareDocumentPosition(this._protectionsPopup);
|
||||
|
||||
if (!(position & (Node.DOCUMENT_POSITION_CONTAINS |
|
||||
Node.DOCUMENT_POSITION_CONTAINED_BY)) &&
|
||||
!this._protectionsPopup.hasAttribute("noautohide")) {
|
||||
// Hide the panel when focusing an element that is
|
||||
// neither an ancestor nor descendant unless the panel has
|
||||
// @noautohide (e.g. for a tour).
|
||||
PanelMultiView.hidePopup(this._protectionsPopup);
|
||||
}
|
||||
},
|
||||
|
||||
refreshProtectionsPopup() {
|
||||
// Refresh the state of the TP toggle switch.
|
||||
this._protectionsPopupTPSwitch.toggleAttribute("enabled",
|
||||
|
@ -61,6 +88,11 @@ var gProtectionsHandler = {
|
|||
this._protectionsPopupMainViewHeaderLabel.textContent =
|
||||
// gNavigatorBundle.getFormattedString("protections.header", [host]);
|
||||
`Tracking Protections for ${host}`;
|
||||
|
||||
let currentlyEnabled =
|
||||
!this._protectionsPopup.hasAttribute("hasException");
|
||||
|
||||
this._protectionsPopupTPSwitch.toggleAttribute("enabled", currentlyEnabled);
|
||||
},
|
||||
|
||||
async onTPSwitchCommand(event) {
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
hidden="true"
|
||||
photon="true"
|
||||
role="alertdialog"
|
||||
onpopupshown="gProtectionsHandler.onPopupShown(event);"
|
||||
onpopuphidden="gProtectionsHandler.onPopupHidden(event);"
|
||||
orient="vertical">
|
||||
|
||||
<panelmultiview id="protections-popup-multiView"
|
||||
|
|
Загрузка…
Ссылка в новой задаче