1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 const Services = require("Services");
10 } = require("devtools/client/shared/widgets/tooltip/HTMLTooltip");
12 const { getStr } = require("./utils/l10n");
14 const SHOW_SETTING_TOOLTIP_PREF = "devtools.responsive.show-setting-tooltip";
16 const CONTAINER_WIDTH = 270;
19 * Setting onboarding tooltip that is shown on the setting menu button in the RDM toolbar
20 * when the pref is on.
22 class SettingOnboardingTooltip {
25 this.tooltip = new HTMLTooltip(this.doc, {
26 consumeOutsideClicks: false,
30 this.onCloseButtonClick = this.onCloseButtonClick.bind(this);
32 const container = doc.createElement("div");
33 container.className = "onboarding-container";
35 const icon = doc.createElement("span");
36 icon.className = "onboarding-icon";
37 container.appendChild(icon);
39 const content = doc.createElement("div");
40 content.className = "onboarding-content";
41 content.textContent = getStr("responsive.settingOnboarding.content");
42 container.appendChild(content);
44 this.closeButton = doc.createElement("button");
45 this.closeButton.className = "onboarding-close-button devtools-button";
46 container.appendChild(this.closeButton);
48 this.closeButton.addEventListener("click", this.onCloseButtonClick);
50 this.tooltip.panel.appendChild(container);
51 this.tooltip.setContentSize({ width: CONTAINER_WIDTH });
52 this.tooltip.show(this.doc.getElementById("settings-button"), {
58 this.closeButton.removeEventListener("click", this.onCloseButtonClick);
60 this.tooltip.destroy();
62 this.closeButton = null;
68 * Handler for the "click" event on the close button. Hides the onboarding tooltip
69 * and sets the show three pane onboarding tooltip pref to false.
71 onCloseButtonClick() {
72 Services.prefs.setBoolPref(SHOW_SETTING_TOOLTIP_PREF, false);
77 module.exports = SettingOnboardingTooltip;