From 00cdc67442f8c8bab53ec58593baa3adf705bd74 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 3 Apr 2023 15:12:37 +0200 Subject: [PATCH] wip #5844 @0.5 --- src/Links/ContentLink.php | 54 ++++++++++++++++++++------------------ src/Links/FlipcardLink.php | 30 +++++++++++++++++++++ src/Links/Link.php | 4 +++ 3 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 src/Links/FlipcardLink.php diff --git a/src/Links/ContentLink.php b/src/Links/ContentLink.php index c963200..088f347 100644 --- a/src/Links/ContentLink.php +++ b/src/Links/ContentLink.php @@ -2,44 +2,47 @@ namespace Fluidbook\Tools\Links; -class ContentLink extends Link -{ +class ContentLink extends Link { public $defaultZIndex = 30; + public $allowsAnimation = true; + public $interactive = false; + public $forceTexture = false; - public function getHTMLContainerClass() - { + public function getHTMLContainerClass() { return parent::getHTMLContainerClass() . ' contentLink'; } - public function getAdditionnalContent() - { + public function getAdditionnalContent() { $res = parent::getAdditionnalContent(); - $animations = self::parseAnimations($this->image_rollover); - foreach ($animations as $animation) { - if (isset($animation['blendmode'])) { - $this->blendmode = $animation['blendmode']; - unset($animation['blendmode']); + if ($this->allowsAnimation) { + $animations = self::parseAnimations($this->image_rollover); + foreach ($animations as $animation) { + if (isset($animation['blendmode'])) { + $this->blendmode = $animation['blendmode']; + unset($animation['blendmode']); + } + if (isset($animation['zindex'])) { + $this->zindex = $animation['zindex']; + } + if (isset($animation['addzindex'])) { + $this->addzindex = $animation['addzindex']; + } } - if (isset($animation['zindex'])) { - $this->zindex = $animation['zindex']; + $res .= ' data-animations="' . htmlspecialchars(json_encode($animations), ENT_QUOTES) . '" '; + if ($this->_isHiddenFirst($animations)) { + $res .= ' data-animation-hide '; } - if (isset($animation['addzindex'])) { - $this->addzindex = $animation['addzindex']; + if ($this->_isFinallyHidden($animations)) { + $res .= ' data-animation-hide-on-leave '; } } - $res .= ' data-animations="' . htmlspecialchars(json_encode($animations), ENT_QUOTES) . '" '; - if ($this->_isHiddenFirst($animations)) { - $res .= ' data-animation-hide '; - } - if ($this->_isFinallyHidden($animations)) { - $res .= ' data-animation-hide-on-leave '; + if ($this->forceTexture && $this->getDepth() >= 40) { + $res .= ' data-force-texture="1" '; } - return $res; } - protected function _isFinallyHidden($animations) - { + protected function _isFinallyHidden($animations) { $hiddenAnimations = ['fadeout', 'unmask']; foreach ($animations as $animation) { if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) { @@ -49,8 +52,7 @@ class ContentLink extends Link return false; } - protected function _isHiddenFirst($animations) - { + protected function _isHiddenFirst($animations) { $hiddenAnimations = ['reveal', 'fadein', 'translatefrom']; foreach ($animations as $animation) { if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) { diff --git a/src/Links/FlipcardLink.php b/src/Links/FlipcardLink.php new file mode 100644 index 0000000..b0b0870 --- /dev/null +++ b/src/Links/FlipcardLink.php @@ -0,0 +1,30 @@ +copyExternalFile($this->to); + $this->copyExternalFile($this->alternative); + $res = 'getTooltipAttribute() . '>'; + $res .= '
'; + $res .= '
'; + $res .= '
'; + $res .= '
'; + return $res; + } + + public function getDefaultTooltip() { + return 'click to flip'; + } + + public function getAdditionnalContent() { + $res = parent::getAdditionnalContent(); + $res .= ' data-flipcard="' . ($this->width > $this->height ? 'axis-x' : 'axis-y') . '" '; + return $res; + } +} diff --git a/src/Links/Link.php b/src/Links/Link.php index c88b17c..91bc09b 100644 --- a/src/Links/Link.php +++ b/src/Links/Link.php @@ -73,6 +73,8 @@ class Link { protected $_cssContainer = null; protected $_htmlContainer = null; + public $allowsAnimation = true; + /** * * @var CompilerInterface @@ -217,6 +219,8 @@ class Link { case 39: return new LayerLink($id, $init, $compiler); case 41: + return new FlipcardLink($id, $init, $compiler); + case 42: return new PDFPopupLink($id, $init, $compiler); default: return null; -- 2.39.5