Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 6aba099

Browse files
committed
chore(client/ts): port switch
1 parent f86d9b1 commit 6aba099

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

src/public/app/widgets/switch.js renamed to src/public/app/widgets/switch.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import NoteContextAwareWidget from "./note_context_aware_widget.js";
33

44
const TPL = `
55
<div class="switch-widget">
6-
<style>
6+
<style>
77
.switch-widget {
88
display: flex;
99
align-items: center;
1010
}
11-
11+
1212
/* The switch - the box around the slider */
1313
.switch-widget .switch {
1414
position: relative;
@@ -17,11 +17,11 @@ const TPL = `
1717
height: 24px;
1818
margin: 0;
1919
}
20-
20+
2121
.switch-on, .switch-off {
2222
display: flex;
2323
}
24-
24+
2525
/* The slider */
2626
.switch-widget .slider {
2727
border-radius: 24px;
@@ -34,7 +34,7 @@ const TPL = `
3434
background-color: var(--more-accented-background-color);
3535
transition: .4s;
3636
}
37-
37+
3838
.switch-widget .slider:before {
3939
border-radius: 50%;
4040
position: absolute;
@@ -47,20 +47,20 @@ const TPL = `
4747
-webkit-transition: .4s;
4848
transition: .4s;
4949
}
50-
50+
5151
.switch-widget .slider.checked {
5252
background-color: var(--main-text-color);
5353
}
54-
54+
5555
.switch-widget .slider.checked:before {
5656
transform: translateX(26px);
5757
}
58-
58+
5959
.switch-widget .switch-disabled {
6060
opacity: 70%;
6161
pointer-events: none;
6262
}
63-
63+
6464
.switch-widget .switch-help-button {
6565
font-weight: 900;
6666
border: 0;
@@ -72,29 +72,38 @@ const TPL = `
7272
7373
<div class="switch-on">
7474
<span class="switch-on-name"></span>
75-
75+
7676
&nbsp;
77-
77+
7878
<span class="switch-on-button">
7979
<label class="switch">
8080
<span class="slider"></span>
8181
</span>
8282
</div>
8383
<div class="switch-off">
8484
<span class="switch-off-name"></span>
85-
85+
8686
&nbsp;
87-
87+
8888
<span class="switch-off-button">
8989
<label class="switch">
9090
<span class="slider checked"></span>
9191
</span>
9292
</div>
93-
93+
9494
<button class="switch-help-button" type="button" data-help-page="" title="${t("open-help-page")}" style="display: none;">?</button>
9595
</div>`;
9696

9797
export default class SwitchWidget extends NoteContextAwareWidget {
98+
99+
private $switchOn!: JQuery<HTMLElement>;
100+
private $switchOnName!: JQuery<HTMLElement>;
101+
private $switchOnButton!: JQuery<HTMLElement>;
102+
private $switchOff!: JQuery<HTMLElement>;
103+
private $switchOffName!: JQuery<HTMLElement>;
104+
private $switchOffButton!: JQuery<HTMLElement>;
105+
private $helpButton!: JQuery<HTMLElement>;
106+
98107
doRender() {
99108
this.$widget = $(TPL);
100109

@@ -113,7 +122,7 @@ export default class SwitchWidget extends NoteContextAwareWidget {
113122
this.$helpButton = this.$widget.find(".switch-help-button");
114123
}
115124

116-
toggle(state) {
125+
toggle(state: boolean) {
117126
if (state) {
118127
this.switchOn();
119128
} else {

0 commit comments

Comments
 (0)