<?php
namespace Website\Widgets\ContentSlider; use Moto; class SliderWidget extends Moto\System\Widgets\AbstractContainerWidget { protected $_name = 'content_slider'; protected static $_defaultProperties = array( 'preset' => 'default', 'visible_on' => 'mobile-v', 'justify' => false, 'spacing' => array( 'top' => 'auto', 'right' => 'auto', 'bottom' => 'auto', 'left' => 'auto', ), 'widthFixed' => false, 'gutter' => true, 'preferences' => array( 'startAnimation' => 'onArriving', ), 'options' => array( 'auto' => true, 'pause' => 10, 'mode' => 'horizontal', 'controls' => true, 'pager' => true, ), ); protected $_templateType = 'templates'; protected $_templatePath = '@websiteWidgets/content_slider/templates/default.twig.html'; protected $_widgetId = true; public function getControlClasses() { $classes = ''; if ($this->getPropertyValue('options.controls') && $this->getPropertyValue('navigation.arrows.properties.visible_on') !== 'mobile-v') { $classes .= ' ' . Moto\System\Widgets\Helper::getCssClassesVisibleOn($this->getPropertyValue('navigation.arrows.properties.visible_on'), [ 'prefix' => 'moto-widget-content_slider-controls-visible-on_', ]); } if ($this->getPropertyValue('options.pager') && $this->getPropertyValue('navigation.pagination.properties.visible_on') !== 'mobile-v') { $classes .= ' ' . Moto\System\Widgets\Helper::getCssClassesVisibleOn($this->getPropertyValue('navigation.pagination.properties.visible_on'), [ 'prefix' => 'moto-widget-content_slider-pager-visible-on_', ]); } $classes = trim($classes); return $classes; } public function getCssClasses() { $classes = 'moto-preset-' . $this->getPropertyValue('preset'); $classes .= ' ' . $this->getSpacing('classes'); $classes .= ' ' . $this->getVisibleOn('classes'); $classes .= ' ' . $this->getAlignClass(); $classes .= ' ' . $this->getControlClasses(); if (!$this->isPreviewMode()) { $classes .= ' moto-widget__state_loading'; } return $classes; } public function exportFrontendSettings() { $preferences = (array) $this->getPropertyValue('preferences'); $options = (array) $this->getPropertyValue('options'); $options['pause'] = (int) Moto\Util::getValue($options, 'pause') * 1000; $settings = [ 'preferences' => $preferences, 'options' => $options, ]; return json_encode((object) $settings); } public function beforeRendering() { Moto\Website\Settings::disableLazyLoadingByWidget($this); } public function afterRendering() { Moto\Website\Settings::resetDisablingLazyLoadingByWidget($this); } } 