Skip to content

Commit

Permalink
Small changes for support for legacy browsers
Browse files Browse the repository at this point in the history
- Remove prefers-color-scheme from light stylesheet
- Add fallback for addEventListener
  • Loading branch information
Jazzzny authored and Ninjaclasher committed Dec 6, 2024
1 parent a9e9e5c commit d97a56f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions django_ace/static/django_ace/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@
}

setEditorTheme(window.matchMedia('(prefers-color-scheme: dark)').matches);
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(ev) {
setEditorTheme(ev.matches);
})
try {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(ev) {
setEditorTheme(ev.matches);
})
} catch (err) {
window.matchMedia('(prefers-color-scheme: dark)').addListener(function(ev) {
setEditorTheme(ev.matches);
})
}
}
}
if (wordwrap == "true") {
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
{% if PREFERRED_STYLE_CSS is not none %}
<link rel="stylesheet" href="{{ static(PREFERRED_STYLE_CSS) }}">
{% else %}
<link rel="stylesheet" href="{{ static(LIGHT_STYLE_CSS) }}" media="(prefers-color-scheme: light)">
<link rel="stylesheet" href="{{ static(LIGHT_STYLE_CSS) }}">
<link rel="stylesheet" href="{{ static(DARK_STYLE_CSS) }}" media="(prefers-color-scheme: dark)">
{% endif %}
{% else %}
Expand Down

0 comments on commit d97a56f

Please sign in to comment.