]> _ Git - cubeextranet.git/commitdiff
Merge burgermenu inside searchengine | #1666
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 20 Sep 2017 16:24:13 +0000 (16:24 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 20 Sep 2017 16:24:13 +0000 (16:24 +0000)
inc/ws/Util/html5/searchengine/class.ws.html5.compiler.php
inc/ws/Util/html5/searchengine/class.ws.html5.links.php

index da3a0201bdf7db195070a43b9d155cdde42b5dec..3605ee5afa3265305078d2b0bbab371fbaf69509 100644 (file)
@@ -22,11 +22,13 @@ class wsHTML5Compiler {
                'js/libs/jquery/jquery.scrollto.js',
                'js/libs/jquery/jquery.localscroll.js',
                'js/libs/jquery/perfect-scrollbar.jquery.js',
+               'js/libs/mmenu/jquery.mmenu.js',
+               'js/libs/mmenu/jquery.mmenu.rtl.js',
+               'js/libs/mmenu/jquery.mmenu.offcanvas.js',
                'js/libs/gsap/TweenMax.js',
                'js/libs/gsap/jquery.gsap.js',
                'js/libs/gal/gal.js',
                'js/libs/gal/gal.filesystem.js',
-               'js/libs/interact.js',
                'js/libs/hammer.js',
                'js/libs/fluidbook/forms/fluidbook.form.bulle.js',
                'js/libs/fluidbook/fluidbook.utils.js',
@@ -41,7 +43,6 @@ class wsHTML5Compiler {
                'js/libs/fluidbook/fluidbook.slider.js',
                'js/libs/fluidbook/fluidbook.nav.js',
                'js/libs/fluidbook/fluidbook.touch.js',
-               'js/libs/fluidbook/fluidbook.interact.js',
                'js/libs/fluidbook/fluidbook.loader.js',
                'js/libs/fluidbook/fluidbook.search.js',
                'js/libs/fluidbook/fluidbook.help.js',
@@ -593,10 +594,10 @@ class wsHTML5Compiler {
                $message = sprintf($this->__('Your browser is not up to date and is not able to run this publication. %sLearn more%s'), '<br /><a href="http://www.whatbrowser.org/intl/' . $this->config->defaultLang . '/" target="_blank">', '</a>');
 
                $splash = '';
-               if ($this->theme->parametres->logoLoader) {
-                       $dim = getimagesize($this->themeRoot . '/' . $this->theme->parametres->logoLoader);
+               if ($this->theme->parametres->logoLoader && file_exists($this->themeRoot . $this->theme->parametres->logoLoader)) {
+                       $dim = getimagesize($this->themeRoot . $this->theme->parametres->logoLoader);
                        if ($dim !== false) {
-                               $this->copy($this->themeRoot . '/' . $this->theme->parametres->logoLoader, $this->vdir . '/data/images/' . $this->theme->parametres->logoLoader);
+                               $this->copy($this->themeRoot . $this->theme->parametres->logoLoader, $this->vdir . '/data/images/' . $this->theme->parametres->logoLoader);
                                $splash .= '<div class="logo"><img src="data/images/' . $this->theme->parametres->logoLoader . '" width="' . $dim[0] . '" height="' . $dim[1] . '" alt="" /></div>';
                        }
                }
@@ -774,6 +775,15 @@ class wsHTML5Compiler {
                        $this->addFilesInfos('archives', $this->wdir . '/' . $this->book->parametres->externalArchives);
                        $this->copy($this->wdir . '/' . $this->book->parametres->externalArchives, $this->vdir . '/data/images/' . $this->book->parametres->externalArchives);
                }
+
+        if ($this->book->parametres->navExtraImage != '') {
+            $this->copy($this->wdir . '/' . $this->book->parametres->navExtraImage, $this->vdir . '/data/images/' . $this->book->parametres->navExtraImage);
+        }
+
+        if ($this->book->parametres->navExtraImageMobile != '') {
+            $this->copy($this->wdir . '/' . $this->book->parametres->navExtraImageMobile, $this->vdir . '/data/images/' . $this->book->parametres->navExtraImageMobile);
+        }
+
        }
 
        protected function writeLinks() {
@@ -935,7 +945,7 @@ class wsHTML5Compiler {
                        }
 
                        if (!$reminimize) {
-                               if (filemtime(__FILE__) > $mintime || filemtime(__DIR__ . '/class.ws.html5.links.php') > $mintime) {
+                               if (filemtime(__FILE__) > $mintime || (file_exists(__DIR__ . '/class.ws.html5.links.php') && filemtime(__DIR__ . '/class.ws.html5.links.php') > $mintime)) {
                                        $reminimize = true;
                                }
                        }
@@ -1324,19 +1334,19 @@ class wsHTML5Compiler {
                $res[] = 'svg .fill-c-menu-text{fill:' . wsHTML5::colorToCSS($this->theme->parametres->subTextColor) . ';}';
 
                // Search field
-               $searchColor = wsHTML5::colorToCSS($this->theme->parametres->couleurS);
-               $searchBackColor = wsHTML5::colorToCSS($this->theme->parametres->searchFieldColor);
-               $search = '#q{';
-               $search .= 'color:' . $searchColor . ';';
-               $search .= 'background-color:' . $searchBackColor . ';';
-               if ($this->theme->parametres->searchShadeAlpha > 0) {
-                       $search .= wsHTML5::writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;';
-               }
-               $search .= '}';
-               $search .= '#searchHints,.hint{color:' . $searchColor . ';background-color:' . $searchBackColor . ';}';
-               $search .= '.hint:hover{color:' . $searchBackColor . ';background-color:' . $searchColor . ';}';
-
-               $res[] = $search;
+//             $searchColor = wsHTML5::colorToCSS($this->theme->parametres->couleurS);
+//             $searchBackColor = wsHTML5::colorToCSS($this->theme->parametres->searchFieldColor);
+//             $search = '#q{';
+//             $search .= 'color:' . $searchColor . ';';
+//             $search .= 'background-color:' . $searchBackColor . ';';
+//             if ($this->theme->parametres->searchShadeAlpha > 0) {
+//                     $search .= wsHTML5::writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;';
+//             }
+//             $search .= '}';
+//             $search .= '#searchHints,.hint{color:' . $searchColor . ';background-color:' . $searchBackColor . ';}';
+//             $search .= '.hint:hover{color:' . $searchBackColor . ';background-color:' . $searchColor . ';}';
+//
+//             $res[] = $search;
 
                // Background
                $res[] = $this->_cssBackground();
@@ -1406,6 +1416,7 @@ class wsHTML5Compiler {
                $lessVariables['menu-text'] = $menuTextColor;
                $lessVariables['menu-field-background'] = wsHTML5::colorToCSS($this->theme->parametres->subFieldColor);
                $lessVariables['menu-field-text'] = wsHTML5::colorToCSS($this->theme->parametres->subTextFieldColor);
+               $lessVariables['icon-color'] = wsHTML5::colorToCSS($this->theme->parametres->couleurI);
 
 
                $menuMultiply = $menuColor->multiply($menuColor);
@@ -1457,7 +1468,7 @@ class wsHTML5Compiler {
 
                $bookVariables = array();
                foreach ($variables as $k => $v) {
-                       $bookVariables[] = '@' . $k . ':' . $v . ';';
+                       $bookVariables[] = '@' . trim($k) . ':' . $v . ';';
                }
                file_put_contents($tmp . '/book-variables.less', implode("\n", $bookVariables));
 
index 5ad7c36dde355d35d787fef4d9befbeb6a3e964c..13b67d2c0d52cbce59331b69957bdc47bb11de01 100644 (file)
@@ -262,8 +262,8 @@ class wsHTML5Link {
                }
 
                $css = '#l_' . $this->id . '{';
-               $css .= 'left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;';
-               $css .= 'width:' . $this->width * $this->getCssScale() . 'px;height:' . $this->height * $this->getCssScale() . 'px;';
+               $css .= 'left:' . round($this->left * $this->getCssScale()) . 'px;top:' . round($this->top * $this->getCssScale()) . 'px;';
+               $css .= 'width:' . round($this->width * $this->getCssScale()) . 'px;height:' . round($this->height * $this->getCssScale()) . 'px;';
                $origin = false;
                if ($this->rot) {
                        $css .= wsHTML5::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)');
@@ -1226,6 +1226,8 @@ class zoomLink extends normalLink {
                // Data attributes
                $attributes = [
                        'maxzoom' => $this->to,
+            'width' => round($this->width),
+            'height' => round($this->height)
                ];
 
                // Set data attributes
@@ -1239,26 +1241,47 @@ class zoomLink extends normalLink {
        }
 
        public function generateImage() {
-               $left = CubeIT_Files::tempnam();
+
+               $maxzoom = ((int)$this->to !== 0) ? $this->to : 2; // Max zoom level might not always be set in the link editor
+
+        // TODO: Consider generating higher-res images (eg. 2x) for HiDPI screens. Maybe some extra optimisations can be done on the larger images...
+
+               $extractOptions = [
+                   // The Poppler::extractArea function accepts a resolution setting and uses that to determine the
+            // scale factor on the extracted images. It does so by dividing by 72, so we can pass our own scale
+            // factor by setting the resolution to 72 * $maxzoom
+                   'resolution' => 72 * $maxzoom
+        ];
+
+               // Round all link co-ordinates because there seems to be a problem with the the Workshop link editor
+        // where link "left" values (and maybe others) change fractionally upon saves. This causes problems later when
+        // extracting the zoom images from the PDF because it causes a cache-miss and the images are regenerated again.
+               $x = round($this->left);
+               $y = round($this->top);
+               $w = round($this->width);
+               $h = round($this->height);
+        $bookwidth = round($this->compiler->book->parametres->width);
+
+        //error_log("--- Book Width: $bookwidth ---");
 
                $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page);
                $pdfpath = wsDocument::getDir($p['document_id']) . 'original.pdf';
+
+        $left = CubeIT_Files::tempnam();
                $leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
                        $p['document_page'],
-                       array('x' => $this->left, 'y' => $this->top, 'width' => $this->width, 'height' => $this->height),
-                       $left, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/');
-
-               $bookwidth = $this->compiler->book->parametres->width;
+                       array('x' => $x, 'y' => $y, 'width' => $w, 'height' => $h),
+                       $left, $extractOptions, WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/');
 
-               if (($this->left + $this->width) > $bookwidth) {
+               if (($x + $w) > $bookwidth) {
                        $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page + 1);
                        $pdfpath = wsDocument::getDir($p['document_id']) . 'original.pdf';
-                       $diff = ($this->width + $this->left) - $bookwidth;
+                       $diff = ($w + $x) - $bookwidth;
                        $right = CubeIT_Files::tempnam();
                        $rightfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
                                $p['document_page'],
-                               array('x' => 0, 'y' => $this->top, 'width' => $diff, 'height' => $this->height),
-                               $right, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/');
+                               array('x' => 0, 'y' => $y, 'width' => $diff, 'height' => $h),
+                               $right, $extractOptions, WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/');
 
                        $both = CubeIT_Files::tempnam() . '.jpg';
                        CubeIT_CommandLine_Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');