Skip to content

Commit

Permalink
update Extension Options Panel.
Browse files Browse the repository at this point in the history
implement the theme preview tooltips setting.
I previously forgot to implement it so it couldn't be disabled.
also anchor the tooltip to the addon button, not the mouse.
  • Loading branch information
aminomancer committed Jul 13, 2022
1 parent 43f872a commit aab5554
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions JS/extensionOptionsPanel.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Extension Options Panel
// @version 1.8.3
// @version 1.8.4
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description This script creates a toolbar button that opens a popup panel
Expand Down Expand Up @@ -280,13 +280,15 @@ class ExtensionOptionsWidget {
);

// create the theme preview tooltip
aDoc
.getElementById("mainPopupSet")
.appendChild(
aDoc.defaultView.MozXULElement.parseXULToFragment(
`<tooltip id="eom-theme-preview-tooltip" noautohide="true" orient="vertical" onpopupshowing="extensionOptionsPanel.onTooltipShowing(event);"><vbox id="eom-theme-preview-box"><html:img id="eom-theme-preview-canvas"></html:img></vbox></tooltip>`
)
);
if (eop.config["Show theme preview tooltips"]) {
aDoc
.getElementById("mainPopupSet")
.appendChild(
aDoc.defaultView.MozXULElement.parseXULToFragment(
`<tooltip id="eom-theme-preview-tooltip" noautohide="true" orient="vertical" onpopupshowing="extensionOptionsPanel.onTooltipShowing(event);"><vbox id="eom-theme-preview-box"><html:img id="eom-theme-preview-canvas"></html:img></vbox></tooltip>`
)
);
}

eop.fluentSetup(aDoc).then(() => eop.swapAddonsButton(aDoc));
},
Expand Down Expand Up @@ -574,7 +576,11 @@ class ExtensionOptionsWidget {
detail: await formatString("softblocked", { name }),
type: "warning",
};
if (addon.type === "theme" && (!message || message.type !== "error")) {
if (
this.config["Show theme preview tooltips"] &&
addon.type === "theme" &&
(!message || message.type !== "error")
) {
message = message ?? {};
message.detail = "";
message.tooltip = "eom-theme-preview-tooltip";
Expand Down Expand Up @@ -932,6 +938,8 @@ class ExtensionOptionsWidget {
e.preventDefault();
return;
}
e.target.setAttribute("position", "after_start");
e.target.moveToAnchor(anchor, "after_start");
}

// generate and load a stylesheet
Expand Down

0 comments on commit aab5554

Please sign in to comment.