From 690e6a28fa4bbabdf7f8f2b4fac523a325d0a9a2 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 20 Sep 2017 16:24:13 +0000 Subject: [PATCH] Merge burgermenu inside searchengine | #1666 --- .../searchengine/class.ws.html5.compiler.php | 51 +++++++++++-------- .../searchengine/class.ws.html5.links.php | 45 ++++++++++++---- 2 files changed, 65 insertions(+), 31 deletions(-) diff --git a/inc/ws/Util/html5/searchengine/class.ws.html5.compiler.php b/inc/ws/Util/html5/searchengine/class.ws.html5.compiler.php index da3a0201b..3605ee5af 100644 --- a/inc/ws/Util/html5/searchengine/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/searchengine/class.ws.html5.compiler.php @@ -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'), '
', ''); $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 .= ''; } } @@ -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)); diff --git a/inc/ws/Util/html5/searchengine/class.ws.html5.links.php b/inc/ws/Util/html5/searchengine/class.ws.html5.links.php index 5ad7c36dd..13b67d2c0 100644 --- a/inc/ws/Util/html5/searchengine/class.ws.html5.links.php +++ b/inc/ws/Util/html5/searchengine/class.ws.html5.links.php @@ -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'); -- 2.39.5