mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 11:02:27 +08:00
chore(client/ts): port new version of switch
This commit is contained in:
parent
0dd91ad737
commit
77bbdc3857
@ -120,15 +120,20 @@ const TPL = `
|
|||||||
|
|
||||||
export default class SwitchWidget extends NoteContextAwareWidget {
|
export default class SwitchWidget extends NoteContextAwareWidget {
|
||||||
|
|
||||||
switchOnName = "";
|
private $switchButton!: JQuery<HTMLElement>;
|
||||||
switchOnTooltip = "";
|
private $switchToggle!: JQuery<HTMLElement>;
|
||||||
|
private $switchName!: JQuery<HTMLElement>;
|
||||||
|
private $helpButton!: JQuery<HTMLElement>;
|
||||||
|
|
||||||
switchOffName = "";
|
private switchOnName = "";
|
||||||
switchOffTooltip = "";
|
private switchOnTooltip = "";
|
||||||
|
|
||||||
disabledTooltip = "";
|
private switchOffName = "";
|
||||||
|
private switchOffTooltip = "";
|
||||||
|
|
||||||
currentState = false;
|
private disabledTooltip = "";
|
||||||
|
|
||||||
|
private currentState = false;
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
@ -147,7 +152,7 @@ export default class SwitchWidget extends NoteContextAwareWidget {
|
|||||||
this.$helpButton = this.$widget.find(".switch-help-button");
|
this.$helpButton = this.$widget.find(".switch-help-button");
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle(state) {
|
toggle(state: boolean) {
|
||||||
if (state) {
|
if (state) {
|
||||||
this.switchOn();
|
this.switchOn();
|
||||||
} else {
|
} else {
|
||||||
@ -185,7 +190,7 @@ export default class SwitchWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
set canToggle(isEnabled) {
|
set canToggle(isEnabled) {
|
||||||
this.$switchButton.toggleClass("disabled", !isEnabled);
|
this.$switchButton.toggleClass("disabled", !isEnabled);
|
||||||
this.$switchToggle.attr("disabled", !isEnabled);
|
this.$switchToggle.attr("disabled", !isEnabled ? "disabled" : null);
|
||||||
|
|
||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
this.isToggled = this.currentState; // Reapply the correct tooltip
|
this.isToggled = this.currentState; // Reapply the correct tooltip
|
Loading…
x
Reference in New Issue
Block a user