2222@basset (' https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme@3.0.0/Material/font/material.woff' , false )
2323@basset (' https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme@3.0.0/Material/font/material.ttf' , false )
2424@basset (' https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme@3.0.0/Material/font/material.woff2' , false )
25+ @basset (' https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme@3.0.0/Material/css/theme-gray.min.css' , false )
26+ <span data-elfinder-light-theme-url =" {{ Basset:: getUrl (' https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme@3.0.0/Material/css/theme-gray.min.css' ) } }" style =" display :none " ></span >
2527@bassetBlock (' elfinderThemeSwitcherScript.js' )
2628<script type =" text/javascript" >
2729document .addEventListener (' DOMContentLoaded' , function () {
@@ -39,19 +41,20 @@ function getElfinderStyleSheet(main = true) {
3941 }
4042
4143 function addElfinderLightStylesheet () {
42- let themeLightAsset = ` {{ Basset:: basset (' https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme@3.0.0/Material/css/theme-gray.min.css' ) } }` ;
43- const match = themeLightAsset .match (/ <link\s + href="([^ "] + )"/ i );
44- if (match && match .length > 1 ) {
45- let mainStyleSheet = getElfinderStyleSheet ();
46- let lightStyleSheet = getElfinderStyleSheet (false );
47- // if found append the light mode css to the main theme stylesheet
48- if (mainStyleSheet && ! lightStyleSheet) {
49- let themeLight = document .createElement (' link' );
50- themeLight .href = match[1 ];
51- themeLight .rel = ' stylesheet' ;
52- themeLight .type = ' text/css' ;
53- mainStyleSheet .insertAdjacentElement (' afterend' , themeLight);
54- }
44+ let lightThemeEl = document .querySelector (' [data-elfinder-light-theme-url]' );
45+ if (! lightThemeEl) return ;
46+ let lightThemeUrl = lightThemeEl .getAttribute (' data-elfinder-light-theme-url' );
47+ if (! lightThemeUrl) return ;
48+
49+ let mainStyleSheet = getElfinderStyleSheet ();
50+ let lightStyleSheet = getElfinderStyleSheet (false );
51+ // if found append the light mode css to the main theme stylesheet
52+ if (mainStyleSheet && ! lightStyleSheet) {
53+ let themeLight = document .createElement (' link' );
54+ themeLight .href = lightThemeUrl;
55+ themeLight .rel = ' stylesheet' ;
56+ themeLight .type = ' text/css' ;
57+ mainStyleSheet .insertAdjacentElement (' afterend' , themeLight);
5558 }
5659 }
5760
@@ -81,13 +84,17 @@ function addElfinderLightStylesheet() {
8184 });
8285 }
8386
84- // we dont want to style the body when elfinder is loaded as a component in a backpack view
85- // we pass true when loading elfinder inside an iframe to style the iframe body.
86- @if ($styleBodyElement ?? false )
87+ });
88+ < / script>
89+ @endBassetBlock
90+ @if ($styleBodyElement ?? false )
91+ < script type= " text/javascript" >
92+ document .addEventListener (' DOMContentLoaded' , function () {
93+ // we dont want to style the body when elfinder is loaded as a component in a backpack view
94+ // we pass true when loading elfinder inside an iframe to style the iframe body.
8795 // use the topbar and footbar darker color as the background to ease transitions
8896 document .getElementsByTagName (' body' )[0 ].style .background = ' #061325' ;
8997 document .getElementsByTagName (' body' )[0 ].style .opacity = 1 ;
90- @endif
91- });
98+ });
9299< / script>
93- @endBassetBlock
100+ @endif
0 commit comments