<?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, 'autoControls' => false, ), 'navigation' => array( 'pagination' => array( 'properties' => array( 'numbered' => 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_', ]); if (!$this->getPropertyValue('navigation.pagination.properties.numbered')) { $classes .= ' moto-widget-content_slider-pager-numbered-disabled'; } } if ($this->getPropertyValue('options.autoControls')) { if ($this->getPropertyValue('navigation.auto.properties.visible_on') !== 'mobile-v') { $classes .= ' moto-widget-content_slider-auto-controls-visible-on_' . $this->getPropertyValue('navigation.auto.properties.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); } } 