/* 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/. */
// This file is loaded into the browser window scope. /* eslint-env mozilla/browser-window */
// If the feature is preffed on, but we haven't created profiles yet, the // service will not be initialized.
let profiles = SelectableProfileService.initialized
? await SelectableProfileService.getAllProfiles()
: []; if (profiles.length < 2) {
profilesButton.hidden = true;
emptyProfilesButton.hidden = false;
emptyProfilesButton.addEventListener("command", this.handleCommand); return;
}
emptyProfilesButton.hidden = true;
profilesButton.hidden = false;
profilesButton.addEventListener("command", this.handleCommand);
let { themeBg, themeFg } = SelectableProfileService.currentProfile.theme;
profilesButton.style.setProperty("--appmenu-profiles-theme-bg", themeBg);
profilesButton.style.setProperty("--appmenu-profiles-theme-fg", themeFg);
profilesButton.setAttribute( "label",
SelectableProfileService.currentProfile.name
);
let avatar = SelectableProfileService.currentProfile.avatar;
profilesButton.setAttribute( "image",
`chrome://browser/content/profiles/assets/16_${avatar}.svg`
);
},
// If the user closes the app menu by opening the FxA menu, the FxA showing // handler will run before this code runs. To avoid disconnecting the // subview handlers in the FxA panel, bail out if the FxA panel is visible. if (document.getElementById("PanelUI-fxa")?.getAttribute("visible")) { return;
} this.subview.removeEventListener("command", this.handleCommand);
},
// If the app menu is already open, don't disconnect the subview listeners. // (See related comment inside `onAppMenuViewHiding`.) if (PanelUI.mainView.getAttribute("visible")) { return;
} this.subview.removeEventListener("command", this.handleCommand);
},
/** * Draws the menubar panel contents.
*/
async onPopupShowing() {
let menuPopup = document.getElementById("menu_ProfilesPopup"); while (menuPopup.hasChildNodes()) {
menuPopup.firstChild.remove();
}
let profiles = await SelectableProfileService.getAllProfiles();
let currentProfile = SelectableProfileService.currentProfile;
for (let profile of profiles) {
let menuitem = document.createXULElement("menuitem");
let { themeBg, themeFg } = profile.theme;
menuitem.setAttribute("profileid", profile.id);
menuitem.setAttribute("command", "Profiles:LaunchProfile");
menuitem.setAttribute("label", profile.name);
menuitem.style.setProperty("--menu-profiles-theme-bg", themeBg);
menuitem.style.setProperty("--menu-profiles-theme-fg", themeFg);
menuitem.style.listStyleImage = `url(chrome://browser/content/profiles/assets/48_${profile.avatar}.svg)`;
menuitem.classList.add("menuitem-iconic", "menuitem-iconic-profile");
async handleCommand(aEvent) { switch (aEvent.target.id) { /* App menu button events */ case"appMenu-profiles-button": // deliberate fallthrough case"appMenu-empty-profiles-button": { this.updateView(aEvent.target); break;
} /* FxA menu button events */ case"PanelUI-fxa-menu-empty-profiles-button": // deliberate fallthrough case"PanelUI-fxa-menu-profiles-button": {
aEvent.stopPropagation(); this.updateFxAView(); break;
} /* Subpanel events that may be triggered in FxA menu or app menu */ case"profiles-appmenu-back-button": {
aEvent.target.closest("panelview").panelMultiView.goBack();
aEvent.target.blur(); break;
} case"profiles-edit-this-profile-button": {
openTrustedLinkIn("about:editprofile", "tab"); break;
} case"profiles-manage-profiles-button": { this.manageProfiles(); break;
} case"profiles-create-profile-button": { this.createNewProfile(); break;
}
/* Menubar events */ case"Profiles:CreateProfile": { this.createNewProfile(); break;
} case"Profiles:ManageProfiles": { this.manageProfiles(); break;
} case"Profiles:LaunchProfile": { this.launchProfile(aEvent.sourceEvent); break;
}
} /* Subpanel profile events that may be triggered in FxA menu or app menu */ if (aEvent.target.classList.contains("profile-item")) { this.launchProfile(aEvent);
}
},
/** * Inserts the subpanel contents for the PanelUI subpanel, which may be shown * either in the app menu or the FxA toolbar button menu.
*/
async populateSubView() {
let profiles = [];
let currentProfile = null;
let avatar = currentProfile.avatar;
profileIconEl.style.listStyleImage = `url("chrome://browser/content/profiles/assets/80_${avatar}.svg")`;
}
let subtitle = PanelMultiView.getViewNode(document, "profiles-subtitle");
subtitle.hidden = profiles.length < 2;
let profilesList = PanelMultiView.getViewNode(document, "profiles-list"); while (profilesList.lastElementChild) {
profilesList.lastElementChild.remove();
} for (let profile of profiles) { if (profile.id === SelectableProfileService.currentProfile.id) { continue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.