'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',
$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'] = '';
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;
}
$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)
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;
}
}
{
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();