@@ -96,7 +96,11 @@ export class DescriptionDisplay {
96
96
97
97
constructor ( container : HTMLDivElement ) {
98
98
this . _container = container ;
99
- this . _expanded = false ;
99
+ if ( localStorage && localStorage . getItem ( 'expanded' ) ) {
100
+ this . _expanded = localStorage . getItem ( 'expanded' ) === 'true' ;
101
+ } else {
102
+ this . _expanded = true ;
103
+ }
100
104
101
105
this . _tabContainer = document . getElementById (
102
106
'description-tab-row'
@@ -110,10 +114,14 @@ export class DescriptionDisplay {
110
114
this . _longText = document . getElementById (
111
115
'description-long-text'
112
116
) as HTMLZeroMDElement ;
117
+
118
+ this . _longText . classList . toggle ( 'show' , this . _expanded ) ;
119
+
113
120
this . _showMoreLessButton = document . getElementById (
114
121
'description-show-more-less'
115
122
) as HTMLButtonElement ;
116
123
124
+ this . setShowMoreLessButtonText ( ) ;
117
125
this . showMoreLessButton . onclick = ( ev : MouseEvent ) => {
118
126
this . onShowMoreLessClick ( ) ;
119
127
} ;
@@ -147,12 +155,16 @@ export class DescriptionDisplay {
147
155
148
156
private onShowMoreLessClick ( ) : void {
149
157
this . _expanded = ! this . expanded ;
158
+ if ( localStorage ) {
159
+ localStorage . setItem ( 'expanded' , `${ this . _expanded } ` ) ;
160
+ }
161
+ this . setShowMoreLessButtonText ( ) ;
162
+ }
163
+ private setShowMoreLessButtonText ( ) : void {
150
164
if ( this . expanded ) {
151
165
this . showMoreLessButton . innerText = 'Show less.' ;
152
- // this.longText.classList.remove('d-none');
153
166
} else {
154
167
this . showMoreLessButton . innerText = 'Show more.' ;
155
- // this.longText.classList.add('d-none');
156
168
}
157
169
}
158
170
}
0 commit comments