@@ -34,11 +34,13 @@ class Visua11y extends Backbone.Controller {
34
34
35
35
initialize ( ) {
36
36
this . apply = _ . debounce ( this . apply . bind ( this ) , 50 ) ;
37
+ this . listenTo ( Adapt , 'configModel:dataLoaded' , this . onPreAdaptStart ) ;
37
38
this . listenTo ( Adapt , 'adapt:start' , this . onAdaptStart ) ;
39
+ this . _adaptStarted = false ;
38
40
}
39
41
40
42
get config ( ) {
41
- return _deepDefaults ( Adapt . course . get ( '_visua11y' ) , DEFAULTS ) ;
43
+ return _deepDefaults ( ( this . _adaptStarted ? Adapt . course : Adapt . config ) . get ( '_visua11y' ) , DEFAULTS ) ;
42
44
}
43
45
44
46
get colorProfiles ( ) {
@@ -187,14 +189,29 @@ class Visua11y extends Backbone.Controller {
187
189
return output ;
188
190
}
189
191
190
- onAdaptStart ( ) {
192
+ onPreAdaptStart ( ) {
193
+ // Language picker support
194
+ if ( ! this . config ?. _isEnabled ) return ;
191
195
this . measure ( ) ;
192
196
this . restore ( ) ;
193
197
this . setupNavigationButton ( ) ;
194
198
this . rules = CSSRule . getAllModifiable ( this ) ;
195
199
this . apply ( ) ;
196
200
}
197
201
202
+ onAdaptStart ( ) {
203
+ this . _adaptStarted = true ;
204
+ if ( this . rules ) {
205
+ this . setupNavigationButton ( ) ;
206
+ return ;
207
+ }
208
+ this . measure ( ) ;
209
+ this . restore ( ) ;
210
+ this . setupNavigationButton ( ) ;
211
+ this . rules = this . rules || CSSRule . getAllModifiable ( this ) ;
212
+ this . apply ( ) ;
213
+ }
214
+
198
215
measure ( ) {
199
216
const computedStyle = window . getComputedStyle ( document . querySelector ( 'html' ) ) ;
200
217
this . _originalFontSize = computedStyle . fontSize ;
@@ -314,6 +331,11 @@ class Visua11y extends Backbone.Controller {
314
331
this . save ( ) ;
315
332
this . rules . forEach ( rule => rule . reset ( ) ) ;
316
333
const $html = $ ( 'html' ) ;
334
+ const documentStyle = document . documentElement . style ;
335
+ documentStyle . setProperty ( '--visua11y-color-profile-url' , 'url(assets/visua11y-filters.svg#default)' ) ;
336
+ documentStyle . setProperty ( '--visua11y-invert' , '0%' ) ;
337
+ documentStyle . setProperty ( '--visua11y-contrast' , '100%' ) ;
338
+ documentStyle . setProperty ( '--visua11y-brightness' , '100%' ) ;
317
339
$html
318
340
. removeAttr ( 'data-color-profile' )
319
341
. removeAttr ( 'data-color-inverted' ) ;
0 commit comments