first
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget;
|
||||
|
||||
|
||||
use Nextend\Framework\Data\Data;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Pattern\GetAssetsPathTrait;
|
||||
use Nextend\SmartSlider3\BackupSlider\ExportSlider;
|
||||
use Nextend\SmartSlider3\BackupSlider\ImportSlider;
|
||||
use Nextend\SmartSlider3\Widget\Group\AbstractWidgetGroup;
|
||||
|
||||
abstract class AbstractWidget {
|
||||
|
||||
use GetAssetsPathTrait;
|
||||
|
||||
protected $name;
|
||||
|
||||
protected $key;
|
||||
|
||||
protected $defaults = array();
|
||||
|
||||
/**
|
||||
* AbstractWidget constructor.
|
||||
*
|
||||
* @param AbstractWidgetGroup $widgetGroup
|
||||
* @param string $name
|
||||
* @param array $defaults
|
||||
*/
|
||||
public function __construct($widgetGroup, $name, $defaults = array()) {
|
||||
|
||||
$this->name = $name;
|
||||
|
||||
$this->defaults = array_merge($this->defaults, $defaults);
|
||||
|
||||
$widgetGroup->addWidget($name, $this);
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getSubFormImagePath() {
|
||||
return self::getAssetsPath() . '/' . $this->name . '.png';
|
||||
}
|
||||
|
||||
public function getDefaults() {
|
||||
return $this->defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SliderWidget $sliderWidget
|
||||
*
|
||||
* @return AbstractWidgetFrontend
|
||||
*/
|
||||
public function createFrontend($sliderWidget, $params) {
|
||||
$className = static::class . 'Frontend';
|
||||
|
||||
$params->fillDefault($this->getDefaults());
|
||||
|
||||
return new $className($sliderWidget, $this, $params);
|
||||
}
|
||||
|
||||
public function getKey() {
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExportSlider $export
|
||||
* @param Data $params
|
||||
*/
|
||||
public function prepareExport($export, $params) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ImportSlider $import
|
||||
* @param Data $params
|
||||
*/
|
||||
public function prepareImport($import, $params) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*/
|
||||
abstract public function renderFields($container);
|
||||
}
|
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget;
|
||||
|
||||
use Nextend\Framework\Data\Data;
|
||||
use Nextend\Framework\Pattern\GetAssetsPathTrait;
|
||||
use Nextend\SmartSlider3\Slider\Slider;
|
||||
|
||||
abstract class AbstractWidgetFrontend {
|
||||
|
||||
use GetAssetsPathTrait;
|
||||
|
||||
/** @var SliderWidget */
|
||||
protected $sliderWidget;
|
||||
|
||||
/**
|
||||
* @var Slider
|
||||
*/
|
||||
protected $slider;
|
||||
|
||||
/** @var AbstractWidget */
|
||||
protected $widget;
|
||||
|
||||
protected $key;
|
||||
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $params;
|
||||
|
||||
/**
|
||||
* AbstractWidgetFrontend constructor.
|
||||
*
|
||||
* @param SliderWidget $sliderWidget
|
||||
* @param AbstractWidget $widget
|
||||
*/
|
||||
public function __construct($sliderWidget, $widget, $params) {
|
||||
$this->sliderWidget = $sliderWidget;
|
||||
$this->slider = $sliderWidget->slider;
|
||||
$this->widget = $widget;
|
||||
|
||||
$this->params = $params;
|
||||
|
||||
$this->key = $widget->getKey();
|
||||
}
|
||||
|
||||
protected function addToPlacement($key, $renderCallback) {
|
||||
|
||||
$params = $this->params;
|
||||
|
||||
if ($params->get($key . 'mode') == 'simple') {
|
||||
|
||||
$area = intval($params->get($key . 'area'));
|
||||
$stack = intval($params->get($key . 'stack', 1));
|
||||
|
||||
$this->sliderWidget->addToSimplePlacement($renderCallback, $this->translateArea($area), $stack, $params->get($key . 'offset', 0));
|
||||
} else {
|
||||
$horizontalSide = $params->get($key . 'horizontal', 'left');
|
||||
$horizontalPosition = $params->get($key . 'horizontal-position', 0);
|
||||
$horizontalUnit = $params->get($key . 'horizontal-unit', 'px');
|
||||
|
||||
$verticalSide = $params->get($key . 'vertical', 'top');
|
||||
$verticalPosition = $params->get($key . 'vertical-position', 0);
|
||||
$verticalUnit = $params->get($key . 'vertical-unit', 'px');
|
||||
|
||||
$this->sliderWidget->addToAdvancedPlacement($renderCallback, $horizontalSide, $horizontalPosition, $horizontalUnit, $verticalSide, $verticalPosition, $verticalUnit);
|
||||
}
|
||||
}
|
||||
|
||||
protected function translateArea($area) {
|
||||
static $areas = array(
|
||||
1 => 'above',
|
||||
2 => 'absolute-left-top',
|
||||
3 => 'absolute-center-top',
|
||||
4 => 'absolute-right-top',
|
||||
5 => 'absolute-left',
|
||||
6 => 'absolute-left-center',
|
||||
7 => 'absolute-right-center',
|
||||
8 => 'absolute-right',
|
||||
9 => 'absolute-left-bottom',
|
||||
10 => 'absolute-center-bottom',
|
||||
11 => 'absolute-right-bottom',
|
||||
12 => 'below',
|
||||
);
|
||||
|
||||
return $areas[$area];
|
||||
}
|
||||
|
||||
public function getDefaults() {
|
||||
return $this->widget->getDefaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Data $params
|
||||
* @param string $key
|
||||
* @param integer $showOnMobileDefault
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getDisplayAttributes($params, $key, $showOnMobileDefault = 0) {
|
||||
|
||||
$attributes = array(
|
||||
'class' => 'n2-ss-widget'
|
||||
);
|
||||
|
||||
if (!$params->get($key . 'display-desktopportrait', 1)) {
|
||||
$attributes['data-hide-desktopportrait'] = 1;
|
||||
}
|
||||
|
||||
if (!$params->get($key . 'display-tabletportrait', 1)) {
|
||||
$attributes['data-hide-tabletportrait'] = 1;
|
||||
}
|
||||
|
||||
if (!$params->get($key . 'display-mobileportrait', $showOnMobileDefault)) {
|
||||
$attributes['data-hide-mobileportrait'] = 1;
|
||||
}
|
||||
|
||||
if ($params->get($key . 'display-hover', 0)) {
|
||||
$attributes['class'] .= ' n2-ss-widget-display-hover';
|
||||
}
|
||||
|
||||
|
||||
$excludeSlides = $params->get($key . 'exclude-slides', '');
|
||||
if (!empty($excludeSlides)) {
|
||||
$attributes['data-exclude-slides'] = $excludeSlides;
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
public static function getOrientationByPosition($mode, $area, $set = 'auto', $default = 'horizontal') {
|
||||
if ($mode == 'advanced') {
|
||||
if ($set == 'auto') {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $set;
|
||||
}
|
||||
if ($set != 'auto') {
|
||||
return $set;
|
||||
}
|
||||
switch ($area) {
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
return 'vertical';
|
||||
break;
|
||||
}
|
||||
|
||||
return 'horizontal';
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Arrow;
|
||||
|
||||
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidget;
|
||||
|
||||
abstract class AbstractWidgetArrow extends AbstractWidget {
|
||||
|
||||
protected $key = 'widget-arrow-';
|
||||
|
||||
}
|
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Arrow\ArrowImage;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Grouping;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Radio\ImageListFromFolder;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
use Nextend\Framework\Form\Element\Style;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Form\Element\Text\Color;
|
||||
use Nextend\Framework\Form\Element\Text\FieldImage;
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetRow;
|
||||
use Nextend\SmartSlider3\Form\Element\Group\WidgetPosition;
|
||||
use Nextend\SmartSlider3\Widget\Arrow\AbstractWidgetArrow;
|
||||
|
||||
class ArrowImage extends AbstractWidgetArrow {
|
||||
|
||||
protected $defaults = array(
|
||||
'widget-arrow-desktop-image-width' => 32,
|
||||
'widget-arrow-tablet-image-width' => 32,
|
||||
'widget-arrow-mobile-image-width' => 16,
|
||||
'widget-arrow-previous-image' => '',
|
||||
'widget-arrow-previous' => '$ss$/plugins/widgetarrow/image/image/previous/normal.svg',
|
||||
'widget-arrow-previous-color' => 'ffffffcc',
|
||||
'widget-arrow-previous-hover' => 0,
|
||||
'widget-arrow-previous-hover-color' => 'ffffffcc',
|
||||
'widget-arrow-style' => '{"data":[{"backgroundcolor":"000000ab","padding":"20|*|10|*|20|*|10|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"5","extra":""},{"backgroundcolor":"000000cf"}]}',
|
||||
'widget-arrow-previous-position-mode' => 'simple',
|
||||
'widget-arrow-previous-position-area' => 6,
|
||||
'widget-arrow-previous-position-offset' => 15,
|
||||
'widget-arrow-next-position-mode' => 'simple',
|
||||
'widget-arrow-next-position-area' => 7,
|
||||
'widget-arrow-next-position-offset' => 15,
|
||||
'widget-arrow-animation' => 'fade',
|
||||
'widget-arrow-mirror' => 1,
|
||||
'widget-arrow-next-image' => '',
|
||||
'widget-arrow-next' => '$ss$/plugins/widgetarrow/image/image/next/normal.svg',
|
||||
'widget-arrow-next-color' => 'ffffffcc',
|
||||
'widget-arrow-next-hover' => 0,
|
||||
'widget-arrow-next-hover-color' => 'ffffffcc',
|
||||
'widget-arrow-previous-alt' => 'previous arrow',
|
||||
'widget-arrow-next-alt' => 'next arrow',
|
||||
'widget-arrow-base64' => 1
|
||||
);
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$rowPrevious = new FieldsetRow($container, 'widget-arrow-image-row-previous');
|
||||
|
||||
$fieldPrevious = new ImageListFromFolder($rowPrevious, 'widget-arrow-previous', n2_x('Previous', 'Arrow direction'), '', array(
|
||||
'folder' => self::getAssetsPath() . '/previous/'
|
||||
));
|
||||
$fieldPrevious->setHasDisabled(false);
|
||||
|
||||
|
||||
$groupingPreviousColorContainer = new Grouping($rowPrevious, 'widget-arrow-image-row-icon-grouping-previous-color-container');
|
||||
$groupingPreviousColor = new Grouping($groupingPreviousColorContainer, 'widget-arrow-image-row-icon-grouping-previous-color');
|
||||
new Color($groupingPreviousColor, 'widget-arrow-previous-color', n2_('Color'), '', array(
|
||||
'alpha' => true
|
||||
));
|
||||
new OnOff($groupingPreviousColor, 'widget-arrow-previous-hover', n2_('Hover'), 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'sliderwidget-arrow-previous-hover-color'
|
||||
)
|
||||
));
|
||||
new Color($groupingPreviousColor, 'widget-arrow-previous-hover-color', n2_('Hover color'), '', array(
|
||||
'alpha' => true
|
||||
));
|
||||
|
||||
$row2 = new FieldsetRow($container, 'widget-arrow-image-row-2');
|
||||
|
||||
new Style($row2, 'widget-arrow-style', n2_('Arrow'), '', array(
|
||||
'mode' => 'button',
|
||||
'preview' => 'SmartSliderAdminWidgetArrowImage',
|
||||
));
|
||||
|
||||
new WidgetPosition($row2, 'widget-arrow-previous-position', n2_('Previous position'));
|
||||
new WidgetPosition($row2, 'widget-arrow-next-position', n2_('Next position'));
|
||||
|
||||
$row3 = new FieldsetRow($container, 'widget-arrow-image-row-3');
|
||||
|
||||
new Text($row3, 'widget-arrow-previous-alt', n2_('Previous alt tag'), 'previous arrow');
|
||||
new Text($row3, 'widget-arrow-next-alt', n2_('Next alt tag'), 'next arrow');
|
||||
new OnOff($row3, 'widget-arrow-base64', n2_('Base64'), 1, array(
|
||||
'tipLabel' => n2_('Base64'),
|
||||
'tipDescription' => n2_('Base64 encoded arrow images are loading faster and they are colorable. But optimization plugins often have errors in their codes related to them, so if your arrow won\'t load, turn this option off.'),
|
||||
'tipLink' => 'https://smartslider.helpscoutdocs.com/article/1782-arrow#base64',
|
||||
'relatedFieldsOn' => array(
|
||||
'sliderwidget-arrow-image-row-icon-grouping-previous-color',
|
||||
'sliderwidget-arrow-image-row-icon-grouping-next-color'
|
||||
)
|
||||
));
|
||||
|
||||
$row4 = new FieldsetRow($container, 'widget-arrow-image-row-4');
|
||||
|
||||
new Text\Number($row4, 'widget-arrow-desktop-image-width', n2_('Image width - Desktop'), '', array(
|
||||
'wide' => 4,
|
||||
'unit' => 'px'
|
||||
));
|
||||
|
||||
new Text\Number($row4, 'widget-arrow-tablet-image-width', n2_('Image width - Tablet'), '', array(
|
||||
'wide' => 4,
|
||||
'unit' => 'px'
|
||||
));
|
||||
|
||||
new Text\Number($row4, 'widget-arrow-mobile-image-width', n2_('Image width - Mobile'), '', array(
|
||||
'wide' => 4,
|
||||
'unit' => 'px'
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function prepareExport($export, $params) {
|
||||
$export->addImage($params->get($this->key . 'previous-image', ''));
|
||||
$export->addImage($params->get($this->key . 'next-image', ''));
|
||||
|
||||
$export->addVisual($params->get($this->key . 'style'));
|
||||
}
|
||||
|
||||
public function prepareImport($import, $params) {
|
||||
|
||||
$params->set($this->key . 'previous-image', $import->fixImage($params->get($this->key . 'previous-image', '')));
|
||||
$params->set($this->key . 'next-image', $import->fixImage($params->get($this->key . 'next-image', '')));
|
||||
|
||||
$params->set($this->key . 'style', $import->fixSection($params->get($this->key . 'style', '')));
|
||||
}
|
||||
}
|
@@ -0,0 +1,302 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Arrow\ArrowImage;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\FastImageSize\FastImageSize;
|
||||
use Nextend\Framework\Filesystem\Filesystem;
|
||||
use Nextend\Framework\Misc\Base64;
|
||||
use Nextend\Framework\Parser\Color;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
use Nextend\Framework\View\Html;
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidgetFrontend;
|
||||
|
||||
class ArrowImageFrontend extends AbstractWidgetFrontend {
|
||||
|
||||
protected $rendered = false;
|
||||
|
||||
protected $previousArguments;
|
||||
protected $nextArguments;
|
||||
|
||||
public function __construct($sliderWidget, $widget, $params) {
|
||||
|
||||
parent::__construct($sliderWidget, $widget, $params);
|
||||
|
||||
|
||||
if ($this->isRenderable('previous')) {
|
||||
$this->addToPlacement($this->key . 'previous-position-', array(
|
||||
$this,
|
||||
'renderPrevious'
|
||||
));
|
||||
}
|
||||
|
||||
if ($this->isRenderable('next')) {
|
||||
$this->addToPlacement($this->key . 'next-position-', array(
|
||||
$this,
|
||||
'renderNext'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private function isRenderable($side) {
|
||||
$arrow = $this->params->get($this->key . $side . '-image');
|
||||
if (empty($arrow)) {
|
||||
$arrow = $this->params->get($this->key . $side);
|
||||
if ($arrow == -1) {
|
||||
$arrow = null;
|
||||
}
|
||||
}
|
||||
|
||||
return !!$arrow;
|
||||
}
|
||||
|
||||
public function renderPrevious($attributes = array()) {
|
||||
|
||||
$this->render();
|
||||
|
||||
if ($this->previousArguments) {
|
||||
|
||||
array_unshift($this->previousArguments, $attributes);
|
||||
|
||||
return call_user_func_array(array(
|
||||
$this,
|
||||
'getHTML'
|
||||
), $this->previousArguments);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function renderNext($attributes = array()) {
|
||||
|
||||
$this->render();
|
||||
|
||||
if ($this->nextArguments) {
|
||||
|
||||
array_unshift($this->nextArguments, $attributes);
|
||||
|
||||
return call_user_func_array(array(
|
||||
$this,
|
||||
'getHTML'
|
||||
), $this->nextArguments);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
private function render() {
|
||||
|
||||
if ($this->rendered) return;
|
||||
|
||||
$this->rendered = true;
|
||||
|
||||
$slider = $this->slider;
|
||||
$id = $this->slider->elementId;
|
||||
$params = $this->params;
|
||||
|
||||
if ($slider->getSlidesCount() <= 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$previousImage = $params->get($this->key . 'previous-image');
|
||||
$previousValue = $params->get($this->key . 'previous');
|
||||
$previousColor = $params->get($this->key . 'previous-color');
|
||||
$previousHover = $params->get($this->key . 'previous-hover');
|
||||
$previousHoverColor = $params->get($this->key . 'previous-hover-color');
|
||||
|
||||
if (empty($previousImage)) {
|
||||
|
||||
if ($previousValue == -1) {
|
||||
$previous = false;
|
||||
} else {
|
||||
$previous = ResourceTranslator::pathToResource(self::getAssetsPath() . '/previous/' . basename($previousValue));
|
||||
}
|
||||
} else {
|
||||
$previous = $previousImage;
|
||||
}
|
||||
|
||||
if ($params->get($this->key . 'mirror')) {
|
||||
$nextColor = $previousColor;
|
||||
$nextHover = $previousHover;
|
||||
$nextHoverColor = $previousHoverColor;
|
||||
|
||||
if (empty($previousImage)) {
|
||||
if ($previousValue == -1) {
|
||||
$next = false;
|
||||
} else {
|
||||
$next = ResourceTranslator::pathToResource(self::getAssetsPath() . '/next/' . basename($previousValue));
|
||||
}
|
||||
} else {
|
||||
$next = $previousImage;
|
||||
$slider->addCSS('#' . $id . '-arrow-next' . '{transform: rotate(180deg);}');
|
||||
}
|
||||
} else {
|
||||
$next = $params->get($this->key . 'next-image');
|
||||
$nextColor = $params->get($this->key . 'next-color');
|
||||
$nextHover = $params->get($this->key . 'next-hover');
|
||||
$nextHoverColor = $params->get($this->key . 'next-hover-color');
|
||||
|
||||
if (empty($next)) {
|
||||
$nextValue = $params->get($this->key . 'next');
|
||||
if ($nextValue == -1) {
|
||||
$next = false;
|
||||
} else {
|
||||
$next = ResourceTranslator::pathToResource(self::getAssetsPath() . '/next/' . basename($nextValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($previous || $next) {
|
||||
|
||||
$slider->addLess(self::getAssetsPath() . '/style.n2less', array(
|
||||
"sliderid" => $slider->elementId
|
||||
));
|
||||
|
||||
|
||||
Js::addStaticGroup(self::getAssetsPath() . '/dist/w-arrow-image.min.js', 'w-arrow-image');
|
||||
|
||||
$displayAttributes = $this->getDisplayAttributes($params, $this->key);
|
||||
|
||||
$animation = $params->get($this->key . 'animation');
|
||||
|
||||
if ($animation == 'none' || $animation == 'fade') {
|
||||
$styleClass = $slider->addStyle($params->get($this->key . 'style'), 'heading');
|
||||
} else {
|
||||
$styleClass = $slider->addStyle($params->get($this->key . 'style'), 'heading-active');
|
||||
}
|
||||
|
||||
if ($previous) {
|
||||
$this->previousArguments = array(
|
||||
$id,
|
||||
$animation,
|
||||
'previous',
|
||||
$previous,
|
||||
$displayAttributes,
|
||||
$styleClass,
|
||||
$previousColor,
|
||||
$previousHover,
|
||||
$previousHoverColor
|
||||
);
|
||||
}
|
||||
|
||||
if ($next) {
|
||||
$this->nextArguments = array(
|
||||
$id,
|
||||
$animation,
|
||||
'next',
|
||||
$next,
|
||||
$displayAttributes,
|
||||
$styleClass,
|
||||
$nextColor,
|
||||
$nextHover,
|
||||
$nextHoverColor
|
||||
);
|
||||
}
|
||||
|
||||
$desktopWidth = $params->get('widget-arrow-desktop-image-width');
|
||||
$tabletWidth = $params->get('widget-arrow-tablet-image-width');
|
||||
$mobileWidth = $params->get('widget-arrow-mobile-image-width');
|
||||
|
||||
$slider->addDeviceCSS('all', 'div#' . $id . ' .nextend-arrow img{width: ' . $desktopWidth . 'px}');
|
||||
if ($tabletWidth != $desktopWidth) {
|
||||
$slider->addDeviceCSS('tabletportrait', 'div#' . $id . ' .nextend-arrow img{width: ' . $tabletWidth . 'px}');
|
||||
$slider->addDeviceCSS('tabletlandscape', 'div#' . $id . ' .nextend-arrow img{width: ' . $tabletWidth . 'px}');
|
||||
}
|
||||
if ($mobileWidth != $desktopWidth) {
|
||||
$slider->addDeviceCSS('mobileportrait', 'div#' . $id . ' .nextend-arrow img{width: ' . $mobileWidth . 'px}');
|
||||
$slider->addDeviceCSS('mobilelandscape', 'div#' . $id . ' .nextend-arrow img{width: ' . $mobileWidth . 'px}');
|
||||
}
|
||||
|
||||
$slider->features->addInitCallback('new _N2.SmartSliderWidgetArrowImage(this);');
|
||||
$slider->sliderType->addJSDependency('SmartSliderWidgetArrowImage');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $attributes
|
||||
* @param string $id
|
||||
* @param string $animation
|
||||
* @param string $side
|
||||
* @param string $imageRaw
|
||||
* @param string $displayAttributes
|
||||
* @param string $styleClass
|
||||
* @param string $color
|
||||
* @param int $hover
|
||||
* @param string $hoverColor
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getHTML($attributes, $id, $animation, $side, $imageRaw, $displayAttributes, $styleClass, $color = 'ffffffcc', $hover = 0, $hoverColor = 'ffffffcc') {
|
||||
|
||||
$imageHover = null;
|
||||
|
||||
$ext = pathinfo($imageRaw, PATHINFO_EXTENSION);
|
||||
|
||||
/**
|
||||
* We can not colorize SVGs when base64 disabled.
|
||||
*/
|
||||
if ($ext == 'svg' && ResourceTranslator::isResource($imageRaw) && $this->params->get($this->key . 'base64', 1)) {
|
||||
|
||||
list($color, $opacity) = Color::colorToSVG($color);
|
||||
$content = Filesystem::readFile(ResourceTranslator::toPath($imageRaw));
|
||||
$image = 'data:image/svg+xml;base64,' . Base64::encode(str_replace(array(
|
||||
'fill="#FFF"',
|
||||
'opacity="1"'
|
||||
), array(
|
||||
'fill="#' . $color . '"',
|
||||
'opacity="' . $opacity . '"'
|
||||
), $content));
|
||||
|
||||
if ($hover) {
|
||||
list($color, $opacity) = Color::colorToSVG($hoverColor);
|
||||
$imageHover = 'data:image/svg+xml;base64,' . Base64::encode(str_replace(array(
|
||||
'fill="#FFF"',
|
||||
'opacity="1"'
|
||||
), array(
|
||||
'fill="#' . $color . '"',
|
||||
'opacity="' . $opacity . '"'
|
||||
), $content));
|
||||
}
|
||||
} else {
|
||||
$image = ResourceTranslator::toUrl($imageRaw);
|
||||
}
|
||||
|
||||
$alt = $this->params->get($this->key . $side . '-alt', $side . ' arrow');
|
||||
|
||||
|
||||
$sizeAttributes = array();
|
||||
FastImageSize::initAttributes($imageRaw, $sizeAttributes);
|
||||
|
||||
if ($imageHover === null) {
|
||||
$image = Html::image($image, $alt, $sizeAttributes + Html::addExcludeLazyLoadAttributes());
|
||||
} else {
|
||||
$image = Html::image($image, $alt, $sizeAttributes + Html::addExcludeLazyLoadAttributes(array(
|
||||
'class' => 'n2-arrow-normal-img'
|
||||
))) . Html::image($imageHover, $alt, $sizeAttributes + Html::addExcludeLazyLoadAttributes(array(
|
||||
'class' => 'n2-arrow-hover-img'
|
||||
)));
|
||||
}
|
||||
|
||||
if ($animation == 'none' || $animation == 'fade') {
|
||||
return Html::tag('div', Html::mergeAttributes($attributes, $displayAttributes, array(
|
||||
'id' => $id . '-arrow-' . $side,
|
||||
'class' => $styleClass . 'nextend-arrow n2-ow-all nextend-arrow-' . $side . ' nextend-arrow-animated-' . $animation,
|
||||
'role' => 'button',
|
||||
'aria-label' => $alt,
|
||||
'tabindex' => '0'
|
||||
)), $image);
|
||||
}
|
||||
|
||||
|
||||
return Html::tag('div', Html::mergeAttributes($attributes, $displayAttributes, array(
|
||||
'id' => $id . '-arrow-' . $side,
|
||||
'class' => 'nextend-arrow nextend-arrow-animated n2-ow-all nextend-arrow-animated-' . $animation . ' nextend-arrow-' . $side,
|
||||
'role' => 'button',
|
||||
'aria-label' => $alt,
|
||||
'tabindex' => '0'
|
||||
)), Html::tag('div', array(
|
||||
'class' => $styleClass
|
||||
), $image) . Html::tag('div', array(
|
||||
'class' => $styleClass . ' n2-active'
|
||||
), $image));
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Autoplay;
|
||||
|
||||
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidget;
|
||||
|
||||
abstract class AbstractWidgetAutoplay extends AbstractWidget {
|
||||
|
||||
protected $key = 'widget-autoplay-';
|
||||
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Autoplay\AutoplayImage;
|
||||
|
||||
use Nextend\Framework\Form\Element\Grouping;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Radio\ImageListFromFolder;
|
||||
use Nextend\Framework\Form\Element\Style;
|
||||
use Nextend\Framework\Form\Element\Text\Color;
|
||||
use Nextend\Framework\Form\Element\Text\FieldImage;
|
||||
use Nextend\Framework\Form\Element\Text\Number;
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetRow;
|
||||
use Nextend\SmartSlider3\Form\Element\Group\WidgetPosition;
|
||||
use Nextend\SmartSlider3\Widget\Autoplay\AbstractWidgetAutoplay;
|
||||
|
||||
class AutoplayImage extends AbstractWidgetAutoplay {
|
||||
|
||||
protected $defaults = array(
|
||||
'widget-autoplay-desktop-image-width' => 16,
|
||||
'widget-autoplay-tablet-image-width' => 16,
|
||||
'widget-autoplay-mobile-image-width' => 8,
|
||||
'widget-autoplay-play-image' => '',
|
||||
'widget-autoplay-play-color' => 'ffffffcc',
|
||||
'widget-autoplay-play' => '$ss$/plugins/widgetautoplay/image/image/play/small-light.svg',
|
||||
'widget-autoplay-style' => '{"data":[{"backgroundcolor":"000000ab","padding":"10|*|10|*|10|*|10|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"3","extra":""},{"backgroundcolor":"000000ab"}]}',
|
||||
'widget-autoplay-position-mode' => 'simple',
|
||||
'widget-autoplay-position-area' => 4,
|
||||
'widget-autoplay-position-offset' => 15,
|
||||
'widget-autoplay-mirror' => 1,
|
||||
'widget-autoplay-pause-image' => '',
|
||||
'widget-autoplay-pause-color' => 'ffffffcc',
|
||||
'widget-autoplay-pause' => '$ss$/plugins/widgetautoplay/image/image/pause/small-light.svg'
|
||||
);
|
||||
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$rowIcon = new FieldsetRow($container, 'widget-autoplay-image-row-icon');
|
||||
|
||||
$fieldPlay = new ImageListFromFolder($rowIcon, 'widget-autoplay-play', n2_('Play'), '', array(
|
||||
'folder' => self::getAssetsPath() . '/play/',
|
||||
'hasDisabled' => false
|
||||
));
|
||||
|
||||
new Color($rowIcon, 'widget-autoplay-play-color', n2_('Color'), '', array(
|
||||
'alpha' => true
|
||||
));
|
||||
|
||||
new Style($rowIcon, 'widget-autoplay-style', n2_('Style'), '', array(
|
||||
'mode' => 'button',
|
||||
'preview' => 'SmartSliderAdminWidgetAutoplayImage'
|
||||
));
|
||||
|
||||
$row2 = new FieldsetRow($container, 'widget-autoplay-image-row-2');
|
||||
|
||||
new Number($row2, 'widget-autoplay-desktop-image-width', n2_('Image width - Desktop'), '', array(
|
||||
'wide' => 4,
|
||||
'unit' => 'px'
|
||||
));
|
||||
|
||||
new Number($row2, 'widget-autoplay-tablet-image-width', n2_('Image width - Tablet'), '', array(
|
||||
'wide' => 4,
|
||||
'unit' => 'px'
|
||||
));
|
||||
|
||||
new Number($row2, 'widget-autoplay-mobile-image-width', n2_('Image width - Mobile'), '', array(
|
||||
'wide' => 4,
|
||||
'unit' => 'px'
|
||||
));
|
||||
|
||||
new WidgetPosition($row2, 'widget-autoplay-position', n2_('Position'));
|
||||
|
||||
}
|
||||
|
||||
public function prepareExport($export, $params) {
|
||||
$export->addImage($params->get($this->key . 'play-image', ''));
|
||||
$export->addImage($params->get($this->key . 'pause-image', ''));
|
||||
|
||||
$export->addVisual($params->get($this->key . 'style'));
|
||||
}
|
||||
|
||||
public function prepareImport($import, $params) {
|
||||
|
||||
$params->set($this->key . 'play-image', $import->fixImage($params->get($this->key . 'play-image', '')));
|
||||
$params->set($this->key . 'pause-image', $import->fixImage($params->get($this->key . 'pause-image', '')));
|
||||
|
||||
$params->set($this->key . 'style', $import->fixSection($params->get($this->key . 'style', '')));
|
||||
}
|
||||
}
|
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Autoplay\AutoplayImage;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Cast;
|
||||
use Nextend\Framework\FastImageSize\FastImageSize;
|
||||
use Nextend\Framework\Filesystem\Filesystem;
|
||||
use Nextend\Framework\Misc\Base64;
|
||||
use Nextend\Framework\Parser\Color;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
use Nextend\Framework\View\Html;
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidgetFrontend;
|
||||
|
||||
class AutoplayImageFrontend extends AbstractWidgetFrontend {
|
||||
|
||||
public function __construct($sliderWidget, $widget, $params) {
|
||||
|
||||
parent::__construct($sliderWidget, $widget, $params);
|
||||
|
||||
$this->addToPlacement($this->key . 'position-', array(
|
||||
$this,
|
||||
'render'
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function render($attributes = array()) {
|
||||
|
||||
$slider = $this->slider;
|
||||
$id = $this->slider->elementId;
|
||||
$params = $this->params;
|
||||
|
||||
if (!$params->get('autoplay', 0)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$sizeAttributes = array();
|
||||
|
||||
$html = '';
|
||||
|
||||
$playImage = $params->get($this->key . 'play-image');
|
||||
$playValue = $params->get($this->key . 'play');
|
||||
$playColor = $params->get($this->key . 'play-color');
|
||||
|
||||
if (empty($playImage)) {
|
||||
|
||||
if ($playValue == -1) {
|
||||
$play = null;
|
||||
} else {
|
||||
$play = ResourceTranslator::pathToResource(self::getAssetsPath() . '/play/' . basename($playValue));
|
||||
}
|
||||
} else {
|
||||
$play = $playImage;
|
||||
}
|
||||
|
||||
if ($params->get($this->key . 'mirror')) {
|
||||
$pauseColor = $playColor;
|
||||
|
||||
if (!empty($playImage)) {
|
||||
$pause = $playImage;
|
||||
} else {
|
||||
$pause = ResourceTranslator::pathToResource(self::getAssetsPath() . '/pause/' . basename($playValue));
|
||||
}
|
||||
} else {
|
||||
$pause = $params->get($this->key . 'pause-image');
|
||||
$pauseColor = $params->get($this->key . 'pause-color');
|
||||
|
||||
if (empty($pause)) {
|
||||
$pauseValue = $params->get($this->key . 'pause');
|
||||
if ($pauseValue == -1) {
|
||||
$pause = null;
|
||||
} else {
|
||||
$pause = ResourceTranslator::pathToResource(self::getAssetsPath() . '/pause/' . basename($pauseValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ext = pathinfo($play, PATHINFO_EXTENSION);
|
||||
if ($ext == 'svg' && ResourceTranslator::isResource($play)) {
|
||||
|
||||
FastImageSize::initAttributes($playColor, $sizeAttributes);
|
||||
|
||||
list($color, $opacity) = Color::colorToSVG($playColor);
|
||||
$play = 'data:image/svg+xml;base64,' . Base64::encode(str_replace(array(
|
||||
'fill="#FFF"',
|
||||
'opacity="1"'
|
||||
), array(
|
||||
'fill="#' . $color . '"',
|
||||
'opacity="' . $opacity . '"'
|
||||
), Filesystem::readFile(ResourceTranslator::toPath($play))));
|
||||
} else {
|
||||
FastImageSize::initAttributes($play, $sizeAttributes);
|
||||
$play = ResourceTranslator::toUrl($play);
|
||||
}
|
||||
|
||||
$ext = pathinfo($pause, PATHINFO_EXTENSION);
|
||||
if ($ext == 'svg' && ResourceTranslator::isResource($pause)) {
|
||||
list($color, $opacity) = Color::colorToSVG($pauseColor);
|
||||
$pause = 'data:image/svg+xml;base64,' . Base64::encode(str_replace(array(
|
||||
'fill="#FFF"',
|
||||
'opacity="1"'
|
||||
), array(
|
||||
'fill="#' . $color . '"',
|
||||
'opacity="' . $opacity . '"'
|
||||
), Filesystem::readFile(ResourceTranslator::toPath($pause))));
|
||||
} else {
|
||||
$pause = ResourceTranslator::toUrl($pause);
|
||||
}
|
||||
|
||||
if ($play && $pause) {
|
||||
|
||||
$desktopWidth = $params->get('widget-autoplay-desktop-image-width');
|
||||
$tabletWidth = $params->get('widget-autoplay-tablet-image-width');
|
||||
$mobileWidth = $params->get('widget-autoplay-mobile-image-width');
|
||||
|
||||
$slider->addDeviceCSS('all', 'div#' . $id . ' .nextend-autoplay img{width: ' . $desktopWidth . 'px}');
|
||||
if ($tabletWidth != $desktopWidth) {
|
||||
$slider->addDeviceCSS('tabletportrait', 'div#' . $id . ' .nextend-autoplay img{width: ' . $tabletWidth . 'px}');
|
||||
$slider->addDeviceCSS('tabletlandscape', 'div#' . $id . ' .nextend-autoplay img{width: ' . $tabletWidth . 'px}');
|
||||
}
|
||||
if ($mobileWidth != $desktopWidth) {
|
||||
$slider->addDeviceCSS('mobileportrait', 'div#' . $id . ' .nextend-autoplay img{width: ' . $mobileWidth . 'px}');
|
||||
$slider->addDeviceCSS('mobilelandscape', 'div#' . $id . ' .nextend-autoplay img{width: ' . $mobileWidth . 'px}');
|
||||
}
|
||||
|
||||
$slider->addLess(self::getAssetsPath() . '/style.n2less', array(
|
||||
"sliderid" => $slider->elementId
|
||||
));
|
||||
|
||||
Js::addStaticGroup(self::getAssetsPath() . '/dist/w-autoplay.min.js', 'w-autoplay');
|
||||
|
||||
|
||||
$displayAttributes = $this->getDisplayAttributes($params, $this->key, 1);
|
||||
|
||||
$styleClass = $slider->addStyle($params->get($this->key . 'style'), 'heading');
|
||||
|
||||
$slider->features->addInitCallback('new _N2.SmartSliderWidgetAutoplayImage(this, ' . Cast::floatToString($params->get($this->key . 'responsive-desktop')) . ', ' . Cast::floatToString($params->get($this->key . 'responsive-tablet')) . ', ' . Cast::floatToString($params->get($this->key . 'responsive-mobile')) . ');');
|
||||
|
||||
$slider->sliderType->addJSDependency('SmartSliderWidgetAutoplayImage');
|
||||
|
||||
$html = Html::tag('div', Html::mergeAttributes($attributes, $displayAttributes, array(
|
||||
'class' => $styleClass . 'nextend-autoplay n2-ow-all nextend-autoplay-image',
|
||||
'role' => 'button',
|
||||
'aria-label' => n2_('Play autoplay'),
|
||||
'data-pause-label' => n2_('Pause autoplay'),
|
||||
'data-play-label' => n2_('Play autoplay'),
|
||||
'tabindex' => '0'
|
||||
)), Html::image($play, 'Play', $sizeAttributes + HTML::addExcludeLazyLoadAttributes(array(
|
||||
'class' => 'nextend-autoplay-play'
|
||||
))) . Html::image($pause, 'Pause', $sizeAttributes + HTML::addExcludeLazyLoadAttributes(array(
|
||||
'class' => 'nextend-autoplay-pause'
|
||||
))));
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Bar;
|
||||
|
||||
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidget;
|
||||
|
||||
abstract class AbstractWidgetBar extends AbstractWidget {
|
||||
|
||||
protected $key = 'widget-bar-';
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Bar\BarHorizontal;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Font;
|
||||
use Nextend\Framework\Form\Element\Grouping;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
use Nextend\Framework\Form\Element\Style;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetRow;
|
||||
use Nextend\SmartSlider3\Form\Element\Group\WidgetPosition;
|
||||
use Nextend\SmartSlider3\Widget\Bar\AbstractWidgetBar;
|
||||
|
||||
class BarHorizontal extends AbstractWidgetBar {
|
||||
|
||||
protected $defaults = array(
|
||||
'widget-bar-position-mode' => 'simple',
|
||||
'widget-bar-position-area' => 10,
|
||||
'widget-bar-position-offset' => 30,
|
||||
'widget-bar-style' => '{"data":[{"backgroundcolor":"000000ab","padding":"5|*|20|*|5|*|20|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"40","extra":""}]}',
|
||||
'widget-bar-show-title' => 1,
|
||||
'widget-bar-font-title' => '{"data":[{"color":"ffffffff","size":"14||px","tshadow":"0|*|0|*|0|*|000000c7","afont":"Montserrat","lineheight":"1.3","bold":0,"italic":0,"underline":0,"align":"left","extra":"vertical-align: middle;"},{"color":"fc2828ff","afont":"Raleway,Arial","size":"25||px"},{}]}',
|
||||
'widget-bar-show-description' => 1,
|
||||
'widget-bar-font-description' => '{"data":[{"color":"ffffffff","size":"14||px","tshadow":"0|*|0|*|0|*|000000c7","afont":"Montserrat","lineheight":"1.3","bold":0,"italic":1,"underline":0,"align":"left","extra":"vertical-align: middle;"},{"color":"fc2828ff","afont":"Raleway,Arial","size":"25||px"},{}]}',
|
||||
'widget-bar-slide-count' => 0,
|
||||
'widget-bar-width' => '100%',
|
||||
'widget-bar-full-width' => 0,
|
||||
'widget-bar-separator' => ' - ',
|
||||
'widget-bar-align' => 'center',
|
||||
'widget-bar-animate' => 0
|
||||
);
|
||||
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$row1 = new FieldsetRow($container, 'widget-bar-horizontal-row-1');
|
||||
|
||||
new WidgetPosition($row1, 'widget-bar-position', n2_('Position'));
|
||||
|
||||
new OnOff($row1, 'widget-bar-animate', n2_('Animate'));
|
||||
|
||||
new Style($row1, 'widget-bar-style', n2_('Bar'), '', array(
|
||||
'mode' => 'simple',
|
||||
'font' => 'sliderwidget-bar-font-title',
|
||||
'font2' => 'sliderwidget-bar-font-description',
|
||||
'preview' => 'SmartSliderAdminWidgetBarHorizontal'
|
||||
));
|
||||
|
||||
$rowTitle = new FieldsetRow($container, 'widget-bar-horizontal-row-title');
|
||||
new OnOff($rowTitle, 'widget-bar-show-title', n2_('Title'), 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'sliderwidget-bar-font-title',
|
||||
'sliderwidget-bar-slide-count-container'
|
||||
)
|
||||
));
|
||||
new Font($rowTitle, 'widget-bar-font-title', '', '', array(
|
||||
'mode' => 'simple',
|
||||
'style' => 'sliderwidget-bar-style',
|
||||
'preview' => 'SmartSliderAdminWidgetBarHorizontal'
|
||||
));
|
||||
|
||||
|
||||
$rowDescription = new FieldsetRow($container, 'widget-bar-horizontal-row-description');
|
||||
new OnOff($rowDescription, 'widget-bar-show-description', n2_('Description'), 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'sliderwidget-bar-font-description',
|
||||
'sliderwidget-bar-slide-count'
|
||||
)
|
||||
));
|
||||
new Font($rowDescription, 'widget-bar-font-description', '', '', array(
|
||||
'mode' => 'simple',
|
||||
'style' => 'sliderwidget-bar-style',
|
||||
'preview' => 'SmartSliderAdminWidgetBarHorizontal'
|
||||
));
|
||||
|
||||
$row4 = new FieldsetRow($container, 'widget-bar-horizontal-row-4');
|
||||
|
||||
$slideCountContainer = new Grouping($row4, 'widget-bar-slide-count-container');
|
||||
new OnOff($slideCountContainer, 'widget-bar-slide-count', n2_('Slide count'), 0, array(
|
||||
'tipLabel' => n2_('Slide count'),
|
||||
'tipDescription' => n2_('The "Title" will be the index of the slide and "Description" will be the total number of slides.'),
|
||||
'tipLink' => 'https://smartslider.helpscoutdocs.com/article/1856-text-bar#slide-count'
|
||||
));
|
||||
new OnOff($row4, 'widget-bar-full-width', n2_('Full width'));
|
||||
|
||||
|
||||
new Text($row4, 'widget-bar-separator', n2_('Separator'), 0, array(
|
||||
'tipLabel' => n2_('Separator'),
|
||||
'tipDescription' => sprintf(n2_('You can set what separates the Tex bar Title and Description. This separator is used at the Slide count option, too, to separate the current and total slide number. %1$s To put the Description to a new line, use the <br> HTML tag.'), '<br>'),
|
||||
'tipLink' => 'https://smartslider.helpscoutdocs.com/article/1856-text-bar#separator'
|
||||
));
|
||||
|
||||
new Select($row4, 'widget-bar-align', n2_('Align'), '', array(
|
||||
'options' => array(
|
||||
'left' => n2_('Left'),
|
||||
'center' => n2_('Center'),
|
||||
'right' => n2_('Right')
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public function prepareExport($export, $params) {
|
||||
$export->addVisual($params->get($this->key . 'style'));
|
||||
$export->addVisual($params->get($this->key . 'font-title'));
|
||||
$export->addVisual($params->get($this->key . 'font-description'));
|
||||
}
|
||||
|
||||
public function prepareImport($import, $params) {
|
||||
|
||||
$params->set($this->key . 'style', $import->fixSection($params->get($this->key . 'style', '')));
|
||||
$params->set($this->key . 'font-title', $import->fixSection($params->get($this->key . 'font-title', '')));
|
||||
$params->set($this->key . 'font-description', $import->fixSection($params->get($this->key . 'font-description', '')));
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Bar\BarHorizontal;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidgetFrontend;
|
||||
|
||||
class BarHorizontalFrontend extends AbstractWidgetFrontend {
|
||||
|
||||
public function __construct($sliderWidget, $widget, $params) {
|
||||
|
||||
parent::__construct($sliderWidget, $widget, $params);
|
||||
|
||||
if (intval($params->get($this->key . 'show-description'))) {
|
||||
$this->slider->exposeSlideData['description'] = true;
|
||||
}
|
||||
|
||||
$this->addToPlacement($this->key . 'position-', array(
|
||||
$this,
|
||||
'render'
|
||||
));
|
||||
}
|
||||
|
||||
public function render($attributes = array()) {
|
||||
|
||||
$slider = $this->slider;
|
||||
$id = $this->slider->elementId;
|
||||
$params = $this->params;
|
||||
|
||||
$slider->addLess(self::getAssetsPath() . '/style.n2less', array(
|
||||
"sliderid" => $slider->elementId
|
||||
));
|
||||
|
||||
Js::addStaticGroup(self::getAssetsPath() . '/dist/w-bar-horizontal.min.js', 'w-bar-horizontal');
|
||||
|
||||
$displayAttributes = $this->getDisplayAttributes($params, $this->key, 1);
|
||||
|
||||
$styleClass = $slider->addStyle($params->get($this->key . 'style'), 'simple');
|
||||
|
||||
$fontTitle = $slider->addFont($params->get($this->key . 'font-title'), 'simple');
|
||||
$fontDescription = $slider->addFont($params->get($this->key . 'font-description'), 'simple');
|
||||
|
||||
$style = 'text-align: ' . $params->get($this->key . 'align') . ';';
|
||||
|
||||
$width = $params->get($this->key . 'width');
|
||||
if (is_numeric($width) || substr($width, -1) == '%' || substr($width, -2) == 'px') {
|
||||
$style .= 'width:' . $width . ';';
|
||||
}
|
||||
|
||||
$innerStyle = '';
|
||||
if (!$params->get($this->key . 'full-width')) {
|
||||
$innerStyle = 'display: inline-block;';
|
||||
}
|
||||
|
||||
$showTitle = intval($params->get($this->key . 'show-title'));
|
||||
|
||||
$showDescription = intval($params->get($this->key . 'show-description'));
|
||||
|
||||
$parameters = array(
|
||||
'area' => intval($params->get($this->key . 'position-area')),
|
||||
'animate' => intval($params->get($this->key . 'animate')),
|
||||
'showTitle' => $showTitle,
|
||||
'fontTitle' => $fontTitle,
|
||||
'slideCount' => intval($params->get($this->key . 'slide-count', 0)),
|
||||
'showDescription' => $showDescription,
|
||||
'fontDescription' => $fontDescription,
|
||||
'separator' => $params->get($this->key . 'separator')
|
||||
);
|
||||
|
||||
$slider->features->addInitCallback('new _N2.SmartSliderWidgetBarHorizontal(this, ' . json_encode($parameters) . ');');
|
||||
|
||||
$slider->sliderType->addJSDependency('SmartSliderWidgetBarHorizontal');
|
||||
|
||||
return Html::tag("div", Html::mergeAttributes($attributes, $displayAttributes, array(
|
||||
"class" => "nextend-bar nextend-bar-horizontal n2-ss-widget-hidden n2-ow-all",
|
||||
"style" => $style
|
||||
)), Html::tag("div", array(
|
||||
"class" => $styleClass,
|
||||
"style" => $innerStyle
|
||||
), '<span class="' . $fontTitle . '"> </span>'));
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Bullet;
|
||||
|
||||
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidget;
|
||||
|
||||
abstract class AbstractBullet extends AbstractWidget {
|
||||
|
||||
protected $key = 'widget-bullet-';
|
||||
|
||||
public function getCommonAssetsPath() {
|
||||
return dirname(__FILE__) . '/Assets';
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Bullet;
|
||||
|
||||
|
||||
use Nextend\Framework\Platform\Platform;
|
||||
use Nextend\Framework\Url\Url;
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidgetFrontend;
|
||||
|
||||
abstract class AbstractBulletFrontend extends AbstractWidgetFrontend {
|
||||
|
||||
public function __construct($sliderWidget, $widget, $params) {
|
||||
|
||||
parent::__construct($sliderWidget, $widget, $params);
|
||||
|
||||
if ($params->get($this->key . 'thumbnail-show-image')) {
|
||||
$this->slider->exposeSlideData['thumbnail'] = true;
|
||||
}
|
||||
|
||||
$this->addToPlacement($this->key . 'position-', array(
|
||||
$this,
|
||||
'render'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public function getCommonAssetsUri() {
|
||||
return Url::pathToUri($this->getCommonAssetsPath());
|
||||
}
|
||||
|
||||
public function getCommonAssetsPath() {
|
||||
|
||||
return Platform::filterAssetsPath(dirname(__FILE__) . '/Assets');
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Bullet\BulletTransition;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
use Nextend\Framework\Form\Element\Style;
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetRow;
|
||||
use Nextend\SmartSlider3\Form\Element\Group\WidgetPosition;
|
||||
use Nextend\SmartSlider3\Widget\Bullet\AbstractBullet;
|
||||
|
||||
class BulletTransition extends AbstractBullet {
|
||||
|
||||
protected $defaults = array(
|
||||
'widget-bullet-position-mode' => 'simple',
|
||||
'widget-bullet-position-area' => 10,
|
||||
'widget-bullet-position-offset' => 10,
|
||||
'widget-bullet-action' => 'click',
|
||||
'widget-bullet-style' => '{"data":[{"backgroundcolor":"000000ab","padding":"5|*|5|*|5|*|5|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"50","extra":"margin: 4px;"},{"backgroundcolor":"1D81F9FF"}]}',
|
||||
'widget-bullet-bar' => '',
|
||||
'widget-bullet-align' => 'center',
|
||||
'widget-bullet-orientation' => 'auto',
|
||||
'widget-bullet-bar-full-size' => 0,
|
||||
'widget-bullet-thumbnail-show-image' => 0,
|
||||
'widget-bullet-thumbnail-width' => 60,
|
||||
'widget-bullet-thumbnail-style' => '{"data":[{"backgroundcolor":"00000080","padding":"3|*|3|*|3|*|3|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"3","extra":"margin: 5px;"}]}',
|
||||
'widget-bullet-thumbnail-side' => 'before'
|
||||
);
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$row1 = new FieldsetRow($container, 'widget-bullet-transition-row-1');
|
||||
|
||||
new WidgetPosition($row1, 'widget-bullet-position', n2_('Position'));
|
||||
|
||||
$row2 = new FieldsetRow($container, 'widget-bullet-transition-row-2');
|
||||
|
||||
new Style($row2, 'widget-bullet-style', n2_('Dot'), '', array(
|
||||
'mode' => 'dot',
|
||||
'style2' => 'sliderwidget-bullet-bar',
|
||||
'preview' => 'SmartSliderAdminWidgetBulletTransition'
|
||||
));
|
||||
|
||||
new Style($row2, 'widget-bullet-bar', n2_('Bar'), '', array(
|
||||
'mode' => 'simple',
|
||||
'style2' => 'sliderwidget-bullet-style',
|
||||
'preview' => 'SmartSliderAdminWidgetBulletTransition'
|
||||
));
|
||||
}
|
||||
|
||||
public function prepareExport($export, $params) {
|
||||
$export->addVisual($params->get($this->key . 'style'));
|
||||
$export->addVisual($params->get($this->key . 'bar'));
|
||||
}
|
||||
|
||||
public function prepareImport($import, $params) {
|
||||
|
||||
$params->set($this->key . 'style', $import->fixSection($params->get($this->key . 'style')));
|
||||
$params->set($this->key . 'bar', $import->fixSection($params->get($this->key . 'bar')));
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Bullet\BulletTransition;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
use Nextend\SmartSlider3\Widget\Bullet\AbstractBulletFrontend;
|
||||
|
||||
class BulletTransitionFrontend extends AbstractBulletFrontend {
|
||||
|
||||
public function render($attributes = array()) {
|
||||
|
||||
$slider = $this->slider;
|
||||
$id = $this->slider->elementId;
|
||||
$params = $this->params;
|
||||
|
||||
if ($slider->getSlidesCount() <= 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$slider->addLess(self::getAssetsPath() . '/style.n2less', array(
|
||||
"sliderid" => $slider->elementId
|
||||
));
|
||||
|
||||
Js::addStaticGroup($this->getCommonAssetsPath() . '/dist/w-bullet.min.js', 'w-bullet');
|
||||
|
||||
$displayAttributes = $this->getDisplayAttributes($params, $this->key, 1);
|
||||
|
||||
$bulletStyle = $slider->addStyle($params->get($this->key . 'style'), 'dot');
|
||||
$barStyle = $slider->addStyle($params->get($this->key . 'bar'), 'simple');
|
||||
|
||||
$orientation = $this->getOrientationByPosition($params->get($this->key . 'position-mode'), $params->get($this->key . 'position-area'), $params->get($this->key . 'orientation'), 'horizontal');
|
||||
|
||||
|
||||
$parameters = array(
|
||||
'area' => intval($params->get($this->key . 'position-area')),
|
||||
'dotClasses' => $bulletStyle,
|
||||
'mode' => '',
|
||||
'action' => $params->get($this->key . 'action')
|
||||
);
|
||||
|
||||
if ($params->get($this->key . 'thumbnail-show-image')) {
|
||||
|
||||
$parameters['thumbnail'] = 1;
|
||||
$parameters['thumbnailWidth'] = intval($params->get($this->key . 'thumbnail-width'));
|
||||
$parameters['thumbnailHeight'] = intval($params->get($this->key . 'thumbnail-height'));
|
||||
$parameters['thumbnailStyle'] = $slider->addStyle($params->get($this->key . 'thumbnail-style'), 'simple', '');
|
||||
$side = $params->get($this->key . 'thumbnail-side');
|
||||
|
||||
|
||||
if ($side == 'before') {
|
||||
if ($orientation == 'vertical') {
|
||||
$position = 'left';
|
||||
} else {
|
||||
$position = 'top';
|
||||
}
|
||||
} else {
|
||||
if ($orientation == 'vertical') {
|
||||
$position = 'right';
|
||||
} else {
|
||||
$position = 'bottom';
|
||||
}
|
||||
}
|
||||
$parameters['thumbnailPosition'] = $position;
|
||||
}
|
||||
|
||||
$slider->features->addInitCallback('new _N2.SmartSliderWidgetBulletTransition(this, ' . json_encode($parameters) . ');');
|
||||
$slider->sliderType->addJSDependency('SmartSliderWidgetBulletTransition');
|
||||
|
||||
$fullSize = intval($params->get($this->key . 'bar-full-size'));
|
||||
|
||||
return Html::tag("div", Html::mergeAttributes($attributes, $displayAttributes, array(
|
||||
"class" => 'n2-ss-control-bullet n2-ow-all n2-ss-control-bullet-' . $orientation . ($fullSize ? ' n2-ss-control-bullet-fullsize' : '')
|
||||
)), Html::tag("div", array(
|
||||
"class" => $barStyle . " nextend-bullet-bar n2-bar-justify-content-" . $params->get($this->key . 'align')
|
||||
), '<div class="n2-bullet ' . $bulletStyle . '" style="visibility:hidden;"></div>'));
|
||||
}
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Group;
|
||||
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\Element\CheckboxOnOff;
|
||||
use Nextend\Framework\Form\Element\Group\GroupCheckboxOnOff;
|
||||
use Nextend\Framework\Form\Form;
|
||||
use Nextend\Framework\Pattern\OrderableTrait;
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidget;
|
||||
use Nextend\SmartSlider3\Widget\WidgetGroupFactory;
|
||||
|
||||
abstract class AbstractWidgetGroup {
|
||||
|
||||
use OrderableTrait;
|
||||
|
||||
/** @var AbstractWidget[] */
|
||||
private $widgets = array();
|
||||
|
||||
protected $showOnMobileDefault = 0;
|
||||
|
||||
public function __construct() {
|
||||
WidgetGroupFactory::addGroup($this);
|
||||
}
|
||||
|
||||
public abstract function getName();
|
||||
|
||||
public abstract function getLabel();
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param AbstractWidget $widget
|
||||
*/
|
||||
public function addWidget($name, $widget) {
|
||||
$this->widgets[$name] = $widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractWidget[]
|
||||
*/
|
||||
public function getWidgets() {
|
||||
return $this->widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return AbstractWidget
|
||||
*/
|
||||
public function getWidget($name) {
|
||||
return $this->widgets[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*/
|
||||
abstract public function renderFields($container);
|
||||
|
||||
/**
|
||||
* @param Form $form
|
||||
*/
|
||||
protected function compatibility($form) {
|
||||
$name = $this->getName();
|
||||
|
||||
/**
|
||||
* Convert to the new control form with the enable field
|
||||
*/
|
||||
if (!$form->has('widget-' . $name . '-enabled')) {
|
||||
|
||||
if ($form->get('widget' . $name, 'disabled') !== 'disabled') {
|
||||
$form->set('widget-' . $name . '-enabled', 1);
|
||||
|
||||
} else {
|
||||
$form->set('widget-' . $name . '-enabled', 0);
|
||||
}
|
||||
}
|
||||
|
||||
$widgets = $this->getWidgets();
|
||||
|
||||
$widgetPreset = $form->get('widget' . $name);
|
||||
|
||||
if (!isset($widgets[$widgetPreset])) {
|
||||
$widgetPreset = key($widgets);
|
||||
$form->set('widget' . $name, $widgetPreset);
|
||||
}
|
||||
|
||||
$widget = $widgets[$widgetPreset];
|
||||
|
||||
$form->fillDefault($widget->getDefaults());
|
||||
}
|
||||
|
||||
protected function addHideOnFeature($key, $row) {
|
||||
|
||||
$groupShowOn = new GroupCheckboxOnOff($row, $key, n2_('Hide on'));
|
||||
new CheckboxOnOff($groupShowOn, $key . 'mobileportrait', false, 'ssi_16 ssi_16--mobileportrait', $this->showOnMobileDefault, array(
|
||||
'invert' => true,
|
||||
'checkboxTip' => n2_('Mobile')
|
||||
));
|
||||
|
||||
|
||||
new CheckboxOnOff($groupShowOn, $key . 'tabletportrait', false, 'ssi_16 ssi_16--tabletportrait', 1, array(
|
||||
'invert' => true,
|
||||
'checkboxTip' => n2_('Tablet')
|
||||
));
|
||||
|
||||
|
||||
new CheckboxOnOff($groupShowOn, $key . 'desktopportrait', false, 'ssi_16 ssi_16--desktopportrait', 1, array(
|
||||
'invert' => true,
|
||||
'checkboxTip' => n2_('Desktop')
|
||||
));
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Group;
|
||||
|
||||
use Nextend\Framework\Form\Container\ContainerTab;
|
||||
use Nextend\Framework\Form\Container\ContainerTable;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Pattern\PluggableTrait;
|
||||
use Nextend\SmartSlider3\Form\Element\ControlTypePicker;
|
||||
use Nextend\SmartSlider3\Widget\Arrow\ArrowImage\ArrowImage;
|
||||
|
||||
class Arrow extends AbstractWidgetGroup {
|
||||
|
||||
use PluggableTrait;
|
||||
|
||||
public $ordering = 1;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
new ArrowImage($this, 'imageSmallRectangle', array(
|
||||
'widget-arrow-desktop-image-width' => 26,
|
||||
'widget-arrow-tablet-image-width' => 26,
|
||||
'widget-arrow-previous' => '$ss$/plugins/widgetarrow/image/image/previous/full.svg',
|
||||
'widget-arrow-next' => '$ss$/plugins/widgetarrow/image/image/next/full.svg',
|
||||
'widget-arrow-style' => '{"data":[{"backgroundcolor":"000000ab","padding":"2|*|2|*|2|*|2|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"3","extra":""},{"backgroundcolor":"FF9139FF"}]}'
|
||||
));
|
||||
|
||||
new ArrowImage($this, 'imageEmpty', array(
|
||||
'widget-arrow-previous' => '$ss$/plugins/widgetarrow/image/image/previous/thin-horizontal.svg',
|
||||
'widget-arrow-next' => '$ss$/plugins/widgetarrow/image/image/next/thin-horizontal.svg',
|
||||
'widget-arrow-style' => ''
|
||||
));
|
||||
|
||||
$this->makePluggable('SliderWidgetArrow');
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'arrow';
|
||||
}
|
||||
|
||||
public function getLabel() {
|
||||
return n2_('Arrows');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerTab $container
|
||||
*/
|
||||
public function renderFields($container) {
|
||||
|
||||
$form = $container->getForm();
|
||||
|
||||
$this->compatibility($form);
|
||||
|
||||
/**
|
||||
* Used for field removal: /controls/widget-arrow
|
||||
*/
|
||||
$table = new ContainerTable($container, 'widget-arrow', n2_('Arrow'));
|
||||
|
||||
new OnOff($table->getFieldsetLabel(), 'widget-arrow-enabled', false, 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'table-rows-widget-arrow'
|
||||
)
|
||||
));
|
||||
|
||||
$row1 = $table->createRow('widget-arrow-1');
|
||||
|
||||
$ajaxUrl = $form->createAjaxUrl(array("slider/renderwidgetarrow"));
|
||||
new ControlTypePicker($row1, 'widgetarrow', $table, $ajaxUrl, $this, 'imageEmpty');
|
||||
|
||||
|
||||
$row2 = $table->createRow('widget-arrow-2');
|
||||
|
||||
new OnOff($row2, 'widget-arrow-display-hover', n2_('Shows on hover'), 0);
|
||||
|
||||
$this->addHideOnFeature('widget-arrow-display-', $row2);
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Group;
|
||||
|
||||
use Nextend\Framework\Data\Data;
|
||||
use Nextend\Framework\Form\Container\ContainerTable;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Parser\Common;
|
||||
use Nextend\Framework\Pattern\PluggableTrait;
|
||||
use Nextend\SmartSlider3\Form\Element\ControlTypePicker;
|
||||
use Nextend\SmartSlider3\Widget\Autoplay\AutoplayImage\AutoplayImage;
|
||||
|
||||
class Autoplay extends AbstractWidgetGroup {
|
||||
|
||||
use PluggableTrait;
|
||||
|
||||
public $ordering = 3;
|
||||
|
||||
protected $showOnMobileDefault = 1;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
new AutoplayImage($this, 'image');
|
||||
|
||||
$this->makePluggable('SliderWidgetAutoplay');
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'autoplay';
|
||||
}
|
||||
|
||||
public function getLabel() {
|
||||
return n2_('Autoplay');
|
||||
}
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$form = $container->getForm();
|
||||
|
||||
$this->compatibility($form);
|
||||
|
||||
$autoplayFinish = $form->get('autoplayfinish');
|
||||
if (!$form->has('autoplayLoop') && !empty($autoplayFinish)) {
|
||||
$this->upgradeData($form);
|
||||
}
|
||||
|
||||
$table = new ContainerTable($container, 'widget-autoplay', n2_('Button'));
|
||||
|
||||
new OnOff($table->getFieldsetLabel(), 'widget-autoplay-enabled', false, 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'table-rows-widget-autoplay'
|
||||
)
|
||||
));
|
||||
|
||||
$row1 = $table->createRow('widget-bullet-1');
|
||||
|
||||
$url = $form->createAjaxUrl(array("slider/renderwidgetautoplay"));
|
||||
new ControlTypePicker($row1, 'widgetautoplay', $table, $url, $this, 'image');
|
||||
|
||||
|
||||
$row2 = $table->createRow('widget-bullet-2');
|
||||
|
||||
new OnOff($row2, 'widget-autoplay-display-hover', n2_('Shows on hover'), 0);
|
||||
|
||||
$this->addHideOnFeature('widget-autoplay-display-', $row2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For compatibility with legacy autoplay values.
|
||||
*
|
||||
* @param Data $data
|
||||
*/
|
||||
protected function upgradeData($data) {
|
||||
if (!$data->has('autoplayLoop')) {
|
||||
list($interval, $intervalModifier, $intervalSlide) = (array)Common::parse($data->get('autoplayfinish', '1|*|loop|*|current'));
|
||||
if ($interval <= 0) {
|
||||
// 0|*|slide|*|current -> In old versions it brought to the Next slide.
|
||||
if ($interval <= 0 && $intervalModifier === 'slide' && $intervalSlide === 'next') {
|
||||
$data->set('autoplayfinish', '1|*|slide|*|current');
|
||||
$data->set('autoplayLoop', 0);
|
||||
}
|
||||
|
||||
// 0|*|loop/slide/slideindex|*|current -> Infinite loop
|
||||
// 0|*|loop|*|next -> Infinite loop
|
||||
if ($intervalSlide === 'current' || ($intervalModifier === 'loop' && $intervalSlide === 'next')) {
|
||||
$data->set('autoplayfinish', '1|*|loop|*|current');
|
||||
$data->set('autoplayLoop', 1);
|
||||
}
|
||||
|
||||
// 0|*|slideindex|*|next -> In old versions it always brought to the 2nd slide.
|
||||
if ($intervalModifier === 'slideindex' && $intervalSlide === 'next') {
|
||||
$data->set('autoplayfinish', '2|*|slideindex|*|current');
|
||||
$data->set('autoplayLoop', '0');
|
||||
}
|
||||
} else {
|
||||
//next is not allowed for "slide" and "slideindex" interval modifiers
|
||||
if ($intervalModifier === 'slide' || $intervalModifier === 'slideindex') {
|
||||
$data->set('autoplayfinish', $interval . '|*|' . $intervalModifier . '|*|current');
|
||||
}
|
||||
// turn off Loop, and work with the original settings
|
||||
$data->set('autoplayLoop', '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Group;
|
||||
|
||||
use Nextend\Framework\Form\Container\ContainerTable;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Pattern\PluggableTrait;
|
||||
use Nextend\SmartSlider3\Form\Element\ControlTypePicker;
|
||||
use Nextend\SmartSlider3\Widget\Bar\BarHorizontal\BarHorizontal;
|
||||
|
||||
class Bar extends AbstractWidgetGroup {
|
||||
|
||||
use PluggableTrait;
|
||||
|
||||
public $ordering = 5;
|
||||
|
||||
protected $showOnMobileDefault = 1;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
new BarHorizontal($this, 'horizontal');
|
||||
|
||||
new BarHorizontal($this, 'horizontalFull', array(
|
||||
'widget-bar-position-offset' => 0,
|
||||
'widget-bar-style' => '{"data":[{"backgroundcolor":"000000ab","padding":"20|*|20|*|20|*|20|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"0","extra":""}]}',
|
||||
'widget-bar-full-width' => 1,
|
||||
'widget-bar-align' => 'left'
|
||||
));
|
||||
|
||||
$this->makePluggable('SliderWidgetBar');
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'bar';
|
||||
}
|
||||
|
||||
public function getLabel() {
|
||||
return n2_('Text bar');
|
||||
}
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$form = $container->getForm();
|
||||
|
||||
$this->compatibility($form);
|
||||
|
||||
/**
|
||||
* Used for field removal: /controls/widget-bar
|
||||
*/
|
||||
$table = new ContainerTable($container, 'widget-bar', n2_('Text bar'));
|
||||
|
||||
new OnOff($table->getFieldsetLabel(), 'widget-bar-enabled', false, 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'table-rows-widget-bar'
|
||||
)
|
||||
));
|
||||
|
||||
$row1 = $table->createRow('widget-bar-1');
|
||||
|
||||
$ajaxUrl = $form->createAjaxUrl(array("slider/renderwidgetbar"));
|
||||
new ControlTypePicker($row1, 'widgetbar', $table, $ajaxUrl, $this, 'horizontal');
|
||||
|
||||
|
||||
$row2 = $table->createRow('widget-bar-2');
|
||||
|
||||
new OnOff($row2, 'widget-bar-display-hover', n2_('Shows on hover'), 0);
|
||||
|
||||
$this->addHideOnFeature('widget-bar-display-', $row2);
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Group;
|
||||
|
||||
use Nextend\Framework\Form\Container\ContainerTable;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
use Nextend\Framework\Form\Element\Style;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Form\Element\Text\NumberAutoComplete;
|
||||
use Nextend\Framework\Pattern\PluggableTrait;
|
||||
use Nextend\SmartSlider3\Form\Element\ControlTypePicker;
|
||||
use Nextend\SmartSlider3\Widget\Bullet\BulletTransition\BulletTransition;
|
||||
|
||||
class Bullet extends AbstractWidgetGroup {
|
||||
|
||||
use PluggableTrait;
|
||||
|
||||
public $ordering = 2;
|
||||
|
||||
protected $showOnMobileDefault = 1;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
new BulletTransition($this, 'transition');
|
||||
|
||||
$this->makePluggable('SliderWidgetBullet');
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'bullet';
|
||||
}
|
||||
|
||||
public function getLabel() {
|
||||
return n2_('Bullets');
|
||||
}
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$form = $container->getForm();
|
||||
|
||||
$this->compatibility($form);
|
||||
|
||||
/**
|
||||
* Used for field removal: /controls/widget-bullet
|
||||
*/
|
||||
$table = new ContainerTable($container, 'widget-bullet', n2_('Bullets'));
|
||||
|
||||
new OnOff($table->getFieldsetLabel(), 'widget-bullet-enabled', false, 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'table-rows-widget-bullet'
|
||||
)
|
||||
));
|
||||
|
||||
$row1 = $table->createRow('widget-bullet-1');
|
||||
|
||||
|
||||
$url = $form->createAjaxUrl(array("slider/renderwidgetbullet"));
|
||||
|
||||
new ControlTypePicker($row1, 'widgetbullet', $table, $url, $this);
|
||||
|
||||
$row2 = $table->createRow('widget-bullet-2');
|
||||
new OnOff($row2, 'widget-bullet-thumbnail-show-image', n2_('Image'), 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'sliderwidget-bullet-thumbnail-width',
|
||||
'sliderwidget-bullet-thumbnail-height',
|
||||
'sliderwidget-bullet-thumbnail-style',
|
||||
'sliderwidget-bullet-thumbnail-side'
|
||||
)
|
||||
));
|
||||
|
||||
new NumberAutoComplete($row2, 'widget-bullet-thumbnail-width', n2_('Width'), 100, array(
|
||||
'unit' => 'px',
|
||||
'values' => array(
|
||||
60,
|
||||
100,
|
||||
150,
|
||||
200
|
||||
),
|
||||
'wide' => 4
|
||||
));
|
||||
|
||||
new NumberAutoComplete($row2, 'widget-bullet-thumbnail-height', n2_('Height'), 60, array(
|
||||
'unit' => 'px',
|
||||
'values' => array(
|
||||
60,
|
||||
100,
|
||||
150,
|
||||
200
|
||||
),
|
||||
'wide' => 4
|
||||
));
|
||||
|
||||
new Style($row2, 'widget-bullet-thumbnail-style', n2_('Style'), '{"data":[{"backgroundcolor":"00000080","padding":"3|*|3|*|3|*|3|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"3","extra":"margin: 5px;background-size:cover;"}]}', array(
|
||||
'mode' => 'simple',
|
||||
'preview' => 'SmartSliderAdminWidgetBulletThumbnail'
|
||||
));
|
||||
|
||||
new Select($row2, 'widget-bullet-thumbnail-side', n2_('Side'), 'before', array(
|
||||
'options' => array(
|
||||
'before' => n2_('Before'),
|
||||
'after' => n2_('After')
|
||||
)
|
||||
));
|
||||
|
||||
$row3 = $table->createRow('widget-bullet-3');
|
||||
|
||||
new OnOff($row3, 'widget-bullet-display-hover', n2_('Shows on hover'), 0);
|
||||
|
||||
$this->addHideOnFeature('widget-bullet-display-', $row3);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Group;
|
||||
|
||||
use Nextend\Framework\Form\Container\ContainerTable;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Pattern\PluggableTrait;
|
||||
use Nextend\SmartSlider3\Form\Element\ControlTypePicker;
|
||||
use Nextend\SmartSlider3\Widget\Shadow\ShadowImage\ShadowImage;
|
||||
|
||||
class Shadow extends AbstractWidgetGroup {
|
||||
|
||||
use PluggableTrait;
|
||||
|
||||
public $ordering = 7;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
new ShadowImage($this, 'shadow');
|
||||
|
||||
$this->makePluggable('SliderWidgetShadow');
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'shadow';
|
||||
}
|
||||
|
||||
public function getLabel() {
|
||||
return n2_('Shadow');
|
||||
}
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$form = $container->getForm();
|
||||
|
||||
$this->compatibility($form);
|
||||
|
||||
$table = new ContainerTable($container, 'widgetshadow', n2_('Shadow'));
|
||||
new OnOff($table->getFieldsetLabel(), 'widget-shadow-enabled', false, 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'table-rows-widgetshadow'
|
||||
)
|
||||
));
|
||||
|
||||
$row1 = $table->createRow('widget-shadow-1');
|
||||
|
||||
$url = $form->createAjaxUrl(array("slider/renderwidgetshadow"));
|
||||
new ControlTypePicker($row1, 'widgetshadow', $table, $url, $this);
|
||||
|
||||
|
||||
$row2 = $table->createRow('widget-shadow-2');
|
||||
|
||||
$this->addHideOnFeature('widget-shadow-display-', $row2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Group;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Container\ContainerTab;
|
||||
use Nextend\Framework\Form\Container\ContainerTable;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Form\Element\Text\NumberAutoComplete;
|
||||
use Nextend\Framework\Pattern\PluggableTrait;
|
||||
use Nextend\SmartSlider3\Form\Element\ControlTypePicker;
|
||||
use Nextend\SmartSlider3\Widget\Thumbnail\Basic\ThumbnailBasic;
|
||||
|
||||
class Thumbnail extends AbstractWidgetGroup {
|
||||
|
||||
use PluggableTrait;
|
||||
|
||||
public $ordering = 6;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
new ThumbnailBasic($this, 'default');
|
||||
|
||||
$this->makePluggable('SliderWidgetThumbnail');
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'thumbnail';
|
||||
}
|
||||
|
||||
public function getLabel() {
|
||||
return n2_('Thumbnails');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerTab $container
|
||||
*/
|
||||
public function renderFields($container) {
|
||||
|
||||
$form = $container->getForm();
|
||||
|
||||
$this->compatibility($form);
|
||||
|
||||
/**
|
||||
* Used for field removal: /controls/widget-thumbnail
|
||||
*/
|
||||
$table = new ContainerTable($container, 'widget-thumbnail', n2_('Thumbnails'));
|
||||
|
||||
new OnOff($table->getFieldsetLabel(), 'widget-thumbnail-enabled', false, 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
'table-rows-widget-thumbnail'
|
||||
)
|
||||
));
|
||||
|
||||
$row1 = $table->createRow('widget-thumbnail-1');
|
||||
|
||||
$row2 = $table->createRow('widget-thumbnail-2');
|
||||
|
||||
new NumberAutoComplete($row2, 'widget-thumbnail-width', n2_('Desktop width'), 100, array(
|
||||
'unit' => 'px',
|
||||
'values' => array(
|
||||
60,
|
||||
100,
|
||||
150,
|
||||
200
|
||||
),
|
||||
'wide' => 4
|
||||
));
|
||||
|
||||
new NumberAutoComplete($row2, 'widget-thumbnail-height', n2_('Height'), 60, array(
|
||||
'unit' => 'px',
|
||||
'values' => array(
|
||||
60,
|
||||
100,
|
||||
150,
|
||||
200
|
||||
),
|
||||
'wide' => 4
|
||||
));
|
||||
|
||||
new NumberAutoComplete($row2, 'widget-thumbnail-tablet-width', n2_('Tablet width'), 100, array(
|
||||
'unit' => 'px',
|
||||
'values' => array(
|
||||
60,
|
||||
100,
|
||||
150,
|
||||
200
|
||||
),
|
||||
'wide' => 4
|
||||
));
|
||||
|
||||
new NumberAutoComplete($row2, 'widget-thumbnail-tablet-height', n2_('Height'), 60, array(
|
||||
'unit' => 'px',
|
||||
'values' => array(
|
||||
60,
|
||||
100,
|
||||
150,
|
||||
200
|
||||
),
|
||||
'wide' => 4
|
||||
));
|
||||
|
||||
new NumberAutoComplete($row2, 'widget-thumbnail-mobile-width', n2_('Mobile width'), 100, array(
|
||||
'unit' => 'px',
|
||||
'values' => array(
|
||||
60,
|
||||
100,
|
||||
150,
|
||||
200
|
||||
),
|
||||
'wide' => 4
|
||||
));
|
||||
|
||||
new NumberAutoComplete($row2, 'widget-thumbnail-mobile-height', n2_('Height'), 60, array(
|
||||
'unit' => 'px',
|
||||
'values' => array(
|
||||
60,
|
||||
100,
|
||||
150,
|
||||
200
|
||||
),
|
||||
'wide' => 4
|
||||
));
|
||||
|
||||
|
||||
$ajaxUrl = $form->createAjaxUrl(array("slider/renderwidgetthumbnail"));
|
||||
new ControlTypePicker($row1, 'widgetthumbnail', $table, $ajaxUrl, $this, 'default');
|
||||
|
||||
|
||||
$row3 = $table->createRow('widget-thumbnail-3');
|
||||
|
||||
new OnOff($row3, 'widget-thumbnail-display-hover', n2_('Shows on hover'), 0);
|
||||
|
||||
$this->addHideOnFeature('widget-thumbnail-display-', $row3);
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Shadow;
|
||||
|
||||
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidget;
|
||||
|
||||
abstract class AbstractWidgetShadow extends AbstractWidget {
|
||||
|
||||
protected $key = 'widget-shadow-';
|
||||
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Shadow\ShadowImage;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Radio\ImageListFromFolder;
|
||||
use Nextend\Framework\Form\Element\Text\FieldImage;
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetRow;
|
||||
use Nextend\SmartSlider3\Widget\Shadow\AbstractWidgetShadow;
|
||||
|
||||
class ShadowImage extends AbstractWidgetShadow {
|
||||
|
||||
protected $defaults = array(
|
||||
'widget-shadow-position-mode' => 'simple',
|
||||
'widget-shadow-position-area' => 12,
|
||||
'widget-shadow-position-stack' => 3,
|
||||
'widget-shadow-shadow-image' => '',
|
||||
'widget-shadow-shadow' => '$ss$/plugins/widgetshadow/shadow/shadow/shadow/dark.png'
|
||||
);
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$row1 = new FieldsetRow($container, 'widget-shadow-row-1');
|
||||
$fieldShadow = new ImageListFromFolder($row1, 'widget-shadow-shadow', n2_('Shadow'), '', array(
|
||||
'folder' => self::getAssetsPath() . '/shadow/',
|
||||
'width' => 582,
|
||||
'column' => 1,
|
||||
'hasDisabled' => false
|
||||
));
|
||||
}
|
||||
|
||||
public function prepareExport($export, $params) {
|
||||
$export->addImage($params->get($this->key . 'shadow-image', ''));
|
||||
}
|
||||
|
||||
public function prepareImport($import, $params) {
|
||||
|
||||
$params->set($this->key . 'shadow-image', $import->fixImage($params->get($this->key . 'shadow-image', '')));
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Shadow\ShadowImage;
|
||||
|
||||
|
||||
use Nextend\Framework\FastImageSize\FastImageSize;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
use Nextend\Framework\View\Html;
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidgetFrontend;
|
||||
|
||||
class ShadowImageFrontend extends AbstractWidgetFrontend {
|
||||
|
||||
public function __construct($sliderWidget, $widget, $params) {
|
||||
|
||||
parent::__construct($sliderWidget, $widget, $params);
|
||||
|
||||
$this->addToPlacement($this->key . 'position-', array(
|
||||
$this,
|
||||
'render'
|
||||
));
|
||||
}
|
||||
|
||||
public function render($attributes = array()) {
|
||||
|
||||
$slider = $this->slider;
|
||||
$id = $this->slider->elementId;
|
||||
$params = $this->params;
|
||||
|
||||
$shadow = $params->get($this->key . 'shadow-image');
|
||||
if (empty($shadow)) {
|
||||
$shadow = $params->get($this->key . 'shadow');
|
||||
if ($shadow == -1) {
|
||||
$shadow = null;
|
||||
} else {
|
||||
$shadow = self::getAssetsUri() . '/shadow/' . basename($shadow);
|
||||
}
|
||||
}
|
||||
if (!$shadow) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$slider->addLess(self::getAssetsPath() . '/style.n2less', array(
|
||||
"sliderid" => $slider->elementId
|
||||
));
|
||||
|
||||
$displayAttributes = $this->getDisplayAttributes($params, $this->key);
|
||||
|
||||
$slider->features->addInitCallback("new _N2.SmartSliderWidget(this, 'shadow', '.nextend-shadow');");
|
||||
|
||||
$slider->sliderType->addJSDependency('SmartSliderWidget');
|
||||
|
||||
$sizeAttributes = array();
|
||||
FastImageSize::initAttributes(ResourceTranslator::urlToResource($shadow), $sizeAttributes);
|
||||
|
||||
return Html::tag('div', Html::mergeAttributes($displayAttributes, array(
|
||||
'class' => "nextend-shadow n2-ow-all"
|
||||
)), Html::image(ResourceTranslator::toUrl($shadow), 'Shadow', $sizeAttributes + Html::addExcludeLazyLoadAttributes(array(
|
||||
'style' => 'display: block; width:100%;max-width:none;',
|
||||
'class' => 'nextend-shadow-image',
|
||||
'loading' => 'lazy'
|
||||
))));
|
||||
}
|
||||
}
|
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget;
|
||||
|
||||
|
||||
use Nextend\Framework\View\Html;
|
||||
use Nextend\SmartSlider3\Slider\Slider;
|
||||
|
||||
class SliderWidget {
|
||||
|
||||
/** @var AbstractWidgetFrontend[] */
|
||||
private $enabledWidgets = array();
|
||||
|
||||
public $widgets = array();
|
||||
|
||||
public $left = array();
|
||||
|
||||
public $right = array();
|
||||
|
||||
/**
|
||||
* @var WidgetPlacementSimple[]
|
||||
*/
|
||||
private $placements = array();
|
||||
|
||||
/**
|
||||
* @var WidgetPlacementAdvanced
|
||||
*/
|
||||
private $placementAdvanced;
|
||||
|
||||
public $slider;
|
||||
|
||||
/**
|
||||
* @param $slider Slider
|
||||
*/
|
||||
public function __construct($slider) {
|
||||
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$params = $slider->params;
|
||||
|
||||
$this->placements['above'] = new WidgetPlacementSimple('above');
|
||||
$this->placements['below'] = new WidgetPlacementSimple('below');
|
||||
$this->placements['left'] = new WidgetPlacementSimple('left');
|
||||
$this->placements['right'] = new WidgetPlacementSimple('right');
|
||||
|
||||
$this->placements['absolute-left'] = new WidgetPlacementSimple('absolute-left');
|
||||
$this->placements['absolute-right'] = new WidgetPlacementSimple('absolute-right');
|
||||
|
||||
$this->placements['absolute-left-top'] = new WidgetPlacementSimple('absolute-left-top');
|
||||
$this->placements['absolute-center-top'] = new WidgetPlacementSimple('absolute-center-top');
|
||||
$this->placements['absolute-right-top'] = new WidgetPlacementSimple('absolute-right-top');
|
||||
|
||||
$this->placements['absolute-left-center'] = new WidgetPlacementSimple('absolute-left-center');
|
||||
$this->placements['absolute-right-center'] = new WidgetPlacementSimple('absolute-right-center');
|
||||
|
||||
$this->placements['absolute-left-bottom'] = new WidgetPlacementSimple('absolute-left-bottom');
|
||||
$this->placements['absolute-center-bottom'] = new WidgetPlacementSimple('absolute-center-bottom');
|
||||
$this->placements['absolute-right-bottom'] = new WidgetPlacementSimple('absolute-right-bottom');
|
||||
|
||||
$this->placementAdvanced = new WidgetPlacementAdvanced('advanced');
|
||||
|
||||
$widgetGroups = WidgetGroupFactory::getGroups();
|
||||
|
||||
foreach ($widgetGroups as $groupName => $group) {
|
||||
$isEnabled = false;
|
||||
if ($params->has('widget-' . $group->getName() . '-enabled')) {
|
||||
$isEnabled = $params->get('widget-' . $group->getName() . '-enabled', 0);
|
||||
} else {
|
||||
$oldValue = $params->get('widget' . $groupName);
|
||||
if ($oldValue != 'disabled' && $oldValue != '') {
|
||||
$isEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($isEnabled) {
|
||||
$widget = $group->getWidget($params->get('widget' . $groupName));
|
||||
if ($widget) {
|
||||
$this->enabledWidgets[$groupName] = $widget->createFrontend($this, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addToSimplePlacement($renderCallback, $placement, $stack, $offset = 0) {
|
||||
|
||||
$this->placements[$placement]->add($renderCallback, $stack, $offset);
|
||||
}
|
||||
|
||||
public function addToAdvancedPlacement($renderCallback, $horizontalSide, $horizontalPosition, $horizontalUnit, $verticalSide, $verticalPosition, $verticalUnit) {
|
||||
|
||||
$this->placementAdvanced->add($renderCallback, $horizontalSide, $horizontalPosition, $horizontalUnit, $verticalSide, $verticalPosition, $verticalUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $innerHTML
|
||||
*
|
||||
* @return mixed|string contains already escaped data
|
||||
*/
|
||||
public function wrapSlider($innerHTML) {
|
||||
|
||||
$insideAbsoluteHTML = '';
|
||||
|
||||
$insideAbsolutes = array(
|
||||
'absolute-left-top',
|
||||
'absolute-center-top',
|
||||
'absolute-right-top',
|
||||
'absolute-left-center',
|
||||
'absolute-right-center',
|
||||
'absolute-left-bottom',
|
||||
'absolute-center-bottom',
|
||||
'absolute-right-bottom'
|
||||
);
|
||||
|
||||
foreach ($insideAbsolutes as $insideAbsolute) {
|
||||
if (!$this->placements[$insideAbsolute]->empty()) {
|
||||
$insideAbsoluteHTML .= $this->placements[$insideAbsolute]->render();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->placementAdvanced->empty()) {
|
||||
$insideAbsoluteHTML .= $this->placementAdvanced->render();
|
||||
}
|
||||
|
||||
if (!empty($insideAbsoluteHTML)) {
|
||||
|
||||
$innerHTML = Html::tag('div', array(
|
||||
'class' => 'n2-ss-slider-wrapper-inside'
|
||||
), $innerHTML . $insideAbsoluteHTML);
|
||||
}
|
||||
|
||||
|
||||
$leftHTML = '';
|
||||
if (!$this->placements['left']->empty()) {
|
||||
$leftHTML = $this->placements['left']->render();
|
||||
}
|
||||
if (!$this->placements['absolute-left']->empty()) {
|
||||
$leftHTML .= $this->placements['absolute-left']->render();
|
||||
}
|
||||
|
||||
$rightHTML = '';
|
||||
if (!$this->placements['right']->empty()) {
|
||||
$rightHTML = $this->placements['right']->render();
|
||||
}
|
||||
if (!$this->placements['absolute-right']->empty()) {
|
||||
$rightHTML .= $this->placements['absolute-right']->render();
|
||||
}
|
||||
|
||||
if (!empty($leftHTML) || !empty($rightHTML)) {
|
||||
|
||||
$innerHTML = Html::tag('div', array(
|
||||
'class' => 'n2-ss-slider-controls-side'
|
||||
), $leftHTML . $innerHTML . $rightHTML);
|
||||
}
|
||||
|
||||
$templateRows = array();
|
||||
|
||||
if (!$this->placements['above']->empty()) {
|
||||
$innerHTML = $this->placements['above']->render() . $innerHTML;
|
||||
$templateRows[] = 'auto';
|
||||
}
|
||||
|
||||
$templateRows[] = '1fr';
|
||||
|
||||
if (!$this->placements['below']->empty()) {
|
||||
$innerHTML .= $this->placements['below']->render();
|
||||
$templateRows[] = 'auto';
|
||||
}
|
||||
|
||||
if (count($templateRows) > 1) {
|
||||
/**
|
||||
* Full page responsive type need this grid to properly render
|
||||
*/
|
||||
$innerHTML = Html::tag('div', array(
|
||||
'class' => 'n2-ss-slider-wrapper-outside',
|
||||
'style' => 'grid-template-rows:' . implode(' ', $templateRows)
|
||||
), $innerHTML);
|
||||
}
|
||||
|
||||
return $innerHTML;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Thumbnail\Basic;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Font;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
use Nextend\Framework\Form\Element\Style;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Form\Element\Text\FieldImage;
|
||||
use Nextend\Framework\Form\Element\Text\Number;
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetRow;
|
||||
use Nextend\SmartSlider3\Form\Element\Group\WidgetPosition;
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidget;
|
||||
|
||||
class ThumbnailBasic extends AbstractWidget {
|
||||
|
||||
protected $key = 'widget-thumbnail-';
|
||||
|
||||
protected $defaults = array(
|
||||
'widget-thumbnail-position-mode' => 'simple',
|
||||
'widget-thumbnail-position-area' => 12,
|
||||
'widget-thumbnail-action' => 'click',
|
||||
'widget-thumbnail-style-bar' => '{"data":[{"backgroundcolor":"242424ff","padding":"3|*|3|*|3|*|3|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"0","extra":""}]}',
|
||||
'widget-thumbnail-style-slides' => '{"data":[{"backgroundcolor":"00000000","padding":"0|*|0|*|0|*|0|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|ffffff00","borderradius":"0","opacity":"40","extra":"margin: 3px;\ntransition: all 0.4s;"},{"border":"0|*|solid|*|ffffffcc","opacity":"100","extra":""}]}',
|
||||
'widget-thumbnail-arrow' => 1,
|
||||
'widget-thumbnail-arrow-image' => '',
|
||||
'widget-thumbnail-arrow-width' => 26,
|
||||
'widget-thumbnail-arrow-offset' => 0,
|
||||
'widget-thumbnail-arrow-prev-alt' => 'previous arrow',
|
||||
'widget-thumbnail-arrow-next-alt' => 'next arrow',
|
||||
'widget-thumbnail-title-style' => '{"data":[{"backgroundcolor":"000000ab","padding":"3|*|10|*|3|*|10|*|px","boxshadow":"0|*|0|*|0|*|0|*|000000ff","border":"0|*|solid|*|000000ff","borderradius":"0","extra":"bottom: 0;\nleft: 0;"}]}',
|
||||
'widget-thumbnail-title' => 0,
|
||||
'widget-thumbnail-title-font' => '{"data":[{"color":"ffffffff","size":"12||px","tshadow":"0|*|0|*|0|*|000000ab","afont":"Montserrat","lineheight":"1.2","bold":0,"italic":0,"underline":0,"align":"left"},{"color":"fc2828ff","afont":"Raleway,Arial","size":"25||px"},{}]}',
|
||||
'widget-thumbnail-description' => 0,
|
||||
'widget-thumbnail-description-font' => '{"data":[{"color":"ffffffff","size":"12||px","tshadow":"0|*|0|*|0|*|000000ab","afont":"Montserrat","lineheight":"1.3","bold":0,"italic":0,"underline":0,"align":"left"},{"color":"fc2828ff","afont":"Raleway,Arial","size":"25||px"},{}]}',
|
||||
'widget-thumbnail-caption-placement' => 'overlay',
|
||||
'widget-thumbnail-caption-size' => 100,
|
||||
'widget-thumbnail-group' => 1,
|
||||
'widget-thumbnail-orientation' => 'auto',
|
||||
'widget-thumbnail-size' => '100%',
|
||||
'widget-thumbnail-show-image' => 1,
|
||||
'widget-thumbnail-width' => 100,
|
||||
'widget-thumbnail-height' => 60,
|
||||
'widget-thumbnail-align-content' => 'start'
|
||||
);
|
||||
|
||||
|
||||
public function renderFields($container) {
|
||||
|
||||
$row1 = new FieldsetRow($container, 'widget-thumbnail-default-row-1');
|
||||
|
||||
new WidgetPosition($row1, 'widget-thumbnail-position', n2_('Position'));
|
||||
|
||||
new Select($row1, 'widget-thumbnail-align-content', n2_('Align thumbnails'), '', array(
|
||||
'options' => array(
|
||||
'start' => n2_('Start'),
|
||||
'center' => n2_('Center'),
|
||||
'end' => n2_('End'),
|
||||
'space-between' => n2_('Space between'),
|
||||
'space-around' => n2_('Space around')
|
||||
)
|
||||
));
|
||||
|
||||
new Style($row1, 'widget-thumbnail-style-bar', n2_('Bar'), '', array(
|
||||
'mode' => 'simple',
|
||||
'style2' => 'sliderwidget-thumbnail-style-slides',
|
||||
'preview' => 'SmartSliderAdminWidgetThumbnailBasic'
|
||||
));
|
||||
|
||||
new Style($row1, 'widget-thumbnail-style-slides', n2_('Thumbnail'), '', array(
|
||||
'mode' => 'dot',
|
||||
'style2' => 'sliderwidget-thumbnail-style-bar',
|
||||
'preview' => 'SmartSliderAdminWidgetThumbnailBasic'
|
||||
));
|
||||
|
||||
$rowCaption = new FieldsetRow($container, 'widget-thumbnail-default-row-caption');
|
||||
new Style($rowCaption, 'widget-thumbnail-title-style', n2_('Caption'), '', array(
|
||||
'mode' => 'simple',
|
||||
'post' => 'break',
|
||||
'font' => 'sliderwidget-thumbnail-title-font',
|
||||
'preview' => 'SmartSliderAdminWidgetThumbnailBasic'
|
||||
));
|
||||
|
||||
new OnOff($rowCaption, 'widget-thumbnail-title', n2_('Title'), '', array(
|
||||
'relatedFieldsOn' => array(
|
||||
'sliderwidget-thumbnail-title-font'
|
||||
)
|
||||
));
|
||||
new Font($rowCaption, 'widget-thumbnail-title-font', '', '', array(
|
||||
'mode' => 'simple',
|
||||
'style' => 'sliderwidget-thumbnail-title-style',
|
||||
'preview' => 'SmartSliderAdminWidgetThumbnailBasic'
|
||||
));
|
||||
|
||||
new OnOff($rowCaption, 'widget-thumbnail-description', n2_('Description'), '', array(
|
||||
'relatedFieldsOn' => array(
|
||||
'sliderwidget-thumbnail-description-font'
|
||||
)
|
||||
));
|
||||
new Font($rowCaption, 'widget-thumbnail-description-font', '', '', array(
|
||||
'mode' => 'simple',
|
||||
'style' => 'sliderwidget-thumbnail-title-style',
|
||||
'preview' => 'SmartSliderAdminWidgetThumbnailBasic'
|
||||
));
|
||||
|
||||
|
||||
new Select($rowCaption, 'widget-thumbnail-caption-placement', n2_('Placement'), '', array(
|
||||
'options' => array(
|
||||
'before' => n2_('Before'),
|
||||
'overlay' => n2_('Overlay'),
|
||||
'after' => n2_('After')
|
||||
)
|
||||
));
|
||||
|
||||
new Number($rowCaption, 'widget-thumbnail-caption-size', n2_('Size'), '', array(
|
||||
'wide' => 5,
|
||||
'unit' => 'px',
|
||||
'tipLabel' => n2_('Size'),
|
||||
'tipDescription' => n2_('The height (horizontal orientation) or width (vertical orientation) of the caption container.')
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public function prepareExport($export, $params) {
|
||||
|
||||
$export->addVisual($params->get($this->key . 'style-bar'));
|
||||
$export->addVisual($params->get($this->key . 'style-slides'));
|
||||
$export->addVisual($params->get($this->key . 'title-style'));
|
||||
|
||||
$export->addVisual($params->get($this->key . 'title-font'));
|
||||
$export->addVisual($params->get($this->key . 'description-font'));
|
||||
}
|
||||
|
||||
public function prepareImport($import, $params) {
|
||||
|
||||
$params->set($this->key . 'style-bar', $import->fixSection($params->get($this->key . 'style-bar', '')));
|
||||
$params->set($this->key . 'style-slides', $import->fixSection($params->get($this->key . 'style-slides', '')));
|
||||
$params->set($this->key . 'title-style', $import->fixSection($params->get($this->key . 'title-style', '')));
|
||||
|
||||
$params->set($this->key . 'title-font', $import->fixSection($params->get($this->key . 'title-font', '')));
|
||||
$params->set($this->key . 'description-font', $import->fixSection($params->get($this->key . 'description-font', '')));
|
||||
}
|
||||
}
|
@@ -0,0 +1,323 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget\Thumbnail\Basic;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\FastImageSize\FastImageSize;
|
||||
use Nextend\Framework\Filesystem\Filesystem;
|
||||
use Nextend\Framework\Misc\Base64;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
use Nextend\Framework\View\Html;
|
||||
use Nextend\SmartSlider3\Widget\AbstractWidgetFrontend;
|
||||
|
||||
class ThumbnailBasicFrontend extends AbstractWidgetFrontend {
|
||||
|
||||
private static $thumbnailTypes = array(
|
||||
'videoDark' => '<svg class="n2-thumbnail-dot-type" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><circle cx="24" cy="24" r="24" fill="#000" opacity=".6"/><path fill="#FFF" d="M19.8 32c-.124 0-.247-.028-.36-.08-.264-.116-.436-.375-.44-.664V16.744c.005-.29.176-.55.44-.666.273-.126.592-.1.84.07l10.4 7.257c.2.132.32.355.32.595s-.12.463-.32.595l-10.4 7.256c-.14.1-.31.15-.48.15z"/></svg>'
|
||||
);
|
||||
|
||||
public function __construct($sliderWidget, $widget, $params) {
|
||||
|
||||
parent::__construct($sliderWidget, $widget, $params);
|
||||
|
||||
$this->addToPlacement($this->key . 'position-', array(
|
||||
$this,
|
||||
'render'
|
||||
));
|
||||
}
|
||||
|
||||
public function render($attributes = array()) {
|
||||
|
||||
$slider = $this->slider;
|
||||
$id = $this->slider->elementId;
|
||||
$params = $this->params;
|
||||
|
||||
$showThumbnail = intval($params->get($this->key . 'show-image'));
|
||||
$showTitle = intval($params->get($this->key . 'title'));
|
||||
$showDescription = intval($params->get($this->key . 'description'));
|
||||
|
||||
if (!$showThumbnail && !$showTitle && !$showDescription) {
|
||||
// Nothing to show
|
||||
return '';
|
||||
}
|
||||
|
||||
$parameters = array(
|
||||
'action' => $params->get($this->key . 'action'),
|
||||
'minimumThumbnailCount' => max(1, intval($params->get($this->key . 'minimum-thumbnail-count')))
|
||||
);
|
||||
|
||||
$displayAttributes = $this->getDisplayAttributes($params, $this->key);
|
||||
|
||||
$barStyle = $slider->addStyle($params->get($this->key . 'style-bar'), 'simple');
|
||||
$slideStyle = $slider->addStyle($params->get($this->key . 'style-slides'), 'dot');
|
||||
|
||||
$width = intval($slider->params->get($this->key . 'width', 100));
|
||||
$height = intval($slider->params->get($this->key . 'height', 60));
|
||||
|
||||
$css = '';
|
||||
if ($showThumbnail) {
|
||||
$css .= 'div#' . $this->slider->elementId . ' .n2-thumbnail-dot img{width:' . $width . 'px;height:' . $height . 'px}';
|
||||
} else {
|
||||
$css .= 'div#' . $this->slider->elementId . ' .n2-thumbnail-dot{min-width:' . $width . 'px;min-height:' . $height . 'px}';
|
||||
}
|
||||
if (!empty($css)) {
|
||||
$this->slider->addDeviceCSS('all', $css);
|
||||
}
|
||||
|
||||
$tabletWidth = intval($slider->params->get($this->key . 'tablet-width', $width));
|
||||
$tabletHeight = intval($slider->params->get($this->key . 'tablet-height', $height));
|
||||
|
||||
if ($tabletWidth !== $width || $tabletHeight !== $height) {
|
||||
|
||||
$css = '';
|
||||
if ($showThumbnail) {
|
||||
$css .= 'div#' . $this->slider->elementId . ' .n2-thumbnail-dot img{width:' . $tabletWidth . 'px;height:' . $tabletHeight . 'px}';
|
||||
} else {
|
||||
$css .= 'div#' . $this->slider->elementId . ' .n2-thumbnail-dot{min-width:' . $tabletWidth . 'px;min-height:' . $tabletHeight . 'px}';
|
||||
}
|
||||
if (!empty($css)) {
|
||||
$this->slider->addDeviceCSS('tabletportrait', $css);
|
||||
$this->slider->addDeviceCSS('tabletlandscape', $css);
|
||||
}
|
||||
}
|
||||
|
||||
$mobileWidth = intval($slider->params->get($this->key . 'mobile-width', $width));
|
||||
$mobileHeight = intval($slider->params->get($this->key . 'mobile-height', $height));
|
||||
if ($mobileWidth !== $width || $mobileHeight !== $height) {
|
||||
|
||||
$css = '';
|
||||
if ($showThumbnail) {
|
||||
$css .= 'div#' . $this->slider->elementId . ' .n2-thumbnail-dot img{width:' . $mobileWidth . 'px;height:' . $mobileHeight . 'px}';
|
||||
} else {
|
||||
$css .= 'div#' . $this->slider->elementId . ' .n2-thumbnail-dot{min-width:' . $mobileWidth . 'px;min-height:' . $mobileHeight . 'px}';
|
||||
}
|
||||
if (!empty($css)) {
|
||||
$this->slider->addDeviceCSS('mobileportrait', $css);
|
||||
$this->slider->addDeviceCSS('mobilelandscape', $css);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$captionPlacement = $slider->params->get($this->key . 'caption-placement', 'overlay');
|
||||
if (!$showThumbnail) {
|
||||
$captionPlacement = 'before';
|
||||
}
|
||||
|
||||
if (!$showTitle && !$showDescription) {
|
||||
$captionPlacement = 'overlay';
|
||||
}
|
||||
|
||||
$captionSize = intval($slider->params->get($this->key . 'caption-size', 100));
|
||||
|
||||
|
||||
$orientation = $params->get($this->key . 'orientation');
|
||||
$orientation = $this->getOrientationByPosition($params->get($this->key . 'position-mode'), $params->get($this->key . 'position-area'), $orientation, 'vertical');
|
||||
|
||||
$captionExtraStyle = '';
|
||||
switch ($captionPlacement) {
|
||||
case 'before':
|
||||
case 'after':
|
||||
switch ($orientation) {
|
||||
case 'vertical':
|
||||
$captionExtraStyle .= "width: " . $captionSize . "px";
|
||||
break;
|
||||
default:
|
||||
$captionExtraStyle .= "height: " . $captionSize . "px";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ($orientation == 'vertical') {
|
||||
|
||||
Js::addStaticGroup(self::getAssetsPath() . '/dist/w-thumbnail-vertical.min.js', 'w-thumbnail-vertical');
|
||||
|
||||
$slider->features->addInitCallback('new _N2.SmartSliderWidgetThumbnailDefaultVertical(this, ' . json_encode($parameters) . ');');
|
||||
$slider->sliderType->addJSDependency('SmartSliderWidgetThumbnailDefaultVertical');
|
||||
} else {
|
||||
|
||||
Js::addStaticGroup(self::getAssetsPath() . '/dist/w-thumbnail-horizontal.min.js', 'w-thumbnail-horizontal');
|
||||
|
||||
$slider->features->addInitCallback('new _N2.SmartSliderWidgetThumbnailDefaultHorizontal(this, ' . json_encode($parameters) . ');');
|
||||
$slider->sliderType->addJSDependency('SmartSliderWidgetThumbnailDefaultHorizontal');
|
||||
}
|
||||
|
||||
$group = max(1, intval($params->get($this->key . 'group')));
|
||||
|
||||
$style = '';
|
||||
|
||||
$size = $params->get($this->key . 'size');
|
||||
if (is_numeric($size)) {
|
||||
$size .= '%';
|
||||
}
|
||||
if ($orientation == 'horizontal') {
|
||||
if (substr($size, -1) == '%' || substr($size, -2) == 'px') {
|
||||
$style .= 'width:' . $size . ';';
|
||||
if (substr($size, -1) == '%') {
|
||||
$attributes['data-width-percent'] = substr($size, 0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
$scrollerStyle = 'grid-template-rows:repeat(' . $group . ', 1fr)';
|
||||
} else {
|
||||
if (substr($size, -1) == '%' || substr($size, -2) == 'px') {
|
||||
$style .= 'height:' . $size . ';';
|
||||
}
|
||||
|
||||
$scrollerStyle = 'grid-template-columns:repeat(' . $group . ', 1fr)';
|
||||
}
|
||||
|
||||
$previous = $next = '';
|
||||
|
||||
$nextSizeAttributes = array();
|
||||
$previousSizeAttributes = array();
|
||||
|
||||
$showArrow = intval($slider->params->get($this->key . 'arrow', 1));
|
||||
if ($showArrow) {
|
||||
$arrowImagePrevious = $arrowImageNext = ResourceTranslator::toUrl($slider->params->get($this->key . 'arrow-image', ''));
|
||||
$arrowWidth = intval($slider->params->get($this->key . 'arrow-width', 26));
|
||||
$commonStyle = '';
|
||||
if (!empty($arrowWidth)) {
|
||||
$commonStyle = 'width:' . $arrowWidth . 'px;';
|
||||
}
|
||||
$previousStyle = $nextStyle = $commonStyle;
|
||||
if (empty($arrowImagePrevious)) {
|
||||
$image = self::getAssetsPath() . '/thumbnail-up-arrow.svg';
|
||||
FastImageSize::initAttributes($image, $previousSizeAttributes);
|
||||
$arrowImagePrevious = 'data:image/svg+xml;base64,' . Base64::encode(Filesystem::readFile($image));
|
||||
if ($orientation === 'horizontal') {
|
||||
$previousStyle .= 'transform:rotateZ(-90deg);';
|
||||
}
|
||||
} else {
|
||||
FastImageSize::initAttributes(ResourceTranslator::urlToResource($arrowImagePrevious), $previousSizeAttributes);
|
||||
switch ($orientation) {
|
||||
case 'vertical':
|
||||
$previousStyle .= 'transform:rotateY(180deg) rotateX(180deg);';
|
||||
break;
|
||||
default:
|
||||
$previousStyle .= 'transform:rotateZ(180deg);';
|
||||
}
|
||||
}
|
||||
if (empty($arrowImageNext)) {
|
||||
$image = self::getAssetsPath() . '/thumbnail-down-arrow.svg';
|
||||
FastImageSize::initAttributes($image, $nextSizeAttributes);
|
||||
$arrowImageNext = 'data:image/svg+xml;base64,' . Base64::encode(Filesystem::readFile($image));
|
||||
if ($orientation === 'horizontal') {
|
||||
$nextStyle .= 'transform:rotateZ(-90deg);';
|
||||
}
|
||||
} else {
|
||||
$nextStyle .= 'transform:none;';
|
||||
FastImageSize::initAttributes(ResourceTranslator::urlToResource($arrowImageNext), $nextSizeAttributes);
|
||||
}
|
||||
|
||||
$previous = Html::tag('div', array(
|
||||
'class' => 'nextend-thumbnail-button nextend-thumbnail-previous'
|
||||
), Html::image($arrowImagePrevious, $slider->params->get($this->key . 'arrow-prev-alt', 'previous arrow'), $previousSizeAttributes + Html::addExcludeLazyLoadAttributes(array(
|
||||
'style' => $previousStyle,
|
||||
'loading' => 'lazy'
|
||||
))));
|
||||
$next = Html::tag('div', array(
|
||||
'class' => 'nextend-thumbnail-button nextend-thumbnail-next'
|
||||
), Html::image($arrowImageNext, $slider->params->get($this->key . 'arrow-next-alt', 'next arrow'), $nextSizeAttributes + Html::addExcludeLazyLoadAttributes(array(
|
||||
'style' => $nextStyle,
|
||||
'loading' => 'lazy'
|
||||
))));
|
||||
}
|
||||
|
||||
$captionStyle = '';
|
||||
if ($showTitle || $showDescription) {
|
||||
$captionStyle = $slider->addStyle($params->get($this->key . 'title-style'), 'simple');
|
||||
}
|
||||
|
||||
$titleFont = '';
|
||||
if ($showTitle) {
|
||||
$titleFont = $slider->addFont($params->get($this->key . 'title-font'), 'simple');
|
||||
}
|
||||
|
||||
$descriptionFont = '';
|
||||
if ($showDescription) {
|
||||
$descriptionFont = $slider->addFont($params->get($this->key . 'description-font'), 'simple');
|
||||
}
|
||||
|
||||
$dots = array();
|
||||
$slides = $slider->getSlides();
|
||||
foreach ($slides as $slide) {
|
||||
|
||||
$dotHTML = array();
|
||||
|
||||
if ($showThumbnail) {
|
||||
|
||||
$dotHTML[] = $slide->renderThumbnailImage($width, $height, array(
|
||||
'alt' => $slide->getThumbnailAltDynamic()
|
||||
));
|
||||
|
||||
$thumbnailType = $slide->getThumbnailType();
|
||||
if (isset(self::$thumbnailTypes[$thumbnailType])) {
|
||||
$dotHTML[] = self::$thumbnailTypes[$thumbnailType];
|
||||
}
|
||||
}
|
||||
|
||||
if ($showTitle || $showDescription) {
|
||||
$captionHTML = '';
|
||||
if ($showTitle) {
|
||||
$title = $slide->getTitle();
|
||||
if (!empty($title)) {
|
||||
$captionHTML .= '<div class="' . $titleFont . '">' . $title . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($showDescription) {
|
||||
$description = $slide->getDescription();
|
||||
if (!empty($description)) {
|
||||
$captionHTML .= '<div class="' . $descriptionFont . '">' . $description . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($captionHTML)) {
|
||||
$dotHTML[] = Html::tag('div', array(
|
||||
'class' => $captionStyle . ' n2-ss-caption n2-ow n2-caption-' . $captionPlacement,
|
||||
'style' => $captionExtraStyle
|
||||
), $captionHTML);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$dots[] = Html::tag('div', $slide->showOnAttributes + array(
|
||||
'class' => 'n2-thumbnail-dot ' . $slideStyle,
|
||||
'data-slide-public-id' => $slide->getPublicID(),
|
||||
'role' => 'button',
|
||||
'aria-label' => $slide->getTitle(),
|
||||
'tabindex' => '0'
|
||||
), implode('', $dotHTML));
|
||||
}
|
||||
|
||||
$slider->addLess(self::getAssetsPath() . '/style.n2less', array(
|
||||
"sliderid" => $slider->elementId
|
||||
));
|
||||
|
||||
return Html::tag('div', Html::mergeAttributes($attributes, $displayAttributes, array(
|
||||
'class' => 'nextend-thumbnail nextend-thumbnail-default nextend-thumbnail-' . $orientation . ' n2-ow-all',
|
||||
'data-has-next' => 0,
|
||||
'data-has-previous' => 0,
|
||||
'style' => $style
|
||||
)), Html::tag('div', array(
|
||||
'class' => 'nextend-thumbnail-inner ' . $barStyle
|
||||
), Html::tag('div', array(
|
||||
'class' => 'nextend-thumbnail-scroller n2-align-content-' . $params->get('widget-thumbnail-align-content'),
|
||||
'style' => $scrollerStyle
|
||||
), implode('', $dots))) . $previous . $next);
|
||||
}
|
||||
|
||||
protected function translateArea($area) {
|
||||
|
||||
if ($area == 5) {
|
||||
return 'left';
|
||||
} else if ($area == 8) {
|
||||
return 'right';
|
||||
}
|
||||
|
||||
return parent::translateArea($area);
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget;
|
||||
|
||||
use Nextend\Framework\Pattern\PluggableTrait;
|
||||
use Nextend\Framework\Pattern\SingletonTrait;
|
||||
use Nextend\SmartSlider3\Widget\Group\AbstractWidgetGroup;
|
||||
use Nextend\SmartSlider3\Widget\Group\Arrow;
|
||||
use Nextend\SmartSlider3\Widget\Group\Autoplay;
|
||||
use Nextend\SmartSlider3\Widget\Group\Bar;
|
||||
use Nextend\SmartSlider3\Widget\Group\Bullet;
|
||||
use Nextend\SmartSlider3\Widget\Group\Shadow;
|
||||
use Nextend\SmartSlider3\Widget\Group\Thumbnail;
|
||||
|
||||
class WidgetGroupFactory {
|
||||
|
||||
use SingletonTrait, PluggableTrait;
|
||||
|
||||
/** @var AbstractWidgetGroup[] */
|
||||
private static $groups = array();
|
||||
|
||||
protected function init() {
|
||||
|
||||
new Arrow();
|
||||
new Autoplay();
|
||||
new Bar();
|
||||
new Bullet();
|
||||
new Shadow();
|
||||
new Thumbnail();
|
||||
|
||||
$this->makePluggable('SliderWidgetGroup');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractWidgetGroup $group
|
||||
*/
|
||||
public static function addGroup($group) {
|
||||
self::$groups[$group->getName()] = $group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractWidgetGroup[]
|
||||
*/
|
||||
public static function getGroups() {
|
||||
return self::$groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return AbstractWidgetGroup
|
||||
*/
|
||||
public static function getGroup($name) {
|
||||
return self::$groups[$name];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WidgetGroupFactory::getInstance();
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget;
|
||||
|
||||
|
||||
class WidgetPlacement {
|
||||
|
||||
protected $name;
|
||||
|
||||
protected $items = array();
|
||||
|
||||
public function __construct($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function empty() {
|
||||
|
||||
return empty($this->items);
|
||||
}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget;
|
||||
|
||||
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class WidgetPlacementAdvanced extends WidgetPlacement {
|
||||
|
||||
protected $items = array();
|
||||
|
||||
protected $variables = array();
|
||||
|
||||
public function add($renderCallback, $horizontalSide, $horizontalPosition, $horizontalUnit, $verticalSide, $verticalPosition, $verticalUnit) {
|
||||
|
||||
$attributes = array(
|
||||
'style' => ''
|
||||
);
|
||||
|
||||
$transforms = array();
|
||||
|
||||
if (is_numeric($horizontalPosition)) {
|
||||
$attributes['style'] .= $horizontalSide . ':' . $horizontalPosition . $horizontalUnit . ';';
|
||||
} else {
|
||||
$attributes['style'] .= $horizontalSide . ':0;';
|
||||
|
||||
$transforms[] = 'translateX(' . $this->toCSSCalc($horizontalSide == 'left' ? 1 : -1, $horizontalPosition) . ')';
|
||||
}
|
||||
|
||||
if (is_numeric($verticalPosition)) {
|
||||
$attributes['style'] .= $verticalSide . ':' . $verticalPosition . $verticalUnit . ';';
|
||||
} else {
|
||||
$attributes['style'] .= $verticalSide . ':0;';
|
||||
|
||||
$transforms[] = 'translateY(' . $this->toCSSCalc($verticalSide == 'top' ? 1 : -1, $verticalPosition) . ')';
|
||||
}
|
||||
|
||||
if (!empty($transforms)) {
|
||||
$attributes['style'] .= 'transform:' . implode(' ', $transforms) . ';';
|
||||
}
|
||||
|
||||
$this->items[] = array(
|
||||
'renderCallback' => $renderCallback,
|
||||
'attributes' => $attributes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function render() {
|
||||
|
||||
$out = '';
|
||||
foreach ($this->items as $item) {
|
||||
$out .= call_user_func($item['renderCallback'], $item['attributes']);
|
||||
}
|
||||
|
||||
if (!empty($out)) {
|
||||
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2-ss-slider-controls n2-ss-slider-controls-' . $this->name,
|
||||
'data-variables' => implode(',', array_unique($this->variables))
|
||||
), $out);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
private function toCSSCalc($modifier, $expression) {
|
||||
|
||||
// Remove whitespaces
|
||||
$expression = preg_replace('/\s+/', '', $expression);
|
||||
|
||||
// take care of minus symbol on single number
|
||||
$expression = preg_replace('/([+\-*\/])[\-]/', '$1[minus]', $expression);
|
||||
|
||||
$expression = preg_replace('/[+\-*\/]/', ' $0 ', $expression);
|
||||
|
||||
$expression = str_replace('[minus]', '-1 * ', $expression);
|
||||
|
||||
preg_match_all('/[a-zA-Z][a-zA-Z0-9]*/', $expression, $matches);
|
||||
|
||||
foreach ($matches as $match) {
|
||||
if (!empty($match)) {
|
||||
$this->variables = array_merge($this->variables, $match);
|
||||
}
|
||||
}
|
||||
|
||||
$expression = preg_replace('/[a-zA-Z][a-zA-Z0-9]*/', 'var(--$0, 0)', $expression);
|
||||
|
||||
return 'calc(' . $modifier . 'px * (' . $expression . '))';
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Widget;
|
||||
|
||||
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class WidgetPlacementSimple extends WidgetPlacement {
|
||||
|
||||
public function add($renderCallback, $stack, $offset = 0) {
|
||||
|
||||
$this->items[] = array(
|
||||
'stack' => $stack,
|
||||
'renderCallback' => $renderCallback,
|
||||
'offset' => $offset
|
||||
);
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
usort($this->items, function ($a, $b) {
|
||||
if ($a['stack'] == $b['stack']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($a['stack'] < $b['stack']) ? -1 : 1;
|
||||
});
|
||||
|
||||
$out = '';
|
||||
foreach ($this->items as $item) {
|
||||
$attributes = array();
|
||||
if ($item['offset'] != 0) {
|
||||
$attributes['style'] = '--widget-offset:' . $item['offset'] . 'px;';
|
||||
}
|
||||
$out .= call_user_func($item['renderCallback'], $attributes);
|
||||
}
|
||||
|
||||
if (!empty($out)) {
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2-ss-slider-controls n2-ss-slider-controls-' . $this->name
|
||||
), $out);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user