mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-11-11 18:03:30 +08:00
Merge branch 'master' of https://github.com/Miodec/monkey-type
This commit is contained in:
commit
b9b24976be
2 changed files with 53 additions and 13 deletions
|
@ -22,29 +22,36 @@ class SettingsGroup {
|
|||
"click",
|
||||
`.pageSettings .section.${this.configName} .button`,
|
||||
(e) => {
|
||||
let target = $(e.currentTarget);
|
||||
if (target.hasClass("disabled") || target.hasClass("no-auto-handle"))
|
||||
return;
|
||||
if (this.onOff) {
|
||||
if ($(e.currentTarget).hasClass("on")) {
|
||||
this.toggleFunction(true);
|
||||
if (target.hasClass("on")) {
|
||||
this.setValue(true);
|
||||
} else {
|
||||
this.toggleFunction(false);
|
||||
this.setValue(false);
|
||||
}
|
||||
this.updateButton();
|
||||
if (this.setCallback !== null) this.setCallback();
|
||||
} else {
|
||||
let value = $(e.currentTarget).attr(configName);
|
||||
let params = $(e.currentTarget).attr("params");
|
||||
if (params === undefined) {
|
||||
this.toggleFunction(value);
|
||||
} else {
|
||||
this.toggleFunction(value, ...params);
|
||||
}
|
||||
this.updateButton();
|
||||
if (this.setCallback !== null) this.setCallback();
|
||||
let value = target.attr(configName);
|
||||
let params = target.attr("params");
|
||||
this.setValue(value, params);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
setValue(value, params = undefined) {
|
||||
if (params === undefined) {
|
||||
this.toggleFunction(value);
|
||||
} else {
|
||||
this.toggleFunction(value, ...params);
|
||||
}
|
||||
this.updateButton();
|
||||
if (this.setCallback !== null) this.setCallback();
|
||||
}
|
||||
|
||||
updateButton() {
|
||||
this.configValue = config[this.configName];
|
||||
$(`.pageSettings .section.${this.configName} .button`).removeClass(
|
||||
|
@ -253,7 +260,20 @@ settingsGroups.timerOpacity = new SettingsGroup(
|
|||
setTimerOpacity
|
||||
);
|
||||
settingsGroups.timerColor = new SettingsGroup("timerColor", setTimerColor);
|
||||
settingsGroups.fontFamily = new SettingsGroup("fontFamily", setFontFamily);
|
||||
settingsGroups.fontFamily = new SettingsGroup(
|
||||
"fontFamily",
|
||||
setFontFamily,
|
||||
null,
|
||||
() => {
|
||||
let customButton = $(".pageSettings .section.fontFamily .buttons .custom");
|
||||
if ($(".pageSettings .section.fontFamily .buttons .active").length === 0) {
|
||||
customButton.addClass("active");
|
||||
customButton.text(`[Custom] (${config.fontFamily.replace(/_/g, " ")})`);
|
||||
} else {
|
||||
customButton.text("[Custom]");
|
||||
}
|
||||
}
|
||||
);
|
||||
settingsGroups.alwaysShowDecimalPlaces = new SettingsGroup(
|
||||
"alwaysShowDecimalPlaces",
|
||||
setAlwaysShowDecimalPlaces
|
||||
|
@ -343,6 +363,13 @@ async function fillSettingsPage() {
|
|||
}</div>`
|
||||
);
|
||||
});
|
||||
$(
|
||||
'<div class="language button no-auto-handle custom" onclick="this.blur();">[Custom]</div>'
|
||||
)
|
||||
.on("click", () => {
|
||||
simplePopups.applyCustomFont.show([]);
|
||||
})
|
||||
.appendTo(fontsEl);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -212,3 +212,16 @@ simplePopups.clearTagPb = new SimplePopup(
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
simplePopups.applyCustomFont = new SimplePopup(
|
||||
"applyCustomFont",
|
||||
"text",
|
||||
"Custom font",
|
||||
[{ placeholder: "Font name", initVal: "" }],
|
||||
"Make sure you have the font installed on your computer before applying.",
|
||||
"Apply",
|
||||
(fontName) => {
|
||||
settingsGroups.fontFamily.setValue(fontName.replace(/\s/g, "_"));
|
||||
},
|
||||
() => {}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue