first
This commit is contained in:
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Align {
|
||||
|
||||
private $slider;
|
||||
|
||||
public $align = 'normal';
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$this->align = $slider->params->get('align', 'normal');
|
||||
}
|
||||
|
||||
public function renderSlider($sliderHTML, $maxWidth) {
|
||||
|
||||
$htmlOptions = array(
|
||||
"id" => $this->slider->elementId . '-align',
|
||||
"class" => "n2-ss-align",
|
||||
"encode" => false
|
||||
);
|
||||
|
||||
$htmlOptionsPadding = array(
|
||||
"class" => 'n2-padding'
|
||||
);
|
||||
|
||||
if (!$this->slider->features->responsive->scaleUp && $this->align != 'normal') {
|
||||
switch ($this->align) {
|
||||
case 'left':
|
||||
case 'right':
|
||||
$width = $this->slider->assets->sizes['width'];
|
||||
$htmlOptions["style"] = "float: {$this->align}; width: {$width}px; max-width:100%;";
|
||||
break;
|
||||
case 'center':
|
||||
$htmlOptions["style"] = "margin: 0 auto; max-width: {$maxWidth}px;";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$sliderHTML = Html::tag("div", $htmlOptions, Html::tag("div", $htmlOptionsPadding, $sliderHTML));
|
||||
|
||||
if ($this->slider->params->get('clear-both-after', 1)) {
|
||||
$sliderHTML .= Html::tag("div", array("class" => "n2_clear"), "");
|
||||
}
|
||||
|
||||
return $sliderHTML;
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
$properties['align'] = $this->align;
|
||||
$properties['isDelayed'] = intval($this->slider->params->get('is-delayed', 0));
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
use Nextend\Framework\Data\Data;
|
||||
use Nextend\Framework\Parser\Common;
|
||||
use Nextend\SmartSlider3\Slider\Slider;
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Autoplay {
|
||||
|
||||
/**
|
||||
* @var Slider
|
||||
*/
|
||||
private $slider;
|
||||
|
||||
public $isEnabled = 0, $isStart = 0, $duration = 8000;
|
||||
public $isLoop = 1, $interval = 1, $intervalModifier = 'loop', $intervalSlide = 'current', $allowReStart = 0;
|
||||
public $stopOnClick = 1, $stopOnMediaStarted = 1;
|
||||
public $resumeOnMediaEnded = 1, $resumeOnSlideChanged = 0;
|
||||
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
$params = $slider->params;
|
||||
|
||||
$this->isEnabled = intval($params->get('autoplay', 0));
|
||||
$this->isStart = intval($params->get('autoplayStart', 1));
|
||||
$this->duration = intval($params->get('autoplayDuration', 8000));
|
||||
|
||||
if ($this->duration < 1) {
|
||||
$this->duration = 1500;
|
||||
}
|
||||
|
||||
list($this->interval, $this->intervalModifier, $this->intervalSlide) = (array)Common::parse($slider->params->get('autoplayfinish', '1|*|loop|*|current'));
|
||||
|
||||
$this->allowReStart = intval($params->get('autoplayAllowReStart', 0));
|
||||
|
||||
$this->isLoop = intval($params->get('autoplayLoop', 1));
|
||||
|
||||
$this->interval = intval($this->interval);
|
||||
|
||||
$this->stopOnClick = intval($params->get('autoplayStopClick', 1));
|
||||
$this->stopOnMouse = $params->get('autoplayStopMouse', 'enter');
|
||||
$this->stopOnMediaStarted = intval($params->get('autoplayStopMedia', 1));
|
||||
|
||||
|
||||
$this->resumeOnClick = intval($params->get('autoplayResumeClick', 0));
|
||||
$this->resumeOnMouse = $params->get('autoplayResumeMouse', 0);
|
||||
$this->resumeOnMediaEnded = intval($params->get('autoplayResumeMedia', 1));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
$properties['autoplay'] = array(
|
||||
'enabled' => $this->isEnabled,
|
||||
'start' => $this->isStart,
|
||||
'duration' => $this->duration,
|
||||
'autoplayLoop' => $this->isLoop,
|
||||
'allowReStart' => $this->allowReStart,
|
||||
'pause' => array(
|
||||
'click' => $this->stopOnClick,
|
||||
'mouse' => $this->stopOnMouse,
|
||||
'mediaStarted' => $this->stopOnMediaStarted
|
||||
),
|
||||
'resume' => array(
|
||||
'click' => $this->resumeOnClick,
|
||||
'mouse' => $this->resumeOnMouse,
|
||||
'mediaEnded' => $this->resumeOnMediaEnded,
|
||||
'slidechanged' => $this->resumeOnSlideChanged
|
||||
),
|
||||
'interval' => $this->interval,
|
||||
'intervalModifier' => $this->intervalModifier,
|
||||
'intervalSlide' => $this->intervalSlide
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* For compatibility with legacy autoplay values.
|
||||
*
|
||||
* @param Data $params
|
||||
*/
|
||||
protected function upgradeData($params) {
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
class BlockRightClick {
|
||||
|
||||
private $slider;
|
||||
|
||||
public $isEnabled = 0;
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$this->isEnabled = intval($slider->params->get('blockrightclick', 0));
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
|
||||
$properties['blockrightclick'] = $this->isEnabled;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
class Controls {
|
||||
|
||||
private $slider;
|
||||
|
||||
private $mousewheel = 0;
|
||||
|
||||
public $drag = 0;
|
||||
|
||||
public $touch = 1;
|
||||
|
||||
public $keyboard = 0;
|
||||
|
||||
public $blockCarouselInteraction = 1;
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$this->mousewheel = intval($slider->params->get('controlsScroll', 0));
|
||||
$this->keyboard = intval($slider->params->get('controlsKeyboard', 1));
|
||||
$this->blockCarouselInteraction = intval($slider->params->get('controlsBlockCarouselInteraction', 1));
|
||||
$this->touch = $slider->params->get('controlsTouch', 'horizontal');
|
||||
if ($slider->getSlidesCount() < 2) {
|
||||
$this->touch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
$properties['controls'] = array(
|
||||
'mousewheel' => $this->mousewheel,
|
||||
'touch' => $this->touch,
|
||||
'keyboard' => $this->keyboard,
|
||||
'blockCarouselInteraction' => $this->blockCarouselInteraction
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
use Nextend\SmartSlider3\Settings;
|
||||
use Nextend\SmartSlider3\Slider\Slider;
|
||||
|
||||
class Focus {
|
||||
|
||||
/**
|
||||
* @var Slider
|
||||
*/
|
||||
private $slider;
|
||||
|
||||
private $focusOffsetTop = '';
|
||||
|
||||
private $focusOffsetBottom = '';
|
||||
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
$responsiveHeightOffsetValue = '#wpadminbar';
|
||||
|
||||
$this->focusOffsetTop = Settings::get('responsive-focus-top', $responsiveHeightOffsetValue);
|
||||
$this->focusOffsetBottom = Settings::get('responsive-focus-bottom', '');
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
$properties['responsive']['focus'] = array(
|
||||
'offsetTop' => $this->focusOffsetTop,
|
||||
'offsetBottom' => $this->focusOffsetBottom
|
||||
);
|
||||
|
||||
$params = $this->slider->params;
|
||||
|
||||
if ($params->get('responsive-mode') == 'fullpage') {
|
||||
if (!$params->has('responsive-focus') && $params->has('responsiveHeightOffset')) {
|
||||
$old = $params->get('responsiveHeightOffset');
|
||||
|
||||
$oldDefault = '';
|
||||
$oldDefault = '#wpadminbar';
|
||||
|
||||
|
||||
if ($old !== $oldDefault) {
|
||||
$params->set('responsive-focus', 1);
|
||||
$params->set('responsive-focus-top', $old);
|
||||
}
|
||||
}
|
||||
|
||||
if ($params->get('responsive-focus', 0)) {
|
||||
$properties['responsive']['focus'] = array(
|
||||
'offsetTop' => $params->get('responsive-focus-top', ''),
|
||||
'offsetBottom' => $params->get('responsive-focus-bottom', '')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
class LayerMode {
|
||||
|
||||
private $slider;
|
||||
|
||||
public $playOnce = 0;
|
||||
|
||||
public $playFirstLayer = 1;
|
||||
|
||||
public $mode = 'skippable';
|
||||
|
||||
public $inAnimation = 'mainInEnd';
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$this->playOnce = intval($slider->params->get('playonce', 0));
|
||||
|
||||
$this->playFirstLayer = intval($slider->params->get('playfirstlayer', 1));
|
||||
|
||||
switch ($slider->params->get('layer-animation-play-mode', 'skippable')) {
|
||||
case 'forced':
|
||||
$this->mode = 'forced';
|
||||
break;
|
||||
default:
|
||||
$this->mode = 'skippable';
|
||||
}
|
||||
|
||||
switch ($slider->params->get('layer-animation-play-in', 'end')) {
|
||||
case 'end':
|
||||
$this->inAnimation = 'mainInEnd';
|
||||
break;
|
||||
default:
|
||||
$this->inAnimation = 'mainInStart';
|
||||
}
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
$params = $this->slider->params;
|
||||
$properties['perspective'] = max(0, intval($params->get('perspective', 1500)));
|
||||
|
||||
$properties['layerMode'] = array(
|
||||
'playOnce' => $this->playOnce,
|
||||
'playFirstLayer' => $this->playFirstLayer,
|
||||
'mode' => $this->mode,
|
||||
'inAnimation' => $this->inAnimation
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class LazyLoad {
|
||||
|
||||
private $slider;
|
||||
|
||||
public $isEnabled = 0, $neighborCount = 0, $layerImageOptimize = 0, $layerImageWidthNormal = 1400, $layerImageWidthTablet = 800, $layerImageWidthMobile = 425;
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$this->isEnabled = intval($slider->params->get('imageload', 0));
|
||||
$this->neighborCount = intval($slider->params->get('imageloadNeighborSlides', 0));
|
||||
|
||||
$this->layerImageOptimize = intval($slider->params->get('layer-image-optimize', 0)) && !$slider->isAdmin;
|
||||
if ($this->layerImageOptimize) {
|
||||
$this->layerImageWidthNormal = $slider->params->get('layer-image-width-normal', 1400);
|
||||
$this->layerImageWidthTablet = $slider->params->get('layer-image-width-tablet', 800);
|
||||
$this->layerImageWidthMobile = $slider->params->get('layer-image-width-mobile', 425);
|
||||
}
|
||||
|
||||
$this->layerImageSizeBase64 = intval($slider->params->get('layer-image-base64', 0)) && !$slider->isAdmin;
|
||||
$this->layerImageSizeBase64Size = max(0, intval($slider->params->get('layer-image-base64-size', 5))) * 1024;
|
||||
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
|
||||
$properties['lazyLoad'] = $this->isEnabled;
|
||||
$properties['lazyLoadNeighbor'] = $this->neighborCount;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
class MaintainSession {
|
||||
|
||||
private $slider;
|
||||
|
||||
public $isEnabled = 0;
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$this->isEnabled = intval($slider->params->get('maintain-session', 0));
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
|
||||
$properties['maintainSession'] = $this->isEnabled;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
use Nextend\Framework\Platform\Platform;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Margin {
|
||||
|
||||
private $slider;
|
||||
|
||||
private $margin;
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$this->margin = explode('|*|', $slider->params->get('margin', '0|*|0|*|0|*|0'));
|
||||
}
|
||||
|
||||
public function renderSlider($sliderHTML) {
|
||||
if (!Platform::isAdmin() && count($this->margin) >= 4) {
|
||||
array_splice($this->margin, 4);
|
||||
if ($this->margin[0] != 0 || $this->margin[1] != 0 || $this->margin[2] != 0 || $this->margin[3] != 0) {
|
||||
$sliderHTML = Html::tag("div", array(
|
||||
"class" => "n2-ss-margin",
|
||||
"encode" => false,
|
||||
"style" => "margin: " . implode('px ', $this->margin) . "px;"
|
||||
), $sliderHTML);
|
||||
}
|
||||
}
|
||||
|
||||
return $sliderHTML;
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Nextend\Framework\FastImageSize\FastImageSize;
|
||||
use Nextend\Framework\Image\ImageEdit;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
|
||||
class Optimize {
|
||||
|
||||
private $slider;
|
||||
|
||||
private $playWhenVisible = 1;
|
||||
|
||||
private $playWhenVisibleAt = 0.5;
|
||||
|
||||
private $backgroundImageWidthNormal = 1920, $quality = 70, $thumbnailWidth = 100, $thumbnailHeight = 60, $thumbnailQuality = 70;
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$this->playWhenVisible = intval($slider->params->get('playWhenVisible', 1));
|
||||
$this->playWhenVisibleAt = max(0, min(100, intval($slider->params->get('playWhenVisibleAt', 50)))) / 100;
|
||||
|
||||
$this->backgroundImageWidthNormal = intval($slider->params->get('optimize-slide-width-normal', 1920));
|
||||
$this->quality = intval($slider->params->get('optimize-quality', 70));
|
||||
|
||||
$this->thumbnailWidth = $slider->params->get('optimizeThumbnailWidth', 100);
|
||||
$this->thumbnailHeight = $slider->params->get('optimizeThumbnailHeight', 60);
|
||||
$this->thumbnailQuality = $slider->params->get('optimize-thumbnail-quality', 70);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
$properties['playWhenVisible'] = $this->playWhenVisible;
|
||||
$properties['playWhenVisibleAt'] = $this->playWhenVisibleAt;
|
||||
}
|
||||
|
||||
public function optimizeBackground($image, $x = 50, $y = 50) {
|
||||
try {
|
||||
$imageSize = FastImageSize::getSize($image);
|
||||
if ($imageSize) {
|
||||
$optimizeScale = $this->slider->params->get('optimize-scale', 0);
|
||||
|
||||
$targetWidth = $imageSize['width'];
|
||||
$targetHeight = $imageSize['height'];
|
||||
if ($optimizeScale && $targetWidth > $this->backgroundImageWidthNormal) {
|
||||
$targetHeight = ceil($this->backgroundImageWidthNormal / $targetWidth * $targetHeight);
|
||||
$targetWidth = $this->backgroundImageWidthNormal;
|
||||
}
|
||||
|
||||
return ImageEdit::resizeImage('slider/cache', ResourceTranslator::toPath($image), $targetWidth, $targetHeight, false, 'normal', 'ffffff', true, $this->quality, true, $x, $y);
|
||||
}
|
||||
|
||||
return $image;
|
||||
|
||||
} catch (Exception $e) {
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
|
||||
public function optimizeThumbnail($image) {
|
||||
if ($this->slider->params->get('optimize-thumbnail-scale', 0)) {
|
||||
try {
|
||||
return ImageEdit::resizeImage('slider/cache', ResourceTranslator::toPath($image), $this->thumbnailWidth, $this->thumbnailHeight, false, 'normal', 'ffffff', true, $this->thumbnailQuality, true);
|
||||
} catch (Exception $e) {
|
||||
|
||||
return ResourceTranslator::toUrl($image);
|
||||
}
|
||||
}
|
||||
|
||||
return ResourceTranslator::toUrl($image);
|
||||
}
|
||||
|
||||
public function adminOptimizeThumbnail($image) {
|
||||
if ($this->slider->params->get('optimize-thumbnail-scale', 0)) {
|
||||
try {
|
||||
return ImageEdit::resizeImage('slider/cache', ResourceTranslator::toPath($image), $this->thumbnailWidth, $this->thumbnailHeight, true, 'normal', 'ffffff', true, $this->thumbnailQuality, true);
|
||||
} catch (Exception $e) {
|
||||
|
||||
return ResourceTranslator::toUrl($image);
|
||||
}
|
||||
}
|
||||
|
||||
return ResourceTranslator::toUrl($image);
|
||||
}
|
||||
|
||||
|
||||
public function optimizeImageWebP($src, $options) {
|
||||
|
||||
$options = array_merge(array(
|
||||
'optimize' => false,
|
||||
'quality' => 70,
|
||||
'resize' => false,
|
||||
'defaultWidth' => 1920,
|
||||
'mediumWidth' => 1200,
|
||||
'mediumHeight' => 0,
|
||||
'smallWidth' => 500,
|
||||
'smallHeight' => 0,
|
||||
'focusX' => 50,
|
||||
'focusY' => 50,
|
||||
'compressOriginal' => false
|
||||
), $options);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
use Nextend\Framework\Model\Section;
|
||||
use Nextend\Framework\Parser\Common;
|
||||
use Nextend\SmartSlider3\Slider\Slide;
|
||||
use Nextend\SmartSlider3Pro\PostBackgroundAnimation\PostBackgroundAnimationStorage;
|
@ -0,0 +1,752 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
use Nextend\Framework\Data\Data;
|
||||
use Nextend\SmartSlider3\Application\Admin\Settings\ViewSettingsGeneral;
|
||||
use Nextend\SmartSlider3\Settings;
|
||||
use Nextend\SmartSlider3\Slider\ResponsiveType\AbstractResponsiveTypeFrontend;
|
||||
use Nextend\SmartSlider3\Slider\ResponsiveType\ResponsiveTypeFactory;
|
||||
use Nextend\SmartSlider3\Slider\Slider;
|
||||
use Nextend\SmartSlider3\SmartSlider3Info;
|
||||
|
||||
class Responsive {
|
||||
|
||||
/** @var Slider */
|
||||
public $slider;
|
||||
|
||||
/**
|
||||
* @var AbstractResponsiveTypeFrontend
|
||||
*/
|
||||
protected $responsivePlugin;
|
||||
|
||||
protected $hideOnDesktopLandscape = 1;
|
||||
protected $hideOnDesktopPortrait = 1;
|
||||
|
||||
protected $hideOnTabletLandscape = 1;
|
||||
protected $hideOnTabletPortrait = 1;
|
||||
|
||||
protected $hideOnMobileLandscape = 1;
|
||||
protected $hideOnMobilePortrait = 1;
|
||||
|
||||
public $onResizeEnabled = 1;
|
||||
|
||||
public $type = 'auto';
|
||||
|
||||
public $scaleDown = 1;
|
||||
|
||||
public $scaleUp = 1;
|
||||
|
||||
public $forceFull = 0;
|
||||
|
||||
public $forceFullOverflowX = 'body';
|
||||
|
||||
public $forceFullHorizontalSelector = '';
|
||||
|
||||
public $minimumHeight = -1;
|
||||
|
||||
public $maximumSlideWidthLandscape = -1;
|
||||
public $maximumSlideWidth = 10000;
|
||||
public $maximumSlideWidthTabletLandscape = -1;
|
||||
public $maximumSlideWidthTablet = -1;
|
||||
public $maximumSlideWidthMobileLandscape = -1;
|
||||
public $maximumSlideWidthMobile = -1;
|
||||
|
||||
public $sliderHeightBasedOn = 'real';
|
||||
public $responsiveDecreaseSliderHeight = 0;
|
||||
|
||||
public $focusUser = 1;
|
||||
|
||||
public $focusEdge = 'auto';
|
||||
|
||||
protected $enabledDevices = array(
|
||||
'desktopLandscape' => 0,
|
||||
'desktopPortrait' => 1,
|
||||
'tabletLandscape' => 0,
|
||||
'tabletPortrait' => 1,
|
||||
'mobileLandscape' => 0,
|
||||
'mobilePortrait' => 1
|
||||
);
|
||||
|
||||
protected $breakpoints = array();
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
*/
|
||||
public $mediaQueries = array(
|
||||
'all' => false
|
||||
);
|
||||
|
||||
public $sizes = array(
|
||||
'desktopPortrait' => array(
|
||||
'width' => 800,
|
||||
'height' => 600
|
||||
),
|
||||
);
|
||||
|
||||
public static $translation = array(
|
||||
'desktoplandscape' => 'desktopLandscape',
|
||||
'desktopportrait' => 'desktopPortrait',
|
||||
'tabletlandscape' => 'tabletLandscape',
|
||||
'tabletportrait' => 'tabletPortrait',
|
||||
'mobilelandscape' => 'mobileLandscape',
|
||||
'mobileportrait' => 'mobilePortrait'
|
||||
);
|
||||
|
||||
public function __construct($slider, $features) {
|
||||
|
||||
$this->slider = $slider;
|
||||
|
||||
$this->hideOnDesktopLandscape = !intval($slider->params->get('desktoplandscape', 1));
|
||||
$this->hideOnDesktopPortrait = !intval($slider->params->get('desktopportrait', 1));
|
||||
|
||||
$this->hideOnTabletLandscape = !intval($slider->params->get('tabletlandscape', 1));
|
||||
$this->hideOnTabletPortrait = !intval($slider->params->get('tabletportrait', 1));
|
||||
|
||||
$this->hideOnMobileLandscape = !intval($slider->params->get('mobilelandscape', 1));
|
||||
$this->hideOnMobilePortrait = !intval($slider->params->get('mobileportrait', 1));
|
||||
|
||||
|
||||
$this->focusUser = intval($slider->params->get('responsiveFocusUser', 1));
|
||||
|
||||
$this->focusEdge = $slider->params->get('responsiveFocusEdge', 'auto');
|
||||
|
||||
$this->responsivePlugin = ResponsiveTypeFactory::createFrontend($slider->params->get('responsive-mode', 'auto'), $this);
|
||||
$this->type = $this->responsivePlugin->getType();
|
||||
$this->responsivePlugin->parse($slider->params, $this, $features);
|
||||
|
||||
$this->onResizeEnabled = !$slider->disableResponsive;
|
||||
|
||||
if (!$this->scaleDown && !$this->scaleUp) {
|
||||
$this->onResizeEnabled = 0;
|
||||
}
|
||||
|
||||
$overrideSizeEnabled = !!$slider->params->get('slider-size-override', 0);
|
||||
|
||||
$this->sizes['desktopPortrait']['width'] = max(10, intval($slider->params->get('width', 1200)));
|
||||
$this->sizes['desktopPortrait']['height'] = max(10, intval($slider->params->get('height', 600)));
|
||||
|
||||
$heightHelperRatio = $this->sizes['desktopPortrait']['height'] / $this->sizes['desktopPortrait']['width'];
|
||||
|
||||
$this->enabledDevices['desktopLandscape'] = intval($slider->params->get('responsive-breakpoint-desktop-landscape-enabled', 0));
|
||||
$this->enabledDevices['tabletLandscape'] = intval($slider->params->get('responsive-breakpoint-tablet-landscape-enabled', 0));
|
||||
$this->enabledDevices['tabletPortrait'] = intval($slider->params->get('responsive-breakpoint-tablet-portrait-enabled', 1));
|
||||
$this->enabledDevices['mobileLandscape'] = intval($slider->params->get('responsive-breakpoint-mobile-landscape-enabled', 0));
|
||||
$this->enabledDevices['mobilePortrait'] = intval($slider->params->get('responsive-breakpoint-mobile-portrait-enabled', 1));
|
||||
|
||||
$useLocalBreakpoints = !$slider->params->get('responsive-breakpoint-global', 0);
|
||||
|
||||
$landscapePortraitWidth = $breakpointWidthLandscape = 3001;
|
||||
$previousSize = false;
|
||||
|
||||
if ($this->enabledDevices['desktopLandscape']) {
|
||||
|
||||
$landscapePortraitWidth = $breakpointWidthPortrait = intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-desktop-portrait', ViewSettingsGeneral::defaults['desktop-large-portrait']) : Settings::get('responsive-screen-width-desktop-portrait', ViewSettingsGeneral::defaults['desktop-large-portrait']));
|
||||
$breakpointWidthLandscape = max($landscapePortraitWidth, intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-desktop-portrait-landscape', ViewSettingsGeneral::defaults['desktop-large-landscape']) : Settings::get('responsive-screen-width-desktop-portrait-landscape', ViewSettingsGeneral::defaults['desktop-large-landscape'])));
|
||||
|
||||
$this->breakpoints[] = array(
|
||||
'device' => 'desktopLandscape',
|
||||
'type' => 'min-screen-width',
|
||||
'portraitWidth' => $breakpointWidthPortrait,
|
||||
'landscapeWidth' => $breakpointWidthLandscape
|
||||
);
|
||||
|
||||
$editorWidth = intval($slider->params->get('desktop-landscape-width', 1440));
|
||||
|
||||
if ($overrideSizeEnabled && $slider->params->get('slider-size-override-desktop-landscape', 0) && $editorWidth > 10) {
|
||||
|
||||
$customHeight = false;
|
||||
$editorHeight = intval($slider->params->get('desktop-landscape-height', 900));
|
||||
|
||||
if ($editorWidth < $breakpointWidthPortrait) {
|
||||
if ($editorHeight > 0) {
|
||||
$editorHeight = $breakpointWidthPortrait / $editorWidth * $editorHeight;
|
||||
}
|
||||
|
||||
$editorWidth = $breakpointWidthPortrait;
|
||||
}
|
||||
|
||||
if ($editorHeight <= 0) {
|
||||
switch ($this->slider->data->get('type', 'simple')) {
|
||||
case 'carousel':
|
||||
case 'showcase':
|
||||
$editorHeight = 0;
|
||||
break;
|
||||
default:
|
||||
$editorHeight = $editorWidth * $heightHelperRatio;
|
||||
}
|
||||
} else {
|
||||
$customHeight = true;
|
||||
}
|
||||
|
||||
$this->sizes['desktopLandscape'] = array(
|
||||
'width' => $editorWidth,
|
||||
'height' => floor($editorHeight),
|
||||
'customHeight' => $customHeight
|
||||
);
|
||||
} else {
|
||||
|
||||
$this->sizes['desktopLandscape'] = array(
|
||||
'width' => $this->sizes['desktopPortrait']['width'],
|
||||
'height' => $this->sizes['desktopPortrait']['height'],
|
||||
'customHeight' => false
|
||||
);
|
||||
}
|
||||
|
||||
$this->sizes['desktopLandscape']['max'] = 3000;
|
||||
$this->sizes['desktopLandscape']['min'] = $breakpointWidthPortrait;
|
||||
|
||||
$previousSize = &$this->sizes['desktopLandscape'];
|
||||
|
||||
}
|
||||
|
||||
$this->sizes['desktopPortrait']['max'] = max($this->sizes['desktopPortrait']['width'], $landscapePortraitWidth - 1, $breakpointWidthLandscape - 1);
|
||||
|
||||
$previousSize = &$this->sizes['desktopPortrait'];
|
||||
|
||||
/**
|
||||
* Keep a copy of the current smallest width to be able to disable smaller devices
|
||||
*/
|
||||
$smallestWidth = $this->sizes['desktopPortrait']['width'];
|
||||
|
||||
if ($this->enabledDevices['tabletLandscape']) {
|
||||
|
||||
$breakpointWidthPortrait = intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-tablet-landscape', ViewSettingsGeneral::defaults['tablet-large-portrait']) : Settings::get('responsive-screen-width-tablet-landscape', ViewSettingsGeneral::defaults['tablet-large-portrait']));
|
||||
$breakpointWidthLandscape = max($breakpointWidthPortrait, intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-tablet-landscape-landscape', ViewSettingsGeneral::defaults['tablet-large-landscape']) : Settings::get('responsive-screen-width-tablet-landscape-landscape', ViewSettingsGeneral::defaults['tablet-large-landscape'])));
|
||||
|
||||
$this->breakpoints[] = array(
|
||||
'device' => 'tabletLandscape',
|
||||
'type' => 'max-screen-width',
|
||||
'portraitWidth' => $breakpointWidthPortrait,
|
||||
'landscapeWidth' => $breakpointWidthLandscape
|
||||
);
|
||||
|
||||
$editorWidth = intval($slider->params->get('tablet-landscape-width', 1024));
|
||||
|
||||
if ($overrideSizeEnabled && $slider->params->get('slider-size-override-tablet-landscape', 0) && $editorWidth > 10) {
|
||||
|
||||
$customHeight = false;
|
||||
$editorHeight = intval($slider->params->get('tablet-landscape-height', 768));
|
||||
|
||||
if ($editorWidth > $breakpointWidthPortrait) {
|
||||
if ($editorHeight > 0) {
|
||||
$editorHeight = $breakpointWidthPortrait / $editorWidth * $editorHeight;
|
||||
}
|
||||
|
||||
$editorWidth = $breakpointWidthPortrait;
|
||||
}
|
||||
|
||||
if ($editorHeight <= 0) {
|
||||
$editorHeight = $editorWidth * $heightHelperRatio;
|
||||
} else {
|
||||
$customHeight = true;
|
||||
}
|
||||
|
||||
$this->sizes['tabletLandscape'] = array(
|
||||
'width' => $editorWidth,
|
||||
'height' => floor($editorHeight),
|
||||
'customHeight' => $customHeight
|
||||
);
|
||||
|
||||
$smallestWidth = min($smallestWidth, $editorWidth);
|
||||
} else {
|
||||
$width = min($smallestWidth, $breakpointWidthPortrait);
|
||||
|
||||
$this->sizes['tabletLandscape'] = array(
|
||||
'width' => $width,
|
||||
'height' => floor($width * $heightHelperRatio),
|
||||
'auto' => true,
|
||||
'customHeight' => false
|
||||
);
|
||||
|
||||
$smallestWidth = min($smallestWidth, $breakpointWidthPortrait);
|
||||
}
|
||||
|
||||
$this->sizes['tabletLandscape']['max'] = max($this->sizes['tabletLandscape']['width'], $breakpointWidthPortrait, $breakpointWidthLandscape);
|
||||
|
||||
$previousSize['min'] = min($previousSize['width'], $breakpointWidthPortrait + 1);
|
||||
|
||||
$previousSize = &$this->sizes['tabletLandscape'];
|
||||
|
||||
}
|
||||
|
||||
if ($this->enabledDevices['tabletPortrait']) {
|
||||
|
||||
$breakpointWidthPortrait = intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-tablet-portrait', ViewSettingsGeneral::defaults['tablet-portrait']) : Settings::get('responsive-screen-width-tablet-portrait', ViewSettingsGeneral::defaults['tablet-portrait']));
|
||||
$breakpointWidthLandscape = max($breakpointWidthPortrait, intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-tablet-portrait-landscape', ViewSettingsGeneral::defaults['tablet-landscape']) : Settings::get('responsive-screen-width-tablet-portrait-landscape', ViewSettingsGeneral::defaults['tablet-landscape'])));
|
||||
|
||||
$this->breakpoints[] = array(
|
||||
'device' => 'tabletPortrait',
|
||||
'type' => 'max-screen-width',
|
||||
'portraitWidth' => $breakpointWidthPortrait,
|
||||
'landscapeWidth' => $breakpointWidthLandscape
|
||||
);
|
||||
|
||||
$editorWidth = intval($slider->params->get('tablet-portrait-width', 768));
|
||||
|
||||
if ($overrideSizeEnabled && $slider->params->get('slider-size-override-tablet-portrait', 0) && $editorWidth > 10) {
|
||||
|
||||
$customHeight = false;
|
||||
$editorHeight = intval($slider->params->get('tablet-portrait-height', 1024));
|
||||
|
||||
if ($editorWidth > $breakpointWidthPortrait) {
|
||||
if ($editorHeight > 0) {
|
||||
$editorHeight = $breakpointWidthPortrait / $editorWidth * $editorHeight;
|
||||
}
|
||||
|
||||
$editorWidth = $breakpointWidthPortrait;
|
||||
}
|
||||
|
||||
if ($editorHeight <= 0) {
|
||||
$editorHeight = $editorWidth * $heightHelperRatio;
|
||||
} else {
|
||||
$customHeight = true;
|
||||
}
|
||||
|
||||
$this->sizes['tabletPortrait'] = array(
|
||||
'width' => $editorWidth,
|
||||
'height' => floor($editorHeight),
|
||||
'customHeight' => $customHeight
|
||||
);
|
||||
|
||||
$smallestWidth = min($smallestWidth, $editorWidth);
|
||||
} else {
|
||||
$width = min($smallestWidth, $breakpointWidthPortrait);
|
||||
|
||||
$this->sizes['tabletPortrait'] = array(
|
||||
'width' => $width,
|
||||
'height' => floor($width * $heightHelperRatio),
|
||||
'auto' => true,
|
||||
'customHeight' => false
|
||||
);
|
||||
|
||||
$smallestWidth = min($smallestWidth, $breakpointWidthPortrait);
|
||||
}
|
||||
|
||||
$this->sizes['tabletPortrait']['max'] = max($this->sizes['tabletPortrait']['width'], $breakpointWidthPortrait, $breakpointWidthLandscape);
|
||||
|
||||
$previousSize['min'] = min($previousSize['width'], $breakpointWidthPortrait + 1);
|
||||
|
||||
$previousSize = &$this->sizes['tabletPortrait'];
|
||||
}
|
||||
|
||||
if ($this->enabledDevices['mobileLandscape']) {
|
||||
|
||||
$breakpointWidthPortrait = intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-mobile-landscape', ViewSettingsGeneral::defaults['mobile-large-portrait']) : Settings::get('responsive-screen-width-mobile-landscape', ViewSettingsGeneral::defaults['mobile-large-portrait']));
|
||||
$breakpointWidthLandscape = max($breakpointWidthPortrait, intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-mobile-landscape-landscape', ViewSettingsGeneral::defaults['mobile-large-landscape']) : Settings::get('responsive-screen-width-mobile-landscape-landscape', ViewSettingsGeneral::defaults['mobile-large-landscape'])));
|
||||
|
||||
$this->breakpoints[] = array(
|
||||
'device' => 'mobileLandscape',
|
||||
'type' => 'max-screen-width',
|
||||
'portraitWidth' => $breakpointWidthPortrait,
|
||||
'landscapeWidth' => $breakpointWidthLandscape
|
||||
);
|
||||
|
||||
|
||||
$editorWidth = intval($slider->params->get('mobile-landscape-width', 568));
|
||||
|
||||
if ($overrideSizeEnabled && $slider->params->get('slider-size-override-mobile-landscape', 0) && $editorWidth > 10) {
|
||||
|
||||
$customHeight = false;
|
||||
$editorHeight = intval($slider->params->get('mobile-landscape-height', 320));
|
||||
|
||||
if ($editorWidth > $breakpointWidthPortrait) {
|
||||
if ($editorHeight > 0) {
|
||||
$editorHeight = $breakpointWidthPortrait / $editorWidth * $editorHeight;
|
||||
}
|
||||
|
||||
$editorWidth = $breakpointWidthPortrait;
|
||||
}
|
||||
|
||||
if ($editorHeight <= 0) {
|
||||
$editorHeight = $editorWidth * $heightHelperRatio;
|
||||
} else {
|
||||
$customHeight = true;
|
||||
}
|
||||
|
||||
$this->sizes['mobileLandscape'] = array(
|
||||
'width' => $editorWidth,
|
||||
'height' => floor($editorHeight),
|
||||
'customHeight' => $customHeight
|
||||
);
|
||||
|
||||
$smallestWidth = min($smallestWidth, $editorWidth);
|
||||
} else {
|
||||
|
||||
$width = min($smallestWidth, $breakpointWidthPortrait);
|
||||
|
||||
$this->sizes['mobileLandscape'] = array(
|
||||
'width' => $width,
|
||||
'height' => floor($width * $heightHelperRatio),
|
||||
'auto' => true,
|
||||
'customHeight' => false
|
||||
);
|
||||
|
||||
$smallestWidth = min($smallestWidth, $breakpointWidthPortrait);
|
||||
}
|
||||
|
||||
$this->sizes['mobileLandscape']['max'] = max($this->sizes['mobileLandscape']['width'], $breakpointWidthPortrait, $breakpointWidthLandscape);
|
||||
|
||||
$previousSize['min'] = min($previousSize['width'], $breakpointWidthPortrait + 1);
|
||||
|
||||
$previousSize = &$this->sizes['mobileLandscape'];
|
||||
}
|
||||
|
||||
if ($this->enabledDevices['mobilePortrait']) {
|
||||
|
||||
$breakpointWidthPortrait = intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-mobile-portrait', ViewSettingsGeneral::defaults['mobile-portrait']) : Settings::get('responsive-screen-width-mobile-portrait', ViewSettingsGeneral::defaults['mobile-portrait']));
|
||||
$breakpointWidthLandscape = max($breakpointWidthPortrait, intval($useLocalBreakpoints ? $slider->params->get('responsive-breakpoint-mobile-portrait-landscape', ViewSettingsGeneral::defaults['mobile-landscape']) : Settings::get('responsive-screen-width-mobile-portrait-landscape', ViewSettingsGeneral::defaults['mobile-landscape'])));
|
||||
|
||||
$this->breakpoints[] = array(
|
||||
'device' => 'mobilePortrait',
|
||||
'type' => 'max-screen-width',
|
||||
'portraitWidth' => $breakpointWidthPortrait,
|
||||
'landscapeWidth' => $breakpointWidthLandscape
|
||||
);
|
||||
|
||||
|
||||
$editorWidth = intval($slider->params->get('mobile-portrait-width', 320));
|
||||
|
||||
if ($overrideSizeEnabled && $slider->params->get('slider-size-override-mobile-portrait', 0) && $editorWidth > 10) {
|
||||
|
||||
$customHeight = false;
|
||||
$editorHeight = intval($slider->params->get('mobile-portrait-height', 568));
|
||||
|
||||
if ($editorWidth > $breakpointWidthPortrait) {
|
||||
if ($editorHeight > 0) {
|
||||
$editorHeight = $breakpointWidthPortrait / $editorWidth * $editorHeight;
|
||||
}
|
||||
|
||||
$editorWidth = $breakpointWidthPortrait;
|
||||
}
|
||||
|
||||
if ($editorHeight <= 0) {
|
||||
$editorHeight = $editorWidth * $heightHelperRatio;
|
||||
} else {
|
||||
$customHeight = true;
|
||||
}
|
||||
|
||||
$this->sizes['mobilePortrait'] = array(
|
||||
'width' => $editorWidth,
|
||||
'height' => floor($editorHeight),
|
||||
'customHeight' => $customHeight
|
||||
);
|
||||
} else {
|
||||
$width = min(320, $smallestWidth, $breakpointWidthPortrait);
|
||||
|
||||
$this->sizes['mobilePortrait'] = array(
|
||||
'width' => $width,
|
||||
'height' => floor($width * $heightHelperRatio),
|
||||
'customHeight' => false
|
||||
);
|
||||
}
|
||||
|
||||
$this->sizes['mobilePortrait']['max'] = max($this->sizes['mobilePortrait']['width'], $breakpointWidthPortrait, $breakpointWidthLandscape);
|
||||
|
||||
$previousSize['min'] = min($previousSize['width'], $breakpointWidthPortrait + 1);
|
||||
|
||||
$previousSize = &$this->sizes['mobilePortrait'];
|
||||
}
|
||||
|
||||
$previousSize['min'] = min(320, $previousSize['width']);
|
||||
|
||||
if (isset($this->sizes['mobileLandscape']['auto'])) {
|
||||
unset($this->sizes['mobileLandscape']['auto']);
|
||||
|
||||
$this->sizes['mobileLandscape']['width'] = $this->sizes['mobileLandscape']['min'];
|
||||
$this->sizes['mobileLandscape']['height'] = floor($this->sizes['mobileLandscape']['width'] * $heightHelperRatio);
|
||||
}
|
||||
|
||||
if (isset($this->sizes['tabletPortrait']['auto'])) {
|
||||
unset($this->sizes['tabletPortrait']['auto']);
|
||||
|
||||
$this->sizes['tabletPortrait']['width'] = $this->sizes['tabletPortrait']['min'];
|
||||
$this->sizes['tabletPortrait']['height'] = floor($this->sizes['tabletPortrait']['width'] * $heightHelperRatio);
|
||||
}
|
||||
|
||||
if (isset($this->sizes['tabletLandscape']['auto'])) {
|
||||
unset($this->sizes['tabletLandscape']['auto']);
|
||||
|
||||
$this->sizes['tabletLandscape']['width'] = $this->sizes['tabletLandscape']['min'];
|
||||
$this->sizes['tabletLandscape']['height'] = floor($this->sizes['tabletLandscape']['width'] * $heightHelperRatio);
|
||||
}
|
||||
|
||||
$this->parseLimitSlideWidth($slider->params);
|
||||
|
||||
$breakpointData = array();
|
||||
foreach ($this->breakpoints as $breakpoint) {
|
||||
$breakpointData[$breakpoint['device']] = $breakpoint;
|
||||
}
|
||||
|
||||
if (isset($breakpointData['desktopLandscape'])) {
|
||||
|
||||
$portraitMinWidth = $breakpointData['desktopLandscape']['portraitWidth'];
|
||||
$landscapeMinWidth = $breakpointData['desktopLandscape']['landscapeWidth'];
|
||||
|
||||
if ($portraitMinWidth == $landscapeMinWidth || $this->slider->isFrame) {
|
||||
$this->mediaQueries['desktoplandscape'] = array('(min-width: ' . $portraitMinWidth . 'px)');
|
||||
|
||||
} else {
|
||||
$this->mediaQueries['desktoplandscape'] = array(
|
||||
'(orientation: landscape) and (min-width: ' . $landscapeMinWidth . 'px)',
|
||||
'(orientation: portrait) and (min-width: ' . $portraitMinWidth . 'px)'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$nextSize = null;
|
||||
foreach (array(
|
||||
'tabletLandscape',
|
||||
'tabletPortrait',
|
||||
'mobileLandscape',
|
||||
'mobilePortrait'
|
||||
) as $nextDevice) {
|
||||
if (isset($breakpointData[$nextDevice])) {
|
||||
$nextSize = $breakpointData[$nextDevice];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$portraitMaxWidth = 0;
|
||||
$landscapeMaxWidth = 0;
|
||||
if (isset($breakpointData['desktopLandscape'])) {
|
||||
$portraitMaxWidth = $breakpointData['desktopLandscape']['portraitWidth'] - 1;
|
||||
$landscapeMaxWidth = $breakpointData['desktopLandscape']['landscapeWidth'] - 1;
|
||||
}
|
||||
$portraitMinWidth = $nextSize['portraitWidth'] + 1;
|
||||
$landscapeMinWidth = $nextSize['landscapeWidth'] + 1;
|
||||
|
||||
if ($portraitMaxWidth == 0 || $landscapeMaxWidth == 0) {
|
||||
if ($portraitMinWidth == $landscapeMinWidth || $this->slider->isFrame) {
|
||||
$this->mediaQueries['desktopportrait'] = array('(min-width: ' . $portraitMinWidth . 'px)');
|
||||
|
||||
} else {
|
||||
$this->mediaQueries['desktopportrait'] = array(
|
||||
'(orientation: landscape) and (min-width: ' . $landscapeMinWidth . 'px)',
|
||||
'(orientation: portrait) and (min-width: ' . $portraitMinWidth . 'px)'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (($portraitMinWidth == $landscapeMinWidth && $portraitMaxWidth == $landscapeMaxWidth) || $this->slider->isFrame) {
|
||||
$this->mediaQueries['desktopportrait'] = array('(min-width: ' . $portraitMinWidth . 'px) and (max-width: ' . $portraitMaxWidth . 'px)');
|
||||
|
||||
} else {
|
||||
$this->mediaQueries['desktopportrait'] = array(
|
||||
'(orientation: landscape) and (min-width: ' . $landscapeMinWidth . 'px) and (max-width: ' . $landscapeMaxWidth . 'px)',
|
||||
'(orientation: portrait) and (min-width: ' . $portraitMinWidth . 'px) and (max-width: ' . $portraitMaxWidth . 'px)'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->initMediaQuery($breakpointData, 'tabletLandscape', array(
|
||||
'tabletPortrait',
|
||||
'mobileLandscape',
|
||||
'mobilePortrait'
|
||||
));
|
||||
|
||||
$this->initMediaQuery($breakpointData, 'tabletPortrait', array(
|
||||
'mobileLandscape',
|
||||
'mobilePortrait'
|
||||
));
|
||||
|
||||
$this->initMediaQuery($breakpointData, 'mobileLandscape', array(
|
||||
'mobilePortrait'
|
||||
));
|
||||
|
||||
$this->initMediaQuery($breakpointData, 'mobilePortrait', array());
|
||||
}
|
||||
|
||||
private function initMediaQuery(&$breakpointData, $deviceName, $nextDevices) {
|
||||
if (isset($breakpointData[$deviceName])) {
|
||||
|
||||
$deviceNameLower = strtolower($deviceName);
|
||||
|
||||
$nextSize = null;
|
||||
foreach ($nextDevices as $nextDevice) {
|
||||
if (isset($breakpointData[$nextDevice])) {
|
||||
$nextSize = $breakpointData[$nextDevice];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$portraitMaxWidth = $breakpointData[$deviceName]['portraitWidth'];
|
||||
$landscapeMaxWidth = $breakpointData[$deviceName]['landscapeWidth'];
|
||||
|
||||
if ($nextSize) {
|
||||
if (($nextSize['portraitWidth'] == $nextSize['landscapeWidth'] && $portraitMaxWidth == $landscapeMaxWidth) || $this->slider->isFrame) {
|
||||
$this->mediaQueries[$deviceNameLower] = array('(max-width: ' . $portraitMaxWidth . 'px) and (min-width: ' . ($nextSize['portraitWidth'] + 1) . 'px)');
|
||||
|
||||
} else {
|
||||
$this->mediaQueries[$deviceNameLower] = array(
|
||||
'(orientation: landscape) and (max-width: ' . $landscapeMaxWidth . 'px) and (min-width: ' . ($nextSize['landscapeWidth'] + 1) . 'px)',
|
||||
'(orientation: portrait) and (max-width: ' . $portraitMaxWidth . 'px) and (min-width: ' . ($nextSize['portraitWidth'] + 1) . 'px)'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (($portraitMaxWidth == $landscapeMaxWidth) || $this->slider->isFrame) {
|
||||
$this->mediaQueries[$deviceNameLower] = array('(max-width: ' . $portraitMaxWidth . 'px)');
|
||||
|
||||
} else {
|
||||
$this->mediaQueries[$deviceNameLower] = array(
|
||||
'(orientation: landscape) and (max-width: ' . $landscapeMaxWidth . 'px)',
|
||||
'(orientation: portrait) and (max-width: ' . $portraitMaxWidth . 'px)'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
|
||||
if ($this->maximumSlideWidthLandscape <= 0) {
|
||||
$this->maximumSlideWidthLandscape = $this->maximumSlideWidth;
|
||||
}
|
||||
|
||||
if ($this->maximumSlideWidthTablet <= 0) {
|
||||
$this->maximumSlideWidthTablet = $this->maximumSlideWidth;
|
||||
}
|
||||
|
||||
if ($this->maximumSlideWidthTabletLandscape <= 0) {
|
||||
$this->maximumSlideWidthTabletLandscape = $this->maximumSlideWidthTablet;
|
||||
}
|
||||
|
||||
if ($this->maximumSlideWidthMobile <= 0) {
|
||||
$this->maximumSlideWidthMobile = $this->maximumSlideWidth;
|
||||
}
|
||||
|
||||
if ($this->maximumSlideWidthMobileLandscape <= 0) {
|
||||
$this->maximumSlideWidthMobileLandscape = $this->maximumSlideWidthMobile;
|
||||
}
|
||||
|
||||
if (!$this->scaleDown) {
|
||||
$this->slider->addDeviceCSS('all', 'div#' . $this->slider->elementId . '-align{min-width:' . $this->sizes['desktopPortrait']['width'] . 'px;}');
|
||||
}
|
||||
|
||||
if (!$this->scaleUp) {
|
||||
$this->slider->addDeviceCSS('all', 'div#' . $this->slider->elementId . '-align{max-width:' . $this->sizes['desktopPortrait']['width'] . 'px;}');
|
||||
}
|
||||
|
||||
|
||||
if ($this->minimumHeight > 0) {
|
||||
$this->slider->sliderType->handleSliderMinHeight($this->minimumHeight);
|
||||
}
|
||||
|
||||
foreach ($this->mediaQueries as $device => $mediaQuery) {
|
||||
if ($mediaQuery) {
|
||||
$this->slider->addDeviceCSS($device, 'div#' . $this->slider->elementId . ' [data-hide-' . $device . '="1"]{display: none !important;}');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->slider->isAdmin) {
|
||||
if ($this->hideOnDesktopLandscape) {
|
||||
$this->slider->addDeviceCSS('desktoplandscape', '.n2-section-smartslider[data-ssid="' . $this->slider->sliderId . '"]{display: none;}');
|
||||
}
|
||||
if (!SmartSlider3Info::$forceDesktop && $this->hideOnDesktopPortrait) {
|
||||
$this->slider->addDeviceCSS('desktopportrait', '.n2-section-smartslider[data-ssid="' . $this->slider->sliderId . '"]{display: none;}');
|
||||
}
|
||||
|
||||
if ($this->hideOnTabletLandscape) {
|
||||
$this->slider->addDeviceCSS('tabletlandscape', '.n2-section-smartslider[data-ssid="' . $this->slider->sliderId . '"]{display: none;}');
|
||||
}
|
||||
if ($this->hideOnTabletPortrait) {
|
||||
$this->slider->addDeviceCSS('tabletportrait', '.n2-section-smartslider[data-ssid="' . $this->slider->sliderId . '"]{display: none;}');
|
||||
}
|
||||
|
||||
if ($this->hideOnMobileLandscape) {
|
||||
$this->slider->addDeviceCSS('mobilelandscape', '.n2-section-smartslider[data-ssid="' . $this->slider->sliderId . '"]{display: none;}');
|
||||
}
|
||||
if ($this->hideOnMobilePortrait) {
|
||||
$this->slider->addDeviceCSS('mobileportrait', '.n2-section-smartslider[data-ssid="' . $this->slider->sliderId . '"]{display: none;}');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$properties['responsive'] = array(
|
||||
'mediaQueries' => $this->mediaQueries,
|
||||
'base' => $this->slider->assets->base,
|
||||
'hideOn' => array(
|
||||
'desktopLandscape' => SmartSlider3Info::$forceAllDevices ? false : $this->hideOnDesktopLandscape,
|
||||
'desktopPortrait' => SmartSlider3Info::$forceDesktop ? false : $this->hideOnDesktopPortrait,
|
||||
'tabletLandscape' => SmartSlider3Info::$forceAllDevices ? false : $this->hideOnTabletLandscape,
|
||||
'tabletPortrait' => SmartSlider3Info::$forceAllDevices ? false : $this->hideOnTabletPortrait,
|
||||
'mobileLandscape' => SmartSlider3Info::$forceAllDevices ? false : $this->hideOnMobileLandscape,
|
||||
'mobilePortrait' => SmartSlider3Info::$forceAllDevices ? false : $this->hideOnMobilePortrait,
|
||||
),
|
||||
|
||||
'onResizeEnabled' => $this->onResizeEnabled,
|
||||
'type' => $this->type,
|
||||
'sliderHeightBasedOn' => $this->sliderHeightBasedOn,
|
||||
|
||||
'focusUser' => $this->focusUser,
|
||||
'focusEdge' => $this->focusEdge,
|
||||
|
||||
'breakpoints' => $this->breakpoints,
|
||||
'enabledDevices' => $this->enabledDevices,
|
||||
'sizes' => $this->sizes,
|
||||
|
||||
'overflowHiddenPage' => intval($this->slider->params->get('overflow-hidden-page', 0))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Data $params
|
||||
*/
|
||||
private function parseLimitSlideWidth($params) {
|
||||
if ($params->get('responsiveLimitSlideWidth', 1)) {
|
||||
|
||||
if ($this->enabledDevices['desktopLandscape']) {
|
||||
if ($params->get('responsiveSlideWidthDesktopLandscape', 0)) {
|
||||
$this->maximumSlideWidthLandscape = intval($params->get('responsiveSlideWidthMaxDesktopLandscape', 1600));
|
||||
|
||||
$this->slider->addDeviceCSS('desktoplandscape', 'div#' . $this->slider->elementId . ' .n2-ss-slide-limiter{max-width:' . $this->maximumSlideWidthLandscape . 'px;}');
|
||||
}
|
||||
}
|
||||
|
||||
if ($params->get('responsiveSlideWidth', 0)) {
|
||||
$this->maximumSlideWidth = intval($params->get('responsiveSlideWidthMax', 3000));
|
||||
} else {
|
||||
$this->maximumSlideWidth = $this->sizes['desktopPortrait']['width'];
|
||||
}
|
||||
|
||||
if ($this->maximumSlideWidth < 1) {
|
||||
$this->maximumSlideWidth = 10000;
|
||||
}
|
||||
|
||||
$this->slider->addDeviceCSS('all', 'div#' . $this->slider->elementId . ' .n2-ss-slide-limiter{max-width:' . $this->maximumSlideWidth . 'px;}');
|
||||
|
||||
|
||||
if ($this->enabledDevices['tabletLandscape']) {
|
||||
if ($params->get('responsiveSlideWidthTabletLandscape', 0)) {
|
||||
$this->maximumSlideWidthTabletLandscape = intval($params->get('responsiveSlideWidthMaxTabletLandscape', 1200));
|
||||
|
||||
$this->slider->addDeviceCSS('tabletlandscape', 'div#' . $this->slider->elementId . ' .n2-ss-slide-limiter{max-width:' . $this->maximumSlideWidthTabletLandscape . 'px;}');
|
||||
}
|
||||
}
|
||||
|
||||
if ($params->get('responsiveSlideWidthTablet', 0)) {
|
||||
$this->maximumSlideWidthTablet = intval($params->get('responsiveSlideWidthMaxTablet', 980));
|
||||
|
||||
$this->slider->addDeviceCSS('tabletportrait', 'div#' . $this->slider->elementId . ' .n2-ss-slide-limiter{max-width:' . $this->maximumSlideWidthTablet . 'px;}');
|
||||
}
|
||||
|
||||
|
||||
if ($this->enabledDevices['mobileLandscape']) {
|
||||
if ($params->get('responsiveSlideWidthMobileLandscape', 0)) {
|
||||
$this->maximumSlideWidthMobileLandscape = intval($params->get('responsiveSlideWidthMaxMobileLandscape', 780));
|
||||
|
||||
$this->slider->addDeviceCSS('mobilelandscape', 'div#' . $this->slider->elementId . ' .n2-ss-slide-limiter{max-width:' . $this->maximumSlideWidthMobileLandscape . 'px;}');
|
||||
}
|
||||
}
|
||||
|
||||
if ($params->get('responsiveSlideWidthMobile', 0)) {
|
||||
$this->maximumSlideWidthMobile = intval($params->get('responsiveSlideWidthMaxMobile', 480));
|
||||
|
||||
$this->slider->addDeviceCSS('mobileportrait', 'div#' . $this->slider->elementId . ' .n2-ss-slide-limiter{max-width:' . $this->maximumSlideWidthMobile . 'px;}');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,420 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
use Nextend\Framework\Image\ImageEdit;
|
||||
use Nextend\Framework\Image\ImageManager;
|
||||
use Nextend\Framework\Parser\Color;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
use Nextend\Framework\View\Html;
|
||||
use Nextend\SmartSlider3\Slider\Slide;
|
||||
use Nextend\SmartSlider3\Slider\Slider;
|
||||
|
||||
class SlideBackground {
|
||||
|
||||
/**
|
||||
* @var Slider
|
||||
*/
|
||||
private $slider;
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
}
|
||||
|
||||
public function makeJavaScriptProperties(&$properties) {
|
||||
$enabled = intval($this->slider->params->get('slide-background-parallax', 0));
|
||||
if ($enabled) {
|
||||
$properties['backgroundParallax'] = array(
|
||||
'strength' => intval($this->slider->params->get('slide-background-parallax-strength', 50)) / 100,
|
||||
'tablet' => intval($this->slider->params->get('bg-parallax-tablet', 0)),
|
||||
'mobile' => intval($this->slider->params->get('bg-parallax-mobile', 0))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $slide Slide
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function make($slide) {
|
||||
|
||||
if ($slide->parameters->get('background-type') == '') {
|
||||
$slide->parameters->set('background-type', 'color');
|
||||
if ($slide->parameters->get('backgroundVideoMp4')) {
|
||||
$slide->parameters->set('background-type', 'video');
|
||||
} else if ($slide->parameters->get('backgroundImage')) {
|
||||
$slide->parameters->set('background-type', 'image');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->makeBackground($slide);
|
||||
}
|
||||
|
||||
private function getBackgroundStyle($slide) {
|
||||
|
||||
$attributes = array();
|
||||
|
||||
$style = '';
|
||||
$color = $slide->fill($slide->parameters->get('backgroundColor', ''));
|
||||
if (empty($color)) {
|
||||
$color = 'ffffff00';
|
||||
}
|
||||
if (strlen($color) > 0 && $color[0] == '#') {
|
||||
$color = substr($color, 1);
|
||||
if (strlen($color) == 6) {
|
||||
$color .= 'ff';
|
||||
}
|
||||
}
|
||||
$gradient = $slide->parameters->get('backgroundGradient', 'off');
|
||||
|
||||
if ($gradient != 'off') {
|
||||
$colorEnd = $slide->fill($slide->parameters->get('backgroundColorEnd', 'ffffff00'));
|
||||
if (empty($colorEnd)) {
|
||||
$colorEnd = 'ffffff00';
|
||||
}
|
||||
|
||||
if ($colorEnd[0] == '#') {
|
||||
$colorEnd = substr($colorEnd, 1);
|
||||
if (strlen($colorEnd) == 6) {
|
||||
$colorEnd .= 'ff';
|
||||
}
|
||||
}
|
||||
|
||||
$startColor = Color::colorToRGBA($color);
|
||||
$endColor = Color::colorToRGBA($colorEnd);
|
||||
|
||||
$attributes['data-gradient'] = $gradient;
|
||||
$attributes['data-color-start'] = $startColor;
|
||||
$attributes['data-color-end'] = $endColor;
|
||||
|
||||
switch ($gradient) {
|
||||
case 'horizontal':
|
||||
$style .= 'background:linear-gradient(to right, ' . $startColor . ' 0%,' . $endColor . ' 100%);';
|
||||
break;
|
||||
case 'vertical':
|
||||
$style .= 'background:linear-gradient(to bottom, ' . $startColor . ' 0%,' . $endColor . ' 100%);';
|
||||
break;
|
||||
case 'diagonal1':
|
||||
$style .= 'background:linear-gradient(45deg, ' . $startColor . ' 0%,' . $endColor . ' 100%);';
|
||||
break;
|
||||
case 'diagonal2':
|
||||
$style .= 'background:linear-gradient(135deg, ' . $startColor . ' 0%,' . $endColor . ' 100%);';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (strlen($color) == 8) {
|
||||
|
||||
$colorRGBA = Color::colorToRGBA($color);
|
||||
$style .= "background-color: " . Color::colorToRGBA($color) . ";";
|
||||
|
||||
$attributes['data-color'] = $colorRGBA;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$attributes['style'] = $style;
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
private function makeBackground($slide) {
|
||||
|
||||
$backgroundType = $slide->parameters->get('background-type');
|
||||
|
||||
if (empty($backgroundType)) {
|
||||
$backgroundVideoMp4 = $slide->parameters->get('backgroundVideoMp4', '');
|
||||
$backgroundImage = $slide->parameters->get('backgroundImage', '');
|
||||
if (!empty($backgroundVideoMp4)) {
|
||||
$backgroundType = 'video';
|
||||
} else if (!empty($backgroundImage)) {
|
||||
$backgroundType = 'image';
|
||||
} else {
|
||||
$backgroundType = 'color';
|
||||
}
|
||||
}
|
||||
|
||||
$fillMode = $slide->parameters->get('backgroundMode', 'default');
|
||||
|
||||
if ($fillMode == 'default') {
|
||||
$fillMode = $this->slider->params->get('backgroundMode', 'fill');
|
||||
|
||||
}
|
||||
|
||||
$backgroundElements = array();
|
||||
|
||||
if ($backgroundType == 'color') {
|
||||
$backgroundElements[] = $this->renderColor($slide);
|
||||
|
||||
} else if ($backgroundType == 'video') {
|
||||
|
||||
|
||||
$backgroundElements[] = $this->renderBackgroundVideo($slide);
|
||||
$backgroundElements[] = $this->renderImage($slide, $fillMode);
|
||||
|
||||
$backgroundElements[] = $this->renderColor($slide);
|
||||
|
||||
} else if ($backgroundType == 'image') {
|
||||
|
||||
|
||||
$backgroundElements[] = $this->renderImage($slide, $fillMode);
|
||||
|
||||
$backgroundElements[] = $this->renderColor($slide);
|
||||
}
|
||||
|
||||
$html = implode('', $backgroundElements);
|
||||
|
||||
/* @see https://bugs.chromium.org/p/chromium/issues/detail?id=1181291
|
||||
* if (!$slide->getFrontendFirst()) {
|
||||
* $html = '<template>' . $html . '</template>';
|
||||
* }
|
||||
*/
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => "n2-ss-slide-background",
|
||||
'data-public-id' => $slide->publicID,
|
||||
'data-mode' => $fillMode
|
||||
), $html);
|
||||
}
|
||||
|
||||
private function renderColor($slide) {
|
||||
$backgroundAttributes = $this->getBackgroundStyle($slide);
|
||||
|
||||
if (!empty($backgroundAttributes['style'])) {
|
||||
|
||||
$backgroundAttributes['class'] = 'n2-ss-slide-background-color';
|
||||
|
||||
if ($slide->parameters->get('backgroundColorOverlay', 0)) {
|
||||
$backgroundAttributes['data-overlay'] = 1;
|
||||
}
|
||||
|
||||
return Html::tag('div', $backgroundAttributes, '');
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $slide Slide
|
||||
* @param $fillMode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function renderImage($slide, $fillMode) {
|
||||
|
||||
$rawBackgroundImage = $slide->parameters->get('backgroundImage', '');
|
||||
|
||||
if (empty($rawBackgroundImage)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$backgroundImageBlur = max(0, $slide->parameters->get('backgroundImageBlur', 0));
|
||||
|
||||
$focusX = max(0, min(100, $slide->fill($slide->parameters->get('backgroundFocusX', 50))));
|
||||
$focusY = max(0, min(100, $slide->fill($slide->parameters->get('backgroundFocusY', 50))));
|
||||
|
||||
$backgroundImageMobile = '';
|
||||
$backgroundImageTablet = '';
|
||||
$backgroundImageDesktopRetina = '';
|
||||
$backgroundImage = $slide->fill($rawBackgroundImage);
|
||||
|
||||
if (!$slide->hasGenerator()) {
|
||||
$imageData = ImageManager::getImageData($backgroundImage);
|
||||
$backgroundImageDesktopRetina = $imageData['desktop-retina']['image'];
|
||||
$backgroundImageMobile = $imageData['mobile']['image'];
|
||||
$backgroundImageTablet = $imageData['tablet']['image'];
|
||||
}
|
||||
|
||||
$alt = $slide->fill($slide->parameters->get('backgroundAlt', ''));
|
||||
$title = $slide->fill($slide->parameters->get('backgroundTitle', ''));
|
||||
|
||||
|
||||
$opacity = min(100, max(0, $slide->parameters->get('backgroundImageOpacity', 100)));
|
||||
|
||||
$style = array();
|
||||
if ($opacity < 100) {
|
||||
$style[] = 'opacity:' . ($opacity / 100);
|
||||
}
|
||||
|
||||
if ($focusX != '50') {
|
||||
$style[] = '--ss-o-pos-x:' . $focusX . '%';
|
||||
}
|
||||
|
||||
if ($focusY != '50') {
|
||||
$style[] = '--ss-o-pos-y:' . $focusY . '%';
|
||||
}
|
||||
|
||||
$attributes = array(
|
||||
"class" => 'n2-ss-slide-background-image',
|
||||
"data-blur" => $backgroundImageBlur,
|
||||
"data-opacity" => $opacity,
|
||||
"data-x" => $focusX,
|
||||
"data-y" => $focusY,
|
||||
"data-alt" => $alt,
|
||||
"data-title" => $title
|
||||
);
|
||||
|
||||
if (!empty($style)) {
|
||||
$attributes['style'] = implode(';', $style);
|
||||
}
|
||||
|
||||
$sources = array();
|
||||
|
||||
if ($this->slider->isAdmin) {
|
||||
$src = $backgroundImage;
|
||||
|
||||
$attributes['data-hash'] = md5($src);
|
||||
$attributes['data-src-desktop'] = $src;
|
||||
$attributes['data-src-desktop-retina'] = $backgroundImageDesktopRetina;
|
||||
$attributes['data-src-tablet'] = $backgroundImageTablet;
|
||||
$attributes['data-src-mobile'] = $backgroundImageMobile;
|
||||
} else {
|
||||
|
||||
if (empty($backgroundImage)) {
|
||||
/**
|
||||
* @todo Does it really work as expected?
|
||||
*/
|
||||
$src = ImageEdit::base64Transparent();
|
||||
} else {
|
||||
/**
|
||||
* @todo this resize might have a better place
|
||||
*/
|
||||
$src = $backgroundImage;
|
||||
if ($this->slider->params->get('optimize-scale', 0)) {
|
||||
$src = ResourceTranslator::urlToResource($this->slider->features->optimize->optimizeBackground($backgroundImage, $focusX, $focusY));
|
||||
}
|
||||
|
||||
|
||||
$slide->addImage(ResourceTranslator::toUrl($src));
|
||||
}
|
||||
|
||||
$hasDeviceSpecificImage = false;
|
||||
|
||||
$mediaQueries = $this->slider->features->responsive->mediaQueries;
|
||||
|
||||
if (!empty($backgroundImageDesktopRetina)) {
|
||||
|
||||
$hasDeviceSpecificImage = true;
|
||||
|
||||
$backgroundImageDesktopRetina = ResourceTranslator::toUrl($backgroundImageDesktopRetina);
|
||||
|
||||
$mediaQueryMinPixelRatio = ' and (-webkit-min-device-pixel-ratio: 1.5)';
|
||||
|
||||
if (!empty($mediaQueries['desktopportrait'])) {
|
||||
$sources[] = HTML::tag('source', Html::addExcludeLazyLoadAttributes(array(
|
||||
'srcset' => $backgroundImageDesktopRetina,
|
||||
'media' => implode($mediaQueryMinPixelRatio . ',', $mediaQueries['desktopportrait']) . $mediaQueryMinPixelRatio
|
||||
)), false, false);
|
||||
}
|
||||
if (!empty($mediaQueries['desktoplandscape'])) {
|
||||
$sources[] = HTML::tag('source', Html::addExcludeLazyLoadAttributes(array(
|
||||
'srcset' => $backgroundImageDesktopRetina,
|
||||
'media' => implode($mediaQueryMinPixelRatio . ',', $mediaQueries['desktoplandscape']) . $mediaQueryMinPixelRatio
|
||||
)), false, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!empty($backgroundImageMobile)) {
|
||||
|
||||
$hasDeviceSpecificImage = true;
|
||||
|
||||
$backgroundImageMobileUrl = ResourceTranslator::toUrl($backgroundImageMobile);
|
||||
|
||||
if (!empty($mediaQueries['mobileportrait'])) {
|
||||
$sources[] = HTML::tag('source', Html::addExcludeLazyLoadAttributes(array(
|
||||
'srcset' => $backgroundImageMobileUrl,
|
||||
'media' => implode(',', $mediaQueries['mobileportrait'])
|
||||
)), false, false);
|
||||
}
|
||||
if (!empty($mediaQueries['mobilelandscape'])) {
|
||||
$sources[] = HTML::tag('source', Html::addExcludeLazyLoadAttributes(array(
|
||||
'srcset' => $backgroundImageMobileUrl,
|
||||
'media' => implode(',', $mediaQueries['mobilelandscape'])
|
||||
)), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($backgroundImageTablet)) {
|
||||
|
||||
$hasDeviceSpecificImage = true;
|
||||
|
||||
$backgroundImageTabletUrl = ResourceTranslator::toUrl($backgroundImageTablet);
|
||||
|
||||
if (!empty($mediaQueries['tabletportrait'])) {
|
||||
$sources[] = HTML::tag('source', Html::addExcludeLazyLoadAttributes(array(
|
||||
'srcset' => $backgroundImageTabletUrl,
|
||||
'media' => implode(',', $mediaQueries['tabletportrait'])
|
||||
)), false, false);
|
||||
}
|
||||
if (!empty($mediaQueries['tabletlandscape'])) {
|
||||
$sources[] = HTML::tag('source', Html::addExcludeLazyLoadAttributes(array(
|
||||
'srcset' => $backgroundImageTabletUrl,
|
||||
'media' => implode(',', $mediaQueries['tabletlandscape'])
|
||||
)), false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$imageAttributes = array(
|
||||
'src' => ResourceTranslator::toUrl($src),
|
||||
'alt' => $alt,
|
||||
'title' => $title,
|
||||
'loading' => 'lazy',
|
||||
'style' => ''
|
||||
);
|
||||
|
||||
$imageAttributes = Html::addExcludeLazyLoadAttributes($imageAttributes);
|
||||
|
||||
$sources[] = Html::tag('img', $imageAttributes, '', false);
|
||||
|
||||
$picture = HTML::tag('picture', Html::addExcludeLazyLoadAttributes(), implode('', $sources));
|
||||
|
||||
$originalImage = Html::tag('div', $attributes, $picture);
|
||||
|
||||
if ($fillMode === 'blurfit') {
|
||||
$slideOption = $slide->parameters->get('backgroundMode', 'default');
|
||||
|
||||
if ($slideOption === 'blurfit') {
|
||||
$blurFit = $slide->parameters->get('backgroundBlurFit', 7);
|
||||
} else {
|
||||
$blurFit = $this->slider->params->get('backgroundBlurFit', 7);
|
||||
$attributes['data-blurfitmode'] = 'default';
|
||||
}
|
||||
$picture = HTML::tag('picture', Html::addExcludeLazyLoadAttributes(array(
|
||||
'style' => 'filter:blur(' . $blurFit . 'px)'
|
||||
)), implode('', $sources));
|
||||
$blurFitStyle = array(
|
||||
'margin:-' . ($blurFit * 2) . 'px',
|
||||
'padding:' . ($blurFit * 2) . 'px'
|
||||
);
|
||||
if (!isset($attributes['style'])) {
|
||||
$attributes['style'] = '';
|
||||
}
|
||||
|
||||
$attributes['data-globalblur'] = $this->slider->params->get('backgroundBlurFit', 7);
|
||||
$attributes['data-bgblur'] = $slide->parameters->get('backgroundBlurFit', 7);
|
||||
$attributes['style'] = implode(';', $blurFitStyle);
|
||||
$ret = Html::tag('div', $attributes, $picture) . $originalImage;
|
||||
} else {
|
||||
$ret = $originalImage;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Slide $slide
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function renderBackgroundVideo($slide) {
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Slider\Feature;
|
||||
|
||||
|
||||
use Nextend\Framework\Parser\Common;
|
||||
use Nextend\Framework\Sanitize;
|
||||
use Nextend\SmartSlider3\Settings;
|
||||
|
||||
class TranslateUrl {
|
||||
|
||||
private $slider;
|
||||
|
||||
public $from = '';
|
||||
|
||||
public $to = '';
|
||||
|
||||
public function __construct($slider) {
|
||||
|
||||
$this->slider = $slider;
|
||||
list($this->from, $this->to) = (array)Common::parse(esc_attr(Settings::get('translate-url', '||')));
|
||||
}
|
||||
|
||||
public function replaceUrl($string) {
|
||||
|
||||
if (!$this->slider->isAdmin && !empty($this->from) && !empty($this->to)) {
|
||||
return str_replace($this->from, $this->to, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user