change the text and center only when the text was different

This commit is contained in:
ReznoRMichael 2021-07-27 23:27:12 +02:00
parent 0891e7bada
commit 7a57bfcbac
3 changed files with 18 additions and 16 deletions

View file

@ -7054,20 +7054,22 @@ SCROLL_BUTTON.addEventListener("click", function () {
document.getElementById("save-location-input").addEventListener("click", function (e) { document.getElementById("save-location-input").addEventListener("click", function (e) {
var tooltip = document.getElementById("save-location-input-tooltip"); var tooltip = document.getElementById("save-location-input-tooltip");
SelectCopyInputText(e, "save-location-input-tooltip", "Copied save files location to clipboard"); SelectCopyInputText(e, "save-location-input-tooltip", "Copied save files location to clipboard");
var tooltipWidth = tooltip.offsetWidth;
/* make sure that the tooltip is centered */ /* make sure that the tooltip is centered */
tooltip.style.marginLeft = "-".concat(tooltipWidth / 2, "px"); tooltip.style.marginLeft = "-".concat(tooltip.offsetWidth / 2, "px");
}, false); }, false);
/* -------------- Switch text back to the default on mouse out -------------- */ /* -------------- Switch text back to the default on mouse out -------------- */
document.getElementById("save-location-input").addEventListener("mouseout", function () { document.getElementById("save-location-input").addEventListener("mouseout", function () {
var tooltip = document.getElementById("save-location-input-tooltip"); var tooltip = document.getElementById("save-location-input-tooltip");
/* change the text and center only when the text was different */
if (tooltip.innerHTML !== "Click once to copy to clipboard") {
FillInnerHTML("save-location-input-tooltip", "Click once to copy to clipboard"); FillInnerHTML("save-location-input-tooltip", "Click once to copy to clipboard");
var tooltipWidth = tooltip.offsetWidth;
/* make sure that the tooltip is centered */ /* make sure that the tooltip is centered */
tooltip.style.marginLeft = "-".concat(tooltipWidth / 2, "px"); tooltip.style.marginLeft = "-".concat(tooltip.offsetWidth / 2, "px");
}
}, false); }, false);
/* ------------- Checkbox functions ---------------------- */ /* ------------- Checkbox functions ---------------------- */

File diff suppressed because one or more lines are too long

View file

@ -970,10 +970,8 @@ document.getElementById("save-location-input").addEventListener("click", (e) =>
SelectCopyInputText(e, "save-location-input-tooltip", "Copied save files location to clipboard"); SelectCopyInputText(e, "save-location-input-tooltip", "Copied save files location to clipboard");
let tooltipWidth = tooltip.offsetWidth;
/* make sure that the tooltip is centered */ /* make sure that the tooltip is centered */
tooltip.style.marginLeft = `-${tooltipWidth / 2}px`; tooltip.style.marginLeft = `-${tooltip.offsetWidth / 2}px`;
}, false); }, false);
/* -------------- Switch text back to the default on mouse out -------------- */ /* -------------- Switch text back to the default on mouse out -------------- */
@ -982,12 +980,14 @@ document.getElementById("save-location-input").addEventListener("mouseout", () =
let tooltip = document.getElementById("save-location-input-tooltip"); let tooltip = document.getElementById("save-location-input-tooltip");
/* change the text and center only when the text was different */
if (tooltip.innerHTML !== "Click once to copy to clipboard") {
FillInnerHTML("save-location-input-tooltip", "Click once to copy to clipboard"); FillInnerHTML("save-location-input-tooltip", "Click once to copy to clipboard");
let tooltipWidth = tooltip.offsetWidth;
/* make sure that the tooltip is centered */ /* make sure that the tooltip is centered */
tooltip.style.marginLeft = `-${tooltipWidth / 2}px`; tooltip.style.marginLeft = `-${tooltip.offsetWidth / 2}px`;
}
}, false); }, false);
/* ------------- Checkbox functions ---------------------- */ /* ------------- Checkbox functions ---------------------- */