From 0360a78d4dd43885bc3279e22c66ca826d269a87 Mon Sep 17 00:00:00 2001 From: "michael.danielczok" <michael@pcsg.de> Date: Tue, 22 Dec 2020 13:07:11 +0100 Subject: [PATCH] feat: Children slider reworked. Default template works like before. --- bricks.xml | 10 ++++- locale.xml | 16 +++++++ .../{Slider.css => Slider.OnlyImage.css} | 1 + src/QUI/Bricks/Controls/Children/Slider.php | 43 +++++++++++++------ 4 files changed, 54 insertions(+), 16 deletions(-) rename src/QUI/Bricks/Controls/Children/{Slider.css => Slider.OnlyImage.css} (99%) diff --git a/bricks.xml b/bricks.xml index 7e5f164..288ffbe 100644 --- a/bricks.xml +++ b/bricks.xml @@ -132,13 +132,19 @@ <locale group="quiqqer/bricks" var="brick.control.setting.template"/> <option value="onlyImage" selected="selected"> - <locale group="quiqqer/bricks" var="brick.control.setting.template.onlyImages"/> + <locale group="quiqqer/bricks" + var="brick.control.setting.template.onlyImages"/> </option> <option value="imageAndText" selected="selected"> - <locale group="quiqqer/bricks" var="brick.control.setting.template.onlyImages"/> + <locale group="quiqqer/bricks" + var="brick.control.setting.template.imageAndText"/> </option> </setting> + <setting name="slideHeight" type="number" min="1"> + <locale group="quiqqer/bricks" var="brick.control.setting.slideHeight"/> + </setting> + <setting name="limit" type="number" min="1"> <locale group="quiqqer/bricks" var="brick.control.setting.limit"/> </setting> diff --git a/locale.xml b/locale.xml index 3d88d9d..55aeb8f 100644 --- a/locale.xml +++ b/locale.xml @@ -330,6 +330,22 @@ <de><![CDATA[Seiten hinzufügen]]></de> <en><![CDATA[Add pages]]></en> </locale> + <locale name="brick.control.setting.template"> + <de><![CDATA[Slider Vorlage (template)]]></de> + <en><![CDATA[Slider template]]></en> + </locale> + <locale name="brick.control.setting.template.onlyImages"> + <de><![CDATA[Nur Bild (standard)]]></de> + <en><![CDATA[Only image (default)]]></en> + </locale> + <locale name="brick.control.setting.template.imageAndText"> + <de><![CDATA[Bild, Titel und Beschreibung]]></de> + <en><![CDATA[Image, title and description]]></en> + </locale> + <locale name="brick.control.setting.slideHeight"> + <de><![CDATA[Slider Höhe]]></de> + <en><![CDATA[Slider height]]></en> + </locale> <locale name="brick.control.setting.limit"> <de><![CDATA[Limit]]></de> <en><![CDATA[Limit]]></en> diff --git a/src/QUI/Bricks/Controls/Children/Slider.css b/src/QUI/Bricks/Controls/Children/Slider.OnlyImage.css similarity index 99% rename from src/QUI/Bricks/Controls/Children/Slider.css rename to src/QUI/Bricks/Controls/Children/Slider.OnlyImage.css index ffe9dcc..daa8966 100644 --- a/src/QUI/Bricks/Controls/Children/Slider.css +++ b/src/QUI/Bricks/Controls/Children/Slider.OnlyImage.css @@ -82,6 +82,7 @@ -webkit-transition: all 1s ease; max-height: calc(100% - 2px); width: auto; + max-width: initial; } .quiqqer-bricks-children-slider-child-display img:hover { diff --git a/src/QUI/Bricks/Controls/Children/Slider.php b/src/QUI/Bricks/Controls/Children/Slider.php index 2b164c3..7d0bfe1 100644 --- a/src/QUI/Bricks/Controls/Children/Slider.php +++ b/src/QUI/Bricks/Controls/Children/Slider.php @@ -23,22 +23,18 @@ public function __construct($attributes = []) { // default options $this->setAttributes([ - 'class' => 'quiqqer-bricks-children-slider', - 'nodeName' => 'section', - 'site' => '', - 'order' => false, - 'limit' => false, - 'moreLink' => false, - 'data-qui' => 'package/quiqqer/bricks/bin/Controls/Children/Slider', - 'template' => null, // default -> onlyImage + 'class' => 'quiqqer-bricks-children-slider', + 'nodeName' => 'section', + 'site' => '', + 'order' => false, + 'limit' => false, + 'moreLink' => false, + 'data-qui' => 'package/quiqqer/bricks/bin/Controls/Children/Slider', + 'template' => false, // default -> onlyImage 'data-qui-options-usemobile' => false ]); - $this->addCSSFile( - dirname(__FILE__).'/Slider.css' - ); - parent::__construct($attributes); } @@ -52,7 +48,11 @@ public function getBody() $Engine = QUI::getTemplateManager()->getEngine(); $MoreLink = null; - if (!$this->getAttribute('height')) { + if (!$this->getAttribute('slideHeight')) { + $this->setAttribute('slideHeight', $this->getAttribute('height')); + } + + if (!$this->getAttribute('slideHeight')) { $this->setAttribute('slideHeight', 200); } @@ -64,16 +64,19 @@ public function getBody() } $template = $this->getTemplate(); + $css = $this->getTemplate(); switch ($this->getAttribute('template')) { case 'onlyImage': $template = dirname(__FILE__).'/Slider.OnlyImage.html'; + $css = dirname(__FILE__).'/Slider.OnlyImage.css'; break; case 'imageAndText': $template = dirname(__FILE__).'/Slider.ImageAndText.html'; + $css = dirname(__FILE__).'/Slider.ImageAndText.css'; if (!$this->getAttribute('slideHeight')) { - $this->setAttribute('slideHeight', 400); + $this->setAttribute('slideHeight', 500); } break; } @@ -84,6 +87,8 @@ public function getBody() 'MoreLink' => $MoreLink ]); + $this->addCSSFile($css); + return $Engine->fetch($template); } @@ -97,6 +102,16 @@ protected function getTemplate() return dirname(__FILE__).'/Slider.OnlyImage.html'; } + /** + * Return the control css + * + * @return string + */ + protected function getCSS() + { + return dirname(__FILE__).'/Slider.OnlyImage.css'; + } + /** * Return the children * -- GitLab