From: vincent@cubedesigners.com Date: Thu, 21 Mar 2019 11:39:05 +0000 (+0000) Subject: wip #2643 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1d1ba8a853954faf87df8ea3341d37858e9da279;p=cubeextranet.git wip #2643 @1 --- diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 5cb547dc7..fcaa9de33 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -45,6 +45,8 @@ class wsHTML5Compiler 'raphael' => ['js/libs/raphael/raphael.min.js', 'js/libs/gsap/plugins/RaphaelPlugin.min.js'], + 'countup' => + ['js/libs/countup/countup.min.js'], 'fluidbook' => ['js/libs/fluidbook/fluidbook.utils.js', 'js/libs/fluidbook/fluidbook.links.js', @@ -1191,7 +1193,22 @@ class wsHTML5Compiler $pagesOfCustomLinks = []; $hiddenLinks = []; - foreach ($links as $linkData) { + $linksCopy = $links; + + foreach ($linksCopy as $k => $linkData) { + if ($linkData['type'] == 35) { + $animation = contentLink::parseAnimation($linkData['image_rollover']); + if (isset($animation['backgroundColor']) && $animation['backgroundColor'] != 'transparent') { + $dupData = $linkData; + $dupData['type'] = 14; + $dupData['to'] = $animation['backgroundColor']; + $dupData['image_rollover'] = ''; + $dupData['uid'] = 'b_' . $linkData['uid']; + array_push($links, $dupData); + array_push($links, $linkData); + unset($links[$k]); + } + } if (isset($linkData['image']) && $linkData['image'] && $linkData['type'] != 28 && $linkData['type'] != 35) { $dupData = $linkData; $dupData['image'] = ''; @@ -1318,10 +1335,11 @@ class wsHTML5Compiler public function _sortLinks($a, $b) { - $priorities = array(26 => 1); - $pa = isset($priorities[$a['type']]) ? $priorities[$a['type']] : 0; - $pb = isset($priorities[$b['type']]) ? $priorities[$b['type']] : 0; + $priorities = array(26 => -1, 35 => 1); + + $pa = isset($priorities[$a['type']]) ? -$priorities[$a['type']] : 0; + $pb = isset($priorities[$b['type']]) ? -$priorities[$b['type']] : 0; return $pb - $pa; } @@ -2086,21 +2104,43 @@ class wsHTML5Compiler $e = explode('.', $f); $ext = array_pop($f); $hash = 'fb_' . substr(md5($fontFile), 0, 10); - if (array_search($hash, $this->cssfont) !== false) { - return; - } - $final = $hash . '.woff'; - if (!file_exists($final) || filemtime($final) < filemtime($f)) { - $dest = $this->wdir . '/' . $final; - if ($ext == 'otf' || $ext == 'woff') { - `sfnt2woff $f $dest`; - } else if ($ext == 'woff') { - copy($f, $dest); + if (!isset($this->cssfont[$hash])) { + $final = $hash . '.woff'; + if (!file_exists($final) || filemtime($final) < filemtime($f)) { + $dest = $this->wdir . '/' . $final; + if ($ext == 'otf' || $ext == 'woff') { + `sfnt2woff $f $dest`; + } + } + $this->vdir->copy($dest, 'data/fonts/' . $hash . '.woff'); + $cmd = "font-line report $f"; + $fontline = `$cmd`; + $report = explode("\n", $fontline); + + foreach ($report as $item) { + $item = trim($item); + list($k, $v) = explode(':', $item, 2); + if ($k == '[head] Units per Em') { + $fontHeight = trim($v); + } + if ($k == '[OS/2] CapHeight') { + $fontCapHeight = trim($v); + } + if ($k == '[OS/2] TypoAscender') { + $ascender = abs(trim($v)); + } + if ($k == '[OS/2] TypoDescender') { + $descender = abs(trim($v)); + } + } + $capHeight = 1; + if (isset($fontCapHeight) && isset($fontHeight)) { + $capHeight = $fontCapHeight / $fontHeight; } + $font = ['family' => $hash, 'capHeight' => $capHeight, 'ascender' => $ascender / $fontHeight, 'descender' => $descender / $fontHeight]; + $this->cssfont[$hash] = $font; } - $this->vdir->copy($dest, 'data/fonts/' . $hash . '.woff'); - $this->cssfont[] = $hash; - return $hash; + return $this->cssfont[$hash]; } public function addJsLib($name, $files) diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index 6ca1f3f22..2c03fbb09 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -612,25 +612,38 @@ class contentLink extends wsHTML5Link public function getAdditionnalContent() { $res = parent::getAdditionnalContent(); - $animation = trim($this->image_rollover); + $variables = self::parseAnimation($this->image_rollover); + + if (isset($variables['type'])) { + $res .= ' data-animation-type="' . $variables['type'] . '" data-animation="' . htmlspecialchars(json_encode($variables), ENT_QUOTES) . '" '; + } + + return $res; + } + + public static function parseAnimation($animation) + { + $animation = trim($animation); + $variables = []; if ($animation != '') { - $variables = []; $lines = CubeIT_Text::splitLines($animation); foreach ($lines as $line) { $e = explode('=', $line); - $variables[trim($e[0])] = trim($e[1]); - } - if (isset($variables['type'])) { - if ($variables['direction'] == 'top') { - $variables['direction'] = 'up'; - } - if ($variables['direction'] == 'bottom') { - $variables['direction'] = 'down'; + $v = trim($e[1]); + // Handle values surronded by quotes + if (preg_match('|^\"([^\"]+)\"$|', $v, $matches)) { + $v = $matches[1]; } - $res .= ' data-animation-type="' . $variables['type'] . '" data-animation="' . htmlspecialchars(json_encode($variables), ENT_QUOTES) . '" '; + $variables[trim($e[0])] = $v; + } + if ($variables['direction'] == 'top') { + $variables['direction'] = 'up'; + } + if ($variables['direction'] == 'bottom') { + $variables['direction'] = 'down'; } } - return $res; + return $variables; } } @@ -1093,12 +1106,17 @@ class textLink extends contentLink { public function getCSS() { - $font = $this->compiler->addFont($this->image); - return 'font-family:' . $font . ';color:' . wsHTML5::colorToCSS($this->extra, 1) . ';'; + $fz = round($this->height * $this->getCssScale() / $font['capHeight'], 2); + return 'line-height:' . $font['capHeight'] . ';font-size:' . $fz . 'px;font-family:' . $font['family'] . ';color:' . wsHTML5::colorToCSS($this->extra, 1) . ';'; + } + public function getHTMLContainerClass() + { + return parent::getHTMLContainerClass() . ' textLink'; } + public function getAdditionnalContent() { $res = parent::getAdditionnalContent();