@@ -3,12 +3,12 @@ import NoteContextAwareWidget from "./note_context_aware_widget.js";
3
3
4
4
const TPL = `
5
5
<div class="switch-widget">
6
- <style>
6
+ <style>
7
7
.switch-widget {
8
8
display: flex;
9
9
align-items: center;
10
10
}
11
-
11
+
12
12
/* The switch - the box around the slider */
13
13
.switch-widget .switch {
14
14
position: relative;
@@ -17,11 +17,11 @@ const TPL = `
17
17
height: 24px;
18
18
margin: 0;
19
19
}
20
-
20
+
21
21
.switch-on, .switch-off {
22
22
display: flex;
23
23
}
24
-
24
+
25
25
/* The slider */
26
26
.switch-widget .slider {
27
27
border-radius: 24px;
@@ -34,7 +34,7 @@ const TPL = `
34
34
background-color: var(--more-accented-background-color);
35
35
transition: .4s;
36
36
}
37
-
37
+
38
38
.switch-widget .slider:before {
39
39
border-radius: 50%;
40
40
position: absolute;
@@ -47,20 +47,20 @@ const TPL = `
47
47
-webkit-transition: .4s;
48
48
transition: .4s;
49
49
}
50
-
50
+
51
51
.switch-widget .slider.checked {
52
52
background-color: var(--main-text-color);
53
53
}
54
-
54
+
55
55
.switch-widget .slider.checked:before {
56
56
transform: translateX(26px);
57
57
}
58
-
58
+
59
59
.switch-widget .switch-disabled {
60
60
opacity: 70%;
61
61
pointer-events: none;
62
62
}
63
-
63
+
64
64
.switch-widget .switch-help-button {
65
65
font-weight: 900;
66
66
border: 0;
@@ -72,29 +72,38 @@ const TPL = `
72
72
73
73
<div class="switch-on">
74
74
<span class="switch-on-name"></span>
75
-
75
+
76
76
77
-
77
+
78
78
<span class="switch-on-button">
79
79
<label class="switch">
80
80
<span class="slider"></span>
81
81
</span>
82
82
</div>
83
83
<div class="switch-off">
84
84
<span class="switch-off-name"></span>
85
-
85
+
86
86
87
-
87
+
88
88
<span class="switch-off-button">
89
89
<label class="switch">
90
90
<span class="slider checked"></span>
91
91
</span>
92
92
</div>
93
-
93
+
94
94
<button class="switch-help-button" type="button" data-help-page="" title="${ t ( "open-help-page" ) } " style="display: none;">?</button>
95
95
</div>` ;
96
96
97
97
export default class SwitchWidget extends NoteContextAwareWidget {
98
+
99
+ protected $switchOn ! : JQuery < HTMLElement > ;
100
+ protected $switchOnName ! : JQuery < HTMLElement > ;
101
+ protected $switchOnButton ! : JQuery < HTMLElement > ;
102
+ protected $switchOff ! : JQuery < HTMLElement > ;
103
+ protected $switchOffName ! : JQuery < HTMLElement > ;
104
+ protected $switchOffButton ! : JQuery < HTMLElement > ;
105
+ protected $helpButton ! : JQuery < HTMLElement > ;
106
+
98
107
doRender ( ) {
99
108
this . $widget = $ ( TPL ) ;
100
109
@@ -113,7 +122,7 @@ export default class SwitchWidget extends NoteContextAwareWidget {
113
122
this . $helpButton = this . $widget . find ( ".switch-help-button" ) ;
114
123
}
115
124
116
- toggle ( state ) {
125
+ toggle ( state : boolean ) {
117
126
if ( state ) {
118
127
this . switchOn ( ) ;
119
128
} else {
0 commit comments