]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5902 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 2 May 2023 09:03:29 +0000 (11:03 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 2 May 2023 09:03:29 +0000 (11:03 +0200)
app/Http/Controllers/Admin/Operations/FluidbookPreviewOperation.php

index e50e6cb6669dfc50a5a36e34a52464969f697013..c217f35c10b7766de754097abd443af54d00de7d 100644 (file)
@@ -27,53 +27,32 @@ trait FluidbookPreviewOperation
 
     protected function _loadingCompile($theme, $title, $url)
     {
-        $bgcolor = Color::colorToCSS($theme->backgroundColor);
-        $scolor = Color::colorToCSS($theme->loadingSecColor);
-        $tcolor = $lcolor = Color::colorToCSS($theme->couleurL);
-        if ($tcolor == $bgcolor) {
+        $bgcolor = new Color($theme->backgroundColor);
+        $scolor = new Color($theme->loadingSecColor);
+        $tcolor = $lcolor = new Color($theme->couleurL);
+
+        $tdist = $tcolor->distance($bgcolor);
+        $sdist = $scolor->distance($bgcolor);
+
+        if ($tdist < 20000 && $sdist > $tdist) {
             $tcolor = $scolor;
         }
 
         $res = '<!DOCTYPE html><html>';
         $res .= '<head>';
-        $res .= '<script type="text/javascript">function load(){
-    var url=\'' . $url . '\'+window.location.hash;
-    window.location=url;
-};
-</script>';
+        $res .= '<script type="text/javascript">function load(){var url=\'' . $url . '\'+window.location.hash;window.location=url;}</script>';
         if (!request('shortLoading', false)) {
             $res .= '<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">';
-            $res .= '<style>
-@keyframes loader-spin {
-  0% {
-    transform: rotate(0deg);
-  }
-  100% {
-    transform: rotate(360deg);
-  }
-}
-*{margin:0;padding:0;}
-html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-color:' . $bgcolor . ';}';
-            $res .= 'h2,h3{text-align:center;color:' . $tcolor . ';font-weight:400;position:relative;top:55%;}';
+            $res .= '<style>@keyframes loader-spin{0%{transform: rotate(0deg);}100%{transform: rotate(360deg);}}*{margin:0;padding:0;}html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-color:' . $bgcolor->toCSS() . ';}';
+            $res .= 'h2,h3{text-align:center;color:' . $tcolor->toCSS() . ';font-weight:400;position:relative;top:55%;}';
             $res .= 'h2{font-size:16px;}';
             $res .= 'h3{font-size:10px;}';
-            $res .= 'svg{position:absolute;top:calc(50% - 24px);left:calc(50% - 24px);
-        animation-name: loader-spin;
-        animation-duration: 1s;
-        animation-iteration-count: infinite;
-        animation-timing-function: linear;}';
+            $res .= 'svg{position:absolute;top:calc(50% - 24px);left:calc(50% - 24px);animation-name: loader-spin;animation-duration: 1s;animation-iteration-count: infinite;animation-timing-function: linear;}';
             $res .= '</style>';
             $res .= '<title>' . $title . '</title>';
             $res .= '</head>';
             $res .= '<body onload="load();">';
-            $res .= '<svg width="48" height="48" id="interface-loader" viewBox="0 0 48 48">
-        <circle cx="24" cy="24" r="23" fill="' . $lcolor . '"></circle>
-        <circle class="animate" cx="24" cy="24" fill="none" stroke="' . $scolor . '" stroke-width="3" r="16"
-                stroke-dasharray="80 80"
-                transform="rotate(0 24 24)">
-        </circle>
-    </svg>';
-
+            $res .= '<svg width="48" height="48" id="interface-loader" viewBox="0 0 48 48"><circle cx="24" cy="24" r="23" fill="' . $lcolor->toCSS() . '"></circle><circle class="animate" cx="24" cy="24" fill="none" stroke="' . $scolor->toCSS() . '" stroke-width="3" r="16" stroke-dasharray="80 80" transform="rotate(0 24 24)"></circle></svg>';
             $res .= '<h2>' . __('Compilation du fluidbook en cours') . '...</h2>';
             $res .= '<h3>' . __('Cette étape ne sera pas nécessaire lorsque le fluidbook sera installé sur son emplacement définitif') . '</h3>';
         } else {