]> _ Git - fluidbook_tools.git/commitdiff
wip #5844 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 3 Apr 2023 13:12:37 +0000 (15:12 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 3 Apr 2023 13:12:37 +0000 (15:12 +0200)
src/Links/ContentLink.php
src/Links/FlipcardLink.php [new file with mode: 0644]
src/Links/Link.php

index c963200d94df700f3dec126a386ce25541892706..088f347ce1c3b99d4a128425e2a7c631f7911f87 100644 (file)
@@ -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 (file)
index 0000000..b0b0870
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+namespace Fluidbook\Tools\Links;
+
+class FlipcardLink extends ImageLink {
+    public $interactive = true;
+    public $defaultZIndex = 70;
+    public $forceTexture = true;
+
+    public function getHTMLContent() {
+        $this->copyExternalFile($this->to);
+        $this->copyExternalFile($this->alternative);
+        $res = '<a href="#" ' . $this->getTooltipAttribute() . '></a>';
+        $res .= '<div class="flipcard">';
+        $res .= '<div class="front"><img src="' . self::getUniversalLocation($this->to) . '"></div>';
+        $res .= '<div class="back"><img src="' . self::getUniversalLocation($this->alternative) . '"></div>';
+        $res .= '</div>';
+        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;
+    }
+}
index c88b17c72a58471ef2a2601b899e6272bd45608c..91bc09b3248ae1fc335d40f7b64f24563193904c 100644 (file)
@@ -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;