From ad32bc3de9492183383397341622211b93d10518 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 2 Mar 2022 12:44:26 +0000 Subject: [PATCH] wip #5138 @1.5 --- inc/ws/Controlleur/class.ws.url.php | 4 +- .../html5/master/class.ws.html5.links.php | 163 +++++++++++------- 2 files changed, 99 insertions(+), 68 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index b069676d0..5d8a1b38b 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -2046,7 +2046,7 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co self::_relay($file, $ok); } - protected function _relay($file, $ok = 'auto') + protected static function _relay($file, $ok = 'auto') { global $core; @@ -2094,7 +2094,7 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co return true; } - public function relayfb($args) + public static function relayfb($args) { global $core; array_shift($args); 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 9f321b594..2aed7f2dd 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -31,6 +31,7 @@ class wsHTML5Link public $infobulle; public $blendmode = "normal"; public $extra; + public $extraraw; public $id; public $rot; public $class; @@ -52,7 +53,8 @@ class wsHTML5Link public $tooltipBackgroundColor = null; public $parallax = 0; public $attachLeft = false; - public $allowsAnimation = false; + public $allowsAnimation = true; + public $forceTexture = false; protected $role = 'button'; @@ -324,15 +326,33 @@ class wsHTML5Link $v = $matches[1]; } $k = trim($e[0]); + if ($normalizeKey) { $k = mb_strtolower($k); } + if ($k === 'animationtype') { + break; + } $res[$k] = $v; } return $res; } + public static function parseAnimationsInExtra($extra) + { + if (!$extra) { + return []; + } + + $e = explode('animationtype=', $extra, 2); + if (count($e) === 1) { + return []; + } + + return self::parseAnimations('type=' . $e[1]); + } + public static function parseAnimations($animations) { $anims = explode('---', $animations); @@ -423,8 +443,10 @@ class wsHTML5Link public function __construct($id, $init, &$compiler) { $this->_init = $init; + $this->extraraw = ''; foreach ($init as $k => $v) { if ($k == 'extra') { + $this->extraraw = $v; if (CubeIT_Util_Json::isJson($v)) { $v = CubeIT_Util_Json::decode($v); } else if (strpos($v, '=') !== false && strpos($v, '&') !== false) { @@ -567,6 +589,57 @@ class wsHTML5Link public function getAdditionnalContent() { $res = ''; + +// if ($this->uid == '831d0b8600') { +// die($this->allowsAnimation . '/' . $this->image_rollover . '/' . $this->extraraw); +// } + + if ($this->allowsAnimation) { + if (stristr($this->image_rollover, 'type=') && $this instanceof contentLink) { + $animations = self::parseAnimations($this->image_rollover); + } else { + $animations = self::parseAnimationsInExtra($this->extraraw); + } + if (count($animations)) { + foreach ($animations as $animation) { + if (isset($animation['blendmode'])) { + $this->blendmode = $animation['blendmode']; + unset($animation['blendmode']); + } + if (isset($animation['zindex'])) { + if ($animation['zindex'] >= 10) { + $this->zindex = $animation['zindex']; + } else { + $this->zindex += $animation['zindex']; + } + } + if (isset($animation['addzindex'])) { + $this->addzindex = $animation['addzindex']; + } + if (isset($animation['parallax'])) { + $this->parallax = $animation['parallax']; + unlink($animation['parallax']); + } + if ($animation['type'] === 'draggable') { + $this->defaultZIndex = 70; + $this->interactive = true; + } + } + + $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" '; + } + + if ($this->role !== '') { $res .= ' role="' . $this->role . '"'; } @@ -588,10 +661,33 @@ class wsHTML5Link $res .= ' data-parallax="' . $this->parallax . '"'; } + return $res; } + protected function _isFinallyHidden($animations) + { + $hiddenAnimations = ['fadeout', 'unmask']; + foreach ($animations as $animation) { + if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) { + return true; + } + } + return false; + } + + protected function _isHiddenFirst($animations) + { + $hiddenAnimations = ['reveal', 'fadein', 'translatefrom']; + foreach ($animations as $animation) { + if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) { + return true; + } + } + return false; + } + public function getClasses() { @@ -1057,71 +1153,7 @@ class contentLink extends wsHTML5Link return $res; } - public function getAdditionnalContent() - { - $res = parent::getAdditionnalContent(); - 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'])) { - if ($animation['zindex'] >= 10) { - $this->zindex = $animation['zindex']; - } else { - $this->zindex += $animation['zindex']; - } - } - if (isset($animation['addzindex'])) { - $this->addzindex = $animation['addzindex']; - } - if (isset($animation['parallax'])) { - $this->parallax = $animation['parallax']; - unlink($animation['parallax']); - } - if ($animation['type'] === 'draggable') { - $this->defaultZIndex = 70; - $this->interactive = true; - } - } - $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) - { - $hiddenAnimations = ['fadeout', 'unmask']; - foreach ($animations as $animation) { - if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) { - return true; - } - } - return false; - } - - protected function _isHiddenFirst($animations) - { - $hiddenAnimations = ['reveal', 'fadein', 'translatefrom']; - foreach ($animations as $animation) { - if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) { - return true; - } - } - return false; - } } class eventOverlayLink extends wsHTML5Link @@ -1799,7 +1831,6 @@ class imageLink extends contentLink public function getBackgroundSize() { - $size = '100%'; $animations = self::parseAnimations($this->image_rollover); foreach ($animations as $animation) { -- 2.39.5