Newer
Older
<?php
/**
* This file contains QUI\Menu\Controls\FloatedNav
*/
namespace QUI\Menu\Controls;
use QUI;
use QUI\Menu\Independent;
/**
* Class WallpaperText
*
* @package quiqqer/menu
*/
class FloatedNav extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = [])
{
// default options
$this->setAttributes([
'class' => 'quiqqer-floatedNavControl',
'menuId' => false,
'posX' => 'right',
// right, left
'forceVerticalCenter' => true,
// if true, container will be centered per JS. pure css way (top: 50%; transform: translateY: (-50%);) causes jumping effect on mobile, when url bar disappears
'size' => 'medium',
// small, medium, large
'design' => 'iconBar',
// iconBar, flat
'animationType' => false,
// false, showAll (show entire control), showOneByOne (show each entry one by one)
'initAnimation' => false,
'animationEasing' => 'easeOutExpo',
// see easing names on https://easings.net/
// 'navInitOpen' => 'always', // always, desktop, never
'showToggleButton' => 'mobile',
// always, mobile, hide,
'showLangSwitch' => false,
]);
parent::__construct($attributes);
$this->setJavaScriptControl('package/quiqqer/menu/bin/Controls/FloatedNav');
);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$LangSwitch = null;
try {
$IndependentMenu = Independent\Handler::getMenu($this->getAttribute('menuId'));
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return '';
}
if (!$IndependentMenu) {
return '';
}

Michael Danielczok
committed
$showToggleButton = true;
switch ($this->getAttribute('showToggleButton')) {

Michael Danielczok
committed
$this->setJavaScriptControlOption('showtogglebutton', 'always');
$this->addCSSClass('quiqqer-floatedNavControl__toggleButton-always');

Michael Danielczok
committed
$this->setJavaScriptControlOption('showtogglebutton', 'mobile');
$this->addCSSClass('quiqqer-floatedNavControl__toggleButton-mobile');

Michael Danielczok
committed
$showToggleButton = false;
break;
}
switch ($this->getAttribute('size')) {
case 'small':
case 'medium':
case 'large':
$size = 'quiqqer-floatedNavControl__size-' . $this->getAttribute('size');
break;
default:
$size = 'quiqqer-floatedNavControl__size-medium';
switch ($this->getAttribute('design')) {
case 'flat':
$design = 'quiqqer-floatedNavControl__design-' . $this->getAttribute('design');
break;
default:
$design = 'quiqqer-floatedNavControl__design-iconsBar';
switch ($this->getAttribute('posX')) {
case 'left':
case 'right':
$posX = 'quiqqer-floatedNavControl__posX-' . $this->getAttribute('posX');
$this->setJavaScriptControlOption('position', $this->getAttribute('posX'));
default:
$posX = 'quiqqer-floatedNavControl__posX-right';
$this->setJavaScriptControlOption('position', 'right');
break;
}
if ($this->getAttribute('showLangSwitch')) {
try {
$LangSwitch = new QUI\Bricks\Controls\LanguageSwitches\Flags([
]);
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
switch ($this->getAttribute('animationType')) {
case 'showAll':
case 'showOneByOne':
$this->setJavaScriptControlOption('animationtype', $this->getAttribute('animationType'));
$this->setJavaScriptControlOption('animationeasing', $this->getAnimationEasingName());
$animation = 'quiqqer-floatedNav__animation-' . $this->getAttribute('animationType');
$initAnimation = 'quiqqer-floatedNavControl__noInitAnimation';
if ($this->getAttribute('initAnimation')) {
$this->setJavaScriptControlOption('initanimation', 1);
$initAnimation = 'quiqqer-floatedNavControl__initAnimation';
}

Michael Danielczok
committed
if ($this->getAttribute('forceVerticalCenter')) {
$this->setJavaScriptControlOption('forceverticalcenter', 1);
}
$this->addCSSClass($initAnimation);
$this->addCSSClass($size);
$this->addCSSClass($design);
$this->addCSSClass($posX);
$children = $IndependentMenu->getChildren();
$Engine->assign([
'this' => $this,
'children' => $children,
'animation' => $animation,
'LangSwitch' => $LangSwitch,

Michael Danielczok
committed
'showToggleButton' => $showToggleButton
return $Engine->fetch(dirname(__FILE__) . '/FloatedNav.html');
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/**
* Get correct easing name for animation
* https://easings.net/
*
* @return false|mixed|string
*/
public function getAnimationEasingName()
{
switch ($this->getAttribute('animationEasing')) {
case 'easeInQuad':
case 'easeInCubic':
case 'easeInQuart':
case 'easeInQuint':
case 'easeInSine':
case 'easeInExpo':
case 'easeInCirc':
case 'easeInBack':
case 'easeOutQuad':
case 'easeOutCubic':
case 'easeOutQuart':
case 'easeOutQuint':
case 'easeOutSine':
case 'easeOutExpo':
case 'easeOutCirc':
case 'easeOutBack':
case 'easeInBounce':
case 'easeInOutQuad':
case 'easeInOutCubic':
case 'easeInOutQuart':
case 'easeInOutQuint':
case 'easeInOutSine':
case 'easeInOutExpo':
case 'easeInOutCirc':
case 'easeInOutBack':
case 'easeInOutBounce':
case 'easeOutBounce':
case 'easeOutInQuad':
case 'easeOutInCubic':
case 'easeOutInQuart':
case 'easeOutInQuint':
case 'easeOutInSine':
case 'easeOutInExpo':
case 'easeOutInCirc':
case 'easeOutInBack':
case 'easeOutInBounce':
return $this->getAttribute('animationEasing');
default:
return 'easeOutExpo';
}
}