Skip to content

Commit 7f61a49

Browse files
committed
Add listener for change color mode
1 parent ca0b27f commit 7f61a49

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

resources/views/standalonepopup.blade.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
<script type="text/javascript">
99
$().ready(function () {
10+
var theme = 'default';
11+
1012
var elf = $('#elfinder').elfinder({
1113
// set your elFinder options here
1214
@if($locale)
@@ -39,10 +41,29 @@
3941
default : 'https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme/manifests/material-gray.json',
4042
dark : 'https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme/manifests/material-default.json',
4143
},
42-
theme: 'default',
44+
theme: theme,
45+
},
46+
function(fm, extraObj) {
47+
fm.bind('open', function() {
48+
setElFinderColorMode();
49+
});
4350
}).elfinder('instance');
4451
45-
//elf.changeTheme('dark').storage('theme', 'dark');
52+
function isElfinderInDarkMode() {
53+
return typeof window.parent.colorMode !== 'undefined' && window.parent.colorMode.result === 'dark';
54+
}
55+
56+
function setElFinderColorMode() {
57+
theme = isElfinderInDarkMode() ? 'dark' : 'default';
58+
let instance = $('#elfinder').elfinder('instance');
59+
instance.changeTheme(theme).storage('theme', theme);
60+
}
61+
62+
if(typeof window.parent.colorMode !== 'undefined') {
63+
window.parent.colorMode.onChange(function() {
64+
setElFinderColorMode();
65+
});
66+
}
4667
});
4768
</script>
4869

0 commit comments

Comments
 (0)