Skip to content

Commit

Permalink
chore(client/ts): port new version of switch
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Jan 31, 2025
1 parent 0dd91ad commit 77bbdc3
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,20 @@ const TPL = `

export default class SwitchWidget extends NoteContextAwareWidget {

switchOnName = "";
switchOnTooltip = "";
private $switchButton!: JQuery<HTMLElement>;
private $switchToggle!: JQuery<HTMLElement>;
private $switchName!: JQuery<HTMLElement>;
private $helpButton!: JQuery<HTMLElement>;

switchOffName = "";
switchOffTooltip = "";
private switchOnName = "";
private switchOnTooltip = "";

disabledTooltip = "";
private switchOffName = "";
private switchOffTooltip = "";

currentState = false;
private disabledTooltip = "";

private currentState = false;

doRender() {
this.$widget = $(TPL);
Expand All @@ -147,7 +152,7 @@ export default class SwitchWidget extends NoteContextAwareWidget {
this.$helpButton = this.$widget.find(".switch-help-button");
}

toggle(state) {
toggle(state: boolean) {
if (state) {
this.switchOn();
} else {
Expand Down Expand Up @@ -185,7 +190,7 @@ export default class SwitchWidget extends NoteContextAwareWidget {

set canToggle(isEnabled) {
this.$switchButton.toggleClass("disabled", !isEnabled);
this.$switchToggle.attr("disabled", !isEnabled);
this.$switchToggle.attr("disabled", !isEnabled ? "disabled" : null);

if (isEnabled) {
this.isToggled = this.currentState; // Reapply the correct tooltip
Expand Down

0 comments on commit 77bbdc3

Please sign in to comment.